AliPhysics  6f1d526 (6f1d526)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dNdetaAnalysis.C
Go to the documentation of this file.
1 #ifndef DNDETAANALYSIS_C
2 #define DNDETAANALYSIS_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 #else
11 class TH1;
12 class TParticle;
13 class TMap;
14 #endif
15 #include "FastAnalysis.C"
16 #include "FastCentHelper.C"
17 namespace dNdeta {
18  //====================================================================
22  struct Base : public FastAnalysis
23  {
25 
26  Base(Bool_t verbose=false, Int_t monitor=0)
27  : FastAnalysis(verbose,monitor), fdNdeta(0)
28  {}
34  static TH1D* CreatedNdeta()
35  {
36  Double_t maxEta = 9; // 10;
37  Int_t nEta = Int_t(200 * maxEta/5+.5);
38  TH1D* eta = new TH1D("dNdeta",
39  "Charged particle pseudo-rapidity density",
40  nEta, -maxEta, +maxEta);
41  eta->Sumw2();
42  eta->SetXTitle("#it{#eta}");
43  eta->SetYTitle("1/N d#it{N}_{ch}/d#it{#eta}");
44  eta->SetMarkerColor(kRed+2);
45  eta->SetMarkerStyle(20);
46  eta->SetDirectory(0);
47 
48  return eta;
49  }
51  {
52  return CreatedNdeta();
53  }
57  virtual void SlaveBegin(TTree*)
58  {
59  Info("SlaveBegin", "Making dN/deta histogram");
61  fdNdeta->SetMarkerColor(kBlack);
62  fdNdeta->SetMarkerStyle(21);
63  fdNdeta->SetTitle(GetName());
64  fOutput->Add(fdNdeta);
65  }
71  virtual Bool_t ProcessParticle(const TParticle* p)
72  {
73  Double_t pT = p->Pt();
74  Double_t pZ = p->Pz();
75  Double_t theta = TMath::ATan2(pT, pZ);
76  Double_t eta = (pT < 1e-10 ? 1024 : -TMath::Log(TMath::Tan(theta/2)));
77  if (TMath::Abs(eta) > 1000) return false;
78 
79  Fill(eta);
80  return true;
81  }
82  virtual void Fill(Double_t eta) { fdNdeta->Fill(eta); }
87  virtual void Terminate()
88  {
89  fOK = GetEventCount();
90  if (fOK <= 0) {
91  SetStatus(-1);
92  Warning("Terminate", "No events selected");
93  return;
94  }
95  fdNdeta = static_cast<TH1*>(GetOutputObject("dNdeta", TH1::Class()));
96  if (!fdNdeta) {
97  SetStatus(-1);
98  Warning("Terminate", "No dN/deta histogram found");
99  return;
100  }
101  Printf("A total of %ld events", fOK);
102  TH1* copy = static_cast<TH1*>(fdNdeta->Clone("before"));
103  fOutput->Add(copy);
104 
105  fdNdeta->Scale(1. / fOK, "width");
106  fdNdeta->Draw();
107  SetStatus(0);
108  }
115  {
116  TObject* m1 = new TNamed("dNdeta", "");
117  m1->SetUniqueID(0x8); // Scale
118 
119  TList* ret = new TList;
120  ret->Add(m1);
121 
122  return ret;
123  }
124  ClassDef(Base,1);
125  };
126 
127  //====================================================================
132  struct NSD : public Base
133  {
140  NSD(Bool_t verbose=false, Int_t monitor=0)
141  : Base(verbose, monitor)
142  {}
150  {
151  if (fHeader->fType & 0x1) return false;
152  return true;
153  }
154  ClassDef(NSD,1);
155  };
156 
157  //====================================================================
162  struct INEL : public Base
163  {
170  INEL(Bool_t verbose=false, Int_t monitor=0)
171  : Base(verbose,monitor)
172  {}
178  virtual Bool_t ProcessHeader() { return true; }
179  ClassDef(INEL,1);
180  };
181 
182  //====================================================================
187  struct INELGt0 : public Base
188  {
195  INELGt0(Bool_t verbose=false, Int_t monitor=0)
196  : Base(verbose,monitor)
197  {
198  SetTrigger("INEL>0");
199  }
206  {
207  if (fHeader->fType & 0x4) return true;
208  return false;
209  }
210  ClassDef(INELGt0,1);
211  };
212 
213  //====================================================================
218  struct V0AND : public Base
219  {
226  V0AND(Bool_t verbose=false, Int_t monitor=0)
227  : Base(verbose,monitor)
228  {
229  SetTrigger("V0AND");
230  }
237  {
238  return CheckTrigger();
239  }
240  ClassDef(V0AND,1);
241  };
242 
243  //====================================================================
244  struct Cent : public Base
245  {
247  const Long_t fMinEvents;
256  Cent(const char* method="V0M", Bool_t verbose=true, Int_t monitor=0)
257  : Base(verbose,monitor),
258  fHelper(method),
259  fMinEvents(100),
260  fCentBin(0)
261  {
262  fTrigMask = 0x0;
264  }
270  virtual TH1* CreateSingle() { return Base::CreatedNdeta(); }
276  virtual void SlaveBegin(TTree* t)
277  {
278  Base::SlaveBegin(t);
279  // We use the parent fdNdeta histogram as a cache
280  fdNdeta->SetName("cache");
281  fdNdeta->SetTitle("Cache");
282 
284  fOutput->ls();
285  }
287  {
288  if (!Base::SetupEstimator()) return false;
289 
291  return true;
292  }
293 
297  virtual void Clear(Option_t* option="")
298  {
299  Base::Clear(option);
300  fdNdeta->Reset(); // Clear the cache
301  }
308  {
309  if (!CheckTrigger()) return false;
310  Double_t cent = GetCentrality();
312  fEventMult,
313  fHeader->fB,
315  fHeader->fNbin);
316  return fCentBin >= 0;
317  }
326  virtual void ProcessParticles()
327  {
328  // Check we got a bin
329  if (fCentBin < 0) return;
330 
331  // Find the histogram to update
332  TH1* out = static_cast<TH1*>(fHelper.fCentList->At(fCentBin-1));
333  // If we still have no histogram, return immediately
334  if (!out) return;
335 
336  // Use parent function to fill cache
338  if (fVerbose) {
339  Double_t n0 = fdNdeta->GetBinContent(fdNdeta->GetNbinsX()/2);
340  Double_t d0 = fdNdeta->GetXaxis()->GetBinWidth(fdNdeta->GetNbinsX()
341  /2);
342  Double_t eta0 = (n0 / d0);
343  Printf("Centrality %6.2f-%6.2f (bin %4d) "
344  "Nch=%8.1f/%4.2f=%8.1f out=%s (%d)",
345  fHelper.fCentAxis->GetBinLowEdge(fCentBin),
346  fHelper.fCentAxis->GetBinUpEdge(fCentBin),
347  fCentBin,
348  n0, d0, eta0,
349  out->GetName(),
350  Int_t(out->GetBinContent(0)));
351  }
352 
353  // Make sure we have nothing in the underflow bin.
354  fdNdeta->SetBinContent(0,0);
355 
356  // Add our cache to the appropriate bin
357  out->Add(fdNdeta);
358  // Increment underflow bin for the event count
359  out->SetBinContent(0, out->GetBinContent(0)+1);
360  }
367  virtual void Terminate()
368  {
369  fOK = GetEventCount();
370  if (fOK <= 0) {
371  SetStatus(-1);
372  Warning("Terminate", "No events selected");
373  return;
374  }
375 
376  if (!fHelper.Finalize(fOutput, fMinEvents, Cent::Normalize))
377  SetStatus(-1);
378  }
379  static TH1* Normalize(TObject* o, Int_t n)
380  {
381  if (!o->IsA()->InheritsFrom(TH1::Class())) return 0;
382  TH1* h = static_cast<TH1*>(o);
383  Int_t m = h->GetBinContent(0);
384  if (m != n)
385  ::Warning("Normalize", "Different event count here:%d helper:%d",m,n);
386  h->SetBinContent(0,0);
387  h->Scale(1. / n, "width");
388  return h;
389  }
390 
397  {
398  TObject* m1 = new TNamed("cent", "hist text30");
399  TObject* m2 = new TNamed("centAcc", "hist text30");
400  TObject* m3 = new TNamed("byCent", "e");
401 
402  m3->SetUniqueID(0x8); // Scale
403  TList* ret = new TList;
404  ret->Add(m1);
405  ret->Add(m2);
406  ret->Add(m3);
407 
408  return ret;
409  }
410  void Print(Option_t* option="") const
411  {
412  Base::Print(option);
413  Printf(" Least # events: %d", fMinEvents);
414  fHelper.Print(option);
415  }
416  ClassDef(Cent,1);
417  };
418 
419  //====================================================================
425  struct Mult : public Cent
426  {
434  Mult(const char* method="RefMult00d80",
435  Bool_t verbose=false,
436  Int_t monitor=0)
437  : Cent(method, verbose,monitor)
438  {
439  // +1 +2 +3 +3 +5, +5, +5, +5,+10,+10,+10,+10,+10,+10,+10
440  Double_t bins[]={ 0, 3, 6, 9, 14, 19, 24, 29, 39, 49, 59, 69, 79, 89, 99};
441  fHelper.SetCentAxis(14, bins);
442  }
443  ClassDef(Mult,1);
444  };
445 } // End of namespace
446 //====================================================================
447 /*
448  * The function to make our analyser
449  */
451 {
455  dNdetaMaker() : FastAnalysis::Maker("dNdeta") {}
456 
467  FastAnalysis* Make(const TString& subtype,
468  Int_t monitor,
469  Bool_t verbose,
470  TMap& uopt)
471  {
472  FastAnalysis* ret = 0;
473  TString t(subtype);
474  if (t.EqualTo("INEL")) ret = new dNdeta::INEL (verbose,monitor);
475  else if (t.EqualTo("NSD")) ret = new dNdeta::NSD (verbose,monitor);
476  else if (t.EqualTo("INELGt0")) ret = new dNdeta::INELGt0(verbose,monitor);
477  else if (t.EqualTo("V0AND")) ret = new dNdeta::V0AND (verbose,monitor);
478  else if (t.BeginsWith("MULT") || t.BeginsWith("CENT")) {
479  TString w(t(4, t.Length()-4));
480  if (!(w.BeginsWith("RefMult") ||
481  w.BeginsWith("ZNA") ||
482  w.BeginsWith("ZNC") ||
483  w.BeginsWith("ZPA") ||
484  w.BeginsWith("ZPC") ||
485  w.BeginsWith("V0M") ||
486  w.BeginsWith("V0A") ||
487  w.BeginsWith("V0C") ||
488  w.BeginsWith("B") ||
489  w.IsNull())) {
490  Printf("Warning: dNdetaMaker::Make: Unknown estimator: %s",
491  w.Data());
492  return 0;
493  }
494  if (t.BeginsWith("MULT"))
495  ret = new dNdeta::Mult(w, verbose, monitor);
496  else
497  ret = new dNdeta::Cent(w, verbose, monitor);
498  }
499 
500  if (ret) {
501  TPair* tp = static_cast<TPair*>(uopt.FindObject("trig"));
502  if( tp) ret->SetTrigger(tp->Value()->GetName());
503  }
504  else
505  Printf("Error: dNdetaMaker::Run: Invalid spec: %s", t.Data());
506  return ret;
507  }
512  void List() const
513  {
514  Printf(" INEL - inelastic");
515  Printf(" INELGt0 - inelastic with at least 1 particle in |eta|<1");
516  Printf(" NSD - Non-single diffractive");
517  Printf(" V0AND - Visible X-section");
518  Printf(" CENT<est> - Centrality classes. <est> is one of ");
519  Printf(" ZNA - ZNA signal");
520  Printf(" ZNC - ZNC signal");
521  Printf(" ZPA - ZPA signal");
522  Printf(" ZPC - ZPC signal");
523  Printf(" V0M - V0-A + -C");
524  Printf(" V0A - V0-A");
525  Printf(" V0C - V0-C");
526  }
530  const char* Script() const { return __FILE__; }
531 };
532 
533 // ------------------------------------------------------------------
534 // Create instance of maker
536 
537 #ifdef __MAKECINT__
538 #pragma link C++ nestedclasses;
539 #pragma link C++ namespace dNdeta;
540 #endif
541 #endif
542 //
543 // EOF
544 //
TObject * GetOutputObject(const char *name, TClass *cls)
Definition: FastAnalysis.C:490
virtual Bool_t ProcessHeader()
virtual Bool_t ProcessParticle(const TParticle *p)
Bool_t CheckTrigger() const
Definition: FastAnalysis.C:173
Cent(const char *method="V0M", Bool_t verbose=true, Int_t monitor=0)
double Double_t
Definition: External.C:58
FastShortHeader * fHeader
Definition: FastAnalysis.C:70
virtual Bool_t SetupEstimator()
Definition: FastAnalysis.C:250
Bool_t Finalize(TCollection *output, Long_t minEvents, TH1 *(*callback)(TObject *, Int_t))
static TObject * CreateOutput()
TH1 * fCentHist
Definition: FastAnalysis.C:84
This script defines classes for looping over the data produced by FastSim.C.
NSD(Bool_t verbose=false, Int_t monitor=0)
virtual Bool_t ProcessHeader()
virtual void Fill(Double_t eta)
FastCentHelper fHelper
ClassDef(INELGt0, 1)
dNdetaMaker * _dNdetaMaker
const char * Script() const
virtual void Clear(Option_t *option="")
virtual TList * GetMonitorObjects()
void SetCentAxis(Int_t n, Double_t low, Double_t high)
ClassDef(Cent, 1)
int Int_t
Definition: External.C:63
V0AND(Bool_t verbose=false, Int_t monitor=0)
virtual Bool_t SetupEstimator()
virtual void SlaveBegin(TTree *t)
Int_t method
static TH1 * Normalize(TObject *o, Int_t n)
static TH1D * CreatedNdeta()
virtual Bool_t ProcessHeader()
Definition: External.C:212
void Print(Option_t *option="") const
virtual void Terminate()
Base(Bool_t verbose=false, 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 void ProcessParticles()
Definition: FastAnalysis.C:561
Bool_t fVerbose
Definition: FastAnalysis.C:74
Mult(const char *method="RefMult00d80", Bool_t verbose=false, Int_t monitor=0)
INEL(Bool_t verbose=false, Int_t monitor=0)
void Print(Option_t *option="") const
ClassDef(Base, 1)
virtual Bool_t ProcessHeader()
ULong64_t fEventMult
Definition: FastAnalysis.C:80
ULong_t fOK
Definition: FastAnalysis.C:86
void CreateDiagnostics(TCollection *output, TH1 *centHist)
ClassDef(NSD, 1)
Int_t CheckCentrality(Double_t cent, Double_t mult, Double_t b, Double_t nPart, Double_t nBin)
virtual Bool_t ProcessHeader()
virtual void ProcessParticles()
INELGt0(Bool_t verbose=false, Int_t monitor=0)
void List() const
virtual void Terminate()
const char Option_t
Definition: External.C:48
FastAnalysis * Make(const TString &subtype, Int_t monitor, Bool_t verbose, TMap &uopt)
bool Bool_t
Definition: External.C:53
void SetTrigger(UInt_t mask)
Definition: FastAnalysis.C:125
UInt_t fTrigMask
Definition: FastAnalysis.C:90
ClassDef(V0AND, 1)
virtual TList * GetMonitorObjects()
Maker(const char *type="")
const Long_t fMinEvents
TString fCentMethod
Definition: FastAnalysis.C:82
virtual TH1 * CreateSingle()
virtual void SlaveBegin(TTree *)
Definition: External.C:196
ClassDef(Mult, 1)
virtual void Clear(Option_t *option="")
Definition: FastAnalysis.C:546
ClassDef(INEL, 1)