ReadFlow.C 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. struct coord
  2. {
  3. float xlow;
  4. float ylow;
  5. float xup;
  6. float yup;
  7. };
  8. void ReadFlow(const char *inFileName)
  9. {
  10. // Setting up global variables for the plot
  11. gROOT->SetStyle("Pub");
  12. gROOT->ForceStyle();
  13. gStyle->SetPalette(kDarkRainBow);
  14. gStyle->SetErrorX(0);
  15. gStyle->SetTitleSize(0.05);
  16. const double binpt [11] = {0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.8,2.3,2.8,4.0};
  17. const TString hName [4] = {TString("h^{#pm}"),TString("#pi^{#pm}"),TString("K^{#pm}"),TString("p+#bar{p}")};
  18. const TString hCent [6] = {TString("0-10%"),TString("10-20%"),TString("20-30%"),TString("30-40%"),TString("40-50%"),TString("50-60%")};
  19. const std::pair<Double_t,Double_t> v2range[6][4] = {{{-0.023,0.06},{-0.023,0.06},{-0.023,0.06},{-0.023,0.06}},
  20. {{-0.005,0.09},{-0.005,0.09},{-0.005,0.09},{-0.005,0.09}},
  21. {{-0.023,0.09},{-0.023,0.09},{-0.023,0.09},{-0.023,0.09}},
  22. {{-0.051,0.16},{-0.051,0.16},{-0.051,0.16},{-0.051,0.16}},
  23. {{-0.023,0.16},{-0.023,0.16},{-0.023,0.16},{-0.023,0.16}},
  24. {{-0.023,0.16},{-0.023,0.16},{-0.023,0.16},{-0.023,0.16}}};
  25. const int ndet = 5;
  26. const int ncent = 6;
  27. const int npt = 9;
  28. const int npid = 4;
  29. TFile *fi = new TFile(inFileName,"read");
  30. TH1F *hv2[ndet][ncent][npt][npid]; //idet-icent-ipt-ipid
  31. TH1F *hv22[ndet][npt][npid];
  32. TH1F *hpt[ncent][npt][npid];
  33. for (int idet=0;idet<ndet;idet++)
  34. {
  35. for (int icent=0;icent<ncent;icent++)
  36. {
  37. for (int ipt=0; ipt<npt; ipt++)
  38. {
  39. for (int ipid=0;ipid<npid;ipid++)
  40. {
  41. if (idet == 0)
  42. {
  43. hpt[icent][ipt][ipid] = (TH1F*) fi->Get(Form("hpt_%i_%i_%i",icent,ipt,ipid));
  44. if (!hpt[icent][ipt][ipid]) std::cout << "WARNING: hpt is null (" << icent << " " << ipt << " " << ipid << ")" << std::endl;
  45. }
  46. if (icent==0)
  47. {
  48. hv22[idet][ipt][ipid] = (TH1F*) fi->Get(Form("hv22_%i_%i_%i",idet,ipt,ipid));
  49. }
  50. hv2[idet][icent][ipt][ipid] = (TH1F*) fi->Get(Form("hv2_%i_%i_%i_%i",idet,icent,ipt,ipid));
  51. }
  52. }
  53. }
  54. }
  55. std::vector<Double_t> vPt, vV2tpc, vV2fhcal, vV2RP;
  56. std::vector<Double_t> ePt, eV2tpc, eV2fhcal, eV2RP;
  57. int det1 = 0, det2 = 3, det0 = 4;
  58. TGraphErrors *grv2tpc[ncent][npid], *grv2fhcal[ncent][npid], *grv2RP[ncent][npid]; //icent-ipid
  59. for (int icent=0;icent<ncent;icent++)
  60. {
  61. for (int ipid=0;ipid<npid;ipid++)
  62. {
  63. for (int ipt=0;ipt<npt;ipt++)
  64. {
  65. std::cout << "icent " << icent << " ipid " << ipid << " ipt " << ipt << std::endl;
  66. vPt.push_back(hpt[icent][ipt][ipid]->GetMean());
  67. ePt.push_back(0.);
  68. vV2tpc.push_back(hv2[det1][icent][ipt][ipid]->GetMean());
  69. eV2tpc.push_back(hv2[det1][icent][ipt][ipid]->GetMeanError());
  70. vV2fhcal.push_back(hv2[det2][icent][ipt][ipid]->GetMean());
  71. eV2fhcal.push_back(hv2[det2][icent][ipt][ipid]->GetMeanError());
  72. vV2RP.push_back(hv2[det0][icent][ipt][ipid]->GetMean());
  73. eV2RP.push_back(hv2[det0][icent][ipt][ipid]->GetMeanError());
  74. }
  75. grv2tpc[icent][ipid] = new TGraphErrors(vPt.size(),&vPt[0],&vV2tpc[0],&ePt[0],&eV2tpc[0]);
  76. grv2tpc[icent][ipid]->SetName(Form("grv2tpc_%i_%i",icent,ipid));
  77. grv2fhcal[icent][ipid] = new TGraphErrors(vPt.size(),&vPt[0],&vV2fhcal[0],&ePt[0],&eV2fhcal[0]);
  78. grv2fhcal[icent][ipid]->SetName(Form("grv2fhcal_%i_%i",icent,ipid));
  79. grv2RP[icent][ipid] = new TGraphErrors(vPt.size(),&vPt[0],&vV2RP[0],&ePt[0],&eV2RP[0]);
  80. grv2RP[icent][ipid]->SetName(Form("grv2RP_%i_%i",icent,ipid));
  81. grv2tpc[icent][ipid]->GetXaxis()->SetTitle("p_{T}, [GeV/c]");
  82. grv2tpc[icent][ipid]->GetYaxis()->SetTitle("v_{2}");
  83. grv2fhcal[icent][ipid]->GetXaxis()->SetTitle("p_{T}, [GeV/c]");
  84. grv2fhcal[icent][ipid]->GetYaxis()->SetTitle("v_{2}");
  85. grv2RP[icent][ipid]->GetXaxis()->SetTitle("p_{T}, [GeV/c]");
  86. grv2RP[icent][ipid]->GetYaxis()->SetTitle("v_{2}");
  87. grv2tpc[icent][ipid] ->SetMarkerStyle(20);
  88. grv2fhcal[icent][ipid]->SetMarkerStyle(26);
  89. grv2RP[icent][ipid]->SetMarkerStyle(21);
  90. grv2tpc[icent][ipid] ->GetYaxis()->SetRangeUser(v2range[icent][ipid].first,v2range[icent][ipid].second);
  91. grv2fhcal[icent][ipid]->GetYaxis()->SetRangeUser(v2range[icent][ipid].first,v2range[icent][ipid].second);
  92. grv2RP[icent][ipid]->GetYaxis()->SetRangeUser(v2range[icent][ipid].first,v2range[icent][ipid].second);
  93. grv2tpc[icent][ipid] ->GetXaxis()->SetLimits(0.,3.49);
  94. grv2fhcal[icent][ipid]->GetXaxis()->SetLimits(0.,3.49);
  95. grv2RP[icent][ipid]->GetXaxis()->SetLimits(0.,3.49);
  96. grv2tpc[icent][ipid] ->SetMarkerSize(1.6);
  97. grv2fhcal[icent][ipid]->SetMarkerSize(1.6);
  98. grv2RP[icent][ipid]->SetMarkerSize(1.6);
  99. vPt.clear(); ePt.clear();
  100. vV2tpc.clear(); eV2tpc.clear();
  101. vV2fhcal.clear(); eV2fhcal.clear();
  102. vV2RP.clear(); eV2RP.clear();
  103. }
  104. }
  105. TH1F *hptTmp;
  106. TGraphErrors *grv22tpc[npid], *grv22fhcal[npid], *grv22RP[npid];
  107. for (int ipid=0;ipid<npid;ipid++) {
  108. for (int ipt = 0; ipt < npt; ipt++) {
  109. hptTmp = (TH1F*) hpt[1][ipt][ipid]->Clone();
  110. hptTmp->Add(hpt[2][ipt][ipid]);
  111. hptTmp->Add(hpt[3][ipt][ipid]);
  112. vPt.push_back(hptTmp->GetMean());
  113. ePt.push_back(0.);
  114. vV2tpc.push_back(hv22[det1][ipt][ipid]->GetMean());
  115. eV2tpc.push_back(hv22[det1][ipt][ipid]->GetMeanError());
  116. vV2fhcal.push_back(hv22[det2][ipt][ipid]->GetMean());
  117. eV2fhcal.push_back(hv22[det2][ipt][ipid]->GetMeanError());
  118. vV2RP.push_back(hv22[det0][ipt][ipid]->GetMean());
  119. eV2RP.push_back(hv22[det0][ipt][ipid]->GetMeanError());
  120. delete hptTmp;
  121. }
  122. grv22tpc[ipid] = new TGraphErrors(vPt.size(),&vPt[0],&vV2tpc[0],&ePt[0],&eV2tpc[0]);
  123. grv22tpc[ipid]->SetName(Form("grv22tpc_%i",ipid));
  124. grv22fhcal[ipid] = new TGraphErrors(vPt.size(),&vPt[0],&vV2fhcal[0],&ePt[0],&eV2fhcal[0]);
  125. grv22fhcal[ipid]->SetName(Form("grv22fhcal_%i",ipid));
  126. grv22RP[ipid] = new TGraphErrors(vPt.size(),&vPt[0],&vV2RP[0],&ePt[0],&eV2RP[0]);
  127. grv22RP[ipid]->SetName(Form("grv22RP_%i",ipid));
  128. grv22tpc[ipid]->GetXaxis()->SetTitle("p_{T}, [GeV/c]");
  129. grv22tpc[ipid]->GetYaxis()->SetTitle("v_{2}");
  130. grv22fhcal[ipid]->GetXaxis()->SetTitle("p_{T}, [GeV/c]");
  131. grv22fhcal[ipid]->GetYaxis()->SetTitle("v_{2}");
  132. grv22RP[ipid]->GetXaxis()->SetTitle("p_{T}, [GeV/c]");
  133. grv22RP[ipid]->GetYaxis()->SetTitle("v_{2}");
  134. grv22tpc[ipid] ->SetMarkerStyle(20);
  135. grv22fhcal[ipid]->SetMarkerStyle(26);
  136. grv22RP[ipid]->SetMarkerStyle(21);
  137. grv22tpc[ipid] ->GetYaxis()->SetRangeUser(v2range[1][ipid].first,v2range[1][ipid].second);
  138. grv22fhcal[ipid]->GetYaxis()->SetRangeUser(v2range[1][ipid].first,v2range[1][ipid].second);
  139. grv22RP[ipid]->GetYaxis()->SetRangeUser(v2range[1][ipid].first,v2range[1][ipid].second);
  140. grv22tpc[ipid] ->GetXaxis()->SetLimits(0.,3.49);
  141. grv22fhcal[ipid]->GetXaxis()->SetLimits(0.,3.49);
  142. grv22RP[ipid]->GetXaxis()->SetLimits(0.,3.49);
  143. grv22tpc[ipid] ->SetMarkerSize(1.6);
  144. grv22fhcal[ipid]->SetMarkerSize(1.6);
  145. grv22RP[ipid]->SetMarkerSize(1.6);
  146. vPt.clear(); ePt.clear();
  147. vV2tpc.clear(); eV2tpc.clear();
  148. vV2fhcal.clear(); eV2fhcal.clear();
  149. vV2RP.clear(); eV2RP.clear();
  150. }
  151. TCanvas *canv[ncent];
  152. TLegend *leg[ncent][npid];
  153. TLine *line0 = new TLine();
  154. coord lc[npid] = {{0.2,0.7,0.55,0.89},{0.2,0.82,0.55,0.89},{0.2,0.82,0.55,0.89},{0.2,0.82,0.55,0.89}};
  155. line0->SetLineStyle(2);
  156. line0->SetLineColor(4);
  157. line0->SetLineWidth(1);
  158. for (int icent=0; icent<ncent; icent++)
  159. {
  160. canv[icent] = new TCanvas(Form("canv_%i",icent),Form("canv cent %i",icent),900,900);
  161. canv[icent] ->Divide(2,2);
  162. }
  163. for (int icent=0; icent<ncent; icent++)
  164. {
  165. for (int ipid=0;ipid<npid;ipid++)
  166. {
  167. canv[icent]->cd(ipid+1);
  168. grv2tpc[icent][ipid]->Draw("AP PLC PMC");
  169. grv2RP[icent][ipid]->Draw("P PLC PMC");
  170. grv2fhcal[icent][ipid]->Draw("P PLC PMC");
  171. leg[icent][ipid] = new TLegend(lc[ipid].xlow,lc[ipid].ylow,lc[ipid].xup,lc[ipid].yup);
  172. leg[icent][ipid]->SetBorderSize(0.);
  173. leg[icent][ipid]->SetHeader(Form("%s, %s",hCent[icent].Data(),hName[ipid].Data()),"C");
  174. if (ipid == 0)
  175. {
  176. leg[icent][ipid]->AddEntry(grv2tpc[icent][ipid],"v2{TPC}","p");
  177. leg[icent][ipid]->AddEntry(grv2RP[icent][ipid],"v2{RP}","p");
  178. leg[icent][ipid]->AddEntry(grv2fhcal[icent][ipid],"v2{FHCal}","p");
  179. }
  180. leg[icent][ipid]->Draw();
  181. line0->DrawLine(0.,0.,3.49,0.);
  182. }
  183. // canv[icent]->SaveAs(Form("/home/peter/Documents/WorkLocal/STAR/Pics/Models/EPflow/v2_cent%i.png",icent));
  184. if (icent == 0)
  185. canv[icent]->Print(Form("./v2.pdf("),"pdf");
  186. if (icent == 5)
  187. canv[icent]->Print(Form("./v2.pdf)"),"pdf");
  188. if (icent != 0 && icent != 5)
  189. canv[icent]->Print(Form("./v2.pdf"),"pdf");
  190. }
  191. TCanvas *canv2 = new TCanvas("canv2","10-40%", 900, 900);
  192. TLegend *leg2[npid];
  193. canv2->Divide(2,2);
  194. for (int ipid=0;ipid<npid;ipid++) {
  195. canv2->cd(ipid + 1);
  196. grv22tpc[ipid]->Draw("AP PLC PMC");
  197. grv22RP[ipid]->Draw("P PLC PMC");
  198. grv22fhcal[ipid]->Draw("P PLC PMC");
  199. leg2[ipid] = new TLegend(lc[ipid].xlow,lc[ipid].ylow,lc[ipid].xup,lc[ipid].yup);
  200. leg2[ipid]->SetBorderSize(0.);
  201. leg2[ipid]->SetHeader(Form("10-40%, %s",hName[ipid].Data()),"C");
  202. if (ipid == 0)
  203. {
  204. leg2[ipid]->AddEntry(grv22tpc[ipid],"v2{TPC}","p");
  205. leg2[ipid]->AddEntry(grv22fhcal[ipid],"v2{RP}","p");
  206. leg2[ipid]->AddEntry(grv22fhcal[ipid],"v2{FHCal}","p");
  207. }
  208. leg2[ipid]->Draw();
  209. line0->DrawLine(0.,0.,3.49,0.);
  210. }
  211. canv2->SaveAs("./v2_cent1040.pdf");
  212. TFile *fo = new TFile("./v2_graphs.root","recreate");
  213. fo->cd();
  214. for (int icent=0; icent<ncent; icent++)
  215. {
  216. for (int ipid=0;ipid<npid;ipid++)
  217. {
  218. grv2tpc[icent][ipid]->Write();
  219. grv2RP[icent][ipid]->Write();
  220. grv2fhcal[icent][ipid]->Write();
  221. }
  222. canv[icent]->Write();
  223. }
  224. for (int ipid=0;ipid<npid;ipid++)
  225. {
  226. grv22tpc[ipid]->Write();
  227. grv22RP[ipid]->Write();
  228. grv22fhcal[ipid]->Write();
  229. }
  230. canv2->Write();
  231. fo->Close();
  232. }