Browse Source

all files first push

master
Blake Leverington 4 years ago
parent
commit
af0b3f1ed4
  1. 2017
      Scripts_20161126/#beammon.h#
  2. 385
      Scripts_20161126/50Hzbackground.C
  3. BIN
      Scripts_20161126/50Hzbackground.pdf
  4. 83
      Scripts_20161126/Makefile
  5. 14
      Scripts_20161126/Readme.txt
  6. BIN
      Scripts_20161126/analyse
  7. 52
      Scripts_20161126/analyse.c
  8. BIN
      Scripts_20161126/analyse2
  9. 327
      Scripts_20161126/analyse2.c
  10. 140
      Scripts_20161126/analyse2.c_old
  11. 919
      Scripts_20161126/analyse2.h
  12. 565
      Scripts_20161126/analyse2.h_old
  13. BIN
      Scripts_20161126/analyse_batch
  14. 50
      Scripts_20161126/analyse_batch.c
  15. 1839
      Scripts_20161126/analyselog.txt
  16. 99
      Scripts_20161126/beamenergyfile.txt
  17. 99
      Scripts_20161126/beamenergyfile_iccorr.txt
  18. 9
      Scripts_20161126/beamenergyfile_iccorr_int_c.txt
  19. 10
      Scripts_20161126/beamenergyfile_iccorr_int_p.txt
  20. 9
      Scripts_20161126/beamenergyfile_int_c.txt
  21. 10
      Scripts_20161126/beamenergyfile_int_p.txt
  22. 2170
      Scripts_20161126/beammon.h
  23. 2170
      Scripts_20161126/beammon.h_old
  24. 170
      Scripts_20161126/beamprofileplot.C
  25. 206
      Scripts_20161126/beamprofileplot_avg.C
  26. 26
      Scripts_20161126/betadedxz2_c.prn
  27. 26
      Scripts_20161126/betadedxz2_he.prn
  28. 21
      Scripts_20161126/betadedxz2_o.prn
  29. 26
      Scripts_20161126/betadedxz2_p.prn
  30. 99
      Scripts_20161126/betadedxz2_sum.prn
  31. 19
      Scripts_20161126/carbonAIR_80_480MeV.txt
  32. 18
      Scripts_20161126/carbonPS_80_480MeV.txt
  33. 99
      Scripts_20161126/chi2Fitfile.txt
  34. 9
      Scripts_20161126/chi2Fitfile_int_c.txt
  35. 10
      Scripts_20161126/chi2Fitfile_int_p.txt
  36. 145
      Scripts_20161126/combinedFit.C
  37. 288
      Scripts_20161126/combinedFit_hit.C
  38. 282
      Scripts_20161126/combinedFit_hit2.C
  39. BIN
      Scripts_20161126/combinedFit_hit2_C_ACLiC_dict_rdict.pcm
  40. BIN
      Scripts_20161126/combinedFit_hit_C_ACLiC_dict_rdict.pcm
  41. 273
      Scripts_20161126/combinedFit_hitbirk.C
  42. BIN
      Scripts_20161126/combinedFit_hitbirk_C_ACLiC_dict_rdict.pcm
  43. BIN
      Scripts_20161126/convert
  44. 213
      Scripts_20161126/convert.c
  45. BIN
      Scripts_20161126/convert_batch
  46. 248
      Scripts_20161126/convert_batch.c
  47. 220
      Scripts_20161126/convert_batch.c_old
  48. 26
      Scripts_20161126/energylist_c_bpm1.txt
  49. 26
      Scripts_20161126/energylist_c_bpm1ratio.txt
  50. 26
      Scripts_20161126/energylist_c_bpmbeta1.txt
  51. 26
      Scripts_20161126/energylist_c_chi2fit.txt
  52. 26
      Scripts_20161126/energylist_c_focus1.txt
  53. 26
      Scripts_20161126/energylist_c_focusHIT.txt
  54. 26
      Scripts_20161126/energylist_c_focusfit.txt
  55. 26
      Scripts_20161126/energylist_c_ic1.txt
  56. 26
      Scripts_20161126/energylist_c_ic1ratio.txt
  57. 26
      Scripts_20161126/energylist_c_kurt1.txt
  58. 26
      Scripts_20161126/energylist_c_noise.txt
  59. 26
      Scripts_20161126/energylist_c_skew1.txt
  60. 26
      Scripts_20161126/energylist_he_bpm1.txt
  61. 26
      Scripts_20161126/energylist_he_bpm1ratio.txt
  62. 26
      Scripts_20161126/energylist_he_bpmbeta1.txt
  63. 26
      Scripts_20161126/energylist_he_chi2fit.txt
  64. 26
      Scripts_20161126/energylist_he_focus1.txt
  65. 26
      Scripts_20161126/energylist_he_focusHIT.txt
  66. 26
      Scripts_20161126/energylist_he_focusfit.txt
  67. 26
      Scripts_20161126/energylist_he_ic1.txt
  68. 26
      Scripts_20161126/energylist_he_ic1ratio.txt
  69. 26
      Scripts_20161126/energylist_he_kurt1.txt
  70. 26
      Scripts_20161126/energylist_he_noise.txt
  71. 26
      Scripts_20161126/energylist_he_skew1.txt
  72. 21
      Scripts_20161126/energylist_o_bpm1.txt
  73. 21
      Scripts_20161126/energylist_o_bpm1ratio.txt
  74. 21
      Scripts_20161126/energylist_o_bpmbeta1.txt
  75. 21
      Scripts_20161126/energylist_o_chi2fit.txt
  76. 21
      Scripts_20161126/energylist_o_focus1.txt
  77. 21
      Scripts_20161126/energylist_o_focusHIT.txt
  78. 21
      Scripts_20161126/energylist_o_focusfit.txt
  79. 21
      Scripts_20161126/energylist_o_ic1.txt
  80. 21
      Scripts_20161126/energylist_o_ic1ratio.txt
  81. 21
      Scripts_20161126/energylist_o_kurt1.txt
  82. 21
      Scripts_20161126/energylist_o_noise.txt
  83. 21
      Scripts_20161126/energylist_o_skew1.txt
  84. 26
      Scripts_20161126/energylist_p_bpm1.txt
  85. 26
      Scripts_20161126/energylist_p_bpm1ratio.txt
  86. 26
      Scripts_20161126/energylist_p_bpmbeta1.txt
  87. 26
      Scripts_20161126/energylist_p_chi2fit.txt
  88. 26
      Scripts_20161126/energylist_p_focus1.txt
  89. 26
      Scripts_20161126/energylist_p_focusHIT.txt
  90. 26
      Scripts_20161126/energylist_p_focusfit.txt
  91. 26
      Scripts_20161126/energylist_p_ic1.txt
  92. 26
      Scripts_20161126/energylist_p_ic1ratio.txt
  93. 26
      Scripts_20161126/energylist_p_kurt1.txt
  94. 26
      Scripts_20161126/energylist_p_noise.txt
  95. 26
      Scripts_20161126/energylist_p_skew1.txt
  96. 123
      Scripts_20161126/figs/beamenergyfile_int_c.C
  97. BIN
      Scripts_20161126/figs/beamenergyfile_int_c.pdf
  98. BIN
      Scripts_20161126/figs/beamenergyfile_int_c.png
  99. 127
      Scripts_20161126/figs/beamenergyfile_int_p.C
  100. BIN
      Scripts_20161126/figs/beamenergyfile_int_p.pdf

2017
Scripts_20161126/#beammon.h#
File diff suppressed because it is too large
View File

385
Scripts_20161126/50Hzbackground.C

@ -0,0 +1,385 @@
{
//=========Macro generated from canvas: Canvas_1/Canvas_1
//========= (Thu Oct 12 16:44:34 2017) by ROOT version5.34/32
TCanvas *Canvas_1 = new TCanvas("Canvas_1", "Canvas_1",303,169,363,321);
gStyle->SetOptFit(1);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
Canvas_1->Range(-0.0125,522.4648,0.1125,613.8474);
Canvas_1->SetFillColor(0);
Canvas_1->SetBorderMode(0);
Canvas_1->SetBorderSize(2);
Canvas_1->SetFrameBorderMode(0);
Canvas_1->SetFrameBorderMode(0);
TProfile *h4_pfx = new TProfile("h4_pfx","ch63:(time-6021800)/1000 {time>6021800&&ic1<5}",100,0,0.1,"");
h4_pfx->SetBinEntries(1,2);
h4_pfx->SetBinEntries(2,1);
h4_pfx->SetBinEntries(3,2);
h4_pfx->SetBinEntries(4,2);
h4_pfx->SetBinEntries(5,2);
h4_pfx->SetBinEntries(6,2);
h4_pfx->SetBinEntries(7,2);
h4_pfx->SetBinEntries(8,2);
h4_pfx->SetBinEntries(9,2);
h4_pfx->SetBinEntries(10,2);
h4_pfx->SetBinEntries(11,2);
h4_pfx->SetBinEntries(12,3);
h4_pfx->SetBinEntries(13,2);
h4_pfx->SetBinEntries(14,2);
h4_pfx->SetBinEntries(15,2);
h4_pfx->SetBinEntries(16,2);
h4_pfx->SetBinEntries(17,2);
h4_pfx->SetBinEntries(18,2);
h4_pfx->SetBinEntries(19,2);
h4_pfx->SetBinEntries(20,2);
h4_pfx->SetBinEntries(21,2);
h4_pfx->SetBinEntries(22,2);
h4_pfx->SetBinEntries(23,2);
h4_pfx->SetBinEntries(24,2);
h4_pfx->SetBinEntries(25,2);
h4_pfx->SetBinEntries(26,2);
h4_pfx->SetBinEntries(27,2);
h4_pfx->SetBinEntries(28,2);
h4_pfx->SetBinEntries(29,2);
h4_pfx->SetBinEntries(30,2);
h4_pfx->SetBinEntries(31,2);
h4_pfx->SetBinEntries(32,2);
h4_pfx->SetBinEntries(33,2);
h4_pfx->SetBinEntries(34,2);
h4_pfx->SetBinEntries(35,2);
h4_pfx->SetBinEntries(36,2);
h4_pfx->SetBinEntries(37,2);
h4_pfx->SetBinEntries(38,1);
h4_pfx->SetBinEntries(39,2);
h4_pfx->SetBinEntries(40,2);
h4_pfx->SetBinEntries(41,2);
h4_pfx->SetBinEntries(42,2);
h4_pfx->SetBinEntries(43,2);
h4_pfx->SetBinEntries(44,2);
h4_pfx->SetBinEntries(45,2);
h4_pfx->SetBinEntries(46,2);
h4_pfx->SetBinEntries(47,3);
h4_pfx->SetBinEntries(48,2);
h4_pfx->SetBinEntries(49,2);
h4_pfx->SetBinEntries(50,2);
h4_pfx->SetBinEntries(51,2);
h4_pfx->SetBinEntries(52,2);
h4_pfx->SetBinEntries(53,2);
h4_pfx->SetBinEntries(54,2);
h4_pfx->SetBinEntries(55,2);
h4_pfx->SetBinEntries(56,2);
h4_pfx->SetBinEntries(57,2);
h4_pfx->SetBinEntries(58,2);
h4_pfx->SetBinEntries(59,2);
h4_pfx->SetBinEntries(60,2);
h4_pfx->SetBinEntries(61,2);
h4_pfx->SetBinEntries(62,2);
h4_pfx->SetBinEntries(63,2);
h4_pfx->SetBinEntries(64,2);
h4_pfx->SetBinEntries(65,2);
h4_pfx->SetBinEntries(66,2);
h4_pfx->SetBinEntries(67,2);
h4_pfx->SetBinEntries(68,2);
h4_pfx->SetBinEntries(69,2);
h4_pfx->SetBinEntries(70,2);
h4_pfx->SetBinEntries(71,2);
h4_pfx->SetBinEntries(72,2);
h4_pfx->SetBinEntries(73,2);
h4_pfx->SetBinEntries(74,1);
h4_pfx->SetBinEntries(75,2);
h4_pfx->SetBinEntries(76,2);
h4_pfx->SetBinEntries(77,2);
h4_pfx->SetBinEntries(78,2);
h4_pfx->SetBinEntries(79,2);
h4_pfx->SetBinEntries(80,2);
h4_pfx->SetBinEntries(81,2);
h4_pfx->SetBinEntries(82,2);
h4_pfx->SetBinEntries(83,3);
h4_pfx->SetBinEntries(84,2);
h4_pfx->SetBinEntries(85,2);
h4_pfx->SetBinEntries(86,2);
h4_pfx->SetBinEntries(87,2);
h4_pfx->SetBinEntries(88,2);
h4_pfx->SetBinEntries(89,2);
h4_pfx->SetBinEntries(90,2);
h4_pfx->SetBinEntries(91,2);
h4_pfx->SetBinEntries(92,2);
h4_pfx->SetBinEntries(93,2);
h4_pfx->SetBinEntries(94,2);
h4_pfx->SetBinEntries(95,2);
h4_pfx->SetBinEntries(96,2);
h4_pfx->SetBinEntries(97,2);
h4_pfx->SetBinEntries(98,2);
h4_pfx->SetBinEntries(99,2);
h4_pfx->SetBinEntries(100,2);
h4_pfx->SetBinContent(1,1097);
h4_pfx->SetBinContent(2,567.5);
h4_pfx->SetBinContent(3,1112);
h4_pfx->SetBinContent(4,1107);
h4_pfx->SetBinContent(5,1101);
h4_pfx->SetBinContent(6,1109);
h4_pfx->SetBinContent(7,1125);
h4_pfx->SetBinContent(8,1145);
h4_pfx->SetBinContent(9,1158);
h4_pfx->SetBinContent(10,1155);
h4_pfx->SetBinContent(11,1168);
h4_pfx->SetBinContent(12,1762.5);
h4_pfx->SetBinContent(13,1148);
h4_pfx->SetBinContent(14,1154);
h4_pfx->SetBinContent(15,1167);
h4_pfx->SetBinContent(16,1149);
h4_pfx->SetBinContent(17,1138);
h4_pfx->SetBinContent(18,1131);
h4_pfx->SetBinContent(19,1113);
h4_pfx->SetBinContent(20,1116);
h4_pfx->SetBinContent(21,1120);
h4_pfx->SetBinContent(22,1095);
h4_pfx->SetBinContent(23,1107);
h4_pfx->SetBinContent(24,1112);
h4_pfx->SetBinContent(25,1106);
h4_pfx->SetBinContent(26,1112);
h4_pfx->SetBinContent(27,1129);
h4_pfx->SetBinContent(28,1134);
h4_pfx->SetBinContent(29,1149);
h4_pfx->SetBinContent(30,1142);
h4_pfx->SetBinContent(31,1148);
h4_pfx->SetBinContent(32,1185);
h4_pfx->SetBinContent(33,1153);
h4_pfx->SetBinContent(34,1160);
h4_pfx->SetBinContent(35,1145);
h4_pfx->SetBinContent(36,1161);
h4_pfx->SetBinContent(37,1137);
h4_pfx->SetBinContent(38,565.5);
h4_pfx->SetBinContent(39,1114);
h4_pfx->SetBinContent(40,1120);
h4_pfx->SetBinContent(41,1119);
h4_pfx->SetBinContent(42,1096);
h4_pfx->SetBinContent(43,1108);
h4_pfx->SetBinContent(44,1121);
h4_pfx->SetBinContent(45,1114);
h4_pfx->SetBinContent(46,1135);
h4_pfx->SetBinContent(47,1683.5);
h4_pfx->SetBinContent(48,1135);
h4_pfx->SetBinContent(49,1161);
h4_pfx->SetBinContent(50,1144);
h4_pfx->SetBinContent(51,1153);
h4_pfx->SetBinContent(52,1177);
h4_pfx->SetBinContent(53,1174);
h4_pfx->SetBinContent(54,1173);
h4_pfx->SetBinContent(55,1171);
h4_pfx->SetBinContent(56,1164);
h4_pfx->SetBinContent(57,1127);
h4_pfx->SetBinContent(58,1130);
h4_pfx->SetBinContent(59,1137);
h4_pfx->SetBinContent(60,1122);
h4_pfx->SetBinContent(61,1106);
h4_pfx->SetBinContent(62,1096);
h4_pfx->SetBinContent(63,1140);
h4_pfx->SetBinContent(64,1100);
h4_pfx->SetBinContent(65,1110);
h4_pfx->SetBinContent(66,1121);
h4_pfx->SetBinContent(67,1139);
h4_pfx->SetBinContent(68,1146);
h4_pfx->SetBinContent(69,1155);
h4_pfx->SetBinContent(70,1147);
h4_pfx->SetBinContent(71,1156);
h4_pfx->SetBinContent(72,1150);
h4_pfx->SetBinContent(73,1173);
h4_pfx->SetBinContent(74,584.5);
h4_pfx->SetBinContent(75,1167);
h4_pfx->SetBinContent(76,1155);
h4_pfx->SetBinContent(77,1160);
h4_pfx->SetBinContent(78,1144);
h4_pfx->SetBinContent(79,1130);
h4_pfx->SetBinContent(80,1110);
h4_pfx->SetBinContent(81,1095);
h4_pfx->SetBinContent(82,1119);
h4_pfx->SetBinContent(83,1675.5);
h4_pfx->SetBinContent(84,1105);
h4_pfx->SetBinContent(85,1128);
h4_pfx->SetBinContent(86,1129);
h4_pfx->SetBinContent(87,1121);
h4_pfx->SetBinContent(88,1124);
h4_pfx->SetBinContent(89,1156);
h4_pfx->SetBinContent(90,1144);
h4_pfx->SetBinContent(91,1155);
h4_pfx->SetBinContent(92,1176);
h4_pfx->SetBinContent(93,1163);
h4_pfx->SetBinContent(94,1162);
h4_pfx->SetBinContent(95,1156);
h4_pfx->SetBinContent(96,1146);
h4_pfx->SetBinContent(97,1159);
h4_pfx->SetBinContent(98,1127);
h4_pfx->SetBinContent(99,1122);
h4_pfx->SetBinContent(100,1111);
h4_pfx->SetBinError(1,775.7593);
h4_pfx->SetBinError(2,567.5);
h4_pfx->SetBinError(3,786.4175);
h4_pfx->SetBinError(4,782.7787);
h4_pfx->SetBinError(5,778.8135);
h4_pfx->SetBinError(6,784.1827);
h4_pfx->SetBinError(7,795.5002);
h4_pfx->SetBinError(8,809.657);
h4_pfx->SetBinError(9,818.8812);
h4_pfx->SetBinError(10,816.7194);
h4_pfx->SetBinError(11,825.9034);
h4_pfx->SetBinError(12,1017.748);
h4_pfx->SetBinError(13,811.7958);
h4_pfx->SetBinError(14,816.0015);
h4_pfx->SetBinError(15,825.2712);
h4_pfx->SetBinError(16,812.4669);
h4_pfx->SetBinError(17,804.7574);
h4_pfx->SetBinError(18,799.749);
h4_pfx->SetBinError(19,787.0111);
h4_pfx->SetBinError(20,789.1568);
h4_pfx->SetBinError(21,791.9978);
h4_pfx->SetBinError(22,774.3646);
h4_pfx->SetBinError(23,782.849);
h4_pfx->SetBinError(24,786.3946);
h4_pfx->SetBinError(25,782.2292);
h4_pfx->SetBinError(26,786.3031);
h4_pfx->SetBinError(27,798.3286);
h4_pfx->SetBinError(28,801.8669);
h4_pfx->SetBinError(29,812.51);
h4_pfx->SetBinError(30,807.5311);
h4_pfx->SetBinError(31,811.7663);
h4_pfx->SetBinError(32,837.9645);
h4_pfx->SetBinError(33,815.299);
h4_pfx->SetBinError(34,820.2442);
h4_pfx->SetBinError(35,809.6978);
h4_pfx->SetBinError(36,820.9558);
h4_pfx->SetBinError(37,803.9916);
h4_pfx->SetBinError(38,565.5);
h4_pfx->SetBinError(39,787.7249);
h4_pfx->SetBinError(40,791.9675);
h4_pfx->SetBinError(41,791.2525);
h4_pfx->SetBinError(42,775.4305);
h4_pfx->SetBinError(43,783.4899);
h4_pfx->SetBinError(44,792.6869);
h4_pfx->SetBinError(45,787.7554);
h4_pfx->SetBinError(46,802.5861);
h4_pfx->SetBinError(47,971.9839);
h4_pfx->SetBinError(48,802.5774);
h4_pfx->SetBinError(49,820.9814);
h4_pfx->SetBinError(50,808.9379);
h4_pfx->SetBinError(51,815.2953);
h4_pfx->SetBinError(52,832.6539);
h4_pfx->SetBinError(53,830.1437);
h4_pfx->SetBinError(54,829.4411);
h4_pfx->SetBinError(55,828.2261);
h4_pfx->SetBinError(56,823.0872);
h4_pfx->SetBinError(57,796.9294);
h4_pfx->SetBinError(58,799.0385);
h4_pfx->SetBinError(59,803.9854);
h4_pfx->SetBinError(60,793.3741);
h4_pfx->SetBinError(61,782.0681);
h4_pfx->SetBinError(62,775.3402);
h4_pfx->SetBinError(63,806.1269);
h4_pfx->SetBinError(64,777.8255);
h4_pfx->SetBinError(65,784.9602);
h4_pfx->SetBinError(66,792.6869);
h4_pfx->SetBinError(67,805.4952);
h4_pfx->SetBinError(68,810.3521);
h4_pfx->SetBinError(69,816.7194);
h4_pfx->SetBinError(70,811.0626);
h4_pfx->SetBinError(71,817.4182);
h4_pfx->SetBinError(72,813.1731);
h4_pfx->SetBinError(73,829.4471);
h4_pfx->SetBinError(74,584.5);
h4_pfx->SetBinError(75,825.213);
h4_pfx->SetBinError(76,816.8846);
h4_pfx->SetBinError(77,820.2954);
h4_pfx->SetBinError(78,808.9676);
h4_pfx->SetBinError(79,799.1436);
h4_pfx->SetBinError(80,784.8914);
h4_pfx->SetBinError(81,774.2819);
h4_pfx->SetBinError(82,791.2575);
h4_pfx->SetBinError(83,967.4134);
h4_pfx->SetBinError(84,781.4567);
h4_pfx->SetBinError(85,797.6318);
h4_pfx->SetBinError(86,798.3549);
h4_pfx->SetBinError(87,792.6717);
h4_pfx->SetBinError(88,794.8588);
h4_pfx->SetBinError(89,817.4182);
h4_pfx->SetBinError(90,808.9453);
h4_pfx->SetBinError(91,816.7132);
h4_pfx->SetBinError(92,831.6252);
h4_pfx->SetBinError(93,822.4637);
h4_pfx->SetBinError(94,821.7095);
h4_pfx->SetBinError(95,817.4157);
h4_pfx->SetBinError(96,810.5372);
h4_pfx->SetBinError(97,819.5563);
h4_pfx->SetBinError(98,796.9106);
h4_pfx->SetBinError(99,793.3741);
h4_pfx->SetBinError(100,785.616);
h4_pfx->SetEntries(200);
TPaveStats *ptstats = new TPaveStats(0.5671642,0.6959248,0.9794776,0.9373041,"brNDC");
ptstats->SetName("stats");
ptstats->SetBorderSize(1);
ptstats->SetFillColor(0);
ptstats->SetTextAlign(12);
ptstats->SetTextFont(42);
TText *text = ptstats->AddText("#chi^{2} / ndf = 1194 / 91");
text->SetTextSize(0.04441379);
text = ptstats->AddText("p0 = 566.3 #pm 0.1 ");
text = ptstats->AddText("p1 = 14.22 #pm 0.17 ");
text = ptstats->AddText("p2 = 50.05 #pm 0.06 ");
text = ptstats->AddText("p3 = 2.319 #pm 0.025 ");
ptstats->SetOptStat(0);
ptstats->SetOptFit(1);
ptstats->Draw();
h4_pfx->GetListOfFunctions()->Add(ptstats);
ptstats->SetParent(h4_pfx);
TF1 *f3 = new TF1("f3","[0]+[1]*TMath::Cos(x*[2]*(2*3.14159)+[3])",0,100);
f3->SetFillColor(19);
f3->SetFillStyle(0);
f3->SetLineColor(2);
f3->SetLineWidth(2);
f3->SetChisquare(1193.557);
f3->SetNDF(91);
f3->GetXaxis()->SetLabelFont(42);
f3->GetXaxis()->SetLabelSize(0.035);
f3->GetXaxis()->SetTitleSize(0.035);
f3->GetXaxis()->SetTitleFont(42);
f3->GetYaxis()->SetLabelFont(42);
f3->GetYaxis()->SetLabelSize(0.035);
f3->GetYaxis()->SetTitleSize(0.035);
f3->GetYaxis()->SetTitleFont(42);
f3->SetParameter(0,566.3128);
f3->SetParError(0,0.1330487);
f3->SetParLimits(0,0,0);
f3->SetParameter(1,14.22488);
f3->SetParError(1,0.168519);
f3->SetParLimits(1,0,0);
f3->SetParameter(2,50.05139);
f3->SetParError(2,0.06405337);
f3->SetParLimits(2,0,0);
f3->SetParameter(3,2.318769);
f3->SetParError(3,0.02512338);
f3->SetParLimits(3,0,0);
h4_pfx->GetListOfFunctions()->Add(f3);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#000099");
h4_pfx->SetLineColor(ci);
h4_pfx->GetXaxis()->SetLabelFont(42);
h4_pfx->GetXaxis()->SetLabelSize(0.035);
h4_pfx->GetXaxis()->SetTitleSize(0.035);
h4_pfx->GetXaxis()->SetTitleFont(42);
h4_pfx->GetYaxis()->SetLabelFont(42);
h4_pfx->GetYaxis()->SetLabelSize(0.035);
h4_pfx->GetYaxis()->SetTitleSize(0.035);
h4_pfx->GetYaxis()->SetTitleFont(42);
h4_pfx->GetZaxis()->SetLabelFont(42);
h4_pfx->GetZaxis()->SetLabelSize(0.035);
h4_pfx->GetZaxis()->SetTitleSize(0.035);
h4_pfx->GetZaxis()->SetTitleFont(42);
h4_pfx->Draw("");
Canvas_1->Modified();
Canvas_1->cd();
Canvas_1->SetSelected(Canvas_1);
}

BIN
Scripts_20161126/50Hzbackground.pdf

Binary file not shown.

83
Scripts_20161126/Makefile

@ -0,0 +1,83 @@
ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)
GSLCFLAGS := $(shell gsl-config --cflags)
GSLLIBS := $(shell gsl-config --libs)
GSLGLIBS := $(shell gsl-config --glibs)
LDFLAGS = -O
LIBS += $(ROOTLIBS) $(GSLLIBS)
CFLAGS += $(ROOTCFLAGS) $(GSLCFLAGS) #-std=gnu++11
# Not sure why Minuit isn't being included -- put in by hand
#
LIBS += -lMinuit
all: convert analyse analyse_batch plot
plot: plot.o
g++ -o plot plot.o $(LDFLAGS) $(LIBS)
%.o: %.c
g++ ${CFLAGS} -c -g $<
plotdata_intensity_proton: plotdata_intensity_proton.o
g++ -o plotdata_intensity_proton plotdata_intensity_proton.o $(LDFLAGS) $(LIBS)
%.o: %.c
g++ ${CFLAGS} -c -g $<
plotdata_intensity_carbon: plotdata_intensity_carbon.o
g++ -o plotdata_intensity_carbon plotdata_intensity_carbon.o $(LDFLAGS) $(LIBS)
%.o: %.c
g++ ${CFLAGS} -c -g $<
analyse: analyse.o
g++ -o analyse analyse.o $(LDFLAGS) $(LIBS)
%.o: %.c
g++ ${CFLAGS} -c -g $<
convert: convert.o
g++ -o convert convert.o $(LDFLAGS) $(LIBS)
%.o: %.c
g++ ${CFLAGS} -c -g $<
convert_batch: convert_batch.o
g++ -o convert_batch convert_batch.o $(LDFLAGS) $(LIBS)
%.o: %.c
g++ ${CFLAGS} -c -g $<
analyse_batch: analyse_batch.o
g++ -o analyse_batch analyse_batch.o $(LDFLAGS) $(LIBS)
%.o: %.c
g++ ${CFLAGS} -c -g $<
analyse2: analyse2.o
g++ -o analyse2 analyse2.o $(LDFLAGS) $(LIBS)
%.o: %.c
g++ ${CFLAGS} -c -g $<
test:
@echo $(ROOTCFLAGS)
@echo $(LDFLAGS)
@echo $(LIBS)
clean:
-rm -f *.o

14
Scripts_20161126/Readme.txt

@ -0,0 +1,14 @@
These scripts are for the data on 2016.11.26
1. The raw data of HIT and Fiber in csv format is converted into root tree with "./convert"
//"convert" is compiled form convert.c with MAKEFILE
//Before using it, please change the PATH for the HIT data and Fiber data in "convert.c", and the filename in MAKEFILE
2. Then analyse the data with "./analyse". The output is a root file with multiple histograms.
//"analyse" is compiled form analyse.c with MAKEFILE
//Before using it, please change the PATH for the root file in "analyse.c", and the filename in MAKEFILE
3. A PDF file is generated from the root file with command "root -q -b process.c"
It contains some histograms of the root file.

BIN
Scripts_20161126/analyse

Binary file not shown.

52
Scripts_20161126/analyse.c

@ -0,0 +1,52 @@
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <TFile.h>
#include <TTree.h>
#include <TSystemDirectory.h>
#include "beammon.h"
using namespace std;
int main(int argc, char **argv)
{
// Working directories
const char *dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/";
const char *pin_dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/pin/";
const char *ext = ".root";
TSystemDirectory pin_dir(pin_dirname, pin_dirname);
TList *files = pin_dir.GetListOfFiles();
if (files)
{
TSystemFile* file;
TString fname = ' ';
TIter next(files);
while ((file = (TSystemFile *)next()))
{
fname = file->GetName();
// Loop over all files PiN_run***.root
if (!file->IsDirectory() && fname.EndsWith(ext) && !fname.BeginsWith("SAVE") && fname.BeginsWith("PiN_run"))
{
Beammon *mon = new Beammon();
printf("File name: %s \n", fname.Data());
// Main part
// Initialize(DIRName, FileName, baselineEvents, prelimEvents, beamLevel, firstFibermat, readOutFrequency in Hz, integrationTime in us)
mon->Initialize(dirname, fname.Data(), 5000, 10000, 1., true, 3000., 312.);
mon->Save();
delete mon;
}
}
}
return 0;
}

BIN
Scripts_20161126/analyse2

Binary file not shown.

327
Scripts_20161126/analyse2.c

@ -0,0 +1,327 @@
#define analyse2_cxx
#include "analyse2.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <TFile.h>
#include <TTree.h>
#include <TSystemDirectory.h>
#include <gsl/gsl_statistics.h>
#include <math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_fft_complex.h>
#include <TF1.h>
#include <TGraphErrors.h>
using namespace std;
void analyse2::Loop()
{
// In a ROOT session, you can do:
// Root > .L analyse2.C
// Root > analyse2 t
// Root > t.GetEntry(12); // Fill t data members with entry number 12
// Root > t.Show(); // Show values of entry 12
// Root > t.Show(16); // Read and show values of entry 16
// Root > t.Loop(); // Loop on all entries
//
// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain-> ve types of modulesSetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus("branchname",1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
if (fChain == 0) return;
Double_t totalcurrent = 0.;
Double_t totaltime = 0.;
const int length = 100;
double array[length] = {0.};
double arrayavg = 0.;
TF1 * bkgfunc = new TF1("bkgfunc","[0]+[1]*TMath::Cos(x*[2]*(2*3.14159)+[3])");
bkgfunc->SetParameters( bkgfitPar0[64], bkgfitPar1[64], bkgfitPar2[64], bkgfitPar3[64]);
TF1 * gausfunc = new TF1("gausfunc","gaus(0)+[3]");
TF1 * gausfunc2 = new TF1("gausfunc2","[0]*exp(-((x-[1])/[2])^2) +[3]*exp(-((x-[1])/[4])^2) + [5]");
TGraphErrors * gausgraph;
int numoverthresh=0;
double maxchannelamp = 0.;
double threshold = 10.;
int maxchannel = 0;
int numtocalc = 0;
int sidenumtocalc= 0;
Long64_t nentries = fChain->GetEntries();
Long64_t ientry = LoadTree(1);
fChain->GetEntry(1);
Double_t basetimeoffset = time;
Double_t channelamp[64] = {0.};
Double_t abschannelamp[64] = {0.};
Bool_t beamonflag = false;
Int_t waitcounter = 0;
Int_t lastfit = 0;
Int_t lastfit2 = 0;
Double_t channellist_gsl[64];
Bool_t savegraph = true;
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
// if (Cut(ientry) < 0) continue;
time_1 = time-basetimeoffset;
ic1_1 = ic1;
ic2_1 = ic2;
mw1_focusx_1 = mw1_focusx;
mw1_focusy_1 = mw1_focusy;
mw2_focusx_1 = mw2_focusx;
mw2_focusy_1 = mw2_focusy;
mw1_posx_1 = mw1_posx;
mw1_posy_1 = mw1_posy;
mw2_posx_1 = mw2_posx;
mw2_posy_1= mw2_posy;
eventid_1 = jentry;
if (jentry % 10000 ==0) cout << jentry << " events completed..." << endl;
//calculate a rolling average of the signal
arrayavg = 0;
for (int i = 1; i<length;i++){
array[i-1] = array[i];
}
if(ic1_1>-100) array[length-1] = ic1_1 ;
for (int i = 0; i<length;i++){
arrayavg += array[i]/double(length);
}
rollingavg = double(arrayavg);
waitcounter++;
// cout << rollingavg << " " << waitcounter << " " << ic1_1 << endl;
//rerun the baseline fitter using the data in front of each spill
if(rollingavg>1 && !beamonflag && jentry>5000) {
beamonflag = true; beamon = 1;
cout << "Beam On: " << jentry << endl;
Baseline(true,3200,int(jentry-4000),true);
bkgfunc->SetParameters( bkgfitPar0[64], bkgfitPar1[64], bkgfitPar2[64], bkgfitPar3[64]);
waitcounter = 0;
}
if(rollingavg <0.5 && beamonflag && jentry>5000 )
{
beamonflag = false;
beamon = 0;
waitcounter = 0;
}
if (ic1_1>0.01) {totaltime+=0.312; totalcurrent+=ic1_1;}
// calculate mean and integral
beamSignal_1 = 0.;
numoverthresh=0;
maxchannelamp = 0.;
threshold = 14;
maxchannel = 0;
// cout << (time_1-basetimeoffset)<< endl;
for (int ch = 4; ch < 64; ch++){
bkgfunc->SetParameters( bkgfitPar0[ch], bkgfitPar1[ch], bkgfitPar2[ch], bkgfitPar3[ch]); //set the parameters for the common mode subtraction
channelamp[ch] = channels[ch]- baseline[ch] - bkgfunc->Eval(time_1); //subtract the baseline
//channelamp_smooth[ch] = channelamp[ch];//to be smoothed later
if (channelamp[ch] < 0.) {abschannelamp[ch] = 0.;}
else {abschannelamp[ch] = channelamp[ch];}
if (ic1_1>0.01) th2d_beamSignal_channel->Fill(ch,channelamp[ch]);
if (ic1_1<=0.01) th2d_bkg_channel->Fill(ch,channelamp[ch]);
if ( channelamp[ch] >threshold) {
numoverthresh++;
if ( channelamp[ch] > maxchannelamp) {
maxchannelamp = channelamp[ch] ;
maxchannel = ch;
}
}
channellist_gsl[ch] = 0;
channelamp_smooth[ch] = 0.;
}
numoverthresh+=4;
numtocalc = 0;
sidenumtocalc = 0;
beamSidebandNoise_1 = 0.;
// for (int ch = 4; ch < maxchannel-numoverthresh/2; ch++){
// if (ch>=4 && ch<=63){
// beamSidebandNoise_1 += channelamp[ch]; //integrate the noise outside the peak
// sidenumtocalc++;
// }
// }
for (int ch = maxchannel+numoverthresh/2; ch < 64; ch++){
if (ch>=4 && ch<=63){
beamSidebandNoise_1 += channelamp[ch]; //integrate the noise outside the peak
sidenumtocalc++;
}
}
beamSidebandNoise_1 = beamSidebandNoise_1 /double(sidenumtocalc); // channel baseline shift
for (int ch = maxchannel-numoverthresh/2 ; ch < maxchannel + numoverthresh/2; ch++){
if (ch>=4 && ch<=63){
beamSignal_1 += channelamp[ch]; //integrate the signal around the peak channel
channelamp_smooth[numtocalc] = channelamp[ch] - beamSidebandNoise_1 ;
beamSignal_1 += channelamp[ch]- beamSidebandNoise_1 ; //integrate the signal around the peak channel
channellist_gsl[numtocalc] = ch;
numtocalc++;
}
}
// if (ic1_1<=5 && ic2_1<=5 && jentry<1000) { cout << beamSignal_1 << " "<<(time_1)<<" " << bkgfunc->Eval((time_1)) << endl; }
// beamSignal_1 -= bkgfunc->Eval(time_1);
//statistical analysis of the beam position
// FFTsmoothing(channelamp_smooth);//Fourier transform smoothing
beamPosX_1 = gsl_stats_wmean(channelamp_smooth,1,channellist_gsl,1,numtocalc); //calculate the weighted mean
beamFocusX_1 = gsl_stats_wsd_with_fixed_mean(channelamp_smooth,1,channellist_gsl,1,numtocalc,beamPosX_1); //SD
beamSkewX_1 = gsl_stats_wskew_m_sd(channelamp_smooth,1,channellist_gsl,1,numtocalc,beamPosX_1,beamFocusX_1); //skewness (symmetry)
beamKurtX_1 = gsl_stats_wkurtosis_m_sd(channelamp_smooth,1,channellist_gsl,1,numtocalc,beamPosX_1,beamFocusX_1); //excess kurtosis (well behaved tails)
beamNumX_1 = numtocalc;
beamFocusX_1 *=2.3548;//SD-->FWHM
if (ic1_1>0.01 && beamSignal_1>5) th2d_mw1_beamPosX->Fill(mw1_posx_1,beamPosX_1);
if (ic1_1>0.01 && beamSignal_1>5) th2d_ic1_beamSignal->Fill(ic1_1,beamSignal_1);
if (ic1_1>0.01 && beamSignal_1>5) th1d_beamSignal_ic1ratio->Fill(beamSignal_1/ic1_1);
//fit with a gaussian function;
if (beamon==1){
if (numtocalc>10&&numtocalc<50){
gausfunc->SetParameters(beamSignal_1/(sqrt(2)*beamFocusX_1/2.3548),beamPosX_1,beamFocusX_1/2.3548,0.);
gausfunc2->SetParameters(beamSignal_1/(sqrt(2)*beamFocusX_1/2.3548),beamPosX_1,beamFocusX_1/2.3548,beamSignal_1/(10*sqrt(2)*beamFocusX_1/2.3548),2*beamFocusX_1/2.3548,0.);
}
else{
gausfunc->SetParameters(500.,32.,10.,0.);
gausfunc2->SetParameters(500.,32,5.0,50.,10.0,0.);
}
gausfunc->SetParLimits(0,0.,10000.);
gausfunc->SetParLimits(1,10.,50.);
gausfunc->SetParLimits(2,0.5,30.);
gausfunc->SetParLimits(3,-150.,150.);
gausfunc2->SetParLimits(0,0.,10000.);
gausfunc2->SetParLimits(1,0.,64.);
gausfunc2->SetParLimits(2,0.5,50.);
gausfunc2->SetParLimits(3,0.,500.);
gausfunc2->SetParLimits(4,1.5,50.);
gausfunc2->SetParLimits(5,-150.,150.);
gausgraph = new TGraphErrors(64,channellist,channelamp,errorx,errory);
lastfit = gausgraph->Fit(gausfunc,"QRN","",4,60); // single gaussian fit
if (beamon && savegraph && waitcounter>5000) {
gausgraph->SetName("example"); gausgraph->SetTitle("example");
gausgraph->Write();
gausfunc->Write();
cout << "Example data saved" << endl;
savegraph = false;
}
// lastfit2 = gausgraph->Fit(gausfunc2,"QR","",4,60);// two gaussian fit
beamPosX_fit = gausfunc->GetParameter(1);
beamFocusX_fit =2.3548* gausfunc->GetParameter(2);
beamChi2_fit = gausfunc->GetChisquare()/gausfunc->GetNDF();
beamPeakX_fit = gausfunc->GetParameter(0);
beamPosX_fit2 = gausfunc2->GetParameter(1);
beamFocusX_fit2 =2.3548* gausfunc2->GetParameter(2);
beamFocus2X_fit2 =2.3548* gausfunc2->GetParameter(4);
beamChi2_fit2 = gausfunc2->GetChisquare()/gausfunc->GetNDF();
beamPeakX_fit2 = gausfunc2->GetParameter(0);
beamPeak2X_fit2 = gausfunc2->GetParameter(3);
for (int ch = 4; ch < 64; ch++){
th2d_fitdiff_channel->Fill(ch, double(channelamp[ch]-gausfunc->Eval(ch)));
th2d_fit2diff_channel->Fill(ch, double(channelamp[ch]-gausfunc2->Eval(ch)));
}
}
newdata->Fill();
}
TVectorD v(10);
v[0] = totalcurrent;
v[1] = totaltime;
v.Write("icinfo");
th2d_mw1_beamPosX->Write();
th2d_ic1_beamSignal->Write();
th1d_beamSignal_ic1ratio->Write();
th2d_beamSignal_channel->Write();
th2d_bkg_channel->Write();
th2d_fitdiff_channel->Write();
th2d_PhaseFFT_channel->Write();
th2d_AmpFFT_channel->Write();
newdata->Write();
}
int main(int argc, char **argv)
{
// Working directories
const char *dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/";
const char *pin_dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/pin/";
const char *ext = ".root";
TSystemDirectory pin_dir(pin_dirname, pin_dirname);
if (true)
{
TSystemFile* file;
TString fname = argv[1];
// fname = file->GetName();
// execute single PiN_run***.root
if ( fname.EndsWith(ext) && !fname.BeginsWith("SAVE") && fname.BeginsWith("PiN_run"))
{
analyse2 *mon = new analyse2();
printf("File name: %s \n", fname.Data());
// Main part
// Initialize(DIRName, FileName, baselineEvents, prelimEvents, beamLevel, firstFibermat, readOutFrequency in Hz, integrationTime in us)
mon->Initialize(dirname, fname.Data(), 3200, 10000, 1., true, 3000., 0.);
mon->Baseline(true,1000,1,true);
mon->Loop(); //analysis loop
// cout << th2d_mw1_beamPosX->GetCorrelationFactor() << endl;
mon->Save();//save output tree file
// mon->Close();//close output tree file
delete mon;
}
}
return 0;
}

140
Scripts_20161126/analyse2.c_old

@ -0,0 +1,140 @@
#define analyse2_cxx
#include "analyse2.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <TFile.h>
#include <TTree.h>
#include <TSystemDirectory.h>
#include <gsl/gsl_statistics.h>
using namespace std;
void analyse2::Loop()
{
// In a ROOT session, you can do:
// Root > .L analyse2.C
// Root > analyse2 t
// Root > t.GetEntry(12); // Fill t data members with entry number 12
// Root > t.Show(); // Show values of entry 12
// Root > t.Show(16); // Read and show values of entry 16
// Root > t.Loop(); // Loop on all entries
//
// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain->SetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus("branchname",1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
if (fChain == 0) return;
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
// if (Cut(ientry) < 0) continue;
time_1 = time;
ic1_1 = ic1;
ic2_1 = ic2;
mw1_focusx_1 = mw1_focusx;
mw1_focusy_1 = mw1_focusy;
mw2_focusx_1 = mw2_focusx;
mw2_focusy_1 = mw2_focusy;
mw1_posx_1 = mw1_posx;
mw1_posy_1 = mw1_posy;
mw2_posx_1 = mw2_posx;
mw2_posy_1= mw2_posy;
// calculate mean and integral
beamSignal_1 = 0.;
/*
for (int ch = 0; ch < 64; ch++){
beamSignal_1 += channels[ch] - baseline[ch];
beamPosX_1 += (channels[ch] - baseline[ch]) * double(ch);
}
beamPosX_1/= beamSignal_1;
// calculate FWHM from RMS
beamFocusX_1 = 0.;
for (int ch = 0; ch < 64; ch++){
beamFocusX_1 += (channels[ch] - baseline[ch]) * (ch-beamPosX_1)* (ch-beamPosX_1);
}
beamFocusX_1 /= beamSignal_1;
beamFocusX_1 = sqrt(beamFocusX_1); //correct this Variance = sigma*sigma / b
*/
for (int ch = 0; ch < 64; ch++){
channels[ch]-=baseline[ch]; //subtract the baseline
beamSignal_1 += channels[ch]; //integrate the signal
}
beamPosX_1 = gsl_stats_wmean(channels,1,channellist,1,64); //calculate the weighted mean
beamFocusX_1 = 2.355* gsl_stats_wsd(channels,1,channellist,1,64); //FWHM
beamSkewX_1 = gsl_stats_wskew(channels,1,channellist,1,64); //skewness (symmetry)
beamKurtX_1 = gsl_stats_wkurtosis(channels,1,channellist,1,64); //excess kurtosis (well behaved tails)
th2f_mw1_beamPosX->Fill(mw1_posx_1,beamPosX_1);
newdata->Fill();
}
th2f_mw1_beamPosX->Write();
newdata->Write();
}
int main(int argc, char **argv)
{
// Working directories
const char *dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/";
const char *pin_dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/pin/";
const char *ext = ".root";
TSystemDirectory pin_dir(pin_dirname, pin_dirname);
if (true)
{
TSystemFile* file;
TString fname = argv[1];
// fname = file->GetName();
// execute single PiN_run***.root
if ( fname.EndsWith(ext) && !fname.BeginsWith("SAVE") && fname.BeginsWith("PiN_run"))
{
analyse2 *mon = new analyse2();
printf("File name: %s \n", fname.Data());
// Main part
// Initialize(DIRName, FileName, baselineEvents, prelimEvents, beamLevel, firstFibermat, readOutFrequency in Hz, integrationTime in us)
mon->Initialize(dirname, fname.Data(), 5000, 10000, 1., true, 3000., 312.);
mon->Baseline(false,1000);
mon->Loop(); //analysis loop
// cout << th2f_mw1_beamPosX->GetCorrelationFactor() << endl;
mon->Save();//save output tree file
// mon->Close();//close output tree file
delete mon;
}
}
return 0;
}

919
Scripts_20161126/analyse2.h

@ -0,0 +1,919 @@
//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Tue Sep 12 15:40:57 2017 by ROOT version 5.34/32
// from TTree t/t
// found on file: ../../HIT_26-11-2016/with_timestamp/pin/PiN_run1.root
//////////////////////////////////////////////////////////
#ifndef analyse2_h
#define analyse2_h
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TTree.h>
#include <stdio.h>
#include <TH2D.h>
#include <TH1D.h>
#include <TProfile.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TMath.h>
#include <vector>
#include <utility>
#include <TString.h>
#include <TDirectory.h>
#include <TString.h>
#include <TVectorD.h>
#include <TGraph.h>
#include <TGraphErrors.h>
#include <cmath>
#include <TPaveStats.h>
#include <TText.h>
#include <TStyle.h>
#include <TObjArray.h>
#include <TLegend.h>
#include <TFitResult.h>
#include <gsl/gsl_statistics.h>
#include <math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_fft_complex.h>
using namespace std;
// Header file for the classes stored in the TTree if any.
// Fixed size dimensions of array or collections stored in the TTree if any.
class analyse2 {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
Int_t fCurrent; //!current Tree number in a TChain
TTree *data;
TTree *newdata;
// Declaration of leaf types
Double_t time;
Double_t event_id;
Double_t sync_out;
Double_t sync_in;
Double_t data_ok;
Double_t led_voltage;
Double_t current;
Double_t ch00;
Double_t ch01;
Double_t ch02;
Double_t ch03;
Double_t ch04;
Double_t ch05;
Double_t ch06;
Double_t ch07;
Double_t ch08;
Double_t ch09;
Double_t ch10;
Double_t ch11;
Double_t ch12;
Double_t ch13;
Double_t ch14;
Double_t ch15;
Double_t ch16;
Double_t ch17;
Double_t ch18;
Double_t ch19;
Double_t ch20;
Double_t ch21;
Double_t ch22;
Double_t ch23;
Double_t ch24;
Double_t ch25;
Double_t ch26;
Double_t ch27;
Double_t ch28;
Double_t ch29;
Double_t ch30;
Double_t ch31;
Double_t ch32;
Double_t ch33;
Double_t ch34;
Double_t ch35;
Double_t ch36;
Double_t ch37;
Double_t ch38;
Double_t ch39;
Double_t ch40;
Double_t ch41;
Double_t ch42;
Double_t ch43;
Double_t ch44;
Double_t ch45;
Double_t ch46;
Double_t ch47;
Double_t ch48;
Double_t ch49;
Double_t ch50;
Double_t ch51;
Double_t ch52;
Double_t ch53;
Double_t ch54;
Double_t ch55;
Double_t ch56;
Double_t ch57;
Double_t ch58;
Double_t ch59;
Double_t ch60;
Double_t ch61;
Double_t ch62;
Double_t ch63;
Double_t ic1;
Double_t ic2;
Double_t mw1_focusx;
Double_t mw1_focusy;
Double_t mw2_focusx;
Double_t mw2_focusy;
Double_t mw1_posx;
Double_t mw1_posy;
Double_t mw2_posx;
Double_t mw2_posy;
// List of branches
TBranch *b_time; //!
TBranch *b_event_id; //!
TBranch *b_sync_out; //!
TBranch *b_sync_in; //!
TBranch *b_data_ok; //!
TBranch *b_led_voltage; //!
TBranch *b_current; //!
TBranch *b_ch00; //!
TBranch *b_ch01; //!
TBranch *b_ch02; //!
TBranch *b_ch03; //!
TBranch *b_ch04; //!
TBranch *b_ch05; //!
TBranch *b_ch06; //!
TBranch *b_ch07; //!
TBranch *b_ch08; //!
TBranch *b_ch09; //!
TBranch *b_ch10; //!
TBranch *b_ch11; //!
TBranch *b_ch12; //!
TBranch *b_ch13; //!
TBranch *b_ch14; //!
TBranch *b_ch15; //!
TBranch *b_ch16; //!
TBranch *b_ch17; //!
TBranch *b_ch18; //!
TBranch *b_ch19; //!
TBranch *b_ch20; //!
TBranch *b_ch21; //!
TBranch *b_ch22; //!
TBranch *b_ch23; //!
TBranch *b_ch24; //!
TBranch *b_ch25; //!
TBranch *b_ch26; //!
TBranch *b_ch27; //!
TBranch *b_ch28; //!
TBranch *b_ch29; //!
TBranch *b_ch30; //!
TBranch *b_ch31; //!
TBranch *b_ch32; //!
TBranch *b_ch33; //!
TBranch *b_ch34; //!
TBranch *b_ch35; //!
TBranch *b_ch36; //!
TBranch *b_ch37; //!
TBranch *b_ch38; //!
TBranch *b_ch39; //!
TBranch *b_ch40; //!
TBranch *b_ch41; //!
TBranch *b_ch42; //!
TBranch *b_ch43; //!
TBranch *b_ch44; //!
TBranch *b_ch45; //!
TBranch *b_ch46; //!
TBranch *b_ch47; //!
TBranch *b_ch48; //!
TBranch *b_ch49; //!
TBranch *b_ch50; //!
TBranch *b_ch51; //!
TBranch *b_ch52; //!
TBranch *b_ch53; //!
TBranch *b_ch54; //!
TBranch *b_ch55; //!
TBranch *b_ch56; //!
TBranch *b_ch57; //!
TBranch *b_ch58; //!
TBranch *b_ch59; //!
TBranch *b_ch60; //!
TBranch *b_ch61; //!
TBranch *b_ch62; //!
TBranch *b_ch63; //!
TBranch *b_ic1; //!
TBranch *b_ic2; //!
TBranch *b_mw1_focusx; //!
TBranch *b_mw1_focusy; //!
TBranch *b_mw2_focusx; //!
TBranch *b_mw2_focusy; //!
TBranch *b_mw1_posx; //!
TBranch *b_mw1_posy; //!
TBranch *b_mw2_posx; //!
TBranch *b_mw2_posy; //!
char *file;
TFile *fileIn;
TFile *fileOut;
TObjArray objectArray;
TBranch *b_channels[64];
TBranch *b_baseline[64];
double channels[64];
double channelamp_smooth[64];
double baseline[64];
double channellist[64];
double errorx[64];
double errory[64];
TBranch *b_beamNumX_1;
TBranch *b_beamPosX_1;
TBranch *b_beamFocusX_1;
TBranch *b_beamSignal_1;
TBranch *b_beamSidebandNoise_1;
TBranch *b_beamSkewX_1;
TBranch *b_beamKurtX_1;
TBranch *b_beamPosX_fit;
TBranch *b_beamFocusX_fit;
TBranch *b_beamChi2_fit;
TBranch *b_beamPeakX_fit;
TBranch *b_beamPosX_fit2;
TBranch *b_beamFocusX_fit2;
TBranch *b_beamFocus2X_fit2;
TBranch *b_beamChi2_fit2;
TBranch *b_beamPeakX_fit2;
TBranch *b_beamPeak2X_fit2;
TBranch *b_ic1_1; //!
TBranch *b_ic2_1; //!
TBranch *b_mw1_focusx_1; //!
TBranch *b_mw1_focusy_1; //!
TBranch *b_mw2_focusx_1; //!
TBranch *b_mw2_focusy_1; //!
TBranch *b_mw1_posx_1; //!
TBranch *b_mw1_posy_1; //!
TBranch *b_mw2_posx_1; //!
TBranch *b_mw2_posy_1; //!
TBranch *b_baseline_integral;
TBranch *b_time_1; //!
TBranch *b_eventid_1; //!
TBranch *b_rollingavg; //!
TBranch *b_beamon; //!
double time_1;
double ic1_1;
double ic2_1;
double mw1_focusx_1;
double mw2_focusx_1;
double mw2_posx_1;
double mw1_posx_1;
double mw1_focusy_1;
double mw2_focusy_1;
double mw2_posy_1;
double mw1_posy_1;
double beamNumX_1;
double beamPosX_1;
double beamFocusX_1;
double beamSignal_1;
double beamSidebandNoise_1;
double beamSkewX_1;
double beamKurtX_1;
double baseline_integral;
double chargeintegral;
double timeintegral;
double eventid_1;
double rollingavg;
int beamon;
double beamPosX_fit;
double beamFocusX_fit;
double beamChi2_fit;
double beamPeakX_fit;
double beamPosX_fit2;
double beamFocusX_fit2;
double beamFocus2X_fit2;
double beamChi2_fit2;
double beamPeakX_fit2;
double beamPeak2X_fit2;
analyse2(TTree *tree=0);
virtual ~analyse2();
virtual Int_t Cut(Long64_t entry);
virtual Int_t GetEntry(Long64_t entry);
virtual Long64_t LoadTree(Long64_t entry);
virtual void Init(TTree *tree);
virtual void Loop();
virtual Bool_t Notify();
virtual void Show(Long64_t entry = -1);
double channelWidth;
void Initialize(const char *dirname, const char *filename, int baselineEvents = 1000, int prelimEvents = 10000, double beamLevel = 0.1, bool firstFibermat = true, double readOutFrequency = 1000., int integrationTime = 100);
void Baseline(bool useFirstEvents, int nBaselineEvents, int StartEvent, bool run50hz);
void Save();
void Close();
double * FFTsmoothing(double arr[]);
// double RollingAverage(const int length, double newdata);
TH2D * th2d_mw1_beamPosX;
TH2D * th2d_ic1_beamSignal;
TH1D * th1d_beamSignal_ic1ratio;
TH2D * th2d_beamSignal_channel;
TH2D * th2d_bkg_channel;
TH1D * th1d_baseline;
TH1D * th1d_baselinesub;
TH1D * th1d_chbaseline;
TH1D * th1d_chbaselinesub;
TH2D * th2d_fitdiff_channel;
TH2D * th2d_fit2diff_channel;
TH2D * th2d_AmpFFT_channel;
TH2D * th2d_PhaseFFT_channel;
TFitResultPtr bkgfitResult;
Double_t bkgfitPar0[65];
Double_t bkgfitPar1[65];
Double_t bkgfitPar2[65];
Double_t bkgfitPar3[65];
Double_t bkgfitPar4[65];
};
#endif
#ifdef analyse2_cxx
analyse2::analyse2(TTree *tree) : fChain(0)
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
if (tree == 0) {
cerr << "no TTree found." << endl;
}
Init(tree);
}
analyse2::~analyse2()
{
if (!fChain) return;
delete fChain->GetCurrentFile();
}
Int_t analyse2::GetEntry(Long64_t entry)
{
// Read contents of entry.
if (!fChain) return 0;
return fChain->GetEntry(entry);
}
Long64_t analyse2::LoadTree(Long64_t entry)
{
// Set the environment to read one entry
if (!fChain) return -5;
Long64_t centry = fChain->LoadTree(entry);
if (centry < 0) return centry;
if (fChain->GetTreeNumber() != fCurrent) {
fCurrent = fChain->GetTreeNumber();
Notify();
}
return centry;
}
void analyse2::Init(TTree *tree)
{
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the branch addresses and branch
// pointers of the tree will be set.
// It is normally not necessary to make changes to the generated
// code, but the routine can be extended by the user if needed.
// Init() will be called many times when running on PROOF
// (once per file to be processed).
// Set branch addresses and branch pointers
if (!tree) return;
fChain = tree;
fCurrent = -1;
fChain->SetMakeClass(1);
fChain->SetBranchAddress("time", &time, &b_time);
fChain->SetBranchAddress("event_id", &event_id, &b_event_id);
fChain->SetBranchAddress("sync_out", &sync_out, &b_sync_out);
fChain->SetBranchAddress("sync_in", &sync_in, &b_sync_in);
fChain->SetBranchAddress("data_ok", &data_ok, &b_data_ok);
fChain->SetBranchAddress("led_voltage", &led_voltage, &b_led_voltage);
fChain->SetBranchAddress("current", &current, &b_current);
fChain->SetBranchAddress("ch00", &ch00, &b_ch00);
fChain->SetBranchAddress("ch01", &ch01, &b_ch01);
fChain->SetBranchAddress("ch02", &ch02, &b_ch02);
fChain->SetBranchAddress("ch03", &ch03, &b_ch03);
fChain->SetBranchAddress("ch04", &ch04, &b_ch04);
fChain->SetBranchAddress("ch05", &ch05, &b_ch05);
fChain->SetBranchAddress("ch06", &ch06, &b_ch06);
fChain->SetBranchAddress("ch07", &ch07, &b_ch07);
fChain->SetBranchAddress("ch08", &ch08, &b_ch08);
fChain->SetBranchAddress("ch09", &ch09, &b_ch09);
fChain->SetBranchAddress("ch10", &ch10, &b_ch10);
fChain->SetBranchAddress("ch11", &ch11, &b_ch11);
fChain->SetBranchAddress("ch12", &ch12, &b_ch12);
fChain->SetBranchAddress("ch13", &ch13, &b_ch13);
fChain->SetBranchAddress("ch14", &ch14, &b_ch14);
fChain->SetBranchAddress("ch15", &ch15, &b_ch15);
fChain->SetBranchAddress("ch16", &ch16, &b_ch16);
fChain->SetBranchAddress("ch17", &ch17, &b_ch17);
fChain->SetBranchAddress("ch18", &ch18, &b_ch18);
fChain->SetBranchAddress("ch19", &ch19, &b_ch19);
fChain->SetBranchAddress("ch20", &ch20, &b_ch20);
fChain->SetBranchAddress("ch21", &ch21, &b_ch21);
fChain->SetBranchAddress("ch22", &ch22, &b_ch22);
fChain->SetBranchAddress("ch23", &ch23, &b_ch23);
fChain->SetBranchAddress("ch24", &ch24, &b_ch24);
fChain->SetBranchAddress("ch25", &ch25, &b_ch25);
fChain->SetBranchAddress("ch26", &ch26, &b_ch26);
fChain->SetBranchAddress("ch27", &ch27, &b_ch27);
fChain->SetBranchAddress("ch28", &ch28, &b_ch28);
fChain->SetBranchAddress("ch29", &ch29, &b_ch29);
fChain->SetBranchAddress("ch30", &ch30, &b_ch30);
fChain->SetBranchAddress("ch31", &ch31, &b_ch31);
fChain->SetBranchAddress("ch32", &ch32, &b_ch32);
fChain->SetBranchAddress("ch33", &ch33, &b_ch33);
fChain->SetBranchAddress("ch34", &ch34, &b_ch34);
fChain->SetBranchAddress("ch35", &ch35, &b_ch35);
fChain->SetBranchAddress("ch36", &ch36, &b_ch36);
fChain->SetBranchAddress("ch37", &ch37, &b_ch37);
fChain->SetBranchAddress("ch38", &ch38, &b_ch38);
fChain->SetBranchAddress("ch39", &ch39, &b_ch39);
fChain->SetBranchAddress("ch40", &ch40, &b_ch40);
fChain->SetBranchAddress("ch41", &ch41, &b_ch41);
fChain->SetBranchAddress("ch42", &ch42, &b_ch42);
fChain->SetBranchAddress("ch43", &ch43, &b_ch43);
fChain->SetBranchAddress("ch44", &ch44, &b_ch44);
fChain->SetBranchAddress("ch45", &ch45, &b_ch45);
fChain->SetBranchAddress("ch46", &ch46, &b_ch46);
fChain->SetBranchAddress("ch47", &ch47, &b_ch47);
fChain->SetBranchAddress("ch48", &ch48, &b_ch48);
fChain->SetBranchAddress("ch49", &ch49, &b_ch49);
fChain->SetBranchAddress("ch50", &ch50, &b_ch50);
fChain->SetBranchAddress("ch51", &ch51, &b_ch51);
fChain->SetBranchAddress("ch52", &ch52, &b_ch52);
fChain->SetBranchAddress("ch53", &ch53, &b_ch53);
fChain->SetBranchAddress("ch54", &ch54, &b_ch54);
fChain->SetBranchAddress("ch55", &ch55, &b_ch55);
fChain->SetBranchAddress("ch56", &ch56, &b_ch56);
fChain->SetBranchAddress("ch57", &ch57, &b_ch57);
fChain->SetBranchAddress("ch58", &ch58, &b_ch58);
fChain->SetBranchAddress("ch59", &ch59, &b_ch59);
fChain->SetBranchAddress("ch60", &ch60, &b_ch60);
fChain->SetBranchAddress("ch61", &ch61, &b_ch61);
fChain->SetBranchAddress("ch62", &ch62, &b_ch62);
fChain->SetBranchAddress("ch63", &ch63, &b_ch63);
fChain->SetBranchAddress("ic1", &ic1, &b_ic1);
fChain->SetBranchAddress("ic2", &ic2, &b_ic2);
fChain->SetBranchAddress("mw1_focusx", &mw1_focusx, &b_mw1_focusx);
fChain->SetBranchAddress("mw1_focusy", &mw1_focusy, &b_mw1_focusy);
fChain->SetBranchAddress("mw2_focusx", &mw2_focusx, &b_mw2_focusx);
fChain->SetBranchAddress("mw2_focusy", &mw2_focusy, &b_mw2_focusy);
fChain->SetBranchAddress("mw1_posx", &mw1_posx, &b_mw1_posx);
fChain->SetBranchAddress("mw1_posy", &mw1_posy, &b_mw1_posy);
fChain->SetBranchAddress("mw2_posx", &mw2_posx, &b_mw2_posx);
fChain->SetBranchAddress("mw2_posy", &mw2_posy, &b_mw2_posy);
// v->ResizeTo(10);
Notify();
}
Bool_t analyse2::Notify()
{
// The Notify() function is called when a new file is opened. This
// can be either for a new TTree in a TChain or when when a new TTree
// is started when using PROOF. It is normally not necessary to make changes
// to the generated code, but the routine can be extended by the
// user if needed. The return value is currently not used.
return kTRUE;
}
void analyse2::Show(Long64_t entry)
{
// Print contents of entry.
// If entry is not specified, print current entry
if (!fChain) return;
fChain->Show(entry);
}
Int_t analyse2::Cut(Long64_t entry)
{
// This function may be called from Loop.
// returns 1 if entry is accepted.
// returns -1 otherwise.
return 1;
}
void analyse2::Initialize(const char *dirname, const char *filename, int baselineEvents, int prelimEvents, double beamLevel, bool firstFibermat, double readOutFrequency, int integrationTime)
{
TString fn = TString(filename);
TString dn = TString(dirname);
channelWidth = 0.8;
TString inName = dn + "pin/" + fn;
fileIn = new TFile(inName, "READ");
fileIn->GetObject("t", fChain);
fChain->Print();
Init(fChain);
TString outname = filename;
outname.Insert(0, "SAVE_");
outname.Insert(0, dirname);
fileOut = new TFile(outname.Data(), "RECREATE");
newdata = new TTree("newdata", "newdata");
for (int n = 0; n < 64; n++)
{
baseline[n] = 0.;
channellist[n] = double(n);
errorx[n] = 0.0;
errory[n] = 7.0;
char bname[20];
sprintf(bname, "ch%02d", n);
b_channels[n] = fChain->GetBranch(bname);
b_channels[n]->SetAddress(&channels[n]);
}
b_eventid_1 = newdata->Branch("eventid_1", &eventid_1);
b_beamNumX_1 = newdata->Branch("beamNumX_1", &beamNumX_1);
b_beamPosX_1 = newdata->Branch("beamPosX_1", &beamPosX_1);
b_beamFocusX_1 = newdata->Branch("beamFocusX_1", &beamFocusX_1);
b_beamSignal_1 = newdata->Branch("beamSignal_1", &beamSignal_1);
b_beamSidebandNoise_1 = newdata->Branch("beamSidebandNoise_1", &beamSidebandNoise_1);
b_beamSkewX_1 = newdata->Branch("beamSkewX_1", &beamSkewX_1);
b_beamKurtX_1 = newdata->Branch("beamKurtX_1", &beamKurtX_1);
b_beamPosX_fit = newdata->Branch("beamPosX_fit", &beamPosX_fit);
b_beamFocusX_fit = newdata->Branch("beamFocusX_fit", &beamFocusX_fit);
b_beamChi2_fit = newdata->Branch("beamChi2_fit", &beamChi2_fit);
b_beamPeakX_fit = newdata->Branch("beamPeakX_fit", &beamPeakX_fit);
b_beamPosX_fit2 = newdata->Branch("beamPosX_fit2", &beamPosX_fit2);
b_beamFocusX_fit2 = newdata->Branch("beamFocusX_fit2", &beamFocusX_fit2);
b_beamFocus2X_fit2 = newdata->Branch("beamFocus2X_fit2", &beamFocus2X_fit2);
b_beamChi2_fit2 = newdata->Branch("beamChi2_fit2", &beamChi2_fit2);
b_beamPeakX_fit2 = newdata->Branch("beamPeakX_fit2", &beamPeakX_fit2);
b_beamPeak2X_fit2 = newdata->Branch("beamPeak2X_fit2", &beamPeak2X_fit2);
b_ic1_1 = newdata->Branch("ic1_1", &ic1_1);
b_ic2_1 = newdata->Branch("ic2_1", &ic2_1);
b_mw1_focusx_1 = newdata->Branch("mw1_focusx_1", &mw1_focusx_1);
b_mw1_posx_1 = newdata->Branch("mw1_posx_1", &mw1_posx_1);
b_mw2_focusx_1 = newdata->Branch("mw2_focusx_1", &mw2_focusx_1);
b_mw2_posx_1 = newdata->Branch("mw2_posx_1", &mw2_posx_1);
b_mw1_focusy_1 = newdata->Branch("mw1_focusy_1", &mw1_focusy_1);
b_mw1_posy_1 = newdata->Branch("mw1_posy_1", &mw1_posy_1);
b_mw2_focusy_1 = newdata->Branch("mw2_focusy_1", &mw2_focusy_1);
b_mw2_posy_1 = newdata->Branch("mw2_posy_1", &mw2_posy_1);
b_rollingavg = newdata->Branch("rollingavg", &rollingavg);
b_beamon = newdata->Branch("beamon", &beamon);
b_time_1 = newdata->Branch("time_1", &time_1);
//histograms;
th2d_mw1_beamPosX = new TH2D("th2d_mw1_beamPosX","th2d_mw1_beamPosX",1000,0,64,1000,0,60);
th2d_ic1_beamSignal = new TH2D("th2d_ic1_beamSignal","th2d_ic1_beamSignal",500,0,500,500,0,100000);
th1d_beamSignal_ic1ratio = new TH1D("th1d_beamSignal_ic1ratio","th1d_beamSignal_ic1ratio",500,0,500.);
th2d_beamSignal_channel = new TH2D("th2d_beamSignal_channel","th2d_beamSignal_channel",65,-0.5,64.5,5100,-1000,10000);
th2d_fitdiff_channel = new TH2D("th2d_fitdiff_channel","th2d_fitdiff_channel",65,-0.5,64.5,5100,-10000,1000);
th2d_fit2diff_channel = new TH2D("th2d_fit2diff_channel","th2d_fit2diff_channel",65,-0.5,64.5,5100,-10000,1000);
th2d_bkg_channel = new TH2D("th2d_bkg_channel","th2d_bkg_channel",65,-0.5,64.5,500,-500,500);
th1d_baseline = new TH1D("th1d_baseline","th1d_baseline",500,-1500,1500.);
th1d_baselinesub = new TH1D("th1d_baselinesub","th1d_baselinesub",500,-1500,1500.);
th1d_chbaseline = new TH1D("th1d_chbaseline","th1d_chbaseline",2100,-100,1000.);
th1d_chbaselinesub = new TH1D("th1d_chbaselinesub","th1d_chbaselinesub",200,-100,100.);
th2d_AmpFFT_channel = new TH2D("th2d_AmpFFT_channel","th2d_AmpFFT_channel",65,-0.5,64.5,500,0,1000);
th2d_PhaseFFT_channel = new TH2D("th2d_PhaseFFT_channel","th2d_PhaseFFT_channel",65,-0.5,64.5,100,-2,2);
}
void analyse2::Baseline(bool useFirstEvents, const int nBaselineEvents, int startevent, bool run50hz)
{
Long64_t nevents = fChain->GetEntriesFast();
baseline_integral = 0.;
// use the first/last nBaselineEvents events to calculate the average/baseline
cout << "Start background subtraction event:" << startevent << endl;
const int numbaseline = 3500;
Double_t channelamp[numbaseline];
Double_t basetime[numbaseline] = {0.};
TGraph * g1;
TF1 * fitfunc = new TF1("fitfunc","[0]+[1]*TMath::Cos(x*[2]*(2*3.14159)+[3])");
fitfunc->SetParameters( 0.0, 10.0, 0.05, 0.0 );
fitfunc->FixParameter(2,0.05);
fChain->GetEvent(1);
Double_t basetimeoffsetzero = time;
fChain->GetEvent(startevent+numbaseline);
Double_t basetimeoffset = time-basetimeoffsetzero;
fChain->GetEvent(startevent);
Double_t basetimeoffsetstart = time-basetimeoffsetzero;
Int_t counter = 0;
char bname[20];
for (int ch = 0; ch < 64; ch++)
{
baseline[ch] =0.;
}
if (!useFirstEvents)
{ // last
for (int i = nevents- numbaseline; i < nevents; i++)
{
fChain->GetEvent(i);
for (int ch = 0; ch < 64; ch++)
{
if (channels[ch]>-100) baseline[ch] += channels[ch] / double(numbaseline);
if (channels[ch]>-100) baseline_integral +=baseline[ch];
th1d_chbaseline->Fill(channels[ch]);
}
}
// cout << "baseline int: " << baseline_integral << endl;
}
else
{
for (int i = startevent ; i <= startevent+ numbaseline; i++)
{
fChain->GetEvent(i);
for (int ch = 0; ch < 64; ch++)
{
if (channels[ch]>-100) baseline[ch] += channels[ch] / double(numbaseline);
if (channels[ch]>-100) baseline_integral +=baseline[ch];
th1d_chbaseline->Fill(channels[ch]);
}
// cout << "baseline int: " << baseline_integral << endl;
}
}
if (run50hz){
///fit a 50Hz background noise to each channel
for (int ch = 0; ch < 64; ch++)
{
counter = 0;
for (int i = startevent ; i < startevent+numbaseline; i++)
{
fChain->GetEvent(i);
// for (int ch = 0; ch < 64; ch++)
//{
channelamp[counter]= channels[ch]- baseline[ch];
//}
basetime[counter] = time-basetimeoffsetzero;
counter++;
}
g1 = new TGraph(numbaseline,basetime,channelamp);
///////finished here. 1) need to fit the baseline to a Cosine function 2) return 3 parameters per channel. 50 Hz is fixed.
bkgfitResult = g1->Fit(fitfunc,"QSR","",basetimeoffsetstart,basetimeoffset );
bkgfitPar0[ch] = bkgfitResult->Parameter(0);
bkgfitPar1[ch] = bkgfitResult->Parameter(1);
bkgfitPar2[ch] = bkgfitResult->Parameter(2);
bkgfitPar3[ch] = bkgfitResult->Parameter(3);
sprintf(bname, "bkg_ch%02d_graph", ch);
g1->SetTitle(bname);
g1->SetName(bname);
//fitResult->Print("V");
// bkgfitResult->Write();
g1->Write();
} //end for (int ch = ...
for (int ch = 0; ch < 64; ch++)
{
counter = 0;
fitfunc->SetParameters( bkgfitPar0[ch], bkgfitPar1[ch], bkgfitPar2[ch], bkgfitPar3[ch]);
for (Long64_t i = startevent ; i <startevent+ numbaseline; i++)
{
fChain->GetEvent(i);
channelamp[counter] = channels[ch]- baseline[ch]- fitfunc->Eval(time-basetimeoffsetzero);
th1d_chbaselinesub->Fill(channelamp[counter]);
counter++;
th2d_bkg_channel->Fill(ch,channelamp[counter]);
}
}
Double_t channelampsum[numbaseline] = {0.};
counter = 0;
///fit a 50Hz background noise to the sum of all channels
for (Long64_t i = startevent ; i <startevent+ numbaseline; i++)
{
fChain->GetEvent(i);
channelampsum[counter]=0.;
for (int ch = 0; ch < 64; ch++){
if (channels[ch]>-100 && baseline[ch]>-100) channelampsum[counter] += channels[ch] - baseline[ch]; //integrate the signal
}
basetime[counter] = (time-basetimeoffsetzero);
counter++;
}
TGraph * g2 = new TGraph(counter,basetime,channelampsum);
TF1 * fitfunc2 = new TF1("fitfunc2","[0]+[1]*TMath::Cos(x*[2]*(2*3.14159)+[3])");
fitfunc2->SetParameters( 5120.0, 450.0, 0.05, 0.0 );
// fitfunc2->SetParLimits(1,0.,1000.);
fitfunc2->FixParameter(2,0.05);
TFitResultPtr sumbkgfitResult = g2->Fit(fitfunc2,"QRS","", basetimeoffsetstart, basetimeoffset);
g2->SetName("commonmodenoise"); g2->SetTitle("commonmodenoise");
g2->Write();
sumbkgfitResult->Write();
fitfunc2->Write();
bkgfitPar0[64] = fitfunc2->GetParameter(0);
bkgfitPar1[64] = fitfunc2->GetParameter(1);
bkgfitPar2[64] = fitfunc2->GetParameter(2);
bkgfitPar3[64] = fitfunc2->GetParameter(3);
counter=0;
for (Long64_t i = startevent ; i <startevent+ numbaseline; i++)
{
fChain->GetEvent(i);
channelampsum[counter] -= fitfunc2->Eval(time-basetimeoffsetzero);
th1d_baselinesub->Fill(channelampsum[counter]);
counter++;
}
th1d_baseline->Write();
th1d_baselinesub->Write();
th1d_chbaseline->Write();
th1d_chbaselinesub->Write();
TGraph * g3 = new TGraph(counter,basetime,channelampsum);
g3->SetName("commonmodenoisesub"); g2->SetTitle("commonmodenoisesub");
g3->Write();
}
}
void analyse2::Save()
{
//fileIn->Close();
//fileOut->cd();
newdata->AutoSave();
}
void analyse2::Close()
{
fileIn->Close();
fileOut->Close();
if(fChain) delete fChain->GetCurrentFile();
}
#define REAL(z,i) ((z)[2*(i)])
#define IMAG(z,i) ((z)[2*(i)+1])
double * analyse2::FFTsmoothing(double arr[])
{
int i; double data[2*64];
double channel[64];
double RealInput[64];
double ImagInput[64];
double RealFFT[64];
double ImagFFT[64];
double AmpFFT[64];
double PhaseFFT[64];
double RealOutput[64];
double ImagOutput[64];
double avgnoiseAmpFFT = 0.;
for (i = 0; i < 64; i++)
{
REAL(data,i) = arr[i]; IMAG(data,i) = 0.0;
}
// REAL(data,0) = 1.0;
// for (i = 1; i <= 10; i++)
// {
// REAL(data,i) 1.0;
// }
for (i = 0; i < 64; i++)
{
channel[i] = i;
RealInput[i] = REAL(data,i);
ImagInput[i] = IMAG(data,i);
// printf ("%d %e %e\n", i, REAL(data,i), IMAG(data,i));
}
// printf ("\n");
// TGraph * g1_input_real = new TGraph(64,channel,RealInput);
// TGraph * g1_input_imag = new TGraph(64,channel,ImagInput);
// g1_input_real->SetName("input_real"); g1_input_real->Write();
//g1_input_imag->SetName("input_imag"); g1_input_imag->Write();
//apply Fourier transform
gsl_fft_complex_radix2_forward (data, 1, 64);
for (i = 0; i < 64; i++)
{
// printf ("%d %e %e\n", i, REAL(data,i)/sqrt(64), IMAG(data,i)/sqrt(64));
RealFFT[i] = REAL(data,i)/sqrt(64);
ImagFFT[i] = IMAG(data,i)/sqrt(64);
AmpFFT[i] = sqrt(RealFFT[i]*RealFFT[i] + ImagFFT[i]*ImagFFT[i]);
PhaseFFT[i] = atan(ImagFFT[i]/RealFFT[i]);
if (beamon){
th2d_AmpFFT_channel->Fill(i,AmpFFT[i]);
th2d_PhaseFFT_channel->Fill(i,PhaseFFT[i]);
}
}
// printf ("\n");
//find the average noise frequency amplitude
for (i = 22; i < 32; i++){
avgnoiseAmpFFT +=AmpFFT[i]/10;
}
//find where the signal frequency amplitude falls below noise;
int cutchannel = 31;
for (i = 0; i < 32; i++)
{
if (AmpFFT[i]<avgnoiseAmpFFT) {
cutchannel = i;
break;
}
}
// TGraph * g1_FFT_real = new TGraph(64,channel,RealFFT);
// TGraph * g1_FFT_imag = new TGraph(64,channel,ImagFFT);
//g1_FFT_real->SetName("FFT_real"); g1_FFT_real->Write();
// g1_FFT_imag->SetName("FFT_imag");g1_FFT_imag->Write();
// TGraph * g1_FFT_amp = new TGraph(64,channel,AmpFFT);
// TGraph * g1_FFT_phase = new TGraph(64,channel,PhaseFFT);
// g1_FFT_amp->SetName("FFT_amp"); g1_FFT_amp->Write();
// g1_FFT_phase->SetName("FFT_phase");g1_FFT_phase->Write();
//suppress channels that are more likely noise; the signal has a lower frequency than noise;
for (i = cutchannel+2; i < 32; i++)
{
REAL(data,i) = 0.;
IMAG(data,i) = 0.;
REAL(data,64-i) = 0.;
IMAG(data,64-i) = 0.;
}
//apply inverse Fourier transform
gsl_fft_complex_radix2_inverse (data, 1, 64);
for (i = 0; i < 64; i++)
{
// printf ("%d %e %e\n", i, REAL(data,i), IMAG(data,i));
RealOutput[i] = REAL(data,i);
ImagOutput[i] = IMAG(data,i);
arr[i] = RealOutput[i];
}
//printf ("\n");
// TGraph * g1_output_real = new TGraph(64,channel,RealOutput);
// TGraph * g1_output_imag = new TGraph(64,channel,ImagOutput);
// g1_output_real->SetName("output_real");g1_output_real->Write();
// g1_output_imag->SetName("output_imag");g1_output_imag->Write();
return arr;
}
#endif // #ifdef analyse2_cxx

565
Scripts_20161126/analyse2.h_old

@ -0,0 +1,565 @@
B//////////////////////////////////////////////////////////
// This class has been automatically generated on
// Tue Sep 12 15:40:57 2017 by ROOT version 5.34/32
// from TTree t/t
// found on file: ../../HIT_26-11-2016/with_timestamp/pin/PiN_run1.root
//////////////////////////////////////////////////////////
#ifndef analyse2_h
#define analyse2_h
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TTree.h>
#include <stdio.h>
#include <TH2D.h>
#include <TH1D.h>
#include <TProfile.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TMath.h>
#include <vector>
#include <utility>
#include <TString.h>
#include <TDirectory.h>
#include <TString.h>
#include <TVectorD.h>
#include <TGraph.h>
#include <TGraphErrors.h>
#include <cmath>
#include <TPaveStats.h>
#include <TText.h>
#include <TROOT.h>
#include <TStyle.h>
#include <TObjArray.h>
#include <TLegend.h>
using namespace std;
// Header file for the classes stored in the TTree if any.
// Fixed size dimensions of array or collections stored in the TTree if any.
class analyse2 {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
Int_t fCurrent; //!current Tree number in a TChain
TTree *data;
TTree *newdata;
// Declaration of leaf types
Double_t time;
Double_t event_id;
Double_t sync_out;
Double_t sync_in;
Double_t data_ok;
Double_t led_voltage;
Double_t current;
Double_t ch00;
Double_t ch01;
Double_t ch02;
Double_t ch03;
Double_t ch04;
Double_t ch05;
Double_t ch06;
Double_t ch07;
Double_t ch08;
Double_t ch09;
Double_t ch10;
Double_t ch11;
Double_t ch12;
Double_t ch13;
Double_t ch14;
Double_t ch15;
Double_t ch16;
Double_t ch17;
Double_t ch18;
Double_t ch19;
Double_t ch20;
Double_t ch21;
Double_t ch22;
Double_t ch23;
Double_t ch24;
Double_t ch25;
Double_t ch26;
Double_t ch27;
Double_t ch28;
Double_t ch29;
Double_t ch30;
Double_t ch31;
Double_t ch32;
Double_t ch33;
Double_t ch34;
Double_t ch35;
Double_t ch36;
Double_t ch37;
Double_t ch38;
Double_t ch39;
Double_t ch40;
Double_t ch41;
Double_t ch42;
Double_t ch43;
Double_t ch44;
Double_t ch45;
Double_t ch46;
Double_t ch47;
Double_t ch48;
Double_t ch49;
Double_t ch50;
Double_t ch51;
Double_t ch52;
Double_t ch53;
Double_t ch54;
Double_t ch55;
Double_t ch56;
Double_t ch57;
Double_t ch58;
Double_t ch59;
Double_t ch60;
Double_t ch61;
Double_t ch62;
Double_t ch63;
Double_t ic1;
Double_t ic2;
Double_t mw1_focusx;
Double_t mw1_focusy;
Double_t mw2_focusx;
Double_t mw2_focusy;
Double_t mw1_posx;
Double_t mw1_posy;
Double_t mw2_posx;
Double_t mw2_posy;
// List of branches
TBranch *b_time; //!
TBranch *b_event_id; //!
TBranch *b_sync_out; //!
TBranch *b_sync_in; //!
TBranch *b_data_ok; //!
TBranch *b_led_voltage; //!
TBranch *b_current; //!
TBranch *b_ch00; //!
TBranch *b_ch01; //!
TBranch *b_ch02; //!
TBranch *b_ch03; //!
TBranch *b_ch04; //!
TBranch *b_ch05; //!
TBranch *b_ch06; //!
TBranch *b_ch07; //!
TBranch *b_ch08; //!
TBranch *b_ch09; //!
TBranch *b_ch10; //!
TBranch *b_ch11; //!
TBranch *b_ch12; //!
TBranch *b_ch13; //!
TBranch *b_ch14; //!
TBranch *b_ch15; //!
TBranch *b_ch16; //!
TBranch *b_ch17; //!
TBranch *b_ch18; //!
TBranch *b_ch19; //!
TBranch *b_ch20; //!
TBranch *b_ch21; //!
TBranch *b_ch22; //!
TBranch *b_ch23; //!
TBranch *b_ch24; //!
TBranch *b_ch25; //!
TBranch *b_ch26; //!
TBranch *b_ch27; //!
TBranch *b_ch28; //!
TBranch *b_ch29; //!
TBranch *b_ch30; //!
TBranch *b_ch31; //!
TBranch *b_ch32; //!
TBranch *b_ch33; //!
TBranch *b_ch34; //!
TBranch *b_ch35; //!
TBranch *b_ch36; //!
TBranch *b_ch37; //!
TBranch *b_ch38; //!
TBranch *b_ch39; //!
TBranch *b_ch40; //!
TBranch *b_ch41; //!
TBranch *b_ch42; //!
TBranch *b_ch43; //!
TBranch *b_ch44; //!
TBranch *b_ch45; //!
TBranch *b_ch46; //!
TBranch *b_ch47; //!
TBranch *b_ch48; //!
TBranch *b_ch49; //!
TBranch *b_ch50; //!
TBranch *b_ch51; //!
TBranch *b_ch52; //!
TBranch *b_ch53; //!
TBranch *b_ch54; //!
TBranch *b_ch55; //!
TBranch *b_ch56; //!
TBranch *b_ch57; //!
TBranch *b_ch58; //!
TBranch *b_ch59; //!
TBranch *b_ch60; //!
TBranch *b_ch61; //!
TBranch *b_ch62; //!
TBranch *b_ch63; //!
TBranch *b_ic1; //!
TBranch *b_ic2; //!
TBranch *b_mw1_focusx; //!
TBranch *b_mw1_focusy; //!
TBranch *b_mw2_focusx; //!
TBranch *b_mw2_focusy; //!
TBranch *b_mw1_posx; //!
TBranch *b_mw1_posy; //!
TBranch *b_mw2_posx; //!
TBranch *b_mw2_posy; //!
char *file;
TFile *fileIn;
TFile *fileOut;
TObjArray objectArray;
TBranch *b_channels[64];
TBranch *b_baseline[64];
double channels[64];
double baseline[64];
double channellist[64];
TBranch *b_beamPosX_1;
TBranch *b_beamFocusX_1;
TBranch *b_beamSignal_1;
TBranch *b_beamSkewX_1;
TBranch *b_beamKurtX_1;
TBranch *b_ic1_1; //!
TBranch *b_ic2_1; //!
TBranch *b_mw1_focusx_1; //!
TBranch *b_mw1_focusy_1; //!
TBranch *b_mw2_focusx_1; //!
TBranch *b_mw2_focusy_1; //!
TBranch *b_mw1_posx_1; //!
TBranch *b_mw1_posy_1; //!
TBranch *b_mw2_posx_1; //!
TBranch *b_mw2_posy_1; //!
TBranch *b_baseline_integral;
TBranch *b_time_1; //!
double time_1;
double ic1_1;
double ic2_1;
double mw1_focusx_1;
double mw2_focusx_1;
double mw2_posx_1;
double mw1_posx_1;
double mw1_focusy_1;
double mw2_focusy_1;
double mw2_posy_1;
double mw1_posy_1;
double beamPosX_1;
double beamFocusX_1;
double beamSignal_1;
double beamSkewX_1;
double beamKurtX_1;
double baseline_integral;
analyse2(TTree *tree=0);
virtual ~analyse2();
virtual Int_t Cut(Long64_t entry);
virtual Int_t GetEntry(Long64_t entry);
virtual Long64_t LoadTree(Long64_t entry);
virtual void Init(TTree *tree);
virtual void Loop();
virtual Bool_t Notify();
virtual void Show(Long64_t entry = -1);
double channelWidth;
void Initialize(const char *dirname, const char *filename, int baselineEvents = 1000, int prelimEvents = 10000, double beamLevel = 0.1, bool firstFibermat = true, double readOutFrequency = 1000., int integrationTime = 100);
void Baseline(bool useFirstEvents, int nBaselineEvents);
void Save();
void Close();
TH2F * th2f_mw1_beamPosX;
TH2F * th2f_ic1_beamSignal;
};
#endif
#ifdef analyse2_cxx
analyse2::analyse2(TTree *tree) : fChain(0)
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
if (tree == 0) {
cerr << "no TTree found." << endl;
}
Init(tree);
}
analyse2::~analyse2()
{
if (!fChain) return;
delete fChain->GetCurrentFile();
}
Int_t analyse2::GetEntry(Long64_t entry)
{
// Read contents of entry.
if (!fChain) return 0;
return fChain->GetEntry(entry);
}
Long64_t analyse2::LoadTree(Long64_t entry)
{
// Set the environment to read one entry
if (!fChain) return -5;
Long64_t centry = fChain->LoadTree(entry);
if (centry < 0) return centry;
if (fChain->GetTreeNumber() != fCurrent) {
fCurrent = fChain->GetTreeNumber();
Notify();
}
return centry;
}
void analyse2::Init(TTree *tree)
{
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the branch addresses and branch
// pointers of the tree will be set.
// It is normally not necessary to make changes to the generated
// code, but the routine can be extended by the user if needed.
// Init() will be called many times when running on PROOF
// (once per file to be processed).
// Set branch addresses and branch pointers
if (!tree) return;
fChain = tree;
fCurrent = -1;
fChain->SetMakeClass(1);
fChain->SetBranchAddress("time", &time, &b_time);
fChain->SetBranchAddress("event_id", &event_id, &b_event_id);
fChain->SetBranchAddress("sync_out", &sync_out, &b_sync_out);
fChain->SetBranchAddress("sync_in", &sync_in, &b_sync_in);
fChain->SetBranchAddress("data_ok", &data_ok, &b_data_ok);
fChain->SetBranchAddress("led_voltage", &led_voltage, &b_led_voltage);
fChain->SetBranchAddress("current", &current, &b_current);
fChain->SetBranchAddress("ch00", &ch00, &b_ch00);
fChain->SetBranchAddress("ch01", &ch01, &b_ch01);
fChain->SetBranchAddress("ch02", &ch02, &b_ch02);
fChain->SetBranchAddress("ch03", &ch03, &b_ch03);
fChain->SetBranchAddress("ch04", &ch04, &b_ch04);
fChain->SetBranchAddress("ch05", &ch05, &b_ch05);
fChain->SetBranchAddress("ch06", &ch06, &b_ch06);
fChain->SetBranchAddress("ch07", &ch07, &b_ch07);
fChain->SetBranchAddress("ch08", &ch08, &b_ch08);
fChain->SetBranchAddress("ch09", &ch09, &b_ch09);
fChain->SetBranchAddress("ch10", &ch10, &b_ch10);
fChain->SetBranchAddress("ch11", &ch11, &b_ch11);
fChain->SetBranchAddress("ch12", &ch12, &b_ch12);
fChain->SetBranchAddress("ch13", &ch13, &b_ch13);
fChain->SetBranchAddress("ch14", &ch14, &b_ch14);
fChain->SetBranchAddress("ch15", &ch15, &b_ch15);
fChain->SetBranchAddress("ch16", &ch16, &b_ch16);
fChain->SetBranchAddress("ch17", &ch17, &b_ch17);
fChain->SetBranchAddress("ch18", &ch18, &b_ch18);
fChain->SetBranchAddress("ch19", &ch19, &b_ch19);
fChain->SetBranchAddress("ch20", &ch20, &b_ch20);
fChain->SetBranchAddress("ch21", &ch21, &b_ch21);
fChain->SetBranchAddress("ch22", &ch22, &b_ch22);
fChain->SetBranchAddress("ch23", &ch23, &b_ch23);
fChain->SetBranchAddress("ch24", &ch24, &b_ch24);
fChain->SetBranchAddress("ch25", &ch25, &b_ch25);
fChain->SetBranchAddress("ch26", &ch26, &b_ch26);
fChain->SetBranchAddress("ch27", &ch27, &b_ch27);
fChain->SetBranchAddress("ch28", &ch28, &b_ch28);
fChain->SetBranchAddress("ch29", &ch29, &b_ch29);
fChain->SetBranchAddress("ch30", &ch30, &b_ch30);
fChain->SetBranchAddress("ch31", &ch31, &b_ch31);
fChain->SetBranchAddress("ch32", &ch32, &b_ch32);
fChain->SetBranchAddress("ch33", &ch33, &b_ch33);
fChain->SetBranchAddress("ch34", &ch34, &b_ch34);
fChain->SetBranchAddress("ch35", &ch35, &b_ch35);
fChain->SetBranchAddress("ch36", &ch36, &b_ch36);
fChain->SetBranchAddress("ch37", &ch37, &b_ch37);
fChain->SetBranchAddress("ch38", &ch38, &b_ch38);
fChain->SetBranchAddress("ch39", &ch39, &b_ch39);
fChain->SetBranchAddress("ch40", &ch40, &b_ch40);
fChain->SetBranchAddress("ch41", &ch41, &b_ch41);
fChain->SetBranchAddress("ch42", &ch42, &b_ch42);
fChain->SetBranchAddress("ch43", &ch43, &b_ch43);
fChain->SetBranchAddress("ch44", &ch44, &b_ch44);
fChain->SetBranchAddress("ch45", &ch45, &b_ch45);
fChain->SetBranchAddress("ch46", &ch46, &b_ch46);
fChain->SetBranchAddress("ch47", &ch47, &b_ch47);
fChain->SetBranchAddress("ch48", &ch48, &b_ch48);
fChain->SetBranchAddress("ch49", &ch49, &b_ch49);
fChain->SetBranchAddress("ch50", &ch50, &b_ch50);
fChain->SetBranchAddress("ch51", &ch51, &b_ch51);
fChain->SetBranchAddress("ch52", &ch52, &b_ch52);
fChain->SetBranchAddress("ch53", &ch53, &b_ch53);
fChain->SetBranchAddress("ch54", &ch54, &b_ch54);
fChain->SetBranchAddress("ch55", &ch55, &b_ch55);
fChain->SetBranchAddress("ch56", &ch56, &b_ch56);
fChain->SetBranchAddress("ch57", &ch57, &b_ch57);
fChain->SetBranchAddress("ch58", &ch58, &b_ch58);
fChain->SetBranchAddress("ch59", &ch59, &b_ch59);
fChain->SetBranchAddress("ch60", &ch60, &b_ch60);
fChain->SetBranchAddress("ch61", &ch61, &b_ch61);
fChain->SetBranchAddress("ch62", &ch62, &b_ch62);
fChain->SetBranchAddress("ch63", &ch63, &b_ch63);
fChain->SetBranchAddress("ic1", &ic1, &b_ic1);
fChain->SetBranchAddress("ic2", &ic2, &b_ic2);
fChain->SetBranchAddress("mw1_focusx", &mw1_focusx, &b_mw1_focusx);
fChain->SetBranchAddress("mw1_focusy", &mw1_focusy, &b_mw1_focusy);
fChain->SetBranchAddress("mw2_focusx", &mw2_focusx, &b_mw2_focusx);
fChain->SetBranchAddress("mw2_focusy", &mw2_focusy, &b_mw2_focusy);
fChain->SetBranchAddress("mw1_posx", &mw1_posx, &b_mw1_posx);
fChain->SetBranchAddress("mw1_posy", &mw1_posy, &b_mw1_posy);
fChain->SetBranchAddress("mw2_posx", &mw2_posx, &b_mw2_posx);
fChain->SetBranchAddress("mw2_posy", &mw2_posy, &b_mw2_posy);
Notify();
}
Bool_t analyse2::Notify()
{
// The Notify() function is called when a new file is opened. This
// can be either for a new TTree in a TChain or when when a new TTree
// is started when using PROOF. It is normally not necessary to make changes
// to the generated code, but the routine can be extended by the
// user if needed. The return value is currently not used.
return kTRUE;
}
void analyse2::Show(Long64_t entry)
{
// Print contents of entry.
// If entry is not specified, print current entry
if (!fChain) return;
fChain->Show(entry);
}
Int_t analyse2::Cut(Long64_t entry)
{
// This function may be called from Loop.
// returns 1 if entry is accepted.
// returns -1 otherwise.
return 1;
}
void analyse2::Initialize(const char *dirname, const char *filename, int baselineEvents, int prelimEvents, double beamLevel, bool firstFibermat, double readOutFrequency, int integrationTime)
{
TString fn = TString(filename);
TString dn = TString(dirname);
channelWidth = 0.8;
TString inName = dn + "pin/" + fn;
fileIn = new TFile(inName, "READ");
fileIn->GetObject("t", fChain);
fChain->Print();
Init(fChain);
TString outname = filename;
outname.Insert(0, "SAVE_");
outname.Insert(0, dirname);
fileOut = new TFile(outname.Data(), "RECREATE");
newdata = new TTree("newdata", "newdata");
for (int n = 0; n < 64; n++)
{
baseline[n] = 0.;
channellist[n] = double(n);
char bname[20];
sprintf(bname, "ch%02d", n);
b_channels[n] = fChain->GetBranch(bname);
b_channels[n]->SetAddress(&channels[n]);
}
b_beamPosX_1 = newdata->Branch("beamPosX_1", &beamPosX_1);
b_beamFocusX_1 = newdata->Branch("beamFocusX_1", &beamFocusX_1);
b_beamSignal_1 = newdata->Branch("beamSignal_1", &beamSignal_1);
b_beamSkewX_1 = newdata->Branch("beamSkewX_1", &beamSkewX_1);
b_beamKurtX_1 = newdata->Branch("beamKurtX_1", &beamKurtX_1);
b_ic1_1 = newdata->Branch("ic1_1", &ic1_1);
b_ic2_1 = newdata->Branch("ic2_1", &ic2_1);
b_mw1_focusx_1 = newdata->Branch("mw1_focusx_1", &mw1_focusx_1);
b_mw1_posx_1 = newdata->Branch("mw1_posx_1", &mw1_posx_1);
b_mw2_focusx_1 = newdata->Branch("mw2_focusx_1", &mw2_focusx_1);
b_mw2_posx_1 = newdata->Branch("mw2_posx_1", &mw2_posx_1);
b_mw1_focusy_1 = newdata->Branch("mw1_focusy_1", &mw1_focusy_1);
b_mw1_posy_1 = newdata->Branch("mw1_posy_1", &mw1_posy_1);
b_mw2_focusy_1 = newdata->Branch("mw2_focusy_1", &mw2_focusy_1);
b_mw2_posy_1 = newdata->Branch("mw2_posy_1", &mw2_posy_1);
b_time_1 = newdata->Branch("time_1", &time_1);
//histograms;
th2f_mw1_beamPosX = new TH2F("th2f_mw1_beamPosX","th2f_mw1_beamPosX",200,0,64,200,0,30);
th2f_ic1_beamSignal = new TH2F("th2f_ic1_beamSignal","th2f_ic1_beamSignal",200,0,300,200,0,30000);
}
void analyse2::Baseline(bool useFirstEvents, int nBaselineEvents)
{
Long64_t nevents = fChain->GetEntriesFast();
baseline_integral = 0.;
// use the first/last nBaselineEvents events to calculate the average/baseline
if (!useFirstEvents)
{ // last
for (int i = nevents - nBaselineEvents; i < nevents; i++)
{
fChain->GetEvent(i);
for (int ch = 0; ch < 64; ch++)
{
baseline[ch] += channels[ch] / double(nBaselineEvents);
baseline_integral +=baseline[ch];
}
}
}
else
{
for (int i = 1; i <= nBaselineEvents; i++)
{
fChain->GetEvent(i);
for (int ch = 0; ch < 64; ch++)
{
baseline[ch] += channels[ch] / double(nBaselineEvents);
baseline_integral +=baseline[ch];
}
}
}
}
void analyse2::Save()
{
//fileIn->Close();
//fileOut->cd();
newdata->AutoSave();
}
void analyse2::Close()
{
fileIn->Close();
fileOut->Close();
if(fChain) delete fChain->GetCurrentFile();
}
#endif // #ifdef analyse2_cxx

BIN
Scripts_20161126/analyse_batch

Binary file not shown.

50
Scripts_20161126/analyse_batch.c

@ -0,0 +1,50 @@
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <TFile.h>
#include <TTree.h>
#include <TSystemDirectory.h>
#include "beammon.h"
using namespace std;
int main(int argc, char **argv)
{
// Working directories
const char *dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/";
const char *pin_dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/pin/";
const char *ext = ".root";
TSystemDirectory pin_dir(pin_dirname, pin_dirname);
if (true)
{
TSystemFile* file;
TString fname = argv[1];
// fname = file->GetName();
// execute single PiN_run***.root
if ( fname.EndsWith(ext) && !fname.BeginsWith("SAVE") && fname.BeginsWith("PiN_run"))
{
Beammon *mon = new Beammon();
printf("File name: %s \n", fname.Data());
// Main part
// Initialize(DIRName, FileName, baselineEvents, prelimEvents, beamLevel, firstFibermat, readOutFrequency in Hz, integrationTime in us)
mon->Initialize(dirname, fname.Data(), 5000, 10000, 1., true, 3000., 312.);
mon->Save();
delete mon;
}
}
return 0;
}

1839
Scripts_20161126/analyselog.txt
File diff suppressed because it is too large
View File

99
Scripts_20161126/beamenergyfile.txt

@ -0,0 +1,99 @@
12.6088 26.0593 0.0311315
10.5936 16.5399 0.0280216
9.36031 13.3199 0.0280258
8.51336 11.6258 0.0235132
7.88605 10.5871 0.0209773
7.39682 9.87477 0.0194038
7.00082 9.33725 0.0164715
6.67084 8.89845 0.0160286
6.39059 8.54168 0.0127532
6.14881 8.25087 0.0139307
5.93691 7.99531 0.0138664
5.74999 7.76564 0.01282
5.58275 7.55637 0.0129529
5.43216 7.36875 0.0128454
5.29477 7.19309 0.0111398
5.16875 7.01846 0.0103578
5.05214 6.84817 0.00969629
4.94396 6.70325 0.00972554
4.84371 6.57749 0.00964673
4.7504 6.463 0.00954754
4.62797 6.30692 0.00897132
4.51492 6.15197 0.00875604
4.41193 6.01346 0.00877936
4.31778 5.88548 0.00877201
4.23108 5.77851 0.00868174
4.15089 5.68864 0.00874538
40.9872 47.8865 0.0909095
36.5311 43.6125 0.081117
33.3966 40.5676 0.0744755
31.0354 38.0954 0.0699413
29.1728 36.0233 0.0605375
27.6535 34.2926 0.0635908
26.4152 33.1498 0.0592109
25.2997 32.039 0.0542048
24.2755 30.8067 0.0465891
23.5412 29.8613 0.0521792
22.8107 28.8944 0.0484988
22.1585 28.2189 0.0440433
21.5696 27.5259 0.0411151
21.0355 26.9188 0.0380742
20.5468 26.3472 0.0435907
20.099 25.7936 0.0405777
19.6851 25.2649 0.0385183
19.3016 24.7551 0.0368334
18.9455 24.1842 0.0345775
18.4699 23.6415 0.0312687
18.0231 23.1263 0.0307455
17.6151 22.6917 0.0302979
17.6151 22.6984 0.0281706
17.2409 22.3378 0.0337156
16.8956 21.9588 0.032412
16.5761 21.5765 0.0302888
281.17 198.344 0.335555
238.032 180.768 0.301257
212.434 169.515 0.286144
194.949 160.897 0.256141
181.707 154.209 0.247799
171.379 148.891 0.233322
163.143 144.917 0.216234
155.987 140.949 0.230964
150.13 137.817 0.230242
145.288 135.186 0.226504
140.907 132.866 0.232584
136.922 130.56 0.220793
133.574 128.654 0.211995
130.481 126.75 0.205258
127.616 124.836 0.203743
124.954 123.514 0.210293
122.474 121.916 0.201321
120.362 120.997 0.201537
118.373 119.345 0.187426
116.315 118.212 0.204463
113.872 116.875 0.214247
111.453 115.195 0.19249
109.36 113.951 0.192839
107.408 112.875 0.18453
105.71 112.05 0.194789
103.993 110.82 0.207279
444.422 284.831 0.359221
377.991 259.142 0.418472
337.641 242.55 0.443748
310.049 230.094 0.424199
289.655 220.92 0.40002
273.879 214.151 0.376549
261.017 208.541 0.370049
250.406 204.316 0.404037
241.353 200.131 0.374179
233.587 196.186 0.42935
226.809 193.373 0.408938
220.824 190.544 0.416405
215.458 187.993 0.423841
210.691 185.902 0.482707
206.301 184.085 0.440831
202.283 182.535 0.452754
198.535 180.75 0.453244
195.17 178.804 0.456629
191.994 177.244 0.500253
189.171 175.39 0.506822
185.146 174.151 0.523461

99
Scripts_20161126/beamenergyfile_iccorr.txt

@ -0,0 +1,99 @@
12.6088 128.959 20.7284
10.5936 95.4837 9.24954
9.36031 87.0192 7.38739
8.51336 84.7314 17.6166
7.88605 82.2372 6.05719
7.39682 81.7527 5.60083
7.00082 81.7537 5.7829
6.67084 81.7976 5.0973
6.39059 82.1433 7.17221
6.14881 82.407 7.06969
5.93691 82.947 9.91634
5.74999 82.9891 7.3586
5.58275 83.5301 11.9167
5.43216 83.2124 6.02971
5.29477 83.5201 7.35278
5.16875 83.491 7.05157
5.05214 83.3136 6.2484
4.94396 83.3912 7.31212
4.84371 83.62 8.73437
4.7504 83.6175 6.73136
4.62797 83.8222 6.32313
4.51492 83.8654 8.03869
4.41193 83.842 7.62379
4.31778 83.8833 7.30949
4.23108 84.0233 6.93167
4.15089 84.5444 10.1888
40.9872 71.8797 10.3145
36.5311 73.4023 9.68684
33.3966 74.7424 9.76108
31.0354 75.5445 10.1754
29.1728 76.0433 9.95471
27.6535 76.5077 12.0599
26.4152 77.3781 11.382
25.2997 78.2041 12.1852
24.2755 78.1433 9.59002
23.5412 78.2363 12.2811
22.8107 78.0838 11.1716
22.1585 78.4915 10.5306
21.5696 78.7347 10.5039
21.0355 78.7987 8.80317
20.5468 78.9939 10.7492
20.099 79.0074 9.5043
19.6851 79.0292 9.66389
19.3016 79.1502 11.1013
18.9455 78.6345 9.37855
18.4699 78.7251 7.76328
18.0231 79.2258 10.55
17.6151 79.4411 9.6731
17.6151 79.298 7.72948
17.2409 79.634 9.09783
16.8956 80.1616 11.3982
16.5761 80.4596 13.4887
281.17 43.5502 8.43378
238.032 46.7265 6.58714
212.434 49.0529 5.91582
194.949 50.8916 7.01233
181.707 52.3817 7.46123
171.379 53.4289 5.67678
163.143 54.6147 5.38848
155.987 55.6315 6.45364
150.13 56.4673 5.83532
145.288 57.217 5.56074
140.907 57.9473 5.6428
136.922 58.7927 7.79654
133.574 59.2683 6.09378
130.481 59.7611 5.97451
127.616 60.1941 6.15244
124.954 60.8589 7.68414
122.474 61.193 6.04012
120.362 61.7457 5.64887
118.373 61.9615 5.42058
116.315 62.5231 6.89418
113.872 63.116 7.91986
111.453 63.4778 5.41418
109.36 64.0516 6.06767
107.408 64.5941 5.88544
105.71 65.1075 5.32293
103.993 65.7429 9.06717
444.422 39.4118 4.00649
377.991 42.1602 5.09433
337.641 44.2701 6.54743
310.049 45.7771 6.96966
289.655 46.9075 6.16233
273.879 48.1554 6.73949
261.017 49.275 7.38948
250.406 50.288 8.59302
241.353 51.1851 8.56987
233.587 51.9352 10.5849
226.809 52.6029 9.96688
220.824 53.1174 9.47958
215.458 54.0711 11.9985
210.691 54.3844 12.1851
206.301 55.1113 11.7491
202.283 55.6644 11.8681
198.535 56.3129 12.9879
195.17 56.731 13.2111
191.994 56.999 14.1807
189.171 57.0587 13.4349
185.146 58.2794 16.4976

9
Scripts_20161126/beamenergyfile_iccorr_int_c.txt

@ -0,0 +1,9 @@
1.99418 1.34194 0.314482
2.99221 1.38547 0.223734
4.99357 1.40155 0.178545
8.00451 1.40731 0.158963
9.96037 1.41096 0.161875
14.9624 1.41761 0.140376
19.9591 1.41838 0.139773
29.9598 1.4225 0.136928
50.0967 1.42816 0.145332

10
Scripts_20161126/beamenergyfile_iccorr_int_p.txt

@ -0,0 +1,10 @@
77.5122 1.64423 0.364533
116.351 1.71581 0.271471
193.951 1.76604 0.283662
310.193 1.79322 0.190482
387.817 1.80044 0.156414
581.737 1.81313 0.143594
776.317 1.82036 0.145791
1164.85 1.82878 0.15898
1948.34 1.83416 0.182862
3130.55 1.84144 0.298605

9
Scripts_20161126/beamenergyfile_int_c.txt

@ -0,0 +1,9 @@
1.99418 209.056 0.432816
2.99221 321.651 0.558112
4.99357 538.085 0.941916
8.00451 863.684 1.44775
9.96037 1082.22 3.11746
14.9624 1623.81 3.13547
19.9591 2169.1 4.29978
29.9598 3263.4 6.79122
50.0967 5448.83 9.71554

10
Scripts_20161126/beamenergyfile_int_p.txt

@ -0,0 +1,10 @@
77.5122 429.555 0.673582
116.351 643.733 0.994535
193.951 1076.4 1.68363
310.193 1725.65 2.64345
387.817 2161.59 3.4271
581.737 3247.54 5.36572
776.317 4338.32 6.88484
1164.85 6521.11 9.97276
1948.34 10910.9 15.779
3130.55 17522.3 26.0387

2170
Scripts_20161126/beammon.h
File diff suppressed because it is too large
View File

2170
Scripts_20161126/beammon.h_old
File diff suppressed because it is too large
View File

170
Scripts_20161126/beamprofileplot.C

@ -0,0 +1,170 @@
{
gROOT->Reset();
gROOT->ProcessLine(".x /work/leverington/beamprofilemonitor/hitdata/Scripts/Scripts_20161126/lhcbStyle.C");
TFile *_file0_p = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run8.root");
TGraphErrors * g_0p = 0;
_file0_p->GetObject("example",g_0p);
TFile *_file1_p = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run32.root");
TGraphErrors * g_1p = 0;
_file1_p->GetObject("example",g_1p);
TFile *_file0_he = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run35.root");
TGraphErrors * g_0he = 0;
_file0_he->GetObject("example",g_0he);
TFile *_file1_he = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run60.root");
TGraphErrors * g_1he = 0;
_file1_he->GetObject("example",g_1he);
TFile *_file0_c = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run63.root");
TGraphErrors * g_0c = 0;
_file0_c->GetObject("example",g_0c);
TFile *_file1_c = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run86.root");
TGraphErrors * g_1c = 0;
_file1_c->GetObject("example",g_1c);
TFile *_file0_o = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run89.root");
TGraphErrors * g_0o = 0;
_file0_o->GetObject("example",g_0o);
TFile *_file1_o = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run108.root");
TGraphErrors * g_1o = 0;
_file1_o->GetObject("example",g_1o);
TCanvas *c1 = new TCanvas("c1", "canvaspad1", 800, 800);
gStyle->SetPadBorderMode(0);
gStyle->SetFrameBorderMode(0);
Float_t small = 1e-5;
c1->Divide(2,2,small,small);
c1->cd(1);
gPad->SetBottomMargin(small);
gPad->SetRightMargin(small);
gPad->SetLeftMargin(0.2);
TMultiGraph * mg_p = new TMultiGraph();
mg_p->Add(g_0p,"pc"); g_0p->SetMarkerStyle(20);g_0p->SetMarkerColor(kGray);
mg_p->Add(g_1p,"pc"); g_1p->SetMarkerStyle(20);
mg_p->Draw("a");
mg_p->SetTitle("");
// mg_p->GetXaxis()->SetTitle("Stopping Power / MeV#upointcm^{2}g^{-1}");
mg_p->GetYaxis()->SetTitle("A_{BPM} / a.u./312#mus"); mg_p->GetYaxis()->SetTitleOffset(1.5);
mg_p->GetXaxis()->SetRangeUser(4,64);
mg_p->GetYaxis()->SetRangeUser(-200,3200);
mg_p->SetMinimum(-200.);
mg_p->SetMaximum(3200.);
TLegend * mylegend = new TLegend(0.60,0.8,0.9,0.9);
mylegend->SetFillColor(0); // white background
mylegend->SetTextFont(22);
mylegend->SetBorderSize(0); // get rid of the box
mylegend->SetTextSize(0.045); // set text size
mylegend->AddEntry(g_0p,"Protons E21 I8","p"); // options: p,l,f
mylegend->AddEntry(g_1p,"Protons E255 I8","p"); // options: p,l,f
mylegend->Draw();
gPad->Modified();
c1->cd(2);
gPad->SetBottomMargin(small);
gPad->SetRightMargin(0.2);
gPad->SetLeftMargin(small);
TMultiGraph * mg_he = new TMultiGraph();
mg_he->Add(g_0he,"pc"); g_0he->SetMarkerStyle(21);g_0he->SetMarkerColor(kGray);
mg_he->Add(g_1he,"pc"); g_1he->SetMarkerStyle(21);
mg_he->Draw("a");
mg_he->SetTitle("");
// mg_he->GetXaxis()->SetTitle("Stopping Power / MeV#upointcm^{2}g^{-1}");
// mg_he->GetYaxis()->SetTitle("#A_{BPM} / [a.u./312#us]");
mg_he->GetXaxis()->SetRangeUser(4,64);
mg_he->GetYaxis()->SetRangeUser(-200,3200);
mg_he->SetMinimum(-200.);
mg_he->SetMaximum(3200.);
TLegend * mylegend2 = new TLegend(0.40,0.8,0.7,0.9);
mylegend2->SetFillColor(0); // white background
mylegend2->SetTextFont(22);
mylegend2->SetBorderSize(0); // get rid of the box
mylegend2->SetTextSize(0.045); // set text size
mylegend2->AddEntry(g_0he,"Helium E21 I8","p"); // options: p,l,f
mylegend2->AddEntry(g_1he,"Helium E255 I8","p"); // options: p,l,f
mylegend2->Draw();
gPad->Modified();
c1->cd(3);
gPad->SetTopMargin(small);
gPad->SetRightMargin(small);
gPad->SetLeftMargin(0.2);
gPad->SetTickx();
TMultiGraph * mg_c = new TMultiGraph();
mg_c->Add(g_0c,"pc"); g_0c->SetMarkerStyle(22);g_0c->SetMarkerColor(kGray);
mg_c->Add(g_1c,"pc"); g_1c->SetMarkerStyle(22);
mg_c->Draw("a");
mg_c->SetTitle("");
mg_c->GetXaxis()->SetTitle("Channel");
mg_c->GetYaxis()->SetTitle("A_{BPM} / a.u./312#mus");mg_c->GetYaxis()->SetTitleOffset(1.5);
mg_c->GetXaxis()->SetRangeUser(4,64);
mg_c->GetYaxis()->SetRangeUser(-200,3200);
mg_c->SetMinimum(-200.);
mg_c->SetMaximum(3200.);
TLegend * mylegend3 = new TLegend(0.60,0.85,0.9,0.95);
mylegend3->SetFillColor(0); // white background
mylegend3->SetTextFont(22);
mylegend3->SetBorderSize(0); // get rid of the box
mylegend3->SetTextSize(0.045); // set text size
mylegend3->AddEntry(g_0c,"Carbon E21 I8","p"); // options: p,l,f
mylegend3->AddEntry(g_1c,"Carbon E255 I8","p"); // options: p,l,f
mylegend3->Draw();
gPad->Modified();
c1->cd(4);
gPad->SetTopMargin(small);
gPad->SetRightMargin(0.2);
gPad->SetLeftMargin(small);
gPad->SetTickx();
TMultiGraph * mg_o = new TMultiGraph();
mg_o->Add(g_0o,"pc"); g_0o->SetMarkerStyle(23);g_0o->SetMarkerColor(kGray);
mg_o->Add(g_1o,"pc"); g_1o->SetMarkerStyle(23);
mg_o->Draw("a");
mg_o->SetTitle("");
mg_o->GetXaxis()->SetTitle("Channel");
//mg_o->GetYaxis()->SetTitle("#A_{BPM} / [a.u./312#us]");
mg_o->GetXaxis()->SetRangeUser(4,64);
mg_o->GetYaxis()->SetRangeUser(-200,3200);
mg_o->SetMinimum(-200.);
mg_o->SetMaximum(3200.);
TLegend * mylegend4 = new TLegend(0.40,0.85,0.7,0.95);
mylegend4->SetFillColor(0); // white background
mylegend4->SetTextFont(22);
mylegend4->SetBorderSize(0); // get rid of the box
mylegend4->SetTextSize(0.045); // set text size
mylegend4->AddEntry(g_0o,"Oxygen E21 I8","p"); // options: p,l,f
mylegend4->AddEntry(g_1o,"Oxygen E201 I8","p"); // options: p,l,f
mylegend4->Draw();
gPad->Modified();
c1->cd();
gPad->Modified();
c1->SaveAs("figs/beamprofileexamples.pdf");
c1->SaveAs("figs/beamprofileexamples.png");
}

206
Scripts_20161126/beamprofileplot_avg.C

@ -0,0 +1,206 @@
{
gROOT->Reset();
gROOT->ProcessLine(".x /work/leverington/beamprofilemonitor/hitdata/Scripts/Scripts_20161126/lhcbStyle.C");
TFile *_file0_p = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run8.root");
TH2D * g_0p = 0;
_file0_p->GetObject("th2d_beamSignal_channel",g_0p);
TProfile* g_0p_pfx = g_0p->ProfileX();
TFile *_file1_p = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run32.root");
TH2D * g_1p = 0;
_file1_p->GetObject("th2d_beamSignal_channel",g_1p);
TProfile* g_1p_pfx = g_1p->ProfileX();
TFile *_file0_he = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run35.root");
TH2D * g_0he = 0;
_file0_he->GetObject("th2d_beamSignal_channel",g_0he);
TProfile* g_0he_pfx = g_0he->ProfileX();
TFile *_file1_he = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run60.root");
TH2D * g_1he = 0;
_file1_he->GetObject("th2d_beamSignal_channel",g_1he);
TProfile* g_1he_pfx = g_1he->ProfileX();
TFile *_file0_c = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run63.root");
TH2D * g_0c = 0;
_file0_c->GetObject("th2d_beamSignal_channel",g_0c);
TProfile* g_0c_pfx = g_0c->ProfileX();
TFile *_file1_c = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run86.root");
TH2D * g_1c = 0;
_file1_c->GetObject("th2d_beamSignal_channel",g_1c);
TProfile* g_1c_pfx = g_1c->ProfileX();
TFile *_file0_o = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run89.root");
TH2D * g_0o = 0;
_file0_o->GetObject("th2d_beamSignal_channel",g_0o);
TProfile* g_0o_pfx = g_0o->ProfileX();
TFile *_file1_o = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run108.root");
TH2D * g_1o = 0;
_file1_o->GetObject("th2d_beamSignal_channel",g_1o);
TProfile* g_1o_pfx = g_1o->ProfileX();
TCanvas *c1 = new TCanvas("c1", "canvaspad1", 800, 800);
gStyle->SetPadBorderMode(0);
gStyle->SetFrameBorderMode(0);
Float_t small = 1e-5;
c1->Divide(2,2,small,small);
c1->cd(1);
gPad->SetBottomMargin(small);
gPad->SetRightMargin(small);
gPad->SetLeftMargin(0.2);
g_0p_pfx->SetMarkerStyle(20);g_0p_pfx->SetMarkerColor(kGray);
g_1p_pfx->SetMarkerStyle(20);
g_0p_pfx->SetTitle("");
// mg_p->GetXaxis()->SetTitle("Stopping Power / MeV#upointcm^{2}g^{-1}");
g_0p_pfx->GetYaxis()->SetTitle("A_{BPM} / a.u./312#mus"); g_0p_pfx->GetYaxis()->SetTitleOffset(1.5);
g_0p_pfx->GetXaxis()->SetRangeUser(4,64);
g_0p_pfx->GetYaxis()->SetRangeUser(-200,3200);
g_0p_pfx->SetMinimum(-200.);
g_0p_pfx->SetMaximum(3200.);
g_0p_pfx->Draw();
g_1p_pfx->Draw("same");
TLegend * mylegend = new TLegend(0.25,0.8,0.9,0.9);
mylegend->SetFillColor(0); // white background
mylegend->SetTextFont(22);
mylegend->SetBorderSize(0); // get rid of the box
mylegend->SetTextSize(0.045); // set text size
mylegend->AddEntry(g_0p_pfx,"Protons: 70 MeV/u, 1.2#upoint10^{9} s^{-1}","p"); // options: p,l,f
mylegend->AddEntry(g_1p_pfx,"Protons: 221 MeV/u, 1.2#upoint10^{9} s^{-1}","p"); // options: p,l,f
mylegend->Draw();
gPad->Modified();
c1->cd(2);
gPad->SetBottomMargin(small);
gPad->SetRightMargin(0.2);
gPad->SetLeftMargin(small);
g_0he_pfx->SetMarkerStyle(20);g_0he_pfx->SetMarkerColor(kGray);
g_1he_pfx->SetMarkerStyle(20);
g_0he_pfx->SetTitle("");
g_0he_pfx->GetYaxis()->SetTitle("A_{BHEM} / a.u./312#mus"); g_0he_pfx->GetYaxis()->SetTitleOffset(1.5);
g_0he_pfx->GetXaxis()->SetRangeUser(4,64);
g_0he_pfx->GetYaxis()->SetRangeUser(-200,3200);
g_0he_pfx->SetMinimum(-200.);
g_0he_pfx->SetMaximum(3200.);
g_0he_pfx->Draw();
g_1he_pfx->Draw("same");
TLegend * mylegend2 = new TLegend(0.05,0.8,0.7,0.9);
mylegend2->SetFillColor(0); // white background
mylegend2->SetTextFont(22);
mylegend2->SetBorderSize(0); // get rid of the box
mylegend2->SetTextSize(0.045); // set text size
mylegend2->AddEntry(g_0he_pfx,"Helium: 72 MeV/u, 3.0#upoint10^{8} s^{-1}","p"); // options: p,l,f
mylegend2->AddEntry(g_1he_pfx,"Helium: 221 MeV/u, 3.0#upoint10^{8} s^{-1}","p"); // options: p,l,f
mylegend2->Draw();
gPad->Modified();
c1->cd(3);
gPad->SetTopMargin(small);
gPad->SetRightMargin(small);
gPad->SetLeftMargin(0.2);
gPad->SetTickx();
g_0c_pfx->SetMarkerStyle(20);g_0c_pfx->SetMarkerColor(kGray);
g_1c_pfx->SetMarkerStyle(20);
g_0c_pfx->SetTitle("");
g_0c_pfx->GetYaxis()->SetTitle("A_{BCM} / a.u./312#mus"); g_0c_pfx->GetYaxis()->SetTitleOffset(1.5);
g_0c_pfx->GetXaxis()->SetRangeUser(4,64); g_0c_pfx->GetXaxis()->SetTitle("Channel");
g_0c_pfx->GetYaxis()->SetRangeUser(-200,3200);
g_0c_pfx->SetMinimum(-200.);
g_0c_pfx->SetMaximum(3200.);
g_0c_pfx->Draw();
g_1c_pfx->Draw("same");
TLegend * mylegend3 = new TLegend(0.25,0.85,0.9,0.95);
mylegend3->SetFillColor(0); // white background
mylegend3->SetTextFont(22);
mylegend3->SetBorderSize(0); // get rid of the box
mylegend3->SetTextSize(0.045); // set text size
mylegend3->AddEntry(g_0c_pfx,"Carbon: 130 MeV/u, 3.0#upoint10^{7} s^{-1}","p"); // options: p,l,f
mylegend3->AddEntry(g_1c_pfx,"Carbon: 430 MeV/u, 3.0#upoint10^{7} s^{-1}","p"); // options: p,l,f
mylegend3->Draw();
gPad->Modified();
c1->cd(4);
gPad->SetTopMargin(small);
gPad->SetRightMargin(0.2);
gPad->SetLeftMargin(small);
gPad->SetTickx();
g_0o_pfx->SetMarkerStyle(20);g_0o_pfx->SetMarkerColor(kGray);
g_1o_pfx->SetMarkerStyle(20);
g_0o_pfx->SetTitle("");
g_0o_pfx->GetYaxis()->SetTitle("A_{BOM} / a.u./312#mus"); g_0o_pfx->GetYaxis()->SetTitleOffset(1.5);
g_0o_pfx->GetXaxis()->SetRangeUser(4,64); g_0o_pfx->GetXaxis()->SetTitle("Channel");
g_0o_pfx->GetYaxis()->SetRangeUser(-200,3200);
g_0o_pfx->SetMinimum(-200.);
g_0o_pfx->SetMaximum(3200.);
g_0o_pfx->Draw();
g_1o_pfx->Draw("same");
TLegend * mylegend4 = new TLegend(0.05,0.85,0.7,0.95);
mylegend4->SetFillColor(0); // white background
mylegend4->SetTextFont(22);
mylegend4->SetBorderSize(0); // get rid of the box
mylegend4->SetTextSize(0.045); // set text size
mylegend4->AddEntry(g_0o_pfx,"Oxygen: 152 MeV/u, 1.5#upoint10^{7} s^{-1}","p"); // options: p,l,f
mylegend4->AddEntry(g_1o_pfx,"Oxygen: 423 MeV/u, 1.5#upoint10^{7} s^{-1}","p"); // options: p,l,f
mylegend4->Draw();
gPad->Modified();
c1->cd();
gPad->Modified();
c1->SaveAs("figs/beamprofileexamples_avg.pdf");
c1->SaveAs("figs/beamprofileexamples_avg.png");
}

26
Scripts_20161126/betadedxz2_c.prn

@ -0,0 +1,26 @@
0.407871 7.810273
0.44884 6.612007
0.479338 5.90094
0.503822 5.415237
0.524858 5.04743
0.543065 4.760538
0.5589 4.531764
0.573741 4.332961
0.586721 4.170288
0.59808 4.035782
0.608891 3.914071
0.619196 3.803392
0.628229 3.710382
0.636893 3.624484
0.645213 3.544902
0.653209 3.470957
0.6609 3.402064
0.667643 3.343389
0.674162 3.288136
0.681086 3.230961
0.689547 3.163124
0.698204 3.095927
0.705926 3.037769
0.713327 2.983549
0.719927 2.936386
0.726761 2.8887

26
Scripts_20161126/betadedxz2_he.prn

@ -0,0 +1,26 @@
0.347272 10.2468
0.371222 9.132771
0.391037 8.349158
0.408018 7.758848
0.422922 7.293203
0.436235 6.913377
0.447968 6.603796
0.459299 6.324933
0.470415 6.06888
0.478846 5.885299
0.487649 5.702666
0.495887 5.539637
0.503656 5.392399
0.510991 5.258883
0.517959 5.136701
0.524572 5.024748
0.530889 4.921279
0.536926 4.825409
0.542699 4.736374
0.550671 4.617484
0.558452 4.505773
0.565815 4.403786
0.565815 4.403786
0.572799 4.310232
0.579449 4.223902
0.585785 4.144029

21
Scripts_20161126/betadedxz2_o.prn

@ -0,0 +1,21 @@
0.436386 6.944096
0.479001 5.906112
0.511349 5.275644
0.537325 4.844508
0.559062 4.525853
0.577647 4.27936
0.594124 4.078395
0.608731 3.912595
0.621998 3.771135
0.634024 3.649797
0.645051 3.543884
0.655227 3.45037
0.664724 3.36653
0.673476 3.292046
0.681811 3.223452
0.689682 3.160675
0.697243 3.102108
0.704219 3.049525
0.710969 2.999914
0.717113 2.955795
0.726111 2.892908

26
Scripts_20161126/betadedxz2_p.prn

@ -0,0 +1,26 @@
0.308525 12.60876
0.340994 10.59358
0.366173 9.360309
0.386744 8.513361
0.404198 7.886052
0.419413 7.396822
0.432945 7.000816
0.44518 6.670844
0.456345 6.390587
0.466617 6.148805
0.476154 5.936913
0.485023 5.749985
0.493348 5.582752
0.501186 5.432157
0.508639 5.294766
0.515744 5.168745
0.522563 5.052145
0.529111 4.943962
0.53538 4.843711
0.541398 4.750403
0.549576 4.627975
0.557429 4.514919
0.564849 4.411926
0.571868 4.317781
0.578541 4.231076
0.5849 4.150888

99
Scripts_20161126/betadedxz2_sum.prn

@ -0,0 +1,99 @@
0.308525 12.60876
0.340994 10.59358
0.366173 9.360309
0.386744 8.513361
0.404198 7.886052
0.419413 7.396822
0.432945 7.000816
0.44518 6.670844
0.456345 6.390587
0.466617 6.148805
0.476154 5.936913
0.485023 5.749985
0.493348 5.582752
0.501186 5.432157
0.508639 5.294766
0.515744 5.168745
0.522563 5.052145
0.529111 4.943962
0.53538 4.843711
0.541398 4.750403
0.549576 4.627975
0.557429 4.514919
0.564849 4.411926
0.571868 4.317781
0.578541 4.231076
0.5849 4.150888
0.347272 10.2468
0.371222 9.132771
0.391037 8.349158
0.408018 7.758848
0.422922 7.293203
0.436235 6.913377
0.447968 6.603796
0.459299 6.324933
0.470415 6.06888
0.478846 5.885299
0.487649 5.702666
0.495887 5.539637
0.503656 5.392399
0.510991 5.258883
0.517959 5.136701
0.524572 5.024748
0.530889 4.921279
0.536926 4.825409
0.542699 4.736374
0.550671 4.617484
0.558452 4.505773
0.565815 4.403786
0.565815 4.403786
0.572799 4.310232
0.579449 4.223902
0.585785 4.144029
0.407871 7.810273
0.44884 6.612007
0.479338 5.90094
0.503822 5.415237
0.524858 5.04743
0.543065 4.760538
0.5589 4.531764
0.573741 4.332961
0.586721 4.170288
0.59808 4.035782
0.608891 3.914071
0.619196 3.803392
0.628229 3.710382
0.636893 3.624484
0.645213 3.544902
0.653209 3.470957
0.6609 3.402064
0.667643 3.343389
0.674162 3.288136
0.681086 3.230961
0.689547 3.163124
0.698204 3.095927
0.705926 3.037769
0.713327 2.983549
0.719927 2.936386
0.726761 2.8887
0.436386 6.944096
0.479001 5.906112
0.511349 5.275644
0.537325 4.844508
0.559062 4.525853
0.577647 4.27936
0.594124 4.078395
0.608731 3.912595
0.621998 3.771135
0.634024 3.649797
0.645051 3.543884
0.655227 3.45037
0.664724 3.36653
0.673476 3.292046
0.681811 3.223452
0.689682 3.160675
0.697243 3.102108
0.704219 3.049525
0.710969 2.999914
0.717113 2.955795
#REF! 2.892908

19
Scripts_20161126/carbonAIR_80_480MeV.txt

@ -0,0 +1,19 @@
7.500000E+01 2.894501E+02
8.750000E+01 2.574361E+02
1.000000E+02 2.329849E+02
1.125000E+02 2.136804E+02
1.250000E+02 1.980438E+02
1.375000E+02 1.851133E+02
1.500000E+02 1.742426E+02
1.625000E+02 1.649735E+02
1.750000E+02 1.569761E+02
1.875000E+02 1.500068E+02
2.000000E+02 1.438792E+02
2.125000E+02 1.384516E+02
2.250000E+02 1.336103E+02
2.375000E+02 1.292671E+02
2.500000E+02 1.253484E+02
3.125000E+02 1.104071E+02
3.750000E+02 1.004445E+02
4.375000E+02 9.337248E+01
5.000000E+02 8.813937E+01

18
Scripts_20161126/carbonPS_80_480MeV.txt

@ -0,0 +1,18 @@
7.500E+01 3.20E+02
8.75E+01 2.84E+02
1.00E+02 2.57E+02
1.13E+02 2.36E+02
1.25E+02 2.19E+02
1.38E+02 2.04E+02
1.50E+02 1.92E+02
1.63E+02 1.82E+02
1.75E+02 1.73E+02
1.88E+02 1.65E+02
2.00E+02 1.59E+02
2.13E+02 1.53E+02
2.25E+02 1.47E+02
2.38E+02 1.42E+02
2.50E+02 1.38E+02
3.13E+02 1.22E+02
3.75E+02 1.11E+02
4.38E+02 1.03E+02

99
Scripts_20161126/chi2Fitfile.txt

@ -0,0 +1,99 @@
12.6088 20.3634 11.1537
10.5936 20.6182 10.6477
9.36031 15.5537 9.76529
8.51336 9.44078 6.76873
7.88605 6.37224 4.75776
7.39682 4.92058 3.57306
7.00082 4.1935 2.85133
6.67084 3.86599 2.57667
6.39059 3.56702 1.98374
6.14881 3.49191 1.97002
5.93691 3.45275 1.92285
5.74999 3.3669 1.84875
5.58275 3.15671 1.69426
5.43216 2.97753 1.62671
5.29477 2.9154 1.44064
5.16875 2.96014 1.3941
5.05214 3.05103 1.37855
4.94396 3.10465 1.40033
4.84371 3.03109 1.40071
4.7504 2.93737 1.40913
4.62797 2.88782 1.33028
4.51492 2.84938 1.27207
4.41193 2.86092 1.34112
4.31778 2.82437 1.35222
4.23108 2.66717 1.24865
4.15089 2.56732 1.22622
40.9872 6.27994 5.27253
36.5311 7.98245 5.95622
33.3966 7.69429 5.86554
31.0354 7.40941 5.73265
29.1728 6.95924 5.16832
27.6535 6.71957 5.26465
26.4152 5.80407 4.77077
25.2997 5.07125 4.16969
24.2755 4.73635 3.91417
23.5412 4.64903 3.77974
22.8107 4.58451 3.80093
22.1585 4.33735 3.53638
21.5696 4.0856 3.33621
21.0355 3.91087 3.22633
20.5468 3.84207 3.19165
20.099 3.79036 3.15216
19.6851 3.74294 3.00686
19.3016 3.68234 2.97015
18.9455 4.04961 3.08459
18.4699 4.02563 2.81425
18.0231 3.74136 2.8403
17.6151 3.3789 2.89056
17.6151 3.38941 2.86236
17.2409 3.10597 2.84523
16.8956 2.86027 2.64809
16.5761 3.02195 2.74544
281.17 2.51407 1.80546
238.032 3.4344 2.10719
212.434 3.91328 2.16306
194.949 3.56708 1.92578
181.707 3.25547 1.78568
171.379 3.03152 1.68562
163.143 2.85541 1.65988
155.987 2.73222 1.6939
150.13 2.5825 1.56581
145.288 2.45023 1.50333
140.907 2.38656 1.49533
136.922 2.43088 1.52539
133.574 2.39842 1.51231
130.481 2.40578 1.46911
127.616 2.36759 1.48596
124.954 2.25557 1.41603
122.474 2.21641 1.41673
120.362 2.01775 1.30119
118.373 1.99875 1.25997
116.315 2.15023 1.4044
113.872 2.1622 1.51406
111.453 1.92624 1.24386
109.36 1.8882 1.17632
107.408 1.93052 1.23876
105.71 1.87902 1.30628
103.993 1.71834 1.17401
444.422 2.30446 1.35946
377.991 2.89209 1.66642
337.641 3.19218 1.84203
310.049 2.88358 1.68625
289.655 2.63785 1.5106
273.879 2.48887 1.48871
261.017 2.37289 1.40968
250.406 2.28575 1.49957
241.353 2.24967 1.4413
233.587 2.19389 1.47229
226.809 2.13171 1.47363
220.824 2.11266 1.5272
215.458 2.05617 1.5094
210.691 2.05026 1.62731
206.301 2.04247 1.57505
202.283 2.0354 1.60618
198.535 2.00556 1.63287
195.17 1.94762 1.57306
191.994 1.82921 1.57821
189.171 1.74854 1.54742
185.146 1.83462 1.74169

9
Scripts_20161126/chi2Fitfile_int_c.txt

@ -0,0 +1,9 @@
1.99418 0.214024 0.0917043
2.99221 0.249229 0.199669
4.99357 0.319172 0.214879
8.00451 0.441951 0.235403
9.96037 0.525536 0.300576
14.9624 0.79445 0.501568
19.9591 1.10916 0.716665
29.9598 1.85144 1.35545
50.0967 3.99519 2.78064

10
Scripts_20161126/chi2Fitfile_int_p.txt

@ -0,0 +1,10 @@
77.5122 0.178151 0.0973584
116.351 0.19269 0.0739868
193.951 0.242582 0.268916
310.193 0.350289 0.298958
387.817 0.441891 0.288529
581.737 0.758055 0.396344
776.317 1.13869 0.636143
1164.85 2.30088 1.28206
1948.34 5.6006 2.91198
3130.55 13.0692 6.72719

145
Scripts_20161126/combinedFit.C

@ -0,0 +1,145 @@
//+ Combined (simultaneous) fit of two histogram with separate functions
// and some common parameters
//
// See http://root.cern.ch/phpBB3//viewtopic.php?f=3&t=11740#p50908
// for a modified version working with Fumili or GSLMultiFit
//
// N.B. this macro must be compiled with ACliC
//
//Author: L. Moneta - Dec 2010
#include "Fit/Fitter.h"
#include "Fit/BinData.h"
#include "Fit/Chi2FCN.h"
#include "TH1.h"
#include "TList.h"
#include "Math/WrappedMultiTF1.h"
#include "HFitInterface.h"
#include "TCanvas.h"
#include "TStyle.h"
// definition of shared parameter
// background function
int iparB[2] = { 0, // exp amplitude in B histo
2 // exp common parameter
};
// signal + background function
int iparSB[5] = { 1, // exp amplitude in S+B histo
2, // exp common parameter
3, // gaussian amplitude
4, // gaussian mean
5 // gaussian sigma
};
struct GlobalChi2 {
GlobalChi2( ROOT::Math::IMultiGenFunction & f1,
ROOT::Math::IMultiGenFunction & f2) :
fChi2_1(&f1), fChi2_2(&f2) {}
// parameter vector is first background (in common 1 and 2)
// and then is signal (only in 2)
double operator() (const double *par) const {
double p1[2];
for (int i = 0; i < 2; ++i) p1[i] = par[iparB[i] ];
double p2[5];
for (int i = 0; i < 5; ++i) p2[i] = par[iparSB[i] ];
return (*fChi2_1)(p1) + (*fChi2_2)(p2);
}
const ROOT::Math::IMultiGenFunction * fChi2_1;
const ROOT::Math::IMultiGenFunction * fChi2_2;
};
void combinedFit() {
#if defined(__CINT__) && !defined(__MAKECINT__)
cout << "ERROR: This tutorial can run only using ACliC, you must run it by doing: " << endl;
cout << "\t .x $ROOTSYS/tutorials/fit/combinedFit.C+" << endl;
return;
#endif
TH1D * hB = new TH1D("hB","histo B",100,0,100);
TH1D * hSB = new TH1D("hSB","histo S+B",100, 0,100);
TF1 * fB = new TF1("fB","expo",0,100);
fB->SetParameters(1,-0.05);
hB->FillRandom("fB");
TF1 * fS = new TF1("fS","gaus",0,100);
fS->SetParameters(1,30,5);
hSB->FillRandom("fB",2000);
hSB->FillRandom("fS",1000);
// perform now global fit
TF1 * fSB = new TF1("fSB","expo + gaus(2)",0,100);
ROOT::Math::WrappedMultiTF1 wfB(*fB,1);
ROOT::Math::WrappedMultiTF1 wfSB(*fSB,1);
ROOT::Fit::DataOptions opt;
ROOT::Fit::DataRange rangeB;
// set the data range
rangeB.SetRange(10,90);
ROOT::Fit::BinData dataB(opt,rangeB);
ROOT::Fit::FillData(dataB, hB);
ROOT::Fit::DataRange rangeSB;
rangeSB.SetRange(10,50);
ROOT::Fit::BinData dataSB(opt,rangeSB);
ROOT::Fit::FillData(dataSB, hSB);
ROOT::Fit::Chi2Function chi2_B(dataB, wfB);
ROOT::Fit::Chi2Function chi2_SB(dataSB, wfSB);
GlobalChi2 globalChi2(chi2_B, chi2_SB);
ROOT::Fit::Fitter fitter;
const int Npar = 6;
double par0[Npar] = { 5,5,-0.1,100, 30,10};
// create before the parameter settings in order to fix or set range on them
fitter.Config().SetParamsSettings(6,par0);
// fix 5-th parameter
fitter.Config().ParSettings(4).Fix();
// set limits on the third and 4-th parameter
fitter.Config().ParSettings(2).SetLimits(-10,-1.E-4);
fitter.Config().ParSettings(3).SetLimits(0,10000);
fitter.Config().ParSettings(3).SetStepSize(5);
fitter.Config().MinimizerOptions().SetPrintLevel(0);
fitter.Config().SetMinimizer("Minuit2","Migrad");
// fit FCN function directly
// (specify optionally data size and flag to indicate that is a chi2 fit)
fitter.FitFCN(6,globalChi2,0,dataB.Size()+dataSB.Size(),true);
ROOT::Fit::FitResult result = fitter.Result();
result.Print(std::cout);
TCanvas * c1 = new TCanvas("Simfit","Simultaneous fit of two histograms",
10,10,700,700);
c1->Divide(1,2);
c1->cd(1);
gStyle->SetOptFit(1111);
fB->SetFitResult( result, iparB);
fB->SetRange(rangeB().first, rangeB().second);
fB->SetLineColor(kBlue);
hB->GetListOfFunctions()->Add(fB);
hB->Draw();
c1->cd(2);
fSB->SetFitResult( result, iparSB);
fSB->SetRange(rangeSB().first, rangeSB().second);
fSB->SetLineColor(kRed);
hSB->GetListOfFunctions()->Add(fSB);
hSB->Draw();
}

288
Scripts_20161126/combinedFit_hit.C

@ -0,0 +1,288 @@
//+ Combined (simultaneous) fit of two histogram with separate functions
// and some common parameters
//
// See http://root.cern.ch/phpBB3//viewtopic.php?f=3&t=11740#p50908
// for a modified version working with Fumili or GSLMultiFit
//
// N.B. this macro must be compiled with ACliC
//
//Author: L. Moneta - Dec 2010
#include "Fit/Fitter.h"
#include "Fit/BinData.h"
#include "Fit/Chi2FCN.h"
#include "TH1.h"
#include "TList.h"
#include "Math/WrappedMultiTF1.h"
#include "HFitInterface.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TGraphErrors.h"
#include "TLegend.h"
#include "TMultiGraph.h"
// definition of shared parameter
// background function
int iparB[3] = { 0, // exp amplitude in B histo
1, // T_0
2 // common parameter
};
// signal + background function
int iparSB2[3] = { 3, // amplitude in S+B histo
4, // T_0
2, // common parameter
};
int iparSB3[3] = { 5, // amplitude
6, // T_0
2, // common parameter
};
int iparSB4[3] = { 7, // amplitude
8, // T_0
2, // common parameter
};
struct GlobalChi2 {
GlobalChi2( ROOT::Math::IMultiGenFunction & f1,
ROOT::Math::IMultiGenFunction & f2,
ROOT::Math::IMultiGenFunction & f3,
ROOT::Math::IMultiGenFunction & f4) :
fChi2_1(&f1), fChi2_2(&f2), fChi2_3(&f3), fChi2_4(&f4) {}
// parameter vector is first background (in common 1 and 2)
// and then is signal (only in 2)
double operator() (const double *par) const {
double p1[3];
for (int i = 0; i < 3; ++i) p1[i] = par[iparB[i] ];
double p2[3];
for (int i = 0; i < 3; ++i) p2[i] = par[iparSB2[i] ];
double p3[3];
for (int i = 0; i < 3; ++i) p3[i] = par[iparSB3[i] ];
double p4[3];
for (int i = 0; i < 3; ++i) p4[i] = par[iparSB4[i] ];
return (*fChi2_1)(p1) + (*fChi2_2)(p2) + (*fChi2_3)(p3) + (*fChi2_4)(p4);
}
const ROOT::Math::IMultiGenFunction * fChi2_1;
const ROOT::Math::IMultiGenFunction * fChi2_2;
const ROOT::Math::IMultiGenFunction * fChi2_3;
const ROOT::Math::IMultiGenFunction * fChi2_4;
};
void combinedFit_hit() {
#if defined(__CINT__) && !defined(__MAKECINT__)
cout << "ERROR: This tutorial can run only using ACliC, you must run it by doing: " << endl;
cout << "\t .x $ROOTSYS/tutorials/fit/combinedFit_hit.C+" << endl;
return;
#endif
TF1 * fB = new TF1("fB","[0]*( (1- 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x )) / (1+[2]* (1- 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x ))*1.0*1.65901*TMath::Power(x,-1.7218)) + 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x ) ) ",0,1);//energy units in keV
//TF1 * fB = new TF1("fB","[0]*( (1-[1]) / (1+[2]* (1- [1])*1.0*1.65901*TMath::Power(x,-1.7218)) +[1] ) ",0,1);
TF1 * fSB2 = new TF1("fSB2","[0]*( (1- 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x )) / (1+[2]* (1- 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x ))*4.0*1.65901*TMath::Power(x,-1.7218)) + 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x ) ) ",0,1);//energy units in keV
//TF1 * fSB2 = new TF1("fSB2","[0]*( (1-[1]) / (1+[2]* (1- [1])*4.0*1.65901*TMath::Power(x,-1.7218)) +[1] ) ",0,1);
TF1 * fSB3 = new TF1("fSB3","[0]*( (1- 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x )) / (1+[2]* (1- 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x ))*36.0*1.65901*TMath::Power(x,-1.7218)) + 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x ) ) ",0,1);//energy units in keV
//TF1 * fSB3 = new TF1("fSB3","[0]*( (1-[1]) / (1+[2]* (1- [1])*36.0*1.65901*TMath::Power(x,-1.7218)) +[1] ) ",0,1);
TF1 * fSB4 = new TF1("fSB4","[0]*( (1- 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x )) / (1+[2]* (1- 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x ))*64.0*1.65901*TMath::Power(x,-1.7218)) + 0.5*(TMath::Log(2*0.511E3*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E3*x*x/(1-x*x)/0.0687) -x*x ) ) ",0,1); //energy units in keV
// TF1 * fSB4 = new TF1("fSB4","[0]*( (1-[1]) / (1+[2]* (1- [1])*64.0*1.65901*TMath::Power(x,-1.7218)) +[1] ) ",0,1);
TGraphErrors * hB = new TGraphErrors("energylist_p_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB2 = new TGraphErrors("energylist_he_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB3 = new TGraphErrors("energylist_c_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB4 = new TGraphErrors("energylist_o_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hB_2 = new TGraphErrors("energylist_p_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB2_2 = new TGraphErrors("energylist_he_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB3_2 = new TGraphErrors("energylist_c_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB4_2 = new TGraphErrors("energylist_o_bpmbeta1.txt","%lg %lg %lg");
// perform now global fit
// TF1 * fSB2 = new TF1("fSB2","expo + gaus(2)",0,100);
ROOT::Math::WrappedMultiTF1 wfB(*fB,1);
ROOT::Math::WrappedMultiTF1 wfSB2(*fSB2,1);
ROOT::Math::WrappedMultiTF1 wfSB3(*fSB3,1);
ROOT::Math::WrappedMultiTF1 wfSB4(*fSB4,1);
ROOT::Fit::DataOptions opt;
ROOT::Fit::DataRange rangeB;
// set the data range
rangeB.SetRange(0.3,0.59);
ROOT::Fit::BinData dataB(opt,rangeB);
ROOT::Fit::FillData(dataB, hB);
ROOT::Fit::DataRange rangeSB2;
rangeSB2.SetRange(0.34,0.59);
ROOT::Fit::BinData dataSB2(opt,rangeSB2);
ROOT::Fit::FillData(dataSB2, hSB2);
ROOT::Fit::DataRange rangeSB3;
rangeSB3.SetRange(0.4,0.73);
ROOT::Fit::BinData dataSB3(opt,rangeSB3);
ROOT::Fit::FillData(dataSB3, hSB3);
ROOT::Fit::DataRange rangeSB4;
rangeSB4.SetRange(0.43,0.73);
ROOT::Fit::BinData dataSB4(opt,rangeSB4);
ROOT::Fit::FillData(dataSB4, hSB4);
ROOT::Fit::Chi2Function chi2_B(dataB, wfB);
ROOT::Fit::Chi2Function chi2_SB2(dataSB2, wfSB2);
ROOT::Fit::Chi2Function chi2_SB3(dataSB3, wfSB3);
ROOT::Fit::Chi2Function chi2_SB4(dataSB4, wfSB4);
GlobalChi2 globalChi2(chi2_B, chi2_SB2, chi2_SB3, chi2_SB4);
ROOT::Fit::Fitter fitter;
const int Npar = 9;
double par0[Npar] = {2,10,0.15,2, 10,2, 10,2, 10};
// double par0[Npar] = {1.4,0.000007,0.15,1.4, 0.00250,2, 0.005,2, 0.007};
// create before the parameter settings in order to fix or set range on them
fitter.Config().SetParamsSettings(Npar,par0);
// fix 5-th parameter
// fitter.Config().ParSettings(1).Fix();
// set limits on the third and 4-th parameter
fitter.Config().ParSettings(0).SetLimits(0,5);
fitter.Config().ParSettings(3).SetLimits(0,5);
fitter.Config().ParSettings(5).SetLimits(0,5);
fitter.Config().ParSettings(7).SetLimits(0,5);
fitter.Config().ParSettings(1).SetLimits(0,1000);
fitter.Config().ParSettings(4).SetLimits(0,1000);//1
fitter.Config().ParSettings(6).SetLimits(0,1000);//10
fitter.Config().ParSettings(8).SetLimits(0,1000);//10
fitter.Config().ParSettings(2).SetLimits(0,1.0);
// fitter.Config().ParSettings(4).SetStepSize(2);
// fitter.Config().ParSettings(1).SetStepSize(0.1);
// fitter.Config().ParSettings(6).SetStepSize(10);
// fitter.Config().ParSettings(8).SetStepSize(10);
fitter.Config().MinimizerOptions().SetPrintLevel(0);
fitter.Config().SetMinimizer("Minuit2","Migrad"); //Minuit2
//fitter.Config().SetNormErrors(true);
// fit FCN function directly
// (specify optionally data size and flag to indicate that is a chi2 fit)
fitter.FitFCN(9,globalChi2,0,dataB.Size()+dataSB2.Size()+dataSB3.Size()+dataSB4.Size(),true);
ROOT::Fit::FitResult result = fitter.Result();
result.Print(std::cout, true);
//result.PrintCovMatrix(std::cout);
cout << "FitResult.Status() = " << result.Status() << endl;
TCanvas * c1 = new TCanvas("Simfit","Simultaneous fit of two histograms",
10,10,700,700);
// c1->Divide(2,2);
// c1->cd(1);
// gStyle->SetOptFit(1111);
fB->SetFitResult( result, iparB);
fB->SetRange(rangeB().first, rangeB().second);
fB->SetLineColor(kRed);
hB->GetListOfFunctions()->Add(fB);
//hB->Draw("AP");
// c1->cd(2);
fSB2->SetFitResult( result, iparSB2);
fSB2->SetRange(rangeSB2().first, rangeSB2().second);
fSB2->SetLineColor(kRed);
hSB2->GetListOfFunctions()->Add(fSB2);
// hSB2->Draw("AP");
// c1->cd(3);
fSB3->SetFitResult( result, iparSB3);
fSB3->SetRange(rangeSB3().first, rangeSB3().second);
fSB3->SetLineColor(kRed);
hSB3->GetListOfFunctions()->Add(fSB3);
// hSB3->Draw("AP");
// c1->cd(4);
fSB4->SetFitResult( result, iparSB4);
fSB4->SetRange(rangeSB4().first, rangeSB4().second);
fSB4->SetLineColor(kRed);
hSB4->GetListOfFunctions()->Add(fSB4);
// hSB4->Draw("AP");
TMultiGraph * mg_e9 = new TMultiGraph();
mg_e9->Add(hB,"p"); hB->SetMarkerStyle(20);
mg_e9->Add(hSB2,"p"); hSB2->SetMarkerStyle(21);
mg_e9->Add(hSB3,"p"); hSB3->SetMarkerStyle(22);
mg_e9->Add(hSB4,"p"); hSB4->SetMarkerStyle(23);
mg_e9->Draw("a"); //must draw first before labeling axes
mg_e9->SetTitle(" ");
mg_e9->GetXaxis()->SetTitle("Lorentz #beta");
mg_e9->GetYaxis()->SetTitle("dA/dE / (10^{-6} a.u./(Mev#upointion#upoints^{-1})");
mg_e9->SetMinimum(0.5);
mg_e9->SetMaximum(1.4);
/* TF1 * tf1_birk1 = new TF1("tf1_birk1","[0]*(1/(1+[1]*1.65901*TMath::Power(x,-1.7218)))",0.3,0.59);
TF1 * tf1_birk2 = new TF1("tf1_birk2","[0]*(1/(1+[1]*4*1.65901*TMath::Power(x,-1.7218)))",0.34,0.59);
TF1 * tf1_birk3 = new TF1("tf1_birk3","[0]*(1/(1+[1]*36*1.65901*TMath::Power(x,-1.7218)))",0.4,0.73);
TF1 * tf1_birk4 = new TF1("tf1_birk4","[0]*(1/(1+[1]*64*1.65901*TMath::Power(x,-1.7218)))",0.43,0.73);
tf1_birk1->SetParameters(1,0.01);tf1_birk1->SetLineStyle(2);tf1_birk1->SetLineColor(kBlack);
tf1_birk2->SetParameters(1,0.01);tf1_birk2->SetLineStyle(2);tf1_birk2->SetLineColor(kBlack);
tf1_birk3->SetParameters(1,0.01);tf1_birk3->SetLineStyle(2);tf1_birk3->SetLineColor(kBlack);
tf1_birk4->SetParameters(1,0.01);tf1_birk4->SetLineStyle(2);tf1_birk4->SetLineColor(kBlack);
hB_2->Fit(tf1_birk1);
hSB2_2->Fit(tf1_birk2);
hSB3_2->Fit(tf1_birk3);
hSB4_2->Fit(tf1_birk4);
tf1_birk1->Draw("same");
tf1_birk2->Draw("same");
tf1_birk3->Draw("same");
tf1_birk4->Draw("same");
*/
TLegend * mylegende9 = new TLegend(0.65,0.65,0.9,0.9);
mylegende9->SetFillColor(0); // white background
mylegende9->SetTextFont(22);
mylegende9->SetBorderSize(0); // get rid of the box
mylegende9->SetTextSize(0.035); // set text size
mylegende9->AddEntry(hB,"Protons","p"); // options: p,l,f
mylegende9->AddEntry(hSB2,"Helium","p"); // options: p,l,f
mylegende9->AddEntry(hSB3,"Carbon","p"); // options: p,l,f
mylegende9->AddEntry(hSB4,"Oxygen","p"); // options: p,l,f
mylegende9->AddEntry(fB,"BVT Fit","l"); // options: p,l,f
// mylegende9->AddEntry(tf1_birk1,"Birks Fit","l"); // options: p,l,f
// mylegende9->AddEntry(tf1_pow1,"[1]#upointpow(#beta,[2])}","l"); // options: p,l,f
mylegende9->Draw();
gPad->Modified();
c1->SaveAs("figs/bvt_beta_combinedfit.pdf");
c1->SaveAs("figs/bvt_beta_combinedfit.png");
c1->SaveAs("figs/bvt_beta_combinedfit.C");
}

282
Scripts_20161126/combinedFit_hit2.C

@ -0,0 +1,282 @@
//+ Combined (simultaneous) fit of two histogram with separate functions
// and some common parameters
//
// See http://root.cern.ch/phpBB3//viewtopic.php?f=3&t=11740#p50908
// for a modified version working with Fumili or GSLMultiFit
//
// N.B. this macro must be compiled with ACliC
//
//Author: L. Moneta - Dec 2010
#include "Fit/Fitter.h"
#include "Fit/BinData.h"
#include "Fit/Chi2FCN.h"
#include "TH1.h"
#include "TList.h"
#include "Math/WrappedMultiTF1.h"
#include "HFitInterface.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TGraphErrors.h"
#include "TLegend.h"
#include "TMultiGraph.h"
// definition of shared parameter
// background function
int iparB[3] = { 0, // exp amplitude in B histo
1, // T_0
2 // common parameter
};
// signal + background function
int iparSB2[3] = { 0, // amplitude in S+B histo
3, // T_0
2, // common parameter
};
int iparSB3[3] = { 0, // amplitude
4, // T_0
2, // common parameter
};
int iparSB4[3] = { 0, // amplitude
5, // T_0
2, // common parameter
};
struct GlobalChi2 {
GlobalChi2( ROOT::Math::IMultiGenFunction & f1,
ROOT::Math::IMultiGenFunction & f2,
ROOT::Math::IMultiGenFunction & f3,
ROOT::Math::IMultiGenFunction & f4) :
fChi2_1(&f1), fChi2_2(&f2), fChi2_3(&f3), fChi2_4(&f4) {}
// parameter vector is first background (in common 1 and 2)
// and then is signal (only in 2)
double operator() (const double *par) const {
double p1[3];
for (int i = 0; i < 3; ++i) p1[i] = par[iparB[i] ];
double p2[3];
for (int i = 0; i < 3; ++i) p2[i] = par[iparSB2[i] ];
double p3[3];
for (int i = 0; i < 3; ++i) p3[i] = par[iparSB3[i] ];
double p4[3];
for (int i = 0; i < 3; ++i) p4[i] = par[iparSB4[i] ];
return (*fChi2_1)(p1) + (*fChi2_2)(p2) + (*fChi2_3)(p3) + (*fChi2_4)(p4);
}
const ROOT::Math::IMultiGenFunction * fChi2_1;
const ROOT::Math::IMultiGenFunction * fChi2_2;
const ROOT::Math::IMultiGenFunction * fChi2_3;
const ROOT::Math::IMultiGenFunction * fChi2_4;
};
void combinedFit_hit2() {
#if defined(__CINT__) && !defined(__MAKECINT__)
cout << "ERROR: This tutorial can run only using ACliC, you must run it by doing: " << endl;
cout << "\t .x $ROOTSYS/tutorials/fit/combinedFit_hit.C+" << endl;
return;
#endif
TF1 * fB = new TF1("fB","[0]*( (1- 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x )) / (1+[2]* (1- 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x ))*1.0*1.65901*TMath::Power(x,-1.7218)) + 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x ) ) ",0,1);//energy units in keV
//TF1 * fB = new TF1("fB","[0]*( (1-[1]) / (1+[2]* (1- [1])*1.0*1.65901*TMath::Power(x,-1.7218)) +[1] ) ",0,1);
TF1 * fSB2 = new TF1("fSB2","[0]*( (1- 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x )) / (1+[2]* (1- 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x ))*4.0*1.65901*TMath::Power(x,-1.7218)) + 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x ) ) ",0,1);//energy units in keV
//TF1 * fSB2 = new TF1("fSB2","[0]*( (1-[1]) / (1+[2]* (1- [1])*4.0*1.65901*TMath::Power(x,-1.7218)) +[1] ) ",0,1);
TF1 * fSB3 = new TF1("fSB3","[0]*( (1- 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x )) / (1+[2]* (1- 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x ))*36.0*1.65901*TMath::Power(x,-1.7218)) + 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x ) ) ",0,1);//energy units in keV
//TF1 * fSB3 = new TF1("fSB3","[0]*( (1-[1]) / (1+[2]* (1- [1])*36.0*1.65901*TMath::Power(x,-1.7218)) +[1] ) ",0,1);
TF1 * fSB4 = new TF1("fSB4","[0]*( (1- 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x )) / (1+[2]* (1- 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x ))*64.0*1.65901*TMath::Power(x,-1.7218)) + 0.5*(TMath::Log(2*0.511E6*x*x/(1-x*x)/[1]) -x*x )/(TMath::Log(2*0.511E6*x*x/(1-x*x)/68.7) -x*x ) ) ",0,1); //energy units in keV
// TF1 * fSB4 = new TF1("fSB4","[0]*( (1-[1]) / (1+[2]* (1- [1])*64.0*1.65901*TMath::Power(x,-1.7218)) +[1] ) ",0,1);
TGraphErrors * hB = new TGraphErrors("energylist_p_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB2 = new TGraphErrors("energylist_he_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB3 = new TGraphErrors("energylist_c_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB4 = new TGraphErrors("energylist_o_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hB_2 = new TGraphErrors("energylist_p_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB2_2 = new TGraphErrors("energylist_he_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB3_2 = new TGraphErrors("energylist_c_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB4_2 = new TGraphErrors("energylist_o_bpmbeta1.txt","%lg %lg %lg");
// perform now global fit
// TF1 * fSB2 = new TF1("fSB2","expo + gaus(2)",0,100);
ROOT::Math::WrappedMultiTF1 wfB(*fB,1);
ROOT::Math::WrappedMultiTF1 wfSB2(*fSB2,1);
ROOT::Math::WrappedMultiTF1 wfSB3(*fSB3,1);
ROOT::Math::WrappedMultiTF1 wfSB4(*fSB4,1);
ROOT::Fit::DataOptions opt;
ROOT::Fit::DataRange rangeB;
// set the data range
rangeB.SetRange(0.3,0.59);
ROOT::Fit::BinData dataB(opt,rangeB);
ROOT::Fit::FillData(dataB, hB);
ROOT::Fit::DataRange rangeSB2;
rangeSB2.SetRange(0.34,0.59);
ROOT::Fit::BinData dataSB2(opt,rangeSB2);
ROOT::Fit::FillData(dataSB2, hSB2);
ROOT::Fit::DataRange rangeSB3;
rangeSB3.SetRange(0.4,0.73);
ROOT::Fit::BinData dataSB3(opt,rangeSB3);
ROOT::Fit::FillData(dataSB3, hSB3);
ROOT::Fit::DataRange rangeSB4;
rangeSB4.SetRange(0.43,0.73);
ROOT::Fit::BinData dataSB4(opt,rangeSB4);
ROOT::Fit::FillData(dataSB4, hSB4);
ROOT::Fit::Chi2Function chi2_B(dataB, wfB);
ROOT::Fit::Chi2Function chi2_SB2(dataSB2, wfSB2);
ROOT::Fit::Chi2Function chi2_SB3(dataSB3, wfSB3);
ROOT::Fit::Chi2Function chi2_SB4(dataSB4, wfSB4);
GlobalChi2 globalChi2(chi2_B, chi2_SB2, chi2_SB3, chi2_SB4);
ROOT::Fit::Fitter fitter;
const int Npar = 6;
double par0[Npar] = {1.4,1E5, 0.005, 1e4,1e4,1e4};
// double par0[Npar] = {1.4,0.000007,0.15,1.4, 0.00250,2, 0.005,2, 0.007};
// create before the parameter settings in order to fix or set range on them
fitter.Config().SetParamsSettings(Npar,par0);
// fix 5-th parameter
// fitter.Config().ParSettings(1).Fix();
// set limits on the third and 4-th parameter
fitter.Config().ParSettings(0).SetLimits(0,5);
fitter.Config().ParSettings(2).SetLimits(0,1.0);
fitter.Config().ParSettings(1).SetLimits(0,2E9);
fitter.Config().ParSettings(3).SetLimits(0,2E6);//1
fitter.Config().ParSettings(4).SetLimits(0,2E6);//10
fitter.Config().ParSettings(5).SetLimits(0,2E6);//10
// fitter.Config().ParSettings(4).SetStepSize(2);
// fitter.Config().ParSettings(1).SetStepSize(0.1);
// fitter.Config().ParSettings(6).SetStepSize(10);
// fitter.Config().ParSettings(8).SetStepSize(10);
fitter.Config().MinimizerOptions().SetPrintLevel(0);
fitter.Config().SetMinimizer("Minuit2","Migrad"); //Minuit2
//fitter.Config().SetNormErrors(true);
// fit FCN function directly
// (specify optionally data size and flag to indicate that is a chi2 fit)
fitter.FitFCN(Npar,globalChi2,0,dataB.Size()+dataSB2.Size()+dataSB3.Size()+dataSB4.Size(),true);
ROOT::Fit::FitResult result = fitter.Result();
result.Print(std::cout, true);
//result.PrintCovMatrix(std::cout);
cout << "FitResult.Status() = " << result.Status() << endl;
TCanvas * c1 = new TCanvas("Simfit","Simultaneous fit");
// c1->Divide(2,2);
// c1->cd(1);
// gStyle->SetOptFit(1111);
fB->SetFitResult( result, iparB);
fB->SetRange(rangeB().first, rangeB().second);
fB->SetLineColor(kRed);
hB->GetListOfFunctions()->Add(fB);
//hB->Draw("AP");
// c1->cd(2);
fSB2->SetFitResult( result, iparSB2);
fSB2->SetRange(rangeSB2().first, rangeSB2().second);
fSB2->SetLineColor(kRed);
hSB2->GetListOfFunctions()->Add(fSB2);
// hSB2->Draw("AP");
// c1->cd(3);
fSB3->SetFitResult( result, iparSB3);
fSB3->SetRange(rangeSB3().first, rangeSB3().second);
fSB3->SetLineColor(kRed);
hSB3->GetListOfFunctions()->Add(fSB3);
// hSB3->Draw("AP");
// c1->cd(4);
fSB4->SetFitResult( result, iparSB4);
fSB4->SetRange(rangeSB4().first, rangeSB4().second);
fSB4->SetLineColor(kRed);
hSB4->GetListOfFunctions()->Add(fSB4);
// hSB4->Draw("AP");
TMultiGraph * mg_e9 = new TMultiGraph();
mg_e9->Add(hB,"p"); hB->SetMarkerStyle(20);
mg_e9->Add(hSB2,"p"); hSB2->SetMarkerStyle(21);
mg_e9->Add(hSB3,"p"); hSB3->SetMarkerStyle(22);
mg_e9->Add(hSB4,"p"); hSB4->SetMarkerStyle(23);
mg_e9->Draw("a"); //must draw first before labeling axes
mg_e9->SetTitle(" ");
mg_e9->GetXaxis()->SetTitle("Lorentz #beta");
mg_e9->GetYaxis()->SetTitle("dA/dE / (10^{-6} a.u./(Mev#upointion#upoints^{-1})");
mg_e9->SetMinimum(0.5);
mg_e9->SetMaximum(1.4);
TF1 * tf1_birk1 = new TF1("tf1_birk1","[0]*(1/(1+[1]*1.65901*TMath::Power(x,-1.7218)))",0.3,0.59);
TF1 * tf1_birk2 = new TF1("tf1_birk2","[0]*(1/(1+[1]*4*1.65901*TMath::Power(x,-1.7218)))",0.34,0.59);
TF1 * tf1_birk3 = new TF1("tf1_birk3","[0]*(1/(1+[1]*36*1.65901*TMath::Power(x,-1.7218)))",0.4,0.73);
TF1 * tf1_birk4 = new TF1("tf1_birk4","[0]*(1/(1+[1]*64*1.65901*TMath::Power(x,-1.7218)))",0.43,0.73);
tf1_birk1->SetParameters(1.46123,0.0177651);tf1_birk1->SetLineStyle(2);tf1_birk1->SetLineColor(kBlack);
tf1_birk2->SetParameters(1.46123,0.00682331);tf1_birk2->SetLineStyle(2);tf1_birk2->SetLineColor(kBlack);
tf1_birk3->SetParameters(1.46123,0.00389243);tf1_birk3->SetLineStyle(2);tf1_birk3->SetLineColor(kBlack);
tf1_birk4->SetParameters(1.46123,0.00310792);tf1_birk4->SetLineStyle(2);tf1_birk4->SetLineColor(kBlack);
// hB_2->Fit(tf1_birk1);
// hSB2_2->Fit(tf1_birk2);
//hSB3_2->Fit(tf1_birk3);
//hSB4_2->Fit(tf1_birk4);
tf1_birk1->Draw("same");
tf1_birk2->Draw("same");
tf1_birk3->Draw("same");
tf1_birk4->Draw("same");
TLegend * mylegende9 = new TLegend(0.65,0.65,0.9,0.9);
mylegende9->SetFillColor(0); // white background
mylegende9->SetTextFont(22);
mylegende9->SetBorderSize(0); // get rid of the box
mylegende9->SetTextSize(0.035); // set text size
mylegende9->AddEntry(hB,"Protons","p"); // options: p,l,f
mylegende9->AddEntry(hSB2,"Helium","p"); // options: p,l,f
mylegende9->AddEntry(hSB3,"Carbon","p"); // options: p,l,f
mylegende9->AddEntry(hSB4,"Oxygen","p"); // options: p,l,f
mylegende9->AddEntry(fB,"BVT Fit","l"); // options: p,l,f
mylegende9->AddEntry(tf1_birk1,"Birks Fit","l"); // options: p,l,f
// mylegende9->AddEntry(tf1_pow1,"[1]#upointpow(#beta,[2])}","l"); // options: p,l,f
mylegende9->Draw();
gPad->Modified();
c1->SaveAs("figs/bvt_beta_combinedfit.pdf");
c1->SaveAs("figs/bvt_beta_combinedfit.png");
c1->SaveAs("figs/bvt_beta_combinedfit.C");
}

BIN
Scripts_20161126/combinedFit_hit2_C_ACLiC_dict_rdict.pcm

Binary file not shown.

BIN
Scripts_20161126/combinedFit_hit_C_ACLiC_dict_rdict.pcm

Binary file not shown.

273
Scripts_20161126/combinedFit_hitbirk.C

@ -0,0 +1,273 @@
//+ Combined (simultaneous) fit of two histogram with separate functions
// and some common parameters
//
// See http://root.cern.ch/phpBB3//viewtopic.php?f=3&t=11740#p50908
// for a modified version working with Fumili or GSLMultiFit
//
// N.B. this macro must be compiled with ACliC
//
//Author: L. Moneta - Dec 2010
#include "Fit/Fitter.h"
#include "Fit/BinData.h"
#include "Fit/Chi2FCN.h"
#include "TH1.h"
#include "TList.h"
#include "Math/WrappedMultiTF1.h"
#include "HFitInterface.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TGraphErrors.h"
#include "TLegend.h"
#include "TMultiGraph.h"
// definition of shared parameter
// background function
int iparB[2] = { 0, //amplitude
1, // k_b
};
// signal + background function
int iparSB2[2] = { 0, // amplitude
2, // k_b
};
int iparSB3[2] = { 0, // amplitude
3, // k_b
};
int iparSB4[2] = { 0, // amplitude
4, // k_b
};
struct GlobalChi2 {
GlobalChi2( ROOT::Math::IMultiGenFunction & f1,
ROOT::Math::IMultiGenFunction & f2,
ROOT::Math::IMultiGenFunction & f3,
ROOT::Math::IMultiGenFunction & f4) :
fChi2_1(&f1), fChi2_2(&f2), fChi2_3(&f3), fChi2_4(&f4) {}
// parameter vector is first background (in common 1 and 2)
// and then is signal (only in 2)
double operator() (const double *par) const {
double p1[2];
for (int i = 0; i < 2; ++i) p1[i] = par[iparB[i] ];
double p2[2];
for (int i = 0; i < 2; ++i) p2[i] = par[iparSB2[i] ];
double p3[2];
for (int i = 0; i < 2; ++i) p3[i] = par[iparSB3[i] ];
double p4[2];
for (int i = 0; i < 2; ++i) p4[i] = par[iparSB4[i] ];
return (*fChi2_1)(p1) + (*fChi2_2)(p2) + (*fChi2_3)(p3) + (*fChi2_4)(p4);
}
const ROOT::Math::IMultiGenFunction * fChi2_1;
const ROOT::Math::IMultiGenFunction * fChi2_2;
const ROOT::Math::IMultiGenFunction * fChi2_3;
const ROOT::Math::IMultiGenFunction * fChi2_4;
};
void combinedFit_hitbirk() {
#if defined(__CINT__) && !defined(__MAKECINT__)
cout << "ERROR: This tutorial can run only using ACliC, you must run it by doing: " << endl;
cout << "\t .x $ROOTSYS/tutorials/fit/combinedFit_hit.C+" << endl;
return;
#endif
TF1 * fB = new TF1("fB","[0]*(1/(1+[1]*1.65901*TMath::Power(x,-1.7218)))",0.3,0.59);
TF1 * fSB2 = new TF1("fSB2","[0]*(1/(1+[1]*4*1.65901*TMath::Power(x,-1.7218)))",0.34,0.59);
TF1 * fSB3 = new TF1("fSB3","[0]*(1/(1+[1]*36*1.65901*TMath::Power(x,-1.7218)))",0.4,0.73);
TF1 * fSB4 = new TF1("fSB4","[0]*(1/(1+[1]*64*1.65901*TMath::Power(x,-1.7218)))",0.43,0.73);
TGraphErrors * hB = new TGraphErrors("energylist_p_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB2 = new TGraphErrors("energylist_he_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB3 = new TGraphErrors("energylist_c_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB4 = new TGraphErrors("energylist_o_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hB_2 = new TGraphErrors("energylist_p_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB2_2 = new TGraphErrors("energylist_he_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB3_2 = new TGraphErrors("energylist_c_bpmbeta1.txt","%lg %lg %lg");
TGraphErrors * hSB4_2 = new TGraphErrors("energylist_o_bpmbeta1.txt","%lg %lg %lg");
// perform now global fit
// TF1 * fSB2 = new TF1("fSB2","expo + gaus(2)",0,100);
ROOT::Math::WrappedMultiTF1 wfB(*fB,1);
ROOT::Math::WrappedMultiTF1 wfSB2(*fSB2,1);
ROOT::Math::WrappedMultiTF1 wfSB3(*fSB3,1);
ROOT::Math::WrappedMultiTF1 wfSB4(*fSB4,1);
ROOT::Fit::DataOptions opt;
ROOT::Fit::DataRange rangeB;
// set the data range
rangeB.SetRange(0.3,0.59);
ROOT::Fit::BinData dataB(opt,rangeB);
ROOT::Fit::FillData(dataB, hB);
ROOT::Fit::DataRange rangeSB2;
rangeSB2.SetRange(0.34,0.59);
ROOT::Fit::BinData dataSB2(opt,rangeSB2);
ROOT::Fit::FillData(dataSB2, hSB2);
ROOT::Fit::DataRange rangeSB3;
rangeSB3.SetRange(0.4,0.73);
ROOT::Fit::BinData dataSB3(opt,rangeSB3);
ROOT::Fit::FillData(dataSB3, hSB3);
ROOT::Fit::DataRange rangeSB4;
rangeSB4.SetRange(0.43,0.73);
ROOT::Fit::BinData dataSB4(opt,rangeSB4);
ROOT::Fit::FillData(dataSB4, hSB4);
ROOT::Fit::Chi2Function chi2_B(dataB, wfB);
ROOT::Fit::Chi2Function chi2_SB2(dataSB2, wfSB2);
ROOT::Fit::Chi2Function chi2_SB3(dataSB3, wfSB3);
ROOT::Fit::Chi2Function chi2_SB4(dataSB4, wfSB4);
GlobalChi2 globalChi2(chi2_B, chi2_SB2, chi2_SB3, chi2_SB4);
ROOT::Fit::Fitter fitter;
const int Npar = 5;
double par0[Npar] = {1.4,0.1,0.1,0.1,0.1};
// double par0[Npar] = {1.4,0.000007,0.15,1.4, 0.00250,2, 0.005,2, 0.007};
// create before the parameter settings in order to fix or set range on them
fitter.Config().SetParamsSettings(Npar,par0);
// fix 5-th parameter
// fitter.Config().ParSettings(1).Fix();
// set limits on the third and 4-th parameter
fitter.Config().ParSettings(0).SetLimits(0,5);
fitter.Config().ParSettings(1).SetLimits(0,1.0);
fitter.Config().ParSettings(2).SetLimits(0,1.0);
fitter.Config().ParSettings(3).SetLimits(0,1.0);//1
fitter.Config().ParSettings(4).SetLimits(0,1.0);//10
// fitter.Config().ParSettings(4).SetStepSize(2);
// fitter.Config().ParSettings(1).SetStepSize(0.1);
// fitter.Config().ParSettings(6).SetStepSize(10);
// fitter.Config().ParSettings(8).SetStepSize(10);
fitter.Config().MinimizerOptions().SetPrintLevel(0);
fitter.Config().SetMinimizer("Minuit2","Migrad"); //Minuit2
//fitter.Config().SetNormErrors(true);
// fit FCN function directly
// (specify optionally data size and flag to indicate that is a chi2 fit)
fitter.FitFCN(Npar,globalChi2,0,dataB.Size()+dataSB2.Size()+dataSB3.Size()+dataSB4.Size(),true);
ROOT::Fit::FitResult result = fitter.Result();
result.Print(std::cout, true);
//result.PrintCovMatrix(std::cout);
cout << "FitResult.Status() = " << result.Status() << endl;
TCanvas * c1 = new TCanvas("Simfit","Simultaneous fit");
// c1->Divide(2,2);
// c1->cd(1);
// gStyle->SetOptFit(1111);
fB->SetFitResult( result, iparB);
fB->SetRange(rangeB().first, rangeB().second);
fB->SetLineColor(kRed);
hB->GetListOfFunctions()->Add(fB);
//hB->Draw("AP");
// c1->cd(2);
fSB2->SetFitResult( result, iparSB2);
fSB2->SetRange(rangeSB2().first, rangeSB2().second);
fSB2->SetLineColor(kRed);
hSB2->GetListOfFunctions()->Add(fSB2);
// hSB2->Draw("AP");
// c1->cd(3);
fSB3->SetFitResult( result, iparSB3);
fSB3->SetRange(rangeSB3().first, rangeSB3().second);
fSB3->SetLineColor(kRed);
hSB3->GetListOfFunctions()->Add(fSB3);
// hSB3->Draw("AP");
// c1->cd(4);
fSB4->SetFitResult( result, iparSB4);
fSB4->SetRange(rangeSB4().first, rangeSB4().second);
fSB4->SetLineColor(kRed);
hSB4->GetListOfFunctions()->Add(fSB4);
// hSB4->Draw("AP");
TMultiGraph * mg_e9 = new TMultiGraph();
mg_e9->Add(hB,"p"); hB->SetMarkerStyle(20);
mg_e9->Add(hSB2,"p"); hSB2->SetMarkerStyle(21);
mg_e9->Add(hSB3,"p"); hSB3->SetMarkerStyle(22);
mg_e9->Add(hSB4,"p"); hSB4->SetMarkerStyle(23);
mg_e9->Draw("a"); //must draw first before labeling axes
mg_e9->SetTitle(" ");
mg_e9->GetXaxis()->SetTitle("Lorentz #beta");
mg_e9->GetYaxis()->SetTitle("dA/dE / (10^{-6} a.u./(Mev#upointion#upoints^{-1})");
mg_e9->SetMinimum(0.5);
mg_e9->SetMaximum(1.4);
TF1 * tf1_birk1 = new TF1("tf1_birk1","[0]*(1/(1+[1]*1.65901*TMath::Power(x,-1.7218)))",0.3,0.59);
TF1 * tf1_birk2 = new TF1("tf1_birk2","[0]*(1/(1+[1]*4*1.65901*TMath::Power(x,-1.7218)))",0.34,0.59);
TF1 * tf1_birk3 = new TF1("tf1_birk3","[0]*(1/(1+[1]*36*1.65901*TMath::Power(x,-1.7218)))",0.4,0.73);
TF1 * tf1_birk4 = new TF1("tf1_birk4","[0]*(1/(1+[1]*64*1.65901*TMath::Power(x,-1.7218)))",0.43,0.73);
tf1_birk1->SetParameters(1,0.01);tf1_birk1->SetLineStyle(2);tf1_birk1->SetLineColor(kBlack);
tf1_birk2->SetParameters(1,0.01);tf1_birk2->SetLineStyle(2);tf1_birk2->SetLineColor(kBlack);
tf1_birk3->SetParameters(1,0.01);tf1_birk3->SetLineStyle(2);tf1_birk3->SetLineColor(kBlack);
tf1_birk4->SetParameters(1,0.01);tf1_birk4->SetLineStyle(2);tf1_birk4->SetLineColor(kBlack);
hB_2->Fit(tf1_birk1);
hSB2_2->Fit(tf1_birk2);
hSB3_2->Fit(tf1_birk3);
hSB4_2->Fit(tf1_birk4);
tf1_birk1->Draw("same");
tf1_birk2->Draw("same");
tf1_birk3->Draw("same");
tf1_birk4->Draw("same");
TLegend * mylegende9 = new TLegend(0.65,0.65,0.9,0.9);
mylegende9->SetFillColor(0); // white background
mylegende9->SetTextFont(22);
mylegende9->SetBorderSize(0); // get rid of the box
mylegende9->SetTextSize(0.035); // set text size
mylegende9->AddEntry(hB,"Protons","p"); // options: p,l,f
mylegende9->AddEntry(hSB2,"Helium","p"); // options: p,l,f
mylegende9->AddEntry(hSB3,"Carbon","p"); // options: p,l,f
mylegende9->AddEntry(hSB4,"Oxygen","p"); // options: p,l,f
mylegende9->AddEntry(fB,"Birks Fit 1","l"); // options: p,l,f
mylegende9->AddEntry(tf1_birk1,"Birks Fit 2","l"); // options: p,l,f
// mylegende9->AddEntry(tf1_pow1,"[1]#upointpow(#beta,[2])}","l"); // options: p,l,f
mylegende9->Draw();
gPad->Modified();
c1->SaveAs("figs/bvt_beta_combinedfitbirks2.pdf");
c1->SaveAs("figs/bvt_beta_combinedfitbirks2.png");
c1->SaveAs("figs/bvt_beta_combinedfitbirks2.C");
}

BIN
Scripts_20161126/combinedFit_hitbirk_C_ACLiC_dict_rdict.pcm

Binary file not shown.

BIN
Scripts_20161126/convert

Binary file not shown.

213
Scripts_20161126/convert.c

@ -0,0 +1,213 @@
#include <string.h>
#include <string>
#include <TFile.h>
#include <TTree.h>
#include <map>
#include <fstream>
#include <TSystemDirectory.h>
#include <iostream>
using namespace std;
void csvToRoot(TString filename)
{
}
Int_t main(Int_t argc, const char *argv[])
{
const char *dbasename = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/database.csv";
const char *dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/csv/";
const char *outputdirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/pin/";
const char *dirCsv = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/hit_csv/with_timestamp/";
const char *ext = ".csv";
//read database
string key, value;
ifstream infile(dbasename, ios::in);
map<string, string> database;
while (infile >> key >> value)
{
database[key] = value;
cout << value << endl;
}
TSystemDirectory dir(dirname, dirname);
TList *files = dir.GetListOfFiles();
if (files)
{
TSystemFile *file;
TString fname;
TIter next(files);
while ((file = (TSystemFile *)next()))
{
fname = file->GetName();
if (fname == "database.csv")
continue;
if (!file->IsDirectory() && fname.EndsWith(ext))
{
TTree *tree = new TTree("t", "t");
cout << fname << endl;
//tree->ReadFile(TString(TString(dirname) + file->GetName()), "time/D:event_id:sync_out:sync_in:data_ok:led_voltage:current:ch00:ch01:ch02:ch03:ch04:ch05:ch06:ch07:ch08:ch09:ch10:ch11:ch12:ch13:ch14:ch15:ch16:ch17:ch18:ch19:ch20:ch21:ch22:ch23:ch24:ch25:ch26:ch27:ch28:ch29:ch30:ch31:ch32:ch33:ch34:ch35:ch36:ch37:ch38:ch39:ch40:ch41:ch42:ch43:ch44:ch45:ch46:ch47:ch48:ch49:ch50:ch51:ch52:ch53:ch54:ch55:ch56:ch57:ch58:ch59:ch60:ch61:ch62:ch63:ch64:ch65:ch66:ch67:ch68:ch69:ch70:ch71:ch72:ch73:ch74:ch75:ch76:ch77:ch78:ch79:ch80:ch81:ch82:ch83:ch84:ch85:ch86:ch87:ch88:ch89:ch90:ch91:ch92:ch93:ch94:ch95:ch96:ch97:ch98:ch99:ch100:ch101:ch102:ch103:ch104:ch105:ch106:ch107:ch108:ch109:ch110:ch111:ch112:ch113:ch114:ch115:ch116:ch117:ch118:ch119:ch120:ch121:ch122:ch123:ch124:ch125:ch126:ch127", '\t');
tree->ReadFile(TString(TString(dirname) + file->GetName()), "time/D:event_id:sync_out:sync_in:data_ok:led_voltage:current:ch00:ch01:ch02:ch03:ch04:ch05:ch06:ch07:ch08:ch09:ch10:ch11:ch12:ch13:ch14:ch15:ch16:ch17:ch18:ch19:ch20:ch21:ch22:ch23:ch24:ch25:ch26:ch27:ch28:ch29:ch30:ch31:ch32:ch33:ch34:ch35:ch36:ch37:ch38:ch39:ch40:ch41:ch42:ch43:ch44:ch45:ch46:ch47:ch48:ch49:ch50:ch51:ch52:ch53:ch54:ch55:ch56:ch57:ch58:ch59:ch60:ch61:ch62:ch63", '\t');
TString outname = TString(outputdirname) + fname;
outname.Replace(outname.Length() - 3, 3, TString("root"));
TFile *outfile = new TFile(outname.Data(), "recreate");
outfile->cd();
//outfile = tree->GetCurrentFile();
TTree *tree2 = new TTree("t2", "t2");
fname.Replace(fname.Length() - 3, 3, TString("root"));
string key = string(fname.Data());
key.erase(key.end() - 5, key.end());
if(database[key] == "nothing"){
outfile->Close();
continue;
}
printf("%s\n", database[key].c_str());
string value = string(dirCsv) + database[key] + ".csv";
printf("name1: %s , name2: %s\n", key.data(), value.data());
tree2->ReadFile(value.data(), "TIME2/D:IC1:IC2:MW1_FOCUSX:MW1_FOCUSY:MW2_FOCUSX:MW2_FOCUSY:MW1_POSX:MW1_POSY:MW2_POSX:MW2_POSY:TCS-SPAM:TCS-KO:BNEXTPOINT:ANALOG_IN1:ANALOG_IN2:ENERGY:INTENSITY:ION-SORT", '\t');
int k = 0;
int count = 0;
double ic1, ic2, mw1_focusx, mw1_focusy, mw2_focusx, mw2_focusy, mw1_posx, mw1_posy, mw2_posx, mw2_posy;
double ic1_avg, ic2_avg, mw1_focusx_avg, mw1_focusy_avg, mw2_focusx_avg, mw2_focusy_avg, mw1_posx_avg, mw1_posy_avg, mw2_posx_avg, mw2_posy_avg;
double time;
double time2;
tree->SetBranchAddress("time", &time);
tree2->SetBranchAddress("TIME2", &time2);
tree2->SetBranchAddress("IC1", &ic1);
tree2->SetBranchAddress("IC2", &ic2);
tree2->SetBranchAddress("MW1_FOCUSX", &mw1_focusx);
tree2->SetBranchAddress("MW1_FOCUSY", &mw1_focusy);
tree2->SetBranchAddress("MW2_FOCUSX", &mw2_focusx);
tree2->SetBranchAddress("MW2_FOCUSY", &mw2_focusy);
tree2->SetBranchAddress("MW1_POSX", &mw1_posx);
tree2->SetBranchAddress("MW1_POSY", &mw1_posy);
tree2->SetBranchAddress("MW2_POSX", &mw2_posx);
tree2->SetBranchAddress("MW2_POSY", &mw2_posy);
TBranch *bic1 = tree->Branch("ic1", &ic1_avg, "ic1/D");
TBranch *bic2 = tree->Branch("ic2", &ic2_avg, "ic2/D");
TBranch *bmw1_focusx = tree->Branch("mw1_focusx", &mw1_focusx_avg, "mw1_focusx/D");
TBranch *bmw1_focusy = tree->Branch("mw1_focusy", &mw1_focusy_avg, "mw1_focusy/D");
TBranch *bmw2_focusx = tree->Branch("mw2_focusx", &mw2_focusx_avg, "mw2_focusx/D");
TBranch *bmw2_focusy = tree->Branch("mw2_focusy", &mw2_focusy_avg, "mw2_focusy/D");
TBranch *bmw1_posx = tree->Branch("mw1_posx", &mw1_posx_avg, "mw1_posx/D");
TBranch *bmw1_posy = tree->Branch("mw1_posy", &mw1_posy_avg, "mw1_posy/D");
TBranch *bmw2_posx = tree->Branch("mw2_posx", &mw2_posx_avg, "mw2_posx/D");
TBranch *bmw2_posy = tree->Branch("mw2_posy", &mw2_posy_avg, "mw2_posy/D");
int currentEntryTree2 = 1;
int nevents = tree->GetEntries();
int nevents2 = tree2->GetEntries();
ic1_avg = 0;
ic2_avg = 0;
mw1_focusx_avg = 0;
mw1_focusy_avg = 0;
mw2_focusx_avg = 0;
mw2_focusy_avg = 0;
mw1_posx_avg = 0;
mw1_posy_avg = 0;
mw2_posx_avg = 0;
mw2_posy_avg = 0;
time2 = 0;
tree2->GetEntry(currentEntryTree2);
for (int i = 0; i < nevents; i++)
{
tree->GetEntry(i);
if (i % 10000 == 0)
{
printf("merging event %d ,", i);
printf("Time %f \n", time);
printf("Entry hit %d ,", currentEntryTree2);
printf("Time hit %f \n", time2);
}
int count = 0;
int count2 = 0;
while (time2 <= (time + 0.2) && currentEntryTree2 < nevents2)
{
if ((time2 - time) <= 0.312 && (time2 - time) >= 0)
{
tree2->GetEntry(currentEntryTree2);
ic1_avg += ic1;
ic2_avg += ic2;
count++;
}
tree2->GetEntry(currentEntryTree2);
if ((time2 - time) <= 0.312 && (time2 - time) >= 0)
{
tree2->GetEntry(currentEntryTree2 - 4);
mw1_focusx_avg += mw1_focusx;
mw1_focusy_avg += mw1_focusy;
mw2_focusx_avg += mw2_focusx;
mw2_focusy_avg += mw2_focusy;
mw1_posx_avg += mw1_posx;
mw1_posy_avg += mw1_posy;
mw2_posx_avg += mw2_posx;
mw2_posy_avg += mw2_posy;
count2++;
}
tree2->GetEntry(currentEntryTree2);
currentEntryTree2++;
}
ic1_avg /= count;
ic2_avg /= count;
mw1_focusx_avg /= count2;
mw1_focusy_avg /= count2;
mw2_focusx_avg /= count2;
mw2_focusy_avg /= count2;
mw1_posx_avg /= count2;
mw1_posy_avg /= count2;
mw2_posx_avg /= count2;
mw2_posy_avg /= count2;
bic1->Fill();
bic2->Fill();
bmw1_focusx->Fill();
bmw1_focusy->Fill();
bmw2_focusx->Fill();
bmw2_focusy->Fill();
bmw1_posx->Fill();
bmw1_posy->Fill();
bmw2_posx->Fill();
bmw2_posy->Fill();
ic1_avg = 0;
ic2_avg = 0;
mw1_focusx_avg = 0;
mw1_focusy_avg = 0;
mw2_focusx_avg = 0;
mw2_focusy_avg = 0;
mw1_posx_avg = 0;
mw1_posy_avg = 0;
mw2_posx_avg = 0;
mw2_posy_avg = 0;
}
tree->Write();
outfile->Close();
}
}
}
return 0;
}

BIN
Scripts_20161126/convert_batch

Binary file not shown.

248
Scripts_20161126/convert_batch.c

@ -0,0 +1,248 @@
#include <string.h>
#include <string>
#include <TFile.h>
#include <TTree.h>
#include <map>
#include <fstream>
#include <TSystemDirectory.h>
#include <iostream>
using namespace std;
void csvToRoot(TString filename)
{
}
Int_t main(Int_t argc, const char *argv[])
{
double timeoffset;
int mwoffset;
double timewindow;
double timeoffset2;
double timewindow2;
if (argc==7){
timeoffset = atof(argv[2]);
mwoffset = atoi(argv[3]);
timewindow = atof(argv[4]);
timeoffset2 = atof(argv[5]);
timewindow2 = atof(argv[6]);
printf("Time offsets: %f %f\n", timeoffset, timeoffset2);
}
else if (argc==2){
timeoffset = -0.24; //offset between ic and bpm readouts
mwoffset = 2; // offset for timestamped event. MW chamber position correlation seems to be better in other windows
timewindow = -0.312; //should be a negative number. window size in time to average over.
timeoffset2 = -0.21; //offset between ic and bpm readouts
timewindow2 = -0.05; //should be a negative number. window size in time to average over.
printf("Default timeoffsets:%f\n", timeoffset);
printf("Default mwoffset:%i\n", mwoffset);
}
else {
printf("./convert_batch PiN_run32.csv \n");
printf("or\n");
printf("./convert_batch PiN_run32.csv -0.25 2 -0.312 -0.21 0.05\n");
return 1;
}
const char *dbasename = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/database.csv";
const char *dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/csv/";
const char *outputdirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/pin/";
const char *dirCsv = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/hit_csv/with_timestamp/";
const char *ext = ".csv";
//read database
string key, value;
ifstream infile(dbasename, ios::in);
map<string, string> database;
while (infile >> key >> value)
{
database[key] = value;
// cout << value << endl;
}
TSystemDirectory dir(dirname, dirname);
if (true)
{
TSystemFile *file;
TString fname = argv[1];
if (fname.EndsWith(ext))
{
TTree *tree = new TTree("t", "t");
cout << fname << endl;
//tree->ReadFile(TString(TString(dirname) + file->GetName()), "time/D:event_id:sync_out:sync_in:data_ok:led_voltage:current:ch00:ch01:ch02:ch03:ch04:ch05:ch06:ch07:ch08:ch09:ch10:ch11:ch12:ch13:ch14:ch15:ch16:ch17:ch18:ch19:ch20:ch21:ch22:ch23:ch24:ch25:ch26:ch27:ch28:ch29:ch30:ch31:ch32:ch33:ch34:ch35:ch36:ch37:ch38:ch39:ch40:ch41:ch42:ch43:ch44:ch45:ch46:ch47:ch48:ch49:ch50:ch51:ch52:ch53:ch54:ch55:ch56:ch57:ch58:ch59:ch60:ch61:ch62:ch63:ch64:ch65:ch66:ch67:ch68:ch69:ch70:ch71:ch72:ch73:ch74:ch75:ch76:ch77:ch78:ch79:ch80:ch81:ch82:ch83:ch84:ch85:ch86:ch87:ch88:ch89:ch90:ch91:ch92:ch93:ch94:ch95:ch96:ch97:ch98:ch99:ch100:ch101:ch102:ch103:ch104:ch105:ch106:ch107:ch108:ch109:ch110:ch111:ch112:ch113:ch114:ch115:ch116:ch117:ch118:ch119:ch120:ch121:ch122:ch123:ch124:ch125:ch126:ch127", '\t');
tree->ReadFile(TString(TString(dirname) + fname.Data()), "time/D:event_id:sync_out:sync_in:data_ok:led_voltage:current:ch00:ch01:ch02:ch03:ch04:ch05:ch06:ch07:ch08:ch09:ch10:ch11:ch12:ch13:ch14:ch15:ch16:ch17:ch18:ch19:ch20:ch21:ch22:ch23:ch24:ch25:ch26:ch27:ch28:ch29:ch30:ch31:ch32:ch33:ch34:ch35:ch36:ch37:ch38:ch39:ch40:ch41:ch42:ch43:ch44:ch45:ch46:ch47:ch48:ch49:ch50:ch51:ch52:ch53:ch54:ch55:ch56:ch57:ch58:ch59:ch60:ch61:ch62:ch63", '\t');
TString outname = TString(outputdirname) + fname ;
outname.Replace(outname.Length() - 4, 4, TString(TString(argv[2])+".root"));
TFile *outfile = new TFile(outname.Data(), "recreate");
outfile->cd();
//outfile = tree->GetCurrentFile();
TTree *tree2 = new TTree("t2", "t2");
fname.Replace(fname.Length() - 3, 3, TString("root"));
string key = string(fname.Data());
key.erase(key.end() - 5, key.end());
if(database[key] == "nothing"){
outfile->Close();
return 1;
}
printf("%s\n", database[key].c_str());
string value = string(dirCsv) + database[key] + ".csv";
printf("name1: %s , name2: %s\n", key.data(), value.data());
tree2->ReadFile(value.data(), "TIME2/D:IC1:IC2:MW1_FOCUSX:MW1_FOCUSY:MW2_FOCUSX:MW2_FOCUSY:MW1_POSX:MW1_POSY:MW2_POSX:MW2_POSY:TCS-SPAM:TCS-KO:BNEXTPOINT:ANALOG_IN1:ANALOG_IN2:ENERGY:INTENSITY:ION-SORT", '\t');
int k = 0;
int count = 0;
double ic1, ic2, mw1_focusx, mw1_focusy, mw2_focusx, mw2_focusy, mw1_posx, mw1_posy, mw2_posx, mw2_posy;
double ic1_avg, ic2_avg, mw1_focusx_avg, mw1_focusy_avg, mw2_focusx_avg, mw2_focusy_avg, mw1_posx_avg, mw1_posy_avg, mw2_posx_avg, mw2_posy_avg;
double time;
double time2;
tree->SetBranchAddress("time", &time);
tree2->SetBranchAddress("TIME2", &time2);
tree2->SetBranchAddress("IC1", &ic1);
tree2->SetBranchAddress("IC2", &ic2);
tree2->SetBranchAddress("MW1_FOCUSX", &mw1_focusx);
tree2->SetBranchAddress("MW1_FOCUSY", &mw1_focusy);
tree2->SetBranchAddress("MW2_FOCUSX", &mw2_focusx);
tree2->SetBranchAddress("MW2_FOCUSY", &mw2_focusy);
tree2->SetBranchAddress("MW1_POSX", &mw1_posx);
tree2->SetBranchAddress("MW1_POSY", &mw1_posy);
tree2->SetBranchAddress("MW2_POSX", &mw2_posx);
tree2->SetBranchAddress("MW2_POSY", &mw2_posy);
TBranch *bic1 = tree->Branch("ic1", &ic1_avg, "ic1/D");
TBranch *bic2 = tree->Branch("ic2", &ic2_avg, "ic2/D");
TBranch *bmw1_focusx = tree->Branch("mw1_focusx", &mw1_focusx_avg, "mw1_focusx/D");
TBranch *bmw1_focusy = tree->Branch("mw1_focusy", &mw1_focusy_avg, "mw1_focusy/D");
TBranch *bmw2_focusx = tree->Branch("mw2_focusx", &mw2_focusx_avg, "mw2_focusx/D");
TBranch *bmw2_focusy = tree->Branch("mw2_focusy", &mw2_focusy_avg, "mw2_focusy/D");
TBranch *bmw1_posx = tree->Branch("mw1_posx", &mw1_posx_avg, "mw1_posx/D");
TBranch *bmw1_posy = tree->Branch("mw1_posy", &mw1_posy_avg, "mw1_posy/D");
TBranch *bmw2_posx = tree->Branch("mw2_posx", &mw2_posx_avg, "mw2_posx/D");
TBranch *bmw2_posy = tree->Branch("mw2_posy", &mw2_posy_avg, "mw2_posy/D");
int currentEntryTree2 = 1;
int nevents = tree->GetEntries();
int nevents2 = tree2->GetEntries();
ic1_avg = 0;
ic2_avg = 0;
mw1_focusx_avg = 0;
mw1_focusy_avg = 0;
mw2_focusx_avg = 0;
mw2_focusy_avg = 0;
mw1_posx_avg = 0;
mw1_posy_avg = 0;
mw2_posx_avg = 0;
mw2_posy_avg = 0;
time2 = 0;
tree2->GetEntry(currentEntryTree2);
for (int i = 0; i < nevents; i++)
{
tree->GetEntry(i);
if (i % 10000 == 0)
{
printf("merging event %d ,", i);
printf("Time %f \n", time);
printf("Entry hit %d ,", currentEntryTree2);
printf("Time hit %f \n", time2);
}
int count = 0;
int count2 = 0;
while ( time2 < time + timeoffset && currentEntryTree2 < nevents2)
{
if (time2 - time - timeoffset > timewindow)
{
tree2->GetEntry(currentEntryTree2);
if (ic1>0) ic1_avg += ic1;
if (ic2>0) ic2_avg += ic2;
if (ic1>0) count++;
if (i % 2000 == 0) printf("%i %2.3f %2.3f %2.3f %2.3f %2.3f %i \n", count, ic1, time2, time, timeoffset, time2 - time - timeoffset, mwoffset);
}
tree2->GetEntry(currentEntryTree2);
if ( time2 - time - timeoffset2 > timewindow2)
{
tree2->GetEntry(currentEntryTree2 + mwoffset); //why currentEtryTree2-4?
mw1_focusx_avg += mw1_focusx;
mw1_focusy_avg += mw1_focusy;
mw2_focusx_avg += mw2_focusx;
mw2_focusy_avg += mw2_focusy;
mw1_posx_avg += mw1_posx;
mw1_posy_avg += mw1_posy;
mw2_posx_avg += mw2_posx;
mw2_posy_avg += mw2_posy;
count2++;
// if (i % 2000 == 0) printf("%i %2.3f %2.3f %2.3f %2.3f\n", count2, time, time2, ic1, mw1_posx);
//if (i % 2001 == 0) printf("%i %2.3f %2.3f %2.3f %2.3f\n", count2, time, time2, ic1, mw1_posx);
// if (i % 2002 == 0) printf("%i %2.3f %2.3f %2.3f %2.3f\n", count2, time, time2, ic1, mw1_posx);
// printf("%i %2.3f %2.3f %2.3f %2.3f\n", count2, time, time2, ic1, mw1_posx);
}
// currentEntryTree2++;
tree2->GetEntry(currentEntryTree2);
currentEntryTree2++;
}
if (count2>0){
mw1_focusx_avg /= double(count2);
mw1_focusy_avg /= double(count2);
mw2_focusx_avg /= double(count2);
mw2_focusy_avg /= double(count2);
mw1_posx_avg /= double(count2); //the positions are weighted by the charge
mw1_posy_avg /= double(count2);
mw2_posx_avg /= double(count2);
mw2_posy_avg /= double(count2);
}
if(count>0){
ic1_avg /= double(count);
ic2_avg /= double(count);
}
if (i % 2000 == 0) cout << ic1_avg << " " << ic2_avg << endl;
bic1->Fill();
bic2->Fill();
bmw1_focusx->Fill();
bmw1_focusy->Fill();
bmw2_focusx->Fill();
bmw2_focusy->Fill();
bmw1_posx->Fill();
bmw1_posy->Fill();
bmw2_posx->Fill();
bmw2_posy->Fill();
ic1_avg = 0.;
ic2_avg = 0.;
mw1_focusx_avg = 0.;
mw1_focusy_avg = 0.;
mw2_focusx_avg = 0.;
mw2_focusy_avg = 0.;
mw1_posx_avg = 0.;
mw1_posy_avg = 0.;
mw2_posx_avg = 0.;
mw2_posy_avg = 0.;
}
tree->Write();
outfile->Close();
}
}
return 0;
}

220
Scripts_20161126/convert_batch.c_old

@ -0,0 +1,220 @@
#include <string.h>
#include <string>
#include <TFile.h>
#include <TTree.h>
#include <map>
#include <fstream>
#include <TSystemDirectory.h>
#include <iostream>
using namespace std;
void csvToRoot(TString filename)
{
}
Int_t main(Int_t argc, const char *argv[])
{
double timeoffset;
if (argc>2){
timeoffset = atof(argv[2]);
printf("Time offset: %f\n", timeoffset);
}
else {
timeoffset = 0.09;
printf("Default time offset:%f\n", timeoffset);
}
const char *dbasename = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/database.csv";
const char *dirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/csv/";
const char *outputdirname = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/with_timestamp/pin/";
const char *dirCsv = "/work/leverington/beamprofilemonitor/hitdata/HIT_26-11-2016/hit_csv/with_timestamp/";
const char *ext = ".csv";
//read database
string key, value;
ifstream infile(dbasename, ios::in);
map<string, string> database;
while (infile >> key >> value)
{
database[key] = value;
// cout << value << endl;
}
TSystemDirectory dir(dirname, dirname);
if (true)
{
TSystemFile *file;
TString fname = argv[1];
if (fname.EndsWith(ext))
{
TTree *tree = new TTree("t", "t");
cout << fname << endl;
//tree->ReadFile(TString(TString(dirname) + file->GetName()), "time/D:event_id:sync_out:sync_in:data_ok:led_voltage:current:ch00:ch01:ch02:ch03:ch04:ch05:ch06:ch07:ch08:ch09:ch10:ch11:ch12:ch13:ch14:ch15:ch16:ch17:ch18:ch19:ch20:ch21:ch22:ch23:ch24:ch25:ch26:ch27:ch28:ch29:ch30:ch31:ch32:ch33:ch34:ch35:ch36:ch37:ch38:ch39:ch40:ch41:ch42:ch43:ch44:ch45:ch46:ch47:ch48:ch49:ch50:ch51:ch52:ch53:ch54:ch55:ch56:ch57:ch58:ch59:ch60:ch61:ch62:ch63:ch64:ch65:ch66:ch67:ch68:ch69:ch70:ch71:ch72:ch73:ch74:ch75:ch76:ch77:ch78:ch79:ch80:ch81:ch82:ch83:ch84:ch85:ch86:ch87:ch88:ch89:ch90:ch91:ch92:ch93:ch94:ch95:ch96:ch97:ch98:ch99:ch100:ch101:ch102:ch103:ch104:ch105:ch106:ch107:ch108:ch109:ch110:ch111:ch112:ch113:ch114:ch115:ch116:ch117:ch118:ch119:ch120:ch121:ch122:ch123:ch124:ch125:ch126:ch127", '\t');
tree->ReadFile(TString(TString(dirname) + fname.Data()), "time/D:event_id:sync_out:sync_in:data_ok:led_voltage:current:ch00:ch01:ch02:ch03:ch04:ch05:ch06:ch07:ch08:ch09:ch10:ch11:ch12:ch13:ch14:ch15:ch16:ch17:ch18:ch19:ch20:ch21:ch22:ch23:ch24:ch25:ch26:ch27:ch28:ch29:ch30:ch31:ch32:ch33:ch34:ch35:ch36:ch37:ch38:ch39:ch40:ch41:ch42:ch43:ch44:ch45:ch46:ch47:ch48:ch49:ch50:ch51:ch52:ch53:ch54:ch55:ch56:ch57:ch58:ch59:ch60:ch61:ch62:ch63", '\t');
TString outname = TString(outputdirname) + fname ;
outname.Replace(outname.Length() - 4, 4, TString(TString(argv[2])+".root"));
TFile *outfile = new TFile(outname.Data(), "recreate");
outfile->cd();
//outfile = tree->GetCurrentFile();
TTree *tree2 = new TTree("t2", "t2");
fname.Replace(fname.Length() - 3, 3, TString("root"));
string key = string(fname.Data());
key.erase(key.end() - 5, key.end());
if(database[key] == "nothing"){
outfile->Close();
return 1;
}
printf("%s\n", database[key].c_str());
string value = string(dirCsv) + database[key] + ".csv";
printf("name1: %s , name2: %s\n", key.data(), value.data());
tree2->ReadFile(value.data(), "TIME2/D:IC1:IC2:MW1_FOCUSX:MW1_FOCUSY:MW2_FOCUSX:MW2_FOCUSY:MW1_POSX:MW1_POSY:MW2_POSX:MW2_POSY:TCS-SPAM:TCS-KO:BNEXTPOINT:ANALOG_IN1:ANALOG_IN2:ENERGY:INTENSITY:ION-SORT", '\t');
int k = 0;
int count = 0;
double ic1, ic2, mw1_focusx, mw1_focusy, mw2_focusx, mw2_focusy, mw1_posx, mw1_posy, mw2_posx, mw2_posy;
double ic1_avg, ic2_avg, mw1_focusx_avg, mw1_focusy_avg, mw2_focusx_avg, mw2_focusy_avg, mw1_posx_avg, mw1_posy_avg, mw2_posx_avg, mw2_posy_avg;
double time;
double time2;
tree->SetBranchAddress("time", &time);
tree2->SetBranchAddress("TIME2", &time2);
tree2->SetBranchAddress("IC1", &ic1);
tree2->SetBranchAddress("IC2", &ic2);
tree2->SetBranchAddress("MW1_FOCUSX", &mw1_focusx);
tree2->SetBranchAddress("MW1_FOCUSY", &mw1_focusy);
tree2->SetBranchAddress("MW2_FOCUSX", &mw2_focusx);
tree2->SetBranchAddress("MW2_FOCUSY", &mw2_focusy);
tree2->SetBranchAddress("MW1_POSX", &mw1_posx);
tree2->SetBranchAddress("MW1_POSY", &mw1_posy);
tree2->SetBranchAddress("MW2_POSX", &mw2_posx);
tree2->SetBranchAddress("MW2_POSY", &mw2_posy);
TBranch *bic1 = tree->Branch("ic1", &ic1_avg, "ic1/D");
TBranch *bic2 = tree->Branch("ic2", &ic2_avg, "ic2/D");
TBranch *bmw1_focusx = tree->Branch("mw1_focusx", &mw1_focusx_avg, "mw1_focusx/D");
TBranch *bmw1_focusy = tree->Branch("mw1_focusy", &mw1_focusy_avg, "mw1_focusy/D");
TBranch *bmw2_focusx = tree->Branch("mw2_focusx", &mw2_focusx_avg, "mw2_focusx/D");
TBranch *bmw2_focusy = tree->Branch("mw2_focusy", &mw2_focusy_avg, "mw2_focusy/D");
TBranch *bmw1_posx = tree->Branch("mw1_posx", &mw1_posx_avg, "mw1_posx/D");
TBranch *bmw1_posy = tree->Branch("mw1_posy", &mw1_posy_avg, "mw1_posy/D");
TBranch *bmw2_posx = tree->Branch("mw2_posx", &mw2_posx_avg, "mw2_posx/D");
TBranch *bmw2_posy = tree->Branch("mw2_posy", &mw2_posy_avg, "mw2_posy/D");
int currentEntryTree2 = 1;
int nevents = tree->GetEntries();
int nevents2 = tree2->GetEntries();
ic1_avg = 0;
ic2_avg = 0;
mw1_focusx_avg = 0;
mw1_focusy_avg = 0;
mw2_focusx_avg = 0;
mw2_focusy_avg = 0;
mw1_posx_avg = 0;
mw1_posy_avg = 0;
mw2_posx_avg = 0;
mw2_posy_avg = 0;
time2 = 0;
tree2->GetEntry(currentEntryTree2);
for (int i = 0; i < nevents; i++)
{
tree->GetEntry(i);
if (i % 10000 == 0)
{
printf("merging event %d ,", i);
printf("Time %f \n", time);
printf("Entry hit %d ,", currentEntryTree2);
printf("Time hit %f \n", time2);
}
int count = 0;
int count2 = 0;
while (time2 <= (time + timeoffset+0.312/2.) && currentEntryTree2 < nevents2)
{
if (abs(time2 - (time+timeoffset)) <= 0.300/2.)
{
// tree2->GetEntry(currentEntryTree2);
ic1_avg += ic1;
ic2_avg += ic2;
count++;
//printf("%i %2.3f %2.3f\n", count, time, time2);
//}
//tree2->GetEntry(currentEntryTree2);
//if (abs(time2 - (time+timeoffset)) <= 0.300/2.)
//{
tree2->GetEntry(currentEntryTree2 - 4); //why currentEtryTree2-4?
mw1_focusx_avg += mw1_focusx;
mw1_focusy_avg += mw1_focusy;
mw2_focusx_avg += mw2_focusx;
mw2_focusy_avg += mw2_focusy;
mw1_posx_avg += mw1_posx*ic1;
mw1_posy_avg += mw1_posy*ic1;
mw2_posx_avg += mw2_posx*ic2;
mw2_posy_avg += mw2_posy*ic2;
count2++;
// printf("%i %2.3f %2.3f %2.3f %2.3f\n", count2, time, time2, ic1, mw1_posx);
}
currentEntryTree2++;
tree2->GetEntry(currentEntryTree2);
// currentEntryTree2++;
}
mw1_focusx_avg /= count2;
mw1_focusy_avg /= count2;
mw2_focusx_avg /= count2;
mw2_focusy_avg /= count2;
mw1_posx_avg /= ic1_avg; //the positions are weighted by the charge
mw1_posy_avg /= ic1_avg;
mw2_posx_avg /= ic2_avg;
mw2_posy_avg /= ic2_avg;
ic1_avg /= count;
ic2_avg /= count;
bic1->Fill();
bic2->Fill();
bmw1_focusx->Fill();
bmw1_focusy->Fill();
bmw2_focusx->Fill();
bmw2_focusy->Fill();
bmw1_posx->Fill();
bmw1_posy->Fill();
bmw2_posx->Fill();
bmw2_posy->Fill();
ic1_avg = 0;
ic2_avg = 0;
mw1_focusx_avg = 0;
mw1_focusy_avg = 0;
mw2_focusx_avg = 0;
mw2_focusy_avg = 0;
mw1_posx_avg = 0;
mw1_posy_avg = 0;
mw2_posx_avg = 0;
mw2_posy_avg = 0;
}
tree->Write();
outfile->Close();
}
}
return 0;
}

26
Scripts_20161126/energylist_c_bpm1.txt

@ -0,0 +1,26 @@
281.17 196.867 1.3175
238.032 179.85 1.20008
212.434 169.016 1.13173
194.949 160.469 1.05858
181.707 153.851 1.01704
171.379 148.603 0.976083
163.143 144.656 0.939167
155.987 140.722 0.934211
150.13 137.608 0.917891
145.288 134.995 0.901069
140.907 132.671 0.89545
136.922 130.383 0.872389
133.574 128.49 0.854152
130.481 126.591 0.837884
127.616 124.669 0.826673
124.954 123.359 0.826776
122.474 121.772 0.809861
120.362 120.852 0.805432
118.373 119.21 0.78314
116.315 118.072 0.794487
113.872 116.746 0.797656
111.453 115.09 0.767728
109.36 113.845 0.761847
107.408 112.763 0.748099
105.71 111.924 0.754045
103.993 110.711 0.760557

26
Scripts_20161126/energylist_c_bpm1ratio.txt

@ -0,0 +1,26 @@
281.17 0.511747 0.0991432
238.032 0.550471 0.0776159
212.434 0.578648 0.069855
194.949 0.600649 0.0828653
181.707 0.618462 0.0881503
171.379 0.631073 0.0670831
163.143 0.645186 0.0636568
155.987 0.657305 0.0762452
150.13 0.66727 0.0689592
145.288 0.676203 0.0657185
140.907 0.684881 0.0666931
136.922 0.694878 0.0919361
133.574 0.700551 0.072031
130.481 0.706417 0.0706179
127.616 0.711568 0.0727347
124.954 0.71947 0.0908468
122.474 0.723455 0.0714208
120.362 0.730006 0.0667801
118.373 0.732592 0.0640762
116.315 0.739325 0.0827212
113.872 0.746295 0.09357
111.453 0.750604 0.0640238
109.36 0.757457 0.0726045
107.408 0.763871 0.0697857
105.71 0.769927 0.0629636
103.993 0.777465 0.107248

26
Scripts_20161126/energylist_c_bpmbeta1.txt

@ -0,0 +1,26 @@
0.407871 0.70017 0.00468578
0.44884 0.75557 0.00504169
0.479338 0.795619 0.00532747
0.503822 0.823137 0.00543006
0.524858 0.846695 0.00559711
0.543065 0.867102 0.00569545
0.5589 0.886679 0.00575669
0.573741 0.902141 0.00598905
0.586721 0.91659 0.00611396
0.59808 0.929151 0.00620195
0.608891 0.94155 0.00635492
0.619196 0.952243 0.00637143
0.628229 0.961937 0.00639461
0.636893 0.970188 0.00642148
0.645213 0.976903 0.00647779
0.653209 0.987228 0.00661662
0.6609 0.994266 0.0066125
0.667643 1.00407 0.00669175
0.674162 1.00707 0.00661587
0.681086 1.01511 0.0068305
0.689547 1.02523 0.00700482
0.698204 1.03263 0.00688834
0.705926 1.04101 0.00696643
0.713327 1.04986 0.00696503
0.719927 1.05878 0.00713316
0.726761 1.06459 0.00731353

26
Scripts_20161126/energylist_c_chi2fit.txt

@ -0,0 +1,26 @@
281.17 2.7051 1.87564
238.032 3.70102 2.23155
212.434 4.23281 2.34094
194.949 3.85693 2.10054
181.707 3.51978 1.96641
171.379 3.28301 1.83182
163.143 3.07473 1.75688
155.987 2.95638 1.79921
150.13 2.79751 1.66286
145.288 2.6533 1.64325
140.907 2.58396 1.63551
136.922 2.63068 1.64612
133.574 2.60137 1.64867
130.481 2.61118 1.63493
127.616 2.57128 1.62584
124.954 2.44019 1.57315
122.474 2.40852 1.55201
120.362 2.18739 1.44594
118.373 2.15996 1.37106
116.315 2.33606 1.56155
113.872 2.3494 1.66249
111.453 2.08909 1.38815
109.36 2.04459 1.31172
107.408 2.09411 1.34803
105.71 2.03485 1.41536
103.993 1.84837 1.30843

26
Scripts_20161126/energylist_c_focus1.txt

@ -0,0 +1,26 @@
281.17 11.6173 0.526113
238.032 9.81008 0.320042
212.434 8.63341 0.236798
194.949 7.75115 0.221266
181.707 7.09651 0.213813
171.379 6.58813 0.184163
163.143 6.2041 0.184757
155.987 5.86053 0.173209
150.13 5.61335 0.161585
145.288 5.42964 0.155038
140.907 5.23743 0.157624
136.922 5.00862 0.15949
133.574 4.82878 0.150554
130.481 4.6612 0.150529
127.616 4.50058 0.148177
124.954 4.44307 0.157311
122.474 4.32668 0.171126
120.362 4.26544 0.151631
118.373 4.1406 0.147127
116.315 4.00506 0.149328
113.872 3.89954 0.152054
111.453 3.82633 0.157703
109.36 3.73899 0.147235
107.408 3.69418 0.150126
105.71 3.62339 0.153794
103.993 3.58926 0.164296

26
Scripts_20161126/energylist_c_focusHIT.txt

@ -0,0 +1,26 @@
281.17 9.8
238.032 8.4
212.434 7.4
194.949 6.6
181.707 6.1
171.379 5.6
163.143 5.3
155.987 5
150.13 4.8
145.288 4.6
140.907 4.4
136.922 4.3
133.574 4.2
130.481 4.1
127.616 4
124.954 3.9
122.474 3.8
120.362 3.8
118.373 3.7
116.315 3.7
113.872 3.6
111.453 3.6
109.36 3.5
107.408 3.5
105.71 3.4
103.993 3.4

26
Scripts_20161126/energylist_c_focusfit.txt

@ -0,0 +1,26 @@
281.17 11.2876 0.283868
238.032 9.21783 0.166625
212.434 8.02 0.126836
194.949 7.18651 0.110407
181.707 6.56283 0.0998927
171.379 6.08487 0.0913746
163.143 5.73336 0.0873942
155.987 5.41198 0.0816706
150.13 5.1947 0.0854009
145.288 5.04038 0.0915793
140.907 4.86282 0.0995636
136.922 4.62808 0.0873889
133.574 4.45099 0.0859766
130.481 4.28634 0.0791057
127.616 4.1333 0.0805856
124.954 4.09938 0.113435
122.474 3.98776 0.100129
120.362 3.95148 0.107079
118.373 3.82589 0.0995612
116.315 3.68008 0.0926725
113.872 3.58183 0.101117
111.453 3.5244 0.0858192
109.36 3.44571 0.0940819
107.408 3.40738 0.102715
105.71 3.35017 0.116638
103.993 3.32749 0.139817

26
Scripts_20161126/energylist_c_ic1.txt

@ -0,0 +1,26 @@
254.499 4.13296 0.0271597 SAVE_PiN_run61.root
215.483 3.49934 0.0229583 SAVE_PiN_run62.root
192.343 3.12357 0.0205949 SAVE_PiN_run63.root
176.544 2.867 0.0186617 SAVE_PiN_run64.root
164.584 2.67278 0.0174517 SAVE_PiN_run65.root
155.258 2.52133 0.0163584 SAVE_PiN_run66.root
147.823 2.40059 0.0154053 SAVE_PiN_run67.root
141.364 2.29569 0.0150784 SAVE_PiN_run68.root
136.079 2.20987 0.0145734 SAVE_PiN_run69.root
131.711 2.13892 0.0141145 SAVE_PiN_run70.root
127.758 2.07474 0.0138419 SAVE_PiN_run71.root
124.164 2.01637 0.0133276 SAVE_PiN_run72.root
121.145 1.96734 0.0129158 SAVE_PiN_run73.root
118.356 1.92206 0.0125667 SAVE_PiN_run74.root
115.773 1.88011 0.012318 SAVE_PiN_run75.root
113.374 1.84114 0.0122102 SAVE_PiN_run76.root
111.138 1.80483 0.0118726 SAVE_PiN_run77.root
109.234 1.77392 0.0117092 SAVE_PiN_run78.root
107.442 1.74481 0.011332 SAVE_PiN_run79.root
105.587 1.71468 0.0114041 SAVE_PiN_run80.root
103.386 1.67895 0.0113347 SAVE_PiN_run81.root
101.207 1.64356 0.0108603 SAVE_PiN_run82.root
99.3211 1.61293 0.0106958 SAVE_PiN_run83.root
97.563 1.58438 0.0104304 SAVE_PiN_run84.root
96.0339 1.55955 0.0104298 SAVE_PiN_run85.root
94.488 1.53444 0.0104569 SAVE_PiN_run86.root

26
Scripts_20161126/energylist_c_ic1ratio.txt

@ -0,0 +1,26 @@
254.499 0.885089
215.483 0.90409
192.343 0.914465
176.544 0.886048
164.584 0.881621
155.258 0.927782
147.823 0.930192
141.364 0.929105
136.079 0.939976
131.711 0.948007
127.758 0.952699
124.164 0.909048
121.145 0.939753
118.356 0.942121
115.773 0.939456
113.374 0.922044
111.138 0.943682
109.234 0.951689
107.442 0.95128
105.587 0.935016
103.386 0.929894
101.207 0.957823
99.3211 0.951092
97.563 0.95056
96.0339 0.965003
94.488 0.923935

26
Scripts_20161126/energylist_c_kurt1.txt

@ -0,0 +1,26 @@
281.17 0.0356758 0.00107116
238.032 0.320209 0.00159163
212.434 0.49406 0.00213649
194.949 0.558706 0.00254213
181.707 0.630652 0.00314274
171.379 0.66606 0.00333442
163.143 0.727336 0.00416318
155.987 0.733897 0.00423606
150.13 0.720708 0.00416761
145.288 0.713137 0.00424307
140.907 0.725848 0.00456726
136.922 0.781209 0.00478593
133.574 0.800686 0.00467725
130.481 0.834471 0.0047637
127.616 0.848479 0.00463475
124.954 0.848781 0.00515817
122.474 0.830013 0.00457454
120.362 0.81721 0.0048051
118.373 0.866358 0.00483772
116.315 0.883082 0.00458012
113.872 0.886597 0.00470424
111.453 0.886818 0.0045689
109.36 0.905571 0.0048629
107.408 0.86823 0.00470287
105.71 0.848611 0.00462913
103.993 0.890782 0.00520447

26
Scripts_20161126/energylist_c_noise.txt

@ -0,0 +1,26 @@
281.17 0.0951588 8.32344
238.032 0.0592451 7.74989
212.434 -0.0351296 6.66716
194.949 0.0984721 7.22182
181.707 -0.0721369 7.75374
171.379 0.0129299 8.39957
163.143 0.0364104 7.46192
155.987 0.00417705 7.32121
150.13 -0.0155063 7.10115
145.288 0.0580136 7.21786
140.907 -0.012564 6.70641
136.922 0.0161248 6.88752
133.574 0.0241872 6.01433
130.481 -0.00668754 5.99136
127.616 -0.028617 6.38002
124.954 -0.0114989 6.50708
122.474 0.0126697 7.88635
120.362 -0.0283078 7.28673
118.373 -0.0396834 6.18225
116.315 -0.0103058 7.45979
113.872 -0.0716595 5.92234
111.453 0.0119976 6.31534
109.36 0.0338752 5.91695
107.408 -0.140158 6.10205
105.71 -0.0362593 6.62066
103.993 0.0717063 7.67349

26
Scripts_20161126/energylist_c_skew1.txt

@ -0,0 +1,26 @@
281.17 -0.0244641 0.00029967
238.032 -0.0291883 0.000307723
212.434 -0.0321315 0.000342685
194.949 -0.0377581 0.00036608
181.707 -0.041645 0.000426071
171.379 -0.0440514 0.000386359
163.143 -0.0479717 0.000457673
155.987 -0.0459235 0.00045976
150.13 -0.0449714 0.000435774
145.288 -0.0557605 0.000472567
140.907 -0.0604744 0.000488399
136.922 -0.0480572 0.000558716
133.574 -0.0499332 0.00050712
130.481 -0.0568798 0.000572831
127.616 -0.059508 0.000559064
124.954 -0.0792876 0.000651931
122.474 -0.0769971 0.000577415
120.362 -0.0710605 0.000636362
118.373 -0.0627967 0.000716938
116.315 -0.0661404 0.000645743
113.872 -0.0503979 0.000697906
111.453 -0.078437 0.000733403
109.36 -0.079987 0.000807965
107.408 -0.0869617 0.00079218
105.71 -0.0801575 0.000840558
103.993 -0.0756168 0.00100789

26
Scripts_20161126/energylist_he_bpm1.txt

@ -0,0 +1,26 @@
40.9872 47.1601 0.325381
36.5311 43.1518 0.296032
33.3966 40.2558 0.275185
31.0354 37.8531 0.258592
29.1728 35.8407 0.23944
27.6535 34.1384 0.234008
26.4152 33.0144 0.224034
25.2997 31.9231 0.213649
24.2755 30.7137 0.200011
23.5412 29.7778 0.200923
22.8107 28.8261 0.192497
22.1585 28.1549 0.184697
21.5696 27.4654 0.178344
21.0355 26.8597 0.172283
20.5468 26.2916 0.174974
20.099 25.7392 0.169175
19.6851 25.2084 0.164477
19.3016 24.7074 0.160319
18.9455 24.1346 0.155186
18.4699 23.5882 0.149138
18.0231 23.0798 0.146083
17.6151 22.6489 0.143489
17.6151 22.6537 0.141393
17.2409 22.2957 0.145132
16.8956 21.9185 0.141963
16.5761 21.5344 0.137924

26
Scripts_20161126/energylist_he_bpm1ratio.txt

@ -0,0 +1,26 @@
40.9872 0.837155 0.119765
36.5311 0.859363 0.113341
33.3966 0.877586 0.115817
31.0354 0.888242 0.119597
29.1728 0.895211 0.117185
27.6535 0.90126 0.142076
26.4152 0.911994 0.133823
25.2997 0.922294 0.143838
24.2755 0.921898 0.11313
23.5412 0.923219 0.144729
22.8107 0.92169 0.131699
22.1585 0.926626 0.124226
21.5696 0.929649 0.124038
21.0355 0.930499 0.103947
20.5468 0.933104 0.128883
20.099 0.933214 0.112198
19.6851 0.933477 0.114058
19.3016 0.934968 0.131146
18.9455 0.928811 0.110757
18.4699 0.929971 0.091714
18.0231 0.935956 0.124491
17.6151 0.93865 0.114269
17.6151 0.937032 0.0918229
17.2409 0.940977 0.107415
16.8956 0.947256 0.134408
16.5761 0.950791 0.15948

26
Scripts_20161126/energylist_he_bpmbeta1.txt

@ -0,0 +1,26 @@
0.347272 1.15061 0.0079386
0.371222 1.18124 0.00810356
0.391037 1.20539 0.00823989
0.408018 1.21968 0.00833216
0.422922 1.22856 0.00820763
0.436235 1.23451 0.00846215
0.447968 1.24983 0.00848127
0.459299 1.2618 0.00844473
0.470415 1.26521 0.00823922
0.478846 1.26492 0.00853495
0.487649 1.26371 0.00843892
0.495887 1.27061 0.00833523
0.503656 1.27334 0.00826832
0.510991 1.27687 0.0081901
0.517959 1.2796 0.00851587
0.524572 1.28062 0.00841711
0.530889 1.28058 0.00835539
0.536926 1.28007 0.00830596
0.542699 1.27389 0.00819119
0.550671 1.27711 0.00807461
0.558452 1.28057 0.00810535
0.565815 1.28576 0.00814576
0.565815 1.28604 0.00802676
0.572799 1.29318 0.0084179
0.579449 1.29729 0.00840238
0.585785 1.29912 0.00832066

26
Scripts_20161126/energylist_he_chi2fit.txt

@ -0,0 +1,26 @@
40.9872 5.78686 4.85869
36.5311 7.57749 5.66953
33.3966 7.4341 5.60529
31.0354 7.31291 5.65149
29.1728 6.95923 5.07375
27.6535 6.82132 5.27028
26.4152 5.90849 4.74753
25.2997 5.22055 4.29738
24.2755 4.88461 3.92364
23.5412 4.83281 3.85984
22.8107 4.77697 3.82449
22.1585 4.51784 3.5504
21.5696 4.26268 3.3718
21.0355 4.09158 3.31968
20.5468 4.0224 3.28346
20.099 3.99887 3.24817
19.6851 3.94067 3.06075
19.3016 3.8586 2.9603
18.9455 4.27659 3.1393
18.4699 4.25376 2.88395
18.0231 3.93524 2.84803
17.6151 3.55297 2.83121
17.6151 3.55802 2.84576
17.2409 3.25466 2.81298
16.8956 3.01523 2.67037
16.5761 3.18326 2.76936

26
Scripts_20161126/energylist_he_focus1.txt

@ -0,0 +1,26 @@
40.9872 15.9221 0.423793
36.5311 14.2921 0.358463
33.3966 12.8768 0.346412
31.0354 11.8021 0.317436
29.1728 10.9673 0.295563
27.6535 10.3418 0.274694
26.4152 9.98036 0.250454
25.2997 9.65909 0.232713
24.2755 9.23717 0.227609
23.5412 8.86011 0.201864
22.8107 8.47676 0.19754
22.1585 8.17635 0.181417
21.5696 7.93508 0.177604
21.0355 7.7211 0.198354
20.5468 7.6021 0.18296
20.099 7.46468 0.171901
19.6851 7.23694 0.171037
19.3016 6.90511 0.165608
18.9455 6.60379 0.162897
18.4699 6.34687 0.162767
18.0231 6.2449 0.1577
17.6151 6.16995 0.164441
17.6151 6.16264 0.156679
17.2409 6.08753 0.154969
16.8956 5.9945 0.140838
16.5761 5.75543 0.1449

26
Scripts_20161126/energylist_he_focusHIT.txt

@ -0,0 +1,26 @@
40.9872 15.4
36.5311 13
33.3966 11.5
31.0354 10.5
29.1728 9.7
27.6535 9.2
26.4152 8.7
25.2997 8.3
24.2755 7.9
23.5412 7.6
22.8107 7.3
22.1585 7
21.5696 6.8
21.0355 6.5
20.5468 6.3
20.099 6.1
19.6851 5.9
19.3016 5.8
18.9455 5.6
18.4699 5.4
18.0231 5.3
17.6151 5.1
17.6151 5.1
17.2409 5
16.8956 5
16.5761 4.9

26
Scripts_20161126/energylist_he_focusfit.txt

@ -0,0 +1,26 @@
40.9872 15.1594 0.157637
36.5311 13.3055 0.110274
33.3966 11.8374 0.0889165
31.0354 10.7895 0.0836284
29.1728 10.0051 0.0751865
27.6535 9.44939 0.065632
26.4152 9.17732 0.0644147
25.2997 8.93682 0.0645154
24.2755 8.5593 0.0622379
23.5412 8.2007 0.0585808
22.8107 7.83545 0.0540224
22.1585 7.54864 0.0516892
21.5696 7.33297 0.0495544
21.0355 7.14276 0.060412
20.5468 7.07923 0.0498132
20.099 6.97124 0.0492933
19.6851 6.7461 0.0464559
19.3016 6.37544 0.0451538
18.9455 6.0389 0.0469093
18.4699 5.78302 0.0474983
18.0231 5.7198 0.0488553
17.6151 5.68573 0.0504578
17.6151 5.68278 0.0590019
17.2409 5.64649 0.0511971
16.8956 5.58385 0.0536603
16.5761 5.32082 0.0536564

26
Scripts_20161126/energylist_he_ic1.txt

@ -0,0 +1,26 @@
36.9312 0.599746 0.00406694 SAVE_PiN_run34.root
32.9287 0.534748 0.00361452 SAVE_PiN_run35.root
30.1125 0.489013 0.00329485 SAVE_PiN_run36.root
27.9903 0.454551 0.0030533 SAVE_PiN_run37.root
26.316 0.427361 0.00281565 SAVE_PiN_run38.root
24.95 0.405178 0.00273157 SAVE_PiN_run39.root
23.8365 0.387094 0.00258457 SAVE_PiN_run40.root
22.8333 0.370802 0.002451 SAVE_PiN_run41.root
21.912 0.355841 0.00229435 SAVE_PiN_run43.root
21.2514 0.345113 0.00229615 SAVE_PiN_run44.root
20.5941 0.334439 0.00220292 SAVE_PiN_run45.root
20.0073 0.32491 0.00210673 SAVE_PiN_run46.root
19.4773 0.316303 0.00203096 SAVE_PiN_run47.root
18.9966 0.308497 0.00195993 SAVE_PiN_run48.root
18.5568 0.301354 0.00197873 SAVE_PiN_run49.root
18.1537 0.294808 0.00191426 SAVE_PiN_run50.root
17.7811 0.288757 0.00186095 SAVE_PiN_run51.root
17.4359 0.283151 0.00181536 SAVE_PiN_run52.root
17.1152 0.277944 0.00176825 SAVE_PiN_run53.root
16.687 0.27099 0.00170039 SAVE_PiN_run54.root
16.2846 0.264455 0.00165894 SAVE_PiN_run55.root
15.9173 0.258489 0.00162654 SAVE_PiN_run56.root
15.9173 0.258489 0.00160302 SAVE_PiN_run57.root
15.5802 0.253016 0.00162981 SAVE_PiN_run58.root
15.2692 0.247965 0.00159113 SAVE_PiN_run59.root
14.9814 0.243291 0.00154646 SAVE_PiN_run60.root

26
Scripts_20161126/energylist_he_ic1ratio.txt

@ -0,0 +1,26 @@
36.9312 0.917436
32.9287 0.907649
30.1125 0.907305
27.9903 0.900293
26.316 0.887237
24.95 0.876085
23.8365 0.878532
22.8333 0.862414
21.912 0.88259
21.2514 0.864072
20.5941 0.872034
20.0073 0.872613
19.4773 0.862322
18.9966 0.891
18.5568 0.881325
18.1537 0.894299
17.7811 0.885777
17.4359 0.849629
17.1152 0.879188
16.687 0.904921
16.2846 0.832804
15.9173 0.850892
15.9173 0.895537
15.5802 0.897175
15.2692 0.846152
14.9814 0.844238

26
Scripts_20161126/energylist_he_kurt1.txt

@ -0,0 +1,26 @@
40.9872 0.062149 0.000502374
36.5311 0.26801 0.000752224
33.3966 0.417309 0.00102226
31.0354 0.516133 0.00129087
29.1728 0.57681 0.00147873
27.6535 0.601425 0.00160397
26.4152 0.576202 0.00163652
25.2997 0.552416 0.00164094
24.2755 0.572242 0.00178198
23.5412 0.599514 0.00184313
22.8107 0.622563 0.00195299
22.1585 0.657125 0.00209616
21.5696 0.668196 0.00218858
21.0355 0.679962 0.00241972
20.5468 0.646933 0.00257645
20.099 0.629794 0.00255621
19.6851 0.661712 0.00280398
19.3016 0.753138 0.00299473
18.9455 0.839607 0.00315274
18.4699 0.904866 0.00344225
18.0231 0.88544 0.00380291
17.6151 0.824344 0.00376951
17.6151 0.832551 0.00371834
17.2409 0.793757 0.00391352
16.8956 0.753537 0.00377728
16.5761 0.847073 0.00420923

26
Scripts_20161126/energylist_he_noise.txt

@ -0,0 +1,26 @@
40.9872 0.0907693 9.0404
36.5311 -0.114624 8.03533
33.3966 0.0739249 7.77771
31.0354 -0.0797303 8.4556
29.1728 0.0957379 6.00886
27.6535 0.0169903 6.71134
26.4152 -0.00831133 6.83634
25.2997 0.00625121 7.04404
24.2755 -0.0709542 7.69864
23.5412 -0.106325 5.93381
22.8107 -0.0289266 6.1212
22.1585 -0.021199 8.16651
21.5696 -0.0615789 8.03329
21.0355 0.00902604 8.22651
20.5468 0.000964529 8.52766
20.099 0.00978403 8.69545
19.6851 -0.125431 8.35675
19.3016 0.111513 8.65042
18.9455 0.0479698 8.72494
18.4699 0.113175 8.68838
18.0231 -0.0610166 9.1184
17.6151 -0.0228421 8.43948
17.6151 -0.00349188 8.85769
17.2409 0.0209996 8.55378
16.8956 -0.0725304 8.09427
16.5761 0.0894327 7.664

26
Scripts_20161126/energylist_he_skew1.txt

@ -0,0 +1,26 @@
40.9872 0.010948 0.000211011
36.5311 -0.00203 0.000277193
33.3966 -0.0103664 0.000308383
31.0354 -0.015916 0.000344433
29.1728 -0.0208106 0.000352361
27.6535 -0.0344067 0.000329169
26.4152 -0.0285648 0.000335402
25.2997 -0.0306445 0.000309011
24.2755 -0.0345809 0.000356599
23.5412 -0.0410346 0.000298393
22.8107 -0.0433163 0.000315473
22.1585 -0.0409883 0.000315195
21.5696 -0.0400524 0.000329647
21.0355 -0.0409011 0.000405011
20.5468 -0.0533499 0.0003929
20.099 -0.0613756 0.000368003
19.6851 -0.0653937 0.000414132
19.3016 -0.0570107 0.000393711
18.9455 -0.062355 0.000411582
18.4699 -0.0637269 0.000410686
18.0231 -0.0646381 0.000443125
17.6151 -0.0668969 0.000532587
17.6151 -0.0689966 0.000465528
17.2409 -0.0722478 0.00047688
16.8956 -0.0730202 0.000397724
16.5761 -0.0728579 0.000449836

21
Scripts_20161126/energylist_o_bpm1.txt

@ -0,0 +1,21 @@
444.422 283.324 1.77394
377.991 258.069 1.70727
337.641 241.789 1.65216
310.049 229.547 1.57122
289.655 220.51 1.50184
273.879 213.788 1.4449
261.017 208.227 1.41063
250.406 204.009 1.42342
241.353 199.865 1.37302
233.587 195.942 1.40855
226.809 193.137 1.37409
220.824 190.311 1.3673
215.458 187.751 1.36183
210.691 185.687 1.41053
206.301 183.871 1.35948
202.283 182.269 1.36312
198.535 180.563 1.3555
195.17 178.594 1.34891
191.994 176.964 1.38416
189.171 175.153 1.38183
185.146 173.879 1.39197

21
Scripts_20161126/energylist_o_bpm1ratio.txt

@ -0,0 +1,21 @@
444.422 0.463955 0.0472485
377.991 0.49717 0.0600861
337.641 0.522513 0.0773371
310.049 0.540532 0.0823137
289.655 0.554082 0.0728014
273.879 0.569026 0.0813242
261.017 0.582256 0.0873147
250.406 0.59429 0.101642
241.353 0.604949 0.101284
233.587 0.613851 0.12513
226.809 0.621925 0.1197
220.824 0.627908 0.112074
215.458 0.639176 0.141836
210.691 0.642942 0.144067
206.301 0.651644 0.140007
202.283 0.658283 0.142713
198.535 0.665819 0.153575
195.17 0.67072 0.156159
191.994 0.673946 0.167684
189.171 0.674636 0.158734
185.146 0.689113 0.195112

21
Scripts_20161126/energylist_o_bpmbeta1.txt

@ -0,0 +1,21 @@
0.436386 0.637511 0.00399157
0.479001 0.682739 0.0045167
0.511349 0.716111 0.00489326
0.537325 0.740358 0.00506767
0.559062 0.761285 0.00518492
0.577647 0.780592 0.00527569
0.594124 0.797751 0.00540435
0.608731 0.814711 0.00568445
0.621998 0.828105 0.00568885
0.634024 0.838841 0.0060301
0.645051 0.851544 0.00605836
0.655227 0.861821 0.00619182
0.664724 0.871405 0.00632064
0.673476 0.881324 0.00669479
0.681811 0.891275 0.00658981
0.689682 0.901056 0.00673865
0.697243 0.909476 0.00682753
0.704219 0.915073 0.00691147
0.710969 0.921715 0.00720939
0.717113 0.925899 0.00730465
0.726111 0.939145 0.00751825

21
Scripts_20161126/energylist_o_chi2fit.txt

@ -0,0 +1,21 @@
444.422 2.50913 1.43854
377.991 3.15341 1.78165
337.641 3.48266 1.9896
310.049 3.145 1.82616
289.655 2.88182 1.6771
273.879 2.71381 1.65493
261.017 2.58176 1.56898
250.406 2.48552 1.59462
241.353 2.45163 1.60246
233.587 2.35874 1.63678
226.809 2.29521 1.62072
220.824 2.27118 1.68845
215.458 2.21196 1.65392
210.691 2.21547 1.80557
206.301 2.22312 1.74699
202.283 2.21125 1.78459
198.535 2.18113 1.7975
195.17 2.11704 1.74831
191.994 1.97474 1.75396
189.171 1.89467 1.72274
185.146 1.99097 1.93813

21
Scripts_20161126/energylist_o_focus1.txt

@ -0,0 +1,21 @@
444.422 10.1353 0.436406
377.991 8.48151 0.298185
337.641 7.42582 0.247136
310.049 6.65796 0.240059
289.655 6.09796 0.21942
273.879 5.67039 0.198437
261.017 5.3283 0.190017
250.406 5.05531 0.188966
241.353 4.81381 0.181183
233.587 4.62773 0.185274
226.809 4.46468 0.181001
220.824 4.31942 0.177293
215.458 4.16624 0.177119
210.691 4.0485 0.179361
206.301 3.90285 0.17064
202.283 3.79799 0.183338
198.535 3.71399 0.163782
195.17 3.61246 0.166099
191.994 3.53538 0.166417
189.171 3.44765 0.166759
185.146 3.36929 0.167733

21
Scripts_20161126/energylist_o_focusHIT.txt

@ -0,0 +1,21 @@
444.422 8.8
377.991 7.3
337.641 6.2
310.049 5.5
289.655 5
273.879 4.6
261.017 4.4
250.406 4.1
241.353 4
233.587 3.8
226.809 3.7
220.824 3.5
215.458 3.4
210.691 3.3
206.301 3.2
202.283 3.1
198.535 3
195.17 2.9
191.994 2.8
189.171 2.7
185.146 2.7

21
Scripts_20161126/energylist_o_focusfit.txt

@ -0,0 +1,21 @@
444.422 9.86271 0.309402
377.991 8.00956 0.189579
337.641 6.9215 0.146643
310.049 6.18437 0.13183
289.655 5.65443 0.118702
273.879 5.23921 0.106218
261.017 4.91583 0.100768
250.406 4.65659 0.0979168
241.353 4.42609 0.0936621
233.587 4.25642 0.0930374
226.809 4.10471 0.0878046
220.824 3.9663 0.0841938
215.458 3.81957 0.082233
210.691 3.71291 0.0845847
206.301 3.56508 0.0764382
202.283 3.46133 0.0758902
198.535 3.39023 0.0763753
195.17 3.29698 0.0732074
191.994 3.23568 0.0698015
189.171 3.1601 0.0784281
185.146 3.08344 0.0714811

21
Scripts_20161126/energylist_o_ic1.txt

@ -0,0 +1,21 @@
416.151 6.75811 0.0418425 SAVE_PiN_run87.root
353.682 5.74365 0.0374351 SAVE_PiN_run88.root
315.718 5.12712 0.0343866 SAVE_PiN_run89.root
289.746 4.70535 0.0316226 SAVE_PiN_run90.root
270.543 4.3935 0.0293093 SAVE_PiN_run91.root
255.685 4.15221 0.0275087 SAVE_PiN_run92.root
243.568 3.95544 0.0262334 SAVE_PiN_run93.root
233.57 3.79307 0.025866 SAVE_PiN_run94.root
225.037 3.65451 0.024529 SAVE_PiN_run95.root
217.717 3.53563 0.0247171 SAVE_PiN_run96.root
211.327 3.43186 0.0237828 SAVE_PiN_run97.root
205.684 3.34022 0.0233477 SAVE_PiN_run98.root
200.624 3.25804 0.0229768 SAVE_PiN_run99.root
196.128 3.18503 0.0234044 SAVE_PiN_run100.root
191.987 3.11779 0.022362 SAVE_PiN_run101.root
188.197 3.05624 0.0221984 SAVE_PiN_run103.root
184.661 2.99881 0.0218315 SAVE_PiN_run104.root
181.485 2.94724 0.0216234 SAVE_PiN_run105.root
178.489 2.89859 0.0219119 SAVE_PiN_run106.root
175.824 2.85531 0.0217452 SAVE_PiN_run107.root
172.026 2.79362 0.0216389 SAVE_PiN_run108.root

21
Scripts_20161126/energylist_o_ic1ratio.txt

@ -0,0 +1,21 @@
416.151 0.941174
353.682 0.925095
315.718 0.892407
289.746 0.88503
270.543 0.907785
255.685 0.889439
243.568 0.877005
233.57 0.877723
225.037 0.86436
217.717 0.858901
211.327 0.866923
205.684 0.888274
200.624 0.846301
196.128 0.87631
191.987 0.869604
188.197 0.879467
184.661 0.862564
181.485 0.868013
178.489 0.87785
175.824 0.889568
172.026 0.865953

21
Scripts_20161126/energylist_o_kurt1.txt

@ -0,0 +1,21 @@
444.422 0.0391801 0.00125918
377.991 0.301277 0.00195732
337.641 0.484785 0.00272705
310.049 0.556202 0.00332809
289.655 0.598105 0.00364761
273.879 0.668359 0.00429699
261.017 0.708683 0.00454656
250.406 0.725855 0.00454412
241.353 0.748311 0.0044552
233.587 0.845926 0.00582114
226.809 0.843351 0.00561141
220.824 0.861779 0.00558332
215.458 0.897915 0.00575129
210.691 0.859559 0.00541461
206.301 0.861972 0.0048006
202.283 0.890871 0.00495878
198.535 0.885117 0.00500067
195.17 0.916953 0.00500143
191.994 0.942331 0.005395
189.171 0.924809 0.00503647
185.146 0.904397 0.00505454

21
Scripts_20161126/energylist_o_noise.txt

@ -0,0 +1,21 @@
444.422 -0.00489616 6.68537
377.991 0.0243297 6.38303
337.641 0.106515 7.24391
310.049 0.0288923 6.10859
289.655 -0.105939 6.30075
273.879 -0.0502152 5.92397
261.017 0.00964585 6.12448
250.406 -0.0951886 6.3359
241.353 0.0920268 5.89285
233.587 -0.00596982 8.13928
226.809 0.069777 8.64053
220.824 -0.0615429 8.78081
215.458 0.0121637 8.50478
210.691 -0.037111 8.30072
206.301 0.00137241 6.90519
202.283 -0.0266904 6.40269
198.535 -0.0889237 5.85698
195.17 -0.13955 6.19566
191.994 0.000563917 6.85085
189.171 0.0417185 6.79554
185.146 0.052973 5.99332

21
Scripts_20161126/energylist_o_skew1.txt

@ -0,0 +1,21 @@
444.422 -0.0280469 0.000364346
377.991 -0.0330713 0.000389986
337.641 -0.0353204 0.000429569
310.049 -0.0422523 0.000465556
289.655 -0.0467927 0.000476789
273.879 -0.0497144 0.000542298
261.017 -0.0499807 0.000562507
250.406 -0.0495207 0.0005861
241.353 -0.045314 0.000593588
233.587 -0.0675023 0.000899926
226.809 -0.0597604 0.000832946
220.824 -0.0579474 0.00097652
215.458 -0.0630855 0.000921185
210.691 -0.0573608 0.000917137
206.301 -0.0420676 0.000786955
202.283 -0.035546 0.000837714
198.535 -0.0339243 0.000822717
195.17 -0.06218 0.000901306
191.994 -0.0551722 0.00110734
189.171 -0.0273813 0.000948981
185.146 -0.0539994 0.000995197

26
Scripts_20161126/energylist_p_bpm1.txt

@ -0,0 +1,26 @@
12.6088 14.7533 0.096904
10.5936 12.9823 0.0867817
9.36031 11.739 0.0833148
8.51336 10.7917 0.0757961
7.88605 10.0881 0.0704225
7.39682 9.53643 0.066426
7.00082 9.08859 0.0614816
6.67084 8.70457 0.0592074
6.39059 8.38237 0.0544328
6.14881 8.11432 0.0542731
5.93691 7.87787 0.0530555
5.74999 7.66343 0.0509711
5.58275 7.4668 0.0501345
5.43216 7.28997 0.0491602
5.29477 7.12113 0.0466416
5.16875 6.95465 0.0450393
5.05214 6.79119 0.0435765
4.94396 6.65235 0.0429222
4.84371 6.53111 0.0422342
4.7504 6.42166 0.0415991
4.62797 6.26875 0.040269
4.51492 6.11729 0.0392985
4.41193 5.98535 0.0386669
4.31778 5.8583 0.03804
4.23108 5.75379 0.0374308
4.15089 5.66446 0.0370458

26
Scripts_20161126/energylist_p_bpm1ratio.txt

@ -0,0 +1,26 @@
12.6088 0.846875 0.162587
10.5936 0.887343 0.0879311
9.36031 0.907533 0.0762469
8.51336 0.932063 0.200989
7.88605 0.927223 0.0684706
7.39682 0.934388 0.0656731
7.00082 0.941687 0.0665411
6.67084 0.946871 0.0590399
6.39059 0.954023 0.0832979
6.14881 0.959175 0.0822801
5.93691 0.967165 0.11564
5.74999 0.969136 0.0859334
5.58275 0.976766 0.139394
5.43216 0.974111 0.0706902
5.29477 0.978422 0.0862178
5.16875 0.97894 0.0827282
5.05214 0.97749 0.0733657
4.94396 0.979042 0.0861606
4.84371 0.982174 0.10259
4.7504 0.982609 0.0792495
4.62797 0.985496 0.0745409
4.51492 0.986499 0.0945878
4.41193 0.986779 0.0897324
4.31778 0.987506 0.0860912
4.23108 0.989358 0.0817015
4.15089 0.995765 0.120135

26
Scripts_20161126/energylist_p_bpmbeta1.txt

@ -0,0 +1,26 @@
0.308525 1.17009 0.00768545
0.340994 1.22548 0.00819192
0.366173 1.25412 0.00890086
0.386744 1.26762 0.00890319
0.404198 1.27924 0.00893001
0.419413 1.28926 0.00898034
0.432945 1.29822 0.00878207
0.44518 1.30487 0.00887555
0.456345 1.31167 0.00851766
0.466617 1.31966 0.00882661
0.476154 1.32693 0.00893656
0.485023 1.33277 0.00886456
0.493348 1.33748 0.00898026
0.501186 1.342 0.00904985
0.508639 1.34494 0.00880901
0.515744 1.34552 0.00871377
0.522563 1.34422 0.00862534
0.529111 1.34555 0.00868173
0.53538 1.34837 0.0087194
0.541398 1.35181 0.00875697
0.549576 1.35453 0.00870121
0.557429 1.35491 0.00870414
0.564849 1.35663 0.00876418
0.571868 1.35679 0.00881008
0.578541 1.35989 0.00884663
0.5849 1.36464 0.00892479

26
Scripts_20161126/energylist_p_chi2fit.txt

@ -0,0 +1,26 @@
12.6088 4.92376 7.47872
10.5936 5.00881 6.30747
9.36031 5.31616 5.90385
8.51336 4.64942 4.978
7.88605 3.97282 3.95399
7.39682 3.48958 3.05764
7.00082 3.24976 2.61228
6.67084 3.11978 2.35697
6.39059 2.94007 1.78095
6.14881 2.94268 1.76171
5.93691 2.96652 1.73581
5.74999 2.95324 1.67745
5.58275 2.80359 1.56897
5.43216 2.72042 1.53197
5.29477 2.6922 1.38143
5.16875 2.73321 1.34053
5.05214 2.83884 1.28687
4.94396 2.91402 1.34718
4.84371 2.86251 1.34265
4.7504 2.79482 1.29505
4.62797 2.77572 1.32771
4.51492 2.76483 1.26223
4.41193 2.80534 1.36321
4.31778 2.77945 1.36982
4.23108 2.64168 1.25611
4.15089 2.55105 1.24133

26
Scripts_20161126/energylist_p_focus1.txt

@ -0,0 +1,26 @@
12.6088 23.2202 1.30071
10.5936 22.3925 0.609153
9.36031 21.5149 0.597366
8.51336 20.6234 0.45632
7.88605 19.6743 0.362185
7.39682 18.7674 0.336758
7.00082 17.9374 0.293683
6.67084 17.1555 0.289904
6.39059 16.4424 0.246882
6.14881 15.8897 0.280069
5.93691 15.343 0.23936
5.74999 14.8706 0.235769
5.58275 14.527 0.27967
5.43216 14.2756 0.266778
5.29477 13.9383 0.243623
5.16875 13.3496 0.244766
5.05214 12.841 0.238929
4.94396 12.4378 0.238023
4.84371 12.1803 0.239261
4.7504 11.9333 0.233253
4.62797 11.5727 0.229587
4.51492 11.191 0.227382
4.41193 10.8187 0.223042
4.31778 10.5284 0.236156
4.23108 10.3842 0.223226
4.15089 10.2094 0.227092

26
Scripts_20161126/energylist_p_focusHIT.txt

@ -0,0 +1,26 @@
12.6088 32.4
10.5936 26.8
9.36031 22.8
8.51336 20
7.88605 18
7.39682 16.5
7.00082 15.4
6.67084 14.5
6.39059 13.7
6.14881 13.1
5.93691 12.6
5.74999 12.2
5.58275 11.8
5.43216 11.4
5.29477 11.1
5.16875 10.8
5.05214 10.4
4.94396 10.1
4.84371 9.8
4.7504 9.5
4.62797 9.1
4.51492 8.8
4.41193 8.5
4.31778 8.2
4.23108 8.1
4.15089 8.1

26
Scripts_20161126/energylist_p_focusfit.txt

@ -0,0 +1,26 @@
12.6088 32.9013 1.98679
10.5936 27.744 0.796985
9.36031 24.4059 0.381944
8.51336 21.995 0.250191
7.88605 20.1596 0.17974
7.39682 18.7334 0.13563
7.00082 17.5547 0.107492
6.67084 16.5428 0.0929105
6.39059 15.6484 0.0805071
6.14881 15.0075 0.0771068
5.93691 14.3766 0.0709875
5.74999 13.8591 0.0686077
5.58275 13.6084 0.13478
5.43216 13.387 0.104907
5.29477 13.0491 0.108599
5.16875 12.3962 0.122035
5.05214 11.8307 0.0855704
4.94396 11.4052 0.0992709
4.84371 11.1674 0.0902259
4.7504 10.9495 0.110161
4.62797 10.604 0.10467
4.51492 10.2355 0.0894564
4.41193 9.8712 0.0979918
4.31778 9.59144 0.0985891
4.23108 9.5084 0.114279
4.15089 9.37103 0.126649

26
Scripts_20161126/energylist_p_ic1.txt

@ -0,0 +1,26 @@
11.3093 0.183659 0.00117077 SAVE_PiN_run5.root
9.5264 0.154705 0.00102858 SAVE_PiN_run7.root
8.43143 0.136923 0.00096873 SAVE_PiN_run8.root
7.67749 0.124679 0.000871756 SAVE_PiN_run9.root
7.1179 0.115592 0.000802586 SAVE_PiN_run11.root
6.68074 0.108492 0.000751885 SAVE_PiN_run12.root
6.32635 0.102737 0.000691779 SAVE_PiN_run13.root
6.03068 0.0979356 0.000662707 SAVE_PiN_run14.root
5.77926 0.0938527 0.000606031 SAVE_PiN_run15.root
5.56214 0.0903267 0.000599825 SAVE_PiN_run16.root
5.37167 0.0872336 0.000583303 SAVE_PiN_run17.root
5.2035 0.0845025 0.000558259 SAVE_PiN_run18.root
5.05292 0.0820573 0.000547287 SAVE_PiN_run19.root
4.91723 0.0798536 0.000534201 SAVE_PiN_run20.root
4.79334 0.0778418 0.000505923 SAVE_PiN_run21.root
4.67963 0.0759952 0.000488392 SAVE_PiN_run22.root
4.57435 0.0742855 0.000473244 SAVE_PiN_run23.root
4.47662 0.0726983 0.000465682 SAVE_PiN_run24.root
4.386 0.0712267 0.000456407 SAVE_PiN_run25.root
4.3016 0.0698562 0.000448572 SAVE_PiN_run26.root
4.1908 0.0680568 0.000434087 SAVE_PiN_run27.root
4.08841 0.0663941 0.000422286 SAVE_PiN_run28.root
3.99507 0.0648783 0.000413852 SAVE_PiN_run29.root
3.9097 0.0634918 0.000407902 SAVE_PiN_run30.root
3.83102 0.0622141 0.000401176 SAVE_PiN_run31.root
3.75822 0.0610318 0.000395632 SAVE_PiN_run32.root

26
Scripts_20161126/energylist_p_ic1ratio.txt

@ -0,0 +1,26 @@
11.3093 0.875362
9.5264 0.956761
8.43143 0.97329
7.67749 0.836673
7.1179 0.97414
6.68074 0.977426
6.32635 0.96967
6.03068 0.977745
5.77926 0.937204
5.56214 0.950673
5.37167 0.918863
5.2035 0.945228
5.05292 0.892151
4.91723 0.966497
4.79334 0.93725
4.67963 0.935821
4.57435 0.943885
4.47662 0.927274
4.386 0.903434
4.3016 0.93812
4.1908 0.940951
4.08841 0.906276
3.99507 0.917244
3.9097 0.926774
3.83102 0.935791
3.75822 0.884807

26
Scripts_20161126/energylist_p_kurt1.txt

@ -0,0 +1,26 @@
12.6088 -0.744136 0.000251997
10.5936 -0.635556 0.000153178
9.36031 -0.519635 0.00019486
8.51336 -0.404028 0.000199052
7.88605 -0.297951 0.000193776
7.39682 -0.204785 0.000222115
7.00082 -0.11727 0.000250413
6.67084 -0.0375088 0.000330798
6.39059 0.0413851 0.000353434
6.14881 0.0960896 0.000439675
5.93691 0.153248 0.000514665
5.74999 0.201237 0.000574853
5.58275 0.198602 0.00072239
5.43216 0.210643 0.000744263
5.29477 0.235006 0.000791398
5.16875 0.300105 0.000927326
5.05214 0.366449 0.00104199
4.94396 0.410503 0.0011509
4.84371 0.424225 0.00121132
4.7504 0.429286 0.00124945
4.62797 0.455989 0.00133598
4.51492 0.483797 0.00141302
4.41193 0.514377 0.00149148
4.31778 0.542605 0.00158946
4.23108 0.513153 0.00159354
4.15089 0.503945 0.00162372

26
Scripts_20161126/energylist_p_noise.txt

@ -0,0 +1,26 @@
12.6088 -0.0381319 9.13905
10.5936 0.0229805 9.07751
9.36031 -0.163127 9.16924
8.51336 -0.073277 9.09055
7.88605 0.0105527 8.74277
7.39682 -0.0396685 8.04183
7.00082 -0.0121889 7.53254
6.67084 0.0432702 8.82198
6.39059 -0.0873416 8.52387
6.14881 0.00527392 7.76973
5.93691 0.0202651 6.84699
5.74999 0.00435701 6.20527
5.58275 -0.0321429 7.36123
5.43216 -0.0762316 7.67736
5.29477 -0.0969601 8.35033
5.16875 0.129156 8.50019
5.05214 0.0920098 8.45706
4.94396 -0.0197884 8.30331
4.84371 0.0341125 6.56841
4.7504 -0.0783546 7.27665
4.62797 -0.0129993 6.57172
4.51492 0.0248155 6.06966
4.41193 0.144623 6.51444
4.31778 0.0166886 6.14929
4.23108 0.0763828 8.05132
4.15089 0.124674 6.23333

26
Scripts_20161126/energylist_p_skew1.txt

@ -0,0 +1,26 @@
12.6088 0.0727608 0.000283934
10.5936 0.0572971 0.000159944
9.36031 0.0468522 0.000165883
8.51336 0.043189 0.000126012
7.88605 0.0355665 0.000104809
7.39682 0.0260337 0.000101641
7.00082 0.0184117 0.000118286
6.67084 0.0102188 0.000140931
6.39059 0.00442483 0.000122168
6.14881 0.00373327 0.000137908
5.93691 0.00288418 0.000134949
5.74999 0.000894669 0.00014388
5.58275 -0.00299652 0.000142959
5.43216 -0.00177812 0.000150106
5.29477 -0.000247082 0.000142952
5.16875 -0.00814118 0.000152731
5.05214 -0.0141199 0.00016785
4.94396 -0.016307 0.000167286
4.84371 -0.0150386 0.000176112
4.7504 -0.0143416 0.000173907
4.62797 -0.0133818 0.000185495
4.51492 -0.0159281 0.00019147
4.41193 -0.0174882 0.000190264
4.31778 -0.0179604 0.000199685
4.23108 -0.0148217 0.000189875
4.15089 -0.0078541 0.000195279

123
Scripts_20161126/figs/beamenergyfile_int_c.C

@ -0,0 +1,123 @@
void beamenergyfile_int_c()
{
//=========Macro generated from canvas: c1/c1
//========= (Tue Dec 5 12:03:42 2017) by ROOT version6.06/02
TCanvas *c1 = new TCanvas("c1", "c1",10,71,700,500);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
c1->Range(-9.855094,-1.21519,60.53843,6.379747);
c1->SetFillColor(0);
c1->SetBorderMode(0);
c1->SetBorderSize(2);
c1->SetTickx(1);
c1->SetTicky(1);
c1->SetLeftMargin(0.14);
c1->SetRightMargin(0.08);
c1->SetTopMargin(0.05);
c1->SetBottomMargin(0.16);
c1->SetFrameLineWidth(2);
c1->SetFrameBorderMode(0);
c1->SetFrameLineWidth(2);
c1->SetFrameBorderMode(0);
Double_t Graph0_fx1001[9] = {
1.99418,
2.99221,
4.99357,
8.00451,
9.96037,
14.9624,
19.9591,
29.9598,
50.0967};
Double_t Graph0_fy1001[9] = {
0.209056,
0.321651,
0.538085,
0.863684,
1.08222,
1.62381,
2.1691,
3.2634,
5.44883};
Double_t Graph0_fex1001[9] = {
0,
0,
0,
0,
0,
0,
0,
0,
0};
Double_t Graph0_fey1001[9] = {
0.000432816,
0.000558112,
0.000941916,
0.00144775,
0.00311746,
0.00313547,
0.00429978,
0.00679122,
0.00971554};
TGraphErrors *gre = new TGraphErrors(9,Graph0_fx1001,Graph0_fy1001,Graph0_fex1001,Graph0_fey1001);
gre->SetName("Graph0");
gre->SetTitle("Carbon Ions");
gre->SetFillColor(1);
gre->SetLineWidth(2);
gre->SetMarkerStyle(22);
TH1F *Graph_Graph1001 = new TH1F("Graph_Graph1001","Carbon Ions",100,0,54.90695);
Graph_Graph1001->SetMinimum(0);
Graph_Graph1001->SetMaximum(6);
Graph_Graph1001->SetDirectory(0);
Graph_Graph1001->SetStats(0);
Graph_Graph1001->SetLineWidth(2);
Graph_Graph1001->SetMarkerStyle(21);
Graph_Graph1001->GetXaxis()->SetTitle("Intensity / 10^{6}s^{-1}");
Graph_Graph1001->GetXaxis()->SetNdivisions(505);
Graph_Graph1001->GetXaxis()->SetLabelFont(22);
Graph_Graph1001->GetXaxis()->SetLabelOffset(0.015);
Graph_Graph1001->GetXaxis()->SetLabelSize(0.05);
Graph_Graph1001->GetXaxis()->SetTitleSize(0.06);
Graph_Graph1001->GetXaxis()->SetTitleFont(22);
Graph_Graph1001->GetYaxis()->SetTitle("#bar{A}_{BPM} / 10^{3} a.u.");
Graph_Graph1001->GetYaxis()->SetLabelFont(22);
Graph_Graph1001->GetYaxis()->SetLabelSize(0.05);
Graph_Graph1001->GetYaxis()->SetTitleSize(0.06);
Graph_Graph1001->GetYaxis()->SetTitleFont(22);
Graph_Graph1001->GetZaxis()->SetLabelFont(22);
Graph_Graph1001->GetZaxis()->SetLabelSize(0.05);
Graph_Graph1001->GetZaxis()->SetTitleSize(0.06);
Graph_Graph1001->GetZaxis()->SetTitleFont(22);
gre->SetHistogram(Graph_Graph1001);
TF1 *pol11002 = new TF1("pol1","pol1",0,54.90695);
pol11002->SetFillStyle(0);
pol11002->SetMarkerStyle(21);
pol11002->SetLineWidth(2);
pol11002->SetChisquare(32.73371);
pol11002->SetNDF(7);
pol11002->GetXaxis()->SetNdivisions(505);
pol11002->GetXaxis()->SetLabelFont(22);
pol11002->GetXaxis()->SetLabelOffset(0.015);
pol11002->GetXaxis()->SetLabelSize(0.05);
pol11002->GetXaxis()->SetTitleSize(0.06);
pol11002->GetXaxis()->SetTitleFont(22);
pol11002->GetYaxis()->SetLabelFont(22);
pol11002->GetYaxis()->SetLabelSize(0.05);
pol11002->GetYaxis()->SetTitleSize(0.06);
pol11002->GetYaxis()->SetTitleFont(22);
pol11002->SetParameter(0,-0.007111445);
pol11002->SetParError(0,0.0004586831);
pol11002->SetParLimits(0,0,0);
pol11002->SetParameter(1,0.1090771);
pol11002->SetParError(1,0.0001024792);
pol11002->SetParLimits(1,0,0);
gre->GetListOfFunctions()->Add(pol11002);
gre->Draw("ap");
c1->Modified();
c1->cd();
c1->SetSelected(c1);
}

BIN
Scripts_20161126/figs/beamenergyfile_int_c.pdf

Binary file not shown.

BIN
Scripts_20161126/figs/beamenergyfile_int_c.png

Binary file not shown.

After

Width: 698  |  Height: 473  |  Size: 8.5 KiB

127
Scripts_20161126/figs/beamenergyfile_int_p.C

@ -0,0 +1,127 @@
void beamenergyfile_int_p()
{
//=========Macro generated from canvas: c1_n2/c1_n2
//========= (Tue Dec 5 12:03:43 2017) by ROOT version6.06/02
TCanvas *c1_n2 = new TCanvas("c1_n2", "c1_n2",10,71,700,500);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
c1_n2->Range(-616.6917,-4.050633,3788.249,21.26582);
c1_n2->SetFillColor(0);
c1_n2->SetBorderMode(0);
c1_n2->SetBorderSize(2);
c1_n2->SetTickx(1);
c1_n2->SetTicky(1);
c1_n2->SetLeftMargin(0.14);
c1_n2->SetRightMargin(0.08);
c1_n2->SetTopMargin(0.05);
c1_n2->SetBottomMargin(0.16);
c1_n2->SetFrameLineWidth(2);
c1_n2->SetFrameBorderMode(0);
c1_n2->SetFrameLineWidth(2);
c1_n2->SetFrameBorderMode(0);
Double_t Graph0_fx1003[10] = {
77.5122,
116.351,
193.951,
310.193,
387.817,
581.737,
776.317,
1164.85,
1948.34,
3130.55};
Double_t Graph0_fy1003[10] = {
0.429555,
0.643733,
1.0764,
1.72565,
2.16159,
3.24754,
4.33832,
6.52111,
10.9109,
17.5223};
Double_t Graph0_fex1003[10] = {
0,
0,
0,
0,
0,
0,
0,
0,
0,
0};
Double_t Graph0_fey1003[10] = {
0.000673582,
0.000994535,
0.00168363,
0.00264345,
0.0034271,
0.00536572,
0.00688484,
0.00997276,
0.015779,
0.0260387};
TGraphErrors *gre = new TGraphErrors(10,Graph0_fx1003,Graph0_fy1003,Graph0_fex1003,Graph0_fey1003);
gre->SetName("Graph0");
gre->SetTitle("Protons");
gre->SetFillColor(1);
gre->SetLineWidth(2);
gre->SetMarkerStyle(20);
TH1F *Graph_Graph1003 = new TH1F("Graph_Graph1003","Protons",100,0,3435.854);
Graph_Graph1003->SetMinimum(0);
Graph_Graph1003->SetMaximum(20);
Graph_Graph1003->SetDirectory(0);
Graph_Graph1003->SetStats(0);
Graph_Graph1003->SetLineWidth(2);
Graph_Graph1003->SetMarkerStyle(21);
Graph_Graph1003->GetXaxis()->SetTitle("Intensity / 10^{6}s^{-1}");
Graph_Graph1003->GetXaxis()->SetNdivisions(505);
Graph_Graph1003->GetXaxis()->SetLabelFont(22);
Graph_Graph1003->GetXaxis()->SetLabelOffset(0.015);
Graph_Graph1003->GetXaxis()->SetLabelSize(0.05);
Graph_Graph1003->GetXaxis()->SetTitleSize(0.06);
Graph_Graph1003->GetXaxis()->SetTitleFont(22);
Graph_Graph1003->GetYaxis()->SetTitle("#bar{A}_{BPM} / 10^{3} a.u.");
Graph_Graph1003->GetYaxis()->SetLabelFont(22);
Graph_Graph1003->GetYaxis()->SetLabelSize(0.05);
Graph_Graph1003->GetYaxis()->SetTitleSize(0.06);
Graph_Graph1003->GetYaxis()->SetTitleFont(22);
Graph_Graph1003->GetZaxis()->SetLabelFont(22);
Graph_Graph1003->GetZaxis()->SetLabelSize(0.05);
Graph_Graph1003->GetZaxis()->SetTitleSize(0.06);
Graph_Graph1003->GetZaxis()->SetTitleFont(22);
gre->SetHistogram(Graph_Graph1003);
TF1 *pol11004 = new TF1("pol1","pol1",0,3435.854);
pol11004->SetFillStyle(0);
pol11004->SetMarkerStyle(21);
pol11004->SetLineWidth(2);
pol11004->SetChisquare(16.16133);
pol11004->SetNDF(8);
pol11004->GetXaxis()->SetNdivisions(505);
pol11004->GetXaxis()->SetLabelFont(22);
pol11004->GetXaxis()->SetLabelOffset(0.015);
pol11004->GetXaxis()->SetLabelSize(0.05);
pol11004->GetXaxis()->SetTitleSize(0.06);
pol11004->GetXaxis()->SetTitleFont(22);
pol11004->GetYaxis()->SetLabelFont(22);
pol11004->GetYaxis()->SetLabelSize(0.05);
pol11004->GetYaxis()->SetTitleSize(0.06);
pol11004->GetYaxis()->SetTitleFont(22);
pol11004->SetParameter(0,-0.005407782);
pol11004->SetParError(0,0.0006990141);
pol11004->SetParLimits(0,0,0);
pol11004->SetParameter(1,0.005593003);
pol11004->SetParError(1,3.747116e-06);
pol11004->SetParLimits(1,0,0);
gre->GetListOfFunctions()->Add(pol11004);
gre->Draw("ap");
c1_n2->Modified();
c1_n2->cd();
c1_n2->SetSelected(c1_n2);
}

BIN
Scripts_20161126/figs/beamenergyfile_int_p.pdf

Binary file not shown.

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save