AliPhysics  5e2c166 (5e2c166)
MidNchAnalysis.C
Go to the documentation of this file.
1 #ifndef MIDNCHANALYSIS_C
2 #define MIDNCHANALYSIS_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 <TGraphErrors.h>
11 # include <TProfile.h>
12 #else
13 class TH1;
14 class TH2;
15 class TParticle;
16 class TMap;
17 class TProfile;
18 #endif
19 #include "FastAnalysis.C"
20 #include "FastCentHelper.C"
21 
22 namespace MidNch {
26  struct Base : public FastAnalysis
27  {
29  TProfile* fNpartVsNch;
30  TProfile* fNpartB;
31  TProfile* fMeanNpart;
32  TProfile* fMeanNch;
33 
43  Base(Bool_t verbose=false, Int_t monitor=0)
44  : FastAnalysis(verbose, monitor),
45  fHelper("B"),
46  fNpartVsNch(0),
47  fNpartB(0),
48  fMeanNpart(0),
49  fMeanNch(0),
50  fNch(0),
51  fNpart(0),
52  fCent(-1)
53  {
54  fCentMethod = fHelper.fCentMeth;
55  }
62  {
63  if (!FastAnalysis::SetupEstimator()) return false;
64 
65  fHelper.CreateDiagnostics(fOutput, fCentHist);
66  return true;
67  }
68 
74  virtual TProfile* CreateOutput() = 0;
78  virtual void SlaveBegin(TTree*)
79  {
80  Info("SlaveBegin", "Creating histogram");
81  fNpartVsNch = CreateOutput();
82  fNpartVsNch->SetDirectory(0);
83  fNpartVsNch->SetName("nPartVsnCh");
84  fNpartVsNch->SetXTitle("\\langle N_{\\mathrm{part}}\\rangle");
85  fNpartVsNch->SetYTitle("\\left\\langle\\frac{\\mathrm{d}N_{\\mathrm{ch}}}"
86  "{\\mathrm{d}\\eta}\\right\\rangle");
87  fNpartVsNch->SetMarkerColor(kRed+2);
88  fNpartVsNch->SetMarkerStyle(20);
89  fNpartVsNch->SetFillStyle(1001);
90  fNpartVsNch->SetFillColor(kYellow+1);
91 
92  fNpartB = new TProfile("nPartB", "N_{\\mathrm{part}}\\hbox{ vs. }b",
93  80, 0, 20);
94  fNpartB->SetXTitle("b\\hbox{ (fm)}");
95  fNpartB->SetYTitle("\\langle N_{\\mathrm{part}}\\rangle");
96  fNpartB->SetDirectory(0);
97  fNpartB->SetMarkerColor(kBlue+2);
98  fNpartB->SetMarkerStyle(21);
99 
100  fMeanNpart = 0;
101  fMeanNch = 0;
102  const TAxis& centAxis = (*fHelper.fCentAxis);
103  if (centAxis.GetXbins() && centAxis.GetXbins()->GetArray()) {
104  fMeanNpart = new TProfile("meanNpart", "", centAxis.GetNbins(),
105  centAxis.GetXbins()->GetArray());
106  fMeanNch = new TProfile("meanNch", "", centAxis.GetNbins(),
107  centAxis.GetXbins()->GetArray());
108  }
109  else {
110  fMeanNpart = new TProfile("meanNpart","", centAxis.GetNbins(),
111  centAxis.GetXmin(), centAxis.GetXmax());
112  fMeanNch = new TProfile("meanNch","", centAxis.GetNbins(),
113  centAxis.GetXmin(), centAxis.GetXmax());
114  }
115  fMeanNpart->SetDirectory(0);
116  fMeanNch ->SetDirectory(0);
117  fMeanNpart->SetXTitle("Centrality (%)");
118  fMeanNch ->SetXTitle("Centrality (%)");
119  fMeanNpart->SetXTitle(fNpartVsNch->GetXaxis()->GetTitle());
120  fMeanNch ->SetYTitle(fNpartVsNch->GetYaxis()->GetTitle());
121  fMeanNpart->SetMarkerStyle(20);
122  fMeanNch ->SetMarkerStyle(21);
123  fMeanNpart->SetMarkerColor(kRed +1);
124  fMeanNch ->SetMarkerStyle(kBlue+1);
125  fMeanNpart->SetLineColor(kRed +1);
126  fMeanNch ->SetLineStyle(kBlue+1);
127 
128  fHelper.CreateHistos(fOutput, 0);
129 
130  fOutput->Add(fNpartVsNch);
131  fOutput->Add(fNpartB);
132  fOutput->Add(fMeanNpart);
133  fOutput->Add(fMeanNch);
134  }
139  virtual void Clear(Option_t* option="")
140  {
141  FastAnalysis::Clear(option);
142  fNch = 0;
143  fNpart = 0;
144  }
152  {
153  if (!FastAnalysis::ProcessHeader()) return false;
154  fNpart = fHeader->fNtgt + fHeader->fNproj;
155  fCent = GetCentrality();
156  fNpartB->Fill(fHeader->fB, fNpart);
157  return (fHelper.CheckCentrality(fCent,
158  fEventMult,
159  fHeader->fB,
160  fNpart,
161  fHeader->fNbin) >= 0);
162  }
170  virtual Bool_t ProcessParticle(const TParticle* p)
171  {
172  Double_t pT = p->Pt();
173  Double_t pZ = p->Pz();
174  Double_t theta = TMath::ATan2(pT, pZ);
175  Double_t eta = (pT < 1e-10 ? 1024 : -TMath::Log(TMath::Tan(theta/2)));
176  if (TMath::Abs(eta) > 0.5) return false;
177  fNch++;
178  return true;
179  }
187  virtual Bool_t Process(Long64_t entry)
188  {
189  if (!FastAnalysis::Process(entry)) return false;
190  // Printf("Npart=%4d Nch=%4d", fNpart, fNch);
191 
192  fNpartVsNch->Fill(fNpart, fNch);
193  fMeanNpart ->Fill(fCent, fNpart);
194  fMeanNch ->Fill(fCent, fNch);
195  return true;
196  }
201  virtual void Terminate()
202  {
203  fOK = GetEventCount();
204  if (fOK <= 0) {
205  SetStatus(-1);
206  Warning("Terminate", "No events selected");
207  return;
208  }
209  TClass* pcl = TProfile::Class();
210  fNpartVsNch = static_cast<TProfile*>(GetOutputObject("nPartVsnCh",
211  pcl));
212  fMeanNpart = static_cast<TProfile*>(GetOutputObject("meanNpart",
213  pcl));
214  fMeanNch = static_cast<TProfile*>(GetOutputObject("meanNch",pcl));
215  if (!fNpartVsNch || !fMeanNpart || !fMeanNch) {
216  SetStatus(-1);
217  Warning("Terminate", "No profiles found found (%p,%p,%p)",
218  fNpartVsNch, fMeanNpart, fMeanNch);
219  return;
220  }
221  Printf("A total of %ld events", fOK);
222 
223  TH1* eg = static_cast<TH1*>(GetOutputObject("eg",TH1::Class()));
224 
225  Color_t c = kYellow+1;
226  Style_t s = 1;
227  if (eg) {
228  TString t(eg->GetTitle());
229  t.ToUpper();
230  if (t.Contains("HIJING")) { c = kRed - 3; s = 1; }
231  else if (t.Contains("AMPT")) { c = kBlue - 3; s = 2; }
232  else if (t.Contains("DPMJET")) { c = kMagenta - 3; s = 3; }
233  else if (t.Contains("EPOS-LHC")) { c = kGreen - 3; s = 4; }
234  else if (t.Contains("AMPT2")) { c = kMagenta - 3; s = 3; }
235  else if (t.Contains("KLN")) { c = kBlue - 3; s = 2; }
236  else if (t.Contains("HIJING2")) { c = kRed + 3; s = 1; }
237  else if (t.Contains("ANGANTYR")) { c = kOrange + 3; s = 3; }
238  }
239 
240 #if 0
241  TGraphErrors* res = new TGraphErrors(mNch->GetNbinsX());
242  res->SetName("result");
243  res->SetTitle(Form("%s \\frac{2}{%s}",
244  fNpartVsNch->GetYaxis()->GetTitle(),
245  fNpartVsNch->GetXaxis()->GetTitle()));
246  res->SetMarkerColor(c);
247  res->SetFillColor(c);
248  res->SetFillStyle(1001);
249  res->SetLineColor(c);
250  res->SetLineStyle(s);
251  for (Int_t i = 1; i <= mNch->GetNbinsX(); i++) {
252  Double_t nPart = mNch->GetXaxis()->GetBinCenter(i);
253  Double_t ePart = mNch->GetXaxis()->GetBinWidth(i);
254  Double_t nCh = mNch->GetBinContent(i);
255  Double_t eCh = mNch->GetBinError (i);
256  res->SetPoint (i-1, nPart, nCh/(nPart/2));
257  res->SetPointError(i-1, ePart/2, eCh/(nPart/2));
258  }
259 #endif
260 
261  TGraphErrors* ret = new TGraphErrors(fMeanNpart->GetNbinsX());
262  ret->SetName("resultB");
263  ret->SetTitle(Form("%s \\frac{2}{%s}",
264  fNpartVsNch->GetYaxis()->GetTitle(),
265  fNpartVsNch->GetXaxis()->GetTitle()));
266  ret->SetMarkerColor(c);
267  ret->SetFillColor(c);
268  ret->SetFillStyle(1001);
269  ret->SetLineColor(c);
270  ret->SetLineStyle(s);
271  for (Int_t i = 1; i <= fMeanNpart->GetNbinsX(); i++) {
272  Double_t nPart = fMeanNpart->GetBinContent(i);
273  Double_t ePart = fMeanNpart->GetBinError (i);
274  Double_t nCh = fMeanNch ->GetBinContent(i);
275  Double_t eCh = fMeanNch ->GetBinError (i);
276  Double_t y = nCh/(nPart/2);
277  Double_t ey = y*TMath::Sqrt(TMath::Power(eCh/nCh,2)
278  +TMath::Power(ePart/nPart,2));
279  ret->SetPoint (i-1, nPart, y);
280  ret->SetPointError(i-1, ePart, ey);
281  }
282 
283  ret->Draw("al3");
284  ret->GetHistogram()->SetTitle("");
285  ret->GetHistogram()->SetXTitle(fMeanNpart->GetYaxis()->GetTitle());
286  ret->GetHistogram()->SetYTitle(Form("%s \\frac{2}{%s}",
287  fMeanNch->GetYaxis()->GetTitle(),
288  fMeanNpart->GetYaxis()->GetTitle()));
289 
290  // fOutput->Add(res);
291  fOutput->Add(ret);
292 
293  fHelper.Finalize(fOutput, 0, 0);
294  }
301  {
302  TObject* m1 = new TNamed("nPartVsnCh", "");
303  TObject* m2 = new TNamed("nPartB", "");
304  TObject* m3 = new TNamed("meanNpart", "");
305  TObject* m4 = new TNamed("meanNch", "");
306 
307  TList* ret = new TList;
308  ret->Add(m1);
309  ret->Add(m2);
310  ret->Add(m3);
311  ret->Add(m4);
312 
313  return ret;
314  }
315  ClassDef(Base,1);
316  };
321  struct XeXe : public Base
322  {
323  XeXe(Bool_t verbose=false, Int_t monitor=0)
324  : Base(verbose, monitor)
325  {
326  fTrigMask = 0x0;
327  }
328  virtual TProfile* CreateOutput()
329  {
330  return new TProfile("", "Xe-Xe", 10, 0, 260);
331 #if 0
332 
333  Double_t mid[21] = {
334  245,
335  230,
336  215,
337  200,
338  178,
339  152,
340  129,
341  108,
342  90.1,
343  74.1,
344  60.4,
345  48.5,
346  38.3,
347  29.8,
348  22.7,
349  16.9,
350  12.6,
351  9.37,
352  6.99,
353  5.26,
354  3.45 };
355  TArrayD bins(22);
356  bins[21] = mid[0] + (mid[0]-mid[1])/2;
357  for (size_t i = 1; i < 21; i++)
358  bins[21-i] = mid[i] + (mid[i-1]-mid[i]) / 2;
359  bins[0] = mid[20] - (mid[19]-mid[20]) / 2;
360 
361  return new TH2D("", "Xe-Xe", bins.GetSize()-1, bins.GetArray(),
362  700, 0, 1400);
363 #endif
364  }
365  ClassDef(XeXe,1);
366  };
367 }
368 
373 {
374  MidNchMaker() : FastAnalysis::Maker("MidNch") {}
375  FastAnalysis* Make(const TString& subtype,
376  Int_t monitor,
377  Bool_t verbose,
378  TMap& uopt)
379  {
380  FastAnalysis* ret = 0;
381  TString t(subtype);
382  if (t.EqualTo("XeXe")) ret = new MidNch::XeXe(verbose, monitor);
383 
384  if (ret) {
385  TPair* tp = static_cast<TPair*>(uopt.FindObject("trig"));
386  if( tp) ret->SetTrigger(tp->Value()->GetName());
387  }
388  else
389  Printf("Error: MidNchMaker::Make: Invalid spec: %s", t.Data());
390  return ret;
391 
392  }
393  void List() const
394  {
395  Printf("XeXe - For Xe-Xe collisions at sqrt(sNN)=5.44TeV");
396  }
397  const char* Script() const { return __FILE__; }
398 };
399 
401 
402 #ifdef __MAKECINT__
403 #pragma link C++ nestedclasses;
404 #pragma link C++ namespace MidNch;
405 #endif
406 #endif
407 //
408 // EOF
409 //
TProfile * fMeanNch
virtual TList * GetMonitorObjects()
TObject * GetOutputObject(const char *name, TClass *cls)
Definition: FastAnalysis.C:490
TProfile * fNpartB
double Double_t
Definition: External.C:58
MidNchMaker * _midNchMaker
XeXe(Bool_t verbose=false, Int_t monitor=0)
FastShortHeader * fHeader
Definition: FastAnalysis.C:70
long long Long64_t
Definition: External.C:43
virtual Bool_t SetupEstimator()
Definition: FastAnalysis.C:250
Bool_t Finalize(TCollection *output, Long_t minEvents, TH1 *(*callback)(TObject *, Int_t))
Double_t fCent
TH1 * fCentHist
Definition: FastAnalysis.C:84
This script defines classes for looping over the data produced by FastSim.C.
const char * Script() const
TCanvas * c
Definition: TestFitELoss.C:172
virtual Bool_t Process(Long64_t entry)
virtual Bool_t Process(Long64_t entry)
Definition: FastAnalysis.C:371
Base(Bool_t verbose=false, Int_t monitor=0)
FastCentHelper fHelper
int Int_t
Definition: External.C:63
virtual Bool_t ProcessHeader()
Definition: FastAnalysis.C:638
Definition: External.C:228
TProfile * fNpartVsNch
virtual void Clear(Option_t *option="")
virtual Bool_t ProcessHeader()
void CreateHistos(TCollection *output, TObject *(*callback)())
Long_t GetEventCount()
Definition: FastAnalysis.C:472
Double_t GetCentrality() const
Definition: FastAnalysis.C:442
virtual TProfile * CreateOutput()=0
ULong64_t fEventMult
Definition: FastAnalysis.C:80
ULong_t fOK
Definition: FastAnalysis.C:86
void CreateDiagnostics(TCollection *output, TH1 *centHist)
Definition: External.C:220
void List() const
Int_t CheckCentrality(Double_t cent, Double_t mult, Double_t b, Double_t nPart, Double_t nBin)
FastAnalysis * Make(const TString &subtype, Int_t monitor, Bool_t verbose, TMap &uopt)
virtual Bool_t ProcessParticle(const TParticle *p)
virtual TProfile * CreateOutput()
const char Option_t
Definition: External.C:48
virtual Bool_t SetupEstimator()
bool Bool_t
Definition: External.C:53
void SetTrigger(UInt_t mask)
Definition: FastAnalysis.C:125
virtual void SlaveBegin(TTree *)
UInt_t fTrigMask
Definition: FastAnalysis.C:90
TProfile * fMeanNpart
TString fCentMethod
Definition: FastAnalysis.C:82
virtual void Terminate()
Definition: External.C:196
virtual void Clear(Option_t *option="")
Definition: FastAnalysis.C:546