DrawTGraph.C 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. // Draws 2 TGraphErrors (upper panel) with their gr1/gr2 ratio (lower pannel)
  2. TCanvas *DrawTGraph(TGraphErrors *const &gr1, TGraphErrors *const &gr2, TString str="",
  3. Double_t yRatio_low=0.89, Double_t yRatio_high=1.11)
  4. {
  5. // Setting up global variables for the plot
  6. gROOT->SetStyle("Pub");
  7. gROOT->ForceStyle();
  8. gStyle->SetPalette(kDarkRainBow);
  9. gStyle->SetErrorX(0);
  10. // Read points
  11. Double_t *vx_gr1 = gr1->GetX();
  12. Double_t *vy_gr1 = gr1->GetY();
  13. Double_t *vx_gr2 = gr2->GetX();
  14. Double_t *vy_gr2 = gr2->GetY();
  15. // Read errors
  16. Double_t *ex_gr1 = gr1->GetEX();
  17. Double_t *ey_gr1 = gr1->GetEY();
  18. Double_t *ex_gr2 = gr2->GetEX();
  19. Double_t *ey_gr2 = gr2->GetEY();
  20. Int_t n1bins = gr1->GetN();
  21. // Initialization of the canvas & pads
  22. TCanvas *canv = new TCanvas(Form("canv"),Form("Canvas"),900,800);
  23. canv->cd();
  24. TPad *padUp = new TPad(Form("padUp"),"v2 vs pt",0.,0.33,1.,1.,0,-1,0);
  25. TPad *padDown = new TPad(Form("padDown"),"Ratio v2",0.,0.,1.,0.33,0,-1,0);
  26. double padUW;
  27. double padUH;
  28. double padDW;
  29. double padDH;
  30. padUp->SetBorderSize(0);
  31. padDown->SetBorderSize(0);
  32. padUp->SetBottomMargin(0.);
  33. padDown->SetTopMargin(0.005);
  34. padUW = padUp->GetWw()*padUp->GetAbsWNDC();
  35. padUH = padUp->GetWh()*padUp->GetAbsHNDC();
  36. padDW = padDown->GetWw()*padDown->GetAbsWNDC();
  37. padDH = padDown->GetWh()*padDown->GetAbsHNDC();
  38. padUp->Draw();
  39. padDown->Draw();
  40. // Setting up markers & colors for TGraphErrors
  41. gr1->SetMarkerStyle(26);
  42. gr1->SetMarkerSize(1.6);
  43. gr1->SetLineColor(kRed);
  44. gr1->SetMarkerColor(kRed);
  45. gr2->SetMarkerStyle(20);
  46. gr2->SetMarkerSize(1.6);
  47. gr2->SetLineColor(kBlack);
  48. gr2->SetMarkerColor(kBlack);
  49. // Draw TGraphErrors in the upper pad
  50. padUp->cd();
  51. gr1->GetXaxis()->SetLimits(0.95*vx_gr1[0],1.05*vx_gr1[n1bins-1]);
  52. gr1->GetXaxis()->SetLabelSize(0.06);
  53. gr1->GetYaxis()->SetLabelSize(0.06);
  54. gr1->GetXaxis()->SetTitleSize(0.07);
  55. gr1->GetYaxis()->SetTitleSize(0.07);
  56. gr1->GetYaxis()->SetTitleOffset(1.08);
  57. gr1->Draw("AP");
  58. gr2->Draw("P");
  59. TLegend *leg_pt = new TLegend(0.468,0.04,0.89,0.309);
  60. leg_pt->SetBorderSize(0);
  61. leg_pt->SetHeader(str.Data(),"C");
  62. // leg_pt->SetHeader(Form("Au+Au,#sqrt{s_{NN}}=200 GeV"),"C");
  63. leg_pt->AddEntry(gr1,Form("%s",gr1->GetTitle()),"p");
  64. leg_pt->AddEntry(gr2,Form("%s",gr2->GetTitle()),"p");
  65. leg_pt->Draw();
  66. //Draw gr1/gr2 ratio in the bottom pad
  67. padDown->cd();
  68. std::vector<Double_t> v1X;
  69. std::vector<Double_t> v1Y;
  70. std::vector<Double_t> v1Xerr;
  71. std::vector<Double_t> v1Yerr;
  72. std::vector<Double_t> v2X;
  73. std::vector<Double_t> v2Y;
  74. std::vector<Double_t> v2Xerr;
  75. std::vector<Double_t> v2Yerr;
  76. std::vector<Double_t> vRatioY;
  77. std::vector<Double_t> vRatioYerr;
  78. for (int i=0; i<gr1->GetN();i++)
  79. {
  80. v1X.push_back(vx_gr1[i]);
  81. v1Y.push_back(vy_gr1[i]);
  82. v1Xerr.push_back(ex_gr1[i]);
  83. v1Yerr.push_back(ey_gr1[i]);
  84. v2Y.push_back((Double_t) gr2->Eval(v1X.at(i),0,"S"));
  85. v2Yerr.push_back(ey_gr2[i]);
  86. vRatioY.push_back(v1Y.at(i)/v2Y.at(i));
  87. vRatioYerr.push_back(
  88. TMath::Sqrt(
  89. TMath::Power(v1Yerr.at(i)/v2Y.at(i),2) +
  90. TMath::Power(v1Y.at(i)*v2Yerr.at(i)/(v2Y.at(i)*v2Y.at(i)),2)
  91. )
  92. );
  93. }
  94. TGraphErrors *grRatio = new TGraphErrors(v1X.size(),&v1X[0],&vRatioY[0],&v1Xerr[0],&vRatioYerr[0]);
  95. grRatio->GetXaxis()->SetLabelSize(0.11);
  96. grRatio->GetYaxis()->SetLabelSize(0.11);
  97. grRatio->GetXaxis()->SetTitleSize(0.12);
  98. grRatio->GetYaxis()->SetTitleSize(0.12);
  99. grRatio->GetYaxis()->SetTitle(Form("%s/%s",gr1->GetTitle(),gr2->GetTitle()));
  100. grRatio->GetYaxis()->SetTitleOffset(0.65);
  101. grRatio->GetXaxis()->SetTitle(Form("%s",gr1->GetXaxis()->GetTitle()));
  102. padDown->SetBottomMargin(0.3);
  103. grRatio->GetYaxis()->SetNdivisions(504);
  104. grRatio->GetXaxis()->SetTickLength(3*12/padUH);
  105. grRatio->GetYaxis()->SetTickLength(2.6*12/padUW);
  106. grRatio->GetYaxis()->SetRangeUser(yRatio_low,yRatio_high);
  107. // grRatio->GetYaxis()->SetRangeUser(0.81,1.19);
  108. grRatio->SetMarkerStyle(26);
  109. grRatio->SetMarkerSize(1.6);
  110. grRatio->SetLineColor(kRed);
  111. grRatio->SetMarkerColor(kRed);
  112. grRatio->GetXaxis()->SetLimits(0.95*vx_gr1[0],1.05*vx_gr1[n1bins-1]);
  113. grRatio->Draw("AP");
  114. TLine lineOne;
  115. lineOne.SetLineStyle(1);
  116. TLine line90;
  117. line90.SetLineWidth(2.);
  118. line90.SetLineStyle(2);
  119. TLine line110;
  120. line110.SetLineWidth(2.);
  121. line110.SetLineStyle(2);
  122. // lineOne.SetLineColor(kRed);
  123. lineOne.DrawLine(0.95*vx_gr1[0],1., 1.05*vx_gr1[n1bins-1],1.);
  124. line90.DrawLine( 0.95*vx_gr1[0],.95, 1.05*vx_gr1[n1bins-1],.95);
  125. line110.DrawLine(0.95*vx_gr1[0],1.05,1.05*vx_gr1[n1bins-1],1.05);
  126. return canv;
  127. }
  128. // Draws N TGraphErrors (upper panel) with their grN/gr1 ratio (lower pannel)
  129. TCanvas *DrawTGraph(std::vector<TGraphErrors*> vgr, TString str,
  130. Double_t yRatio_low=0.89, Double_t yRatio_high=1.11,
  131. Double_t x_low=0.0, Double_t x_high=1.0,
  132. Double_t y_low=0.0, Double_t y_high=1.0,
  133. Double_t leg_x_low=0.22, Double_t leg_y_low=0.55,
  134. Double_t leg_x_high=0.55, Double_t leg_y_high=0.89)
  135. {
  136. // Setting up global variables for the plot
  137. gROOT->SetStyle("Pub");
  138. gROOT->ForceStyle();
  139. gStyle->SetPalette(kDarkRainBow);
  140. gStyle->SetErrorX(0);
  141. std::vector<Double_t*> vx_gr, vy_gr, ex_gr, ey_gr;
  142. std::vector<Int_t> nbins;
  143. for (int i=0; i<vgr.size();i++)
  144. {
  145. // Read points
  146. vx_gr.push_back(vgr.at(i)->GetX());
  147. vy_gr.push_back(vgr.at(i)->GetY());
  148. // Read errors
  149. ex_gr.push_back(vgr.at(i)->GetEX());
  150. ey_gr.push_back(vgr.at(i)->GetEY());
  151. nbins.push_back(vgr.at(i)->GetN());
  152. }
  153. // Initialization of the canvas & pads
  154. TCanvas *canv = new TCanvas(Form("canv"),Form("Canvas"),900,800);
  155. canv->cd();
  156. TPad *padUp = new TPad(Form("padUp"),"v2 vs pt",0.,0.33,1.,1.,0,-1,0);
  157. TPad *padDown = new TPad(Form("padDown"),"Ratio v2",0.,0.,1.,0.33,0,-1,0);
  158. double padUW;
  159. double padUH;
  160. double padDW;
  161. double padDH;
  162. padUp->SetBorderSize(0);
  163. padDown->SetBorderSize(0);
  164. padUp->SetBottomMargin(0.);
  165. padDown->SetTopMargin(0.005);
  166. padUW = padUp->GetWw()*padUp->GetAbsWNDC();
  167. padUH = padUp->GetWh()*padUp->GetAbsHNDC();
  168. padDW = padDown->GetWw()*padDown->GetAbsWNDC();
  169. padDH = padDown->GetWh()*padDown->GetAbsHNDC();
  170. padUp->Draw();
  171. padDown->Draw();
  172. // Draw TGraphErrors in the upper pad
  173. padUp->cd();
  174. // gr1->GetXaxis()->SetLimits(0.95*vx_gr1[0],1.05*vx_gr1[n1bins-1]);
  175. vgr.at(0)->GetXaxis()->SetLimits(x_low,x_high);
  176. vgr.at(0)->GetYaxis()->SetRangeUser(y_low,y_high);
  177. vgr.at(0)->GetXaxis()->SetLabelSize(0.06);
  178. vgr.at(0)->GetYaxis()->SetLabelSize(0.06);
  179. vgr.at(0)->GetXaxis()->SetTitleSize(0.07);
  180. vgr.at(0)->GetYaxis()->SetTitleSize(0.07);
  181. vgr.at(0)->GetYaxis()->SetTitleOffset(1.08);
  182. vgr.at(0)->Draw("AP PLC PMC");
  183. for (int i=1; i<vgr.size();i++)
  184. {
  185. vgr.at(i)->Draw("P PLC PMC");
  186. }
  187. // TLegend *leg_pt = new TLegend(0.568,0.02,0.89,0.295);
  188. TLegend *leg_pt = new TLegend(leg_x_low,leg_y_low,leg_x_high,leg_y_high);
  189. leg_pt->SetBorderSize(0);
  190. leg_pt->SetHeader(str.Data(),"C");
  191. for (int i=0; i<vgr.size();i++)
  192. {
  193. leg_pt->AddEntry(vgr.at(i),Form("%s",vgr.at(i)->GetTitle()),"p");
  194. }
  195. leg_pt->Draw();
  196. //Draw grN/gr1 ratio in the bottom pad
  197. padDown->cd();
  198. std::vector<Double_t> v1X;
  199. std::vector<Double_t> v1Y;
  200. std::vector<Double_t> v1Xerr;
  201. std::vector<Double_t> v1Yerr;
  202. std::vector<Double_t> v2X;
  203. std::vector<Double_t> v2Y;
  204. std::vector<Double_t> v2Xerr;
  205. std::vector<Double_t> v2Yerr;
  206. std::vector<Double_t> vRatioY;
  207. std::vector<Double_t> vRatioYerr;
  208. std::vector<TGraphErrors*> vgrRatio;
  209. for (int igr=1; igr<vgr.size();igr++)
  210. {
  211. v1X.clear();
  212. v1Y.clear();
  213. v1Xerr.clear();
  214. v1Yerr.clear();
  215. v2X.clear();
  216. v2Y.clear();
  217. v2Xerr.clear();
  218. v2Yerr.clear();
  219. vRatioY.clear();
  220. vRatioYerr.clear();
  221. for (int i=0; i<vgr.at(igr)->GetN();i++)
  222. {
  223. v1X.push_back(vx_gr.at(igr)[i]);
  224. v1Y.push_back(vy_gr.at(igr)[i]);
  225. v1Xerr.push_back(ex_gr.at(igr)[i]);
  226. v1Yerr.push_back(ey_gr.at(igr)[i]);
  227. v2Y.push_back((Double_t) vgr.at(0)->Eval(v1X.at(i),0,"S"));
  228. v2Yerr.push_back(ey_gr.at(0)[i]);
  229. vRatioY.push_back(v1Y.at(i)/v2Y.at(i));
  230. vRatioYerr.push_back(
  231. TMath::Sqrt(
  232. TMath::Power(v1Yerr.at(i)/v2Y.at(i),2) +
  233. TMath::Power(v1Y.at(i)*v2Yerr.at(i)/(v2Y.at(i)*v2Y.at(i)),2)
  234. )
  235. );
  236. }
  237. vgrRatio.push_back(new TGraphErrors(v1X.size(),&v1X[0],&vRatioY[0],&v1Xerr[0],&vRatioYerr[0]));
  238. }
  239. padDown->SetBottomMargin(0.3);
  240. for (int igr=0; igr<vgrRatio.size();igr++)
  241. {
  242. vgrRatio.at(igr)->GetXaxis()->SetLabelSize(0.11);
  243. vgrRatio.at(igr)->GetYaxis()->SetLabelSize(0.11);
  244. vgrRatio.at(igr)->GetXaxis()->SetTitleSize(0.12);
  245. vgrRatio.at(igr)->GetYaxis()->SetTitleSize(0.12);
  246. // vgrRatio.at(igr)->GetYaxis()->SetTitle(Form("%s/%s",vgr.at(igr+1)->GetTitle(),vgr.at(0)->GetTitle()));
  247. vgrRatio.at(igr)->GetYaxis()->SetTitle(Form("Ratio"));
  248. vgrRatio.at(igr)->GetYaxis()->SetTitleOffset(0.65);
  249. vgrRatio.at(igr)->GetXaxis()->SetTitle(Form("%s",vgr.at(0)->GetXaxis()->GetTitle()));
  250. vgrRatio.at(igr)->GetYaxis()->SetNdivisions(504);
  251. vgrRatio.at(igr)->GetXaxis()->SetTickLength(3*12/padUH);
  252. vgrRatio.at(igr)->GetYaxis()->SetTickLength(2.6*12/padUW);
  253. vgrRatio.at(igr)->GetYaxis()->SetRangeUser(yRatio_low,yRatio_high);
  254. vgrRatio.at(igr)->SetMarkerStyle(vgr.at(igr+1)->GetMarkerStyle());
  255. vgrRatio.at(igr)->SetMarkerSize(1.6);
  256. vgrRatio.at(igr)->SetLineColor(kRed);
  257. vgrRatio.at(igr)->SetMarkerColor(kRed);
  258. // grRatio->GetXaxis()->SetLimits(0.95*vx_gr1[0],1.05*vx_gr1[n1bins-1]);
  259. if (igr==0)
  260. {
  261. vgrRatio.at(igr)->GetXaxis()->SetLimits(x_low,x_high);
  262. vgrRatio.at(igr)->Draw("AP PLC PMC");
  263. }
  264. // else{
  265. vgrRatio.at(igr)->Draw("P PLC PMC");
  266. // }
  267. TLine lineOne;
  268. lineOne.SetLineStyle(1);
  269. TLine line90;
  270. line90.SetLineWidth(2.);
  271. line90.SetLineStyle(2);
  272. TLine line110;
  273. line110.SetLineWidth(2.);
  274. line110.SetLineStyle(2);
  275. // lineOne.SetLineColor(kRed);
  276. lineOne.DrawLine(x_low,1., x_high,1.);
  277. line90.DrawLine( x_low,.95, x_high,.95);
  278. line110.DrawLine(x_low,1.05,x_high,1.05);
  279. }
  280. return canv;
  281. }
  282. // Draws N TGraphErrors (upper panel) with their grN/gr1 ratio (lower pannel)
  283. TCanvas *DrawTGraphNoRatio(std::vector<TGraphErrors*> vgr, TString str,
  284. Double_t x_low=0.0, Double_t x_high=1.0)
  285. {
  286. // Setting up global variables for the plot
  287. gROOT->SetStyle("Pub");
  288. gROOT->ForceStyle();
  289. gStyle->SetPalette(kDarkRainBow);
  290. gStyle->SetErrorX(0);
  291. std::vector<Double_t*> vx_gr, vy_gr, ex_gr, ey_gr;
  292. std::vector<Int_t> nbins;
  293. for (int i=0; i<vgr.size();i++)
  294. {
  295. // Read points
  296. vx_gr.push_back(vgr.at(i)->GetX());
  297. vy_gr.push_back(vgr.at(i)->GetY());
  298. // Read errors
  299. ex_gr.push_back(vgr.at(i)->GetEX());
  300. ey_gr.push_back(vgr.at(i)->GetEY());
  301. nbins.push_back(vgr.at(i)->GetN());
  302. }
  303. // Initialization of the canvas & pads
  304. TCanvas *canv = new TCanvas(Form("canv"),Form("Canvas"),900,600);
  305. canv->cd();
  306. // gr1->GetXaxis()->SetLimits(0.95*vx_gr1[0],1.05*vx_gr1[n1bins-1]);
  307. vgr.at(0)->GetXaxis()->SetLimits(x_low,x_high);
  308. // vgr.at(0)->GetYaxis()->SetRangeUser(y_low,y_high);
  309. vgr.at(0)->GetXaxis()->SetLabelSize(0.06);
  310. vgr.at(0)->GetYaxis()->SetLabelSize(0.06);
  311. vgr.at(0)->GetXaxis()->SetTitleSize(0.07);
  312. vgr.at(0)->GetYaxis()->SetTitleSize(0.07);
  313. vgr.at(0)->GetYaxis()->SetTitleOffset(1.08);
  314. vgr.at(0)->Draw("AP PLC PMC");
  315. for (int i=1; i<vgr.size();i++)
  316. {
  317. vgr.at(i)->Draw("P PLC PMC");
  318. }
  319. // TLegend *leg_pt = new TLegend(0.568,0.02,0.89,0.295);
  320. TLegend *leg_pt = new TLegend(0.22,0.55,0.55,0.89);
  321. leg_pt->SetBorderSize(0);
  322. leg_pt->SetHeader(str.Data(),"C");
  323. for (int i=0; i<vgr.size();i++)
  324. {
  325. leg_pt->AddEntry(vgr.at(i),Form("%s",vgr.at(i)->GetTitle()),"p");
  326. }
  327. leg_pt->Draw();
  328. return canv;
  329. }
  330. // Save TGraphs in file
  331. void SaveTGraph(TString outFileName, TGraphErrors *const &gr1, TGraphErrors *const &gr2)
  332. {
  333. TFile *fo = new TFile(outFileName.Data(),"recreate");
  334. fo->cd();
  335. TCanvas *canv = (TCanvas*) DrawTGraph(gr1, gr2);
  336. gr1->Write();
  337. gr2->Write();
  338. canv->Write();
  339. }
  340. // Convert TProfile into TGraphErrors
  341. TGraphErrors *ConvertProfile(TProfile *const& pr)
  342. {
  343. std::vector<Double_t> vX, vY, vEx, vEy;
  344. for (int ibin=0; ibin<pr->GetNbinsX(); ibin++)
  345. {
  346. vX.push_back(pr->GetBinCenter(ibin+1));
  347. vEx.push_back(0.);
  348. vY.push_back(pr->GetBinContent(ibin+1));
  349. vEy.push_back(pr->GetBinError(ibin+1));
  350. }
  351. TGraphErrors *gr = new TGraphErrors(vX.size(),&vX[0],&vY[0],&vEx[0],&vEy[0]);
  352. gr->SetTitle(pr->GetTitle());
  353. gr->SetName(pr->GetName());
  354. gr->GetXaxis()->SetTitle(pr->GetXaxis()->GetTitle());
  355. gr->GetYaxis()->SetTitle(pr->GetYaxis()->GetTitle());
  356. gr->SetMarkerStyle(pr->GetMarkerStyle());
  357. gr->SetMarkerSize(pr->GetMarkerSize());
  358. gr->SetMarkerColor(pr->GetMarkerColor());
  359. gr->SetLineColor(pr->GetLineColor());
  360. return gr;
  361. }
  362. // Test function. Shows basic usage of DrawTGraph()
  363. void Test()
  364. {
  365. // cent 0-10%
  366. const std::vector<Double_t> vPt_cent1 = {0.247,0.348,0.448,0.548,0.648,0.748,0.848,0.948,1.092,1.292,1.492,1.692,1.892,2.200,2.703,3.343};
  367. const std::vector<Double_t> vV2_cent1 = {0.01342,0.01488,0.01231,0.02085,0.01557,0.02236,0.02656,0.03014,0.04275,0.03826,0.03859,0.04492,0.06318,0.06910,0.07798,0.07481};
  368. const std::vector<Double_t> ePt_cent1 = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
  369. const std::vector<Double_t> eV2_cent1 = {0.00114,0.00131,0.00133,0.00170,0.00166,0.00203,0.00233,0.00265,0.00268,0.00304,0.00367,0.00476,0.00654,0.00672,0.01123,0.01667};
  370. const std::vector<Double_t> sysl_cent1 = {0.00972,0.00130,0.00123,0.00187,0.00112,0.00129,0.00116,0.00121,0.00145,0.00110,0.00091,0.00120,0.00167,0.00168,0.00224,0.00294};
  371. const std::vector<Double_t> sysh_cent1 = {0.00972,0.00130,0.00123,0.00187,0.00112,0.00129,0.00116,0.00121,0.00145,0.00110,0.00091,0.00120,0.00167,0.00168,0.00224,0.00294};
  372. const std::vector<Double_t> eePt_cent1 = {0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05};
  373. // cent 10-20%
  374. const std::vector<Double_t> vPt_cent2 = {0.247,0.348,0.448,0.548,0.648,0.748,0.848,0.948,1.092,1.292,1.492,1.692,1.892,2.200,2.703,3.343};
  375. const std::vector<Double_t> vV2_cent2 = {0.02194,0.02987,0.03696,0.04342,0.05052,0.05556,0.06572,0.07064,0.07773,0.09169,0.10236,0.11847,0.13255,0.13748,0.15166,0.14679};
  376. const std::vector<Double_t> ePt_cent2 = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
  377. const std::vector<Double_t> eV2_cent2 = {0.00061,0.00070,0.00078,0.00088,0.00098,0.00110,0.00125,0.00141,0.00122,0.00155,0.00204,0.00275,0.00365,0.00363,0.00640,0.00945,0.02444,0.05846};
  378. const std::vector<Double_t> sysl_cent2 = {0.00506,0.00264,0.00283,0.00348,0.00269,0.00236,0.00224,0.00213,0.00207,0.00202,0.00227,0.00238,0.00308,0.00270,0.00313,0.00322,0.00505,0.00160};
  379. const std::vector<Double_t> sysh_cent2 = {0.00506,0.00264,0.00283,0.00348,0.00269,0.00236,0.00224,0.00213,0.00207,0.00202,0.00227,0.00238,0.00308,0.00270,0.00313,0.00322,0.00505,0.00160};
  380. const std::vector<Double_t> eePt_cent2 = {0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05};
  381. TGraphErrors *grPHENIX[2];
  382. grPHENIX[0] = new TGraphErrors(vPt_cent1.size(),&vPt_cent1[0],&vV2_cent1[0],&ePt_cent1[0],&eV2_cent1[0]);
  383. grPHENIX[1] = new TGraphErrors(vPt_cent2.size(),&vPt_cent2[0],&vV2_cent2[0],&ePt_cent2[0],&eV2_cent2[0]);
  384. // Make titile names for graph and axes.
  385. // Those names will be used in DrawTGraph() to plot legend and axis names
  386. grPHENIX[0]->SetTitle("0-10%");
  387. grPHENIX[0]->GetXaxis()->SetTitle("p_{T}, [GeV/c]");
  388. grPHENIX[0]->GetYaxis()->SetTitle("v_{2}");
  389. grPHENIX[1]->SetTitle("10-20%");
  390. grPHENIX[1]->GetXaxis()->SetTitle("p_{T}, [GeV/c]");
  391. grPHENIX[1]->GetYaxis()->SetTitle("v_{2}");
  392. TCanvas *canv = (TCanvas*) DrawTGraph(grPHENIX[0],grPHENIX[1]);
  393. SaveTGraph("outfile.root",grPHENIX[0],grPHENIX[1]);
  394. }