AliPhysics  2b88e80 (2b88e80)
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 //====================================================================
77 {
78  return sMin + TMath::Power(x/xMax, 2)*(sMax-sMin);
79 }
90 {
91  return SysEval(x, sMin, sMax, 80);
92 }
103 {
104  return SysEval(x, sMin, sMax, 2);
105 }
106 
107 //____________________________________________________________________
117 TObject* MakeGSE(TDirectory* d, Double_t c1, Double_t c2)
118 {
119  if (!gROOT->GetClass("GraphSysErr")) return 0;
120  TString bin; bin.Form("%03dd%02d_%03dd%02d",
121  Int_t(c1), Int_t(c1*100)%100,
122  Int_t(c2), Int_t(c2*100)%100);
123  TString sub(bin); sub.Prepend("cent"); sub.Append("/dndeta");
124  TString nme(bin); nme.Prepend("CENT_");
125  TH1* g = GetH1(d, sub);
126  if (!g) return 0;
127 
128  Color_t col = g->GetMarkerColor();
129  // Double_t bg = (1-c1/100)*(2-0.1)+0.1;
130  // Double_t c = TMath::Power(c1/100,2)*(6.2-0.4)+0.4;
131  Double_t bg = CSysEval(c2, 0.02, 0.001);
132  Double_t c = CSysEval(c2, 0.005, 0.075);
133  GraphSysErr* gse = new GraphSysErr(g->GetNbinsX());
134  gse->SetName(nme);
135  gse->SetTitle(Form("%5.1f - %5.1f%%", c1, c2));
136  gse->SetKey("author", "PREGHENELLA : 20150");
137  gse->SetKey("title", "dNch/deta in PbPb at 5023 GeV");
138  gse->SetKey("obskey", "DN/DETARAP");
139  gse->SetKey("reackey", "PB PB --> CHARGED X");
140  gse->SetKey("laboratory", "CERN");
141  gse->SetKey("accelerator", "LHC");
142  gse->SetKey("detector", "TRACKLETS");
143  gse->SetKey("reference", "ALICE-AN-2830");
144  gse->AddQualifier("CENTRALITY IN PCT", Form("%.1f TO %.1f",c1,c2));
145  gse->AddQualifier("SQRT(S)/NUCLEON IN GEV", "5023");
146  gse->SetXTitle("ETARAP");
147  gse->SetYTitle("DN/DETARAP");
148  gse->SetMarkerStyle(g->GetMarkerStyle());
149  gse->SetMarkerSize(g->GetMarkerSize());
151  gse->SetMarkerColor(col);
152  gse->SetLineColor(col);
153  gse->SetFillColor(col);
154  gse->SetSumFillColor(col);
155  gse->SetSumLineColor(col);
157  gse->SetCommonSumFillColor(col);
158  gse->SetCommonSumLineColor(col);
160  MakeCommon(gse, "Particle composition", 0.01, col);
161  MakeCommon(gse, "Weak decay", 0.01, col);
162  MakeCommon(gse, "pT extrapolation", 0.02, col);
163  MakeCommon(gse, "EG dependence", 0.02, col);
164  MakeCommon(gse, "Background subrtaction", bg, col);
165  MakeCommon(gse, "Centrality", c, col);
166  Int_t acc = MakeP2P(gse, "Acceptance", col);
167 
168  Int_t j = 0;
169  for (Int_t i = 1; i <= g->GetNbinsX(); i++) {
170  Double_t eta = g->GetXaxis()->GetBinCenter(i);
171  Double_t eEta = g->GetXaxis()->GetBinWidth(i)/2;
172  Double_t xo = TMath::Abs(eta)+eEta;
173  if (xo > 2) continue;
174  Double_t ea = 0.02*TMath::Power(xo/2,2);
175  gse->SetPoint(j, eta, g->GetBinContent(i));
176  gse->SetPointError(j, eEta, eEta);
177  gse->SetStatError(j, g->GetBinError(i),g->GetBinError(i));
178  gse->SetSysError(acc, j, eEta, eEta, ea/100, ea/100);
179  j++;
180  }
181  return gse;
182 
183 
184 }
185 
186 //____________________________________________________________________
197 TObject*
198 GetO(TDirectory* dir, const char* name, TClass* cls=0)
199 {
200  if (!dir) {
201  Warning("GetO", "No directory passed");
202  return 0;
203  }
204 
205  TObject* o = dir->Get(name);
206  if (!o) {
207  Warning("GetO", "object %s not found in %s",
208  name, dir->GetPath());
209  return 0;
210  }
211  if (!cls) return o;
212  if (!o->IsA()->InheritsFrom(cls)) {
213  Warning("GetO", "Object %s in %s is not a %s, but a %s",
214  name, dir->GetPath(), cls->GetName(), o->ClassName());
215  return 0;
216  }
217  return o;
218 }
219 //____________________________________________________________________
228 TDirectory* GetD(TDirectory* dir, const char* name)
229 {
230  return static_cast<TDirectory*>(GetO(dir,name,TDirectory::Class()));
231 }
232 
233 //____________________________________________________________________
242 TH1* GetH1(TDirectory* dir, const char* name)
243 {
244  return static_cast<TH1*>(GetO(dir,name,TH1::Class()));
245 }
246 //____________________________________________________________________
252 void
253 ExtractGSE(const char* input)
254 {
255  if (!gROOT->GetClass("GraphSysErr"))
256  gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+g");
257 
258  TString base = gSystem->BaseName(input); base.ReplaceAll(".root","");
259  TFile* file = TFile::Open(input, "READ");
260  if (!file) return;
261 
262  TH1* cent = GetH1(file, "realCent");
263 
264  Bool_t first = true;
265  TList* stack = new TList;
266  for (Int_t i = 1; i <= cent->GetNbinsX(); i++) {
267  Double_t c1 = cent->GetXaxis()->GetBinLowEdge(i);
268  Double_t c2 = cent->GetXaxis()->GetBinUpEdge(i);
269  TObject* g = MakeGSE(file, c1, c2);
270  if (!g) continue;
271  stack->Add(g);
272  if (first) g->Draw("quad stat combine axis");
273  else g->Draw("quad stat combine");
274  first = false;
275  }
276 
277  TString obase(base); obase.Prepend("GSE_");
278 
279  std::ofstream out(Form("%s.input", obase.Data()));
280  GraphSysErr::Export(stack, out, "HFC", 2);
281  out << "*E" << std::endl;
282  out.close();
283 
284  TFile* rout = TFile::Open(Form("%s.root", obase.Data()), "RECREATE");
285  stack->Write("container", TObject::kSingleKey);
286  rout->Write();
287 
288 }
294 void
296 {
297  ExtractGSE(Form("MiddNdeta_0x%x.root", flags));
298 }
299 //____________________________________________________________________
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
AliStack * stack
void SetStatError(Int_t i, Double_t ey)
Definition: GraphSysErr.C:3505
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
TList with histograms for a given trigger.
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
TDirectoryFile * dir