CalcRes.C 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. #include <iostream>
  2. #include <TMath.h>
  3. #include <TH1D.h>
  4. #include <TProfile.h>
  5. #include <TFile.h>
  6. #include <Math/SpecFuncMathMore.h>
  7. // Add libMathMore library for GetResZDC() & GetChiZDC()
  8. R__LOAD_LIBRARY(libMathMore.so);
  9. const int fNharmonics = 2;
  10. Double_t GetRes(Double_t _chi)
  11. {
  12. Double_t con = TMath::Sqrt(TMath::Pi() / 2) / 2;
  13. Double_t arg = _chi * _chi / 4.;
  14. Double_t res = con * _chi * exp(-arg) * (TMath::BesselI0(arg) + TMath::BesselI1(arg));
  15. return res;
  16. }
  17. Double_t GetResZDC(Double_t _chi, Int_t _harm)
  18. {
  19. Double_t con = TMath::Sqrt(TMath::Pi() / 2) / 2;
  20. Double_t arg = _chi * _chi / 4.;
  21. if (_harm == 1)
  22. {
  23. Double_t res = con * _chi * exp(-arg) * (TMath::BesselI0(arg) + TMath::BesselI1(arg));
  24. return res;
  25. }
  26. else
  27. {
  28. if (_harm == 2)
  29. {
  30. Double_t res = con * _chi * exp(-arg) * (ROOT::Math::cyl_bessel_i(0.5, arg) + ROOT::Math::cyl_bessel_i(1.5, arg));
  31. return res;
  32. }
  33. else
  34. {
  35. std::cout << "Wrong harmonic in resolution extrapolation! " << std::endl;
  36. return -999.;
  37. }
  38. }
  39. }
  40. Double_t GetChi(Double_t _res, Int_t accuracy = 50)
  41. {
  42. Double_t chi = 2.0;
  43. Double_t delta = 1.0;
  44. for (int i = 0; i < accuracy; i++)
  45. {
  46. if (GetRes(chi) < _res)
  47. {
  48. chi = chi + delta;
  49. }
  50. else
  51. {
  52. chi = chi - delta;
  53. }
  54. delta = delta / 2.;
  55. }
  56. return chi;
  57. }
  58. Double_t GetChiZDC(Double_t _res, Int_t _harm, Int_t accuracy = 50)
  59. {
  60. Double_t chi = 2.0;
  61. Double_t delta = 1.0;
  62. for (int i = 0; i < accuracy; i++)
  63. {
  64. if (GetResZDC(chi, _harm) < _res)
  65. {
  66. chi = chi + delta;
  67. }
  68. else
  69. {
  70. chi = chi - delta;
  71. }
  72. delta = delta / 2.;
  73. }
  74. return chi;
  75. }
  76. void CalcRes(const Char_t *resFileName = "./oResolutionTest.root", const Char_t *resFitName = "./oResFitTest.root")
  77. {
  78. //const std::map<int,int> CentBins [] = {{1,75},{2,65},{3,55},{4,45},{5,35},{6,25},{7,15},{8,7.5},{9,2.5}};
  79. const int NGaps = 1;
  80. TProfile *pRes2Sqr[NGaps];
  81. TProfile *pRes3Sqr[NGaps];
  82. TProfile *pResSP2Sqr[NGaps];
  83. TProfile *pResSP3Sqr[NGaps];
  84. TProfile *pNormSP2Sqr[NGaps];
  85. TProfile *pNormSP3Sqr[NGaps];
  86. TProfile *pResBBC[fNharmonics + 1];
  87. TProfile *pResZDC[fNharmonics + 1];
  88. TProfile *p_res2_EP_3sub_AB;
  89. TProfile *p_res2_EP_3sub_AC;
  90. TProfile *p_res2_EP_3sub_BC;
  91. TProfile *p_res2_EP_3sub1_AB;
  92. TProfile *p_res2_EP_3sub1_AC;
  93. TProfile *p_res2_EP_3sub1_BC;
  94. TH1D *hResBBCHalf[fNharmonics + 1];
  95. TH1D *hResBBCFULL[fNharmonics + 1];
  96. TH1D *hResZDCHalf[fNharmonics + 1];
  97. TH1D *hResZDCFULL[fNharmonics + 1];
  98. TH1D *hRes2Half[NGaps];
  99. TH1D *hRes3Half[NGaps];
  100. TH1D *hRes2FULL[NGaps];
  101. TH1D *hRes3FULL[NGaps];
  102. TH1D *hRes2Chi[NGaps];
  103. TH1D *hRes3Chi[NGaps];
  104. TH1D *hResSP2Half[NGaps];
  105. TH1D *hResSP3Half[NGaps];
  106. TH1D *hResSP2FULL[NGaps];
  107. TH1D *hResSP3FULL[NGaps];
  108. TH1D *hResSP2Chi[NGaps];
  109. TH1D *hResSP3Chi[NGaps];
  110. TH1D *hResEP3subTPC;
  111. TH1D *hResEP3subBBCEast;
  112. TH1D *hResEP3subBBCWest;
  113. TH1D *hResEP3sub1BBC;
  114. TH1D *hResEP3sub1TPCEast;
  115. TH1D *hResEP3sub1TPCWest;
  116. TFile *fi = new TFile(resFileName, "read");
  117. fi->cd();
  118. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  119. {
  120. pResBBC[iHarm] = (TProfile *)fi->Get(Form("p_resBBC_EP%i", iHarm));
  121. hResBBCHalf[iHarm] = new TH1D(Form("hResBBCHalf%i", iHarm), Form("hResBBCHalf%i", iHarm), 16, -0.5, 15.5);
  122. hResBBCFULL[iHarm] = new TH1D(Form("hResBBCFULL%i", iHarm), Form("hResBBCFULL%i", iHarm), 16, -0.5, 15.5);
  123. pResZDC[iHarm] = (TProfile *)fi->Get(Form("p_resZDC_EP%i", iHarm));
  124. hResZDCHalf[iHarm] = new TH1D(Form("hResZDCHalf%i", iHarm), Form("hResZDCHalf%i", iHarm), 16, -0.5, 15.5);
  125. hResZDCFULL[iHarm] = new TH1D(Form("hResZDCFULL%i", iHarm), Form("hResZDCFULL%i", iHarm), 16, -0.5, 15.5);
  126. }
  127. p_res2_EP_3sub_AB = (TProfile *)fi->Get("p_res2_EP_3sub_AB");
  128. p_res2_EP_3sub_AC = (TProfile *)fi->Get("p_res2_EP_3sub_AC");
  129. p_res2_EP_3sub_BC = (TProfile *)fi->Get("p_res2_EP_3sub_BC");
  130. p_res2_EP_3sub1_AB = (TProfile *)fi->Get("p_res2_EP_3sub1_AB");
  131. p_res2_EP_3sub1_AC = (TProfile *)fi->Get("p_res2_EP_3sub1_AC");
  132. p_res2_EP_3sub1_BC = (TProfile *)fi->Get("p_res2_EP_3sub1_BC");
  133. hResEP3subTPC = new TH1D("hResEP3subTPC", "hResEP3subTPC", 16, -0.5, 15.5);
  134. hResEP3subBBCEast = new TH1D("hResEP3subBBCEast", "hResEP3subBBCEast", 16, -0.5, 15.5);
  135. hResEP3subBBCWest = new TH1D("hResEP3subBBCWest", "hResEP3subBBCWest", 16, -0.5, 15.5);
  136. hResEP3sub1BBC = new TH1D("hResEP3sub1BBC", "hResEP3sub1BBC", 16, -0.5, 15.5);
  137. hResEP3sub1TPCEast = new TH1D("hResEP3sub1TPCEast", "hResEP3sub1TPCEast", 16, -0.5, 15.5);
  138. hResEP3sub1TPCWest = new TH1D("hResEP3sub1TPCWest", "hResEP3sub1TPCWest", 16, -0.5, 15.5);
  139. for (int i = 0; i < NGaps; i++)
  140. {
  141. pRes2Sqr[i] = (TProfile *)fi->Get(Form("p_res2_EP_gap%i", i));
  142. pRes3Sqr[i] = (TProfile *)fi->Get(Form("p_res3_EP_gap%i", i));
  143. pResSP2Sqr[i] = (TProfile *)fi->Get(Form("p_res2_SP_gap%i", i));
  144. pResSP3Sqr[i] = (TProfile *)fi->Get(Form("p_res3_SP_gap%i", i));
  145. pNormSP2Sqr[i] = (TProfile *)fi->Get(Form("p_res2_SP_Norm_gap%i", i));
  146. pNormSP3Sqr[i] = (TProfile *)fi->Get(Form("p_res3_SP_Norm_gap%i", i));
  147. hRes2Half[i] = new TH1D(Form("hRes2Half%i", i), Form("hRes2Half%i", i), 16, -0.5, 15.5);
  148. hRes3Half[i] = new TH1D(Form("hRes3Half%i", i), Form("hRes3Half%i", i), 16, -0.5, 15.5);
  149. hRes2FULL[i] = new TH1D(Form("hRes2FULL%i", i), Form("hRes2FULL%i", i), 16, -0.5, 15.5);
  150. hRes3FULL[i] = new TH1D(Form("hRes3FULL%i", i), Form("hRes3FULL%i", i), 16, -0.5, 15.5);
  151. hRes2Chi[i] = new TH1D(Form("hRes2Chi%i", i), Form("hRes2Chi%i", i), 16, -0.5, 15.5);
  152. hRes3Chi[i] = new TH1D(Form("hRes3Chi%i", i), Form("hRes3Chi%i", i), 16, -0.5, 15.5);
  153. hResSP2Half[i] = new TH1D(Form("hResSP2Half%i", i), Form("hResSP2Half%i", i), 16, -0.5, 15.5);
  154. hResSP3Half[i] = new TH1D(Form("hResSP3Half%i", i), Form("hResSP3Half%i", i), 16, -0.5, 15.5);
  155. hResSP2FULL[i] = new TH1D(Form("hResSP2FULL%i", i), Form("hResSP2FULL%i", i), 16, -0.5, 15.5);
  156. hResSP3FULL[i] = new TH1D(Form("hResSP3FULL%i", i), Form("hResSP3FULL%i", i), 16, -0.5, 15.5);
  157. hResSP2Chi[i] = new TH1D(Form("hResSP2Chi%i", i), Form("hResSP2Chi%i", i), 16, -0.5, 15.5);
  158. hResSP3Chi[i] = new TH1D(Form("hResSP3Chi%i", i), Form("hResSP3Chi%i", i), 16, -0.5, 15.5);
  159. }
  160. int bin = 0;
  161. Double_t AB, AC, BC, eAB, eAC, eBC;
  162. for (int ibin = 1; ibin <= p_res2_EP_3sub_AB->GetNbinsX(); ibin++)
  163. {
  164. AB = p_res2_EP_3sub_AB->GetBinContent(ibin);
  165. AC = p_res2_EP_3sub_AC->GetBinContent(ibin);
  166. BC = p_res2_EP_3sub_BC->GetBinContent(ibin);
  167. eAB = p_res2_EP_3sub_AB->GetBinError(ibin);
  168. eAC = p_res2_EP_3sub_AC->GetBinError(ibin);
  169. eBC = p_res2_EP_3sub_BC->GetBinError(ibin);
  170. // std::cout << "bin " << ibin << "AB: " << AB << " AC: " << AC << " BC: " << BC << "\t| ResSqr: " << (AB*AC/BC) << "\t| Res: " << TMath::Sqrt(AB*AC/BC) << std::endl;
  171. if (AB * AC / BC >= 0)
  172. {
  173. hResEP3subTPC->SetBinContent(ibin, TMath::Sqrt(AB * AC / BC));
  174. hResEP3subTPC->SetBinError(ibin, 0.5 * TMath::Sqrt(AC * eAB * eAB / (BC * AB) +
  175. AB * eAC * eAC / (BC * AC) +
  176. AB * AC * eBC * eBC / (BC * BC * BC)));
  177. }
  178. if (AB * BC / AC >= 0)
  179. {
  180. hResEP3subBBCEast->SetBinContent(ibin, TMath::Sqrt(AB * BC / AC));
  181. hResEP3subBBCEast->SetBinError(ibin, 0.5 * TMath::Sqrt(BC * eAB * eAB / (AC * AB) +
  182. AB * eBC * eBC / (AC * BC) +
  183. AB * BC * eAC * eAC / (AC * AC * AC)));
  184. }
  185. if (AC * BC / AB >= 0)
  186. {
  187. hResEP3subBBCWest->SetBinContent(ibin, TMath::Sqrt(AC * BC / AB));
  188. hResEP3subBBCWest->SetBinError(ibin, 0.5 * TMath::Sqrt(BC * eAC * eAC / (AB * AC) +
  189. AC * eBC * eBC / (AB * BC) +
  190. AC * BC * eAB * eAB / (AB * AB * AB)));
  191. }
  192. }
  193. for (int ibin = 1; ibin <= p_res2_EP_3sub1_AB->GetNbinsX(); ibin++)
  194. {
  195. AB = p_res2_EP_3sub1_AB->GetBinContent(ibin);
  196. AC = p_res2_EP_3sub1_AC->GetBinContent(ibin);
  197. BC = p_res2_EP_3sub1_BC->GetBinContent(ibin);
  198. eAB = p_res2_EP_3sub1_AB->GetBinError(ibin);
  199. eAC = p_res2_EP_3sub1_AC->GetBinError(ibin);
  200. eBC = p_res2_EP_3sub1_BC->GetBinError(ibin);
  201. // std::cout << "bin " << ibin << "AB: " << AB << " AC: " << AC << " BC: " << BC << "\t| ResSqr: " << (AB*AC/BC) << "\t| Res: " << TMath::Sqrt(AB*AC/BC) << std::endl;
  202. if (AB * AC / BC >= 0)
  203. {
  204. hResEP3sub1BBC->SetBinContent(ibin, TMath::Sqrt(AB * AC / BC));
  205. hResEP3sub1BBC->SetBinError(ibin, 0.5 * TMath::Sqrt(AC * eAB * eAB / (BC * AB) +
  206. AB * eAC * eAC / (BC * AC) +
  207. AB * AC * eBC * eBC / (BC * BC * BC)));
  208. }
  209. if (AB * BC / AC >= 0)
  210. {
  211. hResEP3sub1TPCEast->SetBinContent(ibin, TMath::Sqrt(AB * BC / AC));
  212. hResEP3sub1TPCEast->SetBinError(ibin, 0.5 * TMath::Sqrt(BC * eAB * eAB / (AC * AB) +
  213. AB * eBC * eBC / (AC * BC) +
  214. AB * BC * eAC * eAC / (AC * AC * AC)));
  215. }
  216. if (AC * BC / AB >= 0)
  217. {
  218. hResEP3sub1TPCWest->SetBinContent(ibin, TMath::Sqrt(AC * BC / AB));
  219. hResEP3sub1TPCWest->SetBinError(ibin, 0.5 * TMath::Sqrt(BC * eAC * eAC / (AB * AC) +
  220. AC * eBC * eBC / (AB * BC) +
  221. AC * BC * eAB * eAB / (AB * AB * AB)));
  222. }
  223. }
  224. //Fill ResHalf
  225. for (int i = 0; i < NGaps; i++)
  226. {
  227. for (int ibin = 1; ibin <= pRes2Sqr[i]->GetNbinsX(); ibin++)
  228. {
  229. hRes2Half[i]->SetBinContent(ibin, TMath::Sqrt(pRes2Sqr[i]->GetBinContent(ibin)));
  230. hRes2Half[i]->SetBinError(ibin, (Double_t)(0.5 * pRes2Sqr[i]->GetBinError(ibin) / TMath::Sqrt(pRes2Sqr[i]->GetBinContent(ibin))));
  231. hRes3Half[i]->SetBinContent(ibin, TMath::Sqrt(pRes3Sqr[i]->GetBinContent(ibin)));
  232. hRes3Half[i]->SetBinError(ibin, (Double_t)(0.5 * pRes3Sqr[i]->GetBinError(ibin) / TMath::Sqrt(pRes3Sqr[i]->GetBinContent(ibin))));
  233. }
  234. for (int ibin = 1; ibin <= pResSP2Sqr[i]->GetNbinsX(); ibin++)
  235. {
  236. if (pNormSP2Sqr[i]->GetBinContent(ibin) != 0 && pResSP2Sqr[i]->GetBinContent(ibin) > 0)
  237. {
  238. hResSP2Half[i]->SetBinContent(ibin, TMath::Sqrt(pResSP2Sqr[i]->GetBinContent(ibin) / pNormSP2Sqr[i]->GetBinContent(ibin)));
  239. hResSP2Half[i]->SetBinError(ibin, (Double_t)(0.5 * TMath::Sqrt(
  240. TMath::Power(pResSP2Sqr[i]->GetBinError(ibin), 2) / (pResSP2Sqr[i]->GetBinContent(ibin) * pNormSP2Sqr[i]->GetBinContent(ibin)) +
  241. pResSP2Sqr[i]->GetBinContent(ibin) * TMath::Power(pNormSP2Sqr[i]->GetBinError(ibin), 2) / TMath::Power(pNormSP2Sqr[i]->GetBinContent(ibin), 3))));
  242. }
  243. if (pNormSP3Sqr[i]->GetBinContent(ibin) != 0 && pResSP3Sqr[i]->GetBinContent(ibin) > 0)
  244. {
  245. hResSP3Half[i]->SetBinContent(ibin, TMath::Sqrt(pResSP3Sqr[i]->GetBinContent(ibin) / pNormSP3Sqr[i]->GetBinContent(ibin)));
  246. hResSP3Half[i]->SetBinError(ibin, (Double_t)(0.5 * TMath::Sqrt(
  247. TMath::Power(pResSP3Sqr[i]->GetBinError(ibin), 2) / (pResSP3Sqr[i]->GetBinContent(ibin) * pNormSP3Sqr[i]->GetBinContent(ibin)) +
  248. pResSP3Sqr[i]->GetBinContent(ibin) * TMath::Power(pNormSP3Sqr[i]->GetBinError(ibin), 2) / TMath::Power(pNormSP3Sqr[i]->GetBinContent(ibin), 3))));
  249. }
  250. }
  251. }
  252. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  253. {
  254. for (int ibin = 1; ibin <= pResBBC[iHarm]->GetNbinsX(); ibin++)
  255. {
  256. hResBBCHalf[iHarm]->SetBinContent(ibin, TMath::Sqrt(TMath::Abs(pResBBC[iHarm]->GetBinContent(ibin))));
  257. hResBBCHalf[iHarm]->SetBinError(ibin, 0.5 * pResBBC[iHarm]->GetBinError(ibin) / TMath::Sqrt(TMath::Abs(pResBBC[iHarm]->GetBinContent(ibin))));
  258. }
  259. for (int ibin = 1; ibin <= pResZDC[iHarm]->GetNbinsX(); ibin++)
  260. {
  261. if (iHarm == 0)
  262. {
  263. hResZDCHalf[iHarm]->SetBinContent(ibin, TMath::Sqrt(TMath::Abs(pResZDC[iHarm]->GetBinContent(ibin))));
  264. hResZDCHalf[iHarm]->SetBinError(ibin, 0.5 * pResZDC[iHarm]->GetBinError(ibin) / TMath::Sqrt(TMath::Abs(pResZDC[iHarm]->GetBinContent(ibin))));
  265. }
  266. }
  267. }
  268. Double_t chi = 0.;
  269. //Fill Chi & FULL
  270. for (int i = 0; i < NGaps; i++)
  271. {
  272. for (int ibin = 1; ibin <= pRes2Sqr[i]->GetNbinsX(); ibin++)
  273. {
  274. chi = GetChi(hRes2Half[i]->GetBinContent(ibin));
  275. hRes2Chi[i]->SetBinContent(ibin, GetRes(chi));
  276. hRes2Chi[i]->SetBinError(ibin, hRes2Half[i]->GetBinError(ibin));
  277. hRes2FULL[i]->SetBinContent(ibin, GetRes(TMath::Sqrt(2) * chi));
  278. hRes2FULL[i]->SetBinError(ibin, TMath::Sqrt(2) * hRes2Half[i]->GetBinError(ibin));
  279. chi = GetChi(hRes3Half[i]->GetBinContent(ibin));
  280. hRes3Chi[i]->SetBinContent(ibin, GetRes(chi));
  281. hRes3Chi[i]->SetBinError(ibin, hRes3Half[i]->GetBinError(ibin));
  282. hRes3FULL[i]->SetBinContent(ibin, GetRes(TMath::Sqrt(2) * chi));
  283. hRes3FULL[i]->SetBinError(ibin, TMath::Sqrt(2) * hRes3Half[i]->GetBinError(ibin));
  284. }
  285. for (int ibin = 1; ibin <= pResSP2Sqr[i]->GetNbinsX(); ibin++)
  286. {
  287. chi = GetChi(hResSP2Half[i]->GetBinContent(ibin));
  288. hResSP2Chi[i]->SetBinContent(ibin, GetRes(chi));
  289. hResSP2Chi[i]->SetBinError(ibin, hResSP2Half[i]->GetBinError(ibin));
  290. hResSP2FULL[i]->SetBinContent(ibin, GetRes(TMath::Sqrt(2) * chi));
  291. hResSP2FULL[i]->SetBinError(ibin, TMath::Sqrt(2) * hResSP2Half[i]->GetBinError(ibin));
  292. chi = GetChi(hResSP3Half[i]->GetBinContent(ibin));
  293. hResSP3Chi[i]->SetBinContent(ibin, GetRes(chi));
  294. hResSP3Chi[i]->SetBinError(ibin, hResSP3Half[i]->GetBinError(ibin));
  295. hResSP3FULL[i]->SetBinContent(ibin, GetRes(TMath::Sqrt(2) * chi));
  296. hResSP3FULL[i]->SetBinError(ibin, TMath::Sqrt(2) * hResSP3Half[i]->GetBinError(ibin));
  297. }
  298. }
  299. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  300. {
  301. for (int ibin = 1; ibin <= pResBBC[iHarm]->GetNbinsX(); ibin++)
  302. {
  303. chi = GetChi(hResBBCHalf[iHarm]->GetBinContent(ibin));
  304. hResBBCFULL[iHarm]->SetBinContent(ibin, GetRes(TMath::Sqrt(2) * chi));
  305. hResBBCFULL[iHarm]->SetBinError(ibin, TMath::Sqrt(2) * hResBBCHalf[iHarm]->GetBinError(ibin));
  306. }
  307. }
  308. for (int ibin = 1; ibin <= hResZDCHalf[0]->GetNbinsX(); ibin++)
  309. {
  310. chi = GetChiZDC(hResZDCHalf[0]->GetBinContent(ibin), 1);
  311. std::cout << "chi_1[" << ibin << "] = " << chi;
  312. hResZDCFULL[0]->SetBinContent(ibin, GetResZDC(TMath::Sqrt(2) * chi, 1));
  313. hResZDCFULL[0]->SetBinError(ibin, TMath::Sqrt(2) * hResZDCHalf[0]->GetBinError(ibin));
  314. std::cout << "\t Res_1[" << ibin << "] = " << GetResZDC(TMath::Sqrt(2) * chi, 1) << std::endl;
  315. }
  316. for (int ibin = 1; ibin <= hResZDCHalf[0]->GetNbinsX(); ibin++)
  317. {
  318. chi = GetChiZDC(hResZDCHalf[0]->GetBinContent(ibin), 1);
  319. std::cout << "chi_2[" << ibin << "] = " << chi;
  320. hResZDCFULL[1]->SetBinContent(ibin, GetResZDC(TMath::Sqrt(2) * chi, 2));
  321. hResZDCFULL[1]->SetBinError(ibin, GetResZDC(TMath::Sqrt(2) * chi, 2)/ hResZDCHalf[0]->GetBinContent(ibin) * hResZDCHalf[0]->GetBinError(ibin));
  322. std::cout << "\t Res_2[" << ibin << "] = " << GetResZDC(TMath::Sqrt(2) * chi, 2) << std::endl;
  323. hResZDCHalf[1]->SetBinContent(ibin, GetResZDC(chi, 2));
  324. hResZDCHalf[1]->SetBinError(ibin, GetResZDC(chi, 2)/ hResZDCHalf[0]->GetBinContent(ibin) * hResZDCHalf[0]->GetBinError(ibin));
  325. }
  326. std::cout << "chi_1[] = chi_2[]. If it isn't the case, check the code." << std::endl;
  327. TFile *fo = new TFile(resFitName, "recreate");
  328. fo->cd();
  329. for (int i = 0; i < NGaps; i++)
  330. {
  331. hRes2Half[i]->Write();
  332. hRes2Chi[i]->Write();
  333. hRes2FULL[i]->Write();
  334. }
  335. for (int i = 0; i < NGaps; i++)
  336. {
  337. hRes3Half[i]->Write();
  338. hRes3Chi[i]->Write();
  339. hRes3FULL[i]->Write();
  340. }
  341. for (int i = 0; i < NGaps; i++)
  342. {
  343. hResSP2Half[i]->Write();
  344. hResSP2Chi[i]->Write();
  345. hResSP2FULL[i]->Write();
  346. }
  347. for (int i = 0; i < NGaps; i++)
  348. {
  349. hResSP3Half[i]->Write();
  350. hResSP3Chi[i]->Write();
  351. hResSP3FULL[i]->Write();
  352. }
  353. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  354. {
  355. hResBBCHalf[iHarm]->Write();
  356. hResBBCFULL[iHarm]->Write();
  357. }
  358. for (int iHarm = 0; iHarm < fNharmonics + 1; iHarm++)
  359. {
  360. hResZDCHalf[iHarm]->Write();
  361. hResZDCFULL[iHarm]->Write();
  362. }
  363. hResEP3subTPC->Write();
  364. hResEP3subBBCEast->Write();
  365. hResEP3subBBCWest->Write();
  366. hResEP3sub1BBC->Write();
  367. hResEP3sub1TPCEast->Write();
  368. hResEP3sub1TPCWest->Write();
  369. }