1 #include "AliAnalysisMultPbTrackHistoManager.h"
7 #include "TMCProcess.h"
8 #include "AliMCParticle.h"
15 ClassImp(AliAnalysisMultPbTrackHistoManager)
17 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)" };
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", "hRecHighestMeanPt", "hRecLowestMeanPt"};
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 TH2D * AliAnalysisMultPbTrackHistoManager::GetHistoDCA(Histo_t id) {
61 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
63 TH2D * h = (TH2D*) GetHisto(kHistoDCANames[id]);
65 h = BookHistoDCA(kHistoDCANames[id], Form("DCA vs pt distribution (%s)",kHistoDCANames[id]));
72 TH2D * AliAnalysisMultPbTrackHistoManager::GetHistoV0vsNtracks(Histo_t id) {
73 // Returns a histo of V0 vs ntracks
76 TString name = TString(kHistoPrefix[id])+"_V0vsNtracks";
78 TH2D * h = (TH2D*) GetHisto(name);
81 Bool_t oldStatus = TH1::AddDirectoryStatus();
82 TH1::AddDirectory(kFALSE);
84 AliInfo(Form("Booking histo %s",name.Data()));
86 h = new TH2D (name.Data(), Form("V0 vs Ntracks (%s)",kHistoPrefix[id]), 300,0,3000, 300, 0, 20000);
87 h->SetXTitle("N_{Tracks}");
88 h->SetYTitle("V0 Amplitude");
89 TH1::AddDirectory(oldStatus);
100 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoMult(Histo_t id) {
101 // Returns a 3D histo of Pt/eta/vtx. It it does not exist, books it.
103 TString name = kHistoPrefix[id];
105 TH1D * h = (TH1D*) GetHisto(name.Data());
107 h = BookHistoMult(name.Data(), Form("Multiplicity distribution (%s)",kHistoPrefix[id]));
114 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoPt (Histo_t id,
115 Float_t minEta, Float_t maxEta,
116 Float_t minVz, Float_t maxVz,
118 // Returns a projection of the 3D histo pt/eta/vz.
119 // WARNING: since that is a histo, the requested range will be discretized to the binning.
120 // Always avoids under (over) flows
121 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
123 TH3D * h3D = GetHistoPtEtaVz(id);
125 // Get range in terms of bin numners. If the float range is
126 // less than -11111 take the range from the first to the last bin (i.e. no
129 Int_t min1 = minEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(minEta);
130 Int_t min2 = minVz < -11111 ? -1 : h3D ->GetZaxis()->FindBin(minVz) ;
132 Int_t max1 = maxEta < -11111 ? h3D->GetNbinsY() : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
133 Int_t max2 = maxVz < -11111 ? h3D->GetNbinsZ() : h3D ->GetZaxis()->FindBin(maxVz -0.00001);
134 // Int_t max1 = maxEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
135 // Int_t max2 = maxVz < -11111 ? -1 : h3D ->GetZaxis()->FindBin(maxVz -0.00001);
138 TString hname = h3D->GetName();
139 hname = hname + "_pt_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
142 if (gROOT->FindObjectAny(hname.Data())){
143 AliError(Form("An object called %s already exists,adding suffix",hname.Data()));
147 TH1D * h = h3D->ProjectionX(hname.Data(), min1, max1, min2, max2, "E");
148 if(scaleWidth) h ->Scale(1.,"width");
155 TH2D * AliAnalysisMultPbTrackHistoManager::GetHistoPtVz (Histo_t id,
156 Float_t minEta, Float_t maxEta,
158 // Returns a projection of the 3D histo pt/eta/vz.
159 // WARNING: since that is a histo, the requested range will be discretized to the binning.
160 // Always avoids under (over) flows
161 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
163 // FIXME: what do I do here for the scaling?
165 TH3D * h3D = GetHistoPtEtaVz(id);
167 // Get range in terms of bin numners. If the float range is
168 // less than -11111 take the range from the first to the last bin (i.e. no
170 Int_t min1 = minEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(minEta);
171 Int_t max1 = maxEta < -11111 ? -1 : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
174 TString hname = h3D->GetName();
175 hname = hname + "_ptvz_" + long (min1) + "_" + long(max1);
177 if (gROOT->FindObjectAny(hname.Data())){
178 AliError(Form("An object called %s already exists,adding suffix",hname.Data()));
182 h3D->GetYaxis()->SetRange(min1,max1);
184 TH2D * h = (TH2D*) h3D->Project3D("zxe");
185 if(scaleWidth) h ->Scale(1.,"width");
192 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoVz (Histo_t id,
193 Float_t minPt, Float_t maxPt,
194 Float_t minEta, Float_t maxEta,
196 // Returns a projection of the 3D histo pt/eta/vz.
197 // WARNING: since that is a histo, the requested range will be discretized to the binning.
198 // Always avoids under (over) flows
199 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
201 TH3D * h3D = GetHistoPtEtaVz(id);
203 // Get range in terms of bin numners. If the float range is
204 // less than -11111 take the range from the first to the last bin (i.e. no
206 Int_t min1 = minPt < -11111 ? 1 : h3D ->GetXaxis()->FindBin(minPt) ;
207 Int_t min2 = minEta < -11111 ? 1 : h3D ->GetYaxis()->FindBin(minEta);
209 Int_t max1 = maxPt < -11111 ? h3D->GetNbinsX() : h3D ->GetXaxis()->FindBin(maxPt -0.00001);
210 Int_t max2 = maxEta < -11111 ? h3D->GetNbinsY() : h3D ->GetYaxis()->FindBin(maxEta-0.00001);
213 TString hname = h3D->GetName();
214 hname = hname + "_Vz_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
216 if (gROOT->FindObjectAny(hname.Data())){
217 AliError(Form("An object called %s already exists, adding suffix",hname.Data()));
221 TH1D * h = h3D->ProjectionZ(hname.Data(), min1, max1, min2, max2, "E");
222 if(scaleWidth) h ->Scale(1.,"width");
228 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoEta (Histo_t id,
229 Float_t minPt, Float_t maxPt,
230 Float_t minVz, Float_t maxVz,
232 // Returns a projection of the 3D histo pt/eta/vz.
233 // WARNING: since that is a histo, the requested range will be discretized to the binning.
234 // Always avoids under (over) flows
235 // If scaleWidth = kTRUE, the projection is scaled for the bin width (default)
237 TH3D * h3D = GetHistoPtEtaVz(id);
239 // Get range in terms of bin numners. If the float range is
240 // less than -11111 take the range from the first to the last bin (i.e. no
242 Int_t min1 = minPt < -11111 ? 1 : h3D ->GetXaxis()->FindBin(minPt) ;
243 Int_t min2 = minVz < -11111 ? 1 : h3D ->GetYaxis()->FindBin(minVz);
245 Int_t max1 = maxPt < -11111 ? h3D->GetNbinsX() : h3D ->GetXaxis()->FindBin(maxPt -0.00001);
246 Int_t max2 = maxVz < -11111 ? h3D->GetNbinsY() : h3D ->GetYaxis()->FindBin(maxVz-0.00001);
248 TString hname = h3D->GetName();
249 hname = hname + "_Eta_" + long (min1) + "_" + long(max1) + "_" + long (min2) + "_" + long(max2);
251 if (gROOT->FindObjectAny(hname.Data())){
252 AliError(Form("An object called %s already exists, adding suffix",hname.Data()));
256 TH1D * h = h3D->ProjectionY(hname.Data(), min1, max1, min2, max2, "E");
257 if(scaleWidth) h ->Scale(1.,"width");
261 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoProcess(Histo_t id) {
263 // Returns histogram with particle specties
265 TString name = TString(kHistoPrefix[id])+"_Process";
267 TH1D * h = (TH1D*) GetHisto(name);
270 Bool_t oldStatus = TH1::AddDirectoryStatus();
271 TH1::AddDirectory(kFALSE);
273 AliInfo(Form("Booking histo %s",name.Data()));
275 h = new TH1D (name.Data(), Form("Particle production process (%s)",kHistoPrefix[id]), kPNoProcess+1, -0.5, kPNoProcess+1-0.5);
276 Int_t nbin = kPNoProcess+1;
277 for(Int_t ibin = 0; ibin < nbin; ibin++){
278 h->GetXaxis()->SetBinLabel(ibin+1,TMCProcessName[ibin]);
280 TH1::AddDirectory(oldStatus);
291 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoSpecies(Histo_t id) {
293 // Returns histogram with particle specties
295 TString name = TString(kHistoPrefix[id])+"_Species";
297 TH1D * h = (TH1D*) GetHisto(name);
300 Bool_t oldStatus = TH1::AddDirectoryStatus();
301 TH1::AddDirectory(kFALSE);
303 AliInfo(Form("Booking histo %s",name.Data()));
305 h = new TH1D (name.Data(), Form("Particle species (%s)",kHistoPrefix[id]), kNPart+1, -0.5, kNPart+1-0.5);
306 Int_t nbin = kNPart+1;
307 for(Int_t ibin = 0; ibin < nbin; ibin++){
308 h->GetXaxis()->SetBinLabel(ibin+1,kSpeciesName[ibin]);
310 TH1::AddDirectory(oldStatus);
321 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoMeanPt(Histo_t id) {
322 // mean pt computed event by event
323 TString name = TString(kHistoPrefix[id])+"_MeanPt";
325 TH1D * h = (TH1D*) GetHisto(name);
328 Bool_t oldStatus = TH1::AddDirectoryStatus();
329 TH1::AddDirectory(kFALSE);
331 AliInfo(Form("Booking histo %s",name.Data()));
333 h = new TH1D (name.Data(), Form("Pt Event by Event(%s)",kHistoPrefix[id]), 100, 0, 1);
335 TH1::AddDirectory(oldStatus);
344 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoPtEvent(Histo_t id) {
346 // Returns of dNdpt, used to compute mean pt event by event
348 TString name = TString(kHistoPrefix[id])+"_PtEvent";
350 TH1D * h = (TH1D*) GetHisto(name);
353 Bool_t oldStatus = TH1::AddDirectoryStatus();
354 TH1::AddDirectory(kFALSE);
356 AliInfo(Form("Booking histo %s",name.Data()));
357 const Int_t nptbins = 68;
358 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};
360 h = new TH1D (name.Data(), Form("Pt Event by Event(%s)",kHistoPrefix[id]), nptbins,binsPt);
361 h->SetBit(kKeepMaxMean,1);
362 if(id == kHistoRecLowestMeanPt ) h->SetBit(kKeepMinMean,1);
364 TH1::AddDirectory(oldStatus);
375 TH1D * AliAnalysisMultPbTrackHistoManager::GetHistoVzEvent(Histo_t id) {
377 // Returns histogram with Vz of the event
379 TString name = TString(kHistoPrefix[id])+"_VzEvent";
381 TH1D * h = (TH1D*) GetHisto(name);
384 Bool_t oldStatus = TH1::AddDirectoryStatus();
385 TH1::AddDirectory(kFALSE);
387 AliInfo(Form("Booking histo %s",name.Data()));
389 h = new TH1D (name.Data(), Form("Vz of the event (%s)",kHistoPrefix[id]), 10, -10, 10);
391 h->SetXTitle("V_{z}^{event} (cm)");
392 TH1::AddDirectory(oldStatus);
404 TH1I * AliAnalysisMultPbTrackHistoManager::GetHistoStats() {
405 // Returns histogram with event statistiscs (processed events at each step)
407 TH1I * h = (TH1I*) GetHisto("hStats");
408 if (!h) h = BookHistoStats();
415 TH1 * AliAnalysisMultPbTrackHistoManager::GetHisto(const char * name) {
416 //Search list for histo
417 // TODO: keep track of histo id rather than searching by name?
418 return (TH1*) fList->FindObject(TString(name)+fHNameSuffix);
422 void AliAnalysisMultPbTrackHistoManager::ScaleHistos(Double_t nev, Option_t * option) {
423 // Scales all histos in the list for nev
424 // option can be used to pass further options to TH1::Scale
426 TIter iter = fList->MakeIterator();
427 while ((h = (TH1*) iter.Next())) {
428 if (!h->InheritsFrom("TH1")) {
429 AliFatal (Form("%s does not inherits from TH1, cannot scale",h->GetName()));
431 if (h->InheritsFrom("TH1I")) {
432 AliInfo (Form("Not scaling integer histo %s",h->GetName()));
435 AliInfo(Form("Scaling %s, nev %2.2f", h->GetName(), nev));
437 h->Scale(1./nev,option);
442 TH3D * AliAnalysisMultPbTrackHistoManager::BookHistoPtEtaVz(const char * name, const char * title) {
443 // Books a 3D histo of Pt/eta/vtx
444 // TODO: make the binning settable, variable binning?
446 Bool_t oldStatus = TH1::AddDirectoryStatus();
447 TH1::AddDirectory(kFALSE);
449 TString hname = name;
452 AliInfo(Form("Booking %s",hname.Data()));
454 // Binning from Jacek task
455 // const Int_t nptbins = 49;
456 // 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};
457 const Int_t nptbins = 68;
458 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};
460 const Int_t netabins=20;
461 Double_t binsEta[netabins+1];
464 Float_t etaStep = (maxEta-minEta)/netabins;
465 for(Int_t ibin = 0; ibin < netabins; ibin++){
466 binsEta[ibin] = minEta + ibin*etaStep;
467 binsEta[ibin+1] = minEta + ibin*etaStep + etaStep;
470 const Int_t nvzbins=10;
471 Double_t binsVz[nvzbins+1];
474 Float_t vzStep = (maxVz-minVz)/nvzbins;
475 for(Int_t ibin = 0; ibin < nvzbins; ibin++){
476 binsVz[ibin] = minVz + ibin*vzStep;
477 binsVz[ibin+1] = minVz + ibin*vzStep + vzStep;
481 TH3D * h = new TH3D (hname,title,
487 h->SetXTitle("p_{T} (GeV)");
488 h->SetYTitle("#eta");
489 h->SetZTitle("V_{z}^{tracks} (cm)");
494 TH1::AddDirectory(oldStatus);
498 TH2D * AliAnalysisMultPbTrackHistoManager::BookHistoDCA(const char * name, const char * title) {
501 const Int_t nptbins = 68;
502 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};
503 const Int_t ndcabins=100;
504 Double_t binsDca[ndcabins+1];
507 // const Double_t binsDCA[] = {-3,-2.8,-2.6,-2.4,-2.2,-2.0,-1.9,};
508 Float_t dcaStep = (maxDca-minDca)/ndcabins;
509 for(Int_t ibin = 0; ibin < ndcabins; ibin++){
510 binsDca[ibin] = minDca + ibin*dcaStep;
511 binsDca[ibin+1] = minDca + ibin*dcaStep + dcaStep;
517 Bool_t oldStatus = TH1::AddDirectoryStatus();
518 TH1::AddDirectory(kFALSE);
520 TString hname = name;
523 AliInfo(Form("Booking %s",hname.Data()));
526 #if defined WEIGHTED_DCA
527 TH1D * h = new TH1D (hname,title, 200,0,200);
528 h->SetXTitle("#Delta DCA");
529 #elif defined TRANSVERSE_DCA
530 TH2D * h = new TH2D (hname,title, ndcabins,binsDca,nptbins,binsPt);
531 h->SetYTitle("p_{T} (GeV)");
532 h->SetXTitle("d_{0} r#phi (cm)");
538 TH1::AddDirectory(oldStatus);
541 TH1D * AliAnalysisMultPbTrackHistoManager::BookHistoMult(const char * name, const char * title) {
542 // Books a multiplicity histo
544 Bool_t oldStatus = TH1::AddDirectoryStatus();
545 TH1::AddDirectory(kFALSE);
547 TString hname = name;
550 AliInfo(Form("Booking %s",hname.Data()));
553 TH1D * h = new TH1D (hname,title, 600, 0,6000);
555 h->SetXTitle("N tracks");
560 TH1::AddDirectory(oldStatus);
564 TH1I * AliAnalysisMultPbTrackHistoManager::BookHistoStats() {
565 // Books histogram with event statistiscs (processed events at each step)
567 Bool_t oldStatus = TH1::AddDirectoryStatus();
568 TH1::AddDirectory(kFALSE);
570 AliInfo(Form("Booking Stat histo"));
572 TH1I * h = new TH1I (TString("hStats")+fHNameSuffix, "Number of processed events", kNStatBins, -0.5, kNStatBins-0.5);
573 for(Int_t istatbin = 0; istatbin < kNStatBins; istatbin++){
574 h->GetXaxis()->SetBinLabel(istatbin+1,kStatStepNames[istatbin]);
576 TH1::AddDirectory(oldStatus);
581 Int_t AliAnalysisMultPbTrackHistoManager::GetLocalParticleID(AliMCParticle * part) {
582 // returns the local code (Part_t)
584 Int_t pdgcode = part->PdgCode();
624 Long64_t AliAnalysisMultPbTrackHistoManager::Merge(TCollection* list)
626 // Merge a list of AliHistoListWrapper objects with this.
627 // Returns the number of merged objects (including this).
629 // We have to make sure that all the list contain the same histos in
630 // the same order. We thus also have to sort the list (sorting is
631 // done by name in TList).
633 // AliInfo("Merging");
641 TIterator* iter = list->MakeIterator();
644 // collections of all histograms
649 while ((obj = iter->Next())) {
650 Bool_t foundDiffinThisIterStep = kFALSE;
652 // Printf("%d - %s",count, obj->GetName());
653 AliHistoListWrapper* entry = dynamic_cast<AliHistoListWrapper*> (obj);
657 TList * hlist = entry->GetList();
659 // Check if all histos in this fList are also in the one from entry and viceversa
660 // Use getters to automatically book non defined histos
662 Bool_t areListsDifferent=kTRUE;
664 Int_t max_loops = hlist->GetSize() + fList->GetSize(); // In the worst case all of the histos will be different...
665 while(areListsDifferent) {
666 if(iloop>max_loops) AliFatal("Infinite Loop?");
671 // loop over the largest
673 TIterator * iterlist = 0;
674 TList * thislist = 0; // the list over which I'm iterating
675 TList * otherlist = 0; // the other
677 if (hlist->GetSize() >= fList->GetSize()) {
685 iterlist = thislist->MakeIterator();
687 while ((hist= iterlist->Next())){
688 if(!otherlist->FindObject(hist->GetName())){
689 AliInfo(Form("Adding object %s",hist->GetName()));
690 TH1 * hclone = (TH1*) hist->Clone();
691 if (!hclone->InheritsFrom("TH1")) AliFatal(Form("Found a %s. This class only supports objects inheriting from TH1",hclone->ClassName()));
693 otherlist->Add(hclone);
694 foundDiffinThisIterStep=kTRUE;
698 // re-sort before checking
702 // check if everything is fine
703 areListsDifferent=kFALSE;
704 if (hlist->GetSize() == fList->GetSize()) {
705 Int_t nhist = fList->GetSize();
706 for(Int_t ihist = 0; ihist < nhist; ihist++){
707 if(strcmp(fList->At(ihist)->GetName(),hlist->At(ihist)->GetName())) areListsDifferent = kTRUE;
710 areListsDifferent=kTRUE;
714 // last check: if something is not ok die loudly
715 if (hlist->GetSize() != fList->GetSize()) {
716 AliFatal("Mismatching size!");
718 Int_t nhist = fList->GetSize();
719 for(Int_t ihist = 0; ihist < nhist; ihist++){
720 if(strcmp(fList->At(ihist)->GetName(),hlist->At(ihist)->GetName())){
721 AliFatal(Form("Mismatching histos: %s -> %s", fList->At(ihist)->GetName(),hlist->At(ihist)->GetName()));
723 // Specific merging strategies, according to the bits...
724 if (fList->At(ihist)->TestBits(kKeepMinMean|kKeepMaxMean)){
725 TH1 * h1 = (TH1*) fList->At(ihist);
726 TH1 * h2 = (TH1*) hlist->At(ihist);
727 if (h1->GetEntries()>0 && h2->GetEntries()>0) {
728 if (h1->TestBit(kKeepMinMean)) {
729 AliInfo(Form("Keeping only the histo with the lowest mean [%s][%f][%f]",h1->GetName(), h1->GetMean(), h2->GetMean()));
730 if(h1->GetMean() > h2->GetMean()) h1->Reset();
733 if (h1->TestBit(kKeepMaxMean)) {
734 AliInfo(Form("Keeping only the histo with the highest mean [%s][%f][%f]",h1->GetName(), h1->GetMean(), h2->GetMean()));
735 if(h2->GetMean() > h1->GetMean()) h1->Reset();
743 if (foundDiffinThisIterStep){
744 iter->Reset(); // We found a difference: previous lists could
745 // also be affected... We start from scratch
751 collections.Add(hlist);
757 fList->Merge(&collections);