7 #include "TGraphAsymmErrors.h"
15 #include <Riostream.h>
40 const char *raafileMethod2=
"",
41 const char *raaOutFilename=
"", Bool_t isRaa=
true)
44 const char *namesRaa[7] = {
"hRABvsPt",
"gRAB_Norm",
"gRAB_DataSystematics",
"gRAB_FeedDownSystematics",
"gRAB_ElossHypothesis",
"gRAB_FeedDownSystematicsElossHypothesis",
"gRAB_GlobalSystematics" };
45 const char *namesRcp[7] = {
"hRCPvsPt",
"gRCP_Norm",
"gRCP_DataSystematics",
"gRCP_FeedDownSystematics",
"gRCP_ElossSystematics",
"gRCP_FeedDownElossSystematics",
"gRCP_GlobalSystematics" };
46 const char *namesRead[7];
47 for(
int i=0; i<7; i++) {
48 if(isRaa) namesRead[i]=namesRaa[i];
49 else namesRead[i]=namesRcp[i];
51 const char *
suffix=
"AB";
if(!isRaa) suffix=
"CP";
55 TFile * raaf2 =
new TFile(raafileMethod2,
"read");
56 TH1D * hRaa2 = (TH1D*)raaf2->Get(namesRead[0]);
57 TGraphAsymmErrors * gRAB_Norm = (TGraphAsymmErrors*)raaf2->Get(namesRead[1]);
58 TGraphAsymmErrors * gRAB_Data2 = (TGraphAsymmErrors*)raaf2->Get(namesRead[2]);
59 TGraphAsymmErrors * gRAB_Data2PP;
60 TGraphAsymmErrors * gRAB_Data2AB;
62 gRAB_Data2PP = (TGraphAsymmErrors*)raaf2->Get(
"gRAB_DataSystematicsPP");
63 gRAB_Data2AB = (TGraphAsymmErrors*)raaf2->Get(
"gRAB_DataSystematicsAB");
65 TGraphAsymmErrors * gRAB_FD2 = (TGraphAsymmErrors*)raaf2->Get(namesRead[3]);
66 TGraphAsymmErrors * gRAB_Eloss2 = (TGraphAsymmErrors*)raaf2->Get(namesRead[4]);
67 TGraphAsymmErrors * gRAB_FDEloss2 = (TGraphAsymmErrors*)raaf2->Get(namesRead[5]);
68 TGraphAsymmErrors * gRAB_Global2 = (TGraphAsymmErrors*)raaf2->Get(namesRead[6]);
69 hRaa2->SetTitle( Form(
"Nb : %s",hRaa2->GetTitle()) );
70 gRAB_Data2->SetTitle( Form(
"Nb : %s",gRAB_Data2->GetTitle()) );
73 gRAB_FDEloss2->SetTitle( Form(
"Nb : %s",gRAB_FDEloss2->GetTitle()) );
74 gRAB_Global2->SetTitle( Form(
"Nb : %s",gRAB_Global2->GetTitle()) );
75 cout <<
" Read Raa with Nb method file "<< endl;
79 TFile * raaf1 =
new TFile(raafileMethod1,
"read");
80 TH1D * hRaa1 = (TH1D*)raaf1->Get(namesRead[0]);
81 TGraphAsymmErrors * gRAB_Data1 = (TGraphAsymmErrors*)raaf1->Get(namesRead[2]);
82 TGraphAsymmErrors * gRAB_FD1 = (TGraphAsymmErrors*)raaf1->Get(namesRead[3]);
83 TGraphAsymmErrors * gRAB_Eloss1 = (TGraphAsymmErrors*)raaf1->Get(namesRead[4]);
84 TGraphAsymmErrors * gRAB_FDEloss1 = (TGraphAsymmErrors*)raaf1->Get(namesRead[5]);
85 TGraphAsymmErrors * gRAB_Global1 = (TGraphAsymmErrors*)raaf1->Get(namesRead[6]);
86 hRaa1->SetTitle( Form(
"fc : %s",hRaa1->GetTitle()) );
87 gRAB_Data1->SetTitle( Form(
"fc : %s",gRAB_Data1->GetTitle()) );
88 gRAB_FDEloss1->SetTitle( Form(
"fc : %s",gRAB_FDEloss1->GetTitle()) );
89 gRAB_Global1->SetTitle( Form(
"fc : %s",gRAB_Global1->GetTitle()) );
90 cout <<
" Read Raa with fc method file "<< endl;
94 TFile * out =
new TFile(raaOutFilename,
"recreate");
95 TH1D * hRaa = (TH1D*)hRaa2->Clone(Form(
"hR%svsPt",suffix));
96 hRaa->SetNameTitle(Form(
"%s",namesRead[0]),Form(
" R_{%s}(c) vs p_{T} for both Nb & fc",suffix));
97 TGraphAsymmErrors * gRAB_DataSystematics =
new TGraphAsymmErrors();
98 gRAB_DataSystematics->SetNameTitle(Form(
"gR%s_DataSystematics",suffix),Form(
"Data only systematics on R_{%s}",suffix));
99 TGraphAsymmErrors * gRAB_FeedDownSystematicsElossHypothesis =
new TGraphAsymmErrors();
100 gRAB_FeedDownSystematicsElossHypothesis->SetNameTitle(Form(
"gR%s_FeedDownSystematicsElossHypothesis",suffix),
"Feed-down + Eloss systematics for both Nb & fc");
101 TGraphAsymmErrors * gRAB_FeedDownSystematics =
new TGraphAsymmErrors();
102 gRAB_FeedDownSystematics->SetNameTitle(Form(
"gR%s_FeedDownSystematics",suffix),
"Feed-down systematics for both Nb & fc");
103 TGraphAsymmErrors * gRAB_ElossHypothesis =
new TGraphAsymmErrors();
104 gRAB_ElossHypothesis->SetNameTitle(Form(
"gR%s_ElossHypothesis",suffix),
"Eloss systematics for both Nb & fc");
105 TGraphAsymmErrors * gRAB_GlobalSystematics =
new TGraphAsymmErrors();
106 gRAB_GlobalSystematics->SetNameTitle(Form(
"gR%s_GlobalSystematics",suffix),
"Global systematics (data + FD + Eloss) for both Nb & fc");
107 cout <<
" Created output file : "<< raaOutFilename << endl;
112 Double_t pt=0., Raa=0., ptwidth=0.;
113 Int_t istartDS=0, istartFDEl1=0,istartFDEl2=0, istartFD1=0,istartFD2=0, istartEl1=0,istartEl2=0;
114 Double_t dataHigh=0., dataLow=0., gfdElossHigh=0, gfdElossLow=0., gfdHigh=0, gfdLow=0., gElossHigh=0, gElossLow=0., globalHigh=0, globalLow=0.;
115 Double_t ElossHigh1=0., ElossLow1=0., ElossHigh2=0., ElossLow2=0., fdHigh1=0., fdLow1=0., fdHigh2=0., fdLow2=0.;
116 Double_t vfdHigh1=0., vfdLow1=0., vfdHigh2=0., vfdLow2=0.;
117 Double_t fdElossHigh1=0., fdElossLow1=0., fdElossHigh2=0., fdElossLow2=0.;
118 Double_t vfdElossHigh1=0., vfdElossLow1=0., vfdElossHigh2=0., vfdElossLow2=0.;
120 Int_t
nbins = hRaa->GetNbinsX();
122 for(Int_t ibin=1; ibin<=
nbins; ibin++){
124 cout <<
" loop, i="<<ibin<<endl;
125 pt = hRaa->GetBinCenter(ibin);
126 Raa = hRaa->GetBinContent(ibin);
127 if( Raa<=0. )
continue;
128 cout <<
" pt="<<pt<<
", Raa="<<Raa<<endl;
131 Int_t n = gRAB_Data2->GetN();
132 for(Int_t j=0; j<=n; j++){
133 gRAB_Data2->GetPoint(j,x,y);
134 if ( TMath::Abs ( x -pt ) < 0.4 ) {
139 dataHigh = gRAB_Data2->GetErrorYhigh(istartDS);
140 dataLow = gRAB_Data2->GetErrorYlow(istartDS);
141 cout <<
" Data syst : + "<< dataHigh <<
" - "<< dataLow <<
" = +"<< dataHigh/Raa <<
" -"<< dataLow/Raa <<
" %"<<endl;
144 n = gRAB_FD2->GetN();
145 for(Int_t j=0; j<=n; j++){
146 gRAB_FD2->GetPoint(j,x,y);
147 if ( TMath::Abs ( x -pt ) < 0.4 ) {
152 fdHigh2 = gRAB_FD2->GetErrorYhigh(istartFD2);
153 fdLow2 = gRAB_FD2->GetErrorYlow(istartFD2);
154 vfdHigh2 = y + fdHigh2;
155 vfdLow2 = y - fdLow2;
156 cout <<
" FD syst : Nb "<< Raa<<
" +"<< fdHigh2 <<
" -"<< fdLow2 <<
" = ("<<vfdLow2<<
","<<vfdHigh2<<
") = +" << fdHigh2/Raa <<
" -" << fdLow2/Raa <<
" %" <<endl;
159 n = gRAB_FD1->GetN();
160 for(Int_t j=0; j<=n; j++){
161 gRAB_FD1->GetPoint(j,x,y);
162 if ( TMath::Abs ( x -pt ) < 0.4 ) {
167 fdHigh1 = gRAB_FD1->GetErrorYhigh(istartFD1);
168 fdLow1 = gRAB_FD1->GetErrorYlow(istartFD1);
169 vfdHigh1 = y + fdHigh1;
170 vfdLow1 = y - fdLow1;
171 cout <<
" FD syst : fc "<< y<<
" +"<< fdHigh1 <<
" -"<< fdLow1 <<
" = ("<<vfdLow1<<
","<<vfdHigh1
172 <<
") = +" << fdHigh1/Raa <<
" -" << fdLow1/Raa <<
" %" <<endl;
176 n = gRAB_Eloss2->GetN();
177 for(Int_t j=0; j<=n; j++){
178 gRAB_Eloss2->GetPoint(j,x,y);
179 if ( TMath::Abs ( x -pt ) < 0.4 ) {
184 ElossHigh2 = gRAB_Eloss2->GetErrorYhigh(istartEl2);
185 ElossLow2 = gRAB_Eloss2->GetErrorYlow(istartEl2);
186 cout <<
" Eloss syst : Nb "<< Raa<<
" +"<< ElossHigh2 <<
" -"<< ElossLow2 <<
" = + "<< ElossHigh2/Raa <<
" - "<< ElossLow2/Raa <<
" %" <<endl;
189 n = gRAB_Eloss1->GetN();
190 for(Int_t j=0; j<=n; j++){
191 gRAB_Eloss1->GetPoint(j,x,y);
192 if ( TMath::Abs ( x -pt ) < 0.4 ) {
197 ElossHigh1 = gRAB_Eloss1->GetErrorYhigh(istartEl1);
198 ElossLow1 = gRAB_Eloss1->GetErrorYlow(istartEl1);
199 cout <<
" Eloss syst : fc "<< Raa<<
" +"<< ElossHigh1 <<
" -"<< ElossLow1 <<
" = + "<< ElossHigh1/Raa <<
" - "<< ElossLow1/Raa <<
" %" <<endl;
203 n = gRAB_FDEloss2->GetN();
204 for(Int_t j=0; j<=n; j++){
205 gRAB_FDEloss2->GetPoint(j,x,y);
206 if ( TMath::Abs ( x -pt ) < 0.4 ) {
211 fdElossHigh2 = gRAB_FDEloss2->GetErrorYhigh(istartFDEl2);
212 fdElossLow2 = gRAB_FDEloss2->GetErrorYlow(istartFDEl2);
213 vfdElossHigh2 = y + fdElossHigh2;
214 vfdElossLow2 = y - fdElossLow2;
215 cout <<
" FD&Eloss syst : Nb "<< Raa<<
" +"<< fdElossHigh2 <<
" -"<< fdElossLow2 <<
" = ("<<vfdElossLow2<<
","<<vfdElossHigh2<<
")" <<endl;
218 n = gRAB_FDEloss1->GetN();
219 for(Int_t j=0; j<=n; j++){
220 gRAB_FDEloss1->GetPoint(j,x,y);
221 if ( TMath::Abs ( x -pt ) < 0.4 ) {
226 fdElossHigh1 = gRAB_FDEloss1->GetErrorYhigh(istartFDEl1);
227 fdElossLow1 = gRAB_FDEloss1->GetErrorYlow(istartFDEl1);
228 vfdElossHigh1 = y + fdElossHigh1;
229 vfdElossLow1 = y - fdElossLow1;
230 cout <<
" FD&Eloss syst : fc "<< y<<
" +"<< fdElossHigh1 <<
" -"<< fdElossLow1 <<
" = ("<<vfdElossLow1<<
","<<vfdElossHigh1
231 <<
") = +" << fdElossHigh1/Raa <<
" -" << fdElossLow1/Raa <<
" %" <<endl;
235 gfdLow = ( vfdLow2 < vfdLow1 ) ? vfdLow2 : vfdLow1;
237 gfdLow = TMath::Abs(gfdLow - Raa);
239 gfdHigh = ( vfdHigh2 > vfdHigh1 ) ? vfdHigh2 : vfdHigh1 ;
241 gfdHigh = TMath::Abs(gfdHigh - Raa);
243 cout <<
" FD syst tot : +"<< gfdHigh <<
" -"<< gfdLow <<
" = +"<< gfdHigh/Raa <<
" - "<< gfdLow/Raa <<
" %"<<endl;
247 gElossLow = ( ElossLow2/Raa > ElossLow1/Raa ) ? ElossLow2/Raa : ElossLow1/Raa;
250 gElossHigh = ( ElossHigh2/Raa > ElossHigh1/Raa ) ? ElossHigh2/Raa : ElossHigh1/Raa ;
253 cout <<
" Eloss syst tot : +"<< gElossHigh <<
" -"<< gElossLow <<
" = +"<< gElossHigh/Raa <<
" -"<< gElossLow/Raa <<
" %"<<endl;
257 gfdElossLow = ( vfdElossLow2 < vfdElossLow1 ) ? vfdElossLow2 : vfdElossLow1;
259 gfdElossLow = TMath::Abs(gfdElossLow - Raa);
261 gfdElossHigh = ( vfdElossHigh2 > vfdElossHigh1 ) ? vfdElossHigh2 : vfdElossHigh1 ;
263 gfdElossHigh = TMath::Abs(gfdElossHigh - Raa);
265 cout <<
" FD&Eloss syst tot : +"<< gfdElossHigh <<
" -"<< gfdElossLow <<
" = +"<< gfdElossHigh/Raa <<
" -"<< gfdElossLow/Raa <<
" %"<<endl;
269 globalHigh = TMath::Sqrt( dataHigh*dataHigh + gfdElossHigh*gfdElossHigh );
270 globalLow = TMath::Sqrt( dataLow*dataLow + gfdElossLow*gfdElossLow );
271 cout <<
" Global syst tot : +"<< globalHigh <<
" -"<< globalLow <<
" = + "<< globalHigh/Raa <<
" - " << globalLow/Raa <<
" %"<<endl;
273 ptwidth = hRaa->GetBinWidth(ibin)/2.;
274 gRAB_DataSystematics->SetPoint(jbins,pt,Raa);
275 gRAB_DataSystematics->SetPointError(jbins,ptwidth,ptwidth,dataLow,dataHigh);
277 gRAB_FeedDownSystematicsElossHypothesis->SetPoint(jbins,pt,Raa);
278 gRAB_FeedDownSystematicsElossHypothesis->SetPointError(jbins,ptwidth,ptwidth,gfdElossLow,gfdElossHigh);
280 gRAB_GlobalSystematics->SetPoint(jbins,pt,Raa);
281 gRAB_GlobalSystematics->SetPointError(jbins,ptwidth,ptwidth,globalLow,globalHigh);
286 TH2D *hRaaCanvas =
new TH2D(
"hRaaCanvas",Form(
" R_{%s}(c) vs p_{T} (for both Nb & fc); p_{t} (GeV/c) ; R_{%s} prompt D",suffix,suffix),25,0.,25.,100,0.,2.0);
287 hRaaCanvas->GetXaxis()->SetTitleSize(0.05);
288 hRaaCanvas->GetXaxis()->SetTitleOffset(0.9);
289 hRaaCanvas->GetYaxis()->SetTitleSize(0.05);
290 hRaaCanvas->GetYaxis()->SetTitleOffset(0.9);
293 TCanvas *cdata =
new TCanvas(
"Compare data syst unc.");
296 gRAB_DataSystematics->SetFillStyle(3017);
297 gRAB_DataSystematics->SetLineColor(4);
298 gRAB_DataSystematics->SetLineWidth(3);
299 gRAB_DataSystematics->SetFillColor(4);
300 gRAB_DataSystematics->Draw(
"2");
301 hRaa2->SetMarkerStyle(28);
302 hRaa2->SetMarkerColor(kGreen+2);
304 gRAB_Data2->SetLineColor(kGreen+2);
305 gRAB_Data2->Draw(
"2");
306 hRaa1->SetMarkerStyle(24);
307 hRaa1->SetMarkerColor(kOrange+7);
309 gRAB_Data1->SetLineColor(kOrange+7);
310 gRAB_Data1->Draw(
"2");
311 TLegend* leg = cdata->BuildLegend();
312 leg->SetFillStyle(0);
314 TLine *line =
new TLine(0.0172415,1.0,25.,1.0);
315 line->SetLineStyle(2);
319 TCanvas *cfd =
new TCanvas(
"Compare FD & Eloss syst unc.");
322 gRAB_FeedDownSystematicsElossHypothesis->SetFillStyle(3017);
323 gRAB_FeedDownSystematicsElossHypothesis->SetLineColor(4);
324 gRAB_FeedDownSystematicsElossHypothesis->SetLineColor(kBlack);
325 gRAB_FeedDownSystematicsElossHypothesis->SetFillStyle(0);
326 gRAB_FeedDownSystematicsElossHypothesis->SetFillColor(kViolet+1);
327 gRAB_FeedDownSystematicsElossHypothesis->Draw(
"2");
329 gRAB_FDEloss2->SetLineColor(kGreen+2);
330 gRAB_FDEloss2->Draw(
"2");
332 gRAB_FDEloss1->SetLineColor(kOrange+7);
333 gRAB_FDEloss1->Draw(
"2");
334 leg = cfd->BuildLegend();
335 leg->SetFillStyle(0);
339 TCanvas *cglobal =
new TCanvas(
"Compare global syst unc.");
342 gRAB_GlobalSystematics->SetFillStyle(3017);
343 gRAB_GlobalSystematics->SetLineColor(4);
344 gRAB_GlobalSystematics->Draw(
"2");
346 gRAB_Global2->SetLineColor(kGreen+2);
347 gRAB_Global2->Draw(
"2");
349 gRAB_Global1->SetLineColor(kOrange+7);
350 gRAB_Global1->Draw(
"2");
351 leg = cglobal->BuildLegend();
352 leg->SetFillStyle(0);
356 gROOT->SetStyle(
"Plain");
357 gStyle->SetPalette(1);
358 gStyle->SetOptStat(0);
359 TCanvas *RaaPlot =
new TCanvas(
"RaaPlot",Form(
"R%s vs pt, plot all",suffix));
360 RaaPlot->SetTopMargin(0.085);
361 RaaPlot->SetBottomMargin(0.1);
370 gRAB_Norm->SetFillStyle(1001);
371 gRAB_Norm->SetFillColor(kGray+2);
372 gRAB_Norm->Draw(
"2");
373 line =
new TLine(0.0172415,1.0,25.,1.0);
374 line->SetLineStyle(2);
379 gRAB_GlobalSystematics->SetFillStyle(0);
380 gRAB_GlobalSystematics->Draw(
"2");
390 gRAB_DataSystematics->Write();
392 gRAB_Data2PP->Write();
393 gRAB_Data2AB->Write();
395 gRAB_FeedDownSystematics->Write();
396 gRAB_ElossHypothesis->Write();
397 gRAB_FeedDownSystematicsElossHypothesis->Write();
398 gRAB_GlobalSystematics->Write();
void CombineRaaFeedDownUncertainties(const char *raafileMethod1="", const char *raafileMethod2="", const char *raaOutFilename="", Bool_t isRaa=true)