get_res.C 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. #include <cstdio>
  2. #include <TROOT.h>
  3. #include <TSystem.h>
  4. #include <TProfile.h>
  5. #include <TMath.h>
  6. #include <TFitResult.h>
  7. #include <TF1.h>
  8. #include <TFile.h>
  9. #include "utility.C"
  10. /*const int _N_HARM = 2;
  11. const int _N_METHOD = 2;
  12. const int _N_SORTS = 4;
  13. const float centralityBinsFlow[] = {10.,20.,40.,50};
  14. const int NcentralityBinsFlow = 3;
  15. const float centralityBinsRes[] = {0.,5.,10.,15.,20.,25.,30.,35.,40.,45.,50.,55.,60.,65.,70.,75.,80.,85.,90.,95.,100};
  16. const int NcentralityBinsRes = 20;
  17. const float ptBins[] = {0.,0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.};
  18. const int NptBins = 12;
  19. const float etaBins[] = {-1.5,-1.2,-1.,-0.8,-0.6,-0.4,-0.2,0.,0.2,0.4,0.6,0.8,1.,1.2,1.5};
  20. const int NetaBins = 14;
  21. const float rapidityBins[] = {-2., -1.8, -1.6, -1.4,-1.2,-1.,-0.8,-0.6,-0.4,-0.2,0.,0.2,0.4,0.6,0.8,1.,1.2,1.4,1.6,1.8,2.};
  22. const int NrapidityBins = 20;
  23. const TString sorts_of_particles[4] = {TString("all sorts") , TString("pions (#pi^{+})") , TString("protons (p)") , TString("kaons (K^{+})")};
  24. const TString methods_names[_N_METHOD] = {TString("TPC") , TString("FHCal")};*/
  25. using TMath::Sqrt;
  26. //R__ADD_LIBRARY_PATH("/lustre/nyx/hades/user/parfenov/mpd_new/real-flow") // if needed
  27. //R__LOAD_LIBRARY(MpdCalculator_C.so)
  28. //R__LOAD_LIBRARY(utility_C.so)
  29. void get_res(TString inFileName , TString outFileName)
  30. {
  31. //gSystem->Load("./utility_C.so");
  32. //gSystem->Load("./MpdCalculator_C.so");
  33. TFile *inFile = new TFile(inFileName.Data());
  34. TFile *outFile = new TFile(outFileName.Data(),"RECREATE");
  35. TProfile *p_Res2Psi_vs_b[_N_HARM][_N_HARM][_N_METHOD];
  36. TProfile *p_ResPsi_vs_b[_N_HARM][_N_HARM][_N_METHOD];
  37. TF1 *resolution_fit[_N_HARM][_N_HARM][_N_METHOD];
  38. //TH1F *h_pt_PID_efficiency_before[NetaBins];
  39. //TH1F *h_pt_PID_efficiency_after_sorts[NetaBins][_N_SORTS];
  40. //TH1F *h_pt_PID_eff[NetaBins][_N_SORTS];
  41. //TF1 *f_pt_PID_eff[NetaBins][_N_SORTS];
  42. TH1F *h_pt_reco_before[NcentralityBinsRes][_N_SORTS][NetaBins];
  43. TH1F *h_pt_true_before[NcentralityBinsRes][_N_SORTS][NetaBins];
  44. TH1F *h_pt_reco_after[NcentralityBinsRes][_N_SORTS][NetaBins];
  45. TH1F *h_pt_true_after[NcentralityBinsRes][_N_SORTS][NetaBins];
  46. TH1F *h_pt_eff_before[NcentralityBinsRes][_N_SORTS][NetaBins];
  47. TH1F *h_pt_eff_after[NcentralityBinsRes][_N_SORTS][NetaBins];
  48. TF1 *f_pt_eff_before[NcentralityBinsRes][_N_SORTS][NetaBins];
  49. TF1 *f_pt_eff_after[NcentralityBinsRes][_N_SORTS][NetaBins];
  50. TH1F *h_pt_reco_final[NcentralityBinsFlow][_N_SORTS][NetaBins];
  51. TH1F *h_pt_true_final[NcentralityBinsFlow][_N_SORTS][NetaBins];
  52. TH1F *h_pt_eff_after_final[NcentralityBinsFlow][_N_SORTS][NetaBins];
  53. TF1 *f_pt_eff_after_final[NcentralityBinsFlow][_N_SORTS][NetaBins];
  54. TH1F *h_eta_reco_before[NcentralityBinsRes][_N_SORTS][NptBins];
  55. TH1F *h_eta_true_before[NcentralityBinsRes][_N_SORTS][NptBins];
  56. TH1F *h_eta_reco_after[NcentralityBinsRes][_N_SORTS][NptBins];
  57. TH1F *h_eta_true_after[NcentralityBinsRes][_N_SORTS][NptBins];
  58. TH1F *h_eta_eff_before[NcentralityBinsRes][_N_SORTS][NptBins];
  59. TH1F *h_eta_eff_after[NcentralityBinsRes][_N_SORTS][NptBins];
  60. TF1 *f_eta_eff_before[NcentralityBinsRes][_N_SORTS][NptBins];
  61. TF1 *f_eta_eff_after[NcentralityBinsRes][_N_SORTS][NptBins];
  62. TH1F *h_eta_reco_final[NcentralityBinsFlow][_N_SORTS][NptBins];
  63. TH1F *h_eta_true_final[NcentralityBinsFlow][_N_SORTS][NptBins];
  64. TH1F *h_eta_eff_after_final[NcentralityBinsFlow][_N_SORTS][NptBins];
  65. TF1 *f_eta_eff_after_final[NcentralityBinsFlow][_N_SORTS][NptBins];
  66. char name[400];
  67. char title[400];
  68. //for (Int_t eta_bin=0; eta_bin<NetaBins; eta_bin++){
  69. //h_pt_PID_efficiency_before[eta_bin] = (TH1F*) inFile->Get(Form("h_pt_PID_efficiency_before%i",eta_bin));
  70. //for (int sort = 0; sort < _N_SORTS; ++sort){
  71. //sprintf(title,"p_{T} efficiency of PID cuts for %s, %.2f < #eta < %.2f ", sorts_of_particles[sort].Data(), etaBins[eta_bin], etaBins[eta_bin+1]);
  72. //h_pt_PID_efficiency_after_sorts[eta_bin][sort] = (TH1F*) inFile->Get(Form("h_pt_PID_efficiency_after_sorts%i%i",eta_bin,sort));
  73. //h_pt_PID_eff[eta_bin][sort] = new TH1F(Form("h_pt_PID_eff%i%i",eta_bin,sort),title,NptBins,ptBins); h_pt_PID_eff[eta_bin][sort] -> Sumw2();
  74. //f_pt_PID_eff[eta_bin][sort] = new TF1(Form("f_pt_PID_eff%i%i",eta_bin,sort),"pol8",0.2,2.);
  75. //}
  76. //}
  77. /*for (int centralityBin = 0; centralityBin < NcentralityBinsFlow; ++centralityBin)
  78. {
  79. for (int sort = 0; sort < _N_SORTS; ++sort)
  80. {
  81. for (int eta_bin=0;eta_bin<NetaBins;eta_bin++){
  82. sprintf(title,"p_{T}-efficiency after cuts for %s, %i ", sorts_of_particles[sort].Data(),centralityBin);
  83. h_pt_eff_after_final[centralityBin][sort][eta_bin] = new TH1F(Form("h_pt_eff_after_final%i%i%i",centralityBin,sort,eta_bin),title,100,0.,3.5);
  84. h_pt_eff_after_final[centralityBin][sort][eta_bin] -> Sumw2();
  85. f_pt_eff_after_final[centralityBin][sort][eta_bin] = new TF1(Form("f_pt_eff_after_final%i%i%i",centralityBin,sort,eta_bin),"pol8",0.2,2.);
  86. sprintf(title,"p_{T}^{reco} spectre after cuts for %s, %i ", sorts_of_particles[sort].Data(),centralityBin);
  87. h_pt_reco_final[centralityBin][sort][eta_bin] = new TH1F(Form("h_pt_reco_final%i%i%i",centralityBin,sort,eta_bin),title,100,0.,3.5);
  88. h_pt_reco_final[centralityBin][sort][eta_bin] -> Sumw2();
  89. sprintf(title,"p_{T}^{true} spectre after cuts for %s, %i ", sorts_of_particles[sort].Data(),centralityBin);
  90. h_pt_true_final[centralityBin][sort][eta_bin] = new TH1F(Form("h_pt_true_final%i%i%i",centralityBin,sort,eta_bin),title,100,0.,3.5);
  91. h_pt_true_final[centralityBin][sort][eta_bin] -> Sumw2();
  92. }
  93. }
  94. }
  95. for (int centralityBin = 0; centralityBin < NcentralityBinsRes; ++centralityBin)
  96. {
  97. for (int sort = 0; sort < _N_SORTS; ++sort)
  98. {
  99. for (int eta_bin=0;eta_bin<NetaBins;eta_bin++){
  100. h_pt_reco_before[centralityBin][sort][eta_bin] = (TH1F*) inFile->Get(Form("h_pt[%i][%i][%i]",centralityBin,eta_bin,sort));
  101. h_pt_true_before[centralityBin][sort][eta_bin] = (TH1F*) inFile->Get(Form("h_pt_mc[%i][%i][%i]",centralityBin,eta_bin,sort));
  102. h_pt_reco_after[centralityBin][sort][eta_bin] = (TH1F*) inFile->Get(Form("h_pt_after[%i][%i][%i]",centralityBin,eta_bin,sort));
  103. h_pt_true_after[centralityBin][sort][eta_bin] = (TH1F*) inFile->Get(Form("h_pt_mc_after[%i][%i][%i]",centralityBin,eta_bin,sort));
  104. //sprintf(title,"p_{T}-efficiency before cuts for %s, %.2f - %.2f % ", sorts_of_particles[sort].Data(), centralityBinsRes[centralityBin], centralityBinsRes[centralityBin+1]);
  105. sprintf(title,"p_{T}-efficiency before cuts for %s, %i %i", sorts_of_particles[sort].Data(),centralityBin,eta_bin);
  106. //h_pt_eff_before[centralityBin][sort][eta_bin] = new TH1F(Form("h_pt_eff_before%i%i%i",centralityBin,sort,eta_bin),title,100,0.,3.5);
  107. //h_pt_eff_before[centralityBin][sort][eta_bin] -> Sumw2();
  108. //sprintf(title,"p_{T}-efficiency after cuts for %s, %2.0f-%2.0f % ", sorts_of_particles[sort].Data(), centralityBinsRes[centralityBin], centralityBinsRes[centralityBin+1]);
  109. sprintf(title,"p_{T}-efficiency after cuts for %s, %i %i", sorts_of_particles[sort].Data(), centralityBin,eta_bin);
  110. //h_pt_eff_after[centralityBin][sort][eta_bin] = new TH1F(Form("h_pt_eff_after%i%i%i" ,centralityBin,sort,eta_bin),title,100,0.,3.5);
  111. //h_pt_eff_after[centralityBin][sort][eta_bin] -> Sumw2();
  112. //f_pt_eff_before[centralityBin][sort][eta_bin] = new TF1(Form("f_pt_eff_before%i%i%i",centralityBin,sort,eta_bin),"pol8",0.2,2.);
  113. //f_pt_eff_after[centralityBin][sort][eta_bin] = new TF1(Form("f_pt_eff_before%i%i%i",centralityBin,sort,eta_bin),"pol8",0.2,2.);
  114. }
  115. }
  116. }*/
  117. for (int harm = 0; harm < _N_HARM; ++harm)
  118. {
  119. for (int _harm = 0; _harm < _N_HARM; ++_harm)
  120. {
  121. for (int method = 0; method < _N_METHOD; ++method)
  122. {
  123. sprintf(name,"p_Res2Psi_vs_b[%i][%i][%i]",harm,_harm,method);
  124. p_Res2Psi_vs_b[harm][_harm][method] = (TProfile*)inFile->Get(name);
  125. sprintf(name,"p_ResPsi_vs_b[%i][%i][%i]",harm,_harm,method);
  126. sprintf(title,"Res(#Psi_{%i,%s}) for v_{%i};b,fm;",_harm+1,methods_names[method].Data(),harm+1);
  127. p_ResPsi_vs_b[harm][_harm][method] = new TProfile(name,title,NcentralityBinsRes,centralityBinsRes);
  128. }
  129. }
  130. }
  131. outFile->cd();
  132. for (int harm = 0; harm < _N_HARM; ++harm)
  133. {
  134. for (int _harm = 0; _harm < _N_HARM; ++_harm)
  135. {
  136. for (int method = 0; method < _N_METHOD; ++method)
  137. {
  138. for (int centralitybin = 0; centralitybin < NcentralityBinsRes; ++centralitybin)
  139. {
  140. Double_t res2 = p_Res2Psi_vs_b[harm][_harm][method]->GetBinContent(centralitybin + 1);
  141. if (res2 < 0)res2 = 0;
  142. Double_t chi_half = Chi(TMath::Sqrt(res2),harm+1);
  143. p_ResPsi_vs_b[harm][_harm][method]->Fill(centralityBinsRes[centralitybin] + 0.1,ResEventPlane(TMath::Sqrt(2.) * chi_half,harm+1));
  144. }
  145. char name[200];
  146. sprintf(name,"resolution_fit[%i][%i][%i]",harm,_harm,method);
  147. resolution_fit[harm][_harm][method] = new TF1(name,"pol8",0.01,100);
  148. p_ResPsi_vs_b[harm][_harm][method]->Fit(name,"W");
  149. p_ResPsi_vs_b[harm][_harm][method]->Write();
  150. resolution_fit[harm][_harm][method]->Write();
  151. }
  152. }
  153. }
  154. //for (Int_t eta_bin=0; eta_bin<NetaBins; eta_bin++){
  155. //for (int sort = 0; sort < _N_SORTS; ++sort){
  156. //h_pt_PID_eff[eta_bin][sort] -> Divide(h_pt_PID_efficiency_after_sorts[eta_bin][sort],h_pt_PID_efficiency_before[eta_bin],1.,1.);
  157. //h_pt_PID_eff[eta_bin][sort] -> Fit(Form("f_pt_PID_eff%i%i",eta_bin,sort),"WR");
  158. //h_pt_PID_eff[eta_bin][sort] -> Write();
  159. //f_pt_PID_eff[eta_bin][sort] -> Write();
  160. //}
  161. //}
  162. /*
  163. for (int centralityBin = 0; centralityBin < NcentralityBinsRes; ++centralityBin)
  164. {
  165. for (int sort = 0; sort < _N_SORTS; ++sort)
  166. {
  167. for (int eta_bin=0;eta_bin<NetaBins;eta_bin++){
  168. //h_pt_eff_after[centralityBin][sort][eta_bin] -> Divide(h_pt_reco_after[centralityBin][sort][eta_bin],h_pt_true_after[centralityBin][sort][eta_bin],1.,1.);
  169. //h_pt_eff_after[centralityBin][sort][eta_bin] -> Fit(Form("f_pt_eff_before%i%i%i",centralityBin,sort,eta_bin),"R");
  170. //h_pt_eff_after[centralityBin][sort] -> Write();
  171. //f_pt_eff_after[centralityBin][sort] -> Write();
  172. if (centralityBin >= 2 && centralityBin < 4) {
  173. h_pt_reco_final[0][sort][eta_bin] ->Add(h_pt_reco_after[centralityBin][sort][eta_bin]);
  174. h_pt_true_final[0][sort][eta_bin] ->Add(h_pt_true_after[centralityBin][sort][eta_bin]);
  175. }
  176. if (centralityBin >= 4 && centralityBin < 8) {
  177. h_pt_reco_final[1][sort][eta_bin] ->Add(h_pt_reco_after[centralityBin][sort][eta_bin]);
  178. h_pt_true_final[1][sort][eta_bin] ->Add(h_pt_true_after[centralityBin][sort][eta_bin]);
  179. }
  180. if (centralityBin >= 8 && centralityBin < 10){
  181. h_pt_reco_final[2][sort][eta_bin] ->Add(h_pt_reco_after[centralityBin][sort][eta_bin]);
  182. h_pt_true_final[2][sort][eta_bin] ->Add(h_pt_true_after[centralityBin][sort][eta_bin]);
  183. }
  184. }
  185. }
  186. }
  187. for (int centralityBin = 0; centralityBin < NcentralityBinsFlow; ++centralityBin)
  188. {
  189. for (int sort = 0; sort < _N_SORTS; ++sort)
  190. {
  191. for (int eta_bin=0;eta_bin<NetaBins;eta_bin++){
  192. h_pt_eff_after_final[centralityBin][sort][eta_bin] -> Divide(h_pt_reco_final[centralityBin][sort][eta_bin],h_pt_true_final[centralityBin][sort][eta_bin],1.,1.);
  193. h_pt_eff_after_final[centralityBin][sort][eta_bin] -> Fit(Form("f_pt_eff_after_final%i%i%i",centralityBin,sort,eta_bin),"R");
  194. h_pt_eff_after_final[centralityBin][sort][eta_bin] -> Write();
  195. f_pt_eff_after_final[centralityBin][sort][eta_bin] -> Write();
  196. }
  197. }
  198. }
  199. */
  200. outFile->Close();
  201. inFile->Close();
  202. }