16 #include "TGraphErrors.h"
23 #include "StMessMgr.h"
25 #include "StGlauberConstUtilities.h"
26 #include "StGlauberPlotMaker.h"
45 mSystematicError = 0 ;
54 if(mSystematicError)
delete mSystematicError ;
60 ifstream fin(filename.Data());
62 Error(
"StGlauberPlotMaker::Read",
"can't open %s", filename.Data());
66 LOG_INFO << Form(
"StGlauberPlotMaker::Read OPEN %s (%s)", filename.Data(), type.Data()) << endm;
68 TGraphErrors* gall =
new TGraphErrors() ;
69 TGraphErrors* gdraw =
new TGraphErrors() ;
70 const TString name(
"g" + mName) ;
71 gall ->SetName(Form(
"%s_all_%d", name.Data(), mGraphId));
72 gdraw->SetName(Form(
"%s_draw_%d", name.Data(), mGraphId));
73 gall ->SetTitle(type);
74 gdraw->SetTitle(type);
77 LOG_INFO <<
"StGlauberPlotMaker::Read Init graphs: "
78 << gall->GetName() <<
" and " << gdraw->GetName()
81 const UInt_t ncent = mNCentrality ;
83 Double_t centMin, centMax ;
86 for(UInt_t ic=0; ic<StGlauberConstUtilities::GetCentralityBin(); ic++)
88 fin >> centralityId >> centMin >> centMax >> val >> error ;
90 const Double_t cent = (centMin + centMax)/2.0 ;
91 if( centralityId < ncent ){
92 gdraw->SetPoint(centralityId, cent, val);
93 gdraw->SetPointError(centralityId, 0.0, error);
96 LOG_INFO <<
"StGlauberPlotMaker::Read " << mName <<
": centrality (min,max) = ("
97 << centMin <<
"," << centMax <<
"), val = "
98 << val <<
" +/- " << error
101 gall->SetPoint(centralityId, cent, val);
102 gall->SetPointError(centralityId, 0.0, error);
106 mGraph.push_back( gall );
107 mGraphDraw.push_back( gdraw );
113 Double_t StGlauberPlotMaker::GetYMinimum()
const
115 Double_t ymin = 0.0 ;
116 if( mName.CompareTo(
"impactparameter", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
117 else if ( mName.CompareTo(
"npart", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
118 else if ( mName.CompareTo(
"ncoll", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
119 else if ( mName.CompareTo(
"multiplicity", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
120 else if ( mName.CompareTo(
"arearp", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
121 else if ( mName.CompareTo(
"areapp", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
122 else if ( mName.CompareTo(
"eccrp", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
123 else if ( mName.CompareTo(
"eccrpm", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
124 else if ( mName.CompareTo(
"eccpp_0", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
125 else if ( mName.CompareTo(
"eccpp_0_2", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
126 else if ( mName.CompareTo(
"eccpp_1", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
127 else if ( mName.CompareTo(
"eccpp_1_2", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
128 else if ( mName.CompareTo(
"eccppm_0", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
129 else if ( mName.CompareTo(
"eccppm_0_2", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
130 else if ( mName.CompareTo(
"eccppm_1", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
131 else if ( mName.CompareTo(
"eccppm_1_2", TString::kIgnoreCase) == 0 ) ymin = 0.0 ;
133 Error(
"StGlauberPlotMaker::GetYMinimum", Form(
"Cannot find %s in the list. return 0", mName.Data()));
141 Double_t StGlauberPlotMaker::GetYMaximum()
const
143 Double_t ymax = 0.0 ;
144 if( mName.CompareTo(
"impactparameter", TString::kIgnoreCase) == 0 ) ymax = 18.0 ;
145 else if ( mName.CompareTo(
"npart", TString::kIgnoreCase) == 0 ) ymax = 420.0 ;
146 else if ( mName.CompareTo(
"ncoll", TString::kIgnoreCase) == 0 ) ymax = 1200.0 ;
147 else if ( mName.CompareTo(
"multiplicity", TString::kIgnoreCase) == 0 ) ymax = 1200.0 ;
148 else if ( mName.CompareTo(
"arearp", TString::kIgnoreCase) == 0 ) ymax = 42.0 ;
149 else if ( mName.CompareTo(
"areapp", TString::kIgnoreCase) == 0 ) ymax = 42.0 ;
150 else if ( mName.CompareTo(
"eccrp", TString::kIgnoreCase) == 0 ) ymax = 0.98 ;
151 else if ( mName.CompareTo(
"eccrpm", TString::kIgnoreCase) == 0 ) ymax = 0.98 ;
152 else if ( mName.CompareTo(
"eccpp_0", TString::kIgnoreCase) == 0 ) ymax = 0.98 ;
153 else if ( mName.CompareTo(
"eccpp_0_2", TString::kIgnoreCase) == 0 ) ymax = 0.98 ;
154 else if ( mName.CompareTo(
"eccpp_1", TString::kIgnoreCase) == 0 ) ymax = 0.98 ;
155 else if ( mName.CompareTo(
"eccpp_1_2", TString::kIgnoreCase) == 0 ) ymax = 0.98 ;
156 else if ( mName.CompareTo(
"eccppm_0", TString::kIgnoreCase) == 0 ) ymax = 0.98 ;
157 else if ( mName.CompareTo(
"eccppm_0_2", TString::kIgnoreCase) == 0 ) ymax = 0.98 ;
158 else if ( mName.CompareTo(
"eccppm_1", TString::kIgnoreCase) == 0 ) ymax = 0.98 ;
159 else if ( mName.CompareTo(
"eccppm_1_2", TString::kIgnoreCase) == 0 ) ymax = 0.98 ;
161 Error(
"StGlauberPlotMaker::GetYMaximum", Form(
"Cannot find %s in the list. return 0", mName.Data()));
169 TString StGlauberPlotMaker::GetYTitle()
const
173 if( mName.CompareTo(
"impactparameter", TString::kIgnoreCase) == 0 ) title =
"#LTb#GT (fm)" ;
174 else if ( mName.CompareTo(
"npart", TString::kIgnoreCase) == 0 ) title =
"N_{part}" ;
175 else if ( mName.CompareTo(
"ncoll", TString::kIgnoreCase) == 0 ) title =
"N_{coll}" ;
176 else if ( mName.CompareTo(
"multiplicity", TString::kIgnoreCase) == 0 ) title =
"Multiplicity" ;
177 else if ( mName.CompareTo(
"arearp", TString::kIgnoreCase) == 0 ) title =
"#LTS_{RP}#GT (fm^{2})" ;
178 else if ( mName.CompareTo(
"areapp", TString::kIgnoreCase) == 0 ) title =
"#LTS_{PP}#GT (fm^{2})" ;
179 else if ( mName.CompareTo(
"eccrp", TString::kIgnoreCase) == 0 ) title =
"#LT#varepsilon_{RP}#GT" ;
180 else if ( mName.CompareTo(
"eccrpm", TString::kIgnoreCase) == 0 ) title =
"#LT#varepsilon_{RP}#GT" ;
181 else if ( mName.CompareTo(
"eccpp_0", TString::kIgnoreCase) == 0 ) title =
"#LT#varepsilon_{part}#GT" ;
182 else if ( mName.CompareTo(
"eccpp_0_2", TString::kIgnoreCase) == 0 ) title =
"#varepsilon_{part}{2}" ;
183 else if ( mName.CompareTo(
"eccpp_1", TString::kIgnoreCase) == 0 ) title =
"#LT#varepsilon_{3,part}#GT" ;
184 else if ( mName.CompareTo(
"eccpp_1_2", TString::kIgnoreCase) == 0 ) title =
"#varepsilon_{3,part}{2}" ;
185 else if ( mName.CompareTo(
"eccppm_0", TString::kIgnoreCase) == 0 ) title =
"#LT#varepsilon_{part}#GT" ;
186 else if ( mName.CompareTo(
"eccppm_0_2", TString::kIgnoreCase) == 0 ) title =
"#varepsilon_{part}{2}" ;
187 else if ( mName.CompareTo(
"eccppm_1", TString::kIgnoreCase) == 0 ) title =
"#LT#varepsilon_{3,part}#GT" ;
188 else if ( mName.CompareTo(
"eccppm_1_2", TString::kIgnoreCase) == 0 ) title =
"#varepsilon_{3,part}{2}" ;
190 Error(
"StGlauberPlotMaker::GetYTitle", Form(
"Cannot find %s in the list. return 0", mName.Data()));
198 TGraphErrors* StGlauberPlotMaker::Divide(
const TGraphErrors& g0,
const TGraphErrors& g1)
const
200 TGraphErrors* g =
new TGraphErrors();
201 g->SetMarkerSize( g0.GetMarkerSize() );
202 g->SetMarkerStyle( g0.GetMarkerStyle() );
203 g->SetMarkerColor( g0.GetMarkerColor() );
204 g->SetLineColor( g0.GetLineColor() );
206 for(Int_t i=0;i<g0.GetN();i++){
207 const Double_t y0 = g0.GetY()[i] ;
208 const Double_t y1 = g1.GetY()[i] ;
209 const Double_t y0e = g0.GetEY()[i] ;
210 const Double_t y1e = g1.GetEY()[i] ;
213 const Double_t r = y0/y1 ;
214 const Double_t re = TMath::Abs(r) * TMath::Sqrt(TMath::Power(y0e/y0,2.0)+TMath::Power(y1e/y1,2.0)) ;
215 const Int_t n = g->GetN() ;
217 g->SetPoint(n, g0.GetX()[i], r) ;
218 g->SetPointError(n, g0.GetEX()[i], re) ;
226 TGraphErrors* StGlauberPlotMaker::SystematicErrors(
const UInt_t mode)
229 if( mGraph.size() < 2 ){
230 Error(
"StGlauberPlotMaker::SystematicErrors",
"Number of graphs < 2, at least 2 graphs are needed to evaluate sys. errors. abort");
235 LOG_INFO <<
"StGlauberPlotMaker::SystematicErrors Start evaluating systematic errors" << endm;
239 const UInt_t nCent = mGraph[0]->GetN() ;
240 Double_t qSum[nCent] ;
241 for(UInt_t ic=0; ic<nCent; ic++){
245 const UInt_t nSize = mGraph.size() ;
246 for(UInt_t
id=1;
id<nSize;
id++){
247 LOG_INFO <<
"StGlauberPlotMaker::SystematicErrors Use " << mGraph[id]->GetTitle() << endm;
249 for(UInt_t ic=0; ic<nCent; ic++){
250 const Double_t val = mGraph[id]->GetY()[ic];
251 const Double_t ref = mGraph[0]->GetY()[ic];
252 const Double_t diff = val - ref;
253 qSum[ic] += diff * diff ;
258 mSystematicError =
new TGraph();
260 Double_t factor = 1.0/TMath::Sqrt(12.0) ;
261 if( mode == 1 ) factor = 1.0 ;
263 for(UInt_t ic=0; ic<nCent; ic++){
264 qSum[ic] = TMath::Sqrt(qSum[ic]) * factor ;
265 mSystematicError->SetPoint(ic, ic+0.5, qSum[ic]);
269 TGraphErrors* g =
new TGraphErrors() ;
270 g->SetFillColor(kYellow);
271 g->SetLineColor(kYellow);
273 for(UInt_t ic=0; ic<mNCentrality; ic++){
274 g->SetPoint(ic, mGraph[0]->GetX()[ic], mGraph[0]->GetY()[ic]);
275 g->SetPointError(ic, 0.0, qSum[ic]);
285 TColor::CreateColorWheel();
286 gStyle->SetPadRightMargin(0.05);
289 TGraphErrors* gSysError = SystematicErrors(mode) ;
292 TCanvas* c1 =
new TCanvas(Form(
"c%d", mCanvasId), Form(
"c%d", mCanvasId++), 600, 800);
296 const UInt_t style[] = {20, 21, 25, 22, 26, 29, 21, 25, 22, 26, 27, 28};
297 const UInt_t color[] = {kBlack, kRed, kRed, kBlue, kBlue, kMagenta+1,
299 kOrange+1, kOrange+1,
309 const Double_t ymin = GetYMinimum() ;
310 const Double_t ymax = GetYMaximum() ;
312 TH1* frame = c1->GetPad(1)->DrawFrame(0, ymin, 80, ymax);
313 frame->SetXTitle(
"% Most central");
314 frame->SetYTitle(GetYTitle());
316 TLegend* leg =
new TLegend(0.05, 0.1, 0.95, 0.9);
317 leg->SetTextSize(0.05);
318 leg->SetFillColor(10);
321 const UInt_t nSize = mGraphDraw.size() ;
322 TGraphErrors* gRatio[nSize] ;
323 for(UInt_t
id=0;
id<nSize;
id++){
324 mGraphDraw[id]->SetMarkerSize(1.2);
325 mGraphDraw[id]->SetMarkerStyle(style[
id]);
326 mGraphDraw[id]->SetMarkerColor(color[
id]);
327 mGraphDraw[id]->SetLineColor(color[
id]);
328 mGraphDraw[id]->Draw(
"P");
331 gRatio[id] = Divide(*mGraphDraw[
id], *mGraphDraw[0]) ;
334 leg->AddEntry(mGraphDraw[
id], gRatio[
id]->GetTitle(),
"P");
336 mGraphDraw[0]->Draw(
"P");
341 TPad* pad = (TPad*) c1->GetPad(2);
345 const Double_t rmin = 1.0 - 0.3 ;
346 const Double_t rmax = 1.0 + 0.3 ;
347 TH1* frameRatio = pad->GetPad(1)->DrawFrame(0, rmin, 80, rmax);
348 frameRatio->SetXTitle(
"% Most central");
349 frameRatio->SetYTitle(Form(
"Ratio of %s", GetYTitle().Data()));
351 TLine* lzero =
new TLine(0, 1.0, 80, 1.0);
352 lzero->SetLineStyle(3);
355 for(UInt_t
id=1;
id<nSize;
id++){
356 gRatio[id]->Draw(
"P");
368 c1->Print(Form(
"figure/systematicerror_%s.eps", mName.Data()));
374 TCanvas* c2 =
new TCanvas(Form(
"c%d", mCanvasId), Form(
"c%d", mCanvasId++));
375 TH1* frame2 = c2->DrawFrame(0, ymin, 80, ymax);
376 frame2->SetXTitle(
"% Most central");
377 frame2->SetYTitle(GetYTitle());
379 gSysError->Draw(
"E3");
380 mGraphDraw[0]->Draw(
"P");
385 c2->Print(Form(
"figure/%s_vs_centrality_with_systematicerror.eps", mName.Data()));
390 TCanvas* c3 =
new TCanvas(Form(
"c%d", mCanvasId), Form(
"c%d", mCanvasId++), 700*0.5, 500*0.5);
391 TH1* frame3 = c3->DrawFrame(0, ymin, 80, ymax);
392 frame3->SetXTitle(
"% Most central");
393 frame3->SetYTitle(GetYTitle());
395 gSysError->Draw(
"E3");
396 mGraphDraw[0]->Draw(
"P");
401 c3->Print(Form(
"figure/%s_vs_centrality_with_systematicerror.png", mName.Data()));
406 const TString tableName(Form(
"table_%s_vs_centrality_systematicerror.txt", mName.Data()));
407 ofstream fout(tableName.Data()) ;
408 LOG_INFO << Form(
"StGlauberPlotMaker::Draw Write table %s in the current directory", tableName.Data()) << endm;
410 for(Int_t ic=0; ic<mGraph[0]->GetN(); ic++){
411 const Double_t val = mGraph[0]->GetY()[ic] ;
412 const Double_t sys = mSystematicError->GetY()[ic] ;
413 const Double_t centMin = StGlauberConstUtilities::GetCentralityMin(ic) ;
414 const Double_t centMax = StGlauberConstUtilities::GetCentralityMax(ic) ;
416 fout << Form(
"%10d %1.1f %1.1f %1.5f %1.5f",
417 ic, centMin, centMax, val, sys) << endl;
419 fout << endl << endl ;
420 fout <<
"# <centrality bin> <minimum centrality> <maximum centrality> <value> <sys. error>" << endl;
void Draw(const UInt_t mode=0)
virtual ~StGlauberPlotMaker()
Default constructor.
Int_t Read(const TString filename, const TString type)
Default destructor.