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