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.

462 lines
20 KiB

  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <iostream>
  4. #include <vector>
  5. #include <utility>
  6. #include <TFile.h>
  7. #include <TTree.h>
  8. #include <TSystemDirectory.h>
  9. #include <string.h>
  10. #include <TFile.h>
  11. #include <TTree.h>
  12. #include <TH1.h>
  13. #include <TH2.h>
  14. #include <TNtuple.h>
  15. #include <iostream>
  16. #include <fstream>
  17. #include <TRandom.h>
  18. #include <TROOT.h>
  19. #include <algorithm>
  20. #include <assert.h>
  21. #include <math.h>
  22. #include <stdlib.h>
  23. #include <time.h>
  24. #include <sys/time.h>
  25. #include <TCanvas.h>
  26. #include <TF1.h>
  27. #include <TProfile.h>
  28. #include <TVectorD.h>
  29. #include <cstdlib>
  30. #include <cmath>
  31. #include <vector>
  32. #include <TApplication.h>
  33. using namespace std;
  34. int main(int argc, char **argv)
  35. {
  36. // Working directories
  37. const char *dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_01-12-2016/with_timestamp/";
  38. const char *listfile = NULL;
  39. int ion = atoi(argv[1]);
  40. if (ion==1) {listfile = "inlistE255_p";}
  41. else if (ion==2) {listfile = "inlistE21_p";}
  42. else if (ion==3) {listfile = "inlistE255_c";}
  43. else if (ion==4) {listfile = "inlistE21_c";}
  44. else {cerr<< argv[1] << " not allowed" << endl;
  45. cerr << "specify (1, 2, 3, or 4) for E255_p, E21_p, E255_c, or E21_c" << endl;
  46. return 1;
  47. }
  48. ifstream in;
  49. ofstream ic1energyfile,ic2energyfile, beamenergyfile,beamenergyfile_iccorr, noisefile, focusfile,focusHITfile, skewfile, kurtfile,focusFitfile,chi2Fitfile;
  50. ofstream ic1energyfile_diff, beamenergyfile_diff, focusFitfile_diff, posFitfile_diff, peakFitfile;
  51. TFile *f;
  52. TTree *tree;
  53. Int_t nfiles = 0;
  54. Int_t EList = 0;
  55. Double_t Energy = 0.;
  56. Double_t F1 = 0.;
  57. Double_t Intensity = 0.;
  58. Double_t SP = 0.;
  59. char Filename[50];
  60. Int_t id = 0;
  61. Double_t signalmean = 0.;
  62. Double_t signalmeanerror = 0.;
  63. Double_t signalmean_corr = 0.;
  64. Double_t signalmeanerror_corr = 0.;
  65. Double_t signalmean_offsetcorr = 0.;
  66. Double_t signalmeanerror_offsetcorr = 0.;
  67. Double_t ic1mean = 0.;
  68. Double_t ic1meanerror = 0.;
  69. Double_t ic2mean = 0.;
  70. Double_t ic2meanerror = 0.;
  71. Double_t sp_air = 0.;
  72. Double_t sp_ps = 0.;
  73. Double_t sp2_air = 0.;
  74. Double_t sp2_ps = 0.;
  75. Double_t ic_beam_ratio = 0.;
  76. Double_t ic_beam_ratioerror = 0.;
  77. Double_t totalcurrent = 0.;
  78. Double_t totaltime = 0.;
  79. Double_t intcorr = 0.;
  80. Double_t icbpmcorrelation = 0.;
  81. Double_t noisemean = 0.;
  82. Double_t noiseRMS = 0.;
  83. Double_t focusmean = 0.;
  84. Double_t focusRMS = 0.;
  85. Double_t skewmean = 0.;
  86. Double_t skewRMS = 0.;
  87. Double_t kurtmean = 0.;
  88. Double_t kurtRMS = 0.;
  89. Double_t focusFitmean = 0.;
  90. Double_t focusFitRMS = 0.;
  91. Double_t chi2Fitmean = 0.;
  92. Double_t chi2FitRMS = 0.;
  93. Double_t peakFitmean = 0.;
  94. Double_t peakFitRMS = 0.;
  95. Double_t focusdiffFitmean = 0.;
  96. Double_t focusdiffFitRMS = 0.;
  97. Double_t focusdiffFitmeanerror = 0.;
  98. Double_t focusdiffFitRMSerror = 0.;
  99. Double_t posdiffFitmean = 0.;
  100. Double_t posdiffFitRMS = 0.;
  101. Double_t posdiffFitmeanerror = 0.;
  102. Double_t posdiffFitRMSerror = 0.;
  103. Double_t signaldiffmean = 0.;
  104. Double_t signaldiffRMS = 0.;
  105. Double_t signaldiffmeanerror = 0.;
  106. Double_t signaldiffRMSerror = 0.;
  107. Double_t ic1diffmean = 0.;
  108. Double_t ic1diffRMS = 0.;
  109. Double_t ic1diffmeanerror = 0.;
  110. Double_t ic1diffRMSerror = 0.;
  111. Double_t focusdiffcorr = 0.;
  112. cout << "Trying to open"<< Form(": %s%s",dirname, listfile)<<"... " << endl;
  113. in.open(Form("%s%s.prn",dirname, listfile));
  114. ic1energyfile.open(Form("%s_ic1.txt",listfile ));
  115. ic2energyfile.open(Form("%s_ic1ratio.txt",listfile ));
  116. beamenergyfile.open(Form("%s_bpm1.txt",listfile ));
  117. beamenergyfile_iccorr.open(Form("%s_bpm1ratio.txt",listfile ));
  118. noisefile.open(Form("%s_noise.txt",listfile ));
  119. focusfile.open(Form("%s_focus1.txt",listfile ));
  120. focusHITfile.open(Form("%s_focusHIT.txt",listfile ));
  121. skewfile.open(Form("%s_skew1.txt",listfile ));
  122. kurtfile.open(Form("%s_kurt1.txt",listfile ));
  123. focusFitfile.open(Form("%s_focusfit.txt",listfile ));
  124. chi2Fitfile.open(Form("%s_chi2fit.txt",listfile ));
  125. ic1energyfile_diff.open(Form("%s_ic1_diff.txt",listfile ));
  126. beamenergyfile_diff.open(Form("%s_bpm1_diff.txt",listfile ));
  127. focusFitfile_diff.open(Form("%s_focusfit_diff.txt",listfile ));
  128. posFitfile_diff.open(Form("%s_posfit_diff.txt",listfile ));
  129. peakFitfile.open(Form("%s_peakfit.txt",listfile ));
  130. TF1 * f_sp_air = new TF1("f_sp_air","[0]*pow(x,[1])+[2]", 50, 250); //stopping power of protons in Air [MeV cm2 /g]
  131. f_sp_air->SetParameters(303.746, -0.873697,1.01335); //protons between 50 and 300 MeV
  132. TF1 * f_sp_ps = new TF1("f_sp_ps","[0]*pow(x,[1])+[2]", 50, 250); //stopping power of protons in polystyrene [MeV cm2 /g]
  133. f_sp_ps->SetParameters(361.936, -0.892255, 1.19133); //protons between 50 and 220 MeV
  134. TF1 * f_h2sp_air = new TF1("f_h2sp_air","[0]*pow(x,[1])+[2]", 50, 250); //stopping power of helium in air [MeV cm2 /g]
  135. f_h2sp_air->SetParameters(1236.51, -0.880225, 4.17041); //helium between 50 and 300 MeV
  136. TF1 * f_h2sp_ps = new TF1("f_h2sp_ps","[0]*pow(x,[1])+[2]", 50, 250); //stopping power of helium in polystyrene [MeV cm2 /g]
  137. f_h2sp_ps->SetParameters(1387.08, -0.882686,4.60833); //heelium between 50 and 300 MeV
  138. TF1 * f_c12sp_air = new TF1("f_c12sp_air","[0]*pow(x,[1])+[2]", 80, 480); //stopping power of carbon in air [MeV cm2 /g]
  139. f_c12sp_air->SetParameters(13291.2, -0.925464,45.3876); //carbon between 80 and 480 MeV
  140. TF1 * f_c12sp_ps = new TF1("f_c12sp_ps","[0]*pow(x,[1])+[2]", 80, 480); //stopping power of carbon in polystyrene [MeV cm2 /g]
  141. f_c12sp_ps->SetParameters(14538.9, -0.922423,49.2859); //carbon between 80 and 480 MeV
  142. TF1 * f_o16sp_air = new TF1("f_o16sp_air","[0]*pow(x,[1])+[2]", 80, 480); //stopping power of oxygen in air [MeV cm2 /g]
  143. f_o16sp_air->SetParameters(24624.9, -0.925425,80.6828); //oxygen between 80 and 480 MeV
  144. TF1 * f_o16sp_ps = new TF1("f_o16sp_ps","[0]*pow(x,[1])+[2]", 80,480); //stopping power of oxygen in polystyrene [MeV cm2 /g]
  145. f_o16sp_ps->SetParameters(26465.6, -0.928309,88.6728); //oxygen between 80 and 480 MeV
  146. ///// ic1/SP intensity correction factor = 19.8E6+/-0.1E6 particles/s per nA/(Mevcm2/g)
  147. if (!in) {
  148. cout << Form("%s%s",dirname, listfile) << " not found." << endl;
  149. return 0;}
  150. cout << Form("%s%s",dirname, listfile) << " opened." << endl;
  151. in >> EList >> Energy >> F1 >> Intensity >> SP >> Filename >> id;//prime the while loop
  152. while (!in.eof()) {
  153. TFile * file = TFile::Open(Form("%s%s",dirname,Filename));
  154. TFile * outfile = TFile::Open(Form("plots/%s_plots",Filename),"RECREATE");
  155. cout << Filename << endl;
  156. // TH1D* signalDist = 0;
  157. // file->GetObject("signalDist",signalDist);
  158. // signalmean = signalDist->GetMean();
  159. // signalmeanerror = signalDist->GetMeanError();
  160. // cout << signalmean << " " << signalmeanerror << endl;
  161. // delete signalDist;
  162. // TCanvas *c1 = new TCanvas("c1");
  163. TTree *data;
  164. file->GetObject("newdata", data);
  165. TH2D *h_beamSignal_channel = (TH2D*)file->Get("th2d_beamSignal_channel");
  166. TH2D *h_bkg_channel = (TH2D*)file->Get("th2d_bkg_channel");
  167. noisemean = h_bkg_channel->GetMean(2);
  168. noiseRMS = h_bkg_channel->GetRMS(2);
  169. TF1 * f1 = new TF1("f1", "gaus(0)",-5,5);
  170. TVectorD *v = (TVectorD*)file->Get("icinfo");
  171. // v->Print();
  172. totalcurrent = (*v)[0];
  173. totaltime = (*v)[1];
  174. // data->Print();
  175. TH1D* h_beamSignal_1 = new TH1D("h_beamSignal_1","h_beamSignal_1",510,-500,50000);
  176. TH1D* h_ic1_1 = new TH1D("h_ic1_1","h_ic1_1",510,-50,500);
  177. TH1D* h_ic2_1 = new TH1D("h_ic2_1","h_ic2_1",510,-50,500);
  178. TH1D* h_beamSignal_diff = new TH1D("h_beamSignal_diff","h_beamSignal_diff",200,-1.5,1.5);
  179. TH1D* h_ic1_diff = new TH1D("h_ic1_diff","h_ic1_diff",200,-0.5,0.5);
  180. TH1D* h_ic_beam_ratio = new TH1D("h_ic_beam_ratio","h_ic_beam_ratio",500,0,500.);
  181. TH2D* h_beamSignal_v_ic = new TH2D("h_beamSignal_v_ic","h_beamSignal_v_ic",510,-50,500,510,-500,50000);
  182. TH2D* h_beamSignal_v_beamSignal2 = new TH2D("h_beamSignal_v_beamSignal2","h_beamSignal_v_beamSignal2",510,-500,50000,510,-500,50000);
  183. TH1D* h_beamFocusX_1 = new TH1D("h_beamFocusX_1","h_beamFocusX_1",200,0,50.);
  184. TH1D* h_beamSkewX_1 = new TH1D("h_beamSkewX_1","h_beamSkewX_1",200,0,50.);
  185. TH1D* h_beamKurtX_1 = new TH1D("h_beamKurtX_1","h_beamKurtX_1",200,0,50.);
  186. TH1D* h_beamFocusX_fit = new TH1D("h_beamFocusX_fit","h_beamFocusX_fit",200,0,50.);
  187. TH1D* h_beamChi2_fit = new TH1D("h_beamChi2_fit","h_beamChi2_fit",200,0,50.);
  188. TH1D* h_beamChi2_fit2 = new TH1D("h_beamChi2_fit2","h_beamChi2_fit2",200,0,50.);
  189. TH1D* h_beamFocusX_corr = new TH1D("h_beamFocusX_corr","h_beamFocusX_corr",200,0.0,2.0);
  190. // TH1D* h_beamFocusX_diff = new TH1D("h_beamFocusX_diff","h_beamFocusX_diff",200,-.4,0.4);
  191. TH1D* h_beamFocusX_diff = new TH1D("h_beamFocusX_diff","h_beamFocusX_diff",2000,-20,20);
  192. TH1D* h_beamPosX_diff = new TH1D("h_beamPosX_diff","h_beamPosX_diff",400,-5.,5.);
  193. Double_t peak = 0.;
  194. TH1D* h_beamPeakX_fit = new TH1D("h_beamPeakX_fit","h_beamPeakX_fit",1000,0,8000.);
  195. if (id>=0&&id<=26){
  196. sp_air = f_sp_air->Eval(Energy)*(Intensity/1.0E6);
  197. sp_ps = f_sp_ps->Eval(Energy)*(Intensity/1.0E6);
  198. sp2_air = f_sp_air->Eval(Energy);
  199. sp2_ps = f_sp_ps->Eval(Energy);
  200. }
  201. else if (id>=27&&id<=52){
  202. sp_air = f_h2sp_air->Eval(Energy)*(Intensity/1.0E6);
  203. sp_ps = f_h2sp_ps->Eval(Energy)*(Intensity/1.0E6);
  204. sp2_air = f_h2sp_air->Eval(Energy);
  205. sp2_ps = f_h2sp_ps->Eval(Energy);
  206. }
  207. else if (id>=53&&id<=78){
  208. sp_air = f_c12sp_air->Eval(Energy)*(Intensity/1.0E6);
  209. sp_ps = f_c12sp_ps->Eval(Energy)*(Intensity/1.0E6);
  210. sp2_air = f_c12sp_air->Eval(Energy);
  211. sp2_ps = f_c12sp_ps->Eval(Energy);
  212. }
  213. else if (id>=79&&id<=99){
  214. sp_air = f_o16sp_air->Eval(Energy)*(Intensity/1.0E6);
  215. sp_ps = f_o16sp_ps->Eval(Energy)*(Intensity/1.0E6);
  216. sp2_air = f_o16sp_air->Eval(Energy);
  217. sp2_ps = f_o16sp_ps->Eval(Energy);
  218. }
  219. else {
  220. sp_air = -1.;
  221. sp_ps = -1.;
  222. sp2_air = -1.;
  223. sp2_ps = -1.;
  224. }
  225. // cout << Form("beamPeakX_fit*sqrt(2)*%F/2.3548",F1) << endl;
  226. // data->Project("h_beamSignal_1","beamSignal_1","beamon==1&&beamSignal_1>50");
  227. // data->Project("h_beamSignal_1", Form("beamPeakX_fit*sqrt(2)*%F/2.3548",F1) ,"beamon==1&&ic1_1>0.005&&beamChi2_fit<200&&beamPeakX_fit>20");
  228. data->Project("h_beamSignal_1", "beamPeakX_fit*sqrt(2)*beamFocusX_fit/2.3548" ,"beamon==1&&ic1_1>0.001&&beamChi2_fit<200&&beamPeakX_fit>20");
  229. //second layer shows a factor 1.08 more signal
  230. data->Project("h_beamSignal_diff", "((beamPeakX_fit*sqrt(2)*beamFocusX_fit/2.3548) - (beamPeakX_fit2*sqrt(2)*beamFocusX_fit2/2.3548)/1.08)/(beamPeakX_fit*sqrt(2)*beamFocusX_fit/2.3548)" ,"beamon==1&&ic1_1>0.001&&beamChi2_fit<200&&beamChi2_fit2<200&&beamPeakX_fit>20&&beamPeakX_fit2>20");
  231. data->Project("h_ic1_diff", " 2*(ic1_1 -ic2_1)/(ic1_1 +ic2_1)" ,"beamon==1&&ic1_1>0.001&&ic2_1>0.001&&beamChi2_fit<200&&beamChi2_fit2<200&&beamPeakX_fit>20&&beamPeakX_fit2>20");
  232. data->Project("h_beamFocusX_1","beamFocusX_1","beamon==1&&ic1_1>0.05");
  233. data->Project("h_beamFocusX_corr","(beamFocusX_fit/beamFocusX_fit2)","beamon==1&&ic1_1>0.005&&beamChi2_fit<200&&beamChi2_fit2<200&&beamPeakX_fit>20&&beamPeakX_fit2>20");
  234. focusdiffcorr = h_beamFocusX_corr->GetMean();
  235. data->Project("h_beamSkewX_1","beamSkewX_1","beamon==1&&ic1_1>0.005");
  236. data->Project("h_beamKurtX_1","beamKurtX_1","beamon==1&&ic1_1>0.005");
  237. data->Project("h_beamFocusX_fit","beamFocusX_fit","beamon==1&&ic1_1>0.005&&beamChi2_fit<200&&beamPeakX_fit>20");
  238. data->Project("h_beamChi2_fit","beamChi2_fit","beamon==1&&ic1_1>0.005&&beamChi2_fit<200&&beamPeakX_fit>20");
  239. // data->Project("h_beamFocusX_diff",Form("(beamFocusX_fit/%f-beamFocusX_fit2)/((beamFocusX_fit/%f+beamFocusX_fit2)/2)",focusdiffcorr,focusdiffcorr),"beamon==1&&ic1_1>0.005&&beamChi2_fit<200&&beamChi2_fit2<200&&beamPeakX_fit>20&&beamPeakX_fit2>20");
  240. data->Project("h_beamFocusX_diff",Form("beamFocusX_fit/%f-beamFocusX_fit2",focusdiffcorr),"beamon==1&&ic1_1>0.005&&beamChi2_fit<200&&beamChi2_fit2<200&&beamPeakX_fit>20&&beamPeakX_fit2>20");
  241. data->Project("h_beamPosX_diff","beamPosX_fit2+beamPosX_fit-128","beamon==1&&ic1_1>0.005&&beamChi2_fit<200&&beamChi2_fit2<200&&beamPeakX_fit>20&&beamPeakX_fit2>20");
  242. data->Project("h_beamPeakX_fit","beamPeakX_fit","beamon==1&&ic1_1>0.005&&beamChi2_fit<200&&beamPeakX_fit>20");
  243. peakFitmean = h_beamPeakX_fit->GetMean();
  244. peakFitRMS = h_beamPeakX_fit->GetRMS();
  245. focusmean = h_beamFocusX_1->GetMean();
  246. focusRMS = h_beamFocusX_1->GetRMS();
  247. peak = h_beamFocusX_diff->GetEntries()*sqrt(2)*(h_beamFocusX_diff->GetRMS());
  248. f1->SetParameters(200,h_beamFocusX_diff->GetMean(),h_beamFocusX_diff->GetRMS());
  249. f1->SetParLimits(0,0,100000);
  250. f1->SetParLimits(1,-10,10);
  251. f1->SetParLimits(2,0,5);
  252. h_beamFocusX_diff->Fit(f1,"");
  253. // focusdiffFitmean = h_beamFocusX_diff->GetMean();
  254. // focusdiffFitmeanerror = h_beamFocusX_diff->GetMeanError();
  255. focusdiffFitmean =f1->GetParameter(1);
  256. focusdiffFitmeanerror = f1->GetParError(1);
  257. focusdiffFitRMS =f1->GetParameter(2);
  258. focusdiffFitRMSerror =f1->GetParError(2);
  259. // focusdiffFitRMS = h_beamFocusX_diff->GetRMS();
  260. // focusdiffFitRMSerror = h_beamFocusX_diff->GetRMSError();
  261. peak = h_beamPosX_diff->GetEntries()*sqrt(2)*(h_beamPosX_diff->GetRMS());
  262. f1->SetParameters(peak, h_beamPosX_diff->GetMean(),h_beamPosX_diff->GetRMS());
  263. h_beamPosX_diff->Fit(f1,"Q");
  264. // posdiffFitmean = h_beamPosX_diff->GetMean();
  265. // posdiffFitmeanerror = h_beamPosX_diff->GetMeanError();
  266. // posdiffFitRMS = h_beamPosX_diff->GetRMS();
  267. // posdiffFitRMSerror = h_beamPosX_diff->GetRMSError();
  268. posdiffFitmean =f1->GetParameter(1);
  269. posdiffFitmeanerror = f1->GetParError(1);
  270. posdiffFitRMS =f1->GetParameter(2);
  271. posdiffFitRMSerror =f1->GetParError(2);
  272. skewmean = h_beamSkewX_1->GetMean();
  273. skewRMS = h_beamSkewX_1->GetRMS();
  274. kurtmean = h_beamKurtX_1->GetMean();
  275. kurtRMS = h_beamKurtX_1->GetRMS();
  276. focusFitmean = h_beamFocusX_fit->GetMean();
  277. focusFitRMS = h_beamFocusX_fit->GetRMS();
  278. chi2Fitmean = h_beamChi2_fit->GetMean();
  279. chi2FitRMS = h_beamChi2_fit->GetRMS();
  280. data->Project("h_ic1_1","ic1_1","ic1_1>0.01");
  281. data->Project("h_ic2_1","ic2_1","ic2_1>0.01");
  282. data->Project("h_ic1_diff","(ic1_1-ic2_1)/ic1_1","ic1_1>0.01&&ic2_1>0.01");
  283. data->Project("h_beamSignal_v_ic","(beamPeakX_fit*sqrt(2)*beamFocusX_fit/2.3548):ic1_1","beamon==1&&ic1_1>0.005&&beamChi2_fit<200&&beamPeakX_fit>20");
  284. icbpmcorrelation = h_beamSignal_v_ic->GetCorrelationFactor();
  285. data->Project("h_ic_beam_ratio","(beamPeakX_fit*sqrt(2)*beamFocusX_fit/2.3548)/ic1_1","beamon==1&&ic1_1>0.005&&beamChi2_fit<200&&beamPeakX_fit>20");
  286. signalmean = h_beamSignal_1->GetMean();
  287. signalmeanerror = h_beamSignal_1->GetMeanError();
  288. peak = h_beamSignal_diff->GetEntries()*sqrt(2)*(h_beamSignal_diff->GetRMS());
  289. f1->SetParameters(peak, h_beamSignal_diff->GetMean(), h_beamSignal_diff->GetRMS());
  290. h_beamSignal_diff->Fit(f1,"Q");
  291. // signaldiffmean = h_beamSignal_diff->GetMean();
  292. // signaldiffmeanerror = h_beamSignal_diff->GetMeanError();
  293. // signaldiffRMS = h_beamSignal_diff->GetRMS();
  294. // signaldiffRMSerror = h_beamSignal_diff->GetRMSError();
  295. signaldiffmean =f1->GetParameter(1);
  296. signaldiffmeanerror = f1->GetParError(1);
  297. signaldiffRMS =f1->GetParameter(2);
  298. signaldiffRMSerror =f1->GetParError(2);
  299. ic1mean = h_ic1_1->GetMean();
  300. ic1meanerror = h_ic1_1->GetMeanError();
  301. // peak = h_ic1_diff->GetEntries()*sqrt(2)*(h_ic1_diff->GetRMS());
  302. //f1->SetParameters(peak, h_ic1_diff->GetMean(), h_ic1_diff->GetRMS());
  303. // h_ic1_diff->Fit(f1,"");
  304. ic1diffmean = h_ic1_diff->GetMean();
  305. ic1diffmeanerror = h_ic1_diff->GetMeanError();
  306. ic1diffRMS = h_ic1_diff->GetRMS();
  307. ic1diffRMSerror = h_ic1_diff->GetRMSError();
  308. // ic1diffmean =f1->GetParameter(1);
  309. // ic1diffmeanerror = f1->GetParError(1);
  310. // ic1diffRMS =f1->GetParameter(2);
  311. // ic1diffRMSerror =f1->GetParError(2);
  312. ic2mean = h_ic2_1->GetMean();
  313. ic2meanerror = h_ic2_1->GetMeanError();
  314. ic_beam_ratio=h_ic_beam_ratio->GetMean();
  315. ic_beam_ratioerror=h_ic_beam_ratio->GetRMS();
  316. // intcorr = (Intensity /19.8E6) / (totalcurrent/sp2_air/totaltime);
  317. intcorr = (Intensity / 19.8E6) / (ic1mean/sp2_air)/ 3.11;
  318. cout << id << " " <<sp2_air << " " << ic1mean/sp2_air << " " << intcorr << endl;
  319. // cout << id <<" " << sp2_ps << " " <<signalmean/(Intensity/1.0E6)/(ic1mean/sp_air) << " " << signalmeanerror/(Intensity/1.0E6)/(ic1mean/sp_air) << endl;
  320. ic1energyfile << Intensity/1.0E6*intcorr << " " << ic1mean *intcorr << " " << ic1meanerror*intcorr<< " " << Filename << endl;
  321. // ic2energyfile << Intensity/1.0E6*intcorr << " " << ic2mean / (Intensity/1.0E6) / (0.659869 + 1.50842 * sp2_air) << " " << ic2meanerror/sp_air << " " << Filename << endl;
  322. beamenergyfile << Intensity/1.0E6*intcorr << " " << signalmean*intcorr << " " << signalmeanerror*intcorr << endl;
  323. beamenergyfile_iccorr << Intensity/1.0E6*intcorr << " " << (ic_beam_ratio*sp2_air/sp2_ps)/84.5 << " " << (ic_beam_ratioerror*sp2_air/sp2_ps)/84.5 << endl;
  324. ic2energyfile << Intensity/1.0E6*intcorr << " " << icbpmcorrelation << endl;
  325. noisefile << Intensity/1.0E6*intcorr << " " << noisemean << " " << noiseRMS << endl;
  326. focusfile << Intensity/1.0E6*intcorr << " " << focusmean*0.8 << " " << focusRMS*0.8 << endl;
  327. focusHITfile << Intensity/1.0E6*intcorr << " " << F1 << endl;
  328. skewfile << Intensity/1.0E6*intcorr << " " << skewmean << " " << skewRMS << endl;
  329. kurtfile << Intensity/1.0E6*intcorr << " " << kurtmean << " " << kurtRMS << endl;
  330. focusFitfile << Intensity/1.0E6*intcorr << " " << focusFitmean*0.8 << " " << focusFitRMS*0.8 << endl;
  331. chi2Fitfile << Intensity/1.0E6*intcorr << " " << chi2Fitmean << " " << chi2FitRMS << endl;
  332. ic1energyfile_diff << Intensity/1.0E6*intcorr << " " << ic1diffRMS/sqrt(2) << " " << ic1diffRMSerror/sqrt(2) << " " << Filename << endl;
  333. beamenergyfile_diff << Intensity/1.0E6*intcorr << " " << signaldiffRMS/sqrt(2) << " " << signaldiffRMSerror/sqrt(2) << endl;
  334. // focusFitfile_diff << Intensity/1.0E6*intcorr << " " << focusdiffFitRMS*0.8/sqrt(2) << " " << focusdiffFitRMSerror*0.8/sqrt(2) << endl;
  335. focusFitfile_diff << Intensity/1.0E6*intcorr << " " << focusdiffFitRMS/sqrt(2) << " " << focusdiffFitRMSerror/sqrt(2) << endl;
  336. posFitfile_diff << Intensity/1.0E6*intcorr << " " << posdiffFitRMS*0.8/sqrt(2) << " " << posdiffFitRMSerror*0.8/sqrt(2) << endl;
  337. peakFitfile << Intensity/1.0E6*intcorr << " " << (peakFitmean/2.)/6.7 << " " << (peakFitRMS/2.)/6.7 << endl;
  338. // h_beamSignal_1->Draw("");
  339. // c1->SaveAs(Form("figs/h_beamsignal_%i.pdf",nfiles));
  340. // c1->Destructor();
  341. // f->Close();
  342. outfile->Write();
  343. outfile->Close();
  344. file->Close();
  345. in >> EList >> Energy >> F1 >> Intensity >> SP >> Filename >> id;
  346. // cout << EList << Energy << F1 << Intensity << SP << Filename << id << endl;
  347. nfiles++;
  348. }
  349. ic1energyfile.close();
  350. ic2energyfile.close();
  351. beamenergyfile.close();
  352. beamenergyfile_iccorr.close();
  353. noisefile.close();
  354. focusfile.close();
  355. focusHITfile.close();
  356. skewfile.close();
  357. kurtfile.close();
  358. in.close();
  359. focusFitfile.close();
  360. chi2Fitfile.close();
  361. ic1energyfile_diff.close();
  362. focusFitfile_diff.close();
  363. beamenergyfile_diff.close();
  364. posFitfile_diff.close();
  365. return 0;
  366. }