MpdCalculator.C 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226
  1. //!!!!!!!!!!!!!!!!!!!!!!
  2. #include "MpdCalculator.h"
  3. MpdCalculator::MpdCalculator(TString inFileName, TString outFileName, TString dcaFileName)
  4. {
  5. this->inFileName = inFileName;
  6. this->outFileName = outFileName;
  7. inChain = new TChain("cbmsim_reduced");
  8. inChain->Add(inFileName.Data());
  9. outFile = new TFile(outFileName.Data(), "RECREATE");
  10. dcaFile = new TFile(dcaFileName.Data(), "READ");
  11. inChain->SetBranchAddress("b_mc", &b_mc);
  12. inChain->SetBranchAddress("centrality_tpc_mpd", &centrality_tpc_mpd);
  13. inChain->SetBranchAddress("n_tracks_mc", &n_tracks_mc);
  14. inChain->SetBranchAddress("n_tracks_mpd", &n_tracks_mpd);
  15. inChain->SetBranchAddress("k_tracks_mpd", &k_tracks_mpd);
  16. inChain->SetBranchAddress("signed_pt_mpd", signed_pt_mpd);
  17. inChain->SetBranchAddress("eta_mpd", eta_mpd);
  18. inChain->SetBranchAddress("n_hits_mpd", n_hits_mpd);
  19. inChain->SetBranchAddress("phi_mpd", phi_mpd);
  20. inChain->SetBranchAddress("theta_mpd", theta_mpd);
  21. inChain->SetBranchAddress("tof_beta_mpd", tof_beta_mpd);
  22. inChain->SetBranchAddress("id_from_mc_mpd", id_from_mc_mpd);
  23. inChain->SetBranchAddress("mother_ID_mc", mother_ID_mc);
  24. inChain->SetBranchAddress("PDG_code_mc", PDG_code_mc);
  25. inChain->SetBranchAddress("phiEP_mc", &phiEP_mc);
  26. inChain->SetBranchAddress("ZDC_energy_mpd", ZDC_energy_mpd);
  27. inChain->SetBranchAddress("pt_mc", pt_mc);
  28. inChain->SetBranchAddress("chi2_mpd", chi2_mpd);
  29. inChain->SetBranchAddress("eta_mc", eta_mc);
  30. inChain->SetBranchAddress("px_mc", px_mc);
  31. inChain->SetBranchAddress("py_mc", py_mc);
  32. inChain->SetBranchAddress("pz_mc", pz_mc);
  33. inChain->SetBranchAddress("energy_mc", energy_mc);
  34. inChain->SetBranchAddress("DCA_x_mpd", DCA_x_mpd);
  35. inChain->SetBranchAddress("DCA_y_mpd", DCA_y_mpd);
  36. inChain->SetBranchAddress("DCA_z_mpd", DCA_z_mpd);
  37. inChain->SetBranchAddress("pid_tpc_prob_pion_mpd", pid_tpc_prob_pion_mpd);
  38. inChain->SetBranchAddress("pid_tpc_prob_kaon_mpd", pid_tpc_prob_kaon_mpd);
  39. inChain->SetBranchAddress("pid_tpc_prob_proton_mpd", pid_tpc_prob_proton_mpd);
  40. inChain->SetBranchAddress("TOF_flag_mpd", TOF_flag_mpd);
  41. h_nhits_TPC = new TH1F("h_nhits_TPC", "number of hits in TPC distribution;N_{hits};N_{tracks};", 60, 0., 60.);
  42. h_nhits_TPC_after = new TH1F("h_nhits_TPC_after", "number of hits in TPC distribution after cuts;N_{hits};N_{tracks};", 60, 0., 60.);
  43. h_multiplicity = new TH1F("h_multiplicity", "multiplicity in TPC;N_{tracks} in TPC;N_{events};", 1600, 0., 1600.);
  44. h_multiplicity_before = new TH1F("h_multiplicity_before", "multiplicity in TPCbefore cuts;N_{tracks} in TPC;N_{events};", 1600, 0., 1600.);
  45. h_impact_parameter = new TH1F("h_impact_parameter", "impact parameter distribution;b,fm;N_{events};", 100, 0., 20.);
  46. h2_energyZDC_L_vs_energy_ZDC_R = new TH2F("h2_energyZDC_L_vs_energy_ZDC_R", "FHCal energy left vs right;E_{left};E_{right};", 300, 0., 70., 300, 0., 70.);
  47. p_b_vs_multiplicity = new TProfile("p_b_vs_multiplicity", "Impact parameter vs TPC multiplicity", 800, 0, 1600);
  48. h2_b_vs_multiplicity = new TH2F("h2_b_vs_multiplicity", "Impact parameter vs TPC multiplicity", 800, 0., 1600., 100, 0., 20.);
  49. h2_b_vs_multiplicity->Sumw2();
  50. p_b_vs_multiplicity->Sumw2();
  51. p_b_vs_energy = new TProfile("p_b_vs_energy", "Impact parameter vs FHCal energy", 200, 0, 70);
  52. h2_b_vs_energy = new TH2F("h2_b_vs_energy", "Impact parameter vs FHCal energy", 200, 0., 70., 200, 0., 20.);
  53. h2_b_vs_energy->Sumw2();
  54. p_b_vs_energy->Sumw2();
  55. h2_b_vs_centrality = new TH2F("h2_b_vs_centrality", "h2_b_vs_centrality", 100, 0, 100, 200, 0., 20.);
  56. char name[200];
  57. char title[200];
  58. for (Int_t dim = 0; dim < Ndim; dim++)
  59. {
  60. for (Int_t eta_bin = 0; eta_bin < NetaBins; eta_bin++)
  61. {
  62. f_pt_fit[dim][eta_bin] = (TF1 *)dcaFile->Get(Form("sigma_pt_fit%i%i", dim, eta_bin));
  63. }
  64. for (Int_t pt_bin = 0; pt_bin < NptBins; pt_bin++)
  65. {
  66. for (Int_t eta_bin = 0; eta_bin < NetaBins; eta_bin++)
  67. {
  68. //f_dca[dim][pt_bin][eta_bin] = (TF1*) dcaFile->Get(Form("dca_fit[%i][%i][%i]",dim,pt_bin,eta_bin));
  69. sprintf(name, "h_DCA_primary[%i][%i][%i]", dim, pt_bin, eta_bin);
  70. sprintf(title, "DCA_{%i} primary for %.2f < p_{t} < %.2f and %.2f < #eta < %.2f ", dim, ptBins[pt_bin], ptBins[pt_bin + 1], etaBins[eta_bin], etaBins[eta_bin + 1]);
  71. h_DCA_primary[dim][pt_bin][eta_bin] = new TH1F(name, title, 200, -50., 50.);
  72. sprintf(name, "h_DCA_secondary[%i][%i][%i]", dim, pt_bin, eta_bin);
  73. sprintf(title, "DCA_{%i} secondary for %.2f < p_{t} < %.2f and %.2f < #eta < %.2f", dim, ptBins[pt_bin], ptBins[pt_bin + 1], etaBins[eta_bin], etaBins[eta_bin + 1]);
  74. h_DCA_secondary[dim][pt_bin][eta_bin] = new TH1F(name, title, 200, -50., 50.);
  75. sprintf(name, "h_DCA_all[%i][%i][%i]", dim, pt_bin, eta_bin);
  76. sprintf(title, "DCA_{%i} all for %.2f < p_{t} < %.2f and %.2f < #eta < %.2f", dim, ptBins[pt_bin], ptBins[pt_bin + 1], etaBins[eta_bin], etaBins[eta_bin + 1]);
  77. h_DCA_all[dim][pt_bin][eta_bin] = new TH1F(name, title, 200, -50., 50.);
  78. }
  79. }
  80. }
  81. for (int sort = 0; sort < _N_SORTS; ++sort)
  82. {
  83. sprintf(name, "p_momenta_resolution[%i]", sort);
  84. sprintf(title, "#Delta p_{t} / p_{t} for %s", sorts_of_particles[sort].Data());
  85. p_momenta_resolution[sort] = new TProfile(name, title, NptBins, ptBins);
  86. }
  87. for (int harm = 0; harm < _N_HARM; ++harm)
  88. {
  89. sprintf(name, "p_flow_wrt_RP_vs_centrality[%i]", harm);
  90. sprintf(title, "v_{%i} wrt RP for ;centrailty, %;v_{%i}", harm + 1, harm + 1);
  91. p_flow_wrt_RP_vs_centrality[harm] = new TProfile(name, title, NcentralityBinsRes, centralityBinsRes);
  92. for (int cenralityBin = 0; cenralityBin < NcentralityBinsFlow; ++cenralityBin)
  93. {
  94. sprintf(name, "p_flow_wrt_RP_vs_pt[%i][%i]", cenralityBin, harm);
  95. sprintf(title, "v_{%i} wrt RP for %.2f < b < %.2f;p_{t};", harm + 1, centralityBinsFlow[cenralityBin], centralityBinsFlow[cenralityBin + 1]);
  96. p_flow_wrt_RP_vs_pt[cenralityBin][harm] = new TProfile(name, title, NptBins, ptBins);
  97. sprintf(name, "p_flow_wrt_RP_vs_eta[%i][%i]", cenralityBin, harm);
  98. sprintf(title, "v_{%i} wrt RP for %.2f < b < %.2f;#eta;", harm + 1, centralityBinsFlow[cenralityBin], centralityBinsFlow[cenralityBin + 1]);
  99. p_flow_wrt_RP_vs_eta[cenralityBin][harm] = new TProfile(name, title, NetaBins, etaBins);
  100. sprintf(name, "p_flow_wrt_RP_vs_rapidity[%i][%i]", cenralityBin, harm);
  101. sprintf(title, "v_{%i} wrt RP for %.2f < b < %.2f;#y;", harm + 1, centralityBinsFlow[cenralityBin], centralityBinsFlow[cenralityBin + 1]);
  102. p_flow_wrt_RP_vs_rapidity[cenralityBin][harm] = new TProfile(name, title, NrapidityBins, rapidityBins);
  103. }
  104. for (int _harm = 0; _harm < _N_HARM; ++_harm)
  105. {
  106. for (int method = 0; method < _N_METHOD; ++method)
  107. {
  108. sprintf(name, "p_true_Res_vs_b[%i][%i][%i]", harm, _harm, method);
  109. sprintf(title, "%s%i%s%i%s%s%s", "<cos", harm + 1, "(#Psi_{", _harm + 1, "}^{FULL} - #Psi_{RP})> using ",
  110. methods_names[method].Data(), ";b,fm;");
  111. p_true_Res_vs_b[harm][_harm][method] = new TProfile(name, title, NcentralityBinsRes, centralityBinsRes);
  112. sprintf(name, "%s%i%s%i%s%i%s", "p_Res2Psi_vs_b[", harm, "][", _harm, "][", method, "]");
  113. sprintf(title, "%s%i%s%i%s%s%s%i%s%s%s", "cos(", harm + 1, "(#Psi_{", _harm + 1, ",", methods_names[method].Data(), "}^{R} - #Psi_{",
  114. _harm + 1, ",", methods_names[method].Data(), "}^{L});b,fm;");
  115. p_Res2Psi_vs_b[harm][_harm][method] = new TProfile(name, title, NcentralityBinsRes, centralityBinsRes);
  116. sprintf(name, "p_flow_wrt_full_vs_centrality[%i][%i][%i]", harm, _harm, method);
  117. sprintf(title, "v_{%i} wrt #Psi_{%i,%s}^{FULL} ;centrality, %; ", harm + 1, _harm + 1, methods_names[method].Data());
  118. p_flow_wrt_full_vs_centrality[harm][_harm][method] = new TProfile(name, title, NcentralityBinsRes, centralityBinsRes);
  119. sprintf(name, "p_flow_wrt_full_vs_centrality_divided[%i][%i][%i]", harm, _harm, method);
  120. sprintf(title, "v_{%i} wrt #Psi_{%i,%s}^{FULL} divided ;centrality, %; ", harm + 1, _harm + 1, methods_names[method].Data());
  121. p_flow_wrt_full_vs_centrality_divided[harm][_harm][method] = new TProfile(name, title, NcentralityBinsRes, centralityBinsRes);
  122. for (int cenralityBin = 0; cenralityBin < NcentralityBinsFlow; ++cenralityBin)
  123. {
  124. sprintf(name, "p_flow_wrt_full_vs_pt[%i][%i][%i][%i]", cenralityBin, harm, _harm, method);
  125. sprintf(title, "v_{%i} wrt #Psi_{%i,%s}^{FULL} for %.2f < b < %.2f;p_{t};", harm + 1, _harm + 1, methods_names[method].Data(),
  126. centralityBinsFlow[cenralityBin], centralityBinsFlow[cenralityBin + 1]);
  127. p_flow_wrt_full_vs_pt[cenralityBin][harm][_harm][method] = new TProfile(name, title, NptBins, ptBins);
  128. sprintf(name, "p_flow_wrt_full_vs_pt_divided[%i][%i][%i][%i]", cenralityBin, harm, _harm, method);
  129. sprintf(title, "v_{%i} wrt #Psi_{%i,%s}^{FULL} divided for %.2f < b < %.2f;p_{t};", harm + 1, _harm + 1, methods_names[method].Data(), centralityBinsFlow[cenralityBin], centralityBinsFlow[cenralityBin + 1]);
  130. p_flow_wrt_full_vs_pt_divided[cenralityBin][harm][_harm][method] = new TProfile(name, title, NptBins, ptBins);
  131. sprintf(name, "p_flow_wrt_full_vs_eta[%i][%i][%i][%i]", cenralityBin, harm, _harm, method);
  132. sprintf(title, "v_{%i} wrt #Psi_{%i,%s}^{FULL} for %.2f < b < %.2f;#eta;", harm + 1, _harm + 1, methods_names[method].Data(),
  133. centralityBinsFlow[cenralityBin], centralityBinsFlow[cenralityBin + 1]);
  134. p_flow_wrt_full_vs_eta[cenralityBin][harm][_harm][method] = new TProfile(name, title, NetaBins, etaBins);
  135. sprintf(name, "p_flow_wrt_full_vs_eta_divided[%i][%i][%i][%i]", cenralityBin, harm, _harm, method);
  136. sprintf(title, "v_{%i} wrt #Psi_{%i,%s}^{FULL} divided for %.2f < b < %.2f;#eta;", harm + 1, _harm + 1, methods_names[method].Data(),
  137. centralityBinsFlow[cenralityBin], centralityBinsFlow[cenralityBin + 1]);
  138. p_flow_wrt_full_vs_eta_divided[cenralityBin][harm][_harm][method] = new TProfile(name, title, NetaBins, etaBins);
  139. sprintf(name, "p_flow_wrt_full_vs_rapidity[%i][%i][%i][%i]", cenralityBin, harm, _harm, method);
  140. sprintf(title, "v_{%i} wrt #Psi_{%i,%s}^{FULL} for %.2f < b < %.2f;#y;", harm + 1, _harm + 1, methods_names[method].Data(),
  141. centralityBinsFlow[cenralityBin], centralityBinsFlow[cenralityBin + 1]);
  142. p_flow_wrt_full_vs_rapidity[cenralityBin][harm][_harm][method] = new TProfile(name, title, NrapidityBins, rapidityBins);
  143. sprintf(name, "p_flow_wrt_full_vs_rapidity_divided[%i][%i][%i][%i]", cenralityBin, harm, _harm, method);
  144. sprintf(title, "v_{%i} wrt #Psi_{%i,%s}^{FULL} divided for %.2f < b < %.2f;y;", harm + 1, _harm + 1, methods_names[method].Data(),
  145. centralityBinsFlow[cenralityBin], centralityBinsFlow[cenralityBin + 1]);
  146. p_flow_wrt_full_vs_rapidity_divided[cenralityBin][harm][_harm][method] = new TProfile(name, title, NrapidityBins, rapidityBins);
  147. }
  148. }
  149. }
  150. }
  151. for (int arm = 0; arm < _N_ARM; ++arm)
  152. {
  153. sprintf(name, "%s%i%s", "h_energy_ZDC_total[", arm, "]");
  154. sprintf(title, "%s%s%s", "FHCal energy distribution for ", arm_names[arm].Data(), " arm;E_{total};N_{events};");
  155. h_energy_ZDC_total[arm] = new TH1F(name, title, 100, 0., 22.);
  156. sprintf(name, "%s%i%s", "h2_energy_ZDC_vs_multiplicity[", arm, "]");
  157. sprintf(title, "%s%s%s", "Total FHCal energy in ", arm_names[arm].Data(), " arm vs TPC multiplicity;E_{total};multiplicity;");
  158. h2_energy_ZDC_vs_multiplicity[arm] = new TH2F(name, title, 300, 0., 70., 200, 0., 800.);
  159. for (int harm = 0; harm < _N_HARM; ++harm)
  160. {
  161. for (int method = 0; method < _N_METHOD; ++method)
  162. {
  163. sprintf(name, "%s%i%s%i%s%i%s", "p_qx_vs_b[", arm, "][", harm, "][", method, "]");
  164. sprintf(title, "%s%i%s%s%s%s", "Q_{x}^{", harm + 1, ",", arm_names[arm].Data(), "} using ", methods_names[method].Data());
  165. p_qx_vs_b[arm][harm][method] = new TProfile(name, title, NcentralityBinsRes, centralityBinsRes);
  166. sprintf(name, "%s%i%s%i%s%i%s", "p_qy_vs_b[", arm, "][", harm, "][", method, "]");
  167. sprintf(title, "%s%i%s%s%s%s", "Q_{y}^{", harm + 1, ",", arm_names[arm].Data(), "} using ", methods_names[method].Data());
  168. p_qy_vs_b[arm][harm][method] = new TProfile(name, title, NcentralityBinsRes, centralityBinsRes);
  169. for (int _harm = 0; _harm < _N_HARM; ++_harm)
  170. {
  171. sprintf(name, "p_true_Res_half_vs_b[%i][%i][%i][%i]", arm, harm, _harm, method);
  172. sprintf(title, "<cos(%i(#Psi_{%i,%s}^{%s} - #Psi_{RP} ))> ;b,fm;", harm + 1, _harm + 1, methods_names[method].Data(), arm_names[arm].Data());
  173. p_true_Res_half_vs_b[arm][harm][_harm][method] = new TProfile(name, title, NcentralityBinsRes, centralityBinsRes);
  174. }
  175. }
  176. }
  177. }
  178. for (int centralityBin = 0; centralityBin < NcentralityBinsRes; ++centralityBin)
  179. {
  180. for (int sort = 0; sort < _N_SORTS; ++sort)
  181. {
  182. sprintf(name, "%s%i%s%i%s", "h_pt[", centralityBin, "][", sort, "]");
  183. sprintf(title, "%s%s%s%.2f%s%.2f%s", "P_{t} distribution for ", sorts_of_particles[sort].Data(),
  184. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";p_{t};N_{tracks};");
  185. h_pt[centralityBin][sort] = new TH1F(name, title, 100, 0., 3.5);
  186. sprintf(name, "%s%i%s%i%s", "h_eta[", centralityBin, "][", sort, "]");
  187. sprintf(title, "%s%s%s%.2f%s%.2f%s", "#eta distribution for ", sorts_of_particles[sort].Data(),
  188. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";#eta;N_{tracks};");
  189. h_eta[centralityBin][sort] = new TH1F(name, title, 100, -2., 2.);
  190. sprintf(name, "%s%i%s%i%s", "h_phi[", centralityBin, "][", sort, "]");
  191. sprintf(title, "%s%s%s%.2f%s%.2f%s", "#phi distribution for ", sorts_of_particles[sort].Data(),
  192. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";#phi;N_{tracks};");
  193. h_phi[centralityBin][sort] = new TH1F(name, title, 100, -4., 4.);
  194. sprintf(name, "%s%i%s%i%s", "h2_pt_vs_eta[", centralityBin, "][", sort, "]");
  195. sprintf(title, "%s%s%s%.2f%s%.2f%s", "p_{t} vs #eta distribution for ", sorts_of_particles[sort].Data(), " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";p_{t};#eta;");
  196. h2_pt_vs_eta[centralityBin][sort] = new TH2F(name, title, 100, 0., 3.5, 100., -1.5, 1.5);
  197. sprintf(name, "%s%i%s%i%s", "h2_pt_vs_phi[", centralityBin, "][", sort, "]");
  198. sprintf(title, "%s%s%s%.2f%s%.2f%s", "p_{t} vs #phi distribution for ", sorts_of_particles[sort].Data(), " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";p_{t};#phi;");
  199. h2_pt_vs_phi[centralityBin][sort] = new TH2F(name, title, 100, 0., 3.5, 100., -4., 4.);
  200. sprintf(name, "%s%i%s%i%s", "h2_phi_vs_eta[", centralityBin, "][", sort, "]");
  201. sprintf(title, "%s%s%s%.2f%s%.2f%s", "#phi vs #eta distribution for ", sorts_of_particles[sort].Data(), " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";#phi;#eta;");
  202. h2_phi_vs_eta[centralityBin][sort] = new TH2F(name, title, 100, -4., 4., 100., -1.5, 1.5); //
  203. sprintf(name, "%s%i%s%i%s", "h_pt_after[", centralityBin, "][", sort, "]");
  204. sprintf(title, "%s%s%s%.2f%s%.2f%s", "P_{t} distribution for ", sorts_of_particles[sort].Data(),
  205. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";p_{t};N_{tracks};");
  206. h_pt_after[centralityBin][sort] = new TH1F(name, title, 100, 0., 3.5);
  207. sprintf(name, "%s%i%s%i%s", "h_eta_after[", centralityBin, "][", sort, "]");
  208. sprintf(title, "%s%s%s%.2f%s%.2f%s", "#eta distribution for ", sorts_of_particles[sort].Data(),
  209. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";#eta;N_{tracks};");
  210. h_eta_after[centralityBin][sort] = new TH1F(name, title, 100, -2., 2.);
  211. sprintf(name, "%s%i%s%i%s", "h_phi_after[", centralityBin, "][", sort, "]");
  212. sprintf(title, "%s%s%s%.2f%s%.2f%s", "#phi distribution for ", sorts_of_particles[sort].Data(),
  213. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";#phi;N_{tracks};");
  214. h_phi_after[centralityBin][sort] = new TH1F(name, title, 100, -4., 4.);
  215. sprintf(name, "%s%i%s%i%s", "h2_pt_vs_eta_after[", centralityBin, "][", sort, "]");
  216. sprintf(title, "%s%s%s%.2f%s%.2f%s", "p_{t} vs #eta distribution for ", sorts_of_particles[sort].Data(), " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";p_{t};#eta;");
  217. h2_pt_vs_eta_after[centralityBin][sort] = new TH2F(name, title, 100, 0., 3.5, 100., -1.5, 1.5);
  218. sprintf(name, "%s%i%s%i%s", "h2_pt_vs_phi_after[", centralityBin, "][", sort, "]");
  219. sprintf(title, "%s%s%s%.2f%s%.2f%s", "p_{t} vs #phi distribution for ", sorts_of_particles[sort].Data(), " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";p_{t};#phi;");
  220. h2_pt_vs_phi_after[centralityBin][sort] = new TH2F(name, title, 100, 0., 3.5, 100., -4., 4.);
  221. sprintf(name, "%s%i%s%i%s", "h2_phi_vs_eta_after[", centralityBin, "][", sort, "]");
  222. sprintf(title, "%s%s%s%.2f%s%.2f%s", "#phi vs #eta distribution for ", sorts_of_particles[sort].Data(), " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";#phi;#eta;");
  223. h2_phi_vs_eta_after[centralityBin][sort] = new TH2F(name, title, 100, -4., 4., 100., -1.5, 1.5); //
  224. sprintf(name, "%s%i%s%i%s", "h_pt_mc[", centralityBin, "][", sort, "]");
  225. sprintf(title, "%s%s%s%.2f%s%.2f%s", "P_{t} distribution for ", sorts_of_particles[sort].Data(),
  226. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";p_{t};N_{tracks};");
  227. h_pt_mc[centralityBin][sort] = new TH1F(name, title, 100, 0., 3.5);
  228. sprintf(name, "%s%i%s%i%s", "h_eta_mc[", centralityBin, "][", sort, "]");
  229. sprintf(title, "%s%s%s%.2f%s%.2f%s", "#eta distribution for ", sorts_of_particles[sort].Data(),
  230. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";#eta;N_{tracks};");
  231. h_eta_mc[centralityBin][sort] = new TH1F(name, title, 100, -2., 2.);
  232. sprintf(name, "%s%i%s%i%s", "h_phi_mc[", centralityBin, "][", sort, "]");
  233. sprintf(title, "%s%s%s%.2f%s%.2f%s", "#phi distribution for ", sorts_of_particles[sort].Data(),
  234. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";#phi;N_{tracks};");
  235. h_phi_mc[centralityBin][sort] = new TH1F(name, title, 100, -4., 4.);
  236. sprintf(name, "%s%i%s%i%s", "h_pt_mc_after[", centralityBin, "][", sort, "]");
  237. sprintf(title, "%s%s%s%.2f%s%.2f%s", "P_{t} distribution for ", sorts_of_particles[sort].Data(),
  238. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";p_{t};N_{tracks};");
  239. h_pt_mc_after[centralityBin][sort] = new TH1F(name, title, 100, 0., 3.5);
  240. sprintf(name, "%s%i%s%i%s", "h_eta_mc_after[", centralityBin, "][", sort, "]");
  241. sprintf(title, "%s%s%s%.2f%s%.2f%s", "#eta distribution for ", sorts_of_particles[sort].Data(),
  242. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";#eta;N_{tracks};");
  243. h_eta_mc_after[centralityBin][sort] = new TH1F(name, title, 100, -2., 2.);
  244. sprintf(name, "%s%i%s%i%s", "h_phi_mc_after[", centralityBin, "][", sort, "]");
  245. sprintf(title, "%s%s%s%.2f%s%.2f%s", "#phi distribution for ", sorts_of_particles[sort].Data(),
  246. " for ", centralityBinsRes[centralityBin], " < b < ", centralityBinsRes[centralityBin + 1], ";#phi;N_{tracks};");
  247. h_phi_mc_after[centralityBin][sort] = new TH1F(name, title, 100, -4., 4.);
  248. }
  249. }
  250. }
  251. void MpdCalculator::FillTPC(Int_t cenrality_bin, EPParticle *event_plane_buffer, Int_t ep_particle_count, Float_t weightB)
  252. {
  253. Double_t qx, qy;
  254. Double_t psi_N_HALF;
  255. phiEP_mc = ATan2(Sin(phiEP_mc), Cos(phiEP_mc));
  256. for (Int_t harm = 0; harm < _N_HARM; ++harm)
  257. {
  258. Double_t psi_N_R = GetPsiHalfTpc(event_plane_buffer, ep_particle_count, 1, harm + 1, qx, qy);
  259. Double_t psi_N_L = GetPsiHalfTpc(event_plane_buffer, ep_particle_count, -1, harm + 1, qx, qy);
  260. Double_t psi_N_FULL = GetPsiFullTpc(event_plane_buffer, ep_particle_count, harm + 1);
  261. for (Int_t _harm = 0; _harm < _N_HARM; ++_harm)
  262. {
  263. Double_t psi_N_R = GetPsiHalfTpc(event_plane_buffer, ep_particle_count, 1, _harm + 1, qx, qy);
  264. Double_t psi_N_L = GetPsiHalfTpc(event_plane_buffer, ep_particle_count, -1, _harm + 1, qx, qy);
  265. // << "Filling with centrality = " << centralityBinsRes[cenrality_bin]+0.1 << "Res2 = " << Cos((harm+1)*(psi_N_R - psi_N_L)) << endl;
  266. p_Res2Psi_vs_b[harm][_harm][0]->Fill(centralityBinsRes[cenrality_bin] + 0.1, Cos((harm + 1) * (psi_N_R - psi_N_L)), weightB);
  267. Double_t psi_N_FULL = GetPsiFullTpc(event_plane_buffer, ep_particle_count, harm + 1);
  268. p_true_Res_vs_b[harm][_harm][0]->Fill(centralityBinsRes[cenrality_bin] + 0.1, Cos((harm + 1) * (psi_N_FULL - phiEP_mc)), weightB);
  269. for (Int_t arm = 0; arm < _N_ARM; ++arm)
  270. {
  271. Double_t psi_N_HALF = GetPsiHalfTpc(event_plane_buffer, ep_particle_count, -2 * arm + 1, _harm + 1, qx, qy);
  272. p_true_Res_half_vs_b[arm][harm][_harm][0]->Fill(centralityBinsRes[cenrality_bin] + 0.1, Cos((harm + 1) * (psi_N_HALF - phiEP_mc)), weightB);
  273. }
  274. }
  275. for (Int_t arm = 0; arm < _N_ARM; ++arm)
  276. {
  277. psi_N_HALF = GetPsiHalfTpc(event_plane_buffer, ep_particle_count, -2 * arm + 1, harm + 1, qx, qy);
  278. p_qx_vs_b[arm][harm][0]->Fill(centralityBinsRes[cenrality_bin] + 0.1, qx, weightB);
  279. p_qy_vs_b[arm][harm][0]->Fill(centralityBinsRes[cenrality_bin] + 0.1, qy, weightB);
  280. }
  281. }
  282. }
  283. void MpdCalculator::FillZDC(Int_t cenrality_bin, Float_t *ZDC_energy_mpd, Float_t weightB)
  284. {
  285. Float_t values[10], absvalues[10];
  286. Double_t qx, qy;
  287. Double_t psi_N_HALF;
  288. phiEP_mc = ATan2(Sin(phiEP_mc), Cos(phiEP_mc));
  289. for (Int_t harm = 0; harm < _N_HARM; ++harm)
  290. {
  291. for (Int_t _harm = 0; _harm < _N_HARM; ++_harm)
  292. {
  293. Double_t psi_N_R = GetPsiHalfZdc(ZDC_energy_mpd, 0, _harm + 1, qx, qy);
  294. Double_t psi_N_L = GetPsiHalfZdc(ZDC_energy_mpd, 1, _harm + 1, qx, qy);
  295. //cout << "Filling with centrality = " << centralityBinsRes[cenrality_bin]+0.1 << "Res2 = " << Cos((harm+1)*(psi_N_R - psi_N_L)) << endl;
  296. p_Res2Psi_vs_b[harm][_harm][1]->Fill(centralityBinsRes[cenrality_bin] + 0.1, Cos((harm + 1) * (psi_N_R - psi_N_L)),weightB);
  297. Double_t psi_N_FULL = GetPsiFullZdc(ZDC_energy_mpd, _harm + 1);
  298. p_true_Res_vs_b[harm][_harm][1]->Fill(centralityBinsRes[cenrality_bin] + 0.1, Cos((harm + 1) * (psi_N_FULL - phiEP_mc)),weightB);
  299. for (Int_t arm = 0; arm < _N_ARM; ++arm)
  300. {
  301. Double_t psi_N_HALF = GetPsiHalfZdc(ZDC_energy_mpd, arm, _harm + 1, qx, qy);
  302. p_true_Res_half_vs_b[arm][harm][_harm][1]->Fill(centralityBinsRes[cenrality_bin] + 0.1, Cos((harm + 1) * (psi_N_HALF - phiEP_mc)),weightB);
  303. }
  304. }
  305. for (Int_t arm = 0; arm < _N_ARM; ++arm)
  306. {
  307. psi_N_HALF = GetPsiHalfZdc(ZDC_energy_mpd, arm, harm + 1, qx, qy);
  308. p_qx_vs_b[arm][harm][1]->Fill(centralityBinsRes[cenrality_bin] + 0.1, qx,weightB);
  309. p_qy_vs_b[arm][harm][1]->Fill(centralityBinsRes[cenrality_bin], qy, weightB);
  310. }
  311. }
  312. }
  313. void MpdCalculator::CalculateResolutions(Int_t nevents)
  314. {
  315. const Float_t dB = 0.25;
  316. Float_t B,wB;
  317. EPParticle *event_plane_buffer = new EPParticle[10000];
  318. if (nevents == 0)
  319. nevents = inChain->GetEntries();
  320. for (Int_t event = 0; event < nevents; ++event)
  321. {
  322. inChain->GetEntry(event); //reading all the branches for current event
  323. cout << "EVENT # " << event << endl;
  324. B = b_mc;
  325. wB = 2*TMath::Pi()*B*dB;
  326. centrality_tpc_mpd = 100 - centrality_tpc_mpd; //FIXED CENTRALITY!!!!!!!!!!!!!!!!!!!!!!
  327. h_impact_parameter->Fill(b_mc,wB); //filling impact parameter hitsogram with no cuts on events
  328. //Int_t multiplicity = GetMultiplicityTPC();
  329. if (n_tracks_mpd == 0)
  330. continue; //skipping empty events
  331. h_multiplicity_before->Fill(n_tracks_mpd,wB); //filling multiplicity TPC before cuts hitsogram
  332. p_b_vs_multiplicity->Fill(k_tracks_mpd, b_mc,wB);
  333. h2_b_vs_centrality->Fill(centrality_tpc_mpd, b_mc,wB);
  334. h2_b_vs_multiplicity->Fill(k_tracks_mpd, b_mc,wB);
  335. int cenrality_bin_res = GetCentralityBinRes(centrality_tpc_mpd); //getting the resolution bin in whic the event is
  336. if (cenrality_bin_res == -1)
  337. continue; // just in case...
  338. for (Long64_t track = 0; track < n_tracks_mc; ++track)
  339. {
  340. //~ _ _ _ _ __ _
  341. //~ | | (_)| | | | / _| | |
  342. //~ | |__ _ | |_ ___ __ _ _ __ __ _ _ __ ___ ___ | |__ ___ | |_ ___ _ __ ___ ___ _ _ | |_ ___
  343. //~ | '_ \ | || __|/ _ \ / _` || '__|/ _` || '_ ` _ \ / __| | '_ \ / _ \| _|/ _ \ | '__|/ _ \ / __|| | | || __|/ __|
  344. //~ | | | || || |_| (_) || (_| || | | (_| || | | | | |\__ \ | |_) || __/| | | (_) || | | __/ | (__ | |_| || |_ \__ \
  345. //~ |_| |_||_| \__|\___/ \__, ||_| \__,_||_| |_| |_||___/ |_.__/ \___||_| \___/ |_| \___| \___| \__,_| \__||___/
  346. //~ __/ |
  347. //~ |___/
  348. int sort = 0;
  349. h_phi_mc[cenrality_bin_res][0]->Fill(ATan2(px_mc[track], py_mc[track]),wB);
  350. h_eta_mc[cenrality_bin_res][0]->Fill(eta_mc[track],wB);
  351. h_pt_mc[cenrality_bin_res][0]->Fill(pt_mc[track],wB);
  352. switch (PDG_code_mc[track])
  353. {
  354. case 211:
  355. sort = 1;
  356. break;
  357. case 2212:
  358. sort = 2;
  359. break;
  360. case 321:
  361. sort = 3;
  362. break;
  363. default:
  364. break;
  365. }
  366. if ((sort == 1) || (sort == 2) || (sort == 3))
  367. {
  368. h_phi_mc[cenrality_bin_res][sort]->Fill(ATan2(px_mc[track], py_mc[track]),wB);
  369. h_eta_mc[cenrality_bin_res][sort]->Fill(eta_mc[track],wB);
  370. h_pt_mc[cenrality_bin_res][sort]->Fill(pt_mc[track],wB);
  371. }
  372. //~ | |
  373. //~ ___ _ _ | |_ ___
  374. //~ / __|| | | || __|/ __|
  375. //~ | (__ | |_| || |_ \__ \
  376. //~ \___| \__,_| \__||___/
  377. Int_t pt_bin = GetPtBin(pt_mc[track]);
  378. Int_t eta_bin = GetEtaBin(eta_mc[track]);
  379. if ((eta_bin == -1) || (pt_bin == -1))
  380. continue;
  381. if (mother_ID_mc[track] > -1)
  382. continue;
  383. //~ | | (_) | | / _|| | | |
  384. //~ | |__ _ ___ | |_ ___ __ _ _ __ __ _ _ __ ___ ___ __ _ | |_ | |_ ___ _ __ ___ _ _ | |_ ___
  385. //~ | '_ \ | |/ __|| __|/ _ \ / _` || '__|/ _` || '_ ` _ \ / __| / _` || _|| __|/ _ \| '__| / __|| | | || __|/ __|
  386. //~ | | | || |\__ \| |_| (_) || (_| || | | (_| || | | | | |\__ \ | (_| || | | |_| __/| | | (__ | |_| || |_ \__ \
  387. //~ |_| |_||_||___/ \__|\___/ \__, ||_| \__,_||_| |_| |_||___/ \__,_||_| \__|\___||_| \___| \__,_| \__||___/
  388. //~ __/ |
  389. //~ |___/
  390. sort = 0;
  391. h_phi_mc_after[cenrality_bin_res][0]->Fill(ATan2(px_mc[track], py_mc[track]),wB);
  392. h_eta_mc_after[cenrality_bin_res][0]->Fill(eta_mc[track],wB);
  393. h_pt_mc_after[cenrality_bin_res][0]->Fill(pt_mc[track],wB);
  394. switch (PDG_code_mc[track])
  395. {
  396. case 211:
  397. sort = 1;
  398. break;
  399. case 2212:
  400. sort = 2;
  401. break;
  402. case 321:
  403. sort = 3;
  404. break;
  405. default:
  406. break;
  407. }
  408. if ((sort == 1) || (sort == 2) || (sort == 3))
  409. {
  410. h_phi_mc_after[cenrality_bin_res][sort]->Fill(ATan2(px_mc[track], py_mc[track]),wB);
  411. h_eta_mc_after[cenrality_bin_res][sort]->Fill(eta_mc[track],wB);
  412. h_pt_mc_after[cenrality_bin_res][sort]->Fill(pt_mc[track],wB);
  413. }
  414. }
  415. int ep_particle_count = 0, multiplicity_tpc_after = 0;
  416. for (Long64_t track = 0; track < n_tracks_mpd; ++track) //loop over mpdtracks
  417. {
  418. //~ _ _ _ _ __ _
  419. //~ | | (_)| | | | / _| | |
  420. //~ | |__ _ | |_ ___ __ _ _ __ __ _ _ __ ___ ___ | |__ ___ | |_ ___ _ __ ___ ___ _ _ | |_ ___
  421. //~ | '_ \ | || __|/ _ \ / _` || '__|/ _` || '_ ` _ \ / __| | '_ \ / _ \| _|/ _ \ | '__|/ _ \ / __|| | | || __|/ __|
  422. //~ | | | || || |_| (_) || (_| || | | (_| || | | | | |\__ \ | |_) || __/| | | (_) || | | __/ | (__ | |_| || |_ \__ \
  423. //~ |_| |_||_| \__|\___/ \__, ||_| \__,_||_| |_| |_||___/ |_.__/ \___||_| \___/ |_| \___| \___| \__,_| \__||___/
  424. //~ __/ |
  425. //~ |___/
  426. Int_t pt_bin = GetPtBin(Abs(signed_pt_mpd[track]));
  427. Int_t eta_bin = GetEtaBin(eta_mpd[track]);
  428. h_DCA_all[0][pt_bin][eta_bin]->Fill(DCA_x_mpd[track],wB);
  429. h_DCA_all[1][pt_bin][eta_bin]->Fill(DCA_y_mpd[track],wB);
  430. h_DCA_all[2][pt_bin][eta_bin]->Fill(DCA_z_mpd[track],wB);
  431. if (mother_ID_mc[id_from_mc_mpd[track]] == -1)
  432. {
  433. h_DCA_primary[0][pt_bin][eta_bin]->Fill(DCA_x_mpd[track],wB);
  434. h_DCA_primary[1][pt_bin][eta_bin]->Fill(DCA_y_mpd[track],wB);
  435. h_DCA_primary[2][pt_bin][eta_bin]->Fill(DCA_z_mpd[track],wB);
  436. }
  437. else if (mother_ID_mc[id_from_mc_mpd[track]] > -1)
  438. {
  439. h_DCA_secondary[0][pt_bin][eta_bin]->Fill(DCA_x_mpd[track],wB);
  440. h_DCA_secondary[1][pt_bin][eta_bin]->Fill(DCA_y_mpd[track],wB);
  441. h_DCA_secondary[2][pt_bin][eta_bin]->Fill(DCA_z_mpd[track],wB);
  442. }
  443. h_nhits_TPC->Fill(n_hits_mpd[track],wB); //number of hits in TPC per track, before eta, nhits and pt cuts, but after mother ID cut
  444. int sort = 0;
  445. h_phi[cenrality_bin_res][0]->Fill(ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])),wB);
  446. h_eta[cenrality_bin_res][0]->Fill(eta_mpd[track],wB);
  447. h_pt[cenrality_bin_res][0]->Fill(Abs(signed_pt_mpd[track]),wB);
  448. h2_pt_vs_eta[cenrality_bin_res][0]->Fill(Abs(signed_pt_mpd[track]), eta_mpd[track],wB);
  449. h2_pt_vs_phi[cenrality_bin_res][0]->Fill(Abs(signed_pt_mpd[track]), ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])),wB);
  450. h2_phi_vs_eta[cenrality_bin_res][0]->Fill(ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])), eta_mpd[track],wB);
  451. p_momenta_resolution[0]->Fill(Abs(signed_pt_mpd[track]), Abs(Abs(signed_pt_mpd[track]) - pt_mc[id_from_mc_mpd[track]]) / Abs(signed_pt_mpd[track]),wB);
  452. switch (PDG_code_mc[id_from_mc_mpd[track]])
  453. {
  454. case 211:
  455. sort = 1;
  456. break;
  457. case 2212:
  458. sort = 2;
  459. break;
  460. case 321:
  461. sort = 3;
  462. break;
  463. default:
  464. break;
  465. }
  466. /*if (pid_tpc_prob_pion_mpd[track] > 0.9 &&
  467. pid_tpc_prob_kaon_mpd[track] < 0.1 &&
  468. pid_tpc_prob_proton_mpd[track] < 0.1) sort = 1;
  469. if (pid_tpc_prob_pion_mpd[track] < 0.1 &&
  470. pid_tpc_prob_kaon_mpd[track] > 0.9 &&
  471. pid_tpc_prob_proton_mpd[track] < 0.1) sort = 3;
  472. if (pid_tpc_prob_pion_mpd[track] < 0.1 &&
  473. pid_tpc_prob_kaon_mpd[track] < 0.1 &&
  474. pid_tpc_prob_proton_mpd[track] > 0.9) sort = 2;
  475. if (signed_pt_mpd[track] >= 0 ) continue; // Only positively charged particles being selected
  476. if (TOF_flag_mpd[track] == 0) continue; // Only tracks with TOF hits being selected
  477. if (TOF_flag_mpd[track] == 4) continue; // Only tracks with TOF hits being selected*/
  478. if ((sort == 1) || (sort == 2) || (sort == 3))
  479. {
  480. h_phi[cenrality_bin_res][sort]->Fill(ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])),wB);
  481. h_eta[cenrality_bin_res][sort]->Fill(eta_mpd[track],wB);
  482. h_pt[cenrality_bin_res][sort]->Fill(Abs(signed_pt_mpd[track]),wB);
  483. h2_pt_vs_eta[cenrality_bin_res][sort]->Fill(Abs(signed_pt_mpd[track]), eta_mpd[track],wB);
  484. h2_pt_vs_phi[cenrality_bin_res][sort]->Fill(Abs(signed_pt_mpd[track]), ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])),wB);
  485. h2_phi_vs_eta[cenrality_bin_res][sort]->Fill(ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])), eta_mpd[track],wB);
  486. p_momenta_resolution[sort]->Fill(Abs(signed_pt_mpd[track]), Abs(Abs(signed_pt_mpd[track]) - pt_mc[id_from_mc_mpd[track]]) / Abs(signed_pt_mpd[track]),wB);
  487. }
  488. //~ | |
  489. //~ ___ _ _ | |_ ___
  490. //~ / __|| | | || __|/ __|
  491. //~ | (__ | |_| || |_ \__ \
  492. //~ \___| \__,_| \__||___/
  493. //if (id_from_mc_mpd[track] == -1) continue; //equivalent to mother id cut
  494. pt_bin = GetPtBin(Abs(signed_pt_mpd[track]));
  495. eta_bin = GetEtaBin(eta_mpd[track]);
  496. if ((eta_bin == -1) || (pt_bin == -1))
  497. continue;
  498. if (n_hits_mpd[track] < Cut_No_Of_hits_min)
  499. continue; //n hits in TPC per track cut
  500. //if (TMath::Abs(DCA_x_mpd[track]) >= f_dca[0][pt_bin][eta_bin]->GetParameter(2)*2) continue;
  501. //if (TMath::Abs(DCA_y_mpd[track]) >= f_dca[1][pt_bin][eta_bin]->GetParameter(2)*2) continue;
  502. //if (TMath::Abs(DCA_z_mpd[track]) >= f_dca[2][pt_bin][eta_bin]->GetParameter(2)*2) continue;
  503. TF1 sigma_fit_res_X = *f_pt_fit[0][eta_bin];
  504. TF1 sigma_fit_res_Y = *f_pt_fit[1][eta_bin];
  505. TF1 sigma_fit_res_Z = *f_pt_fit[2][eta_bin];
  506. if (TMath::Abs(DCA_x_mpd[track]) >= sigma_fit_res_X(Abs(signed_pt_mpd[track])) * 2)
  507. continue;
  508. if (TMath::Abs(DCA_y_mpd[track]) >= sigma_fit_res_Y(Abs(signed_pt_mpd[track])) * 2)
  509. continue;
  510. if (TMath::Abs(DCA_z_mpd[track]) >= sigma_fit_res_Z(Abs(signed_pt_mpd[track])) * 2)
  511. continue;
  512. //if (mother_ID_mc[id_from_mc_mpd[track]] > -1) continue;
  513. //~ | | (_) | | / _|| | | |
  514. //~ | |__ _ ___ | |_ ___ __ _ _ __ __ _ _ __ ___ ___ __ _ | |_ | |_ ___ _ __ ___ _ _ | |_ ___
  515. //~ | '_ \ | |/ __|| __|/ _ \ / _` || '__|/ _` || '_ ` _ \ / __| / _` || _|| __|/ _ \| '__| / __|| | | || __|/ __|
  516. //~ | | | || |\__ \| |_| (_) || (_| || | | (_| || | | | | |\__ \ | (_| || | | |_| __/| | | (__ | |_| || |_ \__ \
  517. //~ |_| |_||_||___/ \__|\___/ \__, ||_| \__,_||_| |_| |_||___/ \__,_||_| \__|\___||_| \___| \__,_| \__||___/
  518. //~ __/ |
  519. //~ |___/
  520. h_nhits_TPC_after->Fill(n_hits_mpd[track],wB); //n hits in TPC after eta, nhits, pt and mother ID cuts
  521. multiplicity_tpc_after++; //multiplicity in TPC after eta, nhits, pt and mother ID cuts
  522. sort = 0;
  523. //filling some distributions after track cuts, depending on sort of the particle from MC data
  524. h_phi_after[cenrality_bin_res][0]->Fill(ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])),wB);
  525. h_eta_after[cenrality_bin_res][0]->Fill(eta_mpd[track],wB);
  526. h_pt_after[cenrality_bin_res][0]->Fill(Abs(signed_pt_mpd[track]),wB);
  527. h2_pt_vs_eta_after[cenrality_bin_res][0]->Fill(Abs(signed_pt_mpd[track]), eta_mpd[track],wB);
  528. h2_pt_vs_phi_after[cenrality_bin_res][0]->Fill(Abs(signed_pt_mpd[track]), ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])),wB);
  529. h2_phi_vs_eta_after[cenrality_bin_res][0]->Fill(ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])), eta_mpd[track],wB);
  530. //~ p_momenta_resolution[0]->Fill(Abs(signed_pt_mpd[track]),Abs(Abs(signed_pt_mpd[track]) - pt_mc[id_from_mc_mpd[track]])
  531. //~ /Abs(signed_pt_mpd[track]));
  532. switch (PDG_code_mc[id_from_mc_mpd[track]])
  533. {
  534. case 211:
  535. sort = 1;
  536. break;
  537. case 2212:
  538. sort = 2;
  539. break;
  540. case 321:
  541. sort = 3;
  542. break;
  543. default:
  544. break;
  545. }
  546. /*if (pid_tpc_prob_pion_mpd[track] > 0.9 &&
  547. pid_tpc_prob_kaon_mpd[track] < 0.1 &&
  548. pid_tpc_prob_proton_mpd[track] < 0.1) sort = 1;
  549. if (pid_tpc_prob_pion_mpd[track] < 0.1 &&
  550. pid_tpc_prob_kaon_mpd[track] > 0.9 &&
  551. pid_tpc_prob_proton_mpd[track] < 0.1) sort = 3;
  552. if (pid_tpc_prob_pion_mpd[track] < 0.1 &&
  553. pid_tpc_prob_kaon_mpd[track] < 0.1 &&
  554. pid_tpc_prob_proton_mpd[track] > 0.9) sort = 2;
  555. if (signed_pt_mpd[track] >= 0 ) continue; // Only positively charged particles being selected
  556. if (TOF_flag_mpd[track] == 0) continue; // Only tracks with TOF hits being selected
  557. if (TOF_flag_mpd[track] == 4) continue; // Only tracks with TOF hits being selected*/
  558. if ((sort == 1) || (sort == 2) || (sort == 3))
  559. {
  560. h_phi_after[cenrality_bin_res][sort]->Fill(ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])),wB);
  561. h_eta_after[cenrality_bin_res][sort]->Fill(eta_mpd[track],wB);
  562. h_pt_after[cenrality_bin_res][sort]->Fill(Abs(signed_pt_mpd[track]),wB);
  563. h2_pt_vs_eta_after[cenrality_bin_res][sort]->Fill(Abs(signed_pt_mpd[track]), eta_mpd[track],wB);
  564. h2_pt_vs_phi_after[cenrality_bin_res][sort]->Fill(Abs(signed_pt_mpd[track]), ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])),wB);
  565. h2_phi_vs_eta_after[cenrality_bin_res][sort]->Fill(ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track])), eta_mpd[track],wB);
  566. //~ p_momenta_resolution[sort]->Fill(Abs(signed_pt_mpd[track]),Abs(Abs(signed_pt_mpd[track]) - pt_mc[id_from_mc_mpd[track]])
  567. //~ /Abs(signed_pt_mpd[track]));
  568. }
  569. //~ if (Abs(eta_mpd[track]) > Cut_Eta_Min) //and finally, the resolution gap eta cut, then filling the buffer of EP particles:
  570. //~ {
  571. event_plane_buffer[ep_particle_count].Pt = Abs(signed_pt_mpd[track]);
  572. event_plane_buffer[ep_particle_count].Eta = eta_mpd[track];
  573. event_plane_buffer[ep_particle_count].Phi = ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track]));
  574. ep_particle_count++;
  575. //~ }
  576. }
  577. h_multiplicity->Fill(multiplicity_tpc_after,wB); //filling multiplicity TPC after cuts hitsogram, now that the loop over mpd tracks is over
  578. for (int arm = 0; arm < _N_ARM; ++arm)
  579. {
  580. h_energy_ZDC_total[arm]->Fill(GetTotalEnergy(ZDC_energy_mpd, arm),wB); //filling the total ZDC energy for given event
  581. h2_energy_ZDC_vs_multiplicity[arm]->Fill(GetTotalEnergy(ZDC_energy_mpd, arm), multiplicity_tpc_after,wB); //filling total ZDC energy vs TPC
  582. //multiplicity after cuts for a given event
  583. }
  584. p_b_vs_energy->Fill(GetTotalEnergy(ZDC_energy_mpd, 0) + GetTotalEnergy(ZDC_energy_mpd, 1), b_mc,wB);
  585. h2_b_vs_energy->Fill(GetTotalEnergy(ZDC_energy_mpd, 0) + GetTotalEnergy(ZDC_energy_mpd, 1), b_mc,wB);
  586. h2_energyZDC_L_vs_energy_ZDC_R->Fill(GetTotalEnergy(ZDC_energy_mpd, 0), GetTotalEnergy(ZDC_energy_mpd, 1),wB); //filling ZDC energy L vs R for a given event
  587. int multiplicity_R = 0, multiplicity_L = 0;
  588. for (int ep_particle = 0; ep_particle < ep_particle_count; ++ep_particle) //TPC subevent multiplicity after cuts
  589. {
  590. if (event_plane_buffer[ep_particle].Eta > 0)
  591. multiplicity_R++;
  592. else if (event_plane_buffer[ep_particle].Eta < 0)
  593. multiplicity_L++;
  594. }
  595. //calculate the EP resolution using TPC if subevents have enough multipllicity
  596. if ((multiplicity_L >= 4) && (multiplicity_R >= 4))
  597. FillTPC(cenrality_bin_res, event_plane_buffer, ep_particle_count,wB);
  598. //if both ZDCs have some signal then calculate EP resolutions using ZDC
  599. if ((GetTotalEnergy(ZDC_energy_mpd, 0) != 0) && (GetTotalEnergy(ZDC_energy_mpd, 1) != 0))
  600. FillZDC(cenrality_bin_res, ZDC_energy_mpd,wB);
  601. }
  602. return;
  603. }
  604. //~ __ _
  605. //~ / _|| |
  606. //~ | |_ | | ___ __ __
  607. //~ | _|| | / _ \\ \ /\ / /
  608. //~ | | | || (_) |\ V V /
  609. //~ |_| |_| \___/ \_/\_/
  610. void MpdCalculator::CalculateFlow(Int_t nevents, TString fitFile)
  611. {
  612. TFile *f = new TFile(fitFile.Data()); //opening file with fit data
  613. TF1 *resolution_fit[_N_HARM][_N_HARM][_N_METHOD]; //declaring the fit-function array
  614. for (int harm = 0; harm < _N_HARM; ++harm)
  615. {
  616. for (int _harm = 0; _harm < _N_HARM; ++_harm)
  617. {
  618. for (int method = 0; method < _N_METHOD; ++method)
  619. {
  620. char name[200];
  621. sprintf(name, "resolution_fit[%i][%i][%i]", harm, _harm, method);
  622. resolution_fit[harm][_harm][method] = (TF1 *)f->Get(name); //reading fit-functions from file
  623. }
  624. }
  625. }
  626. const Float_t dB = 0.25;
  627. Float_t B,wB;
  628. if (nevents == 0)
  629. nevents = inChain->GetEntries();
  630. for (Int_t event = 0; event < nevents; ++event) //loop over events
  631. {
  632. inChain->GetEntry(event); //reading all branches for a given event
  633. cout << "FLOW EVENT # " << event << endl;
  634. B = b_mc;
  635. wB = 2*TMath::Pi()*B*dB;
  636. //Int_t multiplicity = GetMultiplicityTPC();
  637. centrality_tpc_mpd = 100 - centrality_tpc_mpd;
  638. int cenrality_bin_flow = GetCentralityBinFlow(centrality_tpc_mpd); //getting b bin of a given event for flow measurements
  639. //if (cenrality_bin_flow == -1) continue;
  640. int cenrality_bin_res = GetCentralityBinRes(centrality_tpc_mpd); //getting the resolution bin in whic the event is
  641. if (cenrality_bin_res == -1)
  642. continue; // just in case...
  643. //skip the event if the ZDC signal is zero
  644. if ((GetTotalEnergy(ZDC_energy_mpd, 0) == 0) || (GetTotalEnergy(ZDC_energy_mpd, 1) == 0))
  645. continue;
  646. Double_t phi_EP = ATan2(Sin(phiEP_mc), Cos(phiEP_mc)); //unfold the generated event plane
  647. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  648. //RECONSTRUCTED
  649. const Float_t p_mass2[] = {0.88035, 0.2437, 0.01948};
  650. const Int_t pdg_codes[] = {2212, 321, 211}; //0 - PROTON, 1 - KAON, 2 -PION
  651. Bool_t isPion, isKaon, isProton;
  652. // ______ _ _____
  653. // | ___ \ | | | __ \
  654. // | |__| | | | | | \ |
  655. // | ____/ | | | | | |
  656. // | | | | | |__/ |
  657. // |_| |_| |_____/
  658. Int_t sort = 0; // 0 -proton; 1 - kaon; 2 - pion;
  659. for (Long64_t track = 0; track < n_tracks_mpd; ++track) //loop over reconstructed tracks to fill flow buffer
  660. {
  661. isPion = kFALSE;
  662. isKaon = kFALSE;
  663. isProton = kFALSE;
  664. //if (id_from_mc_mpd[track] == -1) continue; //equivalent to mother ID cut
  665. if (n_hits_mpd[track] < Cut_No_Of_hits_min)
  666. continue; //n hits in TPC cut
  667. if (PDG_code_mc[id_from_mc_mpd[track]] != pdg_codes[sort])
  668. continue;
  669. Float_t Pt = Abs(signed_pt_mpd[track]);
  670. Float_t Eta = eta_mpd[track];
  671. Float_t Phi = ATan2(Sin(phi_mpd[track]), Cos(phi_mpd[track]));
  672. //~ Float_t Rapidity = 0.5*TMath::Log((energy_mc[id_from_mc_mpd[track]] + pz_mc[id_from_mc_mpd[track]])
  673. //~ /(energy_mc[id_from_mc_mpd[track]] - pz_mc[id_from_mc_mpd[track]]));
  674. Int_t pt_bin = GetPtBin(Pt);
  675. Int_t eta_bin = GetEtaBin(Eta);
  676. if ((eta_bin == -1) || (pt_bin == -1))
  677. continue;
  678. //if (TMath::Abs(DCA_x_mpd[track]) >= f_dca[0][pt_bin][eta_bin]->GetParameter(2)*2) continue;
  679. //if (TMath::Abs(DCA_y_mpd[track]) >= f_dca[1][pt_bin][eta_bin]->GetParameter(2)*2) continue;
  680. //if (TMath::Abs(DCA_z_mpd[track]) >= f_dca[2][pt_bin][eta_bin]->GetParameter(2)*2) continue;
  681. TF1 sigma_fit_X = *f_pt_fit[0][eta_bin];
  682. TF1 sigma_fit_Y = *f_pt_fit[1][eta_bin];
  683. TF1 sigma_fit_Z = *f_pt_fit[2][eta_bin];
  684. if (TMath::Abs(DCA_x_mpd[track]) >= sigma_fit_X(Pt) * 2)
  685. continue;
  686. if (TMath::Abs(DCA_y_mpd[track]) >= sigma_fit_Y(Pt) * 2)
  687. continue;
  688. if (TMath::Abs(DCA_z_mpd[track]) >= sigma_fit_Z(Pt) * 2)
  689. continue;
  690. /*if (pid_tpc_prob_pion_mpd[track] > 0.9 &&
  691. pid_tpc_prob_kaon_mpd[track] < 0.1 &&
  692. pid_tpc_prob_proton_mpd[track] < 0.1) isPion = kTRUE;
  693. if (pid_tpc_prob_pion_mpd[track] < 0.1 &&
  694. pid_tpc_prob_kaon_mpd[track] > 0.9 &&
  695. pid_tpc_prob_proton_mpd[track] < 0.1) isKaon = kTRUE;
  696. if (pid_tpc_prob_pion_mpd[track] < 0.1 &&
  697. pid_tpc_prob_kaon_mpd[track] < 0.1 &&
  698. pid_tpc_prob_proton_mpd[track] > 0.9) isProton = kTRUE;
  699. if (signed_pt_mpd[track] >= 0 ) continue; // Only positively charged particles being selected
  700. if (TOF_flag_mpd[track] == 0) continue; // Only tracks with TOF hits being selected
  701. if (TOF_flag_mpd[track] == 4) continue; // Only tracks with TOF hits being selected
  702. if (sort == 0 && !isProton) continue;
  703. if (sort == 1 && !isKaon) continue;
  704. if (sort == 2 && !isPion) continue;*/
  705. Float_t Rapidity = TMath::Log((TMath::Sqrt(p_mass2[sort] + Pt * Pt * TMath::CosH(Eta) * TMath::CosH(Eta)) + Pt * TMath::SinH(Eta)) / (TMath::Sqrt(p_mass2[sort] + Pt * Pt)));
  706. Double_t Psi_1_FULL_ZDC = GetPsiFullZdc(ZDC_energy_mpd, 1); //getting event plane using ZDC for 1st harmonic
  707. Float_t Pt_MC = Abs(pt_mc[id_from_mc_mpd[track]]);
  708. Float_t Eta_MC = eta_mc[id_from_mc_mpd[track]];
  709. Float_t Phi_MC = ATan2(py_mc[id_from_mc_mpd[track]], px_mc[id_from_mc_mpd[track]]);
  710. Float_t Rapidity_MC = TMath::Log((TMath::Sqrt(p_mass2[sort] + Pt_MC * Pt_MC * TMath::CosH(Eta_MC) * TMath::CosH(Eta_MC)) + Pt_MC * TMath::SinH(Eta_MC)) / (TMath::Sqrt(p_mass2[sort] + Pt_MC * Pt_MC)));
  711. int sign;
  712. if (Eta < 0)
  713. sign = -1;
  714. else
  715. sign = 1;
  716. TF1 res11 = *resolution_fit[0][0][1];
  717. Float_t mid_bin_cent = (centralityBinsRes[cenrality_bin_res] + centralityBinsRes[cenrality_bin_res + 1]) / 2;
  718. if (res11(mid_bin_cent) != 0)
  719. {
  720. if (cenrality_bin_flow != -1)
  721. {
  722. if ((Abs(Rapidity) > 0.2) && (Abs(Rapidity) < Cut_Eta_Max))
  723. {
  724. p_flow_wrt_full_vs_pt_divided[cenrality_bin_flow][0][0][1]->Fill(Pt, sign * Cos(Psi_1_FULL_ZDC - Phi) / res11(mid_bin_cent),wB);
  725. p_flow_wrt_RP_vs_pt[cenrality_bin_flow][0]->Fill(Pt, sign * Cos(phi_EP - Phi_MC),wB);
  726. }
  727. //if (Pt > Cut_Pt_Min)
  728. p_flow_wrt_full_vs_eta_divided[cenrality_bin_flow][0][0][1]->Fill(Eta, Cos(Psi_1_FULL_ZDC - Phi) / res11(mid_bin_cent),wB);
  729. p_flow_wrt_RP_vs_eta[cenrality_bin_flow][0]->Fill(Eta, Cos(phi_EP - Phi_MC),wB);
  730. //if ((Abs(Eta) < Cut_Eta_Max) && (Pt > Cut_Pt_Min))
  731. p_flow_wrt_full_vs_rapidity_divided[cenrality_bin_flow][0][0][1]->Fill(Rapidity, Cos(Psi_1_FULL_ZDC - Phi) / res11(mid_bin_cent),wB);
  732. p_flow_wrt_RP_vs_rapidity[cenrality_bin_flow][0]->Fill(Rapidity, Cos(phi_EP - Phi_MC),wB);
  733. }
  734. //cout << "filling with centralityBinsRes[cenrality_bin_res] = " << centralityBinsRes[cenrality_bin_res] << " Cos(Psi_1_FULL_ZDC - Phi)/res11(mid_bin_cent) = " << Cos(Psi_1_FULL_ZDC - Phi)/res11(mid_bin_cent) << endl;
  735. //if ((Abs(Eta) < Cut_Eta_Max) && (Pt > Cut_Pt_Min))
  736. p_flow_wrt_full_vs_centrality_divided[0][0][1]->Fill(centralityBinsRes[cenrality_bin_res] + 0.1, sign * Cos(Psi_1_FULL_ZDC - Phi) / res11(mid_bin_cent),wB);
  737. p_flow_wrt_RP_vs_centrality[0]->Fill(centralityBinsRes[cenrality_bin_res] + 0.1, sign * Cos(phi_EP - Phi_MC),wB);
  738. }
  739. TF1 res21 = *resolution_fit[1][0][1];
  740. if (res21(mid_bin_cent) != 0)
  741. {
  742. if (cenrality_bin_flow != -1)
  743. {
  744. //if (Abs(Eta) < Cut_Eta_Max)
  745. p_flow_wrt_full_vs_pt_divided[cenrality_bin_flow][1][0][1]->Fill(Pt, Cos(2. * (Psi_1_FULL_ZDC - Phi)) / res21(mid_bin_cent),wB);
  746. p_flow_wrt_RP_vs_pt[cenrality_bin_flow][1]->Fill(Pt, Cos(2. * (phi_EP - Phi_MC)),wB);
  747. //if (Pt > Cut_Pt_Min)
  748. p_flow_wrt_full_vs_eta_divided[cenrality_bin_flow][1][0][1]->Fill(Eta, Cos(2. * (Psi_1_FULL_ZDC - Phi)) / res21(mid_bin_cent),wB);
  749. p_flow_wrt_RP_vs_eta[cenrality_bin_flow][1]->Fill(Eta, Cos(2. * (phi_EP - Phi_MC)),wB);
  750. //if ((Abs(Eta) < Cut_Eta_Max) && (Pt > Cut_Pt_Min))
  751. p_flow_wrt_full_vs_rapidity_divided[cenrality_bin_flow][1][0][1]->Fill(Rapidity, Cos(2. * (Psi_1_FULL_ZDC - Phi)) / res21(mid_bin_cent),wB);
  752. p_flow_wrt_RP_vs_rapidity[cenrality_bin_flow][1]->Fill(Rapidity, Cos(2. * (phi_EP - Phi_MC)),wB);
  753. }
  754. //if ((Abs(Eta) < Cut_Eta_Max) && (Pt > Cut_Pt_Min))
  755. p_flow_wrt_full_vs_centrality_divided[1][0][1]->Fill(centralityBinsRes[cenrality_bin_res] + 0.1, Cos(2. * (Psi_1_FULL_ZDC - Phi)) / res21(mid_bin_cent),wB);
  756. p_flow_wrt_RP_vs_centrality[1]->Fill(centralityBinsRes[cenrality_bin_res] + 0.1, Cos(2. * (phi_EP - Phi_MC)),wB);
  757. }
  758. }
  759. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  760. //GENERATED
  761. /* for (Long64_t track = 0; track < n_tracks_mc; ++track)
  762. {
  763. if (PDG_code_mc[track] != pdg_codes[sort]) continue;
  764. Float_t Pt = Abs(pt_mc[track]);
  765. Float_t Eta = eta_mc[track];
  766. Float_t Phi = ATan2(py_mc[track],px_mc[track]);
  767. Float_t Rapidity = .5*TMath::Log((energy_mc[track] + pz_mc[track])/(energy_mc[track] - pz_mc[track]));
  768. Int_t pt_bin = GetPtBin(Pt);
  769. Int_t eta_bin = GetEtaBin(Eta);
  770. if ( (eta_bin == -1) || (pt_bin == -1 )) continue;
  771. if (mother_ID_mc[track] > -1 ) continue;
  772. int sign;
  773. if (Eta < 0) sign = -1;
  774. else sign = 1;
  775. //if ((Abs(Eta) < Cut_Eta_Max) && (Pt > Cut_Pt_Min))
  776. //{
  777. p_flow_wrt_RP_vs_centrality[0]->Fill(centralityBinsRes[cenrality_bin_res] + 0.1, sign*Cos(phi_EP - Phi));
  778. //cout << "Filling with centralityBinsRes[cenrality_bin_res] + 0.1 = " << centralityBinsRes[cenrality_bin_res] + 0.1 << "Cos(phi_EP - Phi) = " << Cos(phi_EP - Phi) << endl;
  779. p_flow_wrt_RP_vs_centrality[1]->Fill(centralityBinsRes[cenrality_bin_res] + 0.1, Cos(2.*(phi_EP - Phi)));
  780. //}
  781. if (cenrality_bin_flow != -1)
  782. {
  783. if ((Abs(Eta) > 0.2) && (Abs(Eta) < Cut_Eta_Max))
  784. p_flow_wrt_RP_vs_pt[cenrality_bin_flow][0]->Fill(Pt , sign*Cos(phi_EP - Phi));
  785. //if (Abs(Eta) < Cut_Eta_Max)
  786. p_flow_wrt_RP_vs_pt[cenrality_bin_flow][1]->Fill(Pt , Cos(2.*(phi_EP-Phi)));
  787. //if ((Abs(Eta) < Cut_Eta_Max) && (Pt > Cut_Pt_Min))
  788. p_flow_wrt_RP_vs_rapidity[cenrality_bin_flow][0]->Fill(Rapidity , Cos(phi_EP - Phi));
  789. //if ((Abs(Eta) < Cut_Eta_Max) && (Pt > Cut_Pt_Min))
  790. p_flow_wrt_RP_vs_rapidity[cenrality_bin_flow][1]->Fill(Rapidity , Cos(2.*(phi_EP - Phi)));
  791. //if (Pt > Cut_Pt_Min)
  792. p_flow_wrt_RP_vs_eta[cenrality_bin_flow][0]->Fill(Eta , Cos(phi_EP - Phi));
  793. //if (Pt > Cut_Pt_Min)
  794. p_flow_wrt_RP_vs_eta[cenrality_bin_flow][1]->Fill(Eta , Cos(2.*(phi_EP - Phi)));
  795. }
  796. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  797. }*/
  798. }
  799. }
  800. void MpdCalculator::GetQsTpc(EPParticle *event_plane_buffer, Int_t buffer_size, Int_t sign, Int_t harm, Double_t &Qx, Double_t &Qy)
  801. {
  802. Double_t Qcos = 0., Qsin = 0., total_momenta = 0;
  803. total_momenta = GetTotalMomenta(event_plane_buffer, buffer_size, sign);
  804. Int_t w_sign = 0;
  805. if (harm == 2)
  806. w_sign = 1;
  807. else
  808. w_sign = sign;
  809. for (int ep_particle = 0; ep_particle < buffer_size; ++ep_particle)
  810. {
  811. if (!(event_plane_buffer[ep_particle].Eta * sign > 0))
  812. continue;
  813. Qcos += w_sign * event_plane_buffer[ep_particle].Pt / total_momenta * Cos(harm * event_plane_buffer[ep_particle].Phi);
  814. Qsin += w_sign * event_plane_buffer[ep_particle].Pt / total_momenta * Sin(harm * event_plane_buffer[ep_particle].Phi);
  815. }
  816. Qx = Qcos;
  817. Qy = Qsin;
  818. }
  819. void MpdCalculator::GetQsZdc(Float_t *zdc_energy, Int_t zdc_ID, Int_t harm, Double_t &Qx, Double_t &Qy)
  820. {
  821. Double_t *phi_angle_of_modules = GetAngles();
  822. Double_t Qcos = 0, Qsin = 0;
  823. Double_t w_sign = 0;
  824. Double_t total_energy = GetTotalEnergy(zdc_energy, zdc_ID);
  825. if (harm == 2)
  826. w_sign = 1;
  827. else if (harm == 1)
  828. {
  829. if (zdc_ID == 0)
  830. w_sign = 1;
  831. else if (zdc_ID == 1)
  832. w_sign = -1;
  833. }
  834. for (int module = _N_MODULES_TOTAL / 2 * zdc_ID; module < _N_MODULES_TOTAL / 2 * (zdc_ID + 1); ++module)
  835. {
  836. if ((module == 22) || (module == 67))
  837. continue;
  838. // if ((i ==15)||(i ==21)||(i==23)||(i ==29)||(i==60)||
  839. // (i==66)||(i==68)||(i==74)) continue;
  840. Qcos += w_sign * zdc_energy[module] / total_energy * Cos(harm * phi_angle_of_modules[module]);
  841. Qsin += w_sign * zdc_energy[module] / total_energy * Sin(harm * phi_angle_of_modules[module]);
  842. }
  843. Qx = Qcos;
  844. Qy = Qsin;
  845. }
  846. Double_t MpdCalculator::GetPsiHalfTpc(EPParticle *event_plane_buffer, Int_t buffer_size, Int_t sign, Int_t harm, Double_t &Qx, Double_t &Qy) //if sign == 1 then its positive pseudorapidity and all weights are positive,
  847. {
  848. GetQsTpc(event_plane_buffer, buffer_size, sign, harm, Qx, Qy);
  849. Double_t PsiEP = (1 / (Double_t)harm) * ATan2(Qx, Qy);
  850. return PsiEP;
  851. }
  852. Double_t MpdCalculator::GetPsiHalfZdc(Float_t *zdc_energy, Int_t zdc_ID, Int_t n, Double_t &qx, Double_t &qy)
  853. {
  854. Double_t Qcos = 0., Qsin = 0.;
  855. GetQsZdc(zdc_energy, zdc_ID, n, Qcos, Qsin);
  856. qx = Qcos;
  857. qy = Qsin;
  858. Double_t PsiEP = (1 / (Double_t)n) * ATan2(Qsin, Qcos);
  859. return PsiEP;
  860. }
  861. Double_t MpdCalculator::GetPsiFullZdc(Float_t *zdc_energy, Int_t n)
  862. {
  863. Double_t QcosR = 0., QsinR = 0.;
  864. GetQsZdc(zdc_energy, 0, n, QcosR, QsinR);
  865. Double_t QcosL = 0., QsinL = 0.;
  866. GetQsZdc(zdc_energy, 1, n, QcosL, QsinL);
  867. Double_t psiEP = ATan2(QsinR + QsinL, QcosR + QcosL) / (Double_t)n; // (-pi/n,pi/n]
  868. return psiEP;
  869. }
  870. Double_t MpdCalculator::GetTotalMomenta(EPParticle *event_plane_buffer, Int_t buffer_size, Int_t sign)
  871. {
  872. Double_t total_momenta = 0.;
  873. for (int ep_particle = 0; ep_particle < buffer_size; ++ep_particle)
  874. {
  875. if (!(event_plane_buffer[ep_particle].Eta * sign > 0))
  876. continue;
  877. total_momenta += event_plane_buffer[ep_particle].Pt;
  878. }
  879. return total_momenta;
  880. }
  881. Double_t MpdCalculator::GetTotalEnergy(Float_t *zdc_energy, Int_t zdc_ID)
  882. {
  883. Double_t total_energy = 0.;
  884. for (int i = _N_MODULES_TOTAL / 2 * zdc_ID; i < _N_MODULES_TOTAL / 2 * (zdc_ID + 1); ++i)
  885. {
  886. if ((i == 22) || (i == 67))
  887. continue;
  888. // if ((i ==15)||(i ==21)||(i==23)||(i ==29)||(i==60)||
  889. // (i==66)||(i==68)||(i==74)) continue;
  890. total_energy += zdc_energy[i];
  891. }
  892. return total_energy;
  893. }
  894. Double_t MpdCalculator::GetPsiFullTpc(EPParticle *event_plane_buffer, Int_t buffer_size, Int_t harm)
  895. {
  896. Double_t QcosR = 0., QsinR = 0.;
  897. GetQsTpc(event_plane_buffer, buffer_size, 1, harm, QcosR, QsinR);
  898. Double_t QcosL = 0., QsinL = 0.;
  899. GetQsTpc(event_plane_buffer, buffer_size, -1, harm, QcosL, QsinL);
  900. Double_t psiEP = ATan2(QsinR + QsinL, QcosR + QcosL) / (Double_t)harm; // (-pi/n,pi/n]
  901. return psiEP;
  902. }
  903. //~ _ _
  904. //~ (_)| |
  905. //~ __ __ _ __ _ | |_ ___
  906. //~ \ \ /\ / /| '__|| || __|/ _ \
  907. //~ \ V V / | | | || |_| __/
  908. //~ \_/\_/ |_| |_| \__|\___|
  909. void MpdCalculator::Write()
  910. {
  911. outFile->cd();
  912. h_nhits_TPC->Write();
  913. h_nhits_TPC_after->Write();
  914. h_impact_parameter->Write();
  915. h_multiplicity->Write();
  916. h_multiplicity_before->Write();
  917. h2_energyZDC_L_vs_energy_ZDC_R->Write();
  918. p_b_vs_multiplicity->Write();
  919. p_b_vs_energy->Write();
  920. h2_b_vs_energy->Write();
  921. h2_b_vs_centrality->Write();
  922. h2_b_vs_multiplicity->Write();
  923. for (Int_t dim = 0; dim < Ndim; dim++)
  924. {
  925. for (Int_t pt_bin = 0; pt_bin < NptBins; pt_bin++)
  926. {
  927. for (Int_t eta_bin = 0; eta_bin < NetaBins; eta_bin++)
  928. {
  929. h_DCA_all[dim][pt_bin][eta_bin]->Write();
  930. h_DCA_primary[dim][pt_bin][eta_bin]->Write();
  931. h_DCA_secondary[dim][pt_bin][eta_bin]->Write();
  932. }
  933. }
  934. }
  935. for (int sort = 0; sort < _N_SORTS; ++sort)
  936. {
  937. p_momenta_resolution[sort]->Write();
  938. }
  939. for (int harm = 0; harm < _N_HARM; ++harm)
  940. {
  941. p_flow_wrt_RP_vs_centrality[harm]->Write();
  942. for (int centralityBin = 0; centralityBin < NcentralityBinsFlow; ++centralityBin)
  943. {
  944. p_flow_wrt_RP_vs_pt[centralityBin][harm]->Write();
  945. p_flow_wrt_RP_vs_eta[centralityBin][harm]->Write();
  946. p_flow_wrt_RP_vs_rapidity[centralityBin][harm]->Write();
  947. }
  948. for (int method = 0; method < _N_METHOD; ++method)
  949. {
  950. for (int _harm = 0; _harm < _N_HARM; ++_harm)
  951. {
  952. p_flow_wrt_full_vs_centrality[harm][_harm][method]->Write();
  953. p_flow_wrt_full_vs_centrality_divided[harm][_harm][method]->Write();
  954. p_Res2Psi_vs_b[harm][_harm][method]->Write();
  955. p_true_Res_vs_b[harm][_harm][method]->Write();
  956. for (int centralityBin = 0; centralityBin < NcentralityBinsFlow; ++centralityBin)
  957. {
  958. p_flow_wrt_full_vs_pt[centralityBin][harm][_harm][method]->Write();
  959. p_flow_wrt_full_vs_eta[centralityBin][harm][_harm][method]->Write();
  960. p_flow_wrt_full_vs_rapidity[centralityBin][harm][_harm][method]->Write();
  961. p_flow_wrt_full_vs_pt_divided[centralityBin][harm][_harm][method]->Write();
  962. p_flow_wrt_full_vs_eta_divided[centralityBin][harm][_harm][method]->Write();
  963. p_flow_wrt_full_vs_rapidity_divided[centralityBin][harm][_harm][method]->Write();
  964. }
  965. }
  966. }
  967. }
  968. for (int arm = 0; arm < _N_ARM; ++arm)
  969. {
  970. h_energy_ZDC_total[arm]->Write();
  971. h2_energy_ZDC_vs_multiplicity[arm]->Write();
  972. for (int harm = 0; harm < _N_HARM; ++harm)
  973. {
  974. for (int method = 0; method < _N_METHOD; ++method)
  975. {
  976. p_qx_vs_b[arm][harm][method]->Write();
  977. p_qy_vs_b[arm][harm][method]->Write();
  978. for (int _harm = 0; _harm < _N_HARM; ++_harm)
  979. {
  980. p_true_Res_half_vs_b[arm][harm][_harm][method]->Write();
  981. }
  982. }
  983. }
  984. }
  985. for (int centralityBin = 0; centralityBin < NcentralityBinsRes; ++centralityBin)
  986. {
  987. for (int sort = 0; sort < _N_SORTS; ++sort)
  988. {
  989. h_phi[centralityBin][sort]->Write();
  990. h_pt[centralityBin][sort]->Write();
  991. h_eta[centralityBin][sort]->Write();
  992. h2_pt_vs_eta[centralityBin][sort]->Write();
  993. h2_pt_vs_phi[centralityBin][sort]->Write();
  994. h2_phi_vs_eta[centralityBin][sort]->Write();
  995. h_phi_after[centralityBin][sort]->Write();
  996. h_pt_after[centralityBin][sort]->Write();
  997. h_eta_after[centralityBin][sort]->Write();
  998. h2_pt_vs_eta_after[centralityBin][sort]->Write();
  999. h2_pt_vs_phi_after[centralityBin][sort]->Write();
  1000. h2_phi_vs_eta_after[centralityBin][sort]->Write();
  1001. h_phi_mc[centralityBin][sort]->Write();
  1002. h_pt_mc[centralityBin][sort]->Write();
  1003. h_eta_mc[centralityBin][sort]->Write();
  1004. h_phi_mc_after[centralityBin][sort]->Write();
  1005. h_pt_mc_after[centralityBin][sort]->Write();
  1006. h_eta_mc_after[centralityBin][sort]->Write();
  1007. }
  1008. }
  1009. outFile->Close();
  1010. }
  1011. Int_t MpdCalculator::GetCentralityBinRes(Int_t centrality)
  1012. {
  1013. int centrality_bin = -1;
  1014. for (int c_bin = 0; c_bin < NcentralityBinsRes; ++c_bin)
  1015. {
  1016. if ((centrality > centralityBinsRes[c_bin]) && (centrality <= centralityBinsRes[c_bin + 1]))
  1017. centrality_bin = c_bin;
  1018. }
  1019. return centrality_bin;
  1020. }
  1021. Int_t MpdCalculator::GetCentralityBinFlow(Int_t centrality)
  1022. {
  1023. int centrality_bin = -1;
  1024. for (int c_bin = 0; c_bin < NcentralityBinsFlow; ++c_bin)
  1025. if ((centrality > centralityBinsFlow[c_bin]) && (centrality <= centralityBinsFlow[c_bin + 1]))
  1026. centrality_bin = c_bin;
  1027. if (centrality_bin == 1)
  1028. centrality_bin = -1;
  1029. else if (centrality_bin == 2)
  1030. centrality_bin = 1; ////////////////////PODGON!!!!
  1031. return centrality_bin;
  1032. }
  1033. Int_t MpdCalculator::GetMultiplicityTPC() //should be called in loop over events
  1034. {
  1035. Int_t multiplicity = 0;
  1036. for (Long64_t track = 0; track < n_tracks_mpd; ++track) //loop over mpdtracks, cut on mother ID will be everywhere
  1037. {
  1038. if (id_from_mc_mpd[track] == -1)
  1039. continue; //equivalent to mother id cut
  1040. multiplicity++; //multiplicity in TPC before eta, nhits and pt cuts, but after mother ID cut
  1041. }
  1042. return multiplicity;
  1043. }
  1044. int MpdCalculator::GetPtBin(Float_t pt)
  1045. {
  1046. int pt_bin = -1;
  1047. for (int i = 0; i < NptBins; ++i)
  1048. if ((pt > ptBins[i]) && (pt <= ptBins[i + 1]))
  1049. pt_bin = i;
  1050. return pt_bin;
  1051. }
  1052. int MpdCalculator::GetEtaBin(Float_t eta)
  1053. {
  1054. int eta_bin = -1;
  1055. for (int i = 0; i < NetaBins; ++i)
  1056. if ((eta > etaBins[i]) && (eta <= etaBins[i + 1]))
  1057. eta_bin = i;
  1058. return eta_bin;
  1059. }