AliPhysics  32b88a8 (32b88a8)
 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", h->GetName(), l);
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("1/N \\hbox{d}N_{ch}/\\hbox{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 1/N dNch/deta over widest "
264  "possible eta region at the LHC");
265  gse->SetKey("author", "CHRISTENSEN");
266  gse->SetKey("comment", "We present 1/N 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 7000:
454  case 8000:
455  case 13000: fValue = 0.02; break;
456  default: break;
457  }
458  }
459  }
466  virtual void GetTrigger(Double_t& low, Double_t& high) const
467  {
468  low = high = fValue;
469  }
470  Int_t MakeTrigger(GraphSysErr* gse, TLegend* l) const
471  {
472  gse->AddQualifier("TRIGGER", "NSD");
473  return SysErrorAdder::MakeTrigger(gse, l);
474  }
475 
476 };
481 struct CENTAdder : public SysErrorAdder
482 {
485  // Double_t fMin;
486  // Double_t fMax;
497  CENTAdder(const TString& sys, UShort_t sNN, const TString& method)
498  : SysErrorAdder(sys, sNN, method), fCent(0), fValue(0), fCMin(0), fCMax(0),
499  fLookup(0)
500  {
501  Double_t off = .1;
502  if (fSys.EqualTo("pPb", TString::kIgnoreCase) ||
503  fSys.EqualTo("Pbp", TString::kIgnoreCase)) {
504  TString m;
505  if (!method.BeginsWith("CENT")) m = "CENT";
506  m.Append(method);
507  Double_t cent[] = { 0, 5, 10, 20, 40, 60, 80, 100+off };
508  Double_t zna[] = { 1.5, 1.5, 1.5, 1.5, 2., 2., 3. };
509  Double_t v0a[] = { 1.5, 1.5, 1.5, 1.5, 2., 2., 2. };
510  Double_t v0m[] = { 1.5, 1.5, 1.5, 1.5, 2., 2., 4. };
511  Double_t cl1[] = { 2.5, 2.5, 2.5, 4.0, 6., 10., 11. };
512  Double_t* est = 0;
513  if (m.Contains("CENTZNA") || m.Contains("CENTZNC")) est = zna;
514  else if (m.Contains("CENTV0A") || m.Contains("CENTV0C")) est = v0a;
515  else if (m.Contains("CENTV0M")) est = v0m;
516  else if (m.Contains("CENTCL1")) est = cl1;
517  if (!est) {
518  Warning("","Couldn't find estimator from %s", method.Data());
519  return;
520  }
521  fTrig = m;
522  fLookup = new TH1D("lookup", "Centrality error lookup", 7, cent);
523  for (Int_t i = 1; i <= 7; i++) fLookup->SetBinContent(i,est[i-1]/100);
524  }
525  else {
526  fTrig = "CENT";
527  fLookup = new TH1D("lookup", "Centrality error lookup", 100, 0, 100);
528  Double_t min = 0.004, max = 0.062, top = 100; // 0.02
529  if (sNN == 5023) {
530  min = 0.005;
531  max = 0.075;
532  top = 80;
533  // max = (7.5-min)/TMath::Power(80,2) * TMath::Power(100,2) + min;
534  }
535  for (Int_t i = 1; i <= 100; i++) {
536  Double_t c = fLookup->GetXaxis()->GetBinCenter(i);
537  Double_t e = max * TMath::Power(c/top,2)+min;
538  fLookup->SetBinContent(i, e);
539  }
540  }
541  if (fLookup) fLookup->SetDirectory(0);
542 
543  }
544  const char* GetTriggerName() const
545  {
546  // static TString n;
547  // n = fTrig;
548  // n.ReplaceAll("CENT", "Centrality (");
549  // n.Append(")");
550  return "Centrality";
551  }
552  virtual const char* GetTriggerString() const
553  {
554  return Form("%s_%03dd%02d_%03dd%02d",
555  fTrig.Data(),
556  Int_t(fCMin), Int_t(fCMin*100)%100,
557  Int_t(fCMax), Int_t(fCMax*100)%100);
558  }
565  virtual void GetTrigger(Double_t& low, Double_t& high) const
566  {
567  if (!fLookup) { low = high = 0; return; }
568  Int_t bin = fLookup->FindBin(fCent);
569  low = high = fLookup->GetBinContent(bin);
570  }
571  Int_t MakeTrigger(GraphSysErr* gse, TLegend* l) const
572  {
573  gse->AddQualifier("TRIGGER", fTrig);
574  gse->AddQualifier("CENTRALITY IN PCT", Form("%6.2f TO %6.2f",fCMin,fCMax));
575  return SysErrorAdder::MakeTrigger(gse, l);
576  }
585  Double_t GetCentrality(TH1* h, Bool_t verb=false)
586  {
587  TString name(h->GetName());
588  if (verb)
589  Info("", "Extracting centrality from %s", name.Data());
590  Int_t idx = name.Index("_cent");
591  if (idx == kNPOS) {
592  Warning("GetCentrality", "Don't know how to parse %s",
593  name.Data());
594  return -1;
595  }
596  name.Remove(0,idx+5);
597  name.ReplaceAll("d", ".");
598  name.ReplaceAll("_", " ");
599  TObjArray* tokens = name.Tokenize(" ");
600  TObjString* first = static_cast<TObjString*>(tokens->At(0));
601  TObjString* second = static_cast<TObjString*>(tokens->At(1));
602  fCMin = first->String().Atof();
603  fCMax = second->String().Atof();
604  fCent = (fCMin+fCMax)/2;
605  return fCent;
606  }
615  virtual Int_t MakeEmpirical(GraphSysErr* gse, TLegend* l) const
616  {
617  if (GetEmpirical() <= 0) return -1;
618  if (fCent >= 0)
619  return SysErrorAdder::MakeEmpirical(gse, l);
620 
621  AddLegend(l, 0, "Empirical", kEmpiricalFill);
622  return -1;
623  }
624 
635  virtual GraphSysErr* Make(TH1* h,
636  TLegend* l,
637  Double_t eff=1,
638  Bool_t verb=false)
639  {
640  fCent = GetCentrality(h, verb);
641  if (fCent < 0) return 0;
642  return SysErrorAdder::Make(h, l, eff, verb);
643  }
644 };
645 
646 
649  const TString& s,
650  UShort_t e,
651  const TString& c)
652 {
653  TString tt(t);
654  tt.ToUpper();
655 
656  SysErrorAdder* a = 0;
657  if (tt.EqualTo("OFFLINE") ||tt.EqualTo("UNKNOWN"))a=new OfflineAdder(s,e);
658  else if (tt.EqualTo("INEL") ||tt.EqualTo("MBOR")) a=new INELAdder(s,e);
659  else if (tt.EqualTo("INEL>0")||tt.EqualTo("INELGT0"))a=new INELGt0Adder(s,e);
660  else if (tt.EqualTo("NSD") ||tt.EqualTo("V0AND")) a=new NSDAdder(s,e);
661  else a=new CENTAdder(s,e,c);
662  Info("Create", "Created %s adder for %s/%s/%hu/%s: %p",
663  a->GetTriggerString(), t.Data(), s.Data(), e, c.Data(), a);
664  return a;
665 }
666 
667 
668 //
669 // EOF
670 //
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
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)