AliPhysics  ad6828d (ad6828d)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dNdyAnalysis.C
Go to the documentation of this file.
1 #ifndef __CINT__
2 # include <TH1.h>
3 # include <TH2.h>
4 # include <TMath.h>
5 # include <TParticle.h>
6 # include <TObjArray.h>
7 # include <TString.h>
8 #else
9 class TH1;
10 class TParticle;
11 #endif
12 #include "FastAnalysis.C"
13 #include "FastCentHelper.C"
14 namespace dNdy {
15  //====================================================================
19  struct Base : public FastAnalysis
20  {
22 
29  Base(Bool_t verbose=false, Int_t monitor=0)
30  : FastAnalysis(verbose,monitor), fdNdy(0)
31  {}
37  static TH1D* CreatedNdy()
38  {
39  Double_t maxY = 9; // 10;
40  Double_t dY = .25;
41  TH1D* h = new TH1D("dNdy", "Charged particle-rapidity density",
42  Int_t(2*maxY/dY+.5), -maxY, +maxY);
43  h->Sumw2();
44  h->SetXTitle("\\mathit{y}");
45  h->SetYTitle("\\hbox{d}N_{\\hbox{ch}}/\\hbox{d}y");
46  h->SetMarkerColor(kRed+2);
47  h->SetMarkerStyle(20);
48  h->SetDirectory(0);
49 
50  return h;
51  }
55  virtual void SlaveBegin(TTree*)
56  {
57  Info("SlaveBegin", "Making dN/dy histogram");
58  fdNdy = CreatedNdy();
59  fdNdy->SetMarkerColor(kBlack);
60  fdNdy->SetMarkerStyle(21);
61  fdNdy->SetTitle(GetName());
62  fOutput->Add(fdNdy);
63  }
69  virtual Bool_t ProcessParticle(const TParticle* p)
70  {
71  Fill(p->Y());
72  return true;
73  }
74  virtual void Fill(Double_t y) { fdNdy->Fill(y); }
79  virtual void Terminate()
80  {
81  fOK = GetEventCount();
82  if (fOK <= 0) {
83  SetStatus(-1);
84  Warning("Terminate", "No events selected");
85  return;
86  }
87  fdNdy = static_cast<TH1*>(GetOutputObject("dNdy", TH1::Class()));
88  if (!fdNdy) {
89  SetStatus(-1);
90  Warning("Terminate", "No dN/deta histogram found");
91  return;
92  }
93  Printf("A total of %ld events", fOK);
94  TH1* copy = static_cast<TH1*>(fdNdy->Clone("before"));
95  fOutput->Add(copy);
96 
97  fdNdy->Scale(1. / fOK, "width");
98  fdNdy->Draw();
99  SetStatus(0);
100  }
107  {
108  TObject* m1 = new TNamed("dNdy", "");
109  m1->SetUniqueID(0x8); // Scale
110 
111  TList* ret = new TList;
112  ret->Add(m1);
113 
114  return ret;
115  }
116  ClassDef(Base,1);
117  };
118 
119  //====================================================================
124  struct NSD : public Base
125  {
132  NSD(Bool_t verbose=false, Int_t monitor=0)
133  : Base(verbose, monitor)
134  {}
142  {
143  if (fHeader->fType & 0x1) return false;
144  return true;
145  }
146  ClassDef(NSD,1);
147  };
148 
149  //====================================================================
154  struct INEL : public Base
155  {
162  INEL(Bool_t verbose=false, Int_t monitor=0)
163  : Base(verbose,monitor)
164  {}
170  virtual Bool_t ProcessHeader() { return true; }
171  ClassDef(INEL,1);
172  };
173 
174  //====================================================================
179  struct INELGt0 : public Base
180  {
187  INELGt0(Bool_t verbose=false, Int_t monitor=0)
188  : Base(verbose,monitor)
189  {}
196  {
197  if (fHeader->fType & 0x4) return true;
198  return false;
199  }
200  ClassDef(INELGt0,1);
201  };
202 
203  //====================================================================
204  struct Cent : public Base
205  {
207  const Long_t fMinEvents;
216  Cent(const char* method="V0M", Bool_t verbose=true, Int_t monitor=0)
217  : Base(verbose,monitor),
218  fHelper(method),
219  fMinEvents(100),
220  fCentBin(0)
221  {
223  }
229  virtual TH1* CreateSingle() { return Base::CreatedNdy(); }
235  virtual void SlaveBegin(TTree* t)
236  {
237  Base::SlaveBegin(t);
238  // We use the parent fdNdy histogram as a cache
239  fdNdy->SetName("cache");
240  fdNdy->SetTitle("Cache");
241 
243  fOutput->ls();
244  }
246  {
247  if (!Base::SetupEstimator()) return false;
248 
250  return true;
251  }
252 
256  virtual void Clear(Option_t* option="")
257  {
258  Base::Clear(option);
259  fdNdy->Reset(); // Clear the cache
260  }
267  {
268  Double_t cent = GetCentrality();
270  fEventMult,
271  fHeader->fB,
273  fHeader->fNbin);
274  return fCentBin >= 0;
275  }
284  virtual void ProcessParticles()
285  {
286  // Check we got a bin
287  if (fCentBin < 0) return;
288 
289  // Find the histogram to update
290  TH1* out = static_cast<TH1*>(fHelper.fCentList->At(fCentBin-1));
291  // If we still have no histogram, return immediately
292  if (!out) return;
293 
294  // Use parent function to fill cache
296  if (fVerbose) {
297  Double_t n0 = fdNdy->GetBinContent(fdNdy->GetNbinsX()/2);
298  Double_t d0 = fdNdy->GetXaxis()->GetBinWidth(fdNdy->GetNbinsX()/2);
299  Double_t y0 = (n0 / d0);
300  Printf("Centrality %6.2f-%6.2f (bin %4d) "
301  "Nch=%8.1f/%4.2f=%8.1f out=%s (%d)",
302  fHelper.fCentAxis->GetBinLowEdge(fCentBin),
303  fHelper.fCentAxis->GetBinUpEdge(fCentBin),
304  fCentBin,
305  n0, d0, y0,
306  out->GetName(),
307  Int_t(out->GetBinContent(0)));
308  }
309 
310  // Make sure we have nothing in the underflow bin.
311  fdNdy->SetBinContent(0,0);
312 
313  // Add our cache to the appropriate bin
314  out->Add(fdNdy);
315  // Increment underflow bin for the event count
316  out->SetBinContent(0, out->GetBinContent(0)+1);
317  }
324  virtual void Terminate()
325  {
326  fOK = GetEventCount();
327  if (fOK <= 0) {
328  SetStatus(-1);
329  Warning("Terminate", "No events selected");
330  return;
331  }
332 
333  if (!fHelper.Finalize(fOutput, fMinEvents))
334  SetStatus(-1);
335  }
342  {
343  TObject* m1 = new TNamed("cent", "hist text30");
344  TObject* m2 = new TNamed("centAcc", "hist text30");
345  TObject* m3 = new TNamed("byCent", "e");
346 
347  m3->SetUniqueID(0x8); // Scale
348  TList* ret = new TList;
349  ret->Add(m1);
350  ret->Add(m2);
351  ret->Add(m3);
352 
353  return ret;
354  }
355  ClassDef(Cent,1);
356  };
357 
358  //====================================================================
364  struct Mult : public Cent
365  {
373  Mult(const char* method="RefMult00d80",
374  Bool_t verbose=false,
375  Int_t monitor=0)
376  : Cent(method, verbose,monitor)
377  {
378  // +1 +2 +3 +3 +5, +5, +5, +5,+10,+10,+10,+10,+10,+10,+10
379  Double_t bins[]={ 0, 3, 6, 9, 14, 19, 24, 29, 39, 49, 59, 69, 79, 89, 99};
380  fHelper.SetCentAxis(14, bins);
381  }
382  ClassDef(Mult,1);
383  };
384 } // End of namespace
385 //====================================================================
386 /*
387  * The function to make our analyser
388  */
390 {
394  dNdyMaker() : FastAnalysis::Maker("dNdy") {}
395 
406  FastAnalysis* Make(const TString& subtype,
407  Int_t monitor,
408  Bool_t verbose,
409  TString& uopt)
410  {
411  TString t(subtype);
412  if (t.EqualTo("INEL")) return new dNdy::INEL(verbose,monitor);
413  else if (t.EqualTo("NSD")) return new dNdy::NSD(verbose,monitor);
414  else if (t.EqualTo("INELGt0")) return new dNdy::INELGt0(verbose,monitor);
415  else if (t.BeginsWith("MULT") || t.BeginsWith("CENT")) {
416  TString w(t(4, t.Length()-4));
417  if (!(w.BeginsWith("RefMult") ||
418  w.BeginsWith("ZNA") ||
419  w.BeginsWith("ZNC") ||
420  w.BeginsWith("ZPA") ||
421  w.BeginsWith("ZPC") ||
422  w.BeginsWith("V0M") ||
423  w.BeginsWith("V0A") ||
424  w.BeginsWith("V0C") ||
425  w.BeginsWith("B") ||
426  w.IsNull())) {
427  Printf("Warning: dNdyMaker::Make: Unknown estimator: %s",
428  w.Data());
429  return 0;
430  }
431  if (t.BeginsWith("MULT"))
432  return new dNdy::Mult(w, verbose, monitor);
433  else
434  return new dNdy::Cent(w, verbose, monitor);
435  }
436  Printf("Error: dNdyMaker::Run: Invalid spec: %s", t.Data());
437  return 0;
438  }
443  void List() const
444  {
445  Printf(" INEL - inelastic");
446  Printf(" INELGt0 - inelastic with at least 1 particle in |eta|<1");
447  Printf(" NSD - Non-single diffractive");
448  Printf(" CENT<est> - Centrality classes. <est> is one of ");
449  Printf(" ZNA - ZNA signal");
450  Printf(" ZNC - ZNC signal");
451  Printf(" ZPA - ZPA signal");
452  Printf(" ZPC - ZPC signal");
453  Printf(" V0M - V0-A + -C");
454  Printf(" V0A - V0-A");
455  Printf(" V0C - V0-C");
456  }
460  const char* Script() const { return __FILE__; }
461 };
462 
463 // ------------------------------------------------------------------
464 // Create instance of maker
466 
467 #ifdef __MAKECINT__
468 #pragma link C++ nestedclasses;
469 #pragma link C++ namespace dNdy;
470 #endif
471 
472 //
473 // EOF
474 //
TObject * GetOutputObject(const char *name, TClass *cls)
Definition: FastAnalysis.C:404
double Double_t
Definition: External.C:58
virtual void Clear(Option_t *option="")
Definition: dNdyAnalysis.C:256
FastShortHeader * fHeader
Definition: FastAnalysis.C:67
virtual Bool_t ProcessHeader()
Definition: dNdyAnalysis.C:141
INELGt0(Bool_t verbose=false, Int_t monitor=0)
Definition: dNdyAnalysis.C:187
virtual Bool_t SetupEstimator()
Definition: FastAnalysis.C:181
virtual Bool_t ProcessHeader()
Definition: dNdyAnalysis.C:170
TH1 * fCentHist
Definition: FastAnalysis.C:81
virtual TList * GetMonitorObjects()
Definition: dNdyAnalysis.C:106
This script defines classes for looping over the data produced by FastSim.C.
virtual Bool_t SetupEstimator()
Definition: dNdyAnalysis.C:245
void CreateHistos(TCollection *output, TH1D *(*callback)())
dNdyMaker * _dNdyMaker
Definition: dNdyAnalysis.C:465
ClassDef(Cent, 1)
virtual void ProcessParticles()
Definition: dNdyAnalysis.C:284
FastCentHelper fHelper
Definition: dNdyAnalysis.C:206
void SetCentAxis(Int_t n, Double_t low, Double_t high)
int Int_t
Definition: External.C:63
Base(Bool_t verbose=false, Int_t monitor=0)
Definition: dNdyAnalysis.C:29
Int_t fCentBin
Definition: dNdyAnalysis.C:208
Int_t method
ClassDef(Mult, 1)
Definition: External.C:212
virtual Bool_t ProcessHeader()
Definition: dNdyAnalysis.C:195
virtual void Terminate()
Definition: dNdyAnalysis.C:79
virtual void SlaveBegin(TTree *)
Definition: dNdyAnalysis.C:55
virtual void SlaveBegin(TTree *t)
Definition: dNdyAnalysis.C:235
static TH1D * CreatedNdy()
Definition: dNdyAnalysis.C:37
Long_t GetEventCount()
Definition: FastAnalysis.C:386
Double_t GetCentrality() const
Definition: FastAnalysis.C:356
virtual void ProcessParticles()
Definition: FastAnalysis.C:475
const char * Script() const
Definition: dNdyAnalysis.C:460
Bool_t fVerbose
Definition: FastAnalysis.C:71
Cent(const char *method="V0M", Bool_t verbose=true, Int_t monitor=0)
Definition: dNdyAnalysis.C:216
ClassDef(INEL, 1)
virtual TList * GetMonitorObjects()
Definition: dNdyAnalysis.C:341
const Long_t fMinEvents
Definition: dNdyAnalysis.C:207
ULong64_t fEventMult
Definition: FastAnalysis.C:77
ClassDef(INELGt0, 1)
ULong_t fOK
Definition: FastAnalysis.C:83
void CreateDiagnostics(TCollection *output, TH1 *centHist)
Bool_t Finalize(TCollection *output, Long_t minEvents)
Mult(const char *method="RefMult00d80", Bool_t verbose=false, Int_t monitor=0)
Definition: dNdyAnalysis.C:373
TH1 * fdNdy
Definition: dNdyAnalysis.C:21
Int_t CheckCentrality(Double_t cent, Double_t mult, Double_t b, Double_t nPart, Double_t nBin)
ClassDef(NSD, 1)
FastAnalysis * Make(const TString &subtype, Int_t monitor, Bool_t verbose, TString &uopt)
Definition: dNdyAnalysis.C:406
virtual void Terminate()
Definition: dNdyAnalysis.C:324
INEL(Bool_t verbose=false, Int_t monitor=0)
Definition: dNdyAnalysis.C:162
const char Option_t
Definition: External.C:48
ClassDef(Base, 1)
bool Bool_t
Definition: External.C:53
virtual Bool_t ProcessParticle(const TParticle *p)
Definition: dNdyAnalysis.C:69
void List() const
Definition: dNdyAnalysis.C:443
Maker(const char *type="")
Definition: FastAnalysis.C:944
TString fCentMethod
Definition: FastAnalysis.C:79
virtual void Fill(Double_t y)
Definition: dNdyAnalysis.C:74
NSD(Bool_t verbose=false, Int_t monitor=0)
Definition: dNdyAnalysis.C:132
Definition: External.C:196
virtual TH1 * CreateSingle()
Definition: dNdyAnalysis.C:229
virtual void Clear(Option_t *option="")
Definition: FastAnalysis.C:460
virtual Bool_t ProcessHeader()
Definition: dNdyAnalysis.C:266