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: AliUEHist.cxx 20164 2007-08-14 15:31:50Z morsch $ */
20 // encapsulate histogram and corrections for one underlying event histogram
23 // Author: Jan Fiete Grosse-Oetringhaus, Sara Vallero
25 #include "AliUEHist.h"
26 #include "AliCFContainer.h"
27 #include "THnSparse.h"
30 #include "TCollection.h"
40 const Int_t AliUEHist::fgkCFSteps = 10;
42 AliUEHist::AliUEHist(const char* reqHist) :
50 fContaminationEnhancement(0),
56 for (Int_t i=0; i<fkRegions; i++)
59 if (strlen(reqHist) == 0)
62 const char* title = "";
65 Int_t nTrackVars = 4; // eta vs pT vs pT,lead (vs delta phi) vs multiplicity
67 Double_t* trackBins[5];
68 const char* trackAxisTitle[5];
72 Double_t etaBins[20+1];
73 for (Int_t i=0; i<=iTrackBin[0]; i++)
74 etaBins[i] = -1.0 + 0.1 * i;
75 trackBins[0] = etaBins;
76 trackAxisTitle[0] = "#eta";
80 Double_t pTBins[] = {0.0, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 100.0};
81 trackBins[1] = pTBins;
82 trackAxisTitle[1] = "p_{T} (GeV/c)";
85 const Int_t kNLeadingpTBins = 100;
86 Double_t leadingpTBins[kNLeadingpTBins+1];
87 for (Int_t i=0; i<=kNLeadingpTBins; i++)
88 leadingpTBins[i] = 0.5 * i;
91 const Int_t kNLeadingpTBins2 = 10;
92 Double_t leadingpTBins2[kNLeadingpTBins2+1];
93 for (Int_t i=0; i<=kNLeadingpTBins2; i++)
94 leadingpTBins2[i] = 5.0 * i;
97 const Int_t kNLeadingPhiBins = 40;
98 Double_t leadingPhiBins[kNLeadingPhiBins+1];
99 for (Int_t i=0; i<=kNLeadingPhiBins; i++)
100 leadingPhiBins[i] = -1.5 * TMath::Pi() + 1.0 / 40 * i * TMath::TwoPi();
103 const Int_t kNMultiplicityBins = 15;
104 Double_t multiplicityBins[kNMultiplicityBins+1];
105 for (Int_t i=0; i<=kNMultiplicityBins; i++)
106 multiplicityBins[i] = -0.5 + i;
107 multiplicityBins[kNMultiplicityBins] = 200;
109 trackBins[3] = multiplicityBins;
110 iTrackBin[3] = kNMultiplicityBins;
111 trackAxisTitle[3] = "multiplicity";
113 // selection depending on requested histogram
114 Int_t axis = -1; // 0 = pT,lead, 1 = phi,lead
115 if (strcmp(reqHist, "NumberDensitypT") == 0)
118 title = "d^{2}N_{ch}/d#phid#eta";
120 else if (strcmp(reqHist, "NumberDensityPhi") == 0)
123 title = "d^{2}N_{ch}/d#phid#eta";
125 else if (strcmp(reqHist, "SumpT") == 0)
128 title = "d^{2}#Sigma p_{T}/d#phid#eta";
131 AliFatal(Form("Invalid histogram requested: %s", reqHist));
133 Int_t initRegions = fkRegions;
137 trackBins[2] = leadingpTBins;
138 iTrackBin[2] = kNLeadingpTBins;
139 trackAxisTitle[2] = "leading p_{T} (GeV/c)";
147 iTrackBin[2] = kNLeadingpTBins2;
148 trackBins[2] = leadingpTBins2;
149 trackAxisTitle[2] = "leading p_{T} (GeV/c)";
151 iTrackBin[4] = kNLeadingPhiBins;
152 trackBins[4] = leadingPhiBins;
153 trackAxisTitle[4] = "#phi w.r.t leading track";
156 for (Int_t i=0; i<initRegions; i++)
158 fTrackHist[i] = new AliCFContainer(Form("fTrackHist_%d", i), title, fgkCFSteps, nTrackVars, iTrackBin);
160 for (Int_t j=0; j<nTrackVars; j++)
162 fTrackHist[i]->SetBinLimits(j, trackBins[j]);
163 fTrackHist[i]->SetVarTitle(j, trackAxisTitle[j]);
166 SetStepNames(fTrackHist[i]);
169 // track 3rd and 4th axis --> event 1st and 2nd axis
170 fEventHist = new AliCFContainer("fEventHist", title, fgkCFSteps, 2, iTrackBin+2);
172 fEventHist->SetBinLimits(0, trackBins[2]);
173 fEventHist->SetVarTitle(0, trackAxisTitle[2]);
175 fEventHist->SetBinLimits(1, trackBins[3]);
176 fEventHist->SetVarTitle(1, trackAxisTitle[3]);
178 SetStepNames(fEventHist);
181 //_____________________________________________________________________________
182 AliUEHist::AliUEHist(const AliUEHist &c) :
190 fContaminationEnhancement(0),
195 // AliUEHist copy constructor
198 ((AliUEHist &) c).Copy(*this);
201 //____________________________________________________________________
202 void AliUEHist::SetStepNames(AliCFContainer* container)
204 // sets the names of the correction steps
206 for (Int_t i=0; i<fgkCFSteps; i++)
207 container->SetStepTitle(i, GetStepTitle((CFStep) i));
210 //____________________________________________________________________
211 AliUEHist::~AliUEHist()
215 for (Int_t i=0; i<fkRegions; i++)
219 delete fTrackHist[i];
237 //____________________________________________________________________
238 AliUEHist &AliUEHist::operator=(const AliUEHist &c)
240 // assigment operator
243 ((AliUEHist &) c).Copy(*this);
248 //____________________________________________________________________
249 void AliUEHist::Copy(TObject& c) const
253 AliUEHist& target = (AliUEHist &) c;
255 for (Int_t i=0; i<fkRegions; i++)
257 target.fTrackHist[i] = dynamic_cast<AliCFContainer*> (fTrackHist[i]->Clone());
260 target.fEventHist = dynamic_cast<AliCFContainer*> (fEventHist->Clone());
263 //____________________________________________________________________
264 Long64_t AliUEHist::Merge(TCollection* list)
266 // Merge a list of AliUEHist objects with this (needed for
268 // Returns the number of merged objects (including this).
276 TIterator* iter = list->MakeIterator();
279 // collections of objects
280 const Int_t kMaxLists = fkRegions+1;
281 TList** lists = new TList*[kMaxLists];
283 for (Int_t i=0; i<kMaxLists; i++)
284 lists[i] = new TList;
287 while ((obj = iter->Next())) {
289 AliUEHist* entry = dynamic_cast<AliUEHist*> (obj);
293 for (Int_t i=0; i<fkRegions; i++)
294 if (entry->fTrackHist[i])
295 lists[i]->Add(entry->fTrackHist[i]);
297 lists[fkRegions]->Add(entry->fEventHist);
301 for (Int_t i=0; i<fkRegions; i++)
303 fTrackHist[i]->Merge(lists[i]);
305 fEventHist->Merge(lists[fkRegions]);
307 for (Int_t i=0; i<kMaxLists; i++)
315 //____________________________________________________________________
316 void AliUEHist::SetBinLimits(AliCFGridSparse* grid)
318 // sets the bin limits in eta and pT defined by fEtaMin/Max, fPtMin/Max
320 if (fEtaMax > fEtaMin)
321 grid->SetRangeUser(0, fEtaMin, fEtaMax);
323 grid->SetRangeUser(1, fPtMin, fPtMax);
326 //____________________________________________________________________
327 void AliUEHist::ResetBinLimits(AliCFGridSparse* grid)
329 // resets all bin limits
331 for (Int_t i=0; i<grid->GetNVar(); i++)
332 if (grid->GetGrid()->GetAxis(i)->TestBit(TAxis::kAxisRange))
333 grid->SetRangeUser(i, 0, -1);
336 //____________________________________________________________________
337 void AliUEHist::CountEmptyBins(AliUEHist::CFStep step, Float_t ptLeadMin, Float_t ptLeadMax)
339 // prints the number of empty bins in the track end event histograms in the given step
344 for (Int_t i=0; i<4; i++)
347 binEnd[i] = fTrackHist[0]->GetNBins(i);
350 if (fEtaMax > fEtaMin)
352 binBegin[0] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(0)->FindBin(fEtaMin);
353 binEnd[0] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(0)->FindBin(fEtaMax);
358 binBegin[1] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(1)->FindBin(fPtMin);
359 binEnd[1] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(1)->FindBin(fPtMax);
362 if (ptLeadMax > ptLeadMin)
364 binBegin[2] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(2)->FindBin(ptLeadMin);
365 binEnd[2] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(2)->FindBin(ptLeadMax);
368 // start from multiplicity 1
369 binBegin[3] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(3)->FindBin(1);
371 for (Int_t region=0; region<fkRegions; region++)
377 for (Int_t i=0; i<4; i++)
378 vars[i] = binBegin[i];
380 AliCFGridSparse* grid = fTrackHist[region]->GetGrid(step);
383 if (grid->GetElement(vars) == 0)
385 Printf("Empty bin at eta=%.2f pt=%.2f pt_lead=%.2f mult=%.1f",
386 grid->GetBinCenter(0, vars[0]),
387 grid->GetBinCenter(1, vars[1]),
388 grid->GetBinCenter(2, vars[2]),
389 grid->GetBinCenter(3, vars[3])
395 for (Int_t i=3; i>0; i--)
397 if (vars[i] == binEnd[i]+1)
399 vars[i] = binBegin[i];
404 if (vars[0] == binEnd[0]+1)
409 Printf("Region %s has %d empty bins (out of %d bins)", GetRegionTitle((Region) region), count, total);
413 //____________________________________________________________________
414 TH1D* AliUEHist::GetUEHist(AliUEHist::CFStep step, AliUEHist::Region region, Float_t ptLeadMin, Float_t ptLeadMax)
416 // Extracts the UE histogram at the given step and in the given region by projection and dividing tracks by events
418 // ptLeadMin, ptLeadMax: Only meaningful for vs. delta phi plot (third axis is ptLead)
419 // Histogram has to be deleted by the caller of the function
422 ResetBinLimits(fTrackHist[region]->GetGrid(step));
423 ResetBinLimits(fEventHist->GetGrid(step));
425 SetBinLimits(fTrackHist[region]->GetGrid(step));
431 tracks = fTrackHist[region]->ShowProjection(2, step);
432 tracks->GetYaxis()->SetTitle(fTrackHist[region]->GetTitle());
433 if (fCombineMinMax && region == kMin)
435 ResetBinLimits(fTrackHist[kMax]->GetGrid(step));
436 SetBinLimits(fTrackHist[kMax]->GetGrid(step));
438 TH1D* tracks2 = fTrackHist[kMax]->ShowProjection(2, step);
439 tracks->Add(tracks2);
441 ResetBinLimits(fTrackHist[kMax]->GetGrid(step));
444 // normalize to get a density (deta dphi)
445 TAxis* axis = fTrackHist[region]->GetGrid(step)->GetAxis(0);
446 Float_t phiRegion = TMath::TwoPi() / 3;
447 if (!fCombineMinMax && region == kMin)
449 Float_t normalization = phiRegion * (axis->GetBinUpEdge(axis->GetLast()) - axis->GetBinLowEdge(axis->GetFirst()));
450 //Printf("Normalization: %f", normalization);
451 tracks->Scale(1.0 / normalization);
453 TH1D* events = fEventHist->ShowProjection(0, step);
454 tracks->Divide(events);
458 fTrackHist[region]->GetGrid(step)->SetRangeUser(2, ptLeadMin, ptLeadMax);
459 tracks = fTrackHist[region]->GetGrid(step)->Project(4);
460 fTrackHist[region]->GetGrid(step)->SetRangeUser(2, 0, -1);
462 // normalize to get a density (deta dphi)
463 TAxis* axis = fTrackHist[region]->GetGrid(step)->GetAxis(0);
464 Float_t normalization = fTrackHist[region]->GetGrid(step)->GetAxis(4)->GetBinWidth(1) * (axis->GetBinUpEdge(axis->GetLast()) - axis->GetBinLowEdge(axis->GetFirst()));
465 //Printf("Normalization: %f", normalization);
466 tracks->Scale(1.0 / normalization);
468 TH1D* events = fEventHist->ShowProjection(0, step);
469 Int_t nEvents = (Int_t) events->Integral(events->FindBin(ptLeadMin), events->FindBin(ptLeadMax));
471 tracks->Scale(1.0 / nEvents);
474 ResetBinLimits(fTrackHist[region]->GetGrid(step));
479 //____________________________________________________________________
480 void AliUEHist::CorrectTracks(CFStep step1, CFStep step2, TH1* trackCorrection, Int_t var1, Int_t var2)
482 // corrects from step1 to step2 by multiplying the tracks with trackCorrection
483 // trackCorrection can be a function of eta (var1 == 0), pT (var1 == 1), leading pT (var1 == 2), multiplicity (var1 == 3), delta phi (var1 == 4)
484 // if var2 >= 0 a two dimension correction is assumed in trackCorrection
486 // if trackCorrection is 0, just copies content from step1 to step2
488 for (Int_t region=0; region<fkRegions; region++)
489 CorrectTracks(step1, step2, region, trackCorrection, var1, var2);
492 //____________________________________________________________________
493 void AliUEHist::CorrectTracks(CFStep step1, CFStep step2, Int_t region, TH1* trackCorrection, Int_t var1, Int_t var2)
496 // see documentation of CorrectTracks above
499 if (!fTrackHist[region])
502 THnSparse* grid = fTrackHist[region]->GetGrid(step1)->GetGrid();
503 THnSparse* target = fTrackHist[region]->GetGrid(step2)->GetGrid();
505 // clear target histogram
508 if (trackCorrection != 0)
510 if (grid->GetAxis(var1)->GetNbins() != trackCorrection->GetNbinsX())
511 AliFatal(Form("Invalid binning (var1): %d %d", grid->GetAxis(var1)->GetNbins(), trackCorrection->GetNbinsX()));
513 if (var2 >= 0 && grid->GetAxis(var2)->GetNbins() != trackCorrection->GetNbinsY())
514 AliFatal(Form("Invalid binning (var2): %d %d", grid->GetAxis(var2)->GetNbins(), trackCorrection->GetNbinsY()));
517 // optimized implementation
518 for (Int_t binIdx = 0; binIdx < grid->GetNbins(); binIdx++)
521 Double_t value = grid->GetBinContent(binIdx, bins);
522 Double_t error = grid->GetBinError(binIdx);
524 if (trackCorrection != 0)
528 value *= trackCorrection->GetBinContent(bins[var1]);
529 error *= trackCorrection->GetBinContent(bins[var1]);
533 value *= trackCorrection->GetBinContent(bins[var1], bins[var2]);
534 error *= trackCorrection->GetBinContent(bins[var1], bins[var2]);
538 target->SetBinContent(bins, value);
539 target->SetBinError(bins, error);
543 //____________________________________________________________________
544 void AliUEHist::CorrectEvents(CFStep step1, CFStep step2, TH1D* eventCorrection, Int_t var)
546 // corrects from step1 to step2 by multiplying the events with eventCorrection
547 // eventCorrection is as function of leading pT (var == 0) or multiplicity (var == 1)
549 // if eventCorrection is 0, just copies content from step1 to step2
551 AliCFGridSparse* grid = fEventHist->GetGrid(step1);
552 AliCFGridSparse* target = fEventHist->GetGrid(step2);
554 // clear target histogram
555 target->GetGrid()->Reset();
557 if (eventCorrection != 0 && grid->GetNBins(var) != eventCorrection->GetNbinsX())
558 AliFatal(Form("Invalid binning: %d %d", grid->GetNBins(var), eventCorrection->GetNbinsX()));
561 for (Int_t x = 1; x <= grid->GetNBins(0); x++)
564 for (Int_t y = 1; y <= grid->GetNBins(1); y++)
568 Double_t value = grid->GetElement(bins);
571 Double_t error = grid->GetElementError(bins);
573 if (eventCorrection != 0)
575 value *= eventCorrection->GetBinContent(bins[var]);
576 error *= eventCorrection->GetBinContent(bins[var]);
579 target->SetElement(bins, value);
580 target->SetElementError(bins, error);
586 //____________________________________________________________________
587 void AliUEHist::Correct(AliUEHist* corrections)
589 // applies the given corrections to extract from the step kCFStepReconstructed all previous steps
591 // in this object the data is expected in the step kCFStepReconstructed
595 // bias due to migration in leading pT (because the leading particle is not reconstructed, and the subleading is used)
596 // extracted as function of leading pT
597 for (Int_t region = 0; region < fkRegions; region++)
599 if (!fTrackHist[region])
602 //TH1D* leadingBias = (TH1D*) corrections->GetBias(kCFStepReconstructed, kCFStepTracked, region, "z"); // from MC
603 TH1D* leadingBias = (TH1D*) GetBias(kCFStepBiasStudy, kCFStepReconstructed, region, "z"); // from data
604 CorrectTracks(kCFStepReconstructed, kCFStepTracked, region, leadingBias, 2);
605 if (region == kMin && fCombineMinMax)
607 CorrectTracks(kCFStepReconstructed, kCFStepTracked, kMax, leadingBias, 2);
613 CorrectEvents(kCFStepReconstructed, kCFStepTracked, 0, 0);
615 // correct with kCFStepTracked --> kCFStepTrackedOnlyPrim
616 TH2D* contamination = corrections->GetTrackingContamination();
617 if (corrections->fContaminationEnhancement)
619 Printf("Applying contamination enhancement");
621 for (Int_t x=1; x<=contamination->GetNbinsX(); x++)
622 for (Int_t y=1; y<=contamination->GetNbinsX(); y++)
623 contamination->SetBinContent(x, y, contamination->GetBinContent(x, y) * corrections->fContaminationEnhancement->GetBinContent(corrections->fContaminationEnhancement->GetXaxis()->FindBin(contamination->GetYaxis()->GetBinCenter(y))));
625 CorrectTracks(kCFStepTracked, kCFStepTrackedOnlyPrim, contamination, 0, 1);
626 CorrectEvents(kCFStepTracked, kCFStepTrackedOnlyPrim, 0, 0);
627 delete contamination;
629 // correct with kCFStepTrackedOnlyPrim --> kCFStepAnaTopology
630 TH2D* efficiencyCorrection = corrections->GetTrackingEfficiencyCorrection();
631 CorrectTracks(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, efficiencyCorrection, 0, 1);
632 CorrectEvents(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, 0, 0);
633 delete efficiencyCorrection;
636 CorrectTracks(kCFStepAnaTopology, kCFStepVertex, 0, -1);
637 CorrectEvents(kCFStepAnaTopology, kCFStepVertex, 0, 0);
639 // vertex correction on the level of events as function of multiplicity, weighting tracks and events with the same factor
640 // practically independent of low pT cut
641 TH1D* vertexCorrection = (TH1D*) corrections->GetEventEfficiency(kCFStepVertex, kCFStepTriggered, 1);
643 // convert stage from true multiplicity to observed multiplicity by simple conversion factor
644 TH1D* vertexCorrectionObs = (TH1D*) vertexCorrection->Clone("vertexCorrection2");
645 vertexCorrectionObs->Reset();
647 TF1* func = new TF1("func", "[1]+[0]/(x-[2])");
648 vertexCorrection->Fit(func, "0", "", 0.8, 4);
650 for (Int_t i=1; i<=vertexCorrectionObs->GetNbinsX(); i++)
652 Float_t xPos = 1.0 / 0.77 * vertexCorrectionObs->GetXaxis()->GetBinCenter(i);
654 vertexCorrectionObs->SetBinContent(i, func->Eval(xPos));
656 vertexCorrectionObs->SetBinContent(i, vertexCorrection->Interpolate(xPos));
660 vertexCorrection->DrawCopy();
661 vertexCorrectionObs->SetLineColor(2);
662 vertexCorrectionObs->DrawCopy("same");
664 CorrectTracks(kCFStepVertex, kCFStepTriggered, vertexCorrectionObs, 3);
665 CorrectEvents(kCFStepVertex, kCFStepTriggered, vertexCorrectionObs, 1);
666 delete vertexCorrectionObs;
667 delete vertexCorrection;
670 CorrectTracks(kCFStepTriggered, kCFStepAll, 0, -1);
671 CorrectEvents(kCFStepTriggered, kCFStepAll, 0, 0);
674 //____________________________________________________________________
675 TH1* AliUEHist::GetTrackEfficiency(CFStep step1, CFStep step2, Int_t axis1, Int_t axis2)
677 // creates a track-level efficiency by dividing step2 by step1
678 // projected to axis1 and axis2 (optional if >= 0)
680 // integrate over regions
681 // cache it for efficiency (usually more than one efficiency is requested)
684 fCache = (AliCFContainer*) fTrackHist[0]->Clone();
685 for (Int_t i = 1; i < fkRegions; i++)
687 fCache->Add(fTrackHist[i]);
690 // reset all limits and set the right ones except those in axis1 and axis2
691 ResetBinLimits(fCache->GetGrid(step1));
692 ResetBinLimits(fCache->GetGrid(step2));
693 if (fEtaMax > fEtaMin && axis1 != 0 && axis2 != 0)
695 fCache->GetGrid(step1)->SetRangeUser(0, fEtaMin, fEtaMax);
696 fCache->GetGrid(step2)->SetRangeUser(0, fEtaMin, fEtaMax);
698 if (fPtMax > fPtMin && axis1 != 1 && axis2 != 1)
700 fCache->GetGrid(step1)->SetRangeUser(1, fPtMin, fPtMax);
701 fCache->GetGrid(step2)->SetRangeUser(1, fPtMin, fPtMax);
709 generated = fCache->Project(axis1, axis2, step1);
710 measured = fCache->Project(axis1, axis2, step2);
714 generated = fCache->Project(axis1, step1);
715 measured = fCache->Project(axis1, step2);
718 // check for bins with less than 100 entries, print warning
725 binEnd[0] = generated->GetNbinsX();
726 binEnd[1] = generated->GetNbinsY();
728 if (fEtaMax > fEtaMin)
732 binBegin[0] = generated->GetXaxis()->FindBin(fEtaMin);
733 binEnd[0] = generated->GetXaxis()->FindBin(fEtaMax);
737 binBegin[1] = generated->GetYaxis()->FindBin(fEtaMin);
738 binEnd[1] = generated->GetYaxis()->FindBin(fEtaMax);
744 // TODO this is just checking up to 15 for now
745 Float_t ptMax = TMath::Min((Float_t) 15., fPtMax);
748 binBegin[0] = generated->GetXaxis()->FindBin(fPtMin);
749 binEnd[0] = generated->GetXaxis()->FindBin(ptMax);
753 binBegin[1] = generated->GetYaxis()->FindBin(fPtMin);
754 binEnd[1] = generated->GetYaxis()->FindBin(ptMax);
762 for (Int_t i=0; i<2; i++)
763 vars[i] = binBegin[i];
765 const Int_t limit = 50;
768 if (generated->GetDimension() == 1 && generated->GetBinContent(vars[0]) < limit)
770 Printf("Empty bin at %s=%.2f (%.2f entries)", generated->GetXaxis()->GetTitle(), generated->GetXaxis()->GetBinCenter(vars[0]), generated->GetBinContent(vars[0]));
773 else if (generated->GetDimension() == 2 && generated->GetBinContent(vars[0], vars[1]) < limit)
775 Printf("Empty bin at %s=%.2f %s=%.2f (%.2f entries)",
776 generated->GetXaxis()->GetTitle(), generated->GetXaxis()->GetBinCenter(vars[0]),
777 generated->GetYaxis()->GetTitle(), generated->GetYaxis()->GetBinCenter(vars[1]),
778 generated->GetBinContent(vars[0], vars[1]));
783 if (vars[1] == binEnd[1]+1)
785 vars[1] = binBegin[1];
789 if (vars[0] == binEnd[0]+1)
794 Printf("Correction has %d empty bins (out of %d bins)", count, total);
796 measured->Divide(measured, generated, 1, 1, "B");
803 //____________________________________________________________________
804 TH1* AliUEHist::GetEventEfficiency(CFStep step1, CFStep step2, Int_t axis1, Int_t axis2, Float_t ptLeadMin, Float_t ptLeadMax)
806 // creates a event-level efficiency by dividing step2 by step1
807 // projected to axis1 and axis2 (optional if >= 0)
809 if (ptLeadMax > ptLeadMin)
811 fEventHist->GetGrid(step1)->SetRangeUser(0, ptLeadMin, ptLeadMax);
812 fEventHist->GetGrid(step2)->SetRangeUser(0, ptLeadMin, ptLeadMax);
820 generated = fEventHist->Project(axis1, axis2, step1);
821 measured = fEventHist->Project(axis1, axis2, step2);
825 generated = fEventHist->Project(axis1, step1);
826 measured = fEventHist->Project(axis1, step2);
829 measured->Divide(measured, generated, 1, 1, "B");
833 if (ptLeadMax > ptLeadMin)
835 fEventHist->GetGrid(step1)->SetRangeUser(0, 0, -1);
836 fEventHist->GetGrid(step2)->SetRangeUser(0, 0, -1);
842 //____________________________________________________________________
843 void AliUEHist::WeightHistogram(TH3* hist1, TH1* hist2)
845 // weights each entry of the 3d histogram hist1 with the 1d histogram hist2
846 // where the matching is done of the z axis of hist1 with the x axis of hist2
848 if (hist1->GetNbinsZ() != hist2->GetNbinsX())
849 AliFatal(Form("Inconsistent binning %d %d", hist1->GetNbinsZ(), hist2->GetNbinsX()));
851 for (Int_t x=1; x<=hist1->GetNbinsX(); x++)
853 for (Int_t y=1; y<=hist1->GetNbinsY(); y++)
855 for (Int_t z=1; z<=hist1->GetNbinsZ(); z++)
857 if (hist2->GetBinContent(z) > 0)
859 hist1->SetBinContent(x, y, z, hist1->GetBinContent(x, y, z) / hist2->GetBinContent(z));
860 hist1->SetBinError(x, y, z, hist1->GetBinError(x, y, z) / hist2->GetBinContent(z));
864 hist1->SetBinContent(x, y, z, 0);
865 hist1->SetBinError(x, y, z, 0);
872 //____________________________________________________________________
873 TH1* AliUEHist::GetBias(CFStep step1, CFStep step2, Int_t region, const char* axis, Float_t leadPtMin, Float_t leadPtMax)
875 // extracts the track-level bias (integrating out the multiplicity) between two steps (dividing step2 by step1)
876 // in the given region (sum over all regions is calculated if region == -1)
877 // done by weighting the track-level distribution with the number of events as function of leading pT
878 // and then calculating the ratio between the distributions
879 // projected to axis which is a TH3::Project3D string, e.g. "x", or "yx"
880 // no projection is done if axis == 0
882 AliCFContainer* tmp = 0;
886 tmp = (AliCFContainer*) fTrackHist[0]->Clone();
887 for (Int_t i = 1; i < fkRegions; i++)
889 tmp->Add(fTrackHist[i]);
891 else if (region == kMin && fCombineMinMax)
893 tmp = (AliCFContainer*) fTrackHist[kMin]->Clone();
894 tmp->Add(fTrackHist[kMax]);
897 tmp = fTrackHist[region];
899 ResetBinLimits(tmp->GetGrid(step1));
900 ResetBinLimits(fEventHist->GetGrid(step1));
901 SetBinLimits(tmp->GetGrid(step1));
903 ResetBinLimits(tmp->GetGrid(step2));
904 ResetBinLimits(fEventHist->GetGrid(step2));
905 SetBinLimits(tmp->GetGrid(step2));
907 TH1D* events1 = fEventHist->Project(0, step1);
908 TH3D* hist1 = tmp->Project(0, 1, 2, step1);
909 WeightHistogram(hist1, events1);
911 TH1D* events2 = fEventHist->Project(0, step2);
912 TH3D* hist2 = tmp->Project(0, 1, 2, step2);
913 WeightHistogram(hist2, events2);
915 TH1* generated = hist1;
916 TH1* measured = hist2;
920 if (leadPtMax > leadPtMin)
922 hist1->GetZaxis()->SetRangeUser(leadPtMin, leadPtMax);
923 hist2->GetZaxis()->SetRangeUser(leadPtMin, leadPtMax);
926 if (fEtaMax > fEtaMin && !TString(axis).Contains("x"))
928 hist1->GetXaxis()->SetRangeUser(fEtaMin, fEtaMax);
929 hist2->GetXaxis()->SetRangeUser(fEtaMin, fEtaMax);
931 if (fPtMax > fPtMin && !TString(axis).Contains("y"))
933 hist1->GetYaxis()->SetRangeUser(fPtMin, fPtMax);
934 hist2->GetYaxis()->SetRangeUser(fPtMin, fPtMax);
937 generated = hist1->Project3D(axis);
938 measured = hist2->Project3D(axis);
940 // delete hists here if projection has been done
945 measured->Divide(generated);
951 ResetBinLimits(tmp->GetGrid(step1));
952 ResetBinLimits(tmp->GetGrid(step2));
954 if ((region == -1) || (region == kMin && fCombineMinMax))
960 //____________________________________________________________________
961 TH2D* AliUEHist::GetTrackingEfficiency()
963 // extracts the tracking efficiency by calculating the efficiency from step kCFStepAnaTopology to kCFStepTrackedOnlyPrim
964 // integrates over the regions and all other variables than pT and eta to increase the statistics
966 // returned histogram has to be deleted by the user
968 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepAnaTopology, kCFStepTrackedOnlyPrim, 0, 1));
971 //____________________________________________________________________
972 TH1D* AliUEHist::GetTrackingEfficiency(Int_t axis)
974 // extracts the tracking efficiency by calculating the efficiency from step kCFStepAnaTopology to kCFStepTrackedOnlyPrim
975 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
977 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepAnaTopology, kCFStepTrackedOnlyPrim, axis));
980 //____________________________________________________________________
981 TH2D* AliUEHist::GetTrackingCorrection()
983 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
984 // integrates over the regions and all other variables than pT and eta to increase the statistics
986 // returned histogram has to be deleted by the user
988 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTracked, kCFStepAnaTopology, 0, 1));
991 //____________________________________________________________________
992 TH1D* AliUEHist::GetTrackingCorrection(Int_t axis)
994 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
995 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
997 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepTracked, kCFStepAnaTopology, axis));
1000 //____________________________________________________________________
1001 TH2D* AliUEHist::GetTrackingEfficiencyCorrection()
1003 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1004 // integrates over the regions and all other variables than pT and eta to increase the statistics
1006 // returned histogram has to be deleted by the user
1008 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, 0, 1));
1011 //____________________________________________________________________
1012 TH1D* AliUEHist::GetTrackingEfficiencyCorrection(Int_t axis)
1014 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1015 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
1017 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, axis));
1020 //____________________________________________________________________
1021 TH2D* AliUEHist::GetTrackingContamination()
1023 // extracts the tracking contamination by secondaries by calculating the efficiency from step kCFStepTrackedOnlyPrim to kCFStepTracked
1024 // integrates over the regions and all other variables than pT and eta to increase the statistics
1026 // returned histogram has to be deleted by the user
1028 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTracked, kCFStepTrackedOnlyPrim, 0, 1));
1031 //____________________________________________________________________
1032 TH1D* AliUEHist::GetTrackingContamination(Int_t axis)
1034 // extracts the tracking contamination by secondaries by calculating the efficiency from step kCFStepTrackedOnlyPrim to kCFStepTracked
1035 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
1037 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepTracked, kCFStepTrackedOnlyPrim, axis));
1040 //____________________________________________________________________
1041 const char* AliUEHist::GetRegionTitle(Region region)
1043 // returns the name of the given region
1052 return (fCombineMinMax) ? "Transverse" : "Min";
1060 //____________________________________________________________________
1061 const char* AliUEHist::GetStepTitle(CFStep step)
1063 // returns the name of the given step
1068 return "All events";
1069 case kCFStepTriggered:
1072 return "Primary Vertex";
1073 case kCFStepAnaTopology:
1074 return "Required analysis topology";
1075 case kCFStepTrackedOnlyPrim:
1076 return "Tracked (matched MC, only primaries)";
1077 case kCFStepTracked:
1078 return "Tracked (matched MC, all)";
1079 case kCFStepReconstructed:
1080 return "Reconstructed";
1081 case kCFStepRealLeading:
1082 return "Correct leading particle identified";
1083 case kCFStepBiasStudy:
1084 return "Bias study applying tracking efficiency";
1085 case kCFStepBiasStudy2:
1086 return "Bias study applying tracking efficiency in two steps";