StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plotDirectCumulants_v2pt.C
1 //
3 // $Id: plotDirectCumulants_v2pt.C,v 1.1 2010/03/08 16:54:53 posk Exp $
4 //
5 // Authors: Dhevan Gangadharan and Art Poskanzer, Jan 2010
6 //
7 // Description: Macro to replot the v2(pt) TGraphErrors made by directCumulants_v2.C
8 // cent=1 is the most central
9 // cent=0 is the yield weighted average of all the others.
10 //
12 
13 #include <math.h>
14 #include "TMath.h"
15 #include <iostream.h>
16 #include <iomanip.h>
17 
18 plotDirectCumulants_v2pt() {
19 
20  TCanvas* cOld = (TCanvas*)gROOT->GetListOfCanvases(); // delete old canvas
21  if (cOld) cOld->Delete();
22 
23  bool ptGraphs = kTRUE;
24 
25  gROOT->SetStyle("Bold"); // set style
26  gStyle->SetOptStat(0);
27 
28  const int CENTBINS=9;
29  const int PTBINS= 61; // max ptbins
30  float v2max = 0.4;
31 
32  TFile graphFile("flow.dirCumulant.graphs.root", "READ");
33  //graphFile.ls();
34 
35  TGraphErrors* charged_v2_2[CENTBINS+1];
36  TGraphErrors* charged_v2_4[CENTBINS+1];
37  TCanvas* can[CENTBINS+1];
38  int canvasWidth = 780, canvasHeight = 600; // landscape
39  for (int cent=0; cent<CENTBINS+1; cent++) {
40  if (ptGraphs) {
41  TString* canName = new TString("centrality_");
42  *canName += cent;
43  cout << "plot " << canName->Data() << endl;
44  can[cent] = new TCanvas(canName->Data(), canName->Data(), canvasWidth, canvasHeight);
45  TLegend *legend = new TLegend(.17,.67,.5,.87,NULL,"brNDC");
46  legend->SetFillColor(kWhite);
47  }
48 
49  // v22
50  TString graphName("v22_");
51  graphName += cent;
52  charged_v2_2[cent] = dynamic_cast<TGraphErrors*>(graphFile.Get(graphName.Data()));
53  if (!charged_v2_2[cent]) {
54  cout << "### Can't find graph " << graphName.Data() << endl;
55  return;
56  }
57  charged_v2_2[cent]->SetMarkerStyle(20);
58  charged_v2_2[cent]->SetMarkerColor(2);
59  charged_v2_2[cent]->SetLineColor(2);
60  charged_v2_2[cent]->SetMinimum(0.);
61  charged_v2_2[cent]->SetMaximum(v2max);
62  charged_v2_2[cent]->GetXaxis()->SetTitle("P_{t} (GeV/c)");
63  charged_v2_2[cent]->GetYaxis()->SetTitle("v_{2}");
64 
65  // v24
66  TString graphName("v24_");
67  graphName += (cent);
68  charged_v2_4[cent] = dynamic_cast<TGraphErrors*>(graphFile.Get(graphName.Data()));
69  if (!charged_v2_4[cent]) {
70  cout << "### Can't find graph " << graphName.Data() << endl;
71  return;
72  }
73  charged_v2_4[cent]->SetMarkerStyle(20);
74  charged_v2_4[cent]->SetMarkerColor(4);
75  charged_v2_4[cent]->SetLineColor(4);
76  charged_v2_4[cent]->SetMinimum(0.);
77  charged_v2_4[cent]->SetMaximum(v2max);
78  charged_v2_4[cent]->GetXaxis()->SetTitle("P_{t} (GeV/c)");
79  charged_v2_4[cent]->GetYaxis()->SetTitle("v_{2}{4}");
80 
81  if (ptGraphs) {
82  charged_v2_2[cent]->Draw("AP");
83  legend->AddEntry(charged_v2_2[cent],"charged hadron v_{2}{2}","p");
84  charged_v2_4[cent]->Draw("P");
85  legend->AddEntry(charged_v2_4[cent],"charged hadron v_{2}{4}","p");
86 
87  legend->Draw("same");
88  }
89 
90  //can[cent]->Print(".pdf");
91 
92  }//cent
93 
94  // multi graph
95  int canvasWidth = 600, canvasHeight = 780; // portrait
96  TString* canName = new TString("v2_pt");
97  cout << "plot " << canName->Data() << endl;
98  TCanvas* canMulti = new TCanvas(canName->Data(), canName->Data(), canvasWidth, canvasHeight);
99  canMulti->ToggleEventStatus();
100  TPaveLabel* canTitle = new TPaveLabel(0.1,0.96,0.9,0.99,canName->Data());
101  canTitle->Draw();
102  TLegend *legendMulti = new TLegend(.17,.67,.5,.87,NULL,"brNDC");
103  legendMulti->SetFillColor(kWhite);
104  gStyle->SetLabelSize(0.1,"x");
105  TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.97,0.95);
106  graphPad->Draw();
107  graphPad->cd();
108  int columns = 2;
109  int rows = (CENTBINS+1)/2;
110  graphPad->Divide(columns,rows);
111 
112  for (int cent=0; cent<CENTBINS+1; cent++) {
113  TString graphName("cent_");
114  graphName += cent;
115  graphPad->cd(cent+1);
116  charged_v2_2[cent]->SetTitle(graphName);
117  charged_v2_2[cent]->Draw("AP");
118  charged_v2_4[cent]->Draw("P");
119  if (cent==0) {
120  legendMulti->AddEntry(charged_v2_2[cent],"charged hadron v_{2}{2}","p");
121  legendMulti->AddEntry(charged_v2_4[cent],"charged hadron v_{2}{4}","p");
122  legendMulti->Draw("same");
123  }
124  }//cent
125  graphPad->cd(0);
126 
127  graphFile.Close();
128 
129 }