data analysis scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.4 KiB

  1. #include "hitreader.h"
  2. #include <string>
  3. #include <stdio.h>
  4. #include <iostream>
  5. #include <numeric>
  6. #include <vector>
  7. #include <algorithm> // std::count
  8. #include <utility>
  9. #include <TH2.h>
  10. #include <TF1.h>
  11. #include <TStyle.h>
  12. #include <TCanvas.h>
  13. #include <TFile.h>
  14. #include <TTree.h>
  15. #include <TSystemDirectory.h>
  16. #include <gsl/gsl_statistics.h>
  17. #include <math.h>
  18. #include <gsl/gsl_errno.h>
  19. #include <gsl/gsl_fft_complex.h>
  20. #include <TF1.h>
  21. #include <TGraphErrors.h>
  22. #include <gsl/gsl_sort.h>
  23. #include <TVector.h>
  24. #include "TStopwatch.h"
  25. #include "Math/MinimizerOptions.h"
  26. #include "TVirtualFitter.h"
  27. #include "TMatrixD.h"
  28. #include "TApplication.h"
  29. #include "TRint.h"
  30. #include "TSystem.h"
  31. #include "TMultiGraph.h"
  32. #include "TObject.h"
  33. //function declarations
  34. int analyse(int argc, char **argv);
  35. int opendatafiles(int argc, char ** argv);
  36. void histograms(int argc, char ** argv);
  37. int closedatafiles();
  38. int set_background_v2(int start_frame, int frames);
  39. //////global variables
  40. //opendatafiles
  41. long int fileframesize;
  42. char * filename;
  43. ifstream file;
  44. TFile *rootFile; //output root file
  45. TTree *rootTree;
  46. char * rootfilename;
  47. char * offsetfilename;
  48. ifstream offsetfile;
  49. struct bpm_frame_v2 {
  50. double channel_amp[320];
  51. double channel_position[320];
  52. double avg_position;
  53. double avg_width;
  54. double integratedsignalamp;
  55. int maxchannel;
  56. int nrChannels;
  57. int board_number;
  58. double maxchannel_amp;
  59. };
  60. bpm_frame_v2 board_b[4];
  61. bpm_frame_v2 board_b_bkg[4];
  62. bpm_frame_v2 readboard(Fullframe frame, int boardnumber);
  63. int framestart = 0;
  64. struct beamRecon {
  65. double Position;
  66. double Focus;
  67. double Peak;
  68. double Rsqr;
  69. double Skew;
  70. double Kurtosis;
  71. double Sum;
  72. int n_channels;
  73. };
  74. beamRecon beamreconstruction(bpm_frame_v2 frametoanalyse, double threshold);
  75. beamRecon BPMbeamrecon_0,BPMbeamrecon_1,BPMbeamrecon_2,BPMbeamrecon_3;
  76. beamRecon BPMbeamrecon_Zeroed;
  77. TGraph * board_graph = new TGraph(320);
  78. TF1 * beamrecon_function1 = new TF1("beamrecon_function1", "gaus(0)",0.,320.);
  79. class Channel{
  80. public:
  81. double amplitude;;
  82. double position;
  83. int chnumber;
  84. int last_neighbour;
  85. int next_neighbour;
  86. };
  87. bool CompareChannels(Channel A, Channel B);
  88. double avg ( vector<Channel> v );
  89. double variance ( vector<Channel> v , double mean );
  90. bool visualize = false;
  91. int eventID;
  92. ////histograms
  93. TH2D * TH2D_b0_signal_vs_channel;
  94. TH2D * TH2D_b1_signal_vs_channel;
  95. TH2D * TH2D_b2_signal_vs_channel;
  96. TH2D * TH2D_b3_signal_vs_channel;