AliPhysics  a4b41ad (a4b41ad)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SysErrorAdder.C
Go to the documentation of this file.
1 #ifndef __CINT__
2 # include <TString.h>
3 # include <TH1.h>
4 # include "GraphSysErr.C"
5 # include <TLegend.h>
6 # include <TLegendEntry.h>
7 # include <TObjString.h>
8 # include <TColor.h>
9 #else
10 class GraphSysErr;
11 class TH1;
12 class TLegend;
13 #endif
14 
16 {
20  enum {
21  kTriggerFill = 1001, // 0, // 3144
22  kMergingFill = 3001, // 0, // 3001,
23  kDensityFill = 3002, // 0, // 3002,
24  kEmpiricalFill = 3144, // 0, // 3244
25  kHadronFill = 3244, // 0,
27  };
41  SysErrorAdder(const TString& sys,
42  UShort_t sNN,
43  const TString& trig)
44  : fSys(sys), fSNN(sNN), fTrig(trig)
45  {}
49  virtual ~SysErrorAdder() {}
55  virtual const char* GetTriggerName() const { return "Trigger"; }
56  virtual const char* GetTriggerString() const { return fTrig; }
57  Int_t ModColor(Color_t n, UShort_t off) const
58  {
59  ULong_t max = 0xff;
60  ULong_t pixel = TColor::Number2Pixel(n);
61  ULong_t r = TMath::Min((((pixel >> 16) & max) + off), max);
62  ULong_t g = TMath::Min((((pixel >> 8) & max) + off), max);
63  ULong_t b = TMath::Min((((pixel >> 0) & max) + off), max);
64  ULong_t next = (r << 16) | (g << 8) | (b << 0);
65  // Printf("0x%08x -> 0x%08x", pixel, next);
66  return TColor::GetColor(next);
67  }
68 
78  void ModError(GraphSysErr* gse, Int_t id, Style_t fill,
79  TLegend* l, UShort_t off=64) const
80  {
81  // UShort_t off = 64; // (id-1) * 32;
82  // switch (fill) {
83  // case kMergingFill: off = 16; break;
84  // case kDensityFill: off = 32; break;
85  // case kEmpiricalFill: off = 48; break;
86  // case kHadronFill: off = 64; break;
87  // }
88  Color_t c = gse->GetMarkerColor(); // ModColor(gse->GetMarkerColor(), off);
89 
90  gse->SetSysFillColor(id, c);
91  gse->SetSysLineColor(id, c);
92  gse->SetSysLineWidth(id, 1);
93  gse->SetSysLineStyle(id, id);
94  gse->SetSysFillStyle(id, fill);
95  // gse->SetSysOption(id, GraphSysErr::kBox);
97 
98  AddLegend(l, id, gse->GetSysTitle(id), fill);
99  }
108  void AddLegend(TLegend* l, Int_t id, const char* title, Style_t fill) const
109  {
110  if (!l) return;
111  TLegendEntry* e = l->AddEntry(Form("sys%02d", id), title, "f");
112  e->SetFillStyle(fill);
113  e->SetFillColor(kBlack);
114  e->SetLineColor(kBlack);
115  e->SetLineStyle(id);
116  e->SetLineWidth(1);
117  }
126  virtual Int_t MakeTrigger(GraphSysErr* gse, TLegend* l) const
127  {
128  Double_t low = 0,high = 0;
129  GetTrigger(low,high);
130  if (low == 0 && high == 0) return -1;
131 
132  Int_t id = gse->DefineCommon(GetTriggerName(), true, low, high);
133  ModError(gse, id, kTriggerFill, l, 0);
134  return id;
135  }
144  Int_t MakeMerging(GraphSysErr* gse, TLegend* l) const
145  {
146  if (GetMerging(-1) <= 0 && GetMerging(+1) <= 0) return -1;
147  Int_t id = gse->DeclarePoint2Point("Merging", true);
148  ModError(gse, id, kMergingFill, l);
149  return id;
150  }
159  Int_t MakeDensity(GraphSysErr* gse, TLegend* l) const
160  {
161  if (GetDensity(-1) <= 0 && GetDensity(+1) <= 0) return -1;
162  Int_t id = gse->DeclarePoint2Point("Density", true);
163  ModError(gse, id, kDensityFill, l);
164  return id;
165  }
174  virtual Int_t MakeEmpirical(GraphSysErr* gse, TLegend* l) const
175  {
176  if (GetEmpirical() <= 0) return -1;
177  Int_t id = gse->DeclarePoint2Point("Empirical", true);
178  ModError(gse, id, kEmpiricalFill, l);
179  return id;
180  }
189  virtual Int_t MakeHadron(GraphSysErr* gse, TLegend* l) const
190  {
191  if (GetHadron(4) <= 0) return -1;
192  Int_t id = gse->DeclarePoint2Point("Hadron chemistry", true);
193  ModError(gse, id, kHadronFill, l);
194  return id;
195  }
196  virtual const char* MakeName() const { return GetTriggerString(); }
200  virtual Double_t GetMerging(Short_t ) const { return 0.01; }
204  virtual Double_t GetDensity(Short_t w) const { return (w<0?0.02:0.01); }
208  virtual Double_t GetEmpirical() const { return 0.061; }
212  virtual Double_t GetHadron(Double_t eta) const
213  {
214  Double_t ret = (eta >= 3.6 ? 0.02 : 0);
216  return ret;
217  }
224  virtual void GetTrigger(Double_t& low, Double_t& high) const = 0;
235  virtual GraphSysErr* Make(TH1* h, TLegend* l, Double_t eff=1,
236  Bool_t verb=false)
237  {
238  // --- Reaction key ------------------------------------------------
239  if (verb) Info("", "Making graph from %s %p eff=%f", h->GetName(), l, eff);
240  TString reac = fSys;
241  reac.ToUpper();
242  reac.Insert(reac.Index("P", 1, 1, TString::kIgnoreCase), " ");
243  reac.Append(" --> CHARGED X");
244 
245  GraphSysErr* gse = new GraphSysErr(10);
246  gse->SetName(MakeName());
247  gse->SetSumLineColor(kRed+2);
248  gse->SetSumLineWidth(2);
249  gse->SetSumTitle("All errors");
251  gse->SetLineColor(h->GetLineColor());
252  gse->SetMarkerColor(h->GetMarkerColor());
253  gse->SetFillColor(h->GetFillColor());
254  gse->SetMarkerStyle(h->GetMarkerStyle());
255  gse->SetFillStyle(h->GetFillStyle());
256  gse->SetXTitle("\\mathit{\\eta}");
257  gse->SetYTitle("\\mathrm{d}N_{ch}/\\mathrm{d}\\eta");
258  gse->SetKey("laboratory", "CERN");
259  gse->SetKey("accelerator", "LHC");
260  gse->SetKey("detector", "FORWARD");
261  gse->SetKey("reackey", reac);
262  gse->SetKey("obskey", "DN/DETARAP");
263  gse->SetKey("title", "Systematic study of dNch/deta over widest "
264  "possible eta region at the LHC");
265  gse->SetKey("author", "CHRISTENSEN");
266  gse->SetKey("comment", "We present dNch/deta over widest "
267  "possible eta region at the LHC");
268  gse->SetKey("dscomment", "The pseudo-rapidity density of charged particle");
269  gse->AddQualifier(Form("SQRT(S)%s IN GEV",
270  fSys.EqualTo("pp",TString::kIgnoreCase) ?
271  "" : "/NUCLEON"), Form("%d", fSNN));
272 
273  MakeTrigger(gse, l);
274  Int_t idMerge = MakeMerging(gse, l);
275  Int_t idDens = MakeDensity(gse, l);
276  Int_t idEmp = MakeEmpirical(gse, l);
277  Int_t idHad = MakeHadron(gse, l);
278 
279  Int_t cnt = 0;
280  if (verb)
281  Info("", "Looping over histogram w/%d bins", h->GetNbinsX());
282  for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
283  Double_t y = h->GetBinContent(i);
284  if (y < 1e-6) continue;
285  Double_t ey = h->GetBinError(i);
286  Double_t ex = h->GetXaxis()->GetBinWidth(i)/2;
287  Double_t x = h->GetXaxis()->GetBinCenter(i);
288 
289  gse->SetPoint(cnt, x, eff*y);
290  gse->SetPointError(cnt, ex);
291  gse->SetStatError(cnt, eff*ey);
292 
293  if (idMerge>=0)
294  gse->SetSysError(idMerge, cnt, ex, ex, GetMerging(-1), GetMerging(1));
295  if (idDens >=0)
296  gse->SetSysError(idDens, cnt, ex, ex, GetDensity(-1), GetDensity(1));
297  if (idEmp >=0)
298  gse->SetSysError(idEmp, cnt, ex, GetEmpirical());
299  if (idHad >=0)
300  gse->SetSysError(idHad, cnt, ex, GetHadron(x));
301  cnt++;
302  }
303  return gse;
304  }
305  static SysErrorAdder* Create(const TString& t,
306  const TString& s,
307  UShort_t e,
308  const TString& c);
309 };
315 {
322  OfflineAdder(const TString& sys, UShort_t sNN)
323  : SysErrorAdder(sys, sNN, "OFFLINE")
324  {
325  }
332  virtual void GetTrigger(Double_t& low, Double_t& high) const
333  {
334  low = 0;
335  high = 0;
336  }
337  Int_t MakeTrigger(GraphSysErr* gse, TLegend* l) const
338  {
339  return -1;
340  }
341 };
342 
347 struct INELAdder : public SysErrorAdder
348 {
359  INELAdder(const TString& sys, UShort_t sNN, Double_t low=-1, Double_t high=-1)
360  : SysErrorAdder(sys, sNN, "INEL"), fLow(low), fHigh(high)
361  {
362  if (low > 0 && high > 0) return;
363  if (fSys.EqualTo("pp", TString::kIgnoreCase)) {
364  switch (fSNN) {
365  case 900: fLow = 0.001; fHigh = 0.003; break;
366  case 2760: fLow = 0.0035; fHigh = 0.006; break;
367  case 5023: fLow = fHigh = 0.028; break;
368  case 7000:
369  case 8000: fLow = 0.003; fHigh = 0.006; break;
370  case 13000: fLow = fHigh = 0.028; break;
371  default: break;
372  }
373  }
374  }
381  virtual void GetTrigger(Double_t& low, Double_t& high) const
382  {
383  low = fLow;
384  high = fHigh;
385  }
386  Int_t MakeTrigger(GraphSysErr* gse, TLegend* l) const
387  {
388  gse->AddQualifier("TRIGGER", "INEL");
389  return SysErrorAdder::MakeTrigger(gse, l);
390  }
391 };
397 {
404  INELGt0Adder(const TString& sys, UShort_t sNN)
405  : SysErrorAdder(sys, sNN, "INEL>0"), fLow(0), fHigh(0)
406  {
407  switch (sNN) {
408  case 13000: fLow = fHigh = 0.023; break;
409  }
410  }
411  const char* MakeName() const { return "INELGt0"; }
418  virtual void GetTrigger(Double_t& low, Double_t& high) const
419  {
420  low = fLow; high = fHigh;
421  }
422  Int_t MakeTrigger(GraphSysErr* gse, TLegend* l) const
423  {
424  gse->AddQualifier("TRIGGER", "INEL>0");
425  gse->AddQualifier("N", ">0");
426  return SysErrorAdder::MakeTrigger(gse, l);
427  }
430 };
435 struct NSDAdder : public SysErrorAdder
436 {
445  NSDAdder(const TString& sys, UShort_t sNN, Double_t value=-1)
446  : SysErrorAdder(sys, sNN, "NSD"), fValue(value)
447  {
448  if (value > 0) return;
449  if (fSys.EqualTo("pp", TString::kIgnoreCase)) {
450  switch (fSNN) {
451  case 900: fValue = 0.02; break;
452  case 2760: fValue = 0.03; break;
453  case 5023: fValue = 0.00; break;
454  case 7000:
455  case 8000:
456  case 13000: fValue = 0.02; break;
457  default: break;
458  }
459  }
460  }
467  virtual void GetTrigger(Double_t& low, Double_t& high) const
468  {
469  low = high = fValue;
470  }
471  Int_t MakeTrigger(GraphSysErr* gse, TLegend* l) const
472  {
473  gse->AddQualifier("TRIGGER", "NSD");
474  return SysErrorAdder::MakeTrigger(gse, l);
475  }
476 
477 };
482 struct CENTAdder : public SysErrorAdder
483 {
486  // Double_t fMin;
487  // Double_t fMax;
498  CENTAdder(const TString& sys, UShort_t sNN, const TString& method)
499  : SysErrorAdder(sys, sNN, method), fCent(0), fValue(0), fCMin(0), fCMax(0),
500  fLookup(0)
501  {
502  Double_t off = .1;
503  if (fSys.EqualTo("pPb", TString::kIgnoreCase) ||
504  fSys.EqualTo("Pbp", TString::kIgnoreCase)) {
505  TString m;
506  if (!method.BeginsWith("CENT")) m = "CENT";
507  m.Append(method);
508  Double_t cent[] = { 0, 5, 10, 20, 40, 60, 80, 100+off };
509  Double_t zna[] = { 1.5, 1.5, 1.5, 1.5, 2., 2., 3. };
510  Double_t v0a[] = { 1.5, 1.5, 1.5, 1.5, 2., 2., 2. };
511  Double_t v0m[] = { 1.5, 1.5, 1.5, 1.5, 2., 2., 4. };
512  Double_t cl1[] = { 2.5, 2.5, 2.5, 4.0, 6., 10., 11. };
513  Double_t* est = 0;
514  if (m.Contains("CENTZNA") || m.Contains("CENTZNC")) est = zna;
515  else if (m.Contains("CENTV0A") || m.Contains("CENTV0C")) est = v0a;
516  else if (m.Contains("CENTV0M")) est = v0m;
517  else if (m.Contains("CENTCL1")) est = cl1;
518  if (!est) {
519  Warning("","Couldn't find estimator from %s", method.Data());
520  return;
521  }
522  fTrig = m;
523  fLookup = new TH1D("lookup", "Centrality error lookup", 7, cent);
524  for (Int_t i = 1; i <= 7; i++) fLookup->SetBinContent(i,est[i-1]/100);
525  }
526  else {
527  fTrig = "CENT";
528  fLookup = new TH1D("lookup", "Centrality error lookup", 100, 0, 100);
529  Double_t min = 0.004, max = 0.062, top = 100; // 0.02
530  if (sNN == 5023) {
531  min = 0.005;
532  max = 0.075;
533  top = 80;
534  // max = (7.5-min)/TMath::Power(80,2) * TMath::Power(100,2) + min;
535  }
536  for (Int_t i = 1; i <= 100; i++) {
537  Double_t c = fLookup->GetXaxis()->GetBinCenter(i);
538  Double_t e = max * TMath::Power(c/top,2)+min;
539  fLookup->SetBinContent(i, e);
540  }
541  }
542  if (fLookup) fLookup->SetDirectory(0);
543 
544  }
545  const char* GetTriggerName() const
546  {
547  // static TString n;
548  // n = fTrig;
549  // n.ReplaceAll("CENT", "Centrality (");
550  // n.Append(")");
551  return "Centrality";
552  }
553  virtual const char* GetTriggerString() const
554  {
555  return Form("%s_%03dd%02d_%03dd%02d",
556  fTrig.Data(),
557  Int_t(fCMin), Int_t(fCMin*100)%100,
558  Int_t(fCMax), Int_t(fCMax*100)%100);
559  }
566  virtual void GetTrigger(Double_t& low, Double_t& high) const
567  {
568  if (!fLookup) { low = high = 0; return; }
569  Int_t bin = fLookup->FindBin(fCent);
570  low = high = fLookup->GetBinContent(bin);
571  }
572  Int_t MakeTrigger(GraphSysErr* gse, TLegend* l) const
573  {
574  gse->AddQualifier("TRIGGER", fTrig);
575  gse->AddQualifier("CENTRALITY IN PCT", Form("%6.2f TO %6.2f",fCMin,fCMax));
576  return SysErrorAdder::MakeTrigger(gse, l);
577  }
586  Double_t GetCentrality(TH1* h, Bool_t verb=false)
587  {
588  TString name(h->GetName());
589  if (verb)
590  Info("", "Extracting centrality from %s", name.Data());
591  Int_t idx = name.Index("_cent");
592  if (idx == kNPOS) {
593  Warning("GetCentrality", "Don't know how to parse %s",
594  name.Data());
595  return -1;
596  }
597  name.Remove(0,idx+5);
598  name.ReplaceAll("d", ".");
599  name.ReplaceAll("_", " ");
600  TObjArray* tokens = name.Tokenize(" ");
601  TObjString* first = static_cast<TObjString*>(tokens->At(0));
602  TObjString* second = static_cast<TObjString*>(tokens->At(1));
603  fCMin = first->String().Atof();
604  fCMax = second->String().Atof();
605  fCent = (fCMin+fCMax)/2;
606  return fCent;
607  }
616  virtual Int_t MakeEmpirical(GraphSysErr* gse, TLegend* l) const
617  {
618  if (GetEmpirical() <= 0) return -1;
619  if (fCent >= 0)
620  return SysErrorAdder::MakeEmpirical(gse, l);
621 
622  AddLegend(l, 0, "Empirical", kEmpiricalFill);
623  return -1;
624  }
625 
636  virtual GraphSysErr* Make(TH1* h,
637  TLegend* l,
638  Double_t eff=1,
639  Bool_t verb=false)
640  {
641  fCent = GetCentrality(h, verb);
642  if (fCent < 0) return 0;
643  return SysErrorAdder::Make(h, l, eff, verb);
644  }
645 };
646 
647 
650  const TString& s,
651  UShort_t e,
652  const TString& c)
653 {
654  TString tt(t);
655  tt.ToUpper();
656 
657  SysErrorAdder* a = 0;
658  if (tt.EqualTo("OFFLINE") ||tt.EqualTo("UNKNOWN"))a=new OfflineAdder(s,e);
659  else if (tt.EqualTo("INEL") ||tt.EqualTo("MBOR")) a=new INELAdder(s,e);
660  else if (tt.EqualTo("INEL>0")||tt.EqualTo("INELGT0"))a=new INELGt0Adder(s,e);
661  else if (tt.EqualTo("NSD") ||tt.EqualTo("V0AND")) a=new NSDAdder(s,e);
662  else a=new CENTAdder(s,e,c);
663  Info("Create", "Created %s adder for %s/%s/%hu/%s: %p",
664  a->GetTriggerString(), t.Data(), s.Data(), e, c.Data(), a);
665  return a;
666 }
667 
668 
669 //
670 // EOF
671 //
const char * GetTriggerName() const
virtual Int_t MakeTrigger(GraphSysErr *gse, TLegend *l) const
void SetSysLineColor(Int_t id, Color_t color)
Definition: GraphSysErr.C:4359
void SetYTitle(const char *title)
Definition: GraphSysErr.C:3598
virtual Double_t GetDensity(Short_t w) const
static SysErrorAdder * Create(const TString &t, const TString &s, UShort_t e, const TString &c)
double Double_t
Definition: External.C:58
void SetSysLineStyle(Int_t id, Style_t style)
Definition: GraphSysErr.C:4371
virtual GraphSysErr * Make(TH1 *h, TLegend *l, Double_t eff=1, Bool_t verb=false)
OfflineAdder(const TString &sys, UShort_t sNN)
virtual Double_t GetMerging(Short_t) const
const char * title
Definition: MakeQAPdf.C:26
Double_t fValue
virtual const char * GetTriggerName() const
Definition: SysErrorAdder.C:55
NSDAdder(const TString &sys, UShort_t sNN, Double_t value=-1)
virtual void GetTrigger(Double_t &low, Double_t &high) const =0
virtual Double_t GetHadron(Double_t eta) const
void SetSysOption(Int_t id, EDrawOption_t opt)
Definition: GraphSysErr.C:4431
const char * MakeName() const
Int_t MakeTrigger(GraphSysErr *gse, TLegend *l) const
void SetKey(const char *key, const char *value, Bool_t replace=false)
Definition: GraphSysErr.C:4587
Double_t fCMax
void SetPointError(Int_t i, Double_t ex)
Definition: GraphSysErr.C:3468
virtual void GetTrigger(Double_t &low, Double_t &high) const
void SetSysFillStyle(Int_t id, Style_t style)
Definition: GraphSysErr.C:4407
void SetSysLineWidth(Int_t id, Width_t width)
Definition: GraphSysErr.C:4383
void SetSysError(Int_t id, Double_t eyl, Double_t eyh)
Definition: GraphSysErr.C:3528
virtual void GetTrigger(Double_t &low, Double_t &high) const
TCanvas * c
Definition: TestFitELoss.C:172
void AddQualifier(const TString &key, const TString &value, Bool_t replace=false)
Definition: GraphSysErr.C:4759
const char * GetSysTitle(Int_t id) const
Definition: GraphSysErr.C:3761
void AddLegend(TLegend *l, Int_t id, const char *title, Style_t fill) const
Double_t fCMin
Int_t MakeTrigger(GraphSysErr *gse, TLegend *l) const
void SetStatError(Int_t i, Double_t ey)
Definition: GraphSysErr.C:3505
virtual void GetTrigger(Double_t &low, Double_t &high) const
virtual GraphSysErr * Make(TH1 *h, TLegend *l, Double_t eff=1, Bool_t verb=false)
void SetPoint(Int_t i, Double_t x, Double_t y)
Definition: GraphSysErr.C:3457
virtual void GetTrigger(Double_t &low, Double_t &high) const
UInt_t DefineCommon(const char *title, Bool_t relative, Double_t ey, EDrawOption_t option=kFill)
Definition: GraphSysErr.C:3350
virtual const char * MakeName() const
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 fLow
Int_t method
virtual ~SysErrorAdder()
Definition: SysErrorAdder.C:49
Int_t MakeTrigger(GraphSysErr *gse, TLegend *l) const
Definition: External.C:212
Double_t fHigh
void SetSysFillColor(Int_t id, Color_t color)
Definition: GraphSysErr.C:4395
An (X,Y) graph with configurable errors.
Int_t ModColor(Color_t n, UShort_t off) const
Definition: SysErrorAdder.C:57
unsigned long ULong_t
Definition: External.C:38
virtual Int_t MakeEmpirical(GraphSysErr *gse, TLegend *l) const
virtual void GetTrigger(Double_t &low, Double_t &high) const
void SetSumOption(EDrawOption_t opt)
Definition: GraphSysErr.C:4449
void SetSumLineWidth(Width_t width)
Definition: GraphSysErr.C:4473
short Short_t
Definition: External.C:23
INELAdder(const TString &sys, UShort_t sNN, Double_t low=-1, Double_t high=-1)
Double_t GetCentrality(TH1 *h, Bool_t verb=false)
void ModError(GraphSysErr *gse, Int_t id, Style_t fill, TLegend *l, UShort_t off=64) const
Definition: SysErrorAdder.C:78
SysErrorAdder(const TString &sys, UShort_t sNN, const TString &trig)
Definition: SysErrorAdder.C:41
virtual Double_t GetEmpirical() const
Int_t MakeMerging(GraphSysErr *gse, TLegend *l) const
void SetSumTitle(const char *title)
Definition: GraphSysErr.C:4455
Int_t MakeTrigger(GraphSysErr *gse, TLegend *l) const
virtual const char * GetTriggerString() const
TH1 * fLookup
INELGt0Adder(const TString &sys, UShort_t sNN)
virtual Int_t MakeEmpirical(GraphSysErr *gse, TLegend *l) const
Double_t fCent
virtual Int_t MakeHadron(GraphSysErr *gse, TLegend *l) const
Int_t MakeTrigger(GraphSysErr *gse, TLegend *l) const
unsigned short UShort_t
Definition: External.C:28
virtual const char * GetTriggerString() const
Definition: SysErrorAdder.C:56
bool Bool_t
Definition: External.C:53
Double_t fHigh
UShort_t fSNN
Definition: SysErrorAdder.C:31
Int_t MakeDensity(GraphSysErr *gse, TLegend *l) const
void SetSumLineColor(Color_t color)
Definition: GraphSysErr.C:4461
void SetXTitle(const char *title)
Definition: GraphSysErr.C:3592
Double_t fLow
Double_t fValue
Definition: External.C:196
CENTAdder(const TString &sys, UShort_t sNN, const TString &method)