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"
41 const Int_t AliUEHist::fgkCFSteps = 10;
43 AliUEHist::AliUEHist(const char* reqHist) :
47 fTrackHistEfficiency(0),
56 fContaminationEnhancement(0),
59 fHistogramType(reqHist)
63 for (UInt_t i=0; i<fkRegions; i++)
66 if (strlen(reqHist) == 0)
69 AliLog::SetClassDebugLevel("AliCFContainer", -1);
70 AliLog::SetClassDebugLevel("AliCFGridSparse", -3);
72 const char* title = "";
75 Int_t nTrackVars = 4; // eta vs pT vs pT,lead (vs delta phi) vs multiplicity
77 Double_t* trackBins[6];
78 const char* trackAxisTitle[6];
82 Double_t etaBins[20+1];
83 for (Int_t i=0; i<=iTrackBin[0]; i++)
84 etaBins[i] = -1.0 + 0.1 * i;
85 trackBins[0] = etaBins;
86 trackAxisTitle[0] = "#eta";
89 const Int_t kNDeltaEtaBins = 40;
90 Double_t deltaEtaBins[kNDeltaEtaBins+1];
91 for (Int_t i=0; i<=kNDeltaEtaBins; i++)
92 deltaEtaBins[i] = -2.0 + 0.1 * i;
96 Double_t pTBins[] = {0.15, 0.2, 0.3, 0.4, 0.5, 0.75, 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, 15.0, 20.0};
97 trackBins[1] = pTBins;
98 trackAxisTitle[1] = "p_{T} (GeV/c)";
101 const Int_t kNLeadingpTBins = 100;
102 Double_t leadingpTBins[kNLeadingpTBins+1];
103 for (Int_t i=0; i<=kNLeadingpTBins; i++)
104 leadingpTBins[i] = 0.5 * i;
107 const Int_t kNLeadingpTBins2 = 9;
108 Double_t leadingpTBins2[] = { 0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 15.0, 20.0 };
110 // phi,lead; this binning starts at -pi/2 and is modulo 3
111 const Int_t kNLeadingPhiBins = 72;
112 Double_t leadingPhiBins[kNLeadingPhiBins+1];
113 for (Int_t i=0; i<=kNLeadingPhiBins; i++)
114 leadingPhiBins[i] = -TMath::Pi() / 2 + 1.0 / kNLeadingPhiBins * i * TMath::TwoPi();
117 const Int_t kNMultiplicityBins = 15;
118 Double_t multiplicityBins[kNMultiplicityBins+1];
119 for (Int_t i=0; i<=kNMultiplicityBins; i++)
120 multiplicityBins[i] = -0.5 + i;
121 multiplicityBins[kNMultiplicityBins] = 200;
123 trackBins[3] = multiplicityBins;
124 iTrackBin[3] = kNMultiplicityBins;
125 trackAxisTitle[3] = "multiplicity";
128 const Int_t kNCentralityBins = 5 + 1 + 9;
129 Double_t centralityBins[] = { 0, 1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.1 };
132 const Int_t kNSpeciesBins = 4; // pi, K, p, rest
133 Double_t speciesBins[] = { -0.5, 0.5, 1.5, 2.5, 3.5 };
136 const Int_t kNVertexBins = 7;
137 Double_t vertexBins[] = { -7, -5, -3, -1, 1, 3, 5, 7 };
139 // selection depending on requested histogram
140 Int_t axis = -1; // 0 = pT,lead, 1 = phi,lead
141 if (strcmp(reqHist, "NumberDensitypT") == 0)
144 title = "d^{2}N_{ch}/d#phid#eta";
146 else if (strcmp(reqHist, "NumberDensityPhi") == 0)
149 title = "d^{2}N_{ch}/d#phid#eta";
151 else if (strcmp(reqHist, "NumberDensityPhiCentrality") == 0)
154 title = "d^{2}N_{ch}/d#phid#eta";
156 else if (strcmp(reqHist, "SumpT") == 0)
159 title = "d^{2}#Sigma p_{T}/d#phid#eta";
162 AliFatal(Form("Invalid histogram requested: %s", reqHist));
164 UInt_t initRegions = fkRegions;
166 Bool_t useVtxAxis = kFALSE;
170 trackBins[2] = leadingpTBins;
171 iTrackBin[2] = kNLeadingpTBins;
172 trackAxisTitle[2] = "leading p_{T} (GeV/c)";
180 iTrackBin[2] = kNLeadingpTBins2;
181 trackBins[2] = leadingpTBins2;
182 trackAxisTitle[2] = "leading p_{T} (GeV/c)";
184 iTrackBin[4] = kNLeadingPhiBins;
185 trackBins[4] = leadingPhiBins;
186 trackAxisTitle[4] = "#Delta #phi w.r.t. leading track";
193 iTrackBin[0] = kNDeltaEtaBins;
194 trackBins[0] = deltaEtaBins;
195 trackAxisTitle[0] = "#Delta#eta";
197 iTrackBin[2] = kNLeadingpTBins2;
198 trackBins[2] = leadingpTBins2;
199 trackAxisTitle[2] = "leading p_{T} (GeV/c)";
201 trackBins[3] = centralityBins;
202 iTrackBin[3] = kNCentralityBins;
203 trackAxisTitle[3] = "centrality";
205 iTrackBin[4] = kNLeadingPhiBins;
206 trackBins[4] = leadingPhiBins;
207 trackAxisTitle[4] = "#Delta#phi (rad.)";
212 iTrackBin[5] = kNVertexBins;
213 trackBins[5] = vertexBins;
214 trackAxisTitle[5] = "z-vtx (cm)";
218 for (UInt_t i=0; i<initRegions; i++)
220 if (strcmp(reqHist, "NumberDensityPhiCentrality") == 0)
221 fTrackHist[i] = new AliTHn(Form("fTrackHist_%d", i), title, fgkCFSteps, nTrackVars, iTrackBin);
223 fTrackHist[i] = new AliCFContainer(Form("fTrackHist_%d", i), title, fgkCFSteps, nTrackVars, iTrackBin);
225 for (Int_t j=0; j<nTrackVars; j++)
227 fTrackHist[i]->SetBinLimits(j, trackBins[j]);
228 fTrackHist[i]->SetVarTitle(j, trackAxisTitle[j]);
231 SetStepNames(fTrackHist[i]);
235 Int_t nEventVars = 2;
238 // track 3rd and 4th axis --> event 1st and 2nd axis
239 iEventBin[0] = iTrackBin[2];
240 iEventBin[1] = iTrackBin[3];
242 // plus track 5th axis (in certain cases)
243 if (axis == 2 && useVtxAxis)
246 iEventBin[2] = iTrackBin[5];
249 fEventHist = new AliCFContainer("fEventHist", title, fgkCFSteps, nEventVars, iEventBin);
251 fEventHist->SetBinLimits(0, trackBins[2]);
252 fEventHist->SetVarTitle(0, trackAxisTitle[2]);
254 fEventHist->SetBinLimits(1, trackBins[3]);
255 fEventHist->SetVarTitle(1, trackAxisTitle[3]);
257 if (axis == 2 && useVtxAxis)
259 fEventHist->SetBinLimits(2, trackBins[5]);
260 fEventHist->SetVarTitle(2, trackAxisTitle[5]);
263 SetStepNames(fEventHist);
265 iTrackBin[2] = kNSpeciesBins;
267 fTrackHistEfficiency = new AliCFContainer("fTrackHistEfficiency", "Tracking efficiency", 3, 4, iTrackBin);
268 fTrackHistEfficiency->SetBinLimits(0, trackBins[0]);
269 fTrackHistEfficiency->SetVarTitle(0, trackAxisTitle[0]);
270 fTrackHistEfficiency->SetBinLimits(1, trackBins[1]);
271 fTrackHistEfficiency->SetVarTitle(1, trackAxisTitle[1]);
272 fTrackHistEfficiency->SetBinLimits(2, speciesBins);
273 fTrackHistEfficiency->SetVarTitle(2, "particle species");
274 fTrackHistEfficiency->SetBinLimits(3, trackBins[3]);
275 fTrackHistEfficiency->SetVarTitle(3, trackAxisTitle[3]);
278 //_____________________________________________________________________________
279 AliUEHist::AliUEHist(const AliUEHist &c) :
283 fTrackHistEfficiency(0),
292 fContaminationEnhancement(0),
298 // AliUEHist copy constructor
301 ((AliUEHist &) c).Copy(*this);
304 //____________________________________________________________________
305 void AliUEHist::SetStepNames(AliCFContainer* container)
307 // sets the names of the correction steps
309 for (Int_t i=0; i<fgkCFSteps; i++)
310 container->SetStepTitle(i, GetStepTitle((CFStep) i));
313 //____________________________________________________________________
314 AliUEHist::~AliUEHist()
318 for (UInt_t i=0; i<fkRegions; i++)
322 delete fTrackHist[i];
333 if (fTrackHistEfficiency)
335 delete fTrackHistEfficiency;
336 fTrackHistEfficiency = 0;
346 //____________________________________________________________________
347 AliUEHist &AliUEHist::operator=(const AliUEHist &c)
349 // assigment operator
352 ((AliUEHist &) c).Copy(*this);
357 //____________________________________________________________________
358 void AliUEHist::Copy(TObject& c) const
362 AliUEHist& target = (AliUEHist &) c;
364 for (UInt_t i=0; i<fkRegions; i++)
366 target.fTrackHist[i] = dynamic_cast<AliCFContainer*> (fTrackHist[i]->Clone());
369 target.fEventHist = dynamic_cast<AliCFContainer*> (fEventHist->Clone());
371 if (fTrackHistEfficiency)
372 target.fTrackHistEfficiency = dynamic_cast<AliCFContainer*> (fTrackHistEfficiency->Clone());
374 target.fEtaMin = fEtaMin;
375 target.fEtaMax = fEtaMax;
376 target.fPtMin = fPtMin;
377 target.fPtMax = fPtMax;
378 target.fCentralityMin = fCentralityMin;
379 target.fCentralityMax = fCentralityMax;
380 target.fZVtxMin = fZVtxMin;
381 target.fZVtxMax = fZVtxMax;
383 if (fContaminationEnhancement)
384 target.fContaminationEnhancement = dynamic_cast<TH1F*> (fContaminationEnhancement->Clone());
386 target.fCombineMinMax = fCombineMinMax;
387 target.fHistogramType = fHistogramType;
390 //____________________________________________________________________
391 Long64_t AliUEHist::Merge(TCollection* list)
393 // Merge a list of AliUEHist objects with this (needed for
395 // Returns the number of merged objects (including this).
403 TIterator* iter = list->MakeIterator();
406 // collections of objects
407 const UInt_t kMaxLists = fkRegions+2;
408 TList** lists = new TList*[kMaxLists];
410 for (UInt_t i=0; i<kMaxLists; i++)
411 lists[i] = new TList;
414 while ((obj = iter->Next())) {
416 AliUEHist* entry = dynamic_cast<AliUEHist*> (obj);
420 for (UInt_t i=0; i<fkRegions; i++)
421 if (entry->fTrackHist[i])
422 lists[i]->Add(entry->fTrackHist[i]);
424 lists[fkRegions]->Add(entry->fEventHist);
425 lists[fkRegions+1]->Add(entry->fTrackHistEfficiency);
429 for (UInt_t i=0; i<fkRegions; i++)
431 fTrackHist[i]->Merge(lists[i]);
433 fEventHist->Merge(lists[fkRegions]);
434 fTrackHistEfficiency->Merge(lists[fkRegions+1]);
436 for (UInt_t i=0; i<kMaxLists; i++)
444 //____________________________________________________________________
445 void AliUEHist::SetBinLimits(AliCFGridSparse* grid)
447 // sets the bin limits in eta and pT defined by fEtaMin/Max, fPtMin/Max
449 if (fEtaMax > fEtaMin)
450 grid->SetRangeUser(0, fEtaMin, fEtaMax);
452 grid->SetRangeUser(1, fPtMin, fPtMax);
455 //____________________________________________________________________
456 void AliUEHist::ResetBinLimits(AliCFGridSparse* grid)
458 // resets all bin limits
460 for (Int_t i=0; i<grid->GetNVar(); i++)
461 if (grid->GetGrid()->GetAxis(i)->TestBit(TAxis::kAxisRange))
462 grid->SetRangeUser(i, 0, -1);
465 //____________________________________________________________________
466 void AliUEHist::CountEmptyBins(AliUEHist::CFStep step, Float_t ptLeadMin, Float_t ptLeadMax)
468 // prints the number of empty bins in the track end event histograms in the given step
473 for (Int_t i=0; i<4; i++)
476 binEnd[i] = fTrackHist[0]->GetNBins(i);
479 if (fEtaMax > fEtaMin)
481 binBegin[0] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(0)->FindBin(fEtaMin);
482 binEnd[0] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(0)->FindBin(fEtaMax);
487 binBegin[1] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(1)->FindBin(fPtMin);
488 binEnd[1] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(1)->FindBin(fPtMax);
491 if (ptLeadMax > ptLeadMin)
493 binBegin[2] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(2)->FindBin(ptLeadMin);
494 binEnd[2] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(2)->FindBin(ptLeadMax);
497 // start from multiplicity 1
498 binBegin[3] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(3)->FindBin(1);
500 for (UInt_t region=0; region<fkRegions; region++)
506 for (Int_t i=0; i<4; i++)
507 vars[i] = binBegin[i];
509 AliCFGridSparse* grid = fTrackHist[region]->GetGrid(step);
512 if (grid->GetElement(vars) == 0)
514 Printf("Empty bin at eta=%.2f pt=%.2f pt_lead=%.2f mult=%.1f",
515 grid->GetBinCenter(0, vars[0]),
516 grid->GetBinCenter(1, vars[1]),
517 grid->GetBinCenter(2, vars[2]),
518 grid->GetBinCenter(3, vars[3])
524 for (Int_t i=3; i>0; i--)
526 if (vars[i] == binEnd[i]+1)
528 vars[i] = binBegin[i];
533 if (vars[0] == binEnd[0]+1)
538 Printf("Region %s has %d empty bins (out of %d bins)", GetRegionTitle((Region) region), count, total);
542 //____________________________________________________________________
543 TH1* AliUEHist::GetUEHist(AliUEHist::CFStep step, AliUEHist::Region region, Float_t ptLeadMin, Float_t ptLeadMax, Int_t multBinBegin, Int_t multBinEnd, Int_t twoD, Bool_t etaNorm)
545 // Extracts the UE histogram at the given step and in the given region by projection and dividing tracks by events
547 // ptLeadMin, ptLeadMax: Only meaningful for vs. delta phi plot (third axis is ptLead)
548 // Histogram has to be deleted by the caller of the function
550 // twoD: 0: 1D histogram as function of phi
551 // 1: 2D histogram, deltaphi, deltaeta
552 // 10: 1D histogram, within |deltaeta| < 0.8
553 // 11: 1D histogram, within 0.8 < |deltaeta| < 1.6
555 // etaNorm: if kTRUE (default), the distributions are divided by the area in delta eta
558 ResetBinLimits(fTrackHist[region]->GetGrid(step));
559 ResetBinLimits(fEventHist->GetGrid(step));
561 SetBinLimits(fTrackHist[region]->GetGrid(step));
564 if (fZVtxMax > fZVtxMin)
566 Printf("Using z-vtx range %f --> %f", fZVtxMin, fZVtxMax);
567 fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(5)->SetRangeUser(fZVtxMin, fZVtxMax);
568 fEventHist->GetGrid(step)->GetGrid()->GetAxis(2)->SetRangeUser(fZVtxMin, fZVtxMax);
575 tracks = fTrackHist[region]->ShowProjection(2, step);
576 tracks->GetYaxis()->SetTitle(fTrackHist[region]->GetTitle());
577 if (fCombineMinMax && region == kMin)
579 ResetBinLimits(fTrackHist[kMax]->GetGrid(step));
580 SetBinLimits(fTrackHist[kMax]->GetGrid(step));
582 TH1D* tracks2 = fTrackHist[kMax]->ShowProjection(2, step);
583 tracks->Add(tracks2);
585 ResetBinLimits(fTrackHist[kMax]->GetGrid(step));
588 // normalize to get a density (deta dphi)
589 TAxis* axis = fTrackHist[region]->GetGrid(step)->GetAxis(0);
590 Float_t phiRegion = TMath::TwoPi() / 3;
591 if (!fCombineMinMax && region == kMin)
593 Float_t normalization = phiRegion;
595 normalization *= (axis->GetBinUpEdge(axis->GetLast()) - axis->GetBinLowEdge(axis->GetFirst()));
596 //Printf("Normalization: %f", normalization);
597 tracks->Scale(1.0 / normalization);
599 TH1D* events = fEventHist->ShowProjection(0, step);
600 tracks->Divide(events);
604 if (multBinEnd >= multBinBegin)
606 Printf("Using multiplicity range %d --> %d", multBinBegin, multBinEnd);
607 fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(3)->SetRange(multBinBegin, multBinEnd);
608 fEventHist->GetGrid(step)->GetGrid()->GetAxis(1)->SetRange(multBinBegin, multBinEnd);
611 Int_t firstBin = fTrackHist[region]->GetAxis(2, step)->FindBin(ptLeadMin);
612 Int_t lastBin = fTrackHist[region]->GetAxis(2, step)->FindBin(ptLeadMax);
614 Printf("Using leading pT range %d --> %d", firstBin, lastBin);
616 fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(2)->SetRange(firstBin, lastBin);
619 tracks = (TH1D*) fTrackHist[region]->GetGrid(step)->Project(4);
621 tracks = (TH1D*) fTrackHist[region]->GetGrid(step)->Project(4, 0);
623 Printf("Calculated histogram --> %f tracks", tracks->Integral());
624 fTrackHist[region]->GetGrid(step)->SetRangeUser(2, 0, -1);
626 if (twoD == 10 || twoD == 11)
628 Float_t etaLimit = 0.8;
631 tracks = (TH1D*) ((TH2*) tracks)->ProjectionX("proj", tracks->GetYaxis()->FindBin(-etaLimit + 0.01), tracks->GetYaxis()->FindBin(etaLimit - 0.01))->Clone();
633 // TODO calculate acc with 2 * (deta - 0.5 * deta*deta / 1.6)
634 tracks->Scale(1. / 0.75);
638 TH1D* tracksTmp1 = (TH1D*) ((TH2*) tracks)->ProjectionX("proj1", tracks->GetYaxis()->FindBin(-etaLimit * 2 + 0.01), tracks->GetYaxis()->FindBin(-etaLimit - 0.01))->Clone();
639 TH1D* tracksTmp2 = ((TH2*) tracks)->ProjectionX("proj2", tracks->GetYaxis()->FindBin(etaLimit + 0.01), tracks->GetYaxis()->FindBin(2 * etaLimit - 0.01));
641 tracksTmp1->Add(tracksTmp2);
647 tracks->Scale(1. / 0.25);
651 // normalize to get a density (deta dphi)
652 // TODO normalization may be off for 2d histogram
653 Float_t normalization = fTrackHist[region]->GetGrid(step)->GetAxis(4)->GetBinWidth(1);
657 TAxis* axis = fTrackHist[region]->GetGrid(step)->GetAxis(0);
658 if (strcmp(axis->GetTitle(), "#eta") == 0)
660 Printf("Normalizing using eta-axis range");
661 normalization *= axis->GetBinUpEdge(axis->GetLast()) - axis->GetBinLowEdge(axis->GetFirst());
665 Printf("Normalizing assuming accepted range of |eta| < 0.8");
666 normalization *= 0.8 * 2;
670 //Printf("Normalization: %f", normalization);
671 tracks->Scale(1.0 / normalization);
673 // NOTE fEventHist contains the number of events for the underlying event analysis and the number of trigger particles for the azimuthal correlation analysis. In the latter case the naming is therefore somewhat misleading!
674 TH1D* events = fEventHist->ShowProjection(0, step);
675 Int_t nEvents = (Int_t) events->Integral(firstBin, lastBin);
676 Printf("Calculated histogram --> %d events", nEvents);
679 tracks->Scale(1.0 / nEvents);
684 ResetBinLimits(fTrackHist[region]->GetGrid(step));
685 ResetBinLimits(fEventHist->GetGrid(step));
690 //____________________________________________________________________
691 TH1* AliUEHist::GetPtHist(CFStep step, Region region, Float_t ptLeadMin, Float_t ptLeadMax, Int_t multBinBegin, Int_t multBinEnd, Float_t phiMin, Float_t phiMax, Float_t etaMin, Float_t etaMax, Bool_t skipPhiNormalization)
693 // returns a histogram projected to pT,assoc with the provided cuts
696 ResetBinLimits(fTrackHist[region]->GetGrid(step));
697 ResetBinLimits(fEventHist->GetGrid(step));
701 // the efficiency to have find an event depends on leading pT and this is not corrected for because anyway per bin we calculate tracks over events
702 // therefore the number density must be calculated here per leading pT bin and then summed
704 if (multBinEnd > multBinBegin)
705 Printf("Using multiplicity range %d --> %d", multBinBegin, multBinEnd);
706 fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(3)->SetRange(multBinBegin, multBinEnd);
707 fEventHist->GetGrid(step)->GetGrid()->GetAxis(1)->SetRange(multBinBegin, multBinEnd);
709 fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(0)->SetRangeUser(etaMin, etaMax);
710 fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(4)->SetRangeUser(phiMin, phiMax);
712 // get real phi cuts due to binning
713 Float_t phiMinReal = fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(4)->GetBinLowEdge(fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(4)->GetFirst());
714 Float_t phiMaxReal = fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(4)->GetBinUpEdge(fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(4)->GetLast());
715 Printf("phi min = %.2f and max = %.2f requested; due to binning range will be from %.2f to %.2f, i.e. a %.0f%% larger window", phiMin, phiMax, phiMinReal, phiMaxReal, (phiMaxReal - phiMinReal) / (phiMax - phiMin) * 100 - 100);
717 Int_t firstBin = fTrackHist[region]->GetAxis(2, step)->FindBin(ptLeadMin);
718 Int_t lastBin = fTrackHist[region]->GetAxis(2, step)->FindBin(ptLeadMax);
720 TH1D* events = fEventHist->ShowProjection(0, step);
722 for (Int_t bin=firstBin; bin<=lastBin; bin++)
724 fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(2)->SetRange(bin, bin);
726 // project to pT,assoc
727 TH1D* tracksTmp = (TH1D*) fTrackHist[region]->GetGrid(step)->Project(1);
729 Printf("Calculated histogram in bin %d --> %f tracks", bin, tracksTmp->Integral());
730 fTrackHist[region]->GetGrid(step)->SetRangeUser(2, 0, -1);
732 // normalize to get a density (deta dphi)
733 Float_t normalization = 1;
734 TAxis* axis = fTrackHist[region]->GetGrid(step)->GetAxis(0);
735 if (strcmp(axis->GetTitle(), "#eta") == 0)
737 Printf("Normalizing using eta-axis range");
738 normalization *= axis->GetBinUpEdge(axis->GetLast()) - axis->GetBinLowEdge(axis->GetFirst());
742 Printf("Normalizating assuming accepted range of |eta| < 0.8");
743 normalization *= 0.8 * 2;
747 if (!skipPhiNormalization)
748 normalization *= phiMaxReal - phiMinReal;
750 //Printf("Normalization: %f", normalization);
751 tracksTmp->Scale(1.0 / normalization);
753 // and now dpT (bins have different width)
754 for (Int_t i=1; i<=tracksTmp->GetNbinsX(); i++)
756 tracksTmp->SetBinContent(i, tracksTmp->GetBinContent(i) / tracksTmp->GetXaxis()->GetBinWidth(i));
757 tracksTmp->SetBinError (i, tracksTmp->GetBinError(i) / tracksTmp->GetXaxis()->GetBinWidth(i));
760 Int_t nEvents = (Int_t) events->GetBinContent(bin);
762 tracksTmp->Scale(1.0 / nEvents);
763 Printf("Calculated histogram in bin %d --> %d events", bin, nEvents);
769 tracks->Add(tracksTmp);
776 ResetBinLimits(fTrackHist[region]->GetGrid(step));
777 ResetBinLimits(fEventHist->GetGrid(step));
782 void AliUEHist::MultiplyHistograms(THnSparse* grid, THnSparse* target, TH1* histogram, Int_t var1, Int_t var2)
784 // multiplies <grid> with <histogram> and put the result in <target>
785 // <grid> has usually more dimensions than histogram. The axis which are used to choose the value
786 // from <histogram> are given in <var1> and <var2>
788 // if <histogram> is 0, just copies content from step1 to step2
790 // clear target histogram
795 if (grid->GetAxis(var1)->GetNbins() != histogram->GetNbinsX())
796 AliFatal(Form("Invalid binning (var1): %d %d", grid->GetAxis(var1)->GetNbins(), histogram->GetNbinsX()));
798 if (var2 >= 0 && grid->GetAxis(var2)->GetNbins() != histogram->GetNbinsY())
799 AliFatal(Form("Invalid binning (var2): %d %d", grid->GetAxis(var2)->GetNbins(), histogram->GetNbinsY()));
802 if (grid->GetNdimensions() > 6)
803 AliFatal("Too many dimensions in THnSparse");
807 // optimized implementation
808 for (Int_t binIdx = 0; binIdx < grid->GetNbins(); binIdx++)
810 Double_t value = grid->GetBinContent(binIdx, bins);
811 Double_t error = grid->GetBinError(binIdx);
817 value *= histogram->GetBinContent(bins[var1]);
818 error *= histogram->GetBinContent(bins[var1]);
822 value *= histogram->GetBinContent(bins[var1], bins[var2]);
823 error *= histogram->GetBinContent(bins[var1], bins[var2]);
827 target->SetBinContent(bins, value);
828 target->SetBinError(bins, error);
832 //____________________________________________________________________
833 void AliUEHist::CorrectTracks(CFStep step1, CFStep step2, TH1* trackCorrection, Int_t var1, Int_t var2)
835 // corrects from step1 to step2 by multiplying the tracks with trackCorrection
836 // trackCorrection can be a function of eta (var1 == 0), pT (var1 == 1), leading pT (var1 == 2), multiplicity (var1 == 3), delta phi (var1 == 4)
837 // if var2 >= 0 a two dimension correction is assumed in trackCorrection
839 // if trackCorrection is 0, just copies content from step1 to step2
841 for (UInt_t region=0; region<fkRegions; region++)
842 CorrectTracks(step1, step2, region, trackCorrection, var1, var2);
845 //____________________________________________________________________
846 void AliUEHist::CorrectTracks(CFStep step1, CFStep step2, Int_t region, TH1* trackCorrection, Int_t var1, Int_t var2)
849 // see documentation of CorrectTracks above
852 if (!fTrackHist[region])
855 THnSparse* grid = fTrackHist[region]->GetGrid(step1)->GetGrid();
856 THnSparse* target = fTrackHist[region]->GetGrid(step2)->GetGrid();
858 MultiplyHistograms(grid, target, trackCorrection, var1, var2);
860 Printf("AliUEHist::CorrectTracks: Corrected from %f to %f entries. Correction histogram: %f entries (integral: %f)", grid->GetEntries(), target->GetEntries(), (trackCorrection) ? trackCorrection->GetEntries() : -1.0, (trackCorrection) ? trackCorrection->Integral() : -1.0);
863 //____________________________________________________________________
864 void AliUEHist::CorrectEvents(CFStep step1, CFStep step2, TH1* eventCorrection, Int_t var1, Int_t var2)
866 // corrects from step1 to step2 by multiplying the events with eventCorrection
867 // eventCorrection is as function of leading pT (var == 0) or multiplicity (var == 1)
869 // if eventCorrection is 0, just copies content from step1 to step2
871 AliCFGridSparse* grid = fEventHist->GetGrid(step1);
872 AliCFGridSparse* target = fEventHist->GetGrid(step2);
874 MultiplyHistograms(grid->GetGrid(), target->GetGrid(), eventCorrection, var1, var2);
876 Printf("AliUEHist::CorrectEvents: Corrected from %f to %f entries. Correction histogram: %f entries (integral: %f)", grid->GetEntries(), target->GetEntries(), (eventCorrection) ? eventCorrection->GetEntries() : -1.0, (eventCorrection) ? eventCorrection->Integral() : -1.0);
879 //____________________________________________________________________
880 void AliUEHist::Correct(AliUEHist* corrections)
882 // applies the given corrections to extract from the step kCFStepReconstructed all previous steps
884 // in this object the data is expected in the step kCFStepReconstructed
886 if (fHistogramType.Length() == 0)
888 Printf("W-AliUEHist::Correct: fHistogramType not defined. Guessing histogram type...");
889 if (fTrackHist[kToward]->GetNVar() < 5)
891 if (strcmp(fTrackHist[kToward]->GetTitle(), "d^{2}N_{ch}/d#phid#eta") == 0)
892 fHistogramType = "NumberDensitypT";
893 else if (strcmp(fTrackHist[kToward]->GetTitle(), "d^{2}#Sigma p_{T}/d#phid#eta") == 0)
894 fHistogramType = "SumpT";
896 else if (fTrackHist[kToward]->GetNVar() == 5)
898 if (strcmp(fTrackHist[kToward]->GetGrid(0)->GetGrid()->GetAxis(3)->GetTitle(), "multiplicity") == 0)
899 fHistogramType = "NumberDensityPhi";
900 else if (strcmp(fTrackHist[kToward]->GetGrid(0)->GetGrid()->GetAxis(3)->GetTitle(), "centrality") == 0)
901 fHistogramType = "NumberDensityPhiCentrality";
904 if (fHistogramType.Length() == 0)
905 AliFatal("Cannot figure out histogram type. Try setting it manually...");
908 Printf("AliUEHist::Correct: Correcting %s...", fHistogramType.Data());
910 if (strcmp(fHistogramType, "NumberDensitypT") == 0 || strcmp(fHistogramType, "NumberDensityPhi") == 0 || strcmp(fHistogramType, "SumpT") == 0) // the last is for backward compatibilty
914 // bias due to migration in leading pT (because the leading particle is not reconstructed, and the subleading is used)
915 // extracted as function of leading pT
916 Bool_t biasFromMC = kFALSE;
917 const char* projAxis = "z";
918 Int_t secondBin = -1;
920 if (strcmp(fHistogramType, "NumberDensityPhi") == 0)
926 for (UInt_t region = 0; region < fkRegions; region++)
928 if (!fTrackHist[region])
931 TH1* leadingBiasTracks = 0;
934 leadingBiasTracks = (TH1*) corrections->GetBias(kCFStepReconstructed, kCFStepTracked, region, projAxis, 0, -1, 1); // from MC
935 Printf("WARNING: Using MC bias correction");
938 leadingBiasTracks = (TH1*) GetBias(kCFStepBiasStudy, kCFStepReconstructed, region, projAxis, 0, -1, 1); // from data
940 CorrectTracks(kCFStepReconstructed, kCFStepTracked, region, leadingBiasTracks, 2, secondBin);
941 if (region == kMin && fCombineMinMax)
943 CorrectTracks(kCFStepReconstructed, kCFStepTracked, kMax, leadingBiasTracks, 2, secondBin);
944 delete leadingBiasTracks;
947 delete leadingBiasTracks;
950 TH1* leadingBiasEvents = 0;
952 leadingBiasEvents = (TH1*) corrections->GetBias(kCFStepReconstructed, kCFStepTracked, kToward, projAxis, 0, -1, 2); // from MC
954 leadingBiasEvents = (TH1*) GetBias(kCFStepBiasStudy, kCFStepReconstructed, kToward, projAxis, 0, -1, 2); // from data
956 //new TCanvas; leadingBiasEvents->DrawCopy();
957 CorrectEvents(kCFStepReconstructed, kCFStepTracked, leadingBiasEvents, 0);
958 delete leadingBiasEvents;
960 // --- contamination correction ---
962 TH2D* contamination = corrections->GetTrackingContamination();
963 if (corrections->fContaminationEnhancement)
965 Printf("Applying contamination enhancement");
967 for (Int_t x=1; x<=contamination->GetNbinsX(); x++)
968 for (Int_t y=1; y<=contamination->GetNbinsX(); y++)
969 contamination->SetBinContent(x, y, contamination->GetBinContent(x, y) * corrections->fContaminationEnhancement->GetBinContent(corrections->fContaminationEnhancement->GetXaxis()->FindBin(contamination->GetYaxis()->GetBinCenter(y))));
971 CorrectTracks(kCFStepTracked, kCFStepTrackedOnlyPrim, contamination, 0, 1);
972 CorrectEvents(kCFStepTracked, kCFStepTrackedOnlyPrim, 0, 0);
973 delete contamination;
975 // --- efficiency correction ---
976 // correct single-particle efficiency for associated particles
977 // in addition correct for efficiency on trigger particles (tracks AND events)
979 TH1* efficiencyCorrection = corrections->GetTrackingEfficiencyCorrection();
980 // use kCFStepVertex as a temporary step (will be overwritten later anyway)
981 CorrectTracks(kCFStepTrackedOnlyPrim, kCFStepVertex, efficiencyCorrection, 0, 1);
982 delete efficiencyCorrection;
985 efficiencyCorrection = corrections->GetTrackEfficiency(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, 1, -1, 2);
986 CorrectEvents(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, efficiencyCorrection, 0);
987 CorrectTracks(kCFStepVertex, kCFStepAnaTopology, efficiencyCorrection, 2);
988 delete efficiencyCorrection;
991 CorrectTracks(kCFStepAnaTopology, kCFStepVertex, 0, -1);
992 CorrectEvents(kCFStepAnaTopology, kCFStepVertex, 0, 0);
994 // vertex correction on the level of events as function of multiplicity, weighting tracks and events with the same factor
995 // practically independent of low pT cut
996 TH1D* vertexCorrection = (TH1D*) corrections->GetEventEfficiency(kCFStepVertex, kCFStepTriggered, 1);
998 // convert stage from true multiplicity to observed multiplicity by simple conversion factor
999 TH1D* vertexCorrectionObs = (TH1D*) vertexCorrection->Clone("vertexCorrection2");
1000 vertexCorrectionObs->Reset();
1002 TF1* func = new TF1("func", "[1]+[0]/(x-[2])");
1004 func->SetParameters(0.1, 1, -0.7);
1005 vertexCorrection->Fit(func, "0I", "", 0, 3);
1006 for (Int_t i=1; i<=vertexCorrectionObs->GetNbinsX(); i++)
1008 Float_t xPos = 1.0 / 0.77 * vertexCorrectionObs->GetXaxis()->GetBinCenter(i);
1010 vertexCorrectionObs->SetBinContent(i, func->Eval(xPos));
1012 vertexCorrectionObs->SetBinContent(i, vertexCorrection->Interpolate(xPos));
1017 vertexCorrection->DrawCopy();
1018 vertexCorrectionObs->SetLineColor(2);
1019 vertexCorrectionObs->DrawCopy("same");
1020 func->SetRange(0, 4);
1021 func->DrawClone("same");
1024 CorrectTracks(kCFStepVertex, kCFStepTriggered, vertexCorrectionObs, 3);
1025 CorrectEvents(kCFStepVertex, kCFStepTriggered, vertexCorrectionObs, 1);
1026 delete vertexCorrectionObs;
1027 delete vertexCorrection;
1031 CorrectTracks(kCFStepTriggered, kCFStepAll, 0, -1);
1032 CorrectEvents(kCFStepTriggered, kCFStepAll, 0, 0);
1034 else if (strcmp(fHistogramType, "NumberDensityPhiCentrality") == 0)
1037 CorrectTracks(kCFStepReconstructed, kCFStepTracked, 0, -1);
1038 CorrectEvents(kCFStepReconstructed, kCFStepTracked, 0, -1);
1040 // Dont use eta in the following, because it is a Delta-eta axis
1042 // contamination correction
1043 // correct single-particle contamination for associated particles
1045 TH1* contamination = corrections->GetTrackingContamination(1);
1049 Printf("Applying contamination enhancement");
1051 for (Int_t bin = 1; bin <= contamination->GetNbinsX(); bin++)
1053 printf("%f", contamination->GetBinContent(bin));
1054 if (contamination->GetBinContent(bin) > 0)
1055 contamination->SetBinContent(bin, 1.0 + 1.1 * (contamination->GetBinContent(bin) - 1.0));
1056 printf(" --> %f\n", contamination->GetBinContent(bin));
1060 CorrectTracks(kCFStepTracked, kCFStepTrackedOnlyPrim, contamination, 1);
1061 delete contamination;
1063 // correct for additional contamination due to trigger particle around phi ~ 0
1064 TH2* correlatedContamination = corrections->GetCorrelatedContamination();
1067 Printf("Applying contamination enhancement");
1069 for (Int_t bin = 1; bin <= correlatedContamination->GetNbinsX(); bin++)
1070 for (Int_t bin2 = 1; bin2 <= correlatedContamination->GetNbinsY(); bin2++)
1072 printf("%f", correlatedContamination->GetBinContent(bin, bin2));
1073 if (correlatedContamination->GetBinContent(bin, bin2) > 0)
1074 correlatedContamination->SetBinContent(bin, bin2, 1.0 + 1.1 * (correlatedContamination->GetBinContent(bin, bin2) - 1.0));
1075 printf(" --> %f\n", correlatedContamination->GetBinContent(bin, bin2));
1079 // new TCanvas; correlatedContamination->DrawCopy("COLZ");
1080 CorrectCorrelatedContamination(kCFStepTrackedOnlyPrim, 0, correlatedContamination);
1081 // Printf("\n\n\nWARNING ---> SKIPPING CorrectCorrelatedContamination\n\n\n");
1083 delete correlatedContamination;
1085 // TODO correct for contamination of trigger particles (for tracks AND events)
1086 CorrectEvents(kCFStepTracked, kCFStepTrackedOnlyPrim, 0, 0);
1088 // --- efficiency correction ---
1089 // correct single-particle efficiency for associated particles
1090 // in addition correct for efficiency on trigger particles (tracks AND events)
1092 // in bins of pT and centrality
1093 TH1* efficiencyCorrection = corrections->GetTrackingEfficiencyCorrectionCentrality();
1094 // use kCFStepAnaTopology as a temporary step
1095 CorrectTracks(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, efficiencyCorrection, 1, 3);
1096 delete efficiencyCorrection;
1098 // correct pT,T in bins of pT and centrality
1099 efficiencyCorrection = corrections->GetTrackEfficiency(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, 1, 3, 2);
1100 CorrectEvents(kCFStepTrackedOnlyPrim, kCFStepVertex, efficiencyCorrection, 0, 1);
1101 CorrectTracks(kCFStepAnaTopology, kCFStepVertex, efficiencyCorrection, 2, 3);
1102 delete efficiencyCorrection;
1104 // no correction for vertex finding efficiency and trigger efficiency needed in PbPb
1106 CorrectTracks(kCFStepVertex, kCFStepAll, 0, -1);
1107 CorrectEvents(kCFStepVertex, kCFStepAll, 0, -1);
1110 AliFatal(Form("Unknown histogram for correction: %s", GetTitle()));
1113 //____________________________________________________________________
1114 TH1* AliUEHist::GetTrackEfficiency(CFStep step1, CFStep step2, Int_t axis1, Int_t axis2, Int_t source, Int_t axis3)
1116 // creates a track-level efficiency by dividing step2 by step1
1117 // projected to axis1 and axis2 (optional if >= 0)
1119 // source: 0 = fTrackHist; 1 = fTrackHistEfficiency; 2 = fTrackHistEfficiency rebinned for pT,T / pT,lead binning
1121 // integrate over regions
1122 // cache it for efficiency (usually more than one efficiency is requested)
1124 AliCFContainer* sourceContainer = 0;
1130 fCache = (AliCFContainer*) fTrackHist[0]->Clone();
1131 for (UInt_t i = 1; i < fkRegions; i++)
1133 fCache->Add(fTrackHist[i]);
1135 sourceContainer = fCache;
1137 else if (source == 1 || source == 2)
1139 sourceContainer = fTrackHistEfficiency;
1140 // step offset because we start with kCFStepAnaTopology
1141 step1 = (CFStep) ((Int_t) step1 - (Int_t) kCFStepAnaTopology);
1142 step2 = (CFStep) ((Int_t) step2 - (Int_t) kCFStepAnaTopology);
1147 // reset all limits and set the right ones except those in axis1, axis2 and axis3
1148 ResetBinLimits(sourceContainer->GetGrid(step1));
1149 ResetBinLimits(sourceContainer->GetGrid(step2));
1150 if (fEtaMax > fEtaMin && axis1 != 0 && axis2 != 0 && axis3 != 0)
1152 sourceContainer->GetGrid(step1)->SetRangeUser(0, fEtaMin, fEtaMax);
1153 sourceContainer->GetGrid(step2)->SetRangeUser(0, fEtaMin, fEtaMax);
1155 if (fPtMax > fPtMin && axis1 != 1 && axis2 != 1 && axis3 != 1)
1157 sourceContainer->GetGrid(step1)->SetRangeUser(1, fPtMin, fPtMax);
1158 sourceContainer->GetGrid(step2)->SetRangeUser(1, fPtMin, fPtMax);
1160 if (fCentralityMax > fCentralityMin && axis1 != 3 && axis2 != 3 && axis3 != 3)
1162 sourceContainer->GetGrid(step1)->SetRangeUser(3, fCentralityMin, fCentralityMax);
1163 sourceContainer->GetGrid(step2)->SetRangeUser(3, fCentralityMin, fCentralityMax);
1171 generated = sourceContainer->Project(step1, axis1, axis2, axis3);
1172 measured = sourceContainer->Project(step2, axis1, axis2, axis3);
1174 else if (axis2 >= 0)
1176 generated = sourceContainer->Project(step1, axis1, axis2);
1177 measured = sourceContainer->Project(step2, axis1, axis2);
1181 generated = sourceContainer->Project(step1, axis1);
1182 measured = sourceContainer->Project(step2, axis1);
1185 // check for bins with less than 50 entries, print warning
1193 binEnd[0] = generated->GetNbinsX();
1194 binEnd[1] = generated->GetNbinsY();
1195 binEnd[2] = generated->GetNbinsZ();
1197 if (fEtaMax > fEtaMin)
1201 binBegin[0] = generated->GetXaxis()->FindBin(fEtaMin);
1202 binEnd[0] = generated->GetXaxis()->FindBin(fEtaMax);
1206 binBegin[1] = generated->GetYaxis()->FindBin(fEtaMin);
1207 binEnd[1] = generated->GetYaxis()->FindBin(fEtaMax);
1211 binBegin[2] = generated->GetZaxis()->FindBin(fEtaMin);
1212 binEnd[2] = generated->GetZaxis()->FindBin(fEtaMax);
1216 if (fPtMax > fPtMin)
1218 // TODO this is just checking up to 15 for now
1219 Float_t ptMax = TMath::Min((Float_t) 15., fPtMax);
1222 binBegin[0] = generated->GetXaxis()->FindBin(fPtMin);
1223 binEnd[0] = generated->GetXaxis()->FindBin(ptMax);
1227 binBegin[1] = generated->GetYaxis()->FindBin(fPtMin);
1228 binEnd[1] = generated->GetYaxis()->FindBin(ptMax);
1232 binBegin[2] = generated->GetZaxis()->FindBin(fPtMin);
1233 binEnd[2] = generated->GetZaxis()->FindBin(ptMax);
1241 for (Int_t i=0; i<3; i++)
1242 vars[i] = binBegin[i];
1244 const Int_t limit = 50;
1247 if (generated->GetDimension() == 1 && generated->GetBinContent(vars[0]) < limit)
1249 Printf("Empty bin at %s=%.2f (%.2f entries)", generated->GetXaxis()->GetTitle(), generated->GetXaxis()->GetBinCenter(vars[0]), generated->GetBinContent(vars[0]));
1252 else if (generated->GetDimension() == 2 && generated->GetBinContent(vars[0], vars[1]) < limit)
1254 Printf("Empty bin at %s=%.2f %s=%.2f (%.2f entries)",
1255 generated->GetXaxis()->GetTitle(), generated->GetXaxis()->GetBinCenter(vars[0]),
1256 generated->GetYaxis()->GetTitle(), generated->GetYaxis()->GetBinCenter(vars[1]),
1257 generated->GetBinContent(vars[0], vars[1]));
1260 else if (generated->GetDimension() == 3 && generated->GetBinContent(vars[0], vars[1], vars[2]) < limit)
1262 Printf("Empty bin at %s=%.2f %s=%.2f %s=%.2f (%.2f entries)",
1263 generated->GetXaxis()->GetTitle(), generated->GetXaxis()->GetBinCenter(vars[0]),
1264 generated->GetYaxis()->GetTitle(), generated->GetYaxis()->GetBinCenter(vars[1]),
1265 generated->GetZaxis()->GetTitle(), generated->GetZaxis()->GetBinCenter(vars[2]),
1266 generated->GetBinContent(vars[0], vars[1], vars[2]));
1271 if (vars[2] == binEnd[2]+1)
1273 vars[2] = binBegin[2];
1277 if (vars[1] == binEnd[1]+1)
1279 vars[1] = binBegin[1];
1283 if (vars[0] == binEnd[0]+1)
1288 Printf("Correction has %d empty bins (out of %d bins)", count, total);
1290 // rebin if required
1293 TAxis* axis = fEventHist->GetGrid(0)->GetGrid()->GetAxis(0);
1295 if (axis->GetNbins() < measured->GetNbinsX())
1299 // 2d rebin with variable axis does not exist in root
1301 TH1* tmp = measured;
1302 measured = new TH2D(Form("%s_rebinned", tmp->GetName()), tmp->GetTitle(), axis->GetNbins(), axis->GetXbins()->GetArray(), tmp->GetNbinsY(), tmp->GetYaxis()->GetXbins()->GetArray());
1303 for (Int_t x=1; x<=tmp->GetNbinsX(); x++)
1304 for (Int_t y=1; y<=tmp->GetNbinsY(); y++)
1306 ((TH2*) measured)->Fill(tmp->GetXaxis()->GetBinCenter(x), tmp->GetYaxis()->GetBinCenter(y), tmp->GetBinContent(x, y));
1307 measured->SetBinError(x, y, 0); // cannot trust bin error, set to 0
1312 generated = new TH2D(Form("%s_rebinned", tmp->GetName()), tmp->GetTitle(), axis->GetNbins(), axis->GetXbins()->GetArray(), tmp->GetNbinsY(), tmp->GetYaxis()->GetXbins()->GetArray());
1313 for (Int_t x=1; x<=tmp->GetNbinsX(); x++)
1314 for (Int_t y=1; y<=tmp->GetNbinsY(); y++)
1316 ((TH2*) generated)->Fill(tmp->GetXaxis()->GetBinCenter(x), tmp->GetYaxis()->GetBinCenter(y), tmp->GetBinContent(x, y));
1317 generated->SetBinError(x, y, 0); // cannot trust bin error, set to 0
1323 TH1* tmp = measured;
1324 measured = tmp->Rebin(axis->GetNbins(), Form("%s_rebinned", tmp->GetName()), axis->GetXbins()->GetArray());
1328 generated = tmp->Rebin(axis->GetNbins(), Form("%s_rebinned", tmp->GetName()), axis->GetXbins()->GetArray());
1332 else if (axis->GetNbins() > measured->GetNbinsX())
1335 AliFatal("Rebinning only works for 1d at present");
1337 // this is an unfortunate case where the number of bins has to be increased in principle
1338 // there is a region where the binning is finner in one histogram and a region where it is the other way round
1339 // this cannot be resolved in principle, but as we only calculate the ratio the bin in the second region get the same entries
1340 // only a certain binning is supported here
1341 if (axis->GetNbins() != 100 || measured->GetNbinsX() != 39)
1342 AliFatal(Form("Invalid binning --> %d %d", axis->GetNbins(), measured->GetNbinsX()));
1344 Double_t newBins[] = {0.0, 0.5, 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};
1346 // reduce binning below 5 GeV/c
1347 TH1* tmp = measured;
1348 measured = tmp->Rebin(27, Form("%s_rebinned", tmp->GetName()), newBins);
1351 // increase binning above 5 GeV/c
1353 measured = new TH1F(Form("%s_rebinned2", tmp->GetName()), tmp->GetTitle(), axis->GetNbins(), axis->GetBinLowEdge(1), axis->GetBinUpEdge(axis->GetNbins()));
1354 for (Int_t bin=1; bin<=measured->GetNbinsX(); bin++)
1356 measured->SetBinContent(bin, tmp->GetBinContent(tmp->FindBin(measured->GetBinCenter(bin))));
1357 measured->SetBinError(bin, tmp->GetBinError(tmp->FindBin(measured->GetBinCenter(bin))));
1361 // reduce binning below 5 GeV/c
1363 generated = tmp->Rebin(27, Form("%s_rebinned", tmp->GetName()), newBins);
1366 // increase binning above 5 GeV/c
1368 generated = new TH1F(Form("%s_rebinned2", tmp->GetName()), tmp->GetTitle(), axis->GetNbins(), axis->GetBinLowEdge(1), axis->GetBinUpEdge(axis->GetNbins()));
1369 for (Int_t bin=1; bin<=generated->GetNbinsX(); bin++)
1371 generated->SetBinContent(bin, tmp->GetBinContent(tmp->FindBin(generated->GetBinCenter(bin))));
1372 generated->SetBinError(bin, tmp->GetBinError(tmp->FindBin(generated->GetBinCenter(bin))));
1378 measured->Divide(measured, generated, 1, 1, "B");
1382 ResetBinLimits(sourceContainer->GetGrid(step1));
1383 ResetBinLimits(sourceContainer->GetGrid(step2));
1388 //____________________________________________________________________
1389 TH1* AliUEHist::GetEventEfficiency(CFStep step1, CFStep step2, Int_t axis1, Int_t axis2, Float_t ptLeadMin, Float_t ptLeadMax)
1391 // creates a event-level efficiency by dividing step2 by step1
1392 // projected to axis1 and axis2 (optional if >= 0)
1394 if (ptLeadMax > ptLeadMin)
1396 fEventHist->GetGrid(step1)->SetRangeUser(0, ptLeadMin, ptLeadMax);
1397 fEventHist->GetGrid(step2)->SetRangeUser(0, ptLeadMin, ptLeadMax);
1405 generated = fEventHist->Project(step1, axis1, axis2);
1406 measured = fEventHist->Project(step2, axis1, axis2);
1410 generated = fEventHist->Project(step1, axis1);
1411 measured = fEventHist->Project(step2, axis1);
1414 measured->Divide(measured, generated, 1, 1, "B");
1418 if (ptLeadMax > ptLeadMin)
1420 fEventHist->GetGrid(step1)->SetRangeUser(0, 0, -1);
1421 fEventHist->GetGrid(step2)->SetRangeUser(0, 0, -1);
1427 //____________________________________________________________________
1428 void AliUEHist::WeightHistogram(TH3* hist1, TH1* hist2)
1430 // weights each entry of the 3d histogram hist1 with the 1d histogram hist2
1431 // where the matching is done of the z axis of hist1 with the x axis of hist2
1433 if (hist1->GetNbinsZ() != hist2->GetNbinsX())
1434 AliFatal(Form("Inconsistent binning %d %d", hist1->GetNbinsZ(), hist2->GetNbinsX()));
1436 for (Int_t x=1; x<=hist1->GetNbinsX(); x++)
1438 for (Int_t y=1; y<=hist1->GetNbinsY(); y++)
1440 for (Int_t z=1; z<=hist1->GetNbinsZ(); z++)
1442 if (hist2->GetBinContent(z) > 0)
1444 hist1->SetBinContent(x, y, z, hist1->GetBinContent(x, y, z) / hist2->GetBinContent(z));
1445 hist1->SetBinError(x, y, z, hist1->GetBinError(x, y, z) / hist2->GetBinContent(z));
1449 hist1->SetBinContent(x, y, z, 0);
1450 hist1->SetBinError(x, y, z, 0);
1457 //____________________________________________________________________
1458 TH1* AliUEHist::GetBias(CFStep step1, CFStep step2, Int_t region, const char* axis, Float_t leadPtMin, Float_t leadPtMax, Int_t weighting)
1460 // extracts the track-level bias (integrating out the multiplicity) between two steps (dividing step2 by step1)
1461 // in the given region (sum over all regions is calculated if region == -1)
1462 // done by weighting the track-level distribution with the number of events as function of leading pT
1463 // and then calculating the ratio between the distributions
1464 // projected to axis which is a TH3::Project3D string, e.g. "x", or "yx"
1465 // no projection is done if axis == 0
1466 // weighting: 0 = tracks weighted with events (as discussed above)
1467 // 1 = only track bias is returned
1468 // 2 = only event bias is returned
1470 AliCFContainer* tmp = 0;
1474 tmp = (AliCFContainer*) fTrackHist[0]->Clone();
1475 for (UInt_t i = 1; i < fkRegions; i++)
1477 tmp->Add(fTrackHist[i]);
1479 else if (region == kMin && fCombineMinMax)
1481 tmp = (AliCFContainer*) fTrackHist[kMin]->Clone();
1482 tmp->Add(fTrackHist[kMax]);
1485 tmp = fTrackHist[region];
1487 ResetBinLimits(tmp->GetGrid(step1));
1488 ResetBinLimits(fEventHist->GetGrid(step1));
1489 SetBinLimits(tmp->GetGrid(step1));
1491 ResetBinLimits(tmp->GetGrid(step2));
1492 ResetBinLimits(fEventHist->GetGrid(step2));
1493 SetBinLimits(tmp->GetGrid(step2));
1495 TH1D* events1 = (TH1D*)fEventHist->Project(step1, 0);
1496 TH3D* hist1 = (TH3D*)tmp->Project(step1, 0, tmp->GetNVar()-1, 2);
1498 WeightHistogram(hist1, events1);
1500 TH1D* events2 = (TH1D*)fEventHist->Project(step2, 0);
1501 TH3D* hist2 = (TH3D*)tmp->Project(step2, 0, tmp->GetNVar()-1, 2);
1503 WeightHistogram(hist2, events2);
1505 TH1* generated = hist1;
1506 TH1* measured = hist2;
1508 if (weighting == 0 || weighting == 1)
1512 if (leadPtMax > leadPtMin)
1514 hist1->GetZaxis()->SetRangeUser(leadPtMin, leadPtMax);
1515 hist2->GetZaxis()->SetRangeUser(leadPtMin, leadPtMax);
1518 if (fEtaMax > fEtaMin && !TString(axis).Contains("x"))
1520 hist1->GetXaxis()->SetRangeUser(fEtaMin, fEtaMax);
1521 hist2->GetXaxis()->SetRangeUser(fEtaMin, fEtaMax);
1524 generated = hist1->Project3D(axis);
1525 measured = hist2->Project3D(axis);
1527 // delete hists here if projection has been done
1534 else if (weighting == 2)
1538 generated = events1;
1542 measured->Divide(generated);
1546 ResetBinLimits(tmp->GetGrid(step1));
1547 ResetBinLimits(tmp->GetGrid(step2));
1549 if ((region == -1) || (region == kMin && fCombineMinMax))
1555 //____________________________________________________________________
1556 void AliUEHist::CorrectCorrelatedContamination(CFStep step, Int_t region, TH1* trackCorrection)
1558 // corrects for the given factor in a small delta-eta and delta-phi window as function of pT,A and pT,T
1560 if (!fTrackHist[region])
1563 THnSparse* grid = fTrackHist[region]->GetGrid(step)->GetGrid();
1568 if (grid->GetAxis(var1)->GetNbins() != trackCorrection->GetNbinsX())
1569 AliFatal(Form("Invalid binning (var1): %d %d", grid->GetAxis(var1)->GetNbins(), trackCorrection->GetNbinsX()));
1571 if (grid->GetAxis(var2)->GetNbins() != trackCorrection->GetNbinsY())
1572 AliFatal(Form("Invalid binning (var2): %d %d", grid->GetAxis(var2)->GetNbins(), trackCorrection->GetNbinsY()));
1574 // optimized implementation
1575 for (Int_t binIdx = 0; binIdx < grid->GetNbins(); binIdx++)
1579 Double_t value = grid->GetBinContent(binIdx, bins);
1580 Double_t error = grid->GetBinError(binIdx);
1582 // check eta and phi axes
1583 if (TMath::Abs(grid->GetAxis(0)->GetBinCenter(bins[0])) > 0.1)
1585 if (TMath::Abs(grid->GetAxis(4)->GetBinCenter(bins[4])) > 0.1)
1588 value *= trackCorrection->GetBinContent(bins[var1], bins[var2]);
1589 error *= trackCorrection->GetBinContent(bins[var1], bins[var2]);
1591 grid->SetBinContent(bins, value);
1592 grid->SetBinError(bins, error);
1595 Printf("AliUEHist::CorrectCorrelatedContamination: Corrected.");
1598 //____________________________________________________________________
1599 TH2* AliUEHist::GetCorrelatedContamination()
1601 // contamination correlated with the trigger particle is evaluated between step kCFStepTracked and kCFStepTrackedOnlyPrim in the region of delta eta and delta phi < 0.1 (smallest bin!)
1603 Int_t step1 = kCFStepTrackedOnlyPrim;
1604 Int_t step2 = kCFStepTracked;
1606 fTrackHist[0]->GetGrid(step1)->SetRangeUser(0, -0.01, 0.01); // delta eta
1607 fTrackHist[0]->GetGrid(step1)->SetRangeUser(4, -0.01, 0.01); // delta phi
1608 TH2* tracksStep1 = (TH2*) fTrackHist[0]->Project(step1, 1, 2);
1610 fTrackHist[0]->GetGrid(step2)->SetRangeUser(0, -0.01, 0.01); // delta eta
1611 fTrackHist[0]->GetGrid(step2)->SetRangeUser(4, -0.01, 0.01); // delta phi
1612 TH2* tracksStep2 = (TH2*) fTrackHist[0]->Project(step2, 1, 2);
1614 tracksStep1->Divide(tracksStep2);
1616 TH1* triggersStep1 = fEventHist->Project(step1, 0);
1617 TH1* triggersStep2 = fEventHist->Project(step2, 0);
1619 TH1* singleParticle = GetTrackingContamination(1);
1621 for (Int_t x=1; x<=tracksStep1->GetNbinsX(); x++)
1622 for (Int_t y=1; y<=tracksStep1->GetNbinsY(); y++)
1623 if (singleParticle->GetBinContent(x) > 0)
1624 tracksStep1->SetBinContent(x, y, tracksStep1->GetBinContent(x, y) / triggersStep1->GetBinContent(y) * triggersStep2->GetBinContent(y) / singleParticle->GetBinContent(x));
1626 tracksStep1->SetBinContent(x, y, 0);
1628 delete singleParticle;
1630 delete triggersStep1;
1631 delete triggersStep2;
1636 //____________________________________________________________________
1637 TH2D* AliUEHist::GetTrackingEfficiency()
1639 // extracts the tracking efficiency by calculating the efficiency from step kCFStepAnaTopology to kCFStepTrackedOnlyPrim
1640 // integrates over the regions and all other variables than pT and eta to increase the statistics
1642 // returned histogram has to be deleted by the user
1644 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepAnaTopology, kCFStepTrackedOnlyPrim, 0, 1));
1647 //____________________________________________________________________
1648 TH2D* AliUEHist::GetTrackingEfficiencyCentrality()
1650 // extracts the tracking efficiency by calculating the efficiency from step kCFStepAnaTopology to kCFStepTrackedOnlyPrim
1651 // integrates over the regions and all other variables than pT, centrality to increase the statistics
1653 // returned histogram has to be deleted by the user
1655 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepAnaTopology, kCFStepTrackedOnlyPrim, 1, 3));
1658 //____________________________________________________________________
1659 TH1D* AliUEHist::GetTrackingEfficiency(Int_t axis)
1661 // extracts the tracking efficiency by calculating the efficiency from step kCFStepAnaTopology to kCFStepTrackedOnlyPrim
1662 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
1664 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepAnaTopology, kCFStepTrackedOnlyPrim, axis));
1667 //____________________________________________________________________
1668 TH2D* AliUEHist::GetTrackingCorrection()
1670 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1671 // integrates over the regions and all other variables than pT and eta to increase the statistics
1673 // returned histogram has to be deleted by the user
1675 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTracked, kCFStepAnaTopology, 0, 1));
1678 //____________________________________________________________________
1679 TH1D* AliUEHist::GetTrackingCorrection(Int_t axis)
1681 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1682 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
1684 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepTracked, kCFStepAnaTopology, axis));
1687 //____________________________________________________________________
1688 TH2D* AliUEHist::GetTrackingEfficiencyCorrection()
1690 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1691 // integrates over the regions and all other variables than pT and eta to increase the statistics
1693 // returned histogram has to be deleted by the user
1695 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, 0, 1));
1698 //____________________________________________________________________
1699 TH2D* AliUEHist::GetTrackingEfficiencyCorrectionCentrality()
1701 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1702 // integrates over the regions and all other variables than pT and centrality to increase the statistics
1704 // returned histogram has to be deleted by the user
1706 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, 1, 3));
1709 //____________________________________________________________________
1710 TH1D* AliUEHist::GetTrackingEfficiencyCorrection(Int_t axis)
1712 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1713 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
1715 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, axis));
1718 //____________________________________________________________________
1719 TH2D* AliUEHist::GetTrackingContamination()
1721 // extracts the tracking contamination by secondaries by calculating the efficiency from step kCFStepTrackedOnlyPrim to kCFStepTracked
1722 // integrates over the regions and all other variables than pT and eta to increase the statistics
1724 // returned histogram has to be deleted by the user
1726 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTracked, kCFStepTrackedOnlyPrim, 0, 1));
1729 //____________________________________________________________________
1730 TH2D* AliUEHist::GetTrackingContaminationCentrality()
1732 // extracts the tracking contamination by secondaries by calculating the efficiency from step kCFStepTrackedOnlyPrim to kCFStepTracked
1733 // integrates over the regions and all other variables than pT and centrality to increase the statistics
1735 // returned histogram has to be deleted by the user
1737 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTracked, kCFStepTrackedOnlyPrim, 1, 3));
1740 //____________________________________________________________________
1741 TH1D* AliUEHist::GetTrackingContamination(Int_t axis)
1743 // extracts the tracking contamination by secondaries by calculating the efficiency from step kCFStepTrackedOnlyPrim to kCFStepTracked
1744 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
1746 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepTracked, kCFStepTrackedOnlyPrim, axis));
1749 //____________________________________________________________________
1750 const char* AliUEHist::GetRegionTitle(Region region)
1752 // returns the name of the given region
1761 return (fCombineMinMax) ? "Transverse" : "Min";
1769 //____________________________________________________________________
1770 const char* AliUEHist::GetStepTitle(CFStep step)
1772 // returns the name of the given step
1777 return "All events";
1778 case kCFStepTriggered:
1781 return "Primary Vertex";
1782 case kCFStepAnaTopology:
1783 return "Required analysis topology";
1784 case kCFStepTrackedOnlyPrim:
1785 return "Tracked (matched MC, only primaries)";
1786 case kCFStepTracked:
1787 return "Tracked (matched MC, all)";
1788 case kCFStepReconstructed:
1789 return "Reconstructed";
1790 case kCFStepRealLeading:
1791 return "Correct leading particle identified";
1792 case kCFStepBiasStudy:
1793 return "Bias study applying tracking efficiency";
1794 case kCFStepBiasStudy2:
1795 return "Bias study applying tracking efficiency in two steps";
1801 //____________________________________________________________________
1802 void AliUEHist::CopyReconstructedData(AliUEHist* from)
1804 // copies those histograms extracted from ESD to this object
1806 // TODO at present only the pointers are copied
1808 for (Int_t region=0; region<4; region++)
1810 if (!fTrackHist[region])
1813 fTrackHist[region]->SetGrid(AliUEHist::kCFStepReconstructed, from->fTrackHist[region]->GetGrid(AliUEHist::kCFStepReconstructed));
1814 //fTrackHist[region]->SetGrid(AliUEHist::kCFStepTrackedOnlyPrim, from->fTrackHist[region]->GetGrid(AliUEHist::kCFStepTrackedOnlyPrim));
1815 fTrackHist[region]->SetGrid(AliUEHist::kCFStepBiasStudy, from->fTrackHist[region]->GetGrid(AliUEHist::kCFStepBiasStudy));
1818 fEventHist->SetGrid(AliUEHist::kCFStepReconstructed, from->fEventHist->GetGrid(AliUEHist::kCFStepReconstructed));
1819 //fEventHist->SetGrid(AliUEHist::kCFStepTrackedOnlyPrim, from->fEventHist->GetGrid(AliUEHist::kCFStepTrackedOnlyPrim));
1820 fEventHist->SetGrid(AliUEHist::kCFStepBiasStudy, from->fEventHist->GetGrid(AliUEHist::kCFStepBiasStudy));
1823 //____________________________________________________________________
1824 void AliUEHist::ExtendTrackingEfficiency(Bool_t verbose)
1826 // fits the tracking efficiency at high pT with a constant and fills all bins with this tracking efficiency
1828 Float_t fitRangeBegin = 5.01;
1829 Float_t fitRangeEnd = 14.99;
1830 Float_t extendRangeBegin = 10.01;
1832 if (fTrackHistEfficiency->GetNVar() == 3)
1834 TH1* obj = GetTrackingEfficiency(1);
1842 obj->Fit("pol0", (verbose) ? "+" : "0+", "SAME", fitRangeBegin, fitRangeEnd);
1844 Float_t trackingEff = obj->GetFunction("pol0")->GetParameter(0);
1846 obj = GetTrackingContamination(1);
1854 obj->Fit("pol0", (verbose) ? "+" : "0+", "SAME", fitRangeBegin, fitRangeEnd);
1856 Float_t trackingCont = obj->GetFunction("pol0")->GetParameter(0);
1858 Printf("AliUEHist::ExtendTrackingEfficiency: Fitted efficiency between %f and %f and got %f tracking efficiency and %f tracking contamination correction. Extending from %f onwards (within %f < eta < %f)", fitRangeBegin, fitRangeEnd, trackingEff, trackingCont, extendRangeBegin, fEtaMin, fEtaMax);
1860 // extend for full pT range
1861 for (Int_t x = fTrackHistEfficiency->GetAxis(0, 0)->FindBin(fEtaMin); x <= fTrackHistEfficiency->GetAxis(0, 0)->FindBin(fEtaMax); x++)
1862 for (Int_t y = fTrackHistEfficiency->GetAxis(1, 0)->FindBin(extendRangeBegin); y <= fTrackHistEfficiency->GetNBins(1); y++)
1863 for (Int_t z = 1; z <= fTrackHistEfficiency->GetNBins(2); z++) // particle type axis
1871 fTrackHistEfficiency->GetGrid(0)->SetElement(bins, 100);
1872 fTrackHistEfficiency->GetGrid(1)->SetElement(bins, 100.0 * trackingEff);
1873 fTrackHistEfficiency->GetGrid(2)->SetElement(bins, 100.0 * trackingEff / trackingCont);
1876 else if (fTrackHistEfficiency->GetNVar() == 4)
1878 // fit in centrality intervals of 20% for efficiency, one bin for contamination
1879 Float_t* trackingEff = 0;
1880 Float_t* trackingCont = 0;
1881 Int_t centralityBins = 5;
1883 Printf("AliUEHist::ExtendTrackingEfficiency: Fitting efficiencies between %f and %f. Extending from %f onwards (within %f < eta < %f)", fitRangeBegin, fitRangeEnd, extendRangeBegin, fEtaMin, fEtaMax);
1885 // 0 = eff; 1 = cont
1886 for (Int_t caseNo = 0; caseNo < 2; caseNo++)
1888 Float_t* target = 0;
1889 Int_t centralityBinsLocal = centralityBins;
1893 trackingEff = new Float_t[centralityBinsLocal];
1894 target = trackingEff;
1898 centralityBinsLocal = 1;
1899 trackingCont = new Float_t[centralityBinsLocal];
1900 target = trackingCont;
1903 for (Int_t i=0; i<centralityBinsLocal; i++)
1905 SetCentralityRange(100.0/centralityBinsLocal*i + 0.1, 100.0/centralityBinsLocal*(i+1) - 0.1);
1906 TH1* proj = (caseNo == 0) ? GetTrackingEfficiency(1) : GetTrackingContamination(1);
1912 if ((Int_t) proj->Fit("pol0", (verbose) ? "+" : "Q0+", "SAME", fitRangeBegin, fitRangeEnd) == 0)
1913 target[i] = proj->GetFunction("pol0")->GetParameter(0);
1916 Printf("AliUEHist::ExtendTrackingEfficiency: case %d, centrality %d, eff %f", caseNo, i, target[i]);
1920 // extend for full pT range
1921 for (Int_t x = fTrackHistEfficiency->GetAxis(0, 0)->FindBin(fEtaMin); x <= fTrackHistEfficiency->GetAxis(0, 0)->FindBin(fEtaMax); x++)
1922 for (Int_t y = fTrackHistEfficiency->GetAxis(1, 0)->FindBin(extendRangeBegin); y <= fTrackHistEfficiency->GetNBins(1); y++)
1923 for (Int_t z = 1; z <= fTrackHistEfficiency->GetNBins(2); z++) // particle type axis
1925 for (Int_t z2 = 1; z2 <= fTrackHistEfficiency->GetNBins(3); z2++) // centrality axis
1934 Int_t z2Bin = (Int_t) (fTrackHistEfficiency->GetAxis(3, 0)->GetBinCenter(z2) / (100.0 / centralityBins));
1935 //Printf("%d %d", z2, z2Bin);
1937 fTrackHistEfficiency->GetGrid(0)->SetElement(bins, 100);
1938 fTrackHistEfficiency->GetGrid(1)->SetElement(bins, 100.0 * trackingEff[z2Bin]);
1939 if (trackingCont[0] > 0)
1940 fTrackHistEfficiency->GetGrid(2)->SetElement(bins, 100.0 * trackingEff[z2Bin] / trackingCont[0]);
1942 fTrackHistEfficiency->GetGrid(2)->SetElement(bins, 0);
1946 delete[] trackingEff;
1947 delete[] trackingCont;
1950 SetCentralityRange(0, 0);
1953 void AliUEHist::AdditionalDPhiCorrection(Int_t step)
1955 // corrects the dphi distribution with an extra factor close to dphi ~ 0
1957 Printf("WARNING: In AliUEHist::AdditionalDPhiCorrection.");
1959 THnSparse* grid = fTrackHist[0]->GetGrid(step)->GetGrid();
1961 // optimized implementation
1962 for (Int_t binIdx = 0; binIdx < grid->GetNbins(); binIdx++)
1965 Double_t value = grid->GetBinContent(binIdx, bins);
1966 Double_t error = grid->GetBinError(binIdx);
1968 Float_t binCenter = grid->GetAxis(4)->GetBinCenter(bins[4]);
1969 if (TMath::Abs(binCenter) < 0.2)
1974 else if (TMath::Abs(binCenter) < 0.3)
1980 grid->SetBinContent(bins, value);
1981 grid->SetBinError(bins, error);
1985 void AliUEHist::Scale(Double_t factor)
1987 // scales all contained histograms by the given factor
1989 for (Int_t i=0; i<4; i++)
1991 fTrackHist[i]->Scale(factor);
1993 fEventHist->Scale(factor);
1994 fTrackHistEfficiency->Scale(factor);
1997 void AliUEHist::Reset()
1999 // resets all contained histograms
2001 for (Int_t i=0; i<4; i++)
2003 for (Int_t step=0; step<fTrackHist[i]->GetNStep(); step++)
2004 fTrackHist[i]->GetGrid(step)->GetGrid()->Reset();
2006 for (Int_t step=0; step<fEventHist->GetNStep(); step++)
2007 fEventHist->GetGrid(step)->GetGrid()->Reset();
2009 for (Int_t step=0; step<fTrackHistEfficiency->GetNStep(); step++)
2010 fTrackHistEfficiency->GetGrid(step)->GetGrid()->Reset();