GraphFlow.C 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. struct coord
  2. {
  3. float xlow;
  4. float ylow;
  5. float xup;
  6. float yup;
  7. };
  8. void GraphFlow(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. TFile *fo = new TFile("./v2_graphs.root","recreate");
  152. fo->cd();
  153. for (int icent=0; icent<ncent; icent++)
  154. {
  155. for (int ipid=0;ipid<npid;ipid++)
  156. {
  157. grv2tpc[icent][ipid]->Write();
  158. grv2RP[icent][ipid]->Write();
  159. grv2fhcal[icent][ipid]->Write();
  160. }
  161. }
  162. for (int ipid=0;ipid<npid;ipid++)
  163. {
  164. grv22tpc[ipid]->Write();
  165. grv22RP[ipid]->Write();
  166. grv22fhcal[ipid]->Write();
  167. }
  168. fo->Close();
  169. }