1 #include "AliAnalysisMultPbTrackHistoManager.h"
7 #include "TMCProcess.h"
8 #include "AliMCParticle.h"
15 ClassImp(AliAnalysisMultPbTrackHistoManager)
17 const char * AliAnalysisMultPbTrackHistoManager::kStatStepNames[] = { "All Events", "After physics Selection", "After centrality selection", "With Vertex" };
18 const char * AliAnalysisMultPbTrackHistoManager::kHistoPtEtaVzNames[] = { "hGenPtEtaVz", "hRecPtEtaVz", "hRecPtEtaVzPrim",
19 "hRecPtEtaVzSecWeak", "hRecPtEtaVzSecMaterial", "hRecPtEtaVzFake"};
20 const char * AliAnalysisMultPbTrackHistoManager::kHistoDCANames[] = { "hGenDCA", "hRecDCA", "hRecDCAPrim", "hRecDCASecWeak","hRecDCASecMaterial", "hRecDCAFake"};
21 const char * AliAnalysisMultPbTrackHistoManager::kHistoPrefix[] = { "hGen", "hRec", "hRecPrim", "hRecSecWeak","hRecSecMaterial", "hRecFake"};
22 const char * AliAnalysisMultPbTrackHistoManager::kSpeciesName[] = { "pi+", "K+", "p", "l+", "pi-", "K-", "barp", "l-", "Others"};
25 AliAnalysisMultPbTrackHistoManager::AliAnalysisMultPbTrackHistoManager() : AliHistoListWrapper(), fHNameSuffix(""){
30 AliAnalysisMultPbTrackHistoManager::AliAnalysisMultPbTrackHistoManager(const char * name, const char * title): AliHistoListWrapper(name,title), fHNameSuffix("") {
34 AliAnalysisMultPbTrackHistoManager::AliAnalysisMultPbTrackHistoManager(const AliAnalysisMultPbTrackHistoManager& obj) : AliHistoListWrapper (obj) {
36 AliError("Not Implemented");
39 AliAnalysisMultPbTrackHistoManager::~AliAnalysisMultPbTrackHistoManager() {
44 TH3D * AliAnalysisMultPbTrackHistoManager::GetHistoPtEtaVz(Histo_t id, Int_t particle) {
45 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
47 TString name = kHistoPtEtaVzNames[id];
49 if(particle >= 0) name += kSpeciesName[particle];
51 TH3D * h = (TH3D*) GetHisto(name.Data());
53 h = BookHistoPtEtaVz(name.Data(), Form("Pt Eta Vz distribution (%s)",kHistoPtEtaVzNames[id]));
60 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoDCA(Histo_t id) {
61 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
63 TH1D * h = (TH1D*) GetHisto(kHistoDCANames[id]);
65 h = BookHistoDCA(kHistoDCANames[id], Form("Pt Eta Vz distribution (%s)",kHistoDCANames[id]));
72 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoMult(Histo_t id) {
73 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
75 TString name = kHistoPrefix[id];
77 TH1D * h = (TH1D*) GetHisto(name.Data());
79 h = BookHistoMult(name.Data(), Form("Multiplicity distribution (%s)",kHistoPrefix[id]));
86 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoPt (Histo_t id,
87 Float_t minEta, Float_t maxEta,
88 Float_t minVz, Float_t maxVz,
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)
95 TH3D * h3D = GetHistoPtEtaVz(id);
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
101 Int_t min1 = minEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(minEta);
102 Int_t min2 = minVz < -11111 ? -1 : h3D ->GetZaxis()->FindBin(minVz) ;
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);
110 TString hname = h3D->GetName();
111 hname = hname + "_pt_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
114 if (gROOT->FindObjectAny(hname.Data())){
115 AliError(Form("An object called %s already exists,adding suffix",hname.Data()));
119 TH1D * h = h3D->ProjectionX(hname.Data(), min1, max1, min2, max2, "E");
120 if(scaleWidth) h ->Scale(1.,"width");
127 TH2D * AliAnalysisMultPbTrackHistoManager::GetHistoPtVz (Histo_t id,
128 Float_t minEta, Float_t maxEta,
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)
135 // FIXME: what do I do here for the scaling?
137 TH3D * h3D = GetHistoPtEtaVz(id);
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
142 Int_t min1 = minEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(minEta);
143 Int_t max1 = maxEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
146 TString hname = h3D->GetName();
147 hname = hname + "_ptvz_" + long (min1) + "_" + long(max1);
149 if (gROOT->FindObjectAny(hname.Data())){
150 AliError(Form("An object called %s already exists,adding suffix",hname.Data()));
154 h3D->GetYaxis()->SetRange(min1,max1);
156 TH2D * h = (TH2D*) h3D->Project3D("zxe");
157 if(scaleWidth) h ->Scale(1.,"width");
164 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoVz (Histo_t id,
165 Float_t minPt, Float_t maxPt,
166 Float_t minEta, Float_t maxEta,
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)
173 TH3D * h3D = GetHistoPtEtaVz(id);
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
178 Int_t min1 = minPt < -11111 ? 1 : h3D ->GetXaxis()->FindBin(minPt) ;
179 Int_t min2 = minEta < -11111 ? 1 : h3D ->GetYaxis()->FindBin(minEta);
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);
185 TString hname = h3D->GetName();
186 hname = hname + "_Vz_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
188 if (gROOT->FindObjectAny(hname.Data())){
189 AliError(Form("An object called %s already exists, adding suffix",hname.Data()));
193 TH1D * h = h3D->ProjectionZ(hname.Data(), min1, max1, min2, max2, "E");
194 if(scaleWidth) h ->Scale(1.,"width");
200 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoEta (Histo_t id,
201 Float_t minPt, Float_t maxPt,
202 Float_t minVz, Float_t maxVz,
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)
209 TH3D * h3D = GetHistoPtEtaVz(id);
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
214 Int_t min1 = minPt < -11111 ? 1 : h3D ->GetXaxis()->FindBin(minPt) ;
215 Int_t min2 = minVz < -11111 ? 1 : h3D ->GetYaxis()->FindBin(minVz);
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);
220 TString hname = h3D->GetName();
221 hname = hname + "_Eta_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
223 if (gROOT->FindObjectAny(hname.Data())){
224 AliError(Form("An object called %s already exists, adding suffix",hname.Data()));
228 TH1D * h = h3D->ProjectionY(hname.Data(), min1, max1, min2, max2, "E");
229 if(scaleWidth) h ->Scale(1.,"width");
233 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoProcess(Histo_t id) {
235 // Returns histogram with particle specties
237 TString name = TString(kHistoPrefix[id])+"_Process";
239 TH1D * h = (TH1D*) GetHisto(name);
242 Bool_t oldStatus = TH1::AddDirectoryStatus();
243 TH1::AddDirectory(kFALSE);
245 AliInfo(Form("Booking histo %s",name.Data()));
247 h = new TH1D (name.Data(), Form("Particle production process (%s)",kHistoPrefix[id]), kPNoProcess+1, -0.5, kPNoProcess+1-0.5);
248 Int_t nbin = kPNoProcess+1;
249 for(Int_t ibin = 0; ibin < nbin; ibin++){
250 h->GetXaxis()->SetBinLabel(ibin+1,TMCProcessName[ibin]);
252 TH1::AddDirectory(oldStatus);
263 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoSpecies(Histo_t id) {
265 // Returns histogram with particle specties
267 TString name = TString(kHistoPrefix[id])+"_Species";
269 TH1D * h = (TH1D*) GetHisto(name);
272 Bool_t oldStatus = TH1::AddDirectoryStatus();
273 TH1::AddDirectory(kFALSE);
275 AliInfo(Form("Booking histo %s",name.Data()));
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]);
282 TH1::AddDirectory(oldStatus);
292 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoVzEvent(Histo_t id) {
294 // Returns histogram with Vz of the event
296 TString name = TString(kHistoPrefix[id])+"_VzEvent";
298 TH1D * h = (TH1D*) GetHisto(name);
301 Bool_t oldStatus = TH1::AddDirectoryStatus();
302 TH1::AddDirectory(kFALSE);
304 AliInfo(Form("Booking histo %s",name.Data()));
306 h = new TH1D (name.Data(), Form("Vz of the event (%s)",kHistoPrefix[id]), 10, -10, 10);
308 h->SetXTitle("V_{z}^{event} (cm)");
309 TH1::AddDirectory(oldStatus);
321 TH1I * AliAnalysisMultPbTrackHistoManager::GetHistoStats() {
322 // Returns histogram with event statistiscs (processed events at each step)
324 TH1I * h = (TH1I*) GetHisto("hStats");
325 if (!h) h = BookHistoStats();
332 TH1 * 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);
339 void 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
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()));
348 AliInfo(Form("Scaling %s, nev %2.2f", h->GetName(), nev));
350 h->Scale(1./nev,option);
355 TH3D * AliAnalysisMultPbTrackHistoManager::BookHistoPtEtaVz(const char * name, const char * title) {
356 // Books a 3D histo of Pt/eta/vtx
357 // TODO: make the binning settable, variable binning?
359 Bool_t oldStatus = TH1::AddDirectoryStatus();
360 TH1::AddDirectory(kFALSE);
362 TString hname = name;
365 AliInfo(Form("Booking %s",hname.Data()));
367 // Binning from Jacek task
368 // const Int_t nptbins = 49;
369 // 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};
370 const Int_t nptbins = 68;
371 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};
373 const Int_t netabins=20;
374 Double_t binsEta[netabins+1];
377 Float_t etaStep = (maxEta-minEta)/netabins;
378 for(Int_t ibin = 0; ibin < netabins; ibin++){
379 binsEta[ibin] = minEta + ibin*etaStep;
380 binsEta[ibin+1] = minEta + ibin*etaStep + etaStep;
383 const Int_t nvzbins=10;
384 Double_t binsVz[nvzbins+1];
387 Float_t vzStep = (maxVz-minVz)/nvzbins;
388 for(Int_t ibin = 0; ibin < nvzbins; ibin++){
389 binsVz[ibin] = minVz + ibin*vzStep;
390 binsVz[ibin+1] = minVz + ibin*vzStep + vzStep;
394 TH3D * h = new TH3D (hname,title,
400 h->SetXTitle("p_{T} (GeV)");
401 h->SetYTitle("#eta");
402 h->SetZTitle("V_{z}^{tracks} (cm)");
407 TH1::AddDirectory(oldStatus);
411 TH1D * AliAnalysisMultPbTrackHistoManager::BookHistoDCA(const char * name, const char * title) {
414 Bool_t oldStatus = TH1::AddDirectoryStatus();
415 TH1::AddDirectory(kFALSE);
417 TString hname = name;
420 AliInfo(Form("Booking %s",hname.Data()));
423 TH1D * h = new TH1D (hname,title, 200,0,200);
425 h->SetXTitle("#Delta DCA");
430 TH1::AddDirectory(oldStatus);
433 TH1D * AliAnalysisMultPbTrackHistoManager::BookHistoMult(const char * name, const char * title) {
434 // Books a multiplicity histo
436 Bool_t oldStatus = TH1::AddDirectoryStatus();
437 TH1::AddDirectory(kFALSE);
439 TString hname = name;
442 AliInfo(Form("Booking %s",hname.Data()));
445 TH1D * h = new TH1D (hname,title, 600, 0,6000);
447 h->SetXTitle("N tracks");
452 TH1::AddDirectory(oldStatus);
456 TH1I * AliAnalysisMultPbTrackHistoManager::BookHistoStats() {
457 // Books histogram with event statistiscs (processed events at each step)
459 Bool_t oldStatus = TH1::AddDirectoryStatus();
460 TH1::AddDirectory(kFALSE);
462 AliInfo(Form("Booking Stat histo"));
464 TH1I * h = new TH1I (TString("hStats")+fHNameSuffix, "Number of processed events", kNStatBins, -0.5, kNStatBins-0.5);
465 for(Int_t istatbin = 0; istatbin < kNStatBins; istatbin++){
466 h->GetXaxis()->SetBinLabel(istatbin+1,kStatStepNames[istatbin]);
468 TH1::AddDirectory(oldStatus);
473 Int_t AliAnalysisMultPbTrackHistoManager::GetLocalParticleID(AliMCParticle * part) {
474 // returns the local code (Part_t)
476 Int_t pdgcode = part->PdgCode();