AliPhysics  1168478 (1168478)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtractGSE2.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 //====================================================================
40 {
41  Double_t c = (c1+c2) / 2;
42  if (c < 5) return 0;
43  else if (c < 10) return 1;
44  else if (c < 20) return 2;
45  else if (c < 30) return 3;
46  else if (c < 40) return 4;
47  else if (c < 50) return 5;
48  else if (c < 60) return 6;
49  else if (c < 70) return 7;
50  else if (c < 80) return 8;
51  else if (c < 90) return 9;
52  return 10;
53 }
54 
55 //____________________________________________________________________
64 static Color_t PbPbColor(Double_t c1, Double_t c2)
65 {
66  const Color_t cc[] = { kMagenta+2,
67  kBlue+2,
68  kAzure-1, // 10,
69  kCyan+2,
70  kGreen+1,
71  kSpring+5,//+10,
72  kYellow+1,
73  kOrange+5,//+10,
74  kRed+1,
75  kPink+5,//+10,
76  kBlack };
77  Int_t bin = PbPbBin(c1,c2);
78  return cc[bin];
79 }
80 //____________________________________________________________________
89 void MakeCommon(TObject* o, const char* name, Double_t val, Color_t c)
90 {
91  GraphSysErr* gse = static_cast<GraphSysErr*>(o);
92  Int_t id = gse->DefineCommon(name,true,val,GraphSysErr::kBox);
93  gse->SetSysFillColor(id, c);
94  gse->SetSysLineColor(id, c);
95 }
96 //____________________________________________________________________
106 Int_t MakeP2P(TObject* o, const char* name, Color_t c)
107 {
108  GraphSysErr* gse = static_cast<GraphSysErr*>(o);
109  Int_t id = gse->DeclarePoint2Point(name,true,GraphSysErr::kBox);
110  gse->SetSysFillColor(id, c);
111  gse->SetSysLineColor(id, c);
112  return id;
113 }
114 
115 //====================================================================
117 {
118  return sMin + TMath::Power(x/xMax, 2)*(sMax-sMin);
119 }
120 
122 {
123  return SysEval(x, sMin, sMax, 80);
124 }
126 {
127  return SysEval(x, sMin, sMax, 2);
128 }
129 
130 //____________________________________________________________________
142 TObject* MakeGSE(TDirectory* d,
143  Int_t dimen,
144  UShort_t sNN,
145  Double_t c1,
146  Double_t c2)
147 {
148  if (!gROOT->GetClass("GraphSysErr")) return 0;
149  TString bin; bin.Form("%03dd%02d_%03dd%02d",
150  Int_t(c1), Int_t(c1*100)%100,
151  Int_t(c2), Int_t(c2*100)%100);
152  Bool_t isAll = (c1+1.e-9 >= c2);
153  if (isAll) bin = "all";
154  TString sub(bin);
155  if (!isAll) sub.Prepend("cent");
156  sub.Append(Form("/results%dd/result", dimen));
157  TString nme(bin); nme.Prepend("CENT_");
158  TH1* g = GetH1(d, sub);
159  if (!g) return 0;
160 
161  Double_t eff = g->GetBinContent(0);
162  Printf("Trigger efficiency: %6.4f", eff);
163  if (eff < 1e-6) eff = 1;
164  g->Scale(eff);
165  g->SetBinContent(0,0);
166 
167  Color_t col = PbPbColor(c1,c2); // g->GetMarkerColor();
168  // Double_t bg = (1-c1/100)*(2-0.1)+0.1;
169  // Double_t c = TMath::Power(c1/100,2)*(6.2-0.4)+0.4;
170  Double_t cMin = sNN == 5023 ? 0.005 : 0.004;
171  Double_t cMax = sNN == 5023 ? 0.075 : 0.062;
172  Double_t bg = CSysEval(c2, 0.02, 0.001);
173  Double_t c = CSysEval(c2, cMin, cMax);
174  GraphSysErr* gse = new GraphSysErr(g->GetNbinsX());
175  gse->SetName(nme);
176  gse->SetTitle(Form("%5.1f - %5.1f%%", c1, c2));
177  //gse->SetKey("author",(sNN == 5023?"PREGHENELLA : 2015":"SHAHOYAN : 2013"));
178  gse->SetKey("title", Form("dNch/deta in PbPb at %d GeV", sNN));
179  gse->SetKey("obskey", "DN/DETARAP");
180  gse->SetKey("reackey", "PB PB --> CHARGED X");
181  gse->SetKey("laboratory", "CERN");
182  gse->SetKey("accelerator", "LHC");
183  gse->SetKey("detector", "TRACKLETS");
184  gse->SetKey("reference", sNN==5023 ? "ALICE-AN-2830" : "ALICE-AN-2180");
185  if (!isAll)gse->AddQualifier("CENTRALITY IN PCT", Form("%.1f TO %.1f",c1,c2));
186  gse->AddQualifier("SQRT(S)/NUCLEON IN GEV", Form("%d", sNN));
187  gse->SetXTitle("ETARAP");
188  gse->SetYTitle("DN/DETARAP");
189  gse->SetMarkerStyle(g->GetMarkerStyle());
190  gse->SetMarkerSize(g->GetMarkerSize());
192  gse->SetMarkerColor(col);
193  gse->SetLineColor(col);
194  gse->SetFillColor(col);
195  gse->SetSumFillColor(col);
196  gse->SetSumLineColor(col);
198  gse->SetCommonSumFillColor(col);
199  gse->SetCommonSumLineColor(col);
201  MakeCommon(gse, "Particle composition", 0.01, col);
202  MakeCommon(gse, "Weak decay", 0.01, col);
203  MakeCommon(gse, "pT extrapolation", 0.02, col);
204  MakeCommon(gse, "EG dependence", 0.02, col);
205  MakeCommon(gse, "Background subtraction", bg, col);
206  MakeCommon(gse, "Centrality", c, col);
207  if (eff) {
208  MakeCommon(gse, "TRIGGER", 0.02, col);
209  }
210  Int_t acc = MakeP2P(gse, "Acceptance", col);
211 
212  Int_t j = 0;
213  for (Int_t i = 1; i <= g->GetNbinsX(); i++) {
214  Double_t eta = g->GetXaxis()->GetBinCenter(i);
215  Double_t eEta = g->GetXaxis()->GetBinWidth(i)/2;
216  Double_t xo = TMath::Abs(eta)+eEta;
217  if (xo > 2) continue;
218  Double_t ea = 0.02*TMath::Power(xo/2,2);
219  gse->SetPoint(j, eta, g->GetBinContent(i));
220  gse->SetPointError(j, eEta, eEta);
221  gse->SetStatError(j, g->GetBinError(i),g->GetBinError(i));
222  gse->SetSysError(acc, j, eEta, eEta, ea/100, ea/100);
223  j++;
224  }
225  return gse;
226 
227 
228 }
229 
230 //____________________________________________________________________
242 TObject* MakeTGSE(TDirectory* d,
243  Int_t dimen,
244  UShort_t sNN,
245  Double_t c1,
246  Double_t c2)
247 {
248  if (!gROOT->GetClass("GraphSysErr")) return 0;
249  TString bin; bin.Form("%03dd%02d_%03dd%02d",
250  Int_t(c1), Int_t(c1*100)%100,
251  Int_t(c2), Int_t(c2*100)%100);
252  Bool_t isAll = (c1+1.e-9 >= c2);
253  if (isAll) bin = "all";
254  TString sub(bin);
255  if (!isAll) sub.Prepend("cent");
256  sub.Append(Form("/results%dd/simG",dimen));
257  TString nme(bin); nme.Prepend("CENTT_");
258  TH1* g = GetH1(d, sub);
259  if (!g) return 0;
260 
261  Color_t col = PbPbColor(c1,c2); // g->GetMarkerColor();
262  // Double_t bg = (1-c1/100)*(2-0.1)+0.1;
263  // Double_t c = TMath::Power(c1/100,2)*(6.2-0.4)+0.4;
264  GraphSysErr* gse = new GraphSysErr(g->GetNbinsX());
265  gse->SetName(nme);
266  gse->SetTitle(Form("%5.1f - %5.1f%%", c1, c2));
267  gse->SetKey("author", (sNN == 5023 ? "PREGHENELLA : 2015":"SHAHOYAN : 2013"));
268  gse->SetKey("title", Form("dNch/deta in PbPb at %d GeV", sNN));
269  gse->SetKey("obskey", "DN/DETARAP");
270  gse->SetKey("reackey", "PB PB --> CHARGED X");
271  gse->SetKey("laboratory", "CERN");
272  gse->SetKey("accelerator", "LHC");
273  gse->SetKey("detector", "TRACKLETS");
274  gse->SetKey("reference", sNN==5023 ? "ALICE-AN-2830" : "ALICE-AN-2180");
275  if (!isAll)gse->AddQualifier("CENTRALITY IN PCT", Form("%.1f TO %.1f",c1,c2));
276  gse->AddQualifier("SQRT(S)/NUCLEON IN GEV", Form("%d", sNN));
277  gse->SetXTitle("ETARAP");
278  gse->SetYTitle("DN/DETARAP");
279  gse->SetMarkerStyle(g->GetMarkerStyle());
280  gse->SetMarkerSize(g->GetMarkerSize());
282  gse->SetMarkerColor(col);
283  gse->SetLineColor(col);
284  gse->SetFillColor(col);
285  gse->SetSumFillColor(col);
286  gse->SetSumLineColor(col);
288  gse->SetCommonSumFillColor(col);
289  gse->SetCommonSumLineColor(col);
291 
292  Int_t j = 0;
293  for (Int_t i = 1; i <= g->GetNbinsX(); i++) {
294  Double_t eta = g->GetXaxis()->GetBinCenter(i);
295  Double_t eEta = g->GetXaxis()->GetBinWidth(i)/2;
296  Double_t xo = TMath::Abs(eta)+eEta;
297  if (xo > 2) continue;
298  Double_t ea = 0.02*TMath::Power(xo/2,2);
299  gse->SetPoint(j, eta, g->GetBinContent(i));
300  gse->SetPointError(j, eEta, eEta);
301  gse->SetStatError(j, g->GetBinError(i),g->GetBinError(i));
302  j++;
303  }
304  return gse;
305 
306 
307 }
308 
309 //____________________________________________________________________
310 TObject*
311 GetO(TDirectory* dir, const char* name, TClass* cls=0)
312 {
313  if (!dir) {
314  Warning("GetO", "No directory passed");
315  return 0;
316  }
317 
318  TObject* o = dir->Get(name);
319  if (!o) {
320  Warning("GetO", "object %s not found in %s",
321  name, dir->GetPath());
322  return 0;
323  }
324  if (!cls) return o;
325  if (!o->IsA()->InheritsFrom(cls)) {
326  Warning("GetO", "Object %s in %s is not a %s, but a %s",
327  name, dir->GetPath(), cls->GetName(), o->ClassName());
328  return 0;
329  }
330  return o;
331 }
332 //____________________________________________________________________
333 TDirectory* GetD(TDirectory* dir, const char* name)
334 {
335  return static_cast<TDirectory*>(GetO(dir,name,TDirectory::Class()));
336 }
337 
338 //____________________________________________________________________
339 TH1* GetH1(TDirectory* dir, const char* name)
340 {
341  return static_cast<TH1*>(GetO(dir,name,TH1::Class()));
342 }
343 //____________________________________________________________________
348 void
349 ExtractGSE2(const char* input, UShort_t sNN=5023)
350 {
351  if (!gROOT->GetClass("GraphSysErr"))
352  gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+g");
353 
354  TString base = input; //gSystem->DirName(input); base.ReplaceAll(".root","");
355  TFile* file = TFile::Open(Form("%s/result.root",input), "READ");
356  if (!file) {
357  Warning("ExtractGSE2", "Failed to open %s/result.root", input);
358  return;
359  }
360 
361  Int_t dimen = -1;
362  if (base.EndsWith("unit")) dimen = 0;
363  else if (base.EndsWith("const")) dimen = 1;
364  else if (base.EndsWith("eta")) dimen = 2;
365  else if (base.EndsWith("etaipz")) dimen = 3;
366  if (dimen < 0) {
367  Error("ExtractGSE2", "Don't know how to extract dimension from %s",base);
368  return;
369  }
370 
371  TH1* frame = 0;
372  TH1* cent = GetH1(file, "realCent");
373 
374  Bool_t first = true;
375  TList* stack = new TList;
376  TList* truths = new TList;
377  for (Int_t i = 1; i <= cent->GetNbinsX(); i++) {
378  Double_t c1 = cent->GetXaxis()->GetBinLowEdge(i);
379  Double_t c2 = cent->GetXaxis()->GetBinUpEdge(i);
380  TObject* g = MakeGSE(file, dimen, sNN, c1, c2);
381  TObject* t = MakeTGSE(file, dimen, sNN, c1, c2);
382  Double_t gmin, gmax, tmin, tmax;
383  if (!g) continue;
384  stack->Add(g);
385  truths->Add(t);
386  if (first) g->Draw("quad stat combine axis");
387  else g->Draw("quad stat combine");
388  if (t) t->Draw("quad");
389  first = false;
390  if (!frame) {
391  GraphSysErr* gse = static_cast<GraphSysErr*>(g);
392  if (gse->GetMulti())
393  frame = gse->GetMulti()->GetHistogram();
394  }
395  }
396  if (frame) frame->SetMinimum(1);
397 
398  // TString obase(base); obase.Prepend("GSE_");
399 
400  std::ofstream out(Form("%s/gse.input", base.Data()));
401  GraphSysErr::Export(stack, out, "HFC", 2);
402  out << "*E" << std::endl;
403  out.close();
404 
405  TFile* rout = TFile::Open(Form("%s/gse.root", base.Data()), "RECREATE");
406  stack->AddAll(truths);
407  stack->Write("container", TObject::kSingleKey);
408  rout->Write();
409 
410 }
411 
412 void
414 {
415  ExtractGSE(Form("MiddNdeta_0x%x.root", flags));
416 }
417 //____________________________________________________________________
void Export(std::ostream &out=std::cout, Option_t *option="", Int_t nsign=2)
Definition: GraphSysErr.C:2612
TDirectory * GetD(TDirectory *dir, const char *name)
Definition: ExtractGSE2.C:333
void ExtractGSE2(const char *input, UShort_t sNN=5023)
Definition: ExtractGSE2.C:349
void SetSysLineColor(Int_t id, Color_t color)
Definition: GraphSysErr.C:4359
void SetYTitle(const char *title)
Definition: GraphSysErr.C:3598
const Color_t cc[]
Definition: DrawKs.C:1
double Double_t
Definition: External.C:58
TObject * GetO(TDirectory *dir, const char *name, TClass *cls=0)
Definition: ExtractGSE2.C:311
void SetKey(const char *key, const char *value, Bool_t replace=false)
Definition: GraphSysErr.C:4587
TObject * MakeGSE(TDirectory *d, Int_t dimen, UShort_t sNN, Double_t c1, Double_t c2)
Definition: ExtractGSE2.C:142
void SetPointError(Int_t i, Double_t ex)
Definition: GraphSysErr.C:3468
void SetSysError(Int_t id, Double_t eyl, Double_t eyh)
Definition: GraphSysErr.C:3528
void SetCommonSumLineColor(Color_t color)
Definition: GraphSysErr.C:4503
Double_t EtaSysEval(Double_t x, Double_t sMin, Double_t sMax)
Definition: ExtractGSE2.C:125
TCanvas * c
Definition: TestFitELoss.C:172
void AddQualifier(const TString &key, const TString &value, Bool_t replace=false)
Definition: GraphSysErr.C:4759
void SetCommonSumOption(EDrawOption_t opt)
Definition: GraphSysErr.C:4491
void SetStatError(Int_t i, Double_t ey)
Definition: GraphSysErr.C:3505
TH1 * GetH1(TDirectory *dir, const char *name)
Definition: ExtractGSE2.C:339
void SetPoint(Int_t i, Double_t x, Double_t y)
Definition: GraphSysErr.C:3457
void SetTitle(const char *name)
Definition: GraphSysErr.C:3576
UInt_t DefineCommon(const char *title, Bool_t relative, Double_t ey, EDrawOption_t option=kFill)
Definition: GraphSysErr.C:3350
Int_t MakeP2P(TObject *o, const char *name, Color_t c)
Definition: ExtractGSE2.C:106
int Int_t
Definition: External.C:63
UInt_t DeclarePoint2Point(const char *title, Bool_t relative, EDrawOption_t option=kBar)
Definition: GraphSysErr.C:3393
Double_t SysEval(Double_t x, Double_t sMin, Double_t sMax, Double_t xMax)
Definition: ExtractGSE2.C:116
Double_t CSysEval(Double_t x, Double_t sMin, Double_t sMax)
Definition: ExtractGSE2.C:121
void SetDataOption(EDrawOption_t opt)
Definition: GraphSysErr.C:3586
void SetSysFillColor(Int_t id, Color_t color)
Definition: GraphSysErr.C:4395
static Color_t PbPbColor(Double_t c1, Double_t c2)
Definition: ExtractGSE2.C:64
An (X,Y) graph with configurable errors.
TMultiGraph * GetMulti(Option_t *option="")
Definition: GraphSysErr.C:924
void SetSumOption(EDrawOption_t opt)
Definition: GraphSysErr.C:4449
void MakeCommon(TObject *o, const char *name, Double_t val, Color_t c)
Definition: ExtractGSE2.C:89
TObject * MakeTGSE(TDirectory *d, Int_t dimen, UShort_t sNN, Double_t c1, Double_t c2)
Definition: ExtractGSE2.C:242
TFile * file
TList with histograms for a given trigger.
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 ExtractGSE(Int_t flags)
Definition: ExtractGSE2.C:413
void SetSumLineColor(Color_t color)
Definition: GraphSysErr.C:4461
static Int_t PbPbBin(Double_t c1, Double_t c2)
Definition: ExtractGSE2.C:39
void SetXTitle(const char *title)
Definition: GraphSysErr.C:3592
void SetCommonSumFillColor(Color_t color)
Definition: GraphSysErr.C:4521
Definition: External.C:196
TDirectoryFile * dir