1 #include "AliAnalysisMultPbTrackHistoManager.h"
7 #include "TMCProcess.h"
8 #include "AliMCParticle.h"
12 #include "TDatabasePDG.h"
13 #include "TParameter.h"
17 ClassImp(AliAnalysisMultPbTrackHistoManager)
19 const char * AliAnalysisMultPbTrackHistoManager::kStatStepNames[] = { "All Events", "After centrality selection", "After physics Selection", "With Vertex (quality cuts)", "After ZDC cut", "After vertex range cut (10 cm)" };
20 const char * AliAnalysisMultPbTrackHistoManager::kHistoPtEtaVzNames[] = { "hGenPtEtaVz", "hRecPtEtaVz", "hRecPtEtaVzPrim",
21 "hRecPtEtaVzSecWeak", "hRecPtEtaVzSecMaterial", "hRecPtEtaVzFake"};
22 const char * AliAnalysisMultPbTrackHistoManager::kHistoDCANames[] = { "hGenDCA", "hRecDCA", "hRecDCAPrim", "hRecDCASecWeak","hRecDCASecMaterial", "hRecDCAFake"};
23 const char * AliAnalysisMultPbTrackHistoManager::kHistoPrefix[] = { "hGen", "hRec", "hRecPrim", "hRecSecWeak","hRecSecMaterial", "hRecFake", "hRecHighestMeanPt", "hRecLowestMeanPt"};
24 const char * AliAnalysisMultPbTrackHistoManager::kSpeciesName[] = { "pi+", "K+", "p", "l+", "pi-", "K-", "barp", "l-", "Others"};
27 AliAnalysisMultPbTrackHistoManager::AliAnalysisMultPbTrackHistoManager() : AliHistoListWrapper(), fHNameSuffix(""), fParticleSpecies(0){
32 AliAnalysisMultPbTrackHistoManager::AliAnalysisMultPbTrackHistoManager(const char * name, const char * title): AliHistoListWrapper(name,title), fHNameSuffix(""), fParticleSpecies(0) {
36 AliAnalysisMultPbTrackHistoManager::AliAnalysisMultPbTrackHistoManager(const AliAnalysisMultPbTrackHistoManager& obj) : AliHistoListWrapper (obj) {
38 AliError("Not Implemented");
41 AliAnalysisMultPbTrackHistoManager::~AliAnalysisMultPbTrackHistoManager() {
46 TH2D * AliAnalysisMultPbTrackHistoManager::GetHistoElectronCutQA() {
47 // Get a p vs dE/dx plot, to check the histos we are rejecting
48 TString name = "histoElectronCutQA";
50 TH2D * h = (TH2D*) GetHisto(name);
53 AliInfo(Form("Booking %s", (name+fHNameSuffix).Data()));
54 Bool_t oldStatus = TH1::AddDirectoryStatus();
55 TH1::AddDirectory(kFALSE);
56 h = new TH2D (name+fHNameSuffix, name+fHNameSuffix, 100, 0, 3, 50, 0, 200);
58 TH1::AddDirectory(oldStatus);
66 TH3D * AliAnalysisMultPbTrackHistoManager::GetHistoPtEtaVz(Histo_t id, Int_t particle) {
67 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
69 TString name = kHistoPtEtaVzNames[id];
71 if(particle >= 0) name += kSpeciesName[particle];
73 TH3D * h = (TH3D*) GetHisto(name.Data());
75 h = BookHistoPtEtaVz(name.Data(), Form("Pt Eta Vz distribution (%s)",kHistoPtEtaVzNames[id]));
82 TH2D * AliAnalysisMultPbTrackHistoManager::GetHistoDCA(Histo_t id) {
83 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
85 TH2D * h = (TH2D*) GetHisto(kHistoDCANames[id]);
87 h = BookHistoDCA(kHistoDCANames[id], Form("DCA vs pt distribution (%s)",kHistoDCANames[id]));
94 TH2D * AliAnalysisMultPbTrackHistoManager::GetHistoV0vsNtracks(Histo_t id) {
95 // Returns a histo of V0 vs ntracks
98 TString name = TString(kHistoPrefix[id])+"_V0vsNtracks";
100 TH2D * h = (TH2D*) GetHisto(name);
103 Bool_t oldStatus = TH1::AddDirectoryStatus();
104 TH1::AddDirectory(kFALSE);
106 AliInfo(Form("Booking histo %s",name.Data()));
108 h = new TH2D (name.Data(), Form("V0 vs Ntracks (%s)",kHistoPrefix[id]), 300,0,3000, 300, 0, 20000);
109 h->SetXTitle("N_{Tracks}");
110 h->SetYTitle("V0 Amplitude");
111 TH1::AddDirectory(oldStatus);
122 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoMult(Histo_t id) {
123 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
125 TString name = kHistoPrefix[id];
127 TH1D * h = (TH1D*) GetHisto(name.Data());
129 h = BookHistoMult(name.Data(), Form("Multiplicity distribution (%s)",kHistoPrefix[id]));
136 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoPt (Histo_t id,
137 Float_t minEta, Float_t maxEta,
138 Float_t minVz, Float_t maxVz,
140 // Returns a projection of the 3D histo pt/eta/vz.
141 // WARNING: since that is a histo, the requested range will be discretized to the binning.
142 // Always avoids under (over) flows
143 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
145 TH3D * h3D = GetHistoPtEtaVz(id);
147 // Get range in terms of bin numners. If the float range is
148 // less than -11111 take the range from the first to the last bin (i.e. no
151 Int_t min1 = minEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(minEta);
152 Int_t min2 = minVz < -11111 ? -1 : h3D ->GetZaxis()->FindBin(minVz) ;
154 Int_t max1 = maxEta < -11111 ? h3D->GetNbinsY() : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
155 Int_t max2 = maxVz < -11111 ? h3D->GetNbinsZ() : h3D ->GetZaxis()->FindBin(maxVz -0.00001);
156 // Int_t max1 = maxEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
157 // Int_t max2 = maxVz < -11111 ? -1 : h3D ->GetZaxis()->FindBin(maxVz -0.00001);
160 TString hname = h3D->GetName();
161 hname = hname + "_pt_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
164 if (gROOT->FindObjectAny(hname.Data())){
165 AliError(Form("An object called %s already exists,adding suffix",hname.Data()));
169 TH1D * h = h3D->ProjectionX(hname.Data(), min1, max1, min2, max2, "E");
170 if(scaleWidth) h ->Scale(1.,"width");
177 TH2D * AliAnalysisMultPbTrackHistoManager::GetHistoPtVz (Histo_t id,
178 Float_t minEta, Float_t maxEta,
180 // Returns a projection of the 3D histo pt/eta/vz.
181 // WARNING: since that is a histo, the requested range will be discretized to the binning.
182 // Always avoids under (over) flows
183 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
185 // FIXME: what do I do here for the scaling?
187 TH3D * h3D = GetHistoPtEtaVz(id);
189 // Get range in terms of bin numners. If the float range is
190 // less than -11111 take the range from the first to the last bin (i.e. no
192 Int_t min1 = minEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(minEta);
193 Int_t max1 = maxEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
196 TString hname = h3D->GetName();
197 hname = hname + "_ptvz_" + long (min1) + "_" + long(max1);
199 if (gROOT->FindObjectAny(hname.Data())){
200 AliError(Form("An object called %s already exists,adding suffix",hname.Data()));
204 h3D->GetYaxis()->SetRange(min1,max1);
206 TH2D * h = (TH2D*) h3D->Project3D("zxe");
207 if(scaleWidth) h ->Scale(1.,"width");
214 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoVz (Histo_t id,
215 Float_t minPt, Float_t maxPt,
216 Float_t minEta, Float_t maxEta,
218 // Returns a projection of the 3D histo pt/eta/vz.
219 // WARNING: since that is a histo, the requested range will be discretized to the binning.
220 // Always avoids under (over) flows
221 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
223 TH3D * h3D = GetHistoPtEtaVz(id);
225 // Get range in terms of bin numners. If the float range is
226 // less than -11111 take the range from the first to the last bin (i.e. no
228 Int_t min1 = minPt < -11111 ? 1 : h3D ->GetXaxis()->FindBin(minPt) ;
229 Int_t min2 = minEta < -11111 ? 1 : h3D ->GetYaxis()->FindBin(minEta);
231 Int_t max1 = maxPt < -11111 ? h3D->GetNbinsX() : h3D ->GetXaxis()->FindBin(maxPt -0.00001);
232 Int_t max2 = maxEta < -11111 ? h3D->GetNbinsY() : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
235 TString hname = h3D->GetName();
236 hname = hname + "_Vz_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
238 if (gROOT->FindObjectAny(hname.Data())){
239 AliError(Form("An object called %s already exists, adding suffix",hname.Data()));
243 TH1D * h = h3D->ProjectionZ(hname.Data(), min1, max1, min2, max2, "E");
244 if(scaleWidth) h ->Scale(1.,"width");
250 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoEta (Histo_t id,
251 Float_t minPt, Float_t maxPt,
252 Float_t minVz, Float_t maxVz,
254 // Returns a projection of the 3D histo pt/eta/vz.
255 // WARNING: since that is a histo, the requested range will be discretized to the binning.
256 // Always avoids under (over) flows
257 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
259 TH3D * h3D = GetHistoPtEtaVz(id);
261 // Get range in terms of bin numners. If the float range is
262 // less than -11111 take the range from the first to the last bin (i.e. no
264 Int_t min1 = minPt < -11111 ? 1 : h3D ->GetXaxis()->FindBin(minPt) ;
265 Int_t min2 = minVz < -11111 ? 1 : h3D ->GetYaxis()->FindBin(minVz);
267 Int_t max1 = maxPt < -11111 ? h3D->GetNbinsX() : h3D ->GetXaxis()->FindBin(maxPt -0.00001);
268 Int_t max2 = maxVz < -11111 ? h3D->GetNbinsY() : h3D ->GetYaxis()->FindBin(maxVz-0.00001);
270 TString hname = h3D->GetName();
271 hname = hname + "_Eta_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
273 if (gROOT->FindObjectAny(hname.Data())){
274 AliError(Form("An object called %s already exists, adding suffix",hname.Data()));
278 TH1D * h = h3D->ProjectionY(hname.Data(), min1, max1, min2, max2, "E");
279 if(scaleWidth) h ->Scale(1.,"width");
283 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoProcess(Histo_t id) {
285 // Returns histogram with particle specties
287 TString name = TString(kHistoPrefix[id])+"_Process";
289 TH1D * h = (TH1D*) GetHisto(name);
292 Bool_t oldStatus = TH1::AddDirectoryStatus();
293 TH1::AddDirectory(kFALSE);
295 AliInfo(Form("Booking histo %s",name.Data()));
297 h = new TH1D (name.Data(), Form("Particle production process (%s)",kHistoPrefix[id]), kPNoProcess+1, -0.5, kPNoProcess+1-0.5);
298 Int_t nbin = kPNoProcess+1;
299 for(Int_t ibin = 0; ibin < nbin; ibin++){
300 h->GetXaxis()->SetBinLabel(ibin+1,TMCProcessName[ibin]);
302 TH1::AddDirectory(oldStatus);
313 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoSpecies(Histo_t id) {
315 // Returns histogram with particle specties
317 TString name = TString(kHistoPrefix[id])+"_Species";
319 TH1D * h = (TH1D*) GetHisto(name);
322 Bool_t oldStatus = TH1::AddDirectoryStatus();
323 TH1::AddDirectory(kFALSE);
325 AliInfo(Form("Booking histo %s",name.Data()));
327 h = new TH1D (name.Data(), Form("Particle species (%s)",kHistoPrefix[id]), kNPart+1, -0.5, kNPart+1-0.5);
328 Int_t nbin = kNPart+1;
329 for(Int_t ibin = 0; ibin < nbin; ibin++){
330 h->GetXaxis()->SetBinLabel(ibin+1,kSpeciesName[ibin]);
332 TH1::AddDirectory(oldStatus);
343 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoMeanPt(Histo_t id) {
344 // mean pt computed event by event
345 TString name = TString(kHistoPrefix[id])+"_MeanPt";
347 TH1D * h = (TH1D*) GetHisto(name);
350 Bool_t oldStatus = TH1::AddDirectoryStatus();
351 TH1::AddDirectory(kFALSE);
353 AliInfo(Form("Booking histo %s",name.Data()));
355 h = new TH1D (name.Data(), Form("Pt Event by Event(%s)",kHistoPrefix[id]), 100, 0, 1);
357 TH1::AddDirectory(oldStatus);
366 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoPtEvent(Histo_t id) {
368 // Returns of dNdpt, used to compute mean pt event by event
370 TString name = TString(kHistoPrefix[id])+"_PtEvent";
372 TH1D * h = (TH1D*) GetHisto(name);
375 Bool_t oldStatus = TH1::AddDirectoryStatus();
376 TH1::AddDirectory(kFALSE);
378 AliInfo(Form("Booking histo %s",name.Data()));
379 const Int_t nptbins = 68;
380 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};
382 h = new TH1D (name.Data(), Form("Pt Event by Event(%s)",kHistoPrefix[id]), nptbins,binsPt);
383 h->SetBit(kKeepMaxMean,1);
384 if(id == kHistoRecLowestMeanPt ) h->SetBit(kKeepMinMean,1);
386 TH1::AddDirectory(oldStatus);
397 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoVzEvent(Histo_t id) {
399 // Returns histogram with Vz of the event
401 TString name = TString(kHistoPrefix[id])+"_VzEvent";
403 TH1D * h = (TH1D*) GetHisto(name);
406 Bool_t oldStatus = TH1::AddDirectoryStatus();
407 TH1::AddDirectory(kFALSE);
409 AliInfo(Form("Booking histo %s",name.Data()));
411 h = new TH1D (name.Data(), Form("Vz of the event (%s)",kHistoPrefix[id]), 10, -10, 10);
413 h->SetXTitle("V_{z}^{event} (cm)");
414 TH1::AddDirectory(oldStatus);
426 TH1I * AliAnalysisMultPbTrackHistoManager::GetHistoStats() {
427 // Returns histogram with event statistiscs (processed events at each step)
429 TH1I * h = (TH1I*) GetHisto("hStats");
430 if (!h) h = BookHistoStats();
437 TH1 * AliAnalysisMultPbTrackHistoManager::GetHisto(const char * name) {
438 //Search list for histo
439 // TODO: keep track of histo id rather than searching by name?
440 return (TH1*) fList->FindObject(TString(name)+fHNameSuffix);
444 void AliAnalysisMultPbTrackHistoManager::ScaleHistos(Double_t nev, Option_t * option) {
445 // Scales all histos in the list for nev
446 // option can be used to pass further options to TH1::Scale
448 TIter iter = fList->MakeIterator();
449 while ((h = (TH1*) iter.Next())) {
450 if (!h->InheritsFrom("TH1")) {
451 AliFatal (Form("%s does not inherits from TH1, cannot scale",h->GetName()));
453 if (h->InheritsFrom("TH1I")) {
454 AliInfo (Form("Not scaling integer histo %s",h->GetName()));
457 AliInfo(Form("Scaling %s, nev %2.2f", h->GetName(), nev));
459 h->Scale(1./nev,option);
464 TH3D * AliAnalysisMultPbTrackHistoManager::BookHistoPtEtaVz(const char * name, const char * title) {
465 // Books a 3D histo of Pt/eta/vtx
466 // TODO: make the binning settable, variable binning?
468 Bool_t oldStatus = TH1::AddDirectoryStatus();
469 TH1::AddDirectory(kFALSE);
471 TString hname = name;
474 AliInfo(Form("Booking %s",hname.Data()));
476 // Binning from Jacek task
477 // const Int_t nptbins = 49;
478 // 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};
479 const Int_t nptbins = 68;
480 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};
482 const Int_t netabins=20;
483 Double_t binsEta[netabins+1];
486 Float_t etaStep = (maxEta-minEta)/netabins;
487 for(Int_t ibin = 0; ibin < netabins; ibin++){
488 binsEta[ibin] = minEta + ibin*etaStep;
489 binsEta[ibin+1] = minEta + ibin*etaStep + etaStep;
492 const Int_t nvzbins=10;
493 Double_t binsVz[nvzbins+1];
496 Float_t vzStep = (maxVz-minVz)/nvzbins;
497 for(Int_t ibin = 0; ibin < nvzbins; ibin++){
498 binsVz[ibin] = minVz + ibin*vzStep;
499 binsVz[ibin+1] = minVz + ibin*vzStep + vzStep;
503 TH3D * h = new TH3D (hname,title,
509 h->SetXTitle("p_{T} (GeV)");
510 h->SetYTitle("#eta");
511 h->SetZTitle("V_{z}^{tracks} (cm)");
514 TH1::AddDirectory(oldStatus);
519 TH2D * AliAnalysisMultPbTrackHistoManager::BookHistoDCA(const char * name, const char * title) {
522 const Int_t nptbins = 68;
523 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};
524 const Int_t ndcabins=100;
525 Double_t binsDca[ndcabins+1];
528 // const Double_t binsDCA[] = {-3,-2.8,-2.6,-2.4,-2.2,-2.0,-1.9,};
529 Float_t dcaStep = (maxDca-minDca)/ndcabins;
530 for(Int_t ibin = 0; ibin < ndcabins; ibin++){
531 binsDca[ibin] = minDca + ibin*dcaStep;
532 binsDca[ibin+1] = minDca + ibin*dcaStep + dcaStep;
538 Bool_t oldStatus = TH1::AddDirectoryStatus();
539 TH1::AddDirectory(kFALSE);
541 TString hname = name;
544 AliInfo(Form("Booking %s",hname.Data()));
547 #if defined WEIGHTED_DCA
548 TH1D * h = new TH1D (hname,title, 200,0,200);
549 h->SetXTitle("#Delta DCA");
550 #elif defined TRANSVERSE_DCA
551 TH2D * h = new TH2D (hname,title, ndcabins,binsDca,nptbins,binsPt);
552 h->SetYTitle("p_{T} (GeV)");
553 h->SetXTitle("d_{0} r#phi (cm)");
559 TH1::AddDirectory(oldStatus);
562 TH1D * AliAnalysisMultPbTrackHistoManager::BookHistoMult(const char * name, const char * title) {
563 // Books a multiplicity histo
565 Bool_t oldStatus = TH1::AddDirectoryStatus();
566 TH1::AddDirectory(kFALSE);
568 TString hname = name;
571 AliInfo(Form("Booking %s",hname.Data()));
574 TH1D * h = new TH1D (hname,title, 600, 0,6000);
576 h->SetXTitle("N tracks");
581 TH1::AddDirectory(oldStatus);
585 TH1I * AliAnalysisMultPbTrackHistoManager::BookHistoStats() {
586 // Books histogram with event statistiscs (processed events at each step)
588 Bool_t oldStatus = TH1::AddDirectoryStatus();
589 TH1::AddDirectory(kFALSE);
591 AliInfo(Form("Booking Stat histo"));
593 TH1I * h = new TH1I (TString("hStats")+fHNameSuffix, "Number of processed events", kNStatBins, -0.5, kNStatBins-0.5);
594 for(Int_t istatbin = 0; istatbin < kNStatBins; istatbin++){
595 h->GetXaxis()->SetBinLabel(istatbin+1,kStatStepNames[istatbin]);
597 TH1::AddDirectory(oldStatus);
602 Int_t AliAnalysisMultPbTrackHistoManager::GetLocalParticleID(AliMCParticle * part) {
603 // returns the local code (Part_t)
605 Int_t pdgcode = part->PdgCode();
644 void AliAnalysisMultPbTrackHistoManager::FillSpeciesMap(Int_t pdgCode) {
646 // Fills map of species vs ID
647 if(!fParticleSpecies) fParticleSpecies = new TMap;
649 TObjString * key = new TObjString(Form("%s",TDatabasePDG::Instance()->GetParticle(pdgCode)->GetName()));
650 TParameter<Long64_t>* count = dynamic_cast<TParameter<Long64_t>*> (fParticleSpecies->GetValue(key));
653 count = new TParameter<Long64_t>(key->String().Data(), 0);
654 fParticleSpecies->Add(key, count);
656 count->SetVal(count->GetVal() + 1);
661 Long64_t AliAnalysisMultPbTrackHistoManager::Merge(TCollection* list)
663 // Merge a list of AliHistoListWrapper objects with this.
664 // Returns the number of merged objects (including this).
666 // We have to make sure that all the list contain the same histos in
667 // the same order. We thus also have to sort the list (sorting is
668 // done by name in TList).
676 TIterator* iter = list->MakeIterator();
679 // collections of all histograms
684 while ((obj = iter->Next())) {
686 // AliHistoListWrapper* entry = dynamic_cast<AliHistoListWrapper*> (obj);
687 AliAnalysisMultPbTrackHistoManager* entry = dynamic_cast<AliAnalysisMultPbTrackHistoManager*> (obj);
688 cout << "2 " << endl;
691 cout << "3 " << entry->GetName() << endl;
693 // Merge map fParticleSpecies
694 if(!entry->fParticleSpecies){
695 AliInfo("Cannot get fParticleSpecies");
698 TIterator* iter2 = entry->fParticleSpecies->MakeIterator();
699 TObjString* obj2 = 0;
701 while ((obj2 = dynamic_cast<TObjString*> (iter2->Next())))
704 TParameter<Long64_t>* param2 = static_cast<TParameter<Long64_t>*> (entry->fParticleSpecies->GetValue(obj2));
706 TParameter<Long64_t>* param1 = dynamic_cast<TParameter<Long64_t>*> (fParticleSpecies->GetValue(obj2));
707 cout << " - (other)" << param2->GetName() << " " << param2->GetVal();
710 cout << " (this) " << param1->GetName() << " " << param1->GetVal() << endl;
711 param1->SetVal(param1->GetVal() + param2->GetVal());
716 param1 = dynamic_cast<TParameter<Long64_t>*> (param2->Clone());
717 fParticleSpecies->Add(new TObjString(obj2->String()), param1);
725 // We need a separate loop as this one could be restarted if needed.
727 while ((obj = iter->Next())) {
728 AliAnalysisMultPbTrackHistoManager* entry = dynamic_cast<AliAnalysisMultPbTrackHistoManager*> (obj);
732 Bool_t foundDiffinThisIterStep = kFALSE;
734 // Printf("%d - %s",count, obj->GetName());
736 TList * hlist = entry->GetList();
738 // Check if all histos in this fList are also in the one from entry and viceversa
739 // Use getters to automatically book non defined histos
741 Bool_t areListsDifferent=kTRUE;
743 Int_t max_loops = hlist->GetSize() + fList->GetSize(); // In the worst case all of the histos will be different...
744 while(areListsDifferent) {
745 if(iloop>max_loops) AliFatal("Infinite Loop?");
750 // loop over the largest
752 TIterator * iterlist = 0;
753 TList * thislist = 0; // the list over which I'm iterating
754 TList * otherlist = 0; // the other
756 if (hlist->GetSize() >= fList->GetSize()) {
764 iterlist = thislist->MakeIterator();
766 while ((hist= iterlist->Next())){
767 if(!otherlist->FindObject(hist->GetName())){
768 AliInfo(Form("Adding object %s",hist->GetName()));
769 TH1 * hclone = (TH1*) hist->Clone();
770 if (!hclone->InheritsFrom("TH1")) AliFatal(Form("Found a %s. This class only supports objects inheriting from TH1",hclone->ClassName()));
772 otherlist->Add(hclone);
773 foundDiffinThisIterStep=kTRUE;
777 // re-sort before checking
781 // check if everything is fine
782 areListsDifferent=kFALSE;
783 if (hlist->GetSize() == fList->GetSize()) {
784 Int_t nhist = fList->GetSize();
785 for(Int_t ihist = 0; ihist < nhist; ihist++){
786 if(strcmp(fList->At(ihist)->GetName(),hlist->At(ihist)->GetName())) areListsDifferent = kTRUE;
789 areListsDifferent=kTRUE;
793 // last check: if something is not ok die loudly
794 if (hlist->GetSize() != fList->GetSize()) {
795 AliFatal("Mismatching size!");
797 Int_t nhist = fList->GetSize();
798 for(Int_t ihist = 0; ihist < nhist; ihist++){
799 if(strcmp(fList->At(ihist)->GetName(),hlist->At(ihist)->GetName())){
800 AliFatal(Form("Mismatching histos: %s -> %s", fList->At(ihist)->GetName(),hlist->At(ihist)->GetName()));
802 // Specific merging strategies, according to the bits...
803 if (fList->At(ihist)->TestBits(kKeepMinMean|kKeepMaxMean)){
804 TH1 * h1 = (TH1*) fList->At(ihist);
805 TH1 * h2 = (TH1*) hlist->At(ihist);
806 if (h1->GetEntries()>0 && h2->GetEntries()>0) {
807 if (h1->TestBit(kKeepMinMean)) {
808 AliInfo(Form("Keeping only the histo with the lowest mean [%s][%f][%f]",h1->GetName(), h1->GetMean(), h2->GetMean()));
809 if(h1->GetMean() > h2->GetMean()) h1->Reset();
812 if (h1->TestBit(kKeepMaxMean)) {
813 AliInfo(Form("Keeping only the histo with the highest mean [%s][%f][%f]",h1->GetName(), h1->GetMean(), h2->GetMean()));
814 if(h2->GetMean() > h1->GetMean()) h1->Reset();
822 if (foundDiffinThisIterStep){
823 iter->Reset(); // We found a difference: previous lists could
824 // also be affected... We start from scratch
830 collections.Add(hlist);
836 fList->Merge(&collections);