AliPhysics  fffcdf3 (fffcdf3)
 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  // Preliminary centrality sys error for Xe-Xe
171  Double_t cMin = sNN == 5440 ? 0.0024 : sNN == 5023 ? 0.005 : 0.004;
172  Double_t cMax = sNN == 5440 ? 0.0961 : sNN == 5023 ? 0.075 : 0.062;
173  Double_t bg = CSysEval(c2, 0.02, 0.001);
174  Double_t c = CSysEval(c2, cMin, cMax);
175  GraphSysErr* gse = new GraphSysErr(g->GetNbinsX());
176  gse->SetName(nme);
177  gse->SetTitle(Form("%5.1f - %5.1f%%", c1, c2));
178  //gse->SetKey("author",(sNN == 5023?"PREGHENELLA : 2015":"SHAHOYAN : 2013"));
179  gse->SetKey("title", Form("dNch/deta in PbPb at %d GeV", sNN));
180  gse->SetKey("obskey", "DN/DETARAP");
181  gse->SetKey("reackey", "PB PB --> CHARGED X");
182  gse->SetKey("laboratory", "CERN");
183  gse->SetKey("accelerator", "LHC");
184  gse->SetKey("detector", "TRACKLETS");
185  gse->SetKey("reference", sNN==5023 ? "ALICE-AN-2830" : "ALICE-AN-2180");
186  if (!isAll)gse->AddQualifier("CENTRALITY IN PCT", Form("%.1f TO %.1f",c1,c2));
187  gse->AddQualifier("SQRT(S)/NUCLEON IN GEV", Form("%d", sNN));
188  gse->SetXTitle("ETARAP");
189  gse->SetYTitle("DN/DETARAP");
190  gse->SetMarkerStyle(g->GetMarkerStyle());
191  gse->SetMarkerSize(g->GetMarkerSize());
193  gse->SetMarkerColor(col);
194  gse->SetLineColor(col);
195  gse->SetFillColor(col);
196  gse->SetSumFillColor(col);
197  gse->SetSumLineColor(col);
199  gse->SetCommonSumFillColor(col);
200  gse->SetCommonSumLineColor(col);
202  MakeCommon(gse, "Particle composition", 0.01, col);
203  MakeCommon(gse, "Weak decay", 0.01, col);
204  MakeCommon(gse, "pT extrapolation", 0.02, col);
205  MakeCommon(gse, "EG dependence", 0.02, col);
206  MakeCommon(gse, "Background subtraction", bg, col);
207  MakeCommon(gse, "Centrality", c, col);
208  MakeCommon(gse, "EM contamination", (c1>=70?0.04:0), col);
209  if (eff) {
210  MakeCommon(gse, "TRIGGER", 0.02, col);
211  }
212  Int_t acc = MakeP2P(gse, "Acceptance", col);
213 
214  Int_t j = 0;
215  for (Int_t i = 1; i <= g->GetNbinsX(); i++) {
216  Double_t eta = g->GetXaxis()->GetBinCenter(i);
217  Double_t eEta = g->GetXaxis()->GetBinWidth(i)/2;
218  Double_t xo = TMath::Abs(eta)+eEta;
219  if (xo > 2) continue;
220  Double_t ea = 0.02*TMath::Power(xo/2,2);
221  gse->SetPoint(j, eta, g->GetBinContent(i));
222  gse->SetPointError(j, eEta, eEta);
223  gse->SetStatError(j, g->GetBinError(i),g->GetBinError(i));
224  gse->SetSysError(acc, j, eEta, eEta, ea/100, ea/100);
225  j++;
226  }
227  return gse;
228 
229 
230 }
231 
232 //____________________________________________________________________
244 TObject* MakeTGSE(TDirectory* d,
245  Int_t dimen,
246  UShort_t sNN,
247  Double_t c1,
248  Double_t c2)
249 {
250  if (!gROOT->GetClass("GraphSysErr")) return 0;
251  TString bin; bin.Form("%03dd%02d_%03dd%02d",
252  Int_t(c1), Int_t(c1*100)%100,
253  Int_t(c2), Int_t(c2*100)%100);
254  Bool_t isAll = (c1+1.e-9 >= c2);
255  if (isAll) bin = "all";
256  TString sub(bin);
257  if (!isAll) sub.Prepend("cent");
258  sub.Append(Form("/results%dd/simG",dimen));
259  TString nme(bin); nme.Prepend("CENTT_");
260  TH1* g = GetH1(d, sub);
261  if (!g) return 0;
262 
263  Color_t col = PbPbColor(c1,c2); // g->GetMarkerColor();
264  // Double_t bg = (1-c1/100)*(2-0.1)+0.1;
265  // Double_t c = TMath::Power(c1/100,2)*(6.2-0.4)+0.4;
266  GraphSysErr* gse = new GraphSysErr(g->GetNbinsX());
267  gse->SetName(nme);
268  gse->SetTitle(Form("%5.1f - %5.1f%%", c1, c2));
269  gse->SetKey("author", (sNN == 5023 ? "PREGHENELLA : 2015":"SHAHOYAN : 2013"));
270  gse->SetKey("title", Form("dNch/deta in PbPb at %d GeV", sNN));
271  gse->SetKey("obskey", "DN/DETARAP");
272  gse->SetKey("reackey", "PB PB --> CHARGED X");
273  gse->SetKey("laboratory", "CERN");
274  gse->SetKey("accelerator", "LHC");
275  gse->SetKey("detector", "TRACKLETS");
276  gse->SetKey("reference", sNN==5023 ? "ALICE-AN-2830" : "ALICE-AN-2180");
277  if (!isAll)gse->AddQualifier("CENTRALITY IN PCT", Form("%.1f TO %.1f",c1,c2));
278  gse->AddQualifier("SQRT(S)/NUCLEON IN GEV", Form("%d", sNN));
279  gse->SetXTitle("ETARAP");
280  gse->SetYTitle("DN/DETARAP");
281  gse->SetMarkerStyle(g->GetMarkerStyle());
282  gse->SetMarkerSize(g->GetMarkerSize());
284  gse->SetMarkerColor(col);
285  gse->SetLineColor(col);
286  gse->SetFillColor(col);
287  gse->SetSumFillColor(col);
288  gse->SetSumLineColor(col);
290  gse->SetCommonSumFillColor(col);
291  gse->SetCommonSumLineColor(col);
293 
294  Int_t j = 0;
295  for (Int_t i = 1; i <= g->GetNbinsX(); i++) {
296  Double_t eta = g->GetXaxis()->GetBinCenter(i);
297  Double_t eEta = g->GetXaxis()->GetBinWidth(i)/2;
298  Double_t xo = TMath::Abs(eta)+eEta;
299  if (xo > 2) continue;
300  Double_t ea = 0.02*TMath::Power(xo/2,2);
301  gse->SetPoint(j, eta, g->GetBinContent(i));
302  gse->SetPointError(j, eEta, eEta);
303  gse->SetStatError(j, g->GetBinError(i),g->GetBinError(i));
304  j++;
305  }
306  return gse;
307 
308 
309 }
310 
311 //____________________________________________________________________
312 TObject*
313 GetO(TDirectory* dir, const char* name, TClass* cls=0)
314 {
315  if (!dir) {
316  Warning("GetO", "No directory passed");
317  return 0;
318  }
319 
320  TObject* o = dir->Get(name);
321  if (!o) {
322  Warning("GetO", "object %s not found in %s",
323  name, dir->GetPath());
324  return 0;
325  }
326  if (!cls) return o;
327  if (!o->IsA()->InheritsFrom(cls)) {
328  Warning("GetO", "Object %s in %s is not a %s, but a %s",
329  name, dir->GetPath(), cls->GetName(), o->ClassName());
330  return 0;
331  }
332  return o;
333 }
334 //____________________________________________________________________
335 TDirectory* GetD(TDirectory* dir, const char* name)
336 {
337  return static_cast<TDirectory*>(GetO(dir,name,TDirectory::Class()));
338 }
339 
340 //____________________________________________________________________
341 TH1* GetH1(TDirectory* dir, const char* name)
342 {
343  return static_cast<TH1*>(GetO(dir,name,TH1::Class()));
344 }
345 //____________________________________________________________________
350 void
351 ExtractGSE2(const char* input, UShort_t sNN=5023)
352 {
353  if (!gROOT->GetClass("GraphSysErr"))
354  gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+g");
355 
356  TString base = input; //gSystem->DirName(input); base.ReplaceAll(".root","");
357  TFile* file = TFile::Open(Form("%s/result.root",input), "READ");
358  if (!file) {
359  Warning("ExtractGSE2", "Failed to open %s/result.root", input);
360  return;
361  }
362 
363  Int_t dimen = -1;
364  if (base.EndsWith("unit")) dimen = 0;
365  else if (base.EndsWith("const")) dimen = 1;
366  else if (base.EndsWith("eta")) dimen = 2;
367  else if (base.EndsWith("etaipz")) dimen = 3;
368  if (dimen < 0) {
369  Error("ExtractGSE2", "Don't know how to extract dimension from %s",base);
370  return;
371  }
372 
373  TH1* frame = 0;
374  TH1* cent = GetH1(file, "realCent");
375 
376  Bool_t first = true;
377  TList* stack = new TList;
378  TList* truths = new TList;
379  for (Int_t i = 1; i <= cent->GetNbinsX(); i++) {
380  Double_t c1 = cent->GetXaxis()->GetBinLowEdge(i);
381  Double_t c2 = cent->GetXaxis()->GetBinUpEdge(i);
382  TObject* g = MakeGSE(file, dimen, sNN, c1, c2);
383  TObject* t = MakeTGSE(file, dimen, sNN, c1, c2);
384  Double_t gmin, gmax, tmin, tmax;
385  if (!g) continue;
386  stack->Add(g);
387  truths->Add(t);
388  if (first) g->Draw("quad stat combine axis");
389  else g->Draw("quad stat combine");
390  if (t) t->Draw("quad");
391  first = false;
392  if (!frame) {
393  GraphSysErr* gse = static_cast<GraphSysErr*>(g);
394  if (gse->GetMulti())
395  frame = gse->GetMulti()->GetHistogram();
396  }
397  }
398  if (frame) frame->SetMinimum(1);
399 
400  // TString obase(base); obase.Prepend("GSE_");
401 
402  std::ofstream out(Form("%s/gse.input", base.Data()));
403  GraphSysErr::Export(stack, out, "HFC", 2);
404  out << "*E" << std::endl;
405  out.close();
406 
407  TFile* rout = TFile::Open(Form("%s/gse.root", base.Data()), "RECREATE");
408  stack->AddAll(truths);
409  stack->Write("container", TObject::kSingleKey);
410  rout->Write();
411 
412 }
413 
414 void
416 {
417  ExtractGSE(Form("MiddNdeta_0x%x.root", flags));
418 }
419 //____________________________________________________________________
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:335
void ExtractGSE2(const char *input, UShort_t sNN=5023)
Definition: ExtractGSE2.C:351
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:313
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
AliStack * stack
void SetStatError(Int_t i, Double_t ey)
Definition: GraphSysErr.C:3505
TH1 * GetH1(TDirectory *dir, const char *name)
Definition: ExtractGSE2.C:341
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:244
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:415
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