AliPhysics  a23ce79 (a23ce79)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtractGSE.C
Go to the documentation of this file.
1 
11 #ifndef __CINT__
12 # include "GraphSysErr.C"
13 # include <TFile.h>
14 # include <TList.h>
15 # include <TMath.h>
16 # include <TCanvas.h>
17 # include <TLegend.h>
18 # include <TSeqCollection.h>
19 # include <TLegendEntry.h>
20 # include <THStack.h>
21 #else
22 class TSeqCollection;
23 class TCanvas;
24 class TGraphErrors;
25 class THStack;
26 class TLegend;
27 class TH1;
28 #endif
29 
30 //____________________________________________________________________
39 void MakeCommon(TObject* o, const char* name, Double_t val, Color_t c)
40 {
41  GraphSysErr* gse = static_cast<GraphSysErr*>(o);
42  Int_t id = gse->DefineCommon(name,true,val,GraphSysErr::kBox);
43  gse->SetSysFillColor(id, c);
44  gse->SetSysLineColor(id, c);
45 }
46 //____________________________________________________________________
56 Int_t MakeP2P(TObject* o, const char* name, Color_t c)
57 {
58  GraphSysErr* gse = static_cast<GraphSysErr*>(o);
59  Int_t id = gse->DeclarePoint2Point(name,true,GraphSysErr::kBox);
60  gse->SetSysFillColor(id, c);
61  gse->SetSysLineColor(id, c);
62  return id;
63 }
64 
65 //====================================================================
67 {
68  return sMin + TMath::Power(x/xMax, 2)*(sMax-sMin);
69 }
70 
72 {
73  return SysEval(x, sMin, sMax, 80);
74 }
76 {
77  return SysEval(x, sMin, sMax, 2);
78 }
79 
80 //____________________________________________________________________
91 TObject* MakeGSE(TDirectory* d, UShort_t sNN, Double_t c1, Double_t c2)
92 {
93  if (!gROOT->GetClass("GraphSysErr")) return 0;
94  TString bin; bin.Form("%03dd%02d_%03dd%02d",
95  Int_t(c1), Int_t(c1*100)%100,
96  Int_t(c2), Int_t(c2*100)%100);
97  TString sub(bin); sub.Prepend("cent"); sub.Append("/dndeta");
98  TString nme(bin); nme.Prepend("CENT_");
99  TH1* g = GetH1(d, sub);
100  if (!g) return 0;
101 
102  Color_t col = g->GetMarkerColor();
103  // Double_t bg = (1-c1/100)*(2-0.1)+0.1;
104  // Double_t c = TMath::Power(c1/100,2)*(6.2-0.4)+0.4;
105  Double_t cMin = sNN == 5023 ? 0.005 : 0.004;
106  Double_t cMax = sNN == 5023 ? 0.075 : 0.062;
107  Double_t bg = CSysEval(c2, 0.02, 0.001);
108  Double_t c = CSysEval(c2, cMin, cMax);
109  GraphSysErr* gse = new GraphSysErr(g->GetNbinsX());
110  gse->SetName(nme);
111  gse->SetTitle(Form("%5.1f - %5.1f%%", c1, c2));
112  gse->SetKey("author", (sNN == 5023 ? "PREGHENELLA : 2015":"SHAHOYAN : 2013"));
113  gse->SetKey("title", Form("dNch/deta in PbPb at %d GeV", sNN));
114  gse->SetKey("obskey", "DN/DETARAP");
115  gse->SetKey("reackey", "PB PB --> CHARGED X");
116  gse->SetKey("laboratory", "CERN");
117  gse->SetKey("accelerator", "LHC");
118  gse->SetKey("detector", "TRACKLETS");
119  gse->SetKey("reference", sNN==5023 ? "ALICE-AN-2830" : "ALICE-AN-2180");
120  gse->AddQualifier("CENTRALITY IN PCT", Form("%.1f TO %.1f",c1,c2));
121  gse->AddQualifier("SQRT(S)/NUCLEON IN GEV", Form("%d", sNN));
122  gse->SetXTitle("ETARAP");
123  gse->SetYTitle("DN/DETARAP");
124  gse->SetMarkerStyle(g->GetMarkerStyle());
125  gse->SetMarkerSize(g->GetMarkerSize());
127  gse->SetMarkerColor(col);
128  gse->SetLineColor(col);
129  gse->SetFillColor(col);
130  gse->SetSumFillColor(col);
131  gse->SetSumLineColor(col);
133  gse->SetCommonSumFillColor(col);
134  gse->SetCommonSumLineColor(col);
136  MakeCommon(gse, "Particle composition", 0.01, col);
137  MakeCommon(gse, "Weak decay", 0.01, col);
138  MakeCommon(gse, "pT extrapolation", 0.02, col);
139  MakeCommon(gse, "EG dependence", 0.02, col);
140  MakeCommon(gse, "Background subrtaction", bg, col);
141  MakeCommon(gse, "Centrality", c, col);
142  Int_t acc = MakeP2P(gse, "Acceptance", col);
143 
144  Int_t j = 0;
145  for (Int_t i = 1; i <= g->GetNbinsX(); i++) {
146  Double_t eta = g->GetXaxis()->GetBinCenter(i);
147  Double_t eEta = g->GetXaxis()->GetBinWidth(i)/2;
148  Double_t xo = TMath::Abs(eta)+eEta;
149  if (xo > 2) continue;
150  Double_t ea = 0.02*TMath::Power(xo/2,2);
151  gse->SetPoint(j, eta, g->GetBinContent(i));
152  gse->SetPointError(j, eEta, eEta);
153  gse->SetStatError(j, g->GetBinError(i),g->GetBinError(i));
154  gse->SetSysError(acc, j, eEta, eEta, ea/100, ea/100);
155  j++;
156  }
157  return gse;
158 
159 
160 }
161 
162 //____________________________________________________________________
173 TObject* MakeTGSE(TDirectory* d, UShort_t sNN, Double_t c1, Double_t c2)
174 {
175  if (!gROOT->GetClass("GraphSysErr")) return 0;
176  TString bin; bin.Form("%03dd%02d_%03dd%02d",
177  Int_t(c1), Int_t(c1*100)%100,
178  Int_t(c2), Int_t(c2*100)%100);
179  TString sub(bin); sub.Prepend("cent"); sub.Append("/averages/truth");
180  TString nme(bin); nme.Prepend("CENTT_");
181  TH1* g = GetH1(d, sub);
182  if (!g) return 0;
183 
184  Color_t col = g->GetMarkerColor();
185  // Double_t bg = (1-c1/100)*(2-0.1)+0.1;
186  // Double_t c = TMath::Power(c1/100,2)*(6.2-0.4)+0.4;
187  GraphSysErr* gse = new GraphSysErr(g->GetNbinsX());
188  gse->SetName(nme);
189  gse->SetTitle(Form("%5.1f - %5.1f%%", c1, c2));
190  gse->SetKey("author", (sNN == 5023 ? "PREGHENELLA : 2015":"SHAHOYAN : 2013"));
191  gse->SetKey("title", Form("dNch/deta in PbPb at %d GeV", sNN));
192  gse->SetKey("obskey", "DN/DETARAP");
193  gse->SetKey("reackey", "PB PB --> CHARGED X");
194  gse->SetKey("laboratory", "CERN");
195  gse->SetKey("accelerator", "LHC");
196  gse->SetKey("detector", "TRACKLETS");
197  gse->SetKey("reference", sNN==5023 ? "ALICE-AN-2830" : "ALICE-AN-2180");
198  gse->AddQualifier("CENTRALITY IN PCT", Form("%.1f TO %.1f",c1,c2));
199  gse->AddQualifier("SQRT(S)/NUCLEON IN GEV", Form("%d", sNN));
200  gse->SetXTitle("ETARAP");
201  gse->SetYTitle("DN/DETARAP");
202  gse->SetMarkerStyle(g->GetMarkerStyle());
203  gse->SetMarkerSize(g->GetMarkerSize());
205  gse->SetMarkerColor(col);
206  gse->SetLineColor(col);
207  gse->SetFillColor(col);
208  gse->SetSumFillColor(col);
209  gse->SetSumLineColor(col);
211  gse->SetCommonSumFillColor(col);
212  gse->SetCommonSumLineColor(col);
214 
215  Int_t j = 0;
216  for (Int_t i = 1; i <= g->GetNbinsX(); i++) {
217  Double_t eta = g->GetXaxis()->GetBinCenter(i);
218  Double_t eEta = g->GetXaxis()->GetBinWidth(i)/2;
219  Double_t xo = TMath::Abs(eta)+eEta;
220  if (xo > 2) continue;
221  Double_t ea = 0.02*TMath::Power(xo/2,2);
222  gse->SetPoint(j, eta, g->GetBinContent(i));
223  gse->SetPointError(j, eEta, eEta);
224  gse->SetStatError(j, g->GetBinError(i),g->GetBinError(i));
225  j++;
226  }
227  return gse;
228 
229 
230 }
231 
232 //____________________________________________________________________
233 TObject*
234 GetO(TDirectory* dir, const char* name, TClass* cls=0)
235 {
236  if (!dir) {
237  Warning("GetO", "No directory passed");
238  return 0;
239  }
240 
241  TObject* o = dir->Get(name);
242  if (!o) {
243  Warning("GetO", "object %s not found in %s",
244  name, dir->GetPath());
245  return 0;
246  }
247  if (!cls) return o;
248  if (!o->IsA()->InheritsFrom(cls)) {
249  Warning("GetO", "Object %s in %s is not a %s, but a %s",
250  name, dir->GetPath(), cls->GetName(), o->ClassName());
251  return 0;
252  }
253  return o;
254 }
255 //____________________________________________________________________
256 TDirectory* GetD(TDirectory* dir, const char* name)
257 {
258  return static_cast<TDirectory*>(GetO(dir,name,TDirectory::Class()));
259 }
260 
261 //____________________________________________________________________
262 TH1* GetH1(TDirectory* dir, const char* name)
263 {
264  return static_cast<TH1*>(GetO(dir,name,TH1::Class()));
265 }
266 //____________________________________________________________________
271 void
272 ExtractGSE(const char* input, UShort_t sNN=5023)
273 {
274  if (!gROOT->GetClass("GraphSysErr"))
275  gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+g");
276 
277  TString base = gSystem->BaseName(input); base.ReplaceAll(".root","");
278  TFile* file = TFile::Open(input, "READ");
279  if (!file) return;
280 
281  TH1* cent = GetH1(file, "realCent");
282 
283  Bool_t first = true;
284  TList* stack = new TList;
285  TList* truths = new TList;
286  for (Int_t i = 1; i <= cent->GetNbinsX(); i++) {
287  Double_t c1 = cent->GetXaxis()->GetBinLowEdge(i);
288  Double_t c2 = cent->GetXaxis()->GetBinUpEdge(i);
289  TObject* g = MakeGSE(file, sNN, c1, c2);
290  TObject* t = MakeTGSE(file, sNN, c1, c2);
291  if (!g) continue;
292  stack->Add(g);
293  truths->Add(t);
294  if (first) g->Draw("quad stat combine axis");
295  else g->Draw("quad stat combine");
296  t->Draw("quad");
297  first = false;
298  }
299 
300  TString obase(base); obase.Prepend("GSE_");
301 
302  std::ofstream out(Form("%s.input", obase.Data()));
303  GraphSysErr::Export(stack, out, "HFC", 2);
304  out << "*E" << std::endl;
305  out.close();
306 
307  TFile* rout = TFile::Open(Form("%s.root", obase.Data()), "RECREATE");
308  stack->AddAll(truths);
309  stack->Write("container", TObject::kSingleKey);
310  rout->Write();
311 
312 }
313 
314 void
316 {
317  ExtractGSE(Form("MiddNdeta_0x%x.root", flags));
318 }
319 //____________________________________________________________________
void Export(std::ostream &out=std::cout, Option_t *option="", Int_t nsign=2)
Definition: GraphSysErr.C:2612
void SetSysLineColor(Int_t id, Color_t color)
Definition: GraphSysErr.C:4359
void SetYTitle(const char *title)
Definition: GraphSysErr.C:3598
double Double_t
Definition: External.C:58
Int_t MakeP2P(TObject *o, const char *name, Color_t c)
Definition: ExtractGSE.C:56
void SetKey(const char *key, const char *value, Bool_t replace=false)
Definition: GraphSysErr.C:4587
void SetPointError(Int_t i, Double_t ex)
Definition: GraphSysErr.C:3468
TSystem * gSystem
TObject * MakeGSE(TDirectory *d, Double_t c1, Double_t c2)
Definition: ExtractGSE.C:117
void SetSysError(Int_t id, Double_t eyl, Double_t eyh)
Definition: GraphSysErr.C:3528
void SetCommonSumLineColor(Color_t color)
Definition: GraphSysErr.C:4503
TCanvas * c
Definition: TestFitELoss.C:172
void AddQualifier(const TString &key, const TString &value, Bool_t replace=false)
Definition: GraphSysErr.C:4759
void ExtractGSE(const char *input)
Definition: ExtractGSE.C:253
void SetCommonSumOption(EDrawOption_t opt)
Definition: GraphSysErr.C:4491
void SetStatError(Int_t i, Double_t ey)
Definition: GraphSysErr.C:3505
TObject * MakeTGSE(TDirectory *d, UShort_t sNN, Double_t c1, Double_t c2)
Definition: ExtractGSE.C:173
TDirectory * GetD(TDirectory *dir, const char *name)
Definition: ExtractGSE.C:228
void SetPoint(Int_t i, Double_t x, Double_t y)
Definition: GraphSysErr.C:3457
void SetTitle(const char *name)
Definition: GraphSysErr.C:3576
Double_t EtaSysEval(Double_t x, Double_t sMin, Double_t sMax)
Definition: ExtractGSE.C:102
UInt_t DefineCommon(const char *title, Bool_t relative, Double_t ey, EDrawOption_t option=kFill)
Definition: GraphSysErr.C:3350
int Int_t
Definition: External.C:63
UInt_t DeclarePoint2Point(const char *title, Bool_t relative, EDrawOption_t option=kBar)
Definition: GraphSysErr.C:3393
TH1 * GetH1(TDirectory *dir, const char *name)
Definition: ExtractGSE.C:242
void SetDataOption(EDrawOption_t opt)
Definition: GraphSysErr.C:3586
Double_t SysEval(Double_t x, Double_t sMin, Double_t sMax, Double_t xMax)
Definition: ExtractGSE.C:76
void SetSysFillColor(Int_t id, Color_t color)
Definition: GraphSysErr.C:4395
An (X,Y) graph with configurable errors.
Double_t CSysEval(Double_t x, Double_t sMin, Double_t sMax)
Definition: ExtractGSE.C:89
void SetSumOption(EDrawOption_t opt)
Definition: GraphSysErr.C:4449
TObject * GetO(TDirectory *dir, const char *name, TClass *cls=0)
Definition: ExtractGSE.C:198
TFile * file
unsigned short UShort_t
Definition: External.C:28
void SetSumFillColor(Color_t color)
Definition: GraphSysErr.C:4479
bool Bool_t
Definition: External.C:53
void MakeCommon(TObject *o, const char *name, Double_t val, Color_t c)
Definition: ExtractGSE.C:39
void SetSumLineColor(Color_t color)
Definition: GraphSysErr.C:4461
void SetXTitle(const char *title)
Definition: GraphSysErr.C:3592
void SetCommonSumFillColor(Color_t color)
Definition: GraphSysErr.C:4521
Definition: External.C:196