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.

117 lines
2.3 KiB

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