]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/multPbPb/AliAnalysisMultPbTrackHistoManager.cxx
correct.C
[u/mrichter/AliRoot.git] / PWG0 / multPbPb / AliAnalysisMultPbTrackHistoManager.cxx
CommitLineData
a23f7c97 1#include "AliAnalysisMultPbTrackHistoManager.h"
2#include "AliLog.h"
3#include "TH1.h"
4#include "TH3D.h"
5#include "TH1I.h"
6#include "TROOT.h"
e0376287 7#include "TMCProcess.h"
3b8cbf2d 8#include "AliMCParticle.h"
e0376287 9
a23f7c97 10#include <iostream>
aa6151eb 11#include "TH2D.h"
3b8cbf2d 12
a23f7c97 13using namespace std;
3b8cbf2d 14
a23f7c97 15ClassImp(AliAnalysisMultPbTrackHistoManager)
16
9441cdaa 17const char * AliAnalysisMultPbTrackHistoManager::kStatStepNames[] = { "All Events", "After centrality selection", "After physics Selection", "With Vertex" };
a23f7c97 18const char * AliAnalysisMultPbTrackHistoManager::kHistoPtEtaVzNames[] = { "hGenPtEtaVz", "hRecPtEtaVz", "hRecPtEtaVzPrim",
19 "hRecPtEtaVzSecWeak", "hRecPtEtaVzSecMaterial", "hRecPtEtaVzFake"};
20const char * AliAnalysisMultPbTrackHistoManager::kHistoDCANames[] = { "hGenDCA", "hRecDCA", "hRecDCAPrim", "hRecDCASecWeak","hRecDCASecMaterial", "hRecDCAFake"};
e0376287 21const char * AliAnalysisMultPbTrackHistoManager::kHistoPrefix[] = { "hGen", "hRec", "hRecPrim", "hRecSecWeak","hRecSecMaterial", "hRecFake"};
4d0aa70f 22const char * AliAnalysisMultPbTrackHistoManager::kSpeciesName[] = { "pi+", "K+", "p", "l+", "pi-", "K-", "barp", "l-", "Others"};
a23f7c97 23
24
25AliAnalysisMultPbTrackHistoManager::AliAnalysisMultPbTrackHistoManager() : AliHistoListWrapper(), fHNameSuffix(""){
26 // standard ctor
27
28}
29
30AliAnalysisMultPbTrackHistoManager::AliAnalysisMultPbTrackHistoManager(const char * name, const char * title): AliHistoListWrapper(name,title), fHNameSuffix("") {
31 //named ctor
32};
33
34AliAnalysisMultPbTrackHistoManager::AliAnalysisMultPbTrackHistoManager(const AliAnalysisMultPbTrackHistoManager& obj) : AliHistoListWrapper (obj) {
35 // copy ctor
36 AliError("Not Implemented");
37};
38
39AliAnalysisMultPbTrackHistoManager::~AliAnalysisMultPbTrackHistoManager() {
40 // dtor
41
42}
43
4d0aa70f 44TH3D * AliAnalysisMultPbTrackHistoManager::GetHistoPtEtaVz(Histo_t id, Int_t particle) {
a23f7c97 45 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
46
4d0aa70f 47 TString name = kHistoPtEtaVzNames[id];
48
49 if(particle >= 0) name += kSpeciesName[particle];
50
51 TH3D * h = (TH3D*) GetHisto(name.Data());
a23f7c97 52 if (!h) {
4d0aa70f 53 h = BookHistoPtEtaVz(name.Data(), Form("Pt Eta Vz distribution (%s)",kHistoPtEtaVzNames[id]));
a23f7c97 54 }
55
56 return h;
57
58}
59
60TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoDCA(Histo_t id) {
61 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
62
63 TH1D * h = (TH1D*) GetHisto(kHistoDCANames[id]);
64 if (!h) {
65 h = BookHistoDCA(kHistoDCANames[id], Form("Pt Eta Vz distribution (%s)",kHistoDCANames[id]));
66 }
67
68 return h;
69
70}
71
e0376287 72TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoMult(Histo_t id) {
73 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
74
75 TString name = kHistoPrefix[id];
76 name += "Mult";
77 TH1D * h = (TH1D*) GetHisto(name.Data());
78 if (!h) {
79 h = BookHistoMult(name.Data(), Form("Multiplicity distribution (%s)",kHistoPrefix[id]));
80 }
81
82 return h;
83
84}
85
a23f7c97 86TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoPt (Histo_t id,
87 Float_t minEta, Float_t maxEta,
88 Float_t minVz, Float_t maxVz,
89 Bool_t scaleWidth) {
90 // Returns a projection of the 3D histo pt/eta/vz.
91 // WARNING: since that is a histo, the requested range will be discretized to the binning.
92 // Always avoids under (over) flows
93 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
94
95 TH3D * h3D = GetHistoPtEtaVz(id);
96
97 // Get range in terms of bin numners. If the float range is
98 // less than -11111 take the range from the first to the last bin (i.e. no
99 // under/over-flows)
4d0aa70f 100 // FIXME: UNDERFLOWS
101 Int_t min1 = minEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(minEta);
102 Int_t min2 = minVz < -11111 ? -1 : h3D ->GetZaxis()->FindBin(minVz) ;
a23f7c97 103
4d0aa70f 104 // Int_t max1 = maxEta < -11111 ? h3D->GetNbinsY() : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
105 // Int_t max2 = maxVz < -11111 ? h3D->GetNbinsZ() : h3D ->GetZaxis()->FindBin(maxVz -0.00001);
106 Int_t max1 = maxEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
107 Int_t max2 = maxVz < -11111 ? -1 : h3D ->GetZaxis()->FindBin(maxVz -0.00001);
a23f7c97 108
109
110 TString hname = h3D->GetName();
111 hname = hname + "_pt_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
112
113
114 if (gROOT->FindObjectAny(hname.Data())){
e0376287 115 AliError(Form("An object called %s already exists,adding suffix",hname.Data()));
116 hname += "_2";
a23f7c97 117 }
118
119 TH1D * h = h3D->ProjectionX(hname.Data(), min1, max1, min2, max2, "E");
120 if(scaleWidth) h ->Scale(1.,"width");
121
122 return h;
123
124}
125
aa6151eb 126
127TH2D * AliAnalysisMultPbTrackHistoManager::GetHistoPtVz (Histo_t id,
128 Float_t minEta, Float_t maxEta,
129 Bool_t scaleWidth) {
130 // Returns a projection of the 3D histo pt/eta/vz.
131 // WARNING: since that is a histo, the requested range will be discretized to the binning.
132 // Always avoids under (over) flows
133 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
134
135 // FIXME: what do I do here for the scaling?
136
137 TH3D * h3D = GetHistoPtEtaVz(id);
138
139 // Get range in terms of bin numners. If the float range is
140 // less than -11111 take the range from the first to the last bin (i.e. no
141 // under/over-flows)
142 Int_t min1 = minEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(minEta);
143 Int_t max1 = maxEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
144
145
146 TString hname = h3D->GetName();
147 hname = hname + "_ptvz_" + long (min1) + "_" + long(max1);
148
149 if (gROOT->FindObjectAny(hname.Data())){
150 AliError(Form("An object called %s already exists,adding suffix",hname.Data()));
151 hname += "_2";
152 }
153
154 h3D->GetYaxis()->SetRange(min1,max1);
155
156 TH2D * h = (TH2D*) h3D->Project3D("zxe");
157 if(scaleWidth) h ->Scale(1.,"width");
158
159 return h;
160
161}
162
163
a23f7c97 164TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoVz (Histo_t id,
165 Float_t minPt, Float_t maxPt,
166 Float_t minEta, Float_t maxEta,
167 Bool_t scaleWidth) {
168 // Returns a projection of the 3D histo pt/eta/vz.
169 // WARNING: since that is a histo, the requested range will be discretized to the binning.
170 // Always avoids under (over) flows
171 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
172
173 TH3D * h3D = GetHistoPtEtaVz(id);
174
175 // Get range in terms of bin numners. If the float range is
176 // less than -11111 take the range from the first to the last bin (i.e. no
177 // under/over-flows)
178 Int_t min1 = minPt < -11111 ? 1 : h3D ->GetXaxis()->FindBin(minPt) ;
179 Int_t min2 = minEta < -11111 ? 1 : h3D ->GetYaxis()->FindBin(minEta);
180
181 Int_t max1 = maxPt < -11111 ? h3D->GetNbinsX() : h3D ->GetXaxis()->FindBin(maxPt -0.00001);
182 Int_t max2 = maxEta < -11111 ? h3D->GetNbinsY() : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
183
184
185 TString hname = h3D->GetName();
186 hname = hname + "_Vz_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
187
188 if (gROOT->FindObjectAny(hname.Data())){
e0376287 189 AliError(Form("An object called %s already exists, adding suffix",hname.Data()));
190 hname+="_2";
a23f7c97 191 }
192
193 TH1D * h = h3D->ProjectionZ(hname.Data(), min1, max1, min2, max2, "E");
194 if(scaleWidth) h ->Scale(1.,"width");
195 return h;
196
197
198}
199
200TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoEta (Histo_t id,
201 Float_t minPt, Float_t maxPt,
202 Float_t minVz, Float_t maxVz,
203 Bool_t scaleWidth) {
204 // Returns a projection of the 3D histo pt/eta/vz.
205 // WARNING: since that is a histo, the requested range will be discretized to the binning.
206 // Always avoids under (over) flows
207 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
208
209 TH3D * h3D = GetHistoPtEtaVz(id);
210
211 // Get range in terms of bin numners. If the float range is
212 // less than -11111 take the range from the first to the last bin (i.e. no
213 // under/over-flows)
214 Int_t min1 = minPt < -11111 ? 1 : h3D ->GetXaxis()->FindBin(minPt) ;
215 Int_t min2 = minVz < -11111 ? 1 : h3D ->GetYaxis()->FindBin(minVz);
216
217 Int_t max1 = maxPt < -11111 ? h3D->GetNbinsX() : h3D ->GetXaxis()->FindBin(maxPt -0.00001);
218 Int_t max2 = maxVz < -11111 ? h3D->GetNbinsY() : h3D ->GetYaxis()->FindBin(maxVz-0.00001);
219
220 TString hname = h3D->GetName();
221 hname = hname + "_Eta_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
222
223 if (gROOT->FindObjectAny(hname.Data())){
e0376287 224 AliError(Form("An object called %s already exists, adding suffix",hname.Data()));
225 hname+="_2";
a23f7c97 226 }
227
228 TH1D * h = h3D->ProjectionY(hname.Data(), min1, max1, min2, max2, "E");
229 if(scaleWidth) h ->Scale(1.,"width");
230 return h;
231}
232
3b8cbf2d 233TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoProcess(Histo_t id) {
e0376287 234
235 // Returns histogram with particle specties
236
3b8cbf2d 237 TString name = TString(kHistoPrefix[id])+"_Process";
e0376287 238
239 TH1D * h = (TH1D*) GetHisto(name);
240 if (!h) {
241 name+=fHNameSuffix;
242 Bool_t oldStatus = TH1::AddDirectoryStatus();
243 TH1::AddDirectory(kFALSE);
244
245 AliInfo(Form("Booking histo %s",name.Data()));
246
3b8cbf2d 247 h = new TH1D (name.Data(), Form("Particle production process (%s)",kHistoPrefix[id]), kPNoProcess+1, -0.5, kPNoProcess+1-0.5);
e0376287 248 Int_t nbin = kPNoProcess+1;
249 for(Int_t ibin = 0; ibin < nbin; ibin++){
250 h->GetXaxis()->SetBinLabel(ibin+1,TMCProcessName[ibin]);
251 }
252 TH1::AddDirectory(oldStatus);
253 fList->Add(h);
254
255
256 }
257 return h;
258
259
260}
261
262
3b8cbf2d 263TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoSpecies(Histo_t id) {
264
265 // Returns histogram with particle specties
266
267 TString name = TString(kHistoPrefix[id])+"_Species";
268
269 TH1D * h = (TH1D*) GetHisto(name);
270 if (!h) {
271 name+=fHNameSuffix;
272 Bool_t oldStatus = TH1::AddDirectoryStatus();
273 TH1::AddDirectory(kFALSE);
274
275 AliInfo(Form("Booking histo %s",name.Data()));
276
277 h = new TH1D (name.Data(), Form("Particle species (%s)",kHistoPrefix[id]), kNPart+1, -0.5, kNPart+1-0.5);
278 Int_t nbin = kNPart+1;
279 for(Int_t ibin = 0; ibin < nbin; ibin++){
280 h->GetXaxis()->SetBinLabel(ibin+1,kSpeciesName[ibin]);
281 }
282 TH1::AddDirectory(oldStatus);
283 fList->Add(h);
284
285
286 }
287 return h;
288
289
290}
291
4d0aa70f 292TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoVzEvent(Histo_t id) {
293
294 // Returns histogram with Vz of the event
295
296 TString name = TString(kHistoPrefix[id])+"_VzEvent";
297
298 TH1D * h = (TH1D*) GetHisto(name);
299 if (!h) {
300 name+=fHNameSuffix;
301 Bool_t oldStatus = TH1::AddDirectoryStatus();
302 TH1::AddDirectory(kFALSE);
303
304 AliInfo(Form("Booking histo %s",name.Data()));
305
306 h = new TH1D (name.Data(), Form("Vz of the event (%s)",kHistoPrefix[id]), 10, -10, 10);
307 h->Sumw2();
308 h->SetXTitle("V_{z}^{event} (cm)");
309 TH1::AddDirectory(oldStatus);
310 fList->Add(h);
311
312
313 }
314 return h;
315
316
317}
318
3b8cbf2d 319
a23f7c97 320
321TH1I * AliAnalysisMultPbTrackHistoManager::GetHistoStats() {
322 // Returns histogram with event statistiscs (processed events at each step)
323
324 TH1I * h = (TH1I*) GetHisto("hStats");
325 if (!h) h = BookHistoStats();
326 return h;
327
328}
329
330
331
332TH1 * AliAnalysisMultPbTrackHistoManager::GetHisto(const char * name) {
333 //Search list for histo
334 // TODO: keep track of histo id rather than searching by name?
335 return (TH1*) fList->FindObject(TString(name)+fHNameSuffix);
336
337}
338
339void AliAnalysisMultPbTrackHistoManager::ScaleHistos(Double_t nev, Option_t * option) {
340 // Scales all histos in the list for nev
341 // option can be used to pass further options to TH1::Scale
342 TH1 * h = 0;
343 TIter iter = fList->MakeIterator();
344 while ((h = (TH1*) iter.Next())) {
345 if (!h->InheritsFrom("TH1")) {
346 AliFatal (Form("%s does not inherits from TH1, cannot scale",h->GetName()));
347 }
9441cdaa 348 if (h->InheritsFrom("TH1I")) {
349 AliInfo (Form("Not scaling integer histo %s",h->GetName()));
350 continue;
351 }
e0376287 352 AliInfo(Form("Scaling %s, nev %2.2f", h->GetName(), nev));
a23f7c97 353
354 h->Scale(1./nev,option);
355 }
356
357}
358
359TH3D * AliAnalysisMultPbTrackHistoManager::BookHistoPtEtaVz(const char * name, const char * title) {
360 // Books a 3D histo of Pt/eta/vtx
361 // TODO: make the binning settable, variable binning?
362
363 Bool_t oldStatus = TH1::AddDirectoryStatus();
364 TH1::AddDirectory(kFALSE);
365
366 TString hname = name;
367 hname+=fHNameSuffix;
368
369 AliInfo(Form("Booking %s",hname.Data()));
370
e0376287 371 // Binning from Jacek task
eef42d18 372 // const Int_t nptbins = 49;
373 // const Double_t binsPt[] = {0.,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,4.5,5.0,5.5,6.0,6.5,7.0,8.0,9.0,10.0};//,11.0,12.0,13.0,14.0,15.0,16.0,18.0,20.0,22.0,24.0,26.0,28.0,30.0,32.0,34.0,36.0,40.0,45.0,50.0};
e0376287 374 const Int_t nptbins = 68;
375 const Double_t binsPt[] = {0.,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.2,2.4,2.6,2.8,3.0,3.2,3.4,3.6,3.8,4.0,4.5,5.0,5.5,6.0,6.5,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,18.0,20.0,22.0,24.0,26.0,28.0,30.0,32.0,34.0,36.0,40.0,45.0,50.0};
376
377 const Int_t netabins=20;
378 Double_t binsEta[netabins+1];
379 Float_t minEta = -1;
380 Float_t maxEta = 1;
381 Float_t etaStep = (maxEta-minEta)/netabins;
382 for(Int_t ibin = 0; ibin < netabins; ibin++){
383 binsEta[ibin] = minEta + ibin*etaStep;
384 binsEta[ibin+1] = minEta + ibin*etaStep + etaStep;
385 }
386
387 const Int_t nvzbins=10;
388 Double_t binsVz[nvzbins+1];
389 Float_t minVz = -10;
390 Float_t maxVz = 10;
391 Float_t vzStep = (maxVz-minVz)/nvzbins;
392 for(Int_t ibin = 0; ibin < nvzbins; ibin++){
393 binsVz[ibin] = minVz + ibin*vzStep;
394 binsVz[ibin+1] = minVz + ibin*vzStep + vzStep;
395 }
396
a23f7c97 397
398 TH3D * h = new TH3D (hname,title,
e0376287 399 nptbins, binsPt,
400 netabins, binsEta,
401 nvzbins, binsVz
a23f7c97 402 );
403
4d0aa70f 404 h->SetXTitle("p_{T} (GeV)");
e0376287 405 h->SetYTitle("#eta");
4d0aa70f 406 h->SetZTitle("V_{z}^{tracks} (cm)");
a23f7c97 407 h->Sumw2();
408
409 fList->Add(h);
410
411 TH1::AddDirectory(oldStatus);
412 return h;
413}
414
415TH1D * AliAnalysisMultPbTrackHistoManager::BookHistoDCA(const char * name, const char * title) {
416 // Books a DCA histo
417
418 Bool_t oldStatus = TH1::AddDirectoryStatus();
419 TH1::AddDirectory(kFALSE);
420
421 TString hname = name;
422 hname+=fHNameSuffix;
423
424 AliInfo(Form("Booking %s",hname.Data()));
425
426
54b31d6a 427 TH1D * h = new TH1D (hname,title, 200,0,200);
a23f7c97 428
429 h->SetXTitle("#Delta DCA");
430 h->Sumw2();
431
432 fList->Add(h);
433
434 TH1::AddDirectory(oldStatus);
435 return h;
436}
e0376287 437TH1D * AliAnalysisMultPbTrackHistoManager::BookHistoMult(const char * name, const char * title) {
438 // Books a multiplicity histo
439
440 Bool_t oldStatus = TH1::AddDirectoryStatus();
441 TH1::AddDirectory(kFALSE);
442
443 TString hname = name;
444 hname+=fHNameSuffix;
445
446 AliInfo(Form("Booking %s",hname.Data()));
447
448
449 TH1D * h = new TH1D (hname,title, 600, 0,6000);
450
451 h->SetXTitle("N tracks");
452 h->Sumw2();
453
454 fList->Add(h);
455
456 TH1::AddDirectory(oldStatus);
457 return h;
458}
a23f7c97 459
460TH1I * AliAnalysisMultPbTrackHistoManager::BookHistoStats() {
461 // Books histogram with event statistiscs (processed events at each step)
462
463 Bool_t oldStatus = TH1::AddDirectoryStatus();
464 TH1::AddDirectory(kFALSE);
465
466 AliInfo(Form("Booking Stat histo"));
467
468 TH1I * h = new TH1I (TString("hStats")+fHNameSuffix, "Number of processed events", kNStatBins, -0.5, kNStatBins-0.5);
469 for(Int_t istatbin = 0; istatbin < kNStatBins; istatbin++){
470 h->GetXaxis()->SetBinLabel(istatbin+1,kStatStepNames[istatbin]);
471 }
472 TH1::AddDirectory(oldStatus);
473 fList->Add(h);
474 return h;
475}
476
3b8cbf2d 477Int_t AliAnalysisMultPbTrackHistoManager::GetLocalParticleID(AliMCParticle * part) {
478 // returns the local code (Part_t)
479
480 Int_t pdgcode = part->PdgCode();
481 switch(pdgcode) {
482
483 case 211:
484 return kPartPiPlus;
485 break;
486 case -211:
487 return kPartPiMinus;
488 break;
489 case 2212:
490 return kPartP;
491 break;
492 case -2212:
493 return kPartPBar;
494 break;
495 case 321:
496 return kPartKPlus;
497 break;
498 case -321:
499 return kPartKMinus;
500 break;
501 case -11:
502 return kPartLMinus;
503 break;
504 case 11:
505 return kPartLPlus;
506 break;
507 case -13:
508 return kPartLMinus;
509 break;
510 case 13:
511 return kPartLPlus;
512 break;
513 default:
514 return kPartOther;
515 }
516}
a23f7c97 517
518
519