1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /* $Id: AliUEHistograms.cxx 20164 2007-08-14 15:31:50Z morsch $ */
20 // encapsulates several AliUEHist objects for a full UE analysis plus additional control histograms
23 // Author: Jan Fiete Grosse-Oetringhaus, Sara Vallero
25 #include "AliUEHistograms.h"
27 #include "AliCFContainer.h"
28 #include "AliVParticle.h"
36 ClassImp(AliUEHistograms)
38 const Int_t AliUEHistograms::fgkUEHists = 3;
40 AliUEHistograms::AliUEHistograms(const char* name, const char* histograms) :
49 fCorrelationLeading2Phi(0),
50 fCorrelationMultiplicity(0),
52 fEventCountDifferential(0),
53 fVertexContributors(0),
54 fCentralityDistribution(0)
58 // the string histograms defines which histograms are created:
59 // 1 = NumberDensitypT
61 // 3 = NumberDensityPhi
62 // 4 = NumberDensityPhiCentrality (other multiplicity for Pb)
64 TString histogramsStr(histograms);
66 if (histogramsStr.Contains("1"))
67 fNumberDensitypT = new AliUEHist("NumberDensitypT");
68 if (histogramsStr.Contains("2"))
69 fSumpT = new AliUEHist("SumpT");
71 if (histogramsStr.Contains("3"))
72 fNumberDensityPhi = new AliUEHist("NumberDensityPhi");
73 else if (histogramsStr.Contains("4"))
74 fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentrality");
76 // do not add this hists to the directory
77 Bool_t oldStatus = TH1::AddDirectoryStatus();
78 TH1::AddDirectory(kFALSE);
80 fCorrelationpT = new TH2F("fCorrelationpT", ";p_{T,lead} (MC);p_{T,lead} (RECO)", 200, 0, 50, 200, 0, 50);
81 fCorrelationEta = new TH2F("fCorrelationEta", ";#eta_{T,lead} (MC);#eta_{T,lead} (RECO)", 200, -1, 1, 200, -1, 1);
82 fCorrelationPhi = new TH2F("fCorrelationPhi", ";#phi_{T,lead} (MC);#phi_{T,lead} (RECO)", 200, 0, TMath::TwoPi(), 200, 0, TMath::TwoPi());
83 fCorrelationR = new TH2F("fCorrelationR", ";R;p_{T,lead} (MC)", 200, 0, 2, 200, 0, 50);
84 fCorrelationLeading2Phi = new TH2F("fCorrelationLeading2Phi", ";#Delta #phi;p_{T,lead} (MC)", 200, -TMath::Pi(), TMath::Pi(), 200, 0, 50);
85 fCorrelationMultiplicity = new TH2F("fCorrelationMultiplicity", ";MC tracks;Reco tracks", 100, -0.5, 99.5, 100, -0.5, 99.5);
87 fEventCount = new TH2F("fEventCount", ";step;event type;count", AliUEHist::fgkCFSteps+2, -2.5, -0.5 + AliUEHist::fgkCFSteps, 3, -0.5, 2.5);
88 fEventCount->GetYaxis()->SetBinLabel(1, "ND");
89 fEventCount->GetYaxis()->SetBinLabel(2, "SD");
90 fEventCount->GetYaxis()->SetBinLabel(3, "DD");
92 fEventCountDifferential = new TH3F("fEventCountDifferential", ";p_{T,lead};step;event type", 100, 0, 50, AliUEHist::fgkCFSteps, -0.5, -0.5 + AliUEHist::fgkCFSteps, 3, -0.5, 2.5);
93 fEventCountDifferential->GetZaxis()->SetBinLabel(1, "ND");
94 fEventCountDifferential->GetZaxis()->SetBinLabel(2, "SD");
95 fEventCountDifferential->GetZaxis()->SetBinLabel(3, "DD");
97 fVertexContributors = new TH1F("fVertexContributors", ";contributors;count", 100, -0.5, 99.5);
99 fCentralityDistribution = new TH1F("fCentralityDistribution", ";;count", fNumberDensityPhi->GetEventHist()->GetNBins(1), fNumberDensityPhi->GetEventHist()->GetAxis(1, 0)->GetBinLowEdge(1), fNumberDensityPhi->GetEventHist()->GetAxis(1, 0)->GetBinUpEdge(fNumberDensityPhi->GetEventHist()->GetNBins(1)));
101 TH1::AddDirectory(oldStatus);
104 //_____________________________________________________________________________
105 AliUEHistograms::AliUEHistograms(const AliUEHistograms &c) :
106 TNamed(fName, fTitle),
109 fNumberDensityPhi(0),
114 fCorrelationLeading2Phi(0),
115 fCorrelationMultiplicity(0),
117 fEventCountDifferential(0),
118 fVertexContributors(0),
119 fCentralityDistribution(0)
122 // AliUEHistograms copy constructor
125 ((AliUEHistograms &) c).Copy(*this);
128 //____________________________________________________________________
129 AliUEHistograms::~AliUEHistograms()
133 if (fNumberDensitypT)
135 delete fNumberDensitypT;
136 fNumberDensitypT = 0;
145 if (fNumberDensityPhi)
147 delete fNumberDensityPhi;
148 fNumberDensityPhi = 0;
153 delete fCorrelationpT;
159 delete fCorrelationEta;
165 delete fCorrelationPhi;
171 delete fCorrelationR;
175 if (fCorrelationLeading2Phi)
177 delete fCorrelationLeading2Phi;
178 fCorrelationLeading2Phi = 0;
181 if (fCorrelationMultiplicity)
183 delete fCorrelationMultiplicity;
184 fCorrelationMultiplicity = 0;
193 if (fEventCountDifferential)
195 delete fEventCountDifferential;
196 fEventCountDifferential = 0;
199 if (fVertexContributors)
201 delete fVertexContributors;
202 fVertexContributors = 0;
205 if (fCentralityDistribution)
207 delete fCentralityDistribution;
208 fCentralityDistribution = 0;
212 AliUEHist* AliUEHistograms::GetUEHist(Int_t id)
214 // returns AliUEHist object, useful for loops
218 case 0: return fNumberDensitypT; break;
219 case 1: return fSumpT; break;
220 case 2: return fNumberDensityPhi; break;
226 //____________________________________________________________________
227 Int_t AliUEHistograms::CountParticles(TList* list, Float_t ptMin)
229 // counts the number of particles in the list with a pT above ptMin
230 // TODO eta cut needed here?
233 for (Int_t j=0; j<list->GetEntries(); j++)
234 if (((AliVParticle*) list->At(j))->Pt() > ptMin)
240 //____________________________________________________________________
241 void AliUEHistograms::Fill(Int_t eventType, AliUEHist::CFStep step, AliVParticle* leading, TList* toward, TList* away, TList* min, TList* max)
243 // fills the UE event histograms
245 // this function needs the leading (track or jet or ...) and four lists of AliVParticles which contain the particles/tracks to be filled in the four regions
247 // if leading is not set, just fill event statistics
250 Int_t multiplicity = 0;
252 // TODO configurable?
253 Float_t ptMin = 0.15;
254 if (leading->Pt() > ptMin)
257 multiplicity += CountParticles(toward, ptMin);
258 multiplicity += CountParticles(away, ptMin);
259 multiplicity += CountParticles(min, ptMin);
260 multiplicity += CountParticles(max, ptMin);
262 FillRegion(AliUEHist::kToward, step, leading, toward, multiplicity);
263 FillRegion(AliUEHist::kAway, step, leading, away, multiplicity);
264 FillRegion(AliUEHist::kMin, step, leading, min, multiplicity);
265 FillRegion(AliUEHist::kMax, step, leading, max, multiplicity);
268 vars[0] = leading->Pt();
269 vars[1] = multiplicity;
270 for (Int_t i=0; i<fgkUEHists; i++)
272 GetUEHist(i)->GetEventHist()->Fill(vars, step);
274 fEventCountDifferential->Fill(leading->Pt(), step, eventType);
277 FillEvent(eventType, step);
280 //____________________________________________________________________
281 void AliUEHistograms::FillRegion(AliUEHist::Region region, AliUEHist::CFStep step, AliVParticle* leading, TList* list, Int_t multiplicity)
283 // loops over AliVParticles in list and fills the given region at the given step
285 // See also Fill(...)
287 for (Int_t i=0; i<list->GetEntries(); i++)
289 AliVParticle* particle = (AliVParticle*) list->At(i);
292 vars[0] = particle->Eta();
293 vars[1] = particle->Pt();
294 vars[2] = leading->Pt();
295 vars[3] = multiplicity;
296 vars[4] = leading->Phi() - particle->Phi();
297 if (vars[4] > 1.5 * TMath::Pi())
298 vars[4] -= TMath::TwoPi();
299 if (vars[4] < -0.5 * TMath::Pi())
300 vars[4] += TMath::TwoPi();
302 if (fNumberDensitypT)
303 fNumberDensitypT->GetTrackHist(region)->Fill(vars, step);
306 fSumpT->GetTrackHist(region)->Fill(vars, step, particle->Pt());
308 // fill all in toward region (is anyway as function of delta phi!)
309 if (fNumberDensityPhi)
310 fNumberDensityPhi->GetTrackHist(AliUEHist::kToward)->Fill(vars, step);
314 //____________________________________________________________________
315 void AliUEHistograms::Fill(AliVParticle* leadingMC, AliVParticle* leadingReco)
317 // fills the correlation histograms
321 fCorrelationpT->Fill(leadingMC->Pt(), leadingReco->Pt());
322 if (leadingMC->Pt() > 0.5)
324 fCorrelationEta->Fill(leadingMC->Eta(), leadingReco->Eta());
325 fCorrelationPhi->Fill(leadingMC->Phi(), leadingReco->Phi());
328 Float_t phiDiff = leadingMC->Phi() - leadingReco->Phi();
329 if (phiDiff > TMath::Pi())
330 phiDiff -= TMath::TwoPi();
331 if (phiDiff < -TMath::Pi())
332 phiDiff += TMath::TwoPi();
334 Float_t etaDiff = leadingMC->Eta() - leadingReco->Eta();
336 fCorrelationR->Fill(TMath::Sqrt(phiDiff * phiDiff + etaDiff * etaDiff), leadingMC->Pt());
337 fCorrelationLeading2Phi->Fill(phiDiff, leadingMC->Pt());
341 fCorrelationpT->Fill(1.0, leadingReco->Pt());
342 if (leadingReco->Pt() > 0.5)
344 fCorrelationEta->Fill(0.0, leadingReco->Eta());
345 fCorrelationPhi->Fill(0.0, leadingReco->Phi());
350 //____________________________________________________________________
351 void AliUEHistograms::FillCorrelations(Int_t eventType, Int_t centrality, AliUEHist::CFStep step, TSeqCollection* particles, TSeqCollection* mixed)
353 // fills the fNumberDensityPhi histogram
355 // this function need a list of AliVParticles which contain the particles/tracks to be filled
357 // if mixed is non-0, mixed events are filled, the trigger particle is from particles, the associated from mixed
359 // if particles is not set, just fill event statistics
362 for (Int_t i=0; i<particles->GetEntries(); i++)
364 AliVParticle* triggerParticle = (AliVParticle*) particles->At(i);
365 Int_t jMax = particles->GetEntries();
367 jMax = mixed->GetEntries();
369 for (Int_t j=0; j<jMax; j++)
371 if (!mixed && i == j)
374 AliVParticle* particle = 0;
376 particle = (AliVParticle*) particles->At(j);
378 particle = (AliVParticle*) mixed->At(j);
381 vars[0] = triggerParticle->Eta() - particle->Eta();
382 vars[1] = particle->Pt();
383 vars[2] = triggerParticle->Pt();
384 vars[3] = centrality;
385 vars[4] = triggerParticle->Phi() - particle->Phi();
386 if (vars[4] > 1.5 * TMath::Pi())
387 vars[4] -= TMath::TwoPi();
388 if (vars[4] < -0.5 * TMath::Pi())
389 vars[4] += TMath::TwoPi();
391 // fill all in toward region and no not use the other regions
392 fNumberDensityPhi->GetTrackHist(AliUEHist::kToward)->Fill(vars, step);
395 // once per trigger particle
397 vars[0] = triggerParticle->Pt();
398 vars[1] = centrality;
399 fNumberDensityPhi->GetEventHist()->Fill(vars, step);
401 fEventCountDifferential->Fill(triggerParticle->Pt(), step, eventType);
405 fCentralityDistribution->Fill(centrality);
406 FillEvent(eventType, step);
409 //____________________________________________________________________
410 void AliUEHistograms::FillTrackingEfficiency(TObjArray* mc, TObjArray* recoPrim, TObjArray* recoAll, Int_t particleType)
412 // fills the tracking efficiency objects
414 // mc: all primary MC particles
415 // recoPrim: reconstructed primaries (again MC particles)
416 // recoAll: reconstructed (again MC particles)
417 // particleType is: 0 for pion, 1 for kaon, 2 for proton, 3 for others
419 for (Int_t step=0; step<3; step++)
421 TObjArray* list = mc;
427 for (Int_t i=0; i<list->GetEntries(); i++)
429 AliVParticle* particle = (AliVParticle*) list->At(i);
431 vars[0] = particle->Eta();
432 vars[1] = particle->Pt();
433 vars[2] = particleType;
435 for (Int_t j=0; j<fgkUEHists; j++)
437 GetUEHist(j)->GetTrackHistEfficiency()->Fill(vars, step);
442 //____________________________________________________________________
443 void AliUEHistograms::FillEvent(Int_t eventType, Int_t step)
445 // fills the number of events at the given step and the given enty type
447 // WARNING: This function is called from Fill, so only call it for steps where Fill is not called
449 fEventCount->Fill(step, eventType);
452 //____________________________________________________________________
453 void AliUEHistograms::SetEtaRange(Float_t etaMin, Float_t etaMax)
455 // sets eta min and max for all contained AliUEHist classes
457 for (Int_t i=0; i<fgkUEHists; i++)
459 GetUEHist(i)->SetEtaRange(etaMin, etaMax);
462 //____________________________________________________________________
463 void AliUEHistograms::SetPtRange(Float_t ptMin, Float_t ptMax)
465 // sets pT min and max for all contained AliUEHist classes
467 for (Int_t i=0; i<fgkUEHists; i++)
469 GetUEHist(i)->SetPtRange(ptMin, ptMax);
472 //____________________________________________________________________
473 void AliUEHistograms::SetContaminationEnhancement(TH1F* hist)
475 // sets the contamination enhancement histogram in all contained AliUEHist classes
477 for (Int_t i=0; i<fgkUEHists; i++)
479 GetUEHist(i)->SetContaminationEnhancement(hist);
482 //____________________________________________________________________
483 void AliUEHistograms::SetCombineMinMax(Bool_t flag)
485 // sets pT min and max for all contained AliUEHist classes
487 for (Int_t i=0; i<fgkUEHists; i++)
489 GetUEHist(i)->SetCombineMinMax(flag);
492 //____________________________________________________________________
493 void AliUEHistograms::Correct(AliUEHistograms* corrections)
495 // corrects the contained histograms by calling AliUEHist::Correct
497 for (Int_t i=0; i<fgkUEHists; i++)
499 GetUEHist(i)->Correct(corrections->GetUEHist(i));
502 //____________________________________________________________________
503 AliUEHistograms &AliUEHistograms::operator=(const AliUEHistograms &c)
505 // assigment operator
508 ((AliUEHistograms &) c).Copy(*this);
513 //____________________________________________________________________
514 void AliUEHistograms::Copy(TObject& c) const
518 AliUEHistograms& target = (AliUEHistograms &) c;
520 if (fNumberDensitypT)
521 target.fNumberDensitypT = dynamic_cast<AliUEHist*> (fNumberDensitypT->Clone());
524 target.fSumpT = dynamic_cast<AliUEHist*> (fSumpT->Clone());
526 if (fNumberDensityPhi)
527 target.fNumberDensityPhi = dynamic_cast<AliUEHist*> (fNumberDensityPhi->Clone());
530 target.fCorrelationpT = dynamic_cast<TH2F*> (fCorrelationpT->Clone());
533 target.fCorrelationEta = dynamic_cast<TH2F*> (fCorrelationEta->Clone());
536 target.fCorrelationPhi = dynamic_cast<TH2F*> (fCorrelationPhi->Clone());
539 target.fCorrelationR = dynamic_cast<TH2F*> (fCorrelationR->Clone());
541 if (fCorrelationLeading2Phi)
542 target.fCorrelationLeading2Phi = dynamic_cast<TH2F*> (fCorrelationLeading2Phi->Clone());
544 if (fCorrelationMultiplicity)
545 target.fCorrelationMultiplicity = dynamic_cast<TH2F*> (fCorrelationMultiplicity->Clone());
548 target.fEventCount = dynamic_cast<TH2F*> (fEventCount->Clone());
550 if (fEventCountDifferential)
551 target.fEventCountDifferential = dynamic_cast<TH3F*> (fEventCountDifferential->Clone());
553 if (fVertexContributors)
554 target.fVertexContributors = dynamic_cast<TH1F*> (fVertexContributors->Clone());
556 if (fCentralityDistribution)
557 target.fCentralityDistribution = dynamic_cast<TH1F*> (fCentralityDistribution->Clone());
560 //____________________________________________________________________
561 Long64_t AliUEHistograms::Merge(TCollection* list)
563 // Merge a list of AliUEHistograms objects with this (needed for
565 // Returns the number of merged objects (including this).
573 TIterator* iter = list->MakeIterator();
576 // collections of objects
577 const Int_t kMaxLists = 13;
578 TList* lists[kMaxLists];
580 for (Int_t i=0; i<kMaxLists; i++)
581 lists[i] = new TList;
584 while ((obj = iter->Next())) {
586 AliUEHistograms* entry = dynamic_cast<AliUEHistograms*> (obj);
590 if (entry->fNumberDensitypT)
591 lists[0]->Add(entry->fNumberDensitypT);
593 lists[1]->Add(entry->fSumpT);
594 if (entry->fNumberDensityPhi)
595 lists[2]->Add(entry->fNumberDensityPhi);
596 lists[3]->Add(entry->fCorrelationpT);
597 lists[4]->Add(entry->fCorrelationEta);
598 lists[5]->Add(entry->fCorrelationPhi);
599 lists[6]->Add(entry->fCorrelationR);
600 lists[7]->Add(entry->fCorrelationLeading2Phi);
601 lists[8]->Add(entry->fCorrelationMultiplicity);
602 lists[9]->Add(entry->fEventCount);
603 lists[10]->Add(entry->fEventCountDifferential);
604 lists[11]->Add(entry->fVertexContributors);
605 lists[12]->Add(entry->fCentralityDistribution);
610 if (fNumberDensitypT)
611 fNumberDensitypT->Merge(lists[0]);
613 fSumpT->Merge(lists[1]);
614 if (fNumberDensityPhi)
615 fNumberDensityPhi->Merge(lists[2]);
616 fCorrelationpT->Merge(lists[3]);
617 fCorrelationEta->Merge(lists[4]);
618 fCorrelationPhi->Merge(lists[5]);
619 fCorrelationR->Merge(lists[6]);
620 fCorrelationLeading2Phi->Merge(lists[7]);
621 fCorrelationMultiplicity->Merge(lists[8]);
622 fEventCount->Merge(lists[9]);
623 fEventCountDifferential->Merge(lists[10]);
624 fVertexContributors->Merge(lists[11]);
625 fCentralityDistribution->Merge(lists[12]);
627 for (Int_t i=0; i<kMaxLists; i++)
633 void AliUEHistograms::CopyReconstructedData(AliUEHistograms* from)
635 // copies those histograms extracted from ESD to this object
637 for (Int_t i=0; i<fgkUEHists; i++)
639 GetUEHist(i)->CopyReconstructedData(from->GetUEHist(i));
642 void AliUEHistograms::ExtendTrackingEfficiency()
644 // delegates to AliUEHists
646 for (Int_t i=0; i<fgkUEHists; i++)
648 GetUEHist(i)->ExtendTrackingEfficiency();