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