AliPhysics  a56b849 (a56b849)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WithSysError.C
Go to the documentation of this file.
1 
13 void
14 WithSysError(const TString& system,
15  UShort_t sNN,
16  TString& trigger,
17  const Option_t* option="e5",
18  Bool_t rebinned=true,
19  Bool_t export=true,
20  Bool_t empirical=true,
21  Bool_t alsoLog=true)
22 {
23  // --- Search path -------------------------------------------------
24  const char* fwd = 0;
25  if (gSystem->Getenv("FWD"))
26  fwd = gSystem->Getenv("FWD");
27  else if (gSystem->Getenv("ANA_SRC"))
28  fwd = gSystem->Getenv("ANA_SRC");
29  else
30  fwd = gSystem->ExpandPathName("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2");
31  gROOT->SetMacroPath(Form("%s:%s/dndeta:%s/gse:%s/scripts",
32  gROOT->GetMacroPath(), fwd, fwd, fwd));
33  gSystem->AddIncludePath(Form("-I%s/dndeta -I%s/gse", fwd,fwd));
34 
35  // --- Load code ---------------------------------------------------
36  if (!gROOT->GetClass("Drawer")) gROOT->LoadMacro("Drawer.C+g");
37  if (!gROOT->GetClass("GraphSysErr")) gROOT->LoadMacro("GraphSysErr.C+g");
38  if (!gROOT->GetClass("SysErrorAdder"))gROOT->LoadMacro("SysErrorAdder.C+g");
39 
40 
41  // --- Reaction key ------------------------------------------------
42  TString reac = system;
43  reac.ToUpper();
44  reac.Insert(reac.Index("P", 1, 1), " ");
45  reac.Append(" --> CHARGED X");
46 
47  // --- Fix up trigger and efficiency -------------------------------
48  const char* trigs[] = { trigger.Data(), 0 };
49  const char* exps[] = { "ALICE", "WIP", 0 };
50  Double_t* effs = 0;
51  if (sNN == 8000 && system.EqualTo("pp", TString::kIgnoreCase)) {
52  effs = new Double_t[2];
53  effs[1] = 0;
54  if (trigger.EqualTo("INEL",TString::kIgnoreCase))
55  effs[0] = 0.85;
56  else if (trigger.EqualTo("NSD",TString::kIgnoreCase) ||
57  trigger.EqualTo("V0AND",TString::kIgnoreCase)) {
58  trigger = "NSD";
59  trigs[0] = "NSD";
60  effs[0] = 0.93;
61  }
62  }
63 
64  // --- Select how to add -------------------------------------------
65  SysErrorAdder* adder = 0;
66  TString trigLegTitle = ""; // trigger;
67  if (trigger.EqualTo("INEL",TString::kIgnoreCase))
68  adder = new INELAdder(system, sNN);
69  if (trigger.EqualTo("INELGt0",TString::kIgnoreCase))
70  adder = new INELGt0Adder(system, sNN);
71  else if (trigger.EqualTo("NSD",TString::kIgnoreCase))
72  adder = new NSDAdder(system, sNN);
73  else {
74  trigLegTitle = "Centralities:";
75  adder = new CENTAdder(system, sNN, trigger);
76  }
77 
78  // --- Canvas ------------------------------------------------------
79  TCanvas* c = new TCanvas("C", "C", 1600, 1000);
80  c->SetTopMargin(0.01);
81  c->SetRightMargin(0.20);
82  c->SetLeftMargin(0.12);
83 
84  // --- Legend parameters -------------------------------------------
85  Double_t ly2 = 0.98;
86  Double_t lx1 = 0.81;
87  Double_t lx2 = 0.98;
88  Double_t ldy = 0.2;
89  Double_t ly1 = ly2-(trigLegTitle.IsNull() ? ldy : 2*ldy);
90  // --- Legend for triggers -----------------------------------------
91  // TLegend* tl = new TLegend(0.15,ly1,0.3,ly2);
92  TLegend* tl = new TLegend(lx1,ly1,lx2,ly2, trigLegTitle);
93  tl->SetBorderSize(0);
94  tl->SetFillStyle(0);
95  tl->SetTextColor(Drawer::AliceBlue());
96  tl->SetTextFont(42);
97 
98  // --- Legend for errors -------------------------------------------
99  // TLegend* el = new TLegend(tl->GetX2(),ly1,tl->GetX2()+.2,ly2);
100  ly2 = ly1;
101  ly1 = ly2-ldy;
102  TLegend* el = new TLegend(lx1,ly1,lx2,ly2, "Sys. errors:");
103  el->SetBorderSize(0);
104  el->SetFillStyle(0);
105  el->SetTextColor(Drawer::AliceBlue());
106  el->SetTextFont(42);
107 
108  // --- Legend for unique names -------------------------------------
109  // TLegend* ul = new TLegend(.6,.8,.95,.97);
110  ly2 = ly1;
111  ly1 = ly2-.5*ldy;
112  TLegend* ul = new TLegend(lx1, ly1, lx2, ly2);
113  ul->SetBorderSize(0);
114  ul->SetFillStyle(0);
115  ul->SetTextColor(Drawer::AliceBlue());
116  ul->SetTextFont(42);
117 
118  // --- Get the data ------------------------------------------------
119  TObjArray u;
120  TPair* dataOther = Drawer::GetDataOther(tl, u, system, sNN, trigs,
121  exps, option, rebinned,
122  empirical, effs);
123  if (!dataOther || !dataOther->Key()) {
124  Error("", "No data found %s", canvas->GetTitle());
125  return;
126  }
127  THStack* data = static_cast<THStack*>(dataOther->Key());
128  TMultiGraph* other = static_cast<TMultiGraph*>(dataOther->Value());
129 
130  // --- Loop over the data ------------------------------------------
131  TList* outList = new TList;
132  TIter next(data->GetHists());
133  TH1* h = 0;
134  Bool_t first = true;
135  TH1* frame = 0;
136  const char* opt = "stack stat quad split west west";
137  while ((h = static_cast<TH1*>(next()))) {
138  TString n(h->GetName());
139  if (n.Contains("syserror", TString::kIgnoreCase)) continue;
140 
141  // Color_t col = h->GetMarkerColor();
142  // h->SetMarkerColor(col);
143  // h->SetLineColor(col);
144  // h->SetFillColor(col);
145  GraphSysErr* gse = adder->Make(h, (first ? el : 0));
146  gse->SetTitle("");
147  gse->Draw(Form("%s %s", (first ? "axis" : ""), opt));
148  gse->SetKey("laboratory", "CERN");
149  gse->SetKey("accelerator", "LHC");
150  gse->SetKey("detector", Form("FORWARD%s", rebinned ? "" : "_full"));
151  gse->SetKey("reackey", reac);
152  gse->SetKey("obskey", "DN/DETARAP");
153  gse->SetKey("title", "Systematic study of 1/N dNch/deta over widest possible eta region at the LHC");
154  gse->SetKey("author", "CHRISTENSEN");
155  gse->SetKey("comment", "We present 1/N dNch/deta over widest possible eta region at the LHC");
156  gse->SetKey("dscomment", "The pseudo-rapidity density of charged particle");
157 
158 
159  if (export) {
160  TString trg = adder->GetTriggerString();
161  if (trg.EqualTo("INEL>0")) trg = "INELGt0";
162  TString dir(Form("out/%s/%05d/%s", system.Data(),
163  sNN, trg.Data()));
164  gSystem->Exec(Form("mkdir -p %s", dir.Data()));
165 
166  TFile* file = TFile::Open(Form("%s/%s.root",
167  dir.Data(),
168  gse->GetKey("detector")),
169  "RECREATE");
170  Info("", "Writing to %s", file->GetPath());
171  gse->Write("data");
172  file->Write();
173  file->Close();
174  }
175 
176 
177  outList->Add(gse);
178  if (first) {
179  TMultiGraph* axis = gse->GetMulti();
180  frame = axis->GetHistogram();
181  frame->SetMinimum(0.1);
182  frame->SetMaximum(frame->GetMaximum()*1.1);
183  frame->GetYaxis()->SetTitleOffset(1.4);
184  }
185  // gse->Export(false);
186  first = false;
187  }
188 
189  // --- Draw the others ---------------------------------------------
190  if (other) other->Draw("p");
191 
192  // --- Build legend of unique names --------------------------------
193  TParameter<int>* um =
194  new TParameter<int>("PWG-LF/GEO - work in progress", 20);
195  um->SetUniqueID(trigLegTitle.IsNull() ? kRed+2 : kBlack);
196  u.Add(um);
197  Drawer::MakeUniqueLegend(ul, u, 1);
198  ul->Draw();
199  tl->Draw();
200  el->Draw();
201 
202  // --- Make a title ------------------------------------------------
203  TLatex* ltx = Drawer::MakeTitle(.45, .98, system, sNN, trigger);
204  ltx->SetTextAlign(23);
205  ltx->SetTextSize(0.04);
206 
207  // --- ALICE logo --------------------------------------------------
208  if (!gROOT->GetClass("AliceLogo"))
209  gROOT->LoadMacro("AliceLogo.C+");
210 
211  if (gROOT->GetClass("AliceLogo")) {
212  ly1 = ly1-ldy;
213  c->Range(0,0,1,1);
214  gROOT->ProcessLine("AliceLogo* al = new AliceLogo();");
215  gROOT->ProcessLine(Form("al->Draw(0,%f,%f,%f, 0, 0xf);", lx1,ly1,ldy));
216  }
217 
218 
219  // --- Output to disk ----------------------------------------------
220  TString base(Form("%s_%04d_%s", system.Data(), sNN, trigger.Data()));
221  TString outName(Form("%s.root", base.Data()));
222  TFile* out = TFile::Open(outName.Data(), "RECREATE");
223  outList->Write();
224  out->Write();
225  Info("", "Wrote to %s.root", base.Data());
226 
227  c->Modified();
228  c->Update();
229  c->cd();
230  c->Print(Form("%s.pdf", base.Data()));
231  c->Print(Form("%s.png", base.Data()));
232  c->SaveAs(Form("%s_canvas.root", base.Data()));
234 
235  if (trigLegTitle.IsNull() || !alsoLog) return;
236 
237  frame->SetMinimum(5);
238  frame->SetMaximum(3*frame->GetMaximum());
239  c->SetLogy();
240  c->Modified();
241  c->Update();
242  c->cd();
243  c->Print(Form("%s_logy.pdf", base.Data()));
244  c->Print(Form("%s_logy.png", base.Data()));
245 
246 
247 }
248 
249 
250 //
251 // EOF
252 //
double Double_t
Definition: External.C:58
void Draw(Option_t *option="")
Definition: GraphSysErr.C:791
virtual GraphSysErr * Make(TH1 *h, TLegend *l, Double_t eff=1, Bool_t verb=false)
static TPair * GetDataOther(TLegend *leg, TObjArray &unique, const TString &system, UShort_t sNN, const char **trigs, const char **exps, Option_t *errOpt="e5", Bool_t rebinned=false, Bool_t empirical=true, const Double_t *effs=0)
Definition: Drawer.C:1781
TCanvas * canvas
Definition: DrawAnaELoss.C:28
void SetKey(const char *key, const char *value, Bool_t replace=false)
Definition: GraphSysErr.C:4587
TSystem * gSystem
TCanvas * c
Definition: TestFitELoss.C:172
static Int_t AliceBlue()
Definition: Drawer.C:202
static TLatex * MakeTitle(Double_t x, Double_t y, const TString &system, UShort_t sNN, const TString &trigger)
Definition: Drawer.C:1684
void SetTitle(const char *name)
Definition: GraphSysErr.C:3576
void WithSysError(const TString &system, UShort_t sNN, TString &trigger, const Option_t *option="e5", Bool_t rebinned=true, Bool_t export=true, Bool_t empirical=true, Bool_t alsoLog=true)
Definition: WithSysError.C:14
TMultiGraph * GetMulti(Option_t *option="")
Definition: GraphSysErr.C:924
const char * GetKey(const char *key) const
Definition: GraphSysErr.C:4641
const char * fwd
TFile * file
TList with histograms for a given trigger.
unsigned short UShort_t
Definition: External.C:28
const char Option_t
Definition: External.C:48
virtual const char * GetTriggerString() const
Definition: SysErrorAdder.C:59
bool Bool_t
Definition: External.C:53
Definition: External.C:196
static TLegend * MakeUniqueLegend(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TObjArray &unique, Int_t nSNN)
Definition: Drawer.C:1706
TDirectoryFile * dir