FlowCalculator.cxx 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  1. #ifndef FLOWCALCULATOR_CXX
  2. #define FLOWCALCULATOR_CXX
  3. #include "FlowCalculator.h"
  4. #include <TMath.h>
  5. #include <TProfile.h>
  6. #include <math.h>
  7. // Function that normalizes angle to the range [0,2*pi/harmonic]
  8. Double_t NormalizeAngle(Double_t phi, Double_t harm)
  9. {
  10. phi = fmod(phi,2*TMath::Pi()/harm);
  11. if (phi < 0)
  12. phi += 2*TMath::Pi()/harm;
  13. return phi;
  14. }
  15. // Wrap angle to [-pi,pi]
  16. Double_t WrapAngle(Double_t phi, Double_t harm)
  17. {
  18. phi = fmod(phi + TMath::Pi()/harm, 2*TMath::Pi()/harm);
  19. if (phi < 0)
  20. phi += 2*TMath::Pi()/harm;
  21. return phi - TMath::Pi();
  22. }
  23. FlowCalculator::FlowCalculator(TTree *tree) : BaseReader(tree)
  24. {
  25. centCalc = new CentralityCalculator();
  26. eta_gap.push_back(0.05);
  27. eta_gap.push_back(0.1);
  28. eta_gap.push_back(0.15);
  29. eta_gap.push_back(0.25);
  30. eta_rxn.push_back({1.,2.8});
  31. eta_rxn.push_back({1.,1.5});
  32. eta_rxn.push_back({1.5,2.8});
  33. fRotate = true;
  34. fDate = new TDatime();
  35. fRnd = new TRandom3(fDate->GetDate()+fDate->GetTime());
  36. gRandom->SetSeed(fDate->GetDate()+fDate->GetTime());
  37. fPsiRP = 0.;
  38. }
  39. FlowCalculator::~FlowCalculator()
  40. {
  41. delete centCalc;
  42. eta_gap.clear();
  43. eta_rxn.clear();
  44. delete fDate;
  45. delete fRnd;
  46. }
  47. void FlowCalculator::InitCentFile(TString inName)
  48. {
  49. TFile *fi = new TFile(inName.Data(),"read");
  50. TH1F *hist = (TH1F*) fi->Get(histRefMultName.Data());
  51. centCalc->SetHistogram(hist);
  52. centCalc->SetEfficiency(0.93);
  53. centCalc->Calc();
  54. }
  55. void FlowCalculator::InitResFile(TString inName)
  56. {
  57. TFile *fi = new TFile(inName.Data(),"read");
  58. for (int iGap=0; iGap<4; iGap++)
  59. {
  60. h_res2TPC[iGap] = (TH1F*) fi->Get(Form("hres2TPC_gap%i",iGap));
  61. h_res3TPC[iGap] = (TH1F*) fi->Get(Form("hres3TPC_gap%i",iGap));
  62. }
  63. for (int irxn=0; irxn<3; irxn++)
  64. {
  65. h_res2RXN[irxn] = (TH1F*) fi->Get(Form("hres2RXNfull_part%i",irxn));
  66. h_res3RXN[irxn] = (TH1F*) fi->Get(Form("hres3RXNfull_part%i",irxn));
  67. }
  68. for (int iGap=0; iGap<4; iGap++)
  69. {
  70. for (int ibin = 0; ibin<h_res2TPC[iGap]->GetNbinsX();ibin++)
  71. {
  72. fRes2TPC[iGap][ibin] = h_res2TPC[iGap]->GetBinContent(ibin+1);
  73. }
  74. for (int ibin = 0; ibin<h_res3TPC[iGap]->GetNbinsX();ibin++)
  75. {
  76. fRes3TPC[iGap][ibin] = h_res3TPC[iGap]->GetBinContent(ibin+1);
  77. }
  78. }
  79. for (int irxn=0; irxn<3; irxn++)
  80. {
  81. for (int ibin = 0; ibin<h_res2RXN[irxn]->GetNbinsX();ibin++)
  82. {
  83. fRes2RXN[irxn][ibin] = h_res2RXN[irxn]->GetBinContent(ibin+1);
  84. std::cout << "fRes2RXN_part" << irxn << "[" << ibin << "]\t= "
  85. << fRes2RXN[irxn][ibin] << std::endl;
  86. }
  87. for (int ibin = 0; ibin<h_res3RXN[irxn]->GetNbinsX();ibin++)
  88. {
  89. fRes3RXN[irxn][ibin] = h_res3RXN[irxn]->GetBinContent(ibin+1);
  90. }
  91. }
  92. }
  93. void FlowCalculator::LoopRes(TString outName)
  94. {
  95. std::cout << "FlowCalculator::LoopRes: Processing..." << std::endl;
  96. std::cout << "FlowCalculator::LoopRes: RP rotation: " << fRotate << std::endl;
  97. if (fChain == 0) return;
  98. centCalc->SetModel("PHSD");
  99. centCalc->SetEnergy(200.);
  100. TProfile *p_res1ZDCEvsZDCW;
  101. TProfile *p_res2RXNEvsRXNW[3], *p_res3RXNEvsRXNW[3];
  102. TProfile *p_res2TPCEvsTPCW[4], *p_res3TPCEvsTPCW[4];
  103. TProfile *p_res2RXNEvsTPCM[3], *p_res3RXNEvsTPCM[3];
  104. TProfile *p_res2RXNWvsTPCM[3], *p_res3RXNWvsTPCM[3];
  105. p_res1ZDCEvsZDCW = new TProfile(Form("p_res1ZDCEvsZDCW"),Form("p_res1ZDCEvsZDCW"),10,0.,100.);
  106. for (int iGap=0; iGap<4; iGap++)
  107. {
  108. p_res2TPCEvsTPCW[iGap] = new TProfile(Form("p_res2TPCEvsTPCW_gap%i",iGap),Form("p_res2TPCEvsTPCW_gap%i",iGap),10,0.,100.);
  109. p_res3TPCEvsTPCW[iGap] = new TProfile(Form("p_res3TPCEvsTPCW_gap%i",iGap),Form("p_res3TPCEvsTPCW_gap%i",iGap),10,0.,100.);
  110. }
  111. for (int irxn=0; irxn<3; irxn++)
  112. {
  113. p_res2RXNEvsRXNW[irxn] = new TProfile(Form("p_res2RXNEvsRXNW_%i",irxn),Form("p_res2RXNEvsRXNW_%i",irxn),10,0.,100.);
  114. p_res3RXNEvsRXNW[irxn] = new TProfile(Form("p_res3RXNEvsRXNW_%i",irxn),Form("p_res3RXNEvsRXNW_%i",irxn),10,0.,100.);
  115. p_res2RXNEvsTPCM[irxn] = new TProfile(Form("p_res2RXNEvsTPCM_%i",irxn),Form("p_res2RXNEvsTPCM_%i",irxn),10,0.,100.);
  116. p_res3RXNEvsTPCM[irxn] = new TProfile(Form("p_res3RXNEvsTPCM_%i",irxn),Form("p_res3RXNEvsTPCM_%i",irxn),10,0.,100.);
  117. p_res2RXNWvsTPCM[irxn] = new TProfile(Form("p_res2RXNWvsTPCM_%i",irxn),Form("p_res2RXNWvsTPCM_%i",irxn),10,0.,100.);
  118. p_res3RXNWvsTPCM[irxn] = new TProfile(Form("p_res3RXNWvsTPCM_%i",irxn),Form("p_res3RXNWvsTPCM_%i",irxn),10,0.,100.);
  119. }
  120. // EP QA histograms (x axis - value, y axis - centrality bin
  121. TH2F *hPsiRP; // PsiRP distribution
  122. TH2F *hQv2xRXNEast[3], *hQv2yRXNEast[3]; // Qv2 from RXN East
  123. TH2F *hQv3xRXNEast[3], *hQv3yRXNEast[3]; // Qv3 from RXN East
  124. TH2F *hPsiEP2RXNEast[3], *hPsiEP3RXNEast[3]; // PsiEP from RXN East
  125. TH2F *hdPsiEP2RXNEast[3], *hdPsiEP3RXNEast[3]; // PsiEP - PsiRP from RXN East
  126. TH2F *hQv2xRXNWest[3], *hQv2yRXNWest[3]; // Qv2 from RXN West
  127. TH2F *hQv3xRXNWest[3], *hQv3yRXNWest[3]; // Qv3 from RXN West
  128. TH2F *hPsiEP2RXNWest[3], *hPsiEP3RXNWest[3]; // PsiEP from RXN West
  129. TH2F *hdPsiEP2RXNWest[3], *hdPsiEP3RXNWest[3]; // PsiEP - PsiRP from RXN West
  130. TH2F *hQv2xRXNFull[3], *hQv2yRXNFull[3]; // Qv2 from RXN Full
  131. TH2F *hQv3xRXNFull[3], *hQv3yRXNFull[3]; // Qv3 from RXN Full
  132. TH2F *hPsiEP2RXNFull[3], *hPsiEP3RXNFull[3]; // PsiEP from RXN Full
  133. TH2F *hdPsiEP2RXNFull[3], *hdPsiEP3RXNFull[3]; // PsiEP - PsiRP from RXN Full
  134. hPsiRP = new TH2F("hPsiRP","#Psi_{RP} vs centrality bins",360,0.,2*TMath::Pi(),10,0,100);
  135. for (int irxn=0; irxn<3; irxn++)
  136. {
  137. hQv2xRXNEast[irxn] = new TH2F(Form("hQv2xRXNEast_part%i",irxn),Form("hQv2xRXNEast_part%i",irxn),500,-50.,50.,10,0,100);
  138. hQv2yRXNEast[irxn] = new TH2F(Form("hQv2yRXNEast_part%i",irxn),Form("hQv2yRXNEast_part%i",irxn),500,-50.,50.,10,0,100);
  139. hQv3xRXNEast[irxn] = new TH2F(Form("hQv3xRXNEast_part%i",irxn),Form("hQv3xRXNEast_part%i",irxn),500,-50.,50.,10,0,100);
  140. hQv3yRXNEast[irxn] = new TH2F(Form("hQv3yRXNEast_part%i",irxn),Form("hQv3yRXNEast_part%i",irxn),500,-50.,50.,10,0,100);
  141. hPsiEP2RXNEast[irxn] = new TH2F(Form("hPsiEP2RXNEast_part%i",irxn),Form("hPsiEP2RXNEast_part%i",irxn),360,0.,2*TMath::Pi(),10,0,100);
  142. hPsiEP3RXNEast[irxn] = new TH2F(Form("hPsiEP3RXNEast_part%i",irxn),Form("hPsiEP3RXNEast_part%i",irxn),360,0.,2*TMath::Pi(),10,0,100);
  143. hdPsiEP2RXNEast[irxn] = new TH2F(Form("hdPsiEP2RXNEast_part%i",irxn),Form("hdPsiEP2RXNEast_part%i",irxn),360,-TMath::Pi(),TMath::Pi(),10,0,100);
  144. hdPsiEP3RXNEast[irxn] = new TH2F(Form("hdPsiEP3RXNEast_part%i",irxn),Form("hdPsiEP3RXNEast_part%i",irxn),360,-TMath::Pi(),TMath::Pi(),10,0,100);
  145. hQv2xRXNWest[irxn] = new TH2F(Form("hQv2xRXNWest_part%i",irxn),Form("hQv2xRXNWest_part%i",irxn),500,-50.,50.,10,0,100);
  146. hQv2yRXNWest[irxn] = new TH2F(Form("hQv2yRXNWest_part%i",irxn),Form("hQv2yRXNWest_part%i",irxn),500,-50.,50.,10,0,100);
  147. hQv3xRXNWest[irxn] = new TH2F(Form("hQv3xRXNWest_part%i",irxn),Form("hQv3xRXNWest_part%i",irxn),500,-50.,50.,10,0,100);
  148. hQv3yRXNWest[irxn] = new TH2F(Form("hQv3yRXNWest_part%i",irxn),Form("hQv3yRXNWest_part%i",irxn),500,-50.,50.,10,0,100);
  149. hPsiEP2RXNWest[irxn] = new TH2F(Form("hPsiEP2RXNWest_part%i",irxn),Form("hPsiEP2RXNWest_part%i",irxn),360,0.,2*TMath::Pi(),10,0,100);
  150. hPsiEP3RXNWest[irxn] = new TH2F(Form("hPsiEP3RXNWest_part%i",irxn),Form("hPsiEP3RXNWest_part%i",irxn),360,0.,2*TMath::Pi(),10,0,100);
  151. hdPsiEP2RXNWest[irxn] = new TH2F(Form("hdPsiEP2RXNWest_part%i",irxn),Form("hdPsiEP2RXNWest_part%i",irxn),360,-TMath::Pi(),TMath::Pi(),10,0,100);
  152. hdPsiEP3RXNWest[irxn] = new TH2F(Form("hdPsiEP3RXNWest_part%i",irxn),Form("hdPsiEP3RXNWest_part%i",irxn),360,-TMath::Pi(),TMath::Pi(),10,0,100);
  153. hQv2xRXNFull[irxn] = new TH2F(Form("hQv2xRXNFull_part%i",irxn),Form("hQv2xRXNFull_part%i",irxn),500,-50.,50.,10,0,100);
  154. hQv2yRXNFull[irxn] = new TH2F(Form("hQv2yRXNFull_part%i",irxn),Form("hQv2yRXNFull_part%i",irxn),500,-50.,50.,10,0,100);
  155. hQv3xRXNFull[irxn] = new TH2F(Form("hQv3xRXNFull_part%i",irxn),Form("hQv3xRXNFull_part%i",irxn),500,-50.,50.,10,0,100);
  156. hQv3yRXNFull[irxn] = new TH2F(Form("hQv3yRXNFull_part%i",irxn),Form("hQv3yRXNFull_part%i",irxn),500,-50.,50.,10,0,100);
  157. hPsiEP2RXNFull[irxn] = new TH2F(Form("hPsiEP2RXNFull_part%i",irxn),Form("hPsiEP2RXNFull_part%i",irxn),360,0.,2*TMath::Pi(),10,0,100);
  158. hPsiEP3RXNFull[irxn] = new TH2F(Form("hPsiEP3RXNFull_part%i",irxn),Form("hPsiEP3RXNFull_part%i",irxn),360,0.,2*TMath::Pi(),10,0,100);
  159. hdPsiEP2RXNFull[irxn] = new TH2F(Form("hdPsiEP2RXNFull_part%i",irxn),Form("hdPsiEP2RXNFull_part%i",irxn),360,-TMath::Pi(),TMath::Pi(),10,0,100);
  160. hdPsiEP3RXNFull[irxn] = new TH2F(Form("hdPsiEP3RXNFull_part%i",irxn),Form("hdPsiEP3RXNFull_part%i",irxn),360,-TMath::Pi(),TMath::Pi(),10,0,100);
  161. }
  162. Long64_t nentries = fChain->GetEntries();
  163. Long64_t nbytes = 0, nb = 0;
  164. Int_t refMult, cent;
  165. // EP from TPCs
  166. // TVector2 Qv2EastTPC[4], Qv2WestTPC[4];
  167. // TVector2 Qv3EastTPC[4], Qv3WestTPC[4];
  168. Double_t Psi2EastTPC[4], Psi2WestTPC[4];
  169. Double_t Psi3EastTPC[4], Psi3WestTPC[4];
  170. // EP from BBCs & RXN
  171. // TVector2 Qv2EastRXN[3], Qv2WestRXN[3];
  172. // TVector2 Qv3EastRXN[3], Qv3WestRXN[3];
  173. Double_t Psi2EastRXN[3], Psi2WestRXN[3], Psi2FullRXN[3];
  174. Double_t Psi3EastRXN[3], Psi3WestRXN[3], Psi3FullRXN[3];
  175. Double_t Psi2MiddTPC;
  176. Double_t Psi3MiddTPC;
  177. Double_t Psi1EastZDC, Psi1WestZDC;
  178. for (Long64_t jentry=0; jentry<nentries;jentry++)
  179. {
  180. Long64_t ientry = LoadTree(jentry);
  181. if (ientry < 0) break;
  182. if (jentry%1000 == 0)
  183. std::cout << "Event [" << jentry << "/"
  184. << nentries << "]" << std::endl;
  185. nb = fChain->GetEntry(jentry); nbytes += nb;
  186. // if (Cut(ientry) < 0) continue;
  187. // Centrality determination
  188. refMult = GetMultPHENIX();
  189. cent = centCalc->GetCentrality(refMult);
  190. if (fRotate)
  191. {
  192. fPsiRP = fRnd->Rndm()*2*TMath::Pi();
  193. }
  194. else
  195. {
  196. fPsiRP = 0.;
  197. }
  198. hPsiRP->Fill(fPsiRP,cent);
  199. // EP determination
  200. GetAllQv();
  201. for (int iGap=0; iGap<4; iGap++)
  202. {
  203. // Qv2EastTPC[iGap] = GetQvTPC(-1,2,iGap);
  204. // Qv2WestTPC[iGap] = GetQvTPC( 1,2,iGap);
  205. // Qv3EastTPC[iGap] = GetQvTPC(-1,3,iGap);
  206. // Qv3WestTPC[iGap] = GetQvTPC( 1,3,iGap);
  207. Psi2EastTPC[iGap] = GetPsiEP(fQv2EastTPC[iGap],2);
  208. Psi2WestTPC[iGap] = GetPsiEP(fQv2WestTPC[iGap],2);
  209. Psi3EastTPC[iGap] = GetPsiEP(fQv3EastTPC[iGap],3);
  210. Psi3WestTPC[iGap] = GetPsiEP(fQv3WestTPC[iGap],3);
  211. p_res2TPCEvsTPCW[iGap]->Fill(cent,TMath::Cos( 2*(Psi2EastTPC[iGap] - Psi2WestTPC[iGap]) ));
  212. p_res3TPCEvsTPCW[iGap]->Fill(cent,TMath::Cos( 3*(Psi3EastTPC[iGap] - Psi3WestTPC[iGap]) ));
  213. }
  214. Psi2MiddTPC = GetPsiEP(fQv2MiddTPC,2);
  215. Psi3MiddTPC = GetPsiEP(fQv3MiddTPC,3);
  216. Psi1EastZDC = GetPsiEP(fQv1EastZDC,1);
  217. Psi1WestZDC = GetPsiEP(fQv1WestZDC,1);
  218. p_res1ZDCEvsZDCW->Fill(cent,TMath::Cos( 1*(Psi1EastZDC - Psi1WestZDC) ));
  219. for (int irxn=0; irxn<3; irxn++)
  220. {
  221. if (multWestRXN[irxn] == 0 || multEastRXN[irxn] == 0) continue;
  222. // Qv2EastRXN[irxn] = GetQvRXN(-1,2,irxn);
  223. // Qv2WestRXN[irxn] = GetQvRXN( 1,2,irxn);
  224. // Qv3EastRXN[irxn] = GetQvRXN(-1,3,irxn);
  225. // Qv3WestRXN[irxn] = GetQvRXN( 1,3,irxn);
  226. Psi2EastRXN[irxn] = GetPsiEP(fQv2EastRXN[irxn],2);
  227. Psi2WestRXN[irxn] = GetPsiEP(fQv2WestRXN[irxn],2);
  228. Psi3EastRXN[irxn] = GetPsiEP(fQv3EastRXN[irxn],3);
  229. Psi3WestRXN[irxn] = GetPsiEP(fQv3WestRXN[irxn],3);
  230. p_res2RXNEvsRXNW[irxn]->Fill(cent,TMath::Cos(2* (Psi2EastRXN[irxn] - Psi2WestRXN[irxn]) ));
  231. p_res3RXNEvsRXNW[irxn]->Fill(cent,TMath::Cos(3* (Psi3EastRXN[irxn] - Psi3WestRXN[irxn]) ));
  232. p_res2RXNEvsTPCM[irxn]->Fill(cent,TMath::Cos(2* (Psi2EastRXN[irxn] - Psi2MiddTPC) ));
  233. p_res3RXNEvsTPCM[irxn]->Fill(cent,TMath::Cos(3* (Psi3EastRXN[irxn] - Psi3MiddTPC) ));
  234. p_res2RXNWvsTPCM[irxn]->Fill(cent,TMath::Cos(2* (Psi2WestRXN[irxn] - Psi2MiddTPC) ));
  235. p_res3RXNWvsTPCM[irxn]->Fill(cent,TMath::Cos(3* (Psi3WestRXN[irxn] - Psi3MiddTPC) ));
  236. hQv2xRXNEast[irxn]->Fill(fQv2EastRXN[irxn].X(),cent);
  237. hQv2yRXNEast[irxn]->Fill(fQv2EastRXN[irxn].Y(),cent);
  238. hQv3xRXNEast[irxn]->Fill(fQv3EastRXN[irxn].X(),cent);
  239. hQv3yRXNEast[irxn]->Fill(fQv3EastRXN[irxn].Y(),cent);
  240. hQv2xRXNWest[irxn]->Fill(fQv2WestRXN[irxn].X(),cent);
  241. hQv2yRXNWest[irxn]->Fill(fQv2WestRXN[irxn].Y(),cent);
  242. hQv3xRXNWest[irxn]->Fill(fQv3WestRXN[irxn].X(),cent);
  243. hQv3yRXNWest[irxn]->Fill(fQv3WestRXN[irxn].Y(),cent);
  244. hPsiEP2RXNEast[irxn]->Fill(NormalizeAngle(Psi2EastRXN[irxn],2),cent);
  245. hPsiEP2RXNWest[irxn]->Fill(NormalizeAngle(Psi2WestRXN[irxn],2),cent);
  246. hPsiEP3RXNEast[irxn]->Fill(NormalizeAngle(Psi3EastRXN[irxn],3),cent);
  247. hPsiEP3RXNWest[irxn]->Fill(NormalizeAngle(Psi3WestRXN[irxn],3),cent);
  248. hdPsiEP2RXNEast[irxn]->Fill(WrapAngle(Psi2EastRXN[irxn]-fPsiRP,2),cent);
  249. hdPsiEP2RXNWest[irxn]->Fill(WrapAngle(Psi2WestRXN[irxn]-fPsiRP,2),cent);
  250. hdPsiEP3RXNEast[irxn]->Fill(WrapAngle(Psi3EastRXN[irxn]-fPsiRP,3),cent);
  251. hdPsiEP3RXNWest[irxn]->Fill(WrapAngle(Psi3WestRXN[irxn]-fPsiRP,3),cent);
  252. Psi2FullRXN[irxn] = GetPsiEP(fQv2FullRXN[irxn],2);
  253. Psi3FullRXN[irxn] = GetPsiEP(fQv3FullRXN[irxn],3);
  254. hQv2xRXNFull[irxn]->Fill(fQv2FullRXN[irxn].X(),cent);
  255. hQv2yRXNFull[irxn]->Fill(fQv2FullRXN[irxn].Y(),cent);
  256. hQv3xRXNFull[irxn]->Fill(fQv3FullRXN[irxn].X(),cent);
  257. hQv3yRXNFull[irxn]->Fill(fQv3FullRXN[irxn].Y(),cent);
  258. hPsiEP2RXNFull[irxn]->Fill(NormalizeAngle(Psi2FullRXN[irxn],2),cent);
  259. hPsiEP3RXNFull[irxn]->Fill(NormalizeAngle(Psi3FullRXN[irxn],3),cent);
  260. hdPsiEP2RXNFull[irxn]->Fill(WrapAngle(Psi2FullRXN[irxn]-fPsiRP,2),cent);
  261. hdPsiEP3RXNFull[irxn]->Fill(WrapAngle(Psi3FullRXN[irxn]-fPsiRP,3),cent);
  262. }
  263. }
  264. TFile *fo = new TFile(outName.Data(),"recreate");
  265. fo->cd();
  266. for (int iGap=0; iGap<4; iGap++)
  267. {
  268. p_res2TPCEvsTPCW[iGap]->Write();
  269. p_res3TPCEvsTPCW[iGap]->Write();
  270. }
  271. for (int irxn=0; irxn<3; irxn++)
  272. {
  273. p_res2RXNEvsRXNW[irxn]->Write();
  274. p_res3RXNEvsRXNW[irxn]->Write();
  275. }
  276. for (int irxn=0; irxn<3; irxn++)
  277. {
  278. p_res2RXNEvsTPCM[irxn]->Write();
  279. p_res3RXNEvsTPCM[irxn]->Write();
  280. p_res2RXNWvsTPCM[irxn]->Write();
  281. p_res3RXNWvsTPCM[irxn]->Write();
  282. }
  283. p_res1ZDCEvsZDCW->Write();
  284. fo->mkdir("EventPlane");
  285. fo->cd("EventPlane");
  286. hPsiRP->Write();
  287. for (int irxn=0; irxn<3; irxn++)
  288. {
  289. hQv2xRXNEast[irxn]-> Write();
  290. hQv2yRXNEast[irxn]-> Write();
  291. hQv3xRXNEast[irxn]-> Write();
  292. hQv3yRXNEast[irxn]-> Write();
  293. hQv2xRXNWest[irxn]-> Write();
  294. hQv2yRXNWest[irxn]-> Write();
  295. hQv3xRXNWest[irxn]-> Write();
  296. hQv3yRXNWest[irxn]-> Write();
  297. hQv2xRXNFull[irxn]-> Write();
  298. hQv2yRXNFull[irxn]-> Write();
  299. hQv3xRXNFull[irxn]-> Write();
  300. hQv3yRXNFull[irxn]-> Write();
  301. hPsiEP2RXNEast[irxn]-> Write();
  302. hPsiEP2RXNWest[irxn]-> Write();
  303. hPsiEP2RXNFull[irxn]-> Write();
  304. hPsiEP3RXNEast[irxn]-> Write();
  305. hPsiEP3RXNWest[irxn]-> Write();
  306. hPsiEP3RXNFull[irxn]-> Write();
  307. hdPsiEP2RXNEast[irxn]-> Write();
  308. hdPsiEP2RXNWest[irxn]-> Write();
  309. hdPsiEP2RXNFull[irxn]-> Write();
  310. hdPsiEP3RXNEast[irxn]-> Write();
  311. hdPsiEP3RXNWest[irxn]-> Write();
  312. hdPsiEP3RXNFull[irxn]-> Write();
  313. }
  314. fo->Close();
  315. }
  316. void FlowCalculator::LoopFlow(TString outName)
  317. {
  318. fRotate = true;
  319. std::cout << "FlowCalculator::LoopFlow: Processing..." << std::endl;
  320. std::cout << "FlowCalculator::LoopFlow: RP rotation: " << fRotate << std::endl;
  321. if (fChain == 0) return;
  322. TProfile *p_v2TPC[4][10][4], *p_v3TPC[4][10][4];
  323. TProfile *p_v2RXN[3][10][4], *p_v3RXN[3][10][4];
  324. TH2F *hPhi[4], *hdPhi[4]; // Phi angle of the particles, (Phi - PsiRP) of the particles
  325. for (int iPID=0; iPID<4; iPID++)
  326. {
  327. hPhi[iPID] = new TH2F(Form("hPhi_pid%i",iPID),Form("#varphi vs centrality bins pid %i",iPID),360,0.,2*TMath::Pi(),10,0,100);
  328. hdPhi[iPID] = new TH2F(Form("hdPhi_pid%i",iPID),Form("(#varphi - #Psi_{RP}) vs centrality bins pid %i",iPID),360,0.,2*TMath::Pi(),10,0,100);
  329. }
  330. // [4][10][4] -- EtaGaps, CentralityBins, PID
  331. // PID: 0 - hadrons, 1 - pions, 2 - kaons, 3 - protons
  332. for (int iGap=0; iGap<4; iGap++)
  333. {
  334. for (int iCent=0; iCent<10; iCent++)
  335. {
  336. for (int iPID=0; iPID<4; iPID++)
  337. {
  338. p_v2TPC[iGap][iCent][iPID] = new TProfile(Form("p_v2TPC_gap%i_cent%i_pid%i",iGap,iCent,iPID),
  339. Form("p_v2TPC_gap%i_cent%i_pid%i",iGap,iCent,iPID),
  340. 500,0.1,5.1);
  341. p_v3TPC[iGap][iCent][iPID] = new TProfile(Form("p_v3TPC_gap%i_cent%i_pid%i",iGap,iCent,iPID),
  342. Form("p_v3TPC_gap%i_cent%i_pid%i",iGap,iCent,iPID),
  343. 500,0.1,5.1);
  344. }
  345. }
  346. }
  347. for (int irxn=0; irxn<3; irxn++)
  348. {
  349. for (int iCent=0; iCent<10; iCent++)
  350. {
  351. for (int iPID=0; iPID<4; iPID++)
  352. {
  353. p_v2RXN[irxn][iCent][iPID] = new TProfile(Form("p_v2RXN_part%i_cent%i_pid%i",irxn,iCent,iPID),
  354. Form("p_v2RXN_part%i_cent%i_pid%i",irxn,iCent,iPID),
  355. 500,0.1,5.1);
  356. p_v3RXN[irxn][iCent][iPID] = new TProfile(Form("p_v3RXN_part%i_cent%i_pid%i",irxn,iCent,iPID),
  357. Form("p_v3RXN_part%i_cent%i_pid%i",irxn,iCent,iPID),
  358. 500,0.1,5.1);
  359. }
  360. }
  361. }
  362. Long64_t nentries = fChain->GetEntries();
  363. std::cout << "CHECK!!!!" << std::endl;
  364. std::cout << nentries << std::endl;
  365. Long64_t nbytes = 0, nb = 0;
  366. Int_t refMult, cent;
  367. // EP from TPCs
  368. // TVector2 Qv2EastTPC[4], Qv2WestTPC[4];
  369. // TVector2 Qv3EastTPC[4], Qv3WestTPC[4];
  370. Double_t Psi2EastTPC[4], Psi2WestTPC[4];
  371. Double_t Psi3EastTPC[4], Psi3WestTPC[4];
  372. // EP from BBCs & RXN
  373. // TVector2 Qv2EastRXN[3], Qv2WestRXN[3];
  374. // TVector2 Qv3EastRXN[3], Qv3WestRXN[3];
  375. Double_t Psi2EastRXN[3], Psi2WestRXN[3];
  376. Double_t Psi3EastRXN[3], Psi3WestRXN[3];
  377. Double_t Psi2FullRXN[3], Psi3FullRXN[3];
  378. Double_t weight, vn, res2TPC[4], res3TPC[4], res2RXN[3], res3RXN[3];
  379. Int_t pid;
  380. for (Long64_t jentry=0; jentry<nentries;jentry++)
  381. {
  382. Long64_t ientry = LoadTree(jentry);
  383. if (ientry < 0) break;
  384. if (jentry%1000 == 0)
  385. std::cout << "Event [" << jentry << "/"
  386. << nentries << "]" << std::endl;
  387. nb = fChain->GetEntry(jentry); nbytes += nb;
  388. // if (Cut(ientry) < 0) continue;
  389. // Centrality determination
  390. refMult = GetMultPHENIX();
  391. cent = centCalc->GetCentrality(refMult);
  392. if (fRotate)
  393. {
  394. fPsiRP = gRandom->Rndm()*2*TMath::Pi(); //fRnd->Rndm()*2*TMath::Pi();
  395. }
  396. else
  397. {
  398. fPsiRP = 0.;
  399. }
  400. // EP determination
  401. GetAllQv();
  402. for (int iGap=0; iGap<4; iGap++)
  403. {
  404. // Qv2EastTPC[iGap] = GetQvTPC(-1,2,iGap);
  405. // Qv2WestTPC[iGap] = GetQvTPC( 1,2,iGap);
  406. // Qv3EastTPC[iGap] = GetQvTPC(-1,3,iGap);
  407. // Qv3WestTPC[iGap] = GetQvTPC( 1,3,iGap);
  408. Psi2EastTPC[iGap] = GetPsiEP(fQv2EastTPC[iGap],2);
  409. Psi2WestTPC[iGap] = GetPsiEP(fQv2WestTPC[iGap],2);
  410. Psi3EastTPC[iGap] = GetPsiEP(fQv3EastTPC[iGap],3);
  411. Psi3WestTPC[iGap] = GetPsiEP(fQv3WestTPC[iGap],3);
  412. }
  413. for (int irxn=0; irxn<3; irxn++)
  414. {
  415. // Qv2EastRXN[irxn] = GetQvRXN(-1,2,irxn);
  416. // Qv2WestRXN[irxn] = GetQvRXN( 1,2,irxn);
  417. // Qv3EastRXN[irxn] = GetQvRXN(-1,3,irxn);
  418. // Qv3WestRXN[irxn] = GetQvRXN( 1,3,irxn);
  419. Psi2EastRXN[irxn] = GetPsiEP(fQv2EastRXN[irxn],2);
  420. Psi2WestRXN[irxn] = GetPsiEP(fQv2WestRXN[irxn],2);
  421. Psi2FullRXN[irxn] = GetPsiEP(fQv2FullRXN[irxn],2);
  422. Psi3EastRXN[irxn] = GetPsiEP(fQv3EastRXN[irxn],3);
  423. Psi3WestRXN[irxn] = GetPsiEP(fQv3WestRXN[irxn],3);
  424. Psi3FullRXN[irxn] = GetPsiEP(fQv3FullRXN[irxn],3);
  425. }
  426. // Resolution
  427. for (int iGap=0; iGap<4; iGap++)
  428. {
  429. res2TPC[iGap] = fRes2TPC[iGap][(int)cent/10]; //h_res2TPC[iGap]->GetBinContent(h_res2TPC[iGap]->FindBin(cent));
  430. res3TPC[iGap] = fRes3TPC[iGap][(int)cent/10]; //h_res3TPC[iGap]->GetBinContent(h_res3TPC[iGap]->FindBin(cent));
  431. }
  432. for (int irxn=0; irxn<3; irxn++)
  433. {
  434. res2RXN[irxn] = fRes2RXN[irxn][(int)cent/10]; //h_res2RXN[irxn]->GetBinContent(h_res2RXN[irxn]->FindBin(cent));
  435. res3RXN[irxn] = fRes3RXN[irxn][(int)cent/10]; //h_res3RXN[irxn]->GetBinContent(h_res3RXN[irxn]->FindBin(cent));
  436. }
  437. for (int iTr=0; iTr<nh; iTr++)
  438. {
  439. //if (jentry == 154) std::cout << "\tTrack " << iTr << " out of " << nh << std::endl;
  440. // if (charge[iTr] == 0) continue;
  441. vMom->SetPxPyPzE(momx[iTr],momy[iTr],momz[iTr],ene[iTr]);
  442. double phi1, phi2;
  443. if (jentry == 0 && iTr == 0)
  444. {
  445. phi1 = vMom->Phi()*180./TMath::Pi();
  446. std::cout << "PsiRP = " << fPsiRP*180./TMath::Pi() << ", track.phi_before_rotation = " << phi1;
  447. }
  448. if (fRotate)
  449. {
  450. vMom->RotateZ(fPsiRP);
  451. }
  452. if (jentry == 0 && iTr == 0)
  453. {
  454. phi2 = vMom->Phi()*180./TMath::Pi();
  455. std::cout << " track.phi_after_rotation = " << phi2 << std::endl;
  456. }
  457. // if (vMom->Perp() < 0.1) continue;
  458. if (TMath::Abs(vMom->PseudoRapidity()) > 1.) continue;
  459. weight = (vMom->Perp() > 2.) ? 2. : vMom->Perp();
  460. // PID
  461. pid = -1;
  462. if (TMath::Abs(pdg[iTr]) == 211) pid = 1;
  463. if (TMath::Abs(pdg[iTr]) == 321) pid = 2;
  464. if (TMath::Abs(pdg[iTr]) == 2212) pid = 3;
  465. /*for (int iGap=0; iGap<4; iGap++)
  466. {
  467. // East
  468. if (TMath::Abs(vMom->PseudoRapidity()) >= eta_gap.at(iGap) &&
  469. TMath::Abs(vMom->PseudoRapidity()) < 0.8 &&
  470. vMom->PseudoRapidity() < 0)
  471. {
  472. if (res2TPC[iGap] != 0)
  473. {
  474. vn = TMath::Cos(2 * (vMom->Phi() - Psi2WestTPC[iGap]) ) / res2TPC[iGap];
  475. p_v2TPC[iGap][(Int_t)(cent/10)][0]->Fill(vMom->Perp(),vn);
  476. if (pid != -1)
  477. {
  478. p_v2TPC[iGap][(Int_t)(cent/10)][pid]->Fill(vMom->Perp(),vn);
  479. }
  480. }
  481. if (res3TPC[iGap] != 0)
  482. {
  483. vn = TMath::Cos(3 * (vMom->Phi() - Psi3WestTPC[iGap]) ) / res3TPC[iGap];
  484. p_v3TPC[iGap][(Int_t)(cent/10)][0]->Fill(vMom->Perp(),vn);
  485. if (pid != -1)
  486. {
  487. p_v3TPC[iGap][(Int_t)(cent/10)][pid]->Fill(vMom->Perp(),vn);
  488. }
  489. }
  490. }
  491. // West
  492. if (TMath::Abs(vMom->PseudoRapidity()) >= eta_gap.at(iGap) &&
  493. TMath::Abs(vMom->PseudoRapidity()) < 0.8 &&
  494. vMom->PseudoRapidity() > 0)
  495. {
  496. if (res2TPC[iGap] != 0)
  497. {
  498. vn = TMath::Cos(2 * (vMom->Phi() - Psi2EastTPC[iGap]) ) / res2TPC[iGap];
  499. p_v2TPC[iGap][(Int_t)(cent/10)][0]->Fill(vMom->Perp(),vn);
  500. if (pid != -1)
  501. {
  502. p_v2TPC[iGap][(Int_t)(cent/10)][pid]->Fill(vMom->Perp(),vn);
  503. }
  504. }
  505. if (res3TPC[iGap] != 0)
  506. {
  507. vn = TMath::Cos(3 * (vMom->Phi() - Psi3EastTPC[iGap]) ) / res3TPC[iGap];
  508. p_v3TPC[iGap][(Int_t)(cent/10)][0]->Fill(vMom->Perp(),vn);
  509. if (pid != -1)
  510. {
  511. p_v3TPC[iGap][(Int_t)(cent/10)][pid]->Fill(vMom->Perp(),vn);
  512. }
  513. }
  514. }
  515. }*/
  516. // std::cout << "Check!" << std::endl;
  517. hPhi[0]->Fill(NormalizeAngle(vMom->Phi(),1),cent);
  518. hdPhi[0]->Fill(NormalizeAngle(vMom->Phi()-fPsiRP,1),cent);
  519. if (pid != -1)
  520. {
  521. hPhi[pid]->Fill(NormalizeAngle(vMom->Phi(),1),cent);
  522. hdPhi[pid]->Fill(NormalizeAngle(vMom->Phi()-fPsiRP,1),cent);
  523. }
  524. for (int irxn=0; irxn<3; irxn++)
  525. {
  526. if (TMath::Abs(vMom->PseudoRapidity()) < 0.35)
  527. {
  528. if (multWestRXN[irxn] == 0 || multEastRXN[irxn] == 0) continue;
  529. if (res2RXN[irxn] != 0 && fQv2FullRXN[irxn].X() != -999. &&
  530. fQv2FullRXN[irxn].Y() != -999.)
  531. {
  532. vn = TMath::Cos(2 * (vMom->Phi() - Psi2FullRXN[irxn]) ) / res2RXN[irxn];
  533. p_v2RXN[irxn][(Int_t)(cent/10)][0]->Fill(vMom->Perp(),vn);
  534. if (pid != -1)
  535. {
  536. p_v2RXN[irxn][(Int_t)(cent/10)][pid]->Fill(vMom->Perp(),vn);
  537. }
  538. }
  539. if (res3RXN[irxn] != 0 && fQv3FullRXN[irxn].X() != -999. &&
  540. fQv3FullRXN[irxn].Y() != -999.)
  541. {
  542. vn = TMath::Cos(3 * (vMom->Phi() - Psi3FullRXN[irxn]) ) / res3RXN[irxn];
  543. p_v3RXN[irxn][(Int_t)(cent/10)][0]->Fill(vMom->Perp(),vn);
  544. if (pid != -1)
  545. {
  546. p_v3RXN[irxn][(Int_t)(cent/10)][pid]->Fill(vMom->Perp(),vn);
  547. }
  548. }
  549. }
  550. }
  551. } // end track loop
  552. } // end event loop
  553. TFile *fo = new TFile(outName.Data(),"recreate");
  554. fo->cd();
  555. for (int iGap=0; iGap<4; iGap++)
  556. {
  557. for (int iCent=0; iCent<10; iCent++)
  558. {
  559. for (int iPID=0; iPID<4; iPID++)
  560. {
  561. p_v2TPC[iGap][iCent][iPID]->Write();
  562. p_v3TPC[iGap][iCent][iPID]->Write();
  563. }
  564. }
  565. }
  566. for (int irxn=0; irxn<3; irxn++)
  567. {
  568. for (int iCent=0; iCent<10; iCent++)
  569. {
  570. for (int iPID=0; iPID<4; iPID++)
  571. {
  572. p_v2RXN[irxn][iCent][iPID]->Write();
  573. p_v3RXN[irxn][iCent][iPID]->Write();
  574. }
  575. }
  576. }
  577. fo->mkdir("EventPlane");
  578. fo->cd("EventPlane");
  579. for (int iPID=0; iPID<4; iPID++)
  580. {
  581. hPhi[iPID]->Write();
  582. hdPhi[iPID]->Write();
  583. }
  584. }
  585. TVector2 FlowCalculator::GetQvTPC(Int_t side, Int_t harm, Int_t gap)
  586. {
  587. TVector2 qv(-999.,-999.);
  588. if (side == 0) return qv;
  589. if (harm<2 || harm>3) return qv;
  590. Double_t qvx = 0., qvy = 0.;
  591. for (int iTr=0; iTr<nh; iTr++)
  592. {
  593. if (charge[iTr] == 0) continue;
  594. vMom->SetPxPyPzE(momx[iTr],momy[iTr],momz[iTr],ene[iTr]);
  595. if (vMom->Perp() < 0.1) continue;
  596. if (vMom->Perp() > 2.) continue;
  597. if (side < 0 && vMom->PseudoRapidity() > 0) continue;
  598. if (side > 0 && vMom->PseudoRapidity() < 0) continue;
  599. if (TMath::Abs(vMom->PseudoRapidity()) < eta_gap.at(gap)) continue;
  600. if (TMath::Abs(vMom->PseudoRapidity()) > 0.8) continue;
  601. qvx += vMom->Perp() * TMath::Cos( harm * vMom->Phi() );
  602. qvy += vMom->Perp() * TMath::Sin( harm * vMom->Phi() );
  603. }
  604. qv.Set(qvx,qvy);
  605. return qv;
  606. }
  607. TVector2 FlowCalculator::GetQvBBC(Int_t side, Int_t harm)
  608. {
  609. TVector2 qv(-999.,-999.);
  610. if (side == 0) return qv;
  611. if (harm<1 || harm>2) return qv;
  612. Double_t qvx = 0., qvy = 0.;
  613. for (int iTr=0; iTr<nh; iTr++)
  614. {
  615. if (charge[iTr] == 0) continue;
  616. vMom->SetPxPyPzE(momx[iTr],momy[iTr],momz[iTr],ene[iTr]);
  617. if (vMom->Perp() < 0.1) continue;
  618. if (side < 0 && vMom->PseudoRapidity() > 0) continue;
  619. if (side > 0 && vMom->PseudoRapidity() < 0) continue;
  620. if (TMath::Abs(vMom->PseudoRapidity()) < 3.) continue;
  621. if (TMath::Abs(vMom->PseudoRapidity()) > 4.) continue;
  622. qvx += vMom->Perp() * TMath::Cos( harm * vMom->Phi() );
  623. qvy += vMom->Perp() * TMath::Sin( harm * vMom->Phi() );
  624. }
  625. qv.Set(qvx,qvy);
  626. return qv;
  627. }
  628. TVector2 FlowCalculator::GetQvRXN(Int_t side, Int_t harm, Int_t part)
  629. {
  630. TVector2 qv(-999.,-999.);
  631. if (side == 0) return qv;
  632. if (harm<1 || harm>3) return qv;
  633. Double_t eta_min, eta_max;
  634. if (part == 0)
  635. {
  636. eta_min = 1.;
  637. eta_max = 2.8;
  638. }
  639. else
  640. {
  641. if (part == 1)
  642. {
  643. eta_min = 1.;
  644. eta_max = 1.5;
  645. }
  646. else
  647. {
  648. if (part == 2)
  649. {
  650. eta_min = 1.5;
  651. eta_max = 2.8;
  652. }
  653. else
  654. {
  655. return qv;
  656. }
  657. }
  658. }
  659. Double_t qvx = 0., qvy = 0.;
  660. for (int iTr=0; iTr<nh; iTr++)
  661. {
  662. if (charge[iTr] == 0) continue;
  663. vMom->SetPxPyPzE(momx[iTr],momy[iTr],momz[iTr],ene[iTr]);
  664. if (vMom->Perp() < 0.1) continue;
  665. if (side < 0 && vMom->PseudoRapidity() > 0) continue;
  666. if (side > 0 && vMom->PseudoRapidity() < 0) continue;
  667. if (TMath::Abs(vMom->PseudoRapidity()) < eta_min) continue;
  668. if (TMath::Abs(vMom->PseudoRapidity()) > eta_max) continue;
  669. qvx += vMom->Perp() * TMath::Cos( harm * vMom->Phi() );
  670. qvy += vMom->Perp() * TMath::Sin( harm * vMom->Phi() );
  671. }
  672. qv.Set(qvx,qvy);
  673. return qv;
  674. }
  675. void FlowCalculator::GetAllQv()
  676. {
  677. Double_t weight;
  678. Double_t qv2xEastTPC[4], qv3xEastTPC[4];
  679. Double_t qv2xEastRXN[3], qv3xEastRXN[3];
  680. Double_t qv2yEastTPC[4], qv3yEastTPC[4];
  681. Double_t qv2yEastRXN[3], qv3yEastRXN[3];
  682. Double_t qv2xWestTPC[4], qv3xWestTPC[4];
  683. Double_t qv2xWestRXN[3], qv3xWestRXN[3];
  684. Double_t qv2yWestTPC[4], qv3yWestTPC[4];
  685. Double_t qv2yWestRXN[3], qv3yWestRXN[3];
  686. Double_t qv2xFullRXN[3], qv3xFullRXN[3];
  687. Double_t qv2yFullRXN[3], qv3yFullRXN[3];
  688. Double_t qv2xMiddTPC, qv3xMiddTPC;
  689. Double_t qv2yMiddTPC, qv3yMiddTPC;
  690. Double_t qv1xEastZDC, qv1xWestZDC, qv1xFullZDC;
  691. Double_t qv1yEastZDC, qv1yWestZDC, qv1yFullZDC;
  692. for (int iGap=0; iGap<4; iGap++)
  693. {
  694. qv2xEastTPC[iGap] = 0.; qv2yEastTPC[iGap] = 0.;
  695. qv3xEastTPC[iGap] = 0.; qv3yEastTPC[iGap] = 0.;
  696. qv2xWestTPC[iGap] = 0.; qv2yWestTPC[iGap] = 0.;
  697. qv3xWestTPC[iGap] = 0.; qv3yWestTPC[iGap] = 0.;
  698. }
  699. qv2xMiddTPC = 0.; qv2yMiddTPC = 0.;
  700. qv1xEastZDC = 0.; qv1yEastZDC = 0.;
  701. qv1xWestZDC = 0.; qv1yWestZDC = 0.;
  702. qv1xFullZDC = 0.; qv1yFullZDC = 0.;
  703. multEastZDC = 0; multWestZDC = 0;
  704. for (int irxn=0; irxn<3; irxn++)
  705. {
  706. qv2xEastRXN[irxn] = 0.; qv2yEastRXN[irxn] = 0.;
  707. qv3xEastRXN[irxn] = 0.; qv3yEastRXN[irxn] = 0.;
  708. qv2xFullRXN[irxn] = 0.; qv2yFullRXN[irxn] = 0.;
  709. qv3xFullRXN[irxn] = 0.; qv3yFullRXN[irxn] = 0.;
  710. qv2xWestRXN[irxn] = 0.; qv2yWestRXN[irxn] = 0.;
  711. qv3xWestRXN[irxn] = 0.; qv3yWestRXN[irxn] = 0.;
  712. multEastRXN[irxn] = 0; multWestRXN[irxn] = 0;
  713. }
  714. for (int iTr=0; iTr<nh; iTr++)
  715. {
  716. // if (charge[iTr] == 0) continue;
  717. vMom->SetPxPyPzE(momx[iTr],momy[iTr],momz[iTr],ene[iTr]);
  718. if (fRotate)
  719. {
  720. vMom->RotateZ(fPsiRP);
  721. }
  722. // if (vMom->Perp() < 0.1) continue;
  723. weight = 1.; //vMom->Perp();
  724. if (TMath::Abs(vMom->PseudoRapidity()) < 0.35)
  725. {
  726. qv2xMiddTPC += weight * TMath::Cos( 2. * vMom->Phi() );
  727. qv2yMiddTPC += weight * TMath::Sin( 2. * vMom->Phi() );
  728. qv3xMiddTPC += weight * TMath::Cos( 3. * vMom->Phi() );
  729. qv3yMiddTPC += weight * TMath::Sin( 3. * vMom->Phi() );
  730. }
  731. if (TMath::Abs(vMom->PseudoRapidity()) > 2. &&
  732. TMath::Abs(vMom->PseudoRapidity()) < 5.)
  733. {
  734. qv1xFullZDC += weight * TMath::Cos( 1. * vMom->Phi() );
  735. qv1yFullZDC += weight * TMath::Sin( 1. * vMom->Phi() );
  736. if (vMom->PseudoRapidity() < 0)
  737. {
  738. qv1xEastZDC += weight * TMath::Cos( 1. * vMom->Phi() );
  739. qv1yEastZDC += weight * TMath::Sin( 1. * vMom->Phi() );
  740. multEastZDC++;
  741. }
  742. if (vMom->PseudoRapidity() > 0)
  743. {
  744. qv1xWestZDC += weight * TMath::Cos( 1. * vMom->Phi() );
  745. qv1yWestZDC += weight * TMath::Sin( 1. * vMom->Phi() );
  746. multWestZDC++;
  747. }
  748. }
  749. for (int iGap=0; iGap<4; iGap++)
  750. {
  751. if (TMath::Abs(vMom->PseudoRapidity()) >= eta_gap.at(iGap) &&
  752. TMath::Abs(vMom->PseudoRapidity()) < 0.8 &&
  753. vMom->Perp() < 2. && vMom->PseudoRapidity() < 0)
  754. {
  755. qv2xEastTPC[iGap] += weight * TMath::Cos( 2. * vMom->Phi() );
  756. qv2yEastTPC[iGap] += weight * TMath::Sin( 2. * vMom->Phi() );
  757. qv3xEastTPC[iGap] += weight * TMath::Cos( 3. * vMom->Phi() );
  758. qv3yEastTPC[iGap] += weight * TMath::Sin( 3. * vMom->Phi() );
  759. }
  760. if (TMath::Abs(vMom->PseudoRapidity()) >= eta_gap.at(iGap) &&
  761. TMath::Abs(vMom->PseudoRapidity()) < 0.8 &&
  762. vMom->Perp() < 2. && vMom->PseudoRapidity() > 0)
  763. {
  764. qv2xWestTPC[iGap] += weight * TMath::Cos( 2. * vMom->Phi() );
  765. qv2yWestTPC[iGap] += weight * TMath::Sin( 2. * vMom->Phi() );
  766. qv3xWestTPC[iGap] += weight * TMath::Cos( 3. * vMom->Phi() );
  767. qv3yWestTPC[iGap] += weight * TMath::Sin( 3. * vMom->Phi() );
  768. }
  769. }
  770. for (int irxn=0; irxn<3; irxn++)
  771. {
  772. if (TMath::Abs(vMom->PseudoRapidity()) >= eta_rxn.at(irxn).first &&
  773. TMath::Abs(vMom->PseudoRapidity()) < eta_rxn.at(irxn).second &&
  774. momz[iTr] < 0)
  775. {
  776. qv2xEastRXN[irxn] += weight * TMath::Cos( 2. * vMom->Phi() );
  777. qv2yEastRXN[irxn] += weight * TMath::Sin( 2. * vMom->Phi() );
  778. qv3xEastRXN[irxn] += weight * TMath::Cos( 3. * vMom->Phi() );
  779. qv3yEastRXN[irxn] += weight * TMath::Sin( 3. * vMom->Phi() );
  780. multEastRXN[irxn]++;
  781. }
  782. if (TMath::Abs(vMom->PseudoRapidity()) >= eta_rxn.at(irxn).first &&
  783. TMath::Abs(vMom->PseudoRapidity()) < eta_rxn.at(irxn).second &&
  784. momz[iTr] > 0)
  785. {
  786. qv2xWestRXN[irxn] += weight * TMath::Cos( 2. * vMom->Phi() );
  787. qv2yWestRXN[irxn] += weight * TMath::Sin( 2. * vMom->Phi() );
  788. qv3xWestRXN[irxn] += weight * TMath::Cos( 3. * vMom->Phi() );
  789. qv3yWestRXN[irxn] += weight * TMath::Sin( 3. * vMom->Phi() );
  790. multWestRXN[irxn]++;
  791. }
  792. }
  793. }
  794. fQv2MiddTPC.Set(qv2xMiddTPC,qv2yMiddTPC);
  795. fQv3MiddTPC.Set(qv3xMiddTPC,qv3yMiddTPC);
  796. fQv1EastZDC.Set(qv1xEastZDC,qv1yEastZDC);
  797. fQv1WestZDC.Set(qv1xWestZDC,qv1yWestZDC);
  798. if (multEastZDC >=2 && multWestZDC >= 2)
  799. {
  800. qv1xFullZDC = qv1xEastZDC + qv1xWestZDC;
  801. qv1yFullZDC = qv1yEastZDC + qv1yWestZDC;
  802. }
  803. else
  804. {
  805. qv1xFullZDC = -999.;
  806. qv1yFullZDC = -999.;
  807. }
  808. fQv1FullZDC.Set(qv1xFullZDC,qv1yFullZDC);
  809. for (int iGap=0; iGap<4; iGap++)
  810. {
  811. fQv2EastTPC[iGap].Set(qv2xEastTPC[iGap],qv2yEastTPC[iGap]);
  812. fQv3EastTPC[iGap].Set(qv3xEastTPC[iGap],qv3yEastTPC[iGap]);
  813. fQv2WestTPC[iGap].Set(qv2xWestTPC[iGap],qv2yWestTPC[iGap]);
  814. fQv3WestTPC[iGap].Set(qv3xWestTPC[iGap],qv3yWestTPC[iGap]);
  815. }
  816. for (int irxn=0; irxn<3; irxn++)
  817. {
  818. if (multEastRXN[irxn] >= 2 && multWestRXN[irxn] >= 2)
  819. {
  820. qv2xFullRXN[irxn] = qv2xEastRXN[irxn] + qv2xWestRXN[irxn];
  821. qv2yFullRXN[irxn] = qv2yEastRXN[irxn] + qv2yWestRXN[irxn];
  822. qv3xFullRXN[irxn] = qv3xEastRXN[irxn] + qv3xWestRXN[irxn];
  823. qv3yFullRXN[irxn] = qv3yEastRXN[irxn] + qv3yWestRXN[irxn];
  824. }
  825. else
  826. {
  827. qv2xFullRXN[irxn] = -999.;
  828. qv2yFullRXN[irxn] = -999.;
  829. qv3xFullRXN[irxn] = -999.;
  830. qv3yFullRXN[irxn] = -999.;
  831. }
  832. fQv2EastRXN[irxn].Set(qv2xEastRXN[irxn],qv2yEastRXN[irxn]);
  833. fQv3EastRXN[irxn].Set(qv3xEastRXN[irxn],qv3yEastRXN[irxn]);
  834. fQv2WestRXN[irxn].Set(qv2xWestRXN[irxn],qv2yWestRXN[irxn]);
  835. fQv3WestRXN[irxn].Set(qv3xWestRXN[irxn],qv3yWestRXN[irxn]);
  836. fQv2FullRXN[irxn].Set(qv2xFullRXN[irxn],qv2yFullRXN[irxn]);
  837. fQv3FullRXN[irxn].Set(qv3xFullRXN[irxn],qv3yFullRXN[irxn]);
  838. }
  839. }
  840. Double_t FlowCalculator::GetPsiEP(const TVector2 &qv, Double_t harm)
  841. {
  842. return (Double_t) (1/harm) * TMath::ATan2(qv.Y(),qv.X());
  843. //return (Double_t) TMath::ATan2(qv.Y(),qv.X());
  844. }
  845. #endif