AliPhysics  1811c8f (1811c8f)
spectraAnalysis.C
Go to the documentation of this file.
1 #ifndef SPECTRAANALYSIS_C
2 #define SPECTRAANALYSIS_C
3 #ifndef __CINT__
4 # include <TH1.h>
5 # include <TH2.h>
6 # include <TMath.h>
7 # include <TParticle.h>
8 # include <TObjArray.h>
9 # include <TString.h>
10 # include <TParticlePDG.h>
11 # include <TGraphErrors.h>
12 #else
13 class TH1;
14 class TH2;
15 class TParticle;
16 class TMap;
17 #endif
18 #include "FastAnalysis.C"
19 #include "FastCentHelper.C"
20 
21 namespace spectra {
25  struct Base : public FastAnalysis
26  {
27  enum {
28  kPiSty = 20,
29  kKSty = 21,
30  kPSty = 22,
31  kOSty = 23,
32  kASty = 24
33  };
34  enum {
35  kPiColor = kRed+2,
36  kKColor = kGreen+2,
37  kPColor = kBlue+2,
38  kOColor = kMagenta+2,
39  kAColor = kBlack
40  };
47  Base(Bool_t verbose=false, Int_t monitor=0)
48  : FastAnalysis(verbose,monitor),
49  fNpi(0),
50  fNK(0),
51  fNP(0),
52  fNO(0),
53  fdNdpt(0),
54  fdNdptPi(0),
55  fdNdptK(0),
56  fdNdptP(0),
57  fdNdptO(0),
58  fdNdm(0),
59  fK2piRatio(0),
60  fP2piRatio(0),
61  fO2piRatio(0),
62  fd2Ndptdy(0),
63  fd2Ndmdy(0),
64  fMaxY(10)
65  {
66  }
76  static TH1* CreateSpectra(UInt_t pdg, Color_t col, Style_t sty)
77  {
78  TH1* h = new TH1D(dNdptName(pdg), "", 1000, 0, 10);
79  h->SetXTitle("p_{T}");
80  h->SetYTitle("dN/dp_{T}");
81  h->SetDirectory(0);
82  h->SetMarkerColor(col);
83  h->SetLineColor(col);
84  h->SetFillColor(col);
85  h->SetMarkerStyle(sty);
86  h->Sumw2();
87  return h;
88  }
89  static TH1* CreateMt(UInt_t pdg, Color_t col, Style_t sty)
90  {
91  TH1* h = new TH1D(dNdmtName(pdg), "", 1000, 0, 10);
92  h->SetXTitle("m_{T}");
93  h->SetYTitle("dN/dm_{T}");
94  h->SetDirectory(0);
95  h->SetMarkerColor(col);
96  h->SetLineColor(col);
97  h->SetFillColor(col);
98  h->SetMarkerStyle(sty);
99  h->Sumw2();
100  return h;
101  }
102  static TH1* CreateMass()
103  {
104  TH1* h = new TH1D("dNdm", "Mass distribution", 300, 0, 3);
105  h->SetXTitle("m\\ \\mathrm{(GeV)}");
106  h->SetYTitle("\\mathrm{d}N/\\mathrm{d}m");
107  h->SetDirectory(0);
108  h->SetMarkerColor(kBlack);
109  h->SetLineColor(kBlack);
110  h->SetFillColor(kBlack);
111  h->SetMarkerStyle(20);
112  h->Sumw2();
113  return h;
114  }
124  static TH1* CreateRatio(UInt_t pdg, Color_t col, Style_t sty)
125  {
126  TH1* h = new TH1D(RatioName(pdg), "", 100, 0, 1);
127  h->SetXTitle(Form("%d/211",pdg));
128  h->SetYTitle("Events");
129  h->SetDirectory(0);
130  h->SetMarkerColor(col);
131  h->SetLineColor(col);
132  h->SetFillColor(col);
133  h->SetMarkerStyle(sty);
134  h->Sumw2();
135  return h;
136  }
138  {
139  TList* ret = new TList;
140  ret->SetName("all");
141  ret->SetOwner(true);
142  ret->Add(CreateSpectra(-1, kAColor, kASty));
143  ret->Add(CreateSpectra(211, kPiColor,kPiSty));
144  ret->Add(CreateSpectra(321, kKColor, kKSty));
145  ret->Add(CreateSpectra(2212, kPColor, kPSty));
146  ret->Add(CreateSpectra(0, kOColor, kOSty));
147  ret->Add(CreateMass());
148  ret->Add(CreateRatio(321, kKColor, kKSty));
149  ret->Add(CreateRatio(2212, kPColor, kPSty));
150  ret->Add(CreateRatio(0, kOColor, kOSty));
151 
152  TH2* d2Ndptdy = new TH2D("d2Ndptdy","Spectra", 20, -10, +10, 100, 0, 10);
153  d2Ndptdy->SetDirectory(0);
154  d2Ndptdy->SetXTitle("\\mathit{y}");
155  d2Ndptdy->SetYTitle("p_{\\mathrm{T}}");
156  d2Ndptdy->SetZTitle("\\mathrm{d}^{2}N_{\\mathrm{ch}}/"
157  "\\mathrm{d}p_{\\mathrm{T}}\\mathrm{d}y");
158  ret->Add(d2Ndptdy);
159 
160  TH2* d2Ndmdy = new TH2D("d2Ndmdy", "Mass", 20, -10, +10, 300, 0, 3);
161  d2Ndmdy->SetDirectory(0);
162  d2Ndmdy->SetXTitle("\\mathit{y}");
163  d2Ndmdy->SetYTitle("\\mathit{m}\\ \\hbox{GeV}");
164  d2Ndmdy->SetZTitle("Events");
165  ret->Add(d2Ndmdy);
166 
167  return ret;
168  }
175  virtual void SlaveBegin(TTree*)
176  {
177  Info("SlaveBegin", "Making dN/dpt histogram");
178  TList* l = static_cast<TList*>(CreateOutput());
179  if (!l) {
180  Warning("SlaveBegin", "Failed to make histograms");
181  SetStatus(-1);
182  return;
183  }
184  l->SetOwner(false);
185  l->ls();
186  fdNdpt = static_cast<TH1*>(l->At(0));
187  fdNdptPi = static_cast<TH1*>(l->At(1));
188  fdNdptK = static_cast<TH1*>(l->At(2));
189  fdNdptP = static_cast<TH1*>(l->At(3));
190  fdNdptO = static_cast<TH1*>(l->At(4));
191  fdNdm = static_cast<TH1*>(l->At(5));
192  fK2piRatio = static_cast<TH1*>(l->At(6));
193  fP2piRatio = static_cast<TH1*>(l->At(7));
194  fO2piRatio = static_cast<TH1*>(l->At(8));
195  fd2Ndptdy = static_cast<TH2*>(l->At(9));
196  fd2Ndmdy = static_cast<TH2*>(l->At(10));
197  fOutput->AddAll(l);
198  }
205  Bool_t ProcessHeader() { return true; }
211  {
212  fNpi = fNK = fNP = fNO = 0;
214  if (fNpi <= 0) return;
215  fK2piRatio->Fill(Double_t(fNK)/fNpi);
216  fP2piRatio->Fill(Double_t(fNP)/fNpi);
217  fO2piRatio->Fill(Double_t(fNO)/fNpi);
218  }
224  virtual Bool_t ProcessParticle(const TParticle* p)
225  {
226  Double_t y = p->Y();
227  Double_t pT = p->Pt();
228  Double_t m = p->GetPDG()->Mass();
229  Int_t pdg = TMath::Abs(p->GetPdgCode());
230  fd2Ndptdy->Fill(y, pT);
231  fd2Ndmdy ->Fill(y, m);
232 
233  if (TMath::Abs(y) > fMaxY) return true;
234 
235  fdNdpt->Fill(pT);
236  fdNdm ->Fill(m);
237  if (pdg == 211) { fdNdptPi->Fill(pT); fNpi++; }
238  else if (pdg == 321) { fdNdptK ->Fill(pT); fNK++; }
239  else if (pdg == 2212) { fdNdptP ->Fill(pT); fNP++; }
240  else { fdNdptO ->Fill(pT); fNO++; }
241  return true;
242  }
250  static const char* dNdptName(UInt_t pdg)
251  {
252  switch (pdg) {
253  case -1: return "dNdpt";
254  case 211: return "dNdptPi";
255  case 321: return "dNdptK";
256  case 2212: return "dNdptP";
257  }
258  return "dNdptO";
259  }
267  static const char* dNdmtName(UInt_t pdg)
268  {
269  switch (pdg) {
270  case -1: return "dNdmt";
271  case 211: return "dNdmtPi";
272  case 321: return "dNdmtK";
273  case 2212: return "dNdmtP";
274  }
275  return "dNdmtO";
276  }
284  static const char* RatioName(UInt_t pdg)
285  {
286  switch (pdg) {
287  case 321: return "KtoPiRatio";
288  case 2212: return "PtoPiRatio";
289  }
290  return "OtoPiRatio";
291  }
299  static Bool_t Scale(TList* l, UInt_t pdg, Int_t nOK)
300  {
301  TH1* h = static_cast<TH1*>(l->FindObject(dNdptName(pdg)));
302  if (!h) {
303  ::Warning("Scale", "No %s histogram found", dNdptName(pdg));
304  return false;
305  }
306  Double_t intg = h->Integral();
307  h->Scale(1./nOK/intg, "width");
308  return true;
309  }
319  static Bool_t Ratio(TList* l, TH1* r, Int_t bin, UInt_t pdg)
320  {
321  TH1* h = static_cast<TH1*>(l->FindObject(RatioName(pdg)));
322  if (!h) {
323  ::Warning("Ratio", "No %s histogram found", RatioName(pdg));
324  return false;
325  }
326  r->SetBinContent(bin, h->GetMean());
327  r->SetBinError(bin, h->GetRMS());
328  return true;
329  }
330  static TH1* Normalize(TObject* o, Int_t nEv)
331  {
332  // Printf("Normalising spectra to %d events");
333  TList* l = static_cast<TList*>(o);
334  Scale(l, -1, nEv);
335  Scale(l, 211, nEv);
336  Scale(l, 321, nEv);
337  Scale(l, 2212,nEv);
338  Scale(l, 0, nEv);
339 
340  TH1* ratios = new TH1D("ratios","Ratios to #pi", 3, .5, 3.5);
341  ratios->GetXaxis()->SetBinLabel(1, "K/#pi");
342  ratios->GetXaxis()->SetBinLabel(2, "p/#pi");
343  ratios->GetXaxis()->SetBinLabel(3, "other/#pi");
344  ratios->SetFillColor(kCyan+2);
345  ratios->SetLineColor(kCyan+2);
346  ratios->SetMarkerColor(kCyan+2);
347  ratios->SetMarkerStyle(20);
348  ratios->SetDirectory(0);
349  Ratio(l, ratios, 1, 321);
350  Ratio(l, ratios, 2, 2212);
351  Ratio(l, ratios, 3, 0);
352  l->Add(ratios);
353 
354  TH2* d2Ndptdy = static_cast<TH2D*>(l->FindObject("d2Ndptdy"));
355  TProfile* meanPt = d2Ndptdy->ProfileX("meanPt");
356  meanPt->SetTitle("\\langle p_{\\mathrm{T}}\\rangle");
357  meanPt->SetDirectory(0);
358  meanPt->SetXTitle("\\mathit{y}");
359  meanPt->SetYTitle("\\langle p_{\\mathrm{T}}\\rangle");
360  l->Add(meanPt);
361 
362  TH2* d2Ndmdy = static_cast<TH2D*>(l->FindObject("d2Ndmdy"));
363  TProfile* meanM = d2Ndmdy->ProfileX("meanM");
364  meanM->SetTitle("\\langle p_{\\mathrm{T}}\\rangle");
365  meanM->SetDirectory(0);
366  meanM->SetXTitle("\\mathit{y}");
367  meanM->SetYTitle("\\langle p_{\\mathrm{T}}\\rangle");
368  l->Add(meanM);
369 
370  TH1* mpvPt = new TH1D("mpvPt","\\lambda(p_{\\mathrm{T}}",
371  meanPt->GetNbinsX(),
372  meanPt->GetXaxis()->GetXmin(),
373  meanPt->GetXaxis()->GetXmax());
374  mpvPt->SetDirectory(0);
375  mpvPt->SetStats(0);
376  mpvPt->SetXTitle("\\mathit{y}");
377  mpvPt->SetYTitle(mpvPt->GetTitle());
378  mpvPt->SetLineColor(meanPt->GetLineColor());
379  mpvPt->SetMarkerColor(meanPt->GetMarkerColor());
380  mpvPt->SetMarkerStyle(meanPt->GetMarkerStyle()+4);
381  mpvPt->SetMarkerSize(meanPt->GetMarkerSize());
382  for (Int_t i = 1; i <= mpvPt->GetNbinsX(); i++) {
383  d2Ndptdy->GetXaxis()->SetRange(i,i);
384  Int_t ix, iy, iz;
385  Int_t maxBin = d2Ndptdy->GetMaximumBin(ix, iy, iz);
386  Double_t mpv = d2Ndptdy->GetYaxis()->GetBinCenter(iy);
387  Double_t empv = d2Ndptdy->GetYaxis()->GetBinWidth(iy);
388  mpvPt->SetBinContent(i, mpv);
389  mpvPt->SetBinError (i, empv);
390  }
391  l->Add(mpvPt);
392 
393  TH1* mpvM = new TH1D("mpvM","\\lambda(m)",
394  meanM->GetNbinsX(),
395  meanM->GetXaxis()->GetXmin(),
396  meanM->GetXaxis()->GetXmax());
397  mpvM->SetDirectory(0);
398  mpvM->SetStats(0);
399  mpvM->SetXTitle("\\mathit{y}");
400  mpvM->SetYTitle(mpvM->GetTitle());
401  mpvM->SetLineColor(meanM->GetLineColor());
402  mpvM->SetMarkerColor(meanM->GetMarkerColor());
403  mpvM->SetMarkerStyle(meanM->GetMarkerStyle()+4);
404  mpvM->SetMarkerSize(meanM->GetMarkerSize());
405  for (Int_t i = 1; i <= mpvM->GetNbinsX(); i++) {
406  d2Ndmdy->GetXaxis()->SetRange(i,i);
407  Int_t ix, iy, iz;
408  Int_t maxBin = d2Ndmdy->GetMaximumBin(ix, iy, iz);
409  Double_t mpv = d2Ndmdy->GetYaxis()->GetBinCenter(iy);
410  Double_t empv = d2Ndmdy->GetYaxis()->GetBinWidth(iy);
411  mpvM->SetBinContent(i, mpv);
412  mpvM->SetBinError (i, empv);
413  }
414  l->Add(mpvM);
415 
416  return ratios;
417  }
422  virtual void Terminate()
423  {
424  fOK = GetEventCount();
425  if (fOK <= 0) {
426  SetStatus(-1);
427  Warning("Terminate", "No events selected");
428  return;
429  }
430  Printf("A total of %ld events", fOK);
431 
432  Normalize(fOutput, fOK);
433  }
440  {
441  TObject* m1 = new TNamed(dNdptName(-1), "");
442  m1->SetUniqueID(0x8); // Scale
443 
444  TList* ret = new TList;
445  ret->Add(m1);
446 
447  return ret;
448  }
449  void Print(Option_t* option="") const
450  {
451  FastAnalysis::Print(option);
452  Printf(" Max rapidity: +/-%f", fMaxY);
453  }
454  Long_t fNpi;
455  Long_t fNK;
456  Long_t fNP;
457  Long_t fNO;
458 
464 
466 
470 
473 
475 
476  ClassDef(Base,1);
477  };
478 
479  //====================================================================
484  struct V0AND : public Base
485  {
492  V0AND(Bool_t verbose=false, Int_t monitor=0)
493  : Base(verbose,monitor)
494  {
495  SetTrigger("V0AND");
496  }
503  {
504  return CheckTrigger();
505  }
506  ClassDef(V0AND,1);
507  };
508  //====================================================================
509  struct Cent : public Base
510  {
512  const Long_t fMinEvents;
521  Cent(const char* method="V0M", Bool_t verbose=true, Int_t monitor=0)
522  : Base(verbose,monitor),
523  fHelper(method),
524  fMinEvents(100),
525  fCentBin(0)
526  {
527  fTrigMask = 0x0;
528  fCentMethod = fHelper.fCentMeth;
529  }
535  virtual void SlaveBegin(TTree* t)
536  {
537  Base::SlaveBegin(t);
538  // We use the parent fdNdeta histogram as a cache
539  fHelper.CreateHistos(fOutput, Base::CreateOutput);
540  fOutput->ls();
541  }
543  {
544  if (!Base::SetupEstimator()) return false;
545 
546  fHelper.CreateDiagnostics(fOutput, fCentHist);
547  return true;
548  }
549 
553  virtual void Clear(Option_t* option="")
554  {
555  Base::Clear(option);
556  fdNdpt ->Reset();
557  fdNdptPi ->Reset();
558  fdNdptK ->Reset();
559  fdNdptP ->Reset();
560  fdNdptO ->Reset();
561  fdNdm ->Reset();
562  fK2piRatio->Reset();
563  fP2piRatio->Reset();
564  fO2piRatio->Reset();
565  fd2Ndptdy ->Reset();
566  fd2Ndmdy ->Reset();
567  }
574  {
575  if (!CheckTrigger()) return false;
576  Double_t cent = GetCentrality();
577  fCentBin = fHelper.CheckCentrality(cent,
578  fEventMult,
579  fHeader->fB,
581  fHeader->fNbin);
582  return fCentBin >= 0;
583  }
584  virtual void FillOut(TList* out)
585  {
586  static_cast<TH1*>(out->At(0)) ->Add(fdNdpt);
587  static_cast<TH1*>(out->At(1)) ->Add(fdNdptPi);
588  static_cast<TH1*>(out->At(2)) ->Add(fdNdptK);
589  static_cast<TH1*>(out->At(3)) ->Add(fdNdptP);
590  static_cast<TH1*>(out->At(4)) ->Add(fdNdptO);
591  static_cast<TH1*>(out->At(5)) ->Add(fdNdm);
592  static_cast<TH1*>(out->At(6)) ->Add(fK2piRatio);
593  static_cast<TH1*>(out->At(7)) ->Add(fP2piRatio);
594  static_cast<TH1*>(out->At(8)) ->Add(fO2piRatio);
595  static_cast<TH1*>(out->At(9)) ->Add(fd2Ndptdy);
596  static_cast<TH1*>(out->At(10))->Add(fd2Ndmdy);
597  }
606  virtual void ProcessParticles()
607  {
608  // Check we got a bin
609  if (fCentBin < 0) return;
610 
611  // Find the histogram to update
612  TList* out = static_cast<TList*>(fHelper.fCentList->At(fCentBin-1));
613  // If we still have no histogram, return immediately
614  if (!out) return;
615 
616  // Use parent function to fill cache
618 
619  // Add our cache to the appropriate bin
620  FillOut(out);
621  }
622  virtual void SetAttr(TH1* h, const char* title, Color_t col, Style_t sty)
623  {
624  h->SetDirectory(0);
625  h->SetTitle(title);
626  h->SetYTitle(title);
627  h->SetMarkerColor(col);
628  h->SetMarkerStyle(sty);
629  h->SetMarkerSize(2);
630  h->SetLineColor(col);
631  h->SetStats(0);
632  }
633 
640  virtual void Terminate()
641  {
642  fOK = GetEventCount();
643  if (fOK <= 0) {
644  SetStatus(-1);
645  Warning("Terminate", "No events selected");
646  return;
647  }
648 
649  if (!fHelper.Finalize(fOutput, fMinEvents, Base::Normalize))
650  SetStatus(-1);
651 
652 
653  TH1* meanPt = static_cast<TH1*>(fHelper.fCentAll->Clone("cmeanPt"));
654  meanPt->Reset();
655  SetAttr(meanPt, "\\langle p_{\\mathrm{T}}\\rangle", kKColor, kKSty);
656  fOutput->Add(meanPt);
657 
658  TH1* mpvPt = static_cast<TH1*>(meanPt->Clone("cmpvPt"));
659  mpvPt->Reset();
660  SetAttr(mpvPt,"\\lambda\\left(p_{\\mathrm{T}}\\right)",kKColor,kKSty+4);
661  fOutput->Add(mpvPt);
662 
663  TH1* meanM = static_cast<TH1*>(fHelper.fCentAll->Clone("cmeanM"));
664  meanM->Reset();
665  SetAttr(meanM,"\\langle m\\rangle",kPColor,kPSty);
666  fOutput->Add(meanM);
667 
668  TH1* mpvM = static_cast<TH1*>(meanM->Clone("cmpvM"));
669  mpvM->Reset();
670  SetAttr(mpvM,"\\lambda(m)",kPColor,kPSty+4);
671  fOutput->Add(mpvM);
672 
673  TH1* pt2m = static_cast<TH1*>(fHelper.fCentAll->Clone("cpt2m"));
674  pt2m->Reset();
675  SetAttr(pt2m,"\\langle p_{\\mathrm{T}}\\rangle/\\langle m\\rangle",
676  kPiColor, kPiSty);
677  fOutput->Add(pt2m);
678 
679  TH1* lpt2m = static_cast<TH1*>(pt2m->Clone("clpt2m"));
680  lpt2m->Reset();
681  SetAttr(lpt2m, "\\lambda\\left(p_{\\mathrm{T}}\\right)/\\lambda(m)",
682  kKColor, kKSty);
683  fOutput->Add(lpt2m);
684 
685  TH1* mpt2m = static_cast<TH1*>(pt2m->Clone("cmpt2m"));
686  mpt2m->Reset();
687  SetAttr(mpt2m,"\\lambda\\left(p_{\\mathrm{T}}\\right)/\\langle m\\rangle",
688  kPColor, kPSty);
689  fOutput->Add(mpt2m);
690 
691  TH1* k2pi = static_cast<TH1*>(fHelper.fCentAll->Clone("ck2pi"));
692  k2pi->Reset();
693  SetAttr(k2pi,"\\langle K/\\pi\\rangle",kKColor,kKSty);
694  fOutput->Add(k2pi);
695 
696  TH1* p2pi = static_cast<TH1*>(fHelper.fCentAll->Clone("cp2pi"));
697  p2pi->Reset();
698  SetAttr(p2pi,"\\langle p/\\pi \\rangle",kPColor,kPSty);
699  fOutput->Add(p2pi);
700 
701  TH1* o2pi = static_cast<TH1*>(fHelper.fCentAll->Clone("co2pi"));
702  o2pi->Reset();
703  SetAttr(o2pi,"\\langle X/\\pi \\rangle",kOColor,kOSty);
704  fOutput->Add(o2pi);
705 
706  for (Int_t i = 1; i <= meanPt->GetNbinsX(); i++) {
707  TList* out = static_cast<TList*>(fHelper.CentCollection(i));
708  if (!out) continue;
709  TH1* dNdpt = static_cast<TH1*>(out->At(0));
710  TH1* dNdptPi = static_cast<TH1*>(out->At(1));
711  TH1* dNdptK = static_cast<TH1*>(out->At(2));
712  TH1* dNdptP = static_cast<TH1*>(out->At(3));
713  TH1* dNdptO = static_cast<TH1*>(out->At(4));
714  TH1* dNdm = static_cast<TH1*>(out->At(5));
715  TH1* k2piRatio = static_cast<TH1*>(out->At(6));
716  TH1* p2piRatio = static_cast<TH1*>(out->At(7));
717  TH1* o2piRatio = static_cast<TH1*>(out->At(8));
718  TH2* d2Ndptdy = static_cast<TH2*>(out->At(9));
719  TH2* d2Ndmdy = static_cast<TH2*>(out->At(10));
720  TH1* rat = static_cast<TH1*>(out->At(11));
721  Int_t bPt = dNdpt->GetMaximumBin();
722  Int_t bM = dNdm ->GetMaximumBin();
723  meanPt->SetBinContent(i, dNdpt->GetMean());
724  meanPt->SetBinError (i, dNdpt->GetMeanError());
725  meanM ->SetBinContent(i, dNdm ->GetMean());
726  meanM ->SetBinError (i, dNdm ->GetMeanError());
727  mpvPt->SetBinContent (i, dNdpt->GetXaxis()->GetBinCenter(bPt));
728  mpvPt->SetBinError (i, dNdpt->GetXaxis()->GetBinWidth (bPt));
729  mpvM ->SetBinContent (i, dNdm ->GetXaxis()->GetBinCenter(bM));
730  mpvM ->SetBinError (i, dNdm ->GetXaxis()->GetBinWidth (bM));
731  k2pi ->SetBinContent(i, rat ->GetBinContent(1));
732  k2pi ->SetBinError (i, rat ->GetBinError (1));
733  p2pi ->SetBinContent(i, rat ->GetBinContent(2));
734  p2pi ->SetBinError (i, rat ->GetBinError (2));
735  o2pi ->SetBinContent(i, rat ->GetBinContent(3));
736  o2pi ->SetBinError (i, rat ->GetBinError (3));
737  }
738  pt2m->Add(meanPt);
739  pt2m->Divide(meanM);
740  lpt2m->Add(mpvPt);
741  lpt2m->Divide(mpvM);
742  mpt2m->Add(mpvPt);
743  mpt2m->Divide(meanM);
744 
745  Double_t fit[] = { 1.61,1.60,1.57,1.50,1.47,1.48,1.51,1.52,1.49,1.47,0};
746  Double_t err[] = { 0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.03,0.03,0.04,0};
747  TProfile* nPart =
748  static_cast<TProfile*>(fOutput->FindObject("centNPartMean"));
749  TGraphErrors* ptm = new TGraphErrors;
750  ptm->SetName("cptm");
751  ptm->SetTitle("\\langle p_{\\mathrm{T}}\\rangle/\\langle m\\rangle");
752  ptm->SetMarkerColor(kPiColor);
753  ptm->SetMarkerStyle(kPiSty);
754  ptm->SetLineColor(kPiColor);
755  fOutput->Add(ptm);
756  TGraphErrors* lptm = new TGraphErrors;
757  lptm->SetName("clptm");
758  lptm->SetTitle("\\lambda\\left(p_{\\mathrm{T}}\\right)/\\lambda(m)");
759  lptm->SetMarkerColor(kPiColor);
760  lptm->SetMarkerStyle(kPiSty+4);
761  lptm->SetLineColor(kPiColor);
762  fOutput->Add(lptm);
763  for (Int_t i = 1; i <= nPart->GetNbinsX(); i++) {
764  Double_t nP = nPart->GetBinContent(i);
765  Double_t eP = nPart->GetBinError (i);
766  Double_t p2m = pt2m ->GetBinContent(i);
767  Double_t ep2m = pt2m ->GetBinError (i);
768  Double_t lp2m = lpt2m->GetBinContent(i);
769  Double_t lep2m = lpt2m->GetBinError (i);
770  ptm->SetPoint (i-1, nP, p2m);
771  ptm->SetPointError (i-1, eP, ep2m);
772  lptm->SetPoint (i-1, nP, lp2m);
773  lptm->SetPointError(i-1, eP, lep2m);
774  Printf("%2d Npart=%5.1f+/-%4.1f <pT>/<m>=%5.3f+/-%5.3f "
775  "l(pT)/l(m)=%5.3f+/-%5.3f a=%5.3f+/-%5.3f",
776  i, nP, eP, p2m, ep2m, lp2m, lep2m, fit[i-1], err[i-1]);
777  }
778  TMultiGraph* mg = new TMultiGraph;
779  mg->SetName("mg");
780  mg->SetTitle("Estimates");
781  mg->Add(ptm);
782  mg->Add(lptm);
783  fOutput->Add(mg);
784 
785  THStack* means = new THStack("meansCent","Particle means");
786  means->Add(meanPt);
787  means->Add(meanM);
788  fOutput->Add(means);
789 
790  THStack* ptms = new THStack("ptmsCent","Particle ptms");
791  ptms->Add(pt2m);
792  ptms->Add(lpt2m);
793  ptms->Add(mpt2m);
794  fOutput->Add(ptms);
795 
796  THStack* ratios = new THStack("ratiosCent","Particle ratios");
797  ratios->Add(k2pi);
798  ratios->Add(p2pi);
799  ratios->Add(o2pi);
800  fOutput->Add(ratios);
801 
802  ptm->SaveAs("ptm.C");
803  }
810  {
811  TObject* m1 = new TNamed("cent", "hist text30");
812  TObject* m2 = new TNamed("centAcc", "hist text30");
813  TObject* m3 = new TNamed("byCent", "e");
814  TObject* m0 = new TNamed(dNdptName(-1), "");
815  m0->SetUniqueID(0x8); // Scale
816  m3->SetUniqueID(0x8); // Scale
817  TList* ret = new TList;
818  ret->Add(m0);
819  ret->Add(m1);
820  ret->Add(m2);
821  ret->Add(m3);
822 
823  return ret;
824  }
825  void Print(Option_t* option="") const
826  {
827  Base::Print(option);
828  Printf(" Least # events: %d", fMinEvents);
829  fHelper.Print(option);
830  }
831  ClassDef(Cent,1);
832  };
833 
834 }
835 //====================================================================
836 /*
837  * The function to make our analyser
838  */
840 {
844  spectraMaker() : FastAnalysis::Maker("spectra") {}
855  FastAnalysis* Make(const TString& subtype,
856  Int_t monitor,
857  Bool_t verbose,
858  TMap& uopt)
859  {
860  spectra::Base* ret = 0;
861  TString t(subtype);
862  if (t.EqualTo("V0AND")) ret = new spectra::V0AND(verbose,monitor);
863  else if (t.BeginsWith("CENT")) {
864  TString w(t(4, t.Length()-4));
865  if (!(w.BeginsWith("RefMult") ||
866  w.BeginsWith("ZNA") ||
867  w.BeginsWith("ZNC") ||
868  w.BeginsWith("ZPA") ||
869  w.BeginsWith("ZPC") ||
870  w.BeginsWith("V0M") ||
871  w.BeginsWith("V0A") ||
872  w.BeginsWith("V0C") ||
873  w.BeginsWith("B") ||
874  w.IsNull())) {
875  Printf("Warning: spectraMaker::Make: Unknown estimator: %s",
876  w.Data());
877  return 0;
878  }
879  ret = new spectra::Cent(w, verbose, monitor);
880  }
881  else
882  ret = new spectra::Base(verbose, monitor);
883 
884  if (ret) {
885  TPair* tp = static_cast<TPair*>(uopt.FindObject("trig"));
886  if (tp) ret->SetTrigger(tp->Value()->GetName());
887  TPair* my = static_cast<TPair*>(uopt.FindObject("maxy"));
888  if (my) ret->fMaxY = TString(my->Value()->GetName()).Atof();
889  }
890  else
891  Printf("Error: spectraMaker::Run: Invalid spec: %s", t.Data());
892  return ret;
893  }
898  void List() const
899  {
900  Printf(" <default> - Inelastic");
901  Printf(" V0AND - Visible X-section");
902  Printf(" CENT<est> - Centrality classes. <est> is one of ");
903  Printf(" ZNA - ZNA signal");
904  Printf(" ZNC - ZNC signal");
905  Printf(" ZPA - ZPA signal");
906  Printf(" ZPC - ZPC signal");
907  Printf(" V0M - V0-A + -C");
908  Printf(" V0A - V0-A");
909  Printf(" V0C - V0-C");
910  }
914  const char* Script() const { return __FILE__; }
915 };
916 
917 
918 // ------------------------------------------------------------------
919 // Create instance of maker
921 
922 #endif
923 //
924 // EOF
925 //
void Print(Option_t *option="") const
Int_t pdg
Bool_t CheckTrigger() const
Definition: FastAnalysis.C:173
spectraMaker * _spectraMaker
double Double_t
Definition: External.C:58
static Bool_t Scale(TList *l, UInt_t pdg, Int_t nOK)
const char * title
Definition: MakeQAPdf.C:27
FastShortHeader * fHeader
Definition: FastAnalysis.C:70
static const char * RatioName(UInt_t pdg)
static TH1 * CreateMt(UInt_t pdg, Color_t col, Style_t sty)
virtual Bool_t SetupEstimator()
Definition: FastAnalysis.C:250
Bool_t Finalize(TCollection *output, Long_t minEvents, TH1 *(*callback)(TObject *, Int_t))
virtual Bool_t SetupEstimator()
TH1 * fCentHist
Definition: FastAnalysis.C:84
const char * Script() const
This script defines classes for looping over the data produced by FastSim.C.
static TH1 * CreateSpectra(UInt_t pdg, Color_t col, Style_t sty)
TH1 * SetAttr(TH1 *h, Color_t color, Style_t marker=20, Double_t size=1., Style_t fill=0, Style_t line=1, Width_t width=1)
static const char * dNdmtName(UInt_t pdg)
static TObject * CreateOutput()
Bool_t ProcessHeader()
virtual void Clear(Option_t *option="")
const Long_t fMinEvents
void Print(Option_t *option="") const
static TH1 * CreateRatio(UInt_t pdg, Color_t col, Style_t sty)
virtual Bool_t ProcessHeader()
int Int_t
Definition: External.C:63
virtual void SlaveBegin(TTree *t)
Base(Bool_t verbose=false, Int_t monitor=0)
unsigned int UInt_t
Definition: External.C:33
static Bool_t Ratio(TList *l, TH1 *r, Int_t bin, UInt_t pdg)
Int_t method
virtual void SlaveBegin(TTree *)
static TH1 * Normalize(TObject *o, Int_t nEv)
Definition: External.C:228
Definition: External.C:212
Cent(const char *method="V0M", Bool_t verbose=true, Int_t monitor=0)
void CreateHistos(TCollection *output, TObject *(*callback)())
virtual void Print(Option_t *option="") const
Definition: FastAnalysis.C:403
Long_t GetEventCount()
Definition: FastAnalysis.C:472
Double_t GetCentrality() const
Definition: FastAnalysis.C:442
virtual TList * GetMonitorObjects()
virtual void ProcessParticles()
Definition: FastAnalysis.C:561
virtual void ProcessParticles()
TCollection * CentCollection(Int_t bin) const
void Print(Option_t *option="") const
virtual TList * GetMonitorObjects()
virtual Bool_t ProcessParticle(const TParticle *p)
ULong64_t fEventMult
Definition: FastAnalysis.C:80
ULong_t fOK
Definition: FastAnalysis.C:86
void CreateDiagnostics(TCollection *output, TH1 *centHist)
virtual void Terminate()
static const char * dNdptName(UInt_t pdg)
Definition: External.C:220
V0AND(Bool_t verbose=false, Int_t monitor=0)
virtual Bool_t ProcessHeader()
Int_t CheckCentrality(Double_t cent, Double_t mult, Double_t b, Double_t nPart, Double_t nBin)
FastCentHelper fHelper
virtual void SetAttr(TH1 *h, const char *title, Color_t col, Style_t sty)
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
void SetTrigger(UInt_t mask)
Definition: FastAnalysis.C:125
void ProcessParticles()
UInt_t fTrigMask
Definition: FastAnalysis.C:90
virtual void FillOut(TList *out)
TString fCentMethod
Definition: FastAnalysis.C:82
virtual void Terminate()
Definition: External.C:196
void List() const
static TH1 * CreateMass()
virtual void Clear(Option_t *option="")
Definition: FastAnalysis.C:546
FastAnalysis * Make(const TString &subtype, Int_t monitor, Bool_t verbose, TMap &uopt)