]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/JetTasks/AliUEHist.cxx
fixing calculation of delta phi distribution
[u/mrichter/AliRoot.git] / PWG4 / JetTasks / AliUEHist.cxx
CommitLineData
a75aacd6 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id: AliUEHist.cxx 20164 2007-08-14 15:31:50Z morsch $ */
17
18//
19//
20// encapsulate histogram and corrections for one underlying event histogram
21//
22//
23// Author: Jan Fiete Grosse-Oetringhaus, Sara Vallero
24
25#include "AliUEHist.h"
26#include "AliCFContainer.h"
27#include "THnSparse.h"
28#include "TMath.h"
29#include "TList.h"
30#include "TCollection.h"
31#include "TH1D.h"
32#include "TH2D.h"
33#include "TH3D.h"
34#include "AliLog.h"
35#include "TCanvas.h"
144bd037 36#include "TF1.h"
a75aacd6 37
38ClassImp(AliUEHist)
39
40const Int_t AliUEHist::fgkCFSteps = 10;
41
42AliUEHist::AliUEHist(const char* reqHist) :
d1c75d06 43 TObject(),
a75aacd6 44 fkRegions(4),
45 fEventHist(0),
b1831bcb 46 fTrackHistEfficiency(0),
a75aacd6 47 fEtaMin(0),
48 fEtaMax(0),
49 fPtMin(0),
50 fPtMax(0),
144bd037 51 fContaminationEnhancement(0),
a75aacd6 52 fCombineMinMax(0),
53 fCache(0)
54{
55 // Constructor
56
57 for (Int_t i=0; i<fkRegions; i++)
58 fTrackHist[i] = 0;
59
60 if (strlen(reqHist) == 0)
61 return;
62
df269636 63 AliLog::SetClassDebugLevel("AliCFContainer", -1);
e741fadd 64 AliLog::SetClassDebugLevel("AliCFGridSparse", -3);
df269636 65
a75aacd6 66 const char* title = "";
67
68 // track level
69 Int_t nTrackVars = 4; // eta vs pT vs pT,lead (vs delta phi) vs multiplicity
70 Int_t iTrackBin[5];
71 Double_t* trackBins[5];
72 const char* trackAxisTitle[5];
73
74 // eta
75 iTrackBin[0] = 20;
76 Double_t etaBins[20+1];
77 for (Int_t i=0; i<=iTrackBin[0]; i++)
78 etaBins[i] = -1.0 + 0.1 * i;
79 trackBins[0] = etaBins;
80 trackAxisTitle[0] = "#eta";
81
82 // pT
83 iTrackBin[1] = 39;
84 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};
85 trackBins[1] = pTBins;
86 trackAxisTitle[1] = "p_{T} (GeV/c)";
87
88 // pT,lead binning 1
89 const Int_t kNLeadingpTBins = 100;
90 Double_t leadingpTBins[kNLeadingpTBins+1];
91 for (Int_t i=0; i<=kNLeadingpTBins; i++)
92 leadingpTBins[i] = 0.5 * i;
93
94 // pT,lead binning 2
ada1a03f 95 const Int_t kNLeadingpTBins2 = 13;
96 Double_t leadingpTBins2[] = { 0.0, 0.5, 1.0, 2.0, 4.0, 6.0, 8.0, 10.0, 15.0, 20.0, 30.0, 40.0, 50.0, 100.0 };
a75aacd6 97
98 // phi,lead
99 const Int_t kNLeadingPhiBins = 40;
100 Double_t leadingPhiBins[kNLeadingPhiBins+1];
101 for (Int_t i=0; i<=kNLeadingPhiBins; i++)
2ac8dc5c 102 leadingPhiBins[i] = -0.5 * TMath::Pi() + 1.0 / 40 * i * TMath::TwoPi();
a75aacd6 103
104 // multiplicity
105 const Int_t kNMultiplicityBins = 15;
106 Double_t multiplicityBins[kNMultiplicityBins+1];
107 for (Int_t i=0; i<=kNMultiplicityBins; i++)
108 multiplicityBins[i] = -0.5 + i;
109 multiplicityBins[kNMultiplicityBins] = 200;
b1831bcb 110
111 // particle species
112 const Int_t kNSpeciesBins = 4; // pi, K, p, rest
113 Double_t speciesBins[] = { -0.5, 0.5, 1.5, 2.5, 3.5 };
a75aacd6 114
115 trackBins[3] = multiplicityBins;
116 iTrackBin[3] = kNMultiplicityBins;
117 trackAxisTitle[3] = "multiplicity";
118
119 // selection depending on requested histogram
120 Int_t axis = -1; // 0 = pT,lead, 1 = phi,lead
121 if (strcmp(reqHist, "NumberDensitypT") == 0)
122 {
123 axis = 0;
124 title = "d^{2}N_{ch}/d#phid#eta";
125 }
126 else if (strcmp(reqHist, "NumberDensityPhi") == 0)
127 {
128 axis = 1;
129 title = "d^{2}N_{ch}/d#phid#eta";
130 }
131 else if (strcmp(reqHist, "SumpT") == 0)
132 {
133 axis = 0;
134 title = "d^{2}#Sigma p_{T}/d#phid#eta";
135 }
136 else
137 AliFatal(Form("Invalid histogram requested: %s", reqHist));
138
139 Int_t initRegions = fkRegions;
140
141 if (axis == 0)
142 {
143 trackBins[2] = leadingpTBins;
144 iTrackBin[2] = kNLeadingpTBins;
145 trackAxisTitle[2] = "leading p_{T} (GeV/c)";
146
147 }
148 else if (axis == 1)
149 {
150 nTrackVars = 5;
151 initRegions = 1;
152
153 iTrackBin[2] = kNLeadingpTBins2;
154 trackBins[2] = leadingpTBins2;
155 trackAxisTitle[2] = "leading p_{T} (GeV/c)";
156
157 iTrackBin[4] = kNLeadingPhiBins;
158 trackBins[4] = leadingPhiBins;
159 trackAxisTitle[4] = "#phi w.r.t leading track";
160 }
161
162 for (Int_t i=0; i<initRegions; i++)
163 {
164 fTrackHist[i] = new AliCFContainer(Form("fTrackHist_%d", i), title, fgkCFSteps, nTrackVars, iTrackBin);
165
166 for (Int_t j=0; j<nTrackVars; j++)
167 {
168 fTrackHist[i]->SetBinLimits(j, trackBins[j]);
169 fTrackHist[i]->SetVarTitle(j, trackAxisTitle[j]);
170 }
171
172 SetStepNames(fTrackHist[i]);
173 }
174
175 // track 3rd and 4th axis --> event 1st and 2nd axis
176 fEventHist = new AliCFContainer("fEventHist", title, fgkCFSteps, 2, iTrackBin+2);
177
178 fEventHist->SetBinLimits(0, trackBins[2]);
179 fEventHist->SetVarTitle(0, trackAxisTitle[2]);
180
181 fEventHist->SetBinLimits(1, trackBins[3]);
182 fEventHist->SetVarTitle(1, trackAxisTitle[3]);
183
184 SetStepNames(fEventHist);
b1831bcb 185
186 iTrackBin[2] = kNSpeciesBins;
187
188 fTrackHistEfficiency = new AliCFContainer("fTrackHistEfficiency", "Tracking efficiency", 3, 3, iTrackBin);
189 fTrackHistEfficiency->SetBinLimits(0, trackBins[0]);
190 fTrackHistEfficiency->SetVarTitle(0, trackAxisTitle[0]);
191 fTrackHistEfficiency->SetBinLimits(1, trackBins[1]);
192 fTrackHistEfficiency->SetVarTitle(1, trackAxisTitle[1]);
193 fTrackHistEfficiency->SetBinLimits(2, speciesBins);
194 fTrackHistEfficiency->SetVarTitle(2, "particle species");
a75aacd6 195}
196
d1c75d06 197//_____________________________________________________________________________
198AliUEHist::AliUEHist(const AliUEHist &c) :
199 TObject(),
200 fkRegions(4),
201 fEventHist(0),
b1831bcb 202 fTrackHistEfficiency(0),
d1c75d06 203 fEtaMin(0),
204 fEtaMax(0),
205 fPtMin(0),
206 fPtMax(0),
144bd037 207 fContaminationEnhancement(0),
d1c75d06 208 fCombineMinMax(0),
209 fCache(0)
210{
211 //
212 // AliUEHist copy constructor
213 //
214
215 ((AliUEHist &) c).Copy(*this);
216}
217
a75aacd6 218//____________________________________________________________________
219void AliUEHist::SetStepNames(AliCFContainer* container)
220{
221 // sets the names of the correction steps
222
223 for (Int_t i=0; i<fgkCFSteps; i++)
224 container->SetStepTitle(i, GetStepTitle((CFStep) i));
225}
226
227//____________________________________________________________________
228AliUEHist::~AliUEHist()
229{
230 // Destructor
231
232 for (Int_t i=0; i<fkRegions; i++)
233 {
234 if (fTrackHist[i])
235 {
236 delete fTrackHist[i];
237 fTrackHist[i] = 0;
238 }
239 }
240
241 if (fEventHist)
242 {
243 delete fEventHist;
244 fEventHist = 0;
245 }
246
b1831bcb 247 if (fTrackHistEfficiency)
248 {
249 delete fTrackHistEfficiency;
250 fTrackHistEfficiency = 0;
251 }
252
a75aacd6 253 if (fCache)
254 {
255 delete fCache;
256 fCache = 0;
257 }
258}
259
260//____________________________________________________________________
261AliUEHist &AliUEHist::operator=(const AliUEHist &c)
262{
263 // assigment operator
264
265 if (this != &c)
266 ((AliUEHist &) c).Copy(*this);
267
268 return *this;
269}
270
271//____________________________________________________________________
272void AliUEHist::Copy(TObject& c) const
273{
274 // copy function
275
276 AliUEHist& target = (AliUEHist &) c;
277
278 for (Int_t i=0; i<fkRegions; i++)
279 if (fTrackHist[i])
280 target.fTrackHist[i] = dynamic_cast<AliCFContainer*> (fTrackHist[i]->Clone());
281
282 if (fEventHist)
283 target.fEventHist = dynamic_cast<AliCFContainer*> (fEventHist->Clone());
b1831bcb 284
285 if (fTrackHistEfficiency)
286 target.fTrackHistEfficiency = dynamic_cast<AliCFContainer*> (fTrackHistEfficiency->Clone());
a75aacd6 287}
288
289//____________________________________________________________________
290Long64_t AliUEHist::Merge(TCollection* list)
291{
292 // Merge a list of AliUEHist objects with this (needed for
293 // PROOF).
294 // Returns the number of merged objects (including this).
295
296 if (!list)
297 return 0;
298
299 if (list->IsEmpty())
300 return 1;
301
302 TIterator* iter = list->MakeIterator();
303 TObject* obj;
304
305 // collections of objects
b1831bcb 306 const Int_t kMaxLists = fkRegions+2;
a75aacd6 307 TList** lists = new TList*[kMaxLists];
308
309 for (Int_t i=0; i<kMaxLists; i++)
310 lists[i] = new TList;
311
312 Int_t count = 0;
313 while ((obj = iter->Next())) {
314
315 AliUEHist* entry = dynamic_cast<AliUEHist*> (obj);
316 if (entry == 0)
317 continue;
318
319 for (Int_t i=0; i<fkRegions; i++)
320 if (entry->fTrackHist[i])
321 lists[i]->Add(entry->fTrackHist[i]);
322
323 lists[fkRegions]->Add(entry->fEventHist);
b1831bcb 324 lists[fkRegions+1]->Add(entry->fTrackHistEfficiency);
a75aacd6 325
326 count++;
327 }
328 for (Int_t i=0; i<fkRegions; i++)
329 if (fTrackHist[i])
330 fTrackHist[i]->Merge(lists[i]);
331
332 fEventHist->Merge(lists[fkRegions]);
b1831bcb 333 fTrackHistEfficiency->Merge(lists[fkRegions+1]);
a75aacd6 334
335 for (Int_t i=0; i<kMaxLists; i++)
336 delete lists[i];
337
338 delete[] lists;
339
340 return count+1;
341}
342
343//____________________________________________________________________
344void AliUEHist::SetBinLimits(AliCFGridSparse* grid)
345{
346 // sets the bin limits in eta and pT defined by fEtaMin/Max, fPtMin/Max
347
348 if (fEtaMax > fEtaMin)
349 grid->SetRangeUser(0, fEtaMin, fEtaMax);
350 if (fPtMax > fPtMin)
351 grid->SetRangeUser(1, fPtMin, fPtMax);
352}
353
354//____________________________________________________________________
355void AliUEHist::ResetBinLimits(AliCFGridSparse* grid)
356{
357 // resets all bin limits
358
359 for (Int_t i=0; i<grid->GetNVar(); i++)
144bd037 360 if (grid->GetGrid()->GetAxis(i)->TestBit(TAxis::kAxisRange))
a75aacd6 361 grid->SetRangeUser(i, 0, -1);
362}
363
144bd037 364//____________________________________________________________________
365void AliUEHist::CountEmptyBins(AliUEHist::CFStep step, Float_t ptLeadMin, Float_t ptLeadMax)
366{
367 // prints the number of empty bins in the track end event histograms in the given step
368
369 Int_t binBegin[4];
370 Int_t binEnd[4];
371
372 for (Int_t i=0; i<4; i++)
373 {
374 binBegin[i] = 1;
375 binEnd[i] = fTrackHist[0]->GetNBins(i);
376 }
377
378 if (fEtaMax > fEtaMin)
379 {
380 binBegin[0] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(0)->FindBin(fEtaMin);
381 binEnd[0] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(0)->FindBin(fEtaMax);
382 }
383
384 if (fPtMax > fPtMin)
385 {
386 binBegin[1] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(1)->FindBin(fPtMin);
387 binEnd[1] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(1)->FindBin(fPtMax);
388 }
389
390 if (ptLeadMax > ptLeadMin)
391 {
392 binBegin[2] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(2)->FindBin(ptLeadMin);
393 binEnd[2] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(2)->FindBin(ptLeadMax);
394 }
395
396 // start from multiplicity 1
397 binBegin[3] = fTrackHist[0]->GetGrid(step)->GetGrid()->GetAxis(3)->FindBin(1);
398
399 for (Int_t region=0; region<fkRegions; region++)
400 {
401 Int_t total = 0;
402 Int_t count = 0;
403 Int_t vars[4];
404
405 for (Int_t i=0; i<4; i++)
406 vars[i] = binBegin[i];
407
408 AliCFGridSparse* grid = fTrackHist[region]->GetGrid(step);
409 while (1)
410 {
411 if (grid->GetElement(vars) == 0)
412 {
413 Printf("Empty bin at eta=%.2f pt=%.2f pt_lead=%.2f mult=%.1f",
414 grid->GetBinCenter(0, vars[0]),
415 grid->GetBinCenter(1, vars[1]),
416 grid->GetBinCenter(2, vars[2]),
417 grid->GetBinCenter(3, vars[3])
418 );
419 count++;
420 }
421
422 vars[3]++;
423 for (Int_t i=3; i>0; i--)
424 {
425 if (vars[i] == binEnd[i]+1)
426 {
427 vars[i] = binBegin[i];
428 vars[i-1]++;
429 }
430 }
431
432 if (vars[0] == binEnd[0]+1)
433 break;
434 total++;
435 }
436
437 Printf("Region %s has %d empty bins (out of %d bins)", GetRegionTitle((Region) region), count, total);
438 }
439}
440
a75aacd6 441//____________________________________________________________________
442TH1D* AliUEHist::GetUEHist(AliUEHist::CFStep step, AliUEHist::Region region, Float_t ptLeadMin, Float_t ptLeadMax)
443{
444 // Extracts the UE histogram at the given step and in the given region by projection and dividing tracks by events
445 //
446 // ptLeadMin, ptLeadMax: Only meaningful for vs. delta phi plot (third axis is ptLead)
447 // Histogram has to be deleted by the caller of the function
448
449 // unzoom all axes
450 ResetBinLimits(fTrackHist[region]->GetGrid(step));
451 ResetBinLimits(fEventHist->GetGrid(step));
452
453 SetBinLimits(fTrackHist[region]->GetGrid(step));
454
455 TH1D* tracks = 0;
456
457 if (ptLeadMin < 0)
458 {
459 tracks = fTrackHist[region]->ShowProjection(2, step);
460 tracks->GetYaxis()->SetTitle(fTrackHist[region]->GetTitle());
461 if (fCombineMinMax && region == kMin)
462 {
463 ResetBinLimits(fTrackHist[kMax]->GetGrid(step));
464 SetBinLimits(fTrackHist[kMax]->GetGrid(step));
465
466 TH1D* tracks2 = fTrackHist[kMax]->ShowProjection(2, step);
467 tracks->Add(tracks2);
468
469 ResetBinLimits(fTrackHist[kMax]->GetGrid(step));
470 }
471
472 // normalize to get a density (deta dphi)
473 TAxis* axis = fTrackHist[region]->GetGrid(step)->GetAxis(0);
474 Float_t phiRegion = TMath::TwoPi() / 3;
475 if (!fCombineMinMax && region == kMin)
476 phiRegion /= 2;
477 Float_t normalization = phiRegion * (axis->GetBinUpEdge(axis->GetLast()) - axis->GetBinLowEdge(axis->GetFirst()));
478 //Printf("Normalization: %f", normalization);
479 tracks->Scale(1.0 / normalization);
480
481 TH1D* events = fEventHist->ShowProjection(0, step);
482 tracks->Divide(events);
483 }
484 else
485 {
e741fadd 486 // 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
487 // therefore the number density must be calculated here per leading pT bin and then summed
488
489 Int_t firstBin = fTrackHist[region]->GetAxis(2, step)->FindBin(ptLeadMin);
490 Int_t lastBin = fTrackHist[region]->GetAxis(2, step)->FindBin(ptLeadMax);
a75aacd6 491
e741fadd 492 for (Int_t bin=firstBin; bin<=lastBin; bin++)
493 {
494 fTrackHist[region]->GetGrid(step)->GetGrid()->GetAxis(2)->SetRange(bin, bin);
495 TH1D* tracksTmp = (TH1D*) fTrackHist[region]->GetGrid(step)->Project(4);
496 Printf("Calculated histogram in bin %d --> %f tracks", bin, tracksTmp->Integral());
497 fTrackHist[region]->GetGrid(step)->SetRangeUser(2, 0, -1);
498
499 // normalize to get a density (deta dphi)
500 TAxis* axis = fTrackHist[region]->GetGrid(step)->GetAxis(0);
501 Float_t normalization = fTrackHist[region]->GetGrid(step)->GetAxis(4)->GetBinWidth(1) * (axis->GetBinUpEdge(axis->GetLast()) - axis->GetBinLowEdge(axis->GetFirst()));
502 //Printf("Normalization: %f", normalization);
503 tracksTmp->Scale(1.0 / normalization);
504
505 TH1D* events = fEventHist->ShowProjection(0, step);
506 Int_t nEvents = (Int_t) events->GetBinContent(bin);
507 if (nEvents > 0)
508 tracksTmp->Scale(1.0 / nEvents);
509 Printf("Calculated histogram in bin %d --> %d events", bin, nEvents);
510
511 if (!tracks)
512 tracks = tracksTmp;
513 else
514 {
515 tracks->Add(tracksTmp);
516 delete tracksTmp;
517 }
518 }
a75aacd6 519 }
520
521 ResetBinLimits(fTrackHist[region]->GetGrid(step));
522
523 return tracks;
524}
525
526//____________________________________________________________________
527void AliUEHist::CorrectTracks(CFStep step1, CFStep step2, TH1* trackCorrection, Int_t var1, Int_t var2)
528{
529 // corrects from step1 to step2 by multiplying the tracks with trackCorrection
530 // trackCorrection can be a function of eta (var1 == 0), pT (var1 == 1), leading pT (var1 == 2), multiplicity (var1 == 3), delta phi (var1 == 4)
531 // if var2 >= 0 a two dimension correction is assumed in trackCorrection
532 //
533 // if trackCorrection is 0, just copies content from step1 to step2
534
535 for (Int_t region=0; region<fkRegions; region++)
144bd037 536 CorrectTracks(step1, step2, region, trackCorrection, var1, var2);
537}
538
539//____________________________________________________________________
540void AliUEHist::CorrectTracks(CFStep step1, CFStep step2, Int_t region, TH1* trackCorrection, Int_t var1, Int_t var2)
541{
542 //
543 // see documentation of CorrectTracks above
544 //
545
546 if (!fTrackHist[region])
547 return;
5a53c6f2 548
144bd037 549 THnSparse* grid = fTrackHist[region]->GetGrid(step1)->GetGrid();
550 THnSparse* target = fTrackHist[region]->GetGrid(step2)->GetGrid();
551
552 // clear target histogram
553 target->Reset();
554
555 if (trackCorrection != 0)
a75aacd6 556 {
144bd037 557 if (grid->GetAxis(var1)->GetNbins() != trackCorrection->GetNbinsX())
558 AliFatal(Form("Invalid binning (var1): %d %d", grid->GetAxis(var1)->GetNbins(), trackCorrection->GetNbinsX()));
a75aacd6 559
144bd037 560 if (var2 >= 0 && grid->GetAxis(var2)->GetNbins() != trackCorrection->GetNbinsY())
561 AliFatal(Form("Invalid binning (var2): %d %d", grid->GetAxis(var2)->GetNbins(), trackCorrection->GetNbinsY()));
562 }
563
564 // optimized implementation
565 for (Int_t binIdx = 0; binIdx < grid->GetNbins(); binIdx++)
566 {
567 Int_t bins[5];
568 Double_t value = grid->GetBinContent(binIdx, bins);
569 Double_t error = grid->GetBinError(binIdx);
a75aacd6 570
571 if (trackCorrection != 0)
572 {
144bd037 573 if (var2 < 0)
a75aacd6 574 {
144bd037 575 value *= trackCorrection->GetBinContent(bins[var1]);
576 error *= trackCorrection->GetBinContent(bins[var1]);
577 }
578 else
579 {
580 value *= trackCorrection->GetBinContent(bins[var1], bins[var2]);
581 error *= trackCorrection->GetBinContent(bins[var1], bins[var2]);
a75aacd6 582 }
a75aacd6 583 }
144bd037 584
585 target->SetBinContent(bins, value);
586 target->SetBinError(bins, error);
a75aacd6 587 }
5a53c6f2 588
589 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);
a75aacd6 590}
591
592//____________________________________________________________________
593void AliUEHist::CorrectEvents(CFStep step1, CFStep step2, TH1D* eventCorrection, Int_t var)
594{
595 // corrects from step1 to step2 by multiplying the events with eventCorrection
596 // eventCorrection is as function of leading pT (var == 0) or multiplicity (var == 1)
597 //
598 // if eventCorrection is 0, just copies content from step1 to step2
599
600 AliCFGridSparse* grid = fEventHist->GetGrid(step1);
601 AliCFGridSparse* target = fEventHist->GetGrid(step2);
602
144bd037 603 // clear target histogram
604 target->GetGrid()->Reset();
605
a75aacd6 606 if (eventCorrection != 0 && grid->GetNBins(var) != eventCorrection->GetNbinsX())
607 AliFatal(Form("Invalid binning: %d %d", grid->GetNBins(var), eventCorrection->GetNbinsX()));
608
609 Int_t bins[2];
610 for (Int_t x = 1; x <= grid->GetNBins(0); x++)
611 {
612 bins[0] = x;
613 for (Int_t y = 1; y <= grid->GetNBins(1); y++)
614 {
615 bins[1] = y;
616
617 Double_t value = grid->GetElement(bins);
618 if (value != 0)
619 {
620 Double_t error = grid->GetElementError(bins);
621
622 if (eventCorrection != 0)
623 {
624 value *= eventCorrection->GetBinContent(bins[var]);
625 error *= eventCorrection->GetBinContent(bins[var]);
626 }
627
628 target->SetElement(bins, value);
629 target->SetElementError(bins, error);
630 }
631 }
632 }
5a53c6f2 633
634 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);
a75aacd6 635}
636
637//____________________________________________________________________
638void AliUEHist::Correct(AliUEHist* corrections)
639{
640 // applies the given corrections to extract from the step kCFStepReconstructed all previous steps
641 //
642 // in this object the data is expected in the step kCFStepReconstructed
643
644 // ---- track level
645
646 // bias due to migration in leading pT (because the leading particle is not reconstructed, and the subleading is used)
647 // extracted as function of leading pT
144bd037 648 for (Int_t region = 0; region < fkRegions; region++)
649 {
650 if (!fTrackHist[region])
651 continue;
ada1a03f 652
653 const char* projAxis = "z";
654 Int_t secondBin = -1;
655
656 if (fTrackHist[region]->GetNVar() == 5)
657 {
658 projAxis = "yz";
659 secondBin = 4;
660 }
661
662 #if 0
663 TH1* leadingBias = (TH1*) corrections->GetBias(kCFStepReconstructed, kCFStepTracked, region, projAxis); // from MC
664 Printf("WARNING: Using MC bias correction");
665 #else
666 TH1* leadingBias = (TH1*) GetBias(kCFStepBiasStudy, kCFStepReconstructed, region, projAxis); // from data
667 #endif
668 CorrectTracks(kCFStepReconstructed, kCFStepTracked, region, leadingBias, 2, secondBin);
144bd037 669 if (region == kMin && fCombineMinMax)
670 {
ada1a03f 671 CorrectTracks(kCFStepReconstructed, kCFStepTracked, kMax, leadingBias, 2, secondBin);
144bd037 672 delete leadingBias;
673 break;
674 }
675 delete leadingBias;
676 }
a75aacd6 677 CorrectEvents(kCFStepReconstructed, kCFStepTracked, 0, 0);
a75aacd6 678
679 // correct with kCFStepTracked --> kCFStepTrackedOnlyPrim
680 TH2D* contamination = corrections->GetTrackingContamination();
144bd037 681 if (corrections->fContaminationEnhancement)
682 {
683 Printf("Applying contamination enhancement");
684
685 for (Int_t x=1; x<=contamination->GetNbinsX(); x++)
686 for (Int_t y=1; y<=contamination->GetNbinsX(); y++)
687 contamination->SetBinContent(x, y, contamination->GetBinContent(x, y) * corrections->fContaminationEnhancement->GetBinContent(corrections->fContaminationEnhancement->GetXaxis()->FindBin(contamination->GetYaxis()->GetBinCenter(y))));
688 }
a75aacd6 689 CorrectTracks(kCFStepTracked, kCFStepTrackedOnlyPrim, contamination, 0, 1);
690 CorrectEvents(kCFStepTracked, kCFStepTrackedOnlyPrim, 0, 0);
691 delete contamination;
692
144bd037 693 // correct with kCFStepTrackedOnlyPrim --> kCFStepAnaTopology
694 TH2D* efficiencyCorrection = corrections->GetTrackingEfficiencyCorrection();
695 CorrectTracks(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, efficiencyCorrection, 0, 1);
696 CorrectEvents(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, 0, 0);
697 delete efficiencyCorrection;
a75aacd6 698
699 // copy
700 CorrectTracks(kCFStepAnaTopology, kCFStepVertex, 0, -1);
701 CorrectEvents(kCFStepAnaTopology, kCFStepVertex, 0, 0);
702
703 // vertex correction on the level of events as function of multiplicity, weighting tracks and events with the same factor
704 // practically independent of low pT cut
705 TH1D* vertexCorrection = (TH1D*) corrections->GetEventEfficiency(kCFStepVertex, kCFStepTriggered, 1);
706
707 // convert stage from true multiplicity to observed multiplicity by simple conversion factor
708 TH1D* vertexCorrectionObs = (TH1D*) vertexCorrection->Clone("vertexCorrection2");
709 vertexCorrectionObs->Reset();
710
144bd037 711 TF1* func = new TF1("func", "[1]+[0]/(x-[2])");
e741fadd 712 vertexCorrection->Fit(func, "0I", "", 0, 3);
144bd037 713
a75aacd6 714 for (Int_t i=1; i<=vertexCorrectionObs->GetNbinsX(); i++)
144bd037 715 {
716 Float_t xPos = 1.0 / 0.77 * vertexCorrectionObs->GetXaxis()->GetBinCenter(i);
e741fadd 717 if (xPos < 3)
144bd037 718 vertexCorrectionObs->SetBinContent(i, func->Eval(xPos));
719 else
720 vertexCorrectionObs->SetBinContent(i, vertexCorrection->Interpolate(xPos));
721 }
a75aacd6 722
b1831bcb 723 #if 0
144bd037 724 new TCanvas;
a75aacd6 725 vertexCorrection->DrawCopy();
726 vertexCorrectionObs->SetLineColor(2);
144bd037 727 vertexCorrectionObs->DrawCopy("same");
ada1a03f 728 func->SetRange(0, 4);
729 func->DrawClone("same");
b1831bcb 730 #endif
a75aacd6 731
732 CorrectTracks(kCFStepVertex, kCFStepTriggered, vertexCorrectionObs, 3);
733 CorrectEvents(kCFStepVertex, kCFStepTriggered, vertexCorrectionObs, 1);
734 delete vertexCorrectionObs;
735 delete vertexCorrection;
ada1a03f 736 delete func;
a75aacd6 737
738 // copy
739 CorrectTracks(kCFStepTriggered, kCFStepAll, 0, -1);
740 CorrectEvents(kCFStepTriggered, kCFStepAll, 0, 0);
741}
742
743//____________________________________________________________________
b1831bcb 744TH1* AliUEHist::GetTrackEfficiency(CFStep step1, CFStep step2, Int_t axis1, Int_t axis2, Int_t source)
a75aacd6 745{
746 // creates a track-level efficiency by dividing step2 by step1
747 // projected to axis1 and axis2 (optional if >= 0)
b1831bcb 748 //
749 // source: 0 = fTrackHist; 1 = fTrackHistEfficiency
a75aacd6 750
751 // integrate over regions
752 // cache it for efficiency (usually more than one efficiency is requested)
b1831bcb 753
754 AliCFContainer* sourceContainer = 0;
755
756 if (source == 0)
a75aacd6 757 {
b1831bcb 758 if (!fCache)
759 {
760 fCache = (AliCFContainer*) fTrackHist[0]->Clone();
761 for (Int_t i = 1; i < fkRegions; i++)
762 if (fTrackHist[i])
763 fCache->Add(fTrackHist[i]);
764 }
765 sourceContainer = fCache;
a75aacd6 766 }
b1831bcb 767 else if (source == 1)
768 {
769 sourceContainer = fTrackHistEfficiency;
770 // step offset because we start with kCFStepAnaTopology
771 step1 = (CFStep) ((Int_t) step1 - (Int_t) kCFStepAnaTopology);
772 step2 = (CFStep) ((Int_t) step2 - (Int_t) kCFStepAnaTopology);
773 }
774 else
775 return 0;
776
a75aacd6 777 // reset all limits and set the right ones except those in axis1 and axis2
b1831bcb 778 ResetBinLimits(sourceContainer->GetGrid(step1));
779 ResetBinLimits(sourceContainer->GetGrid(step2));
a75aacd6 780 if (fEtaMax > fEtaMin && axis1 != 0 && axis2 != 0)
781 {
b1831bcb 782 sourceContainer->GetGrid(step1)->SetRangeUser(0, fEtaMin, fEtaMax);
783 sourceContainer->GetGrid(step2)->SetRangeUser(0, fEtaMin, fEtaMax);
a75aacd6 784 }
785 if (fPtMax > fPtMin && axis1 != 1 && axis2 != 1)
786 {
b1831bcb 787 sourceContainer->GetGrid(step1)->SetRangeUser(1, fPtMin, fPtMax);
788 sourceContainer->GetGrid(step2)->SetRangeUser(1, fPtMin, fPtMax);
a75aacd6 789 }
790
791 TH1* measured = 0;
792 TH1* generated = 0;
793
144bd037 794 if (axis2 >= 0)
a75aacd6 795 {
b1831bcb 796 generated = sourceContainer->Project(axis1, axis2, step1);
797 measured = sourceContainer->Project(axis1, axis2, step2);
a75aacd6 798 }
799 else
800 {
b1831bcb 801 generated = sourceContainer->Project(axis1, step1);
802 measured = sourceContainer->Project(axis1, step2);
a75aacd6 803 }
804
144bd037 805 // check for bins with less than 100 entries, print warning
806 Int_t binBegin[2];
807 Int_t binEnd[2];
808
809 binBegin[0] = 1;
810 binBegin[1] = 1;
811
812 binEnd[0] = generated->GetNbinsX();
813 binEnd[1] = generated->GetNbinsY();
814
815 if (fEtaMax > fEtaMin)
816 {
817 if (axis1 == 0)
818 {
819 binBegin[0] = generated->GetXaxis()->FindBin(fEtaMin);
820 binEnd[0] = generated->GetXaxis()->FindBin(fEtaMax);
821 }
822 if (axis2 == 0)
823 {
824 binBegin[1] = generated->GetYaxis()->FindBin(fEtaMin);
825 binEnd[1] = generated->GetYaxis()->FindBin(fEtaMax);
826 }
827 }
828
829 if (fPtMax > fPtMin)
830 {
831 // TODO this is just checking up to 15 for now
832 Float_t ptMax = TMath::Min((Float_t) 15., fPtMax);
833 if (axis1 == 1)
834 {
835 binBegin[0] = generated->GetXaxis()->FindBin(fPtMin);
836 binEnd[0] = generated->GetXaxis()->FindBin(ptMax);
837 }
838 if (axis2 == 1)
839 {
840 binBegin[1] = generated->GetYaxis()->FindBin(fPtMin);
841 binEnd[1] = generated->GetYaxis()->FindBin(ptMax);
842 }
843 }
844
845 Int_t total = 0;
846 Int_t count = 0;
847 Int_t vars[2];
848
849 for (Int_t i=0; i<2; i++)
850 vars[i] = binBegin[i];
851
852 const Int_t limit = 50;
853 while (1)
854 {
855 if (generated->GetDimension() == 1 && generated->GetBinContent(vars[0]) < limit)
856 {
857 Printf("Empty bin at %s=%.2f (%.2f entries)", generated->GetXaxis()->GetTitle(), generated->GetXaxis()->GetBinCenter(vars[0]), generated->GetBinContent(vars[0]));
858 count++;
859 }
860 else if (generated->GetDimension() == 2 && generated->GetBinContent(vars[0], vars[1]) < limit)
861 {
862 Printf("Empty bin at %s=%.2f %s=%.2f (%.2f entries)",
863 generated->GetXaxis()->GetTitle(), generated->GetXaxis()->GetBinCenter(vars[0]),
864 generated->GetYaxis()->GetTitle(), generated->GetYaxis()->GetBinCenter(vars[1]),
865 generated->GetBinContent(vars[0], vars[1]));
866 count++;
867 }
868
869 vars[1]++;
870 if (vars[1] == binEnd[1]+1)
871 {
872 vars[1] = binBegin[1];
873 vars[0]++;
874 }
875
876 if (vars[0] == binEnd[0]+1)
877 break;
878 total++;
879 }
880
881 Printf("Correction has %d empty bins (out of %d bins)", count, total);
882
883 measured->Divide(measured, generated, 1, 1, "B");
a75aacd6 884
885 delete generated;
886
b1831bcb 887 ResetBinLimits(sourceContainer->GetGrid(step1));
888 ResetBinLimits(sourceContainer->GetGrid(step2));
889
a75aacd6 890 return measured;
891}
892
893//____________________________________________________________________
894TH1* AliUEHist::GetEventEfficiency(CFStep step1, CFStep step2, Int_t axis1, Int_t axis2, Float_t ptLeadMin, Float_t ptLeadMax)
895{
896 // creates a event-level efficiency by dividing step2 by step1
897 // projected to axis1 and axis2 (optional if >= 0)
898
899 if (ptLeadMax > ptLeadMin)
900 {
901 fEventHist->GetGrid(step1)->SetRangeUser(0, ptLeadMin, ptLeadMax);
902 fEventHist->GetGrid(step2)->SetRangeUser(0, ptLeadMin, ptLeadMax);
903 }
904
905 TH1* measured = 0;
906 TH1* generated = 0;
907
144bd037 908 if (axis2 >= 0)
a75aacd6 909 {
910 generated = fEventHist->Project(axis1, axis2, step1);
911 measured = fEventHist->Project(axis1, axis2, step2);
912 }
913 else
914 {
915 generated = fEventHist->Project(axis1, step1);
916 measured = fEventHist->Project(axis1, step2);
917 }
918
144bd037 919 measured->Divide(measured, generated, 1, 1, "B");
a75aacd6 920
921 delete generated;
922
923 if (ptLeadMax > ptLeadMin)
924 {
925 fEventHist->GetGrid(step1)->SetRangeUser(0, 0, -1);
926 fEventHist->GetGrid(step2)->SetRangeUser(0, 0, -1);
927 }
928
929 return measured;
930}
931
932//____________________________________________________________________
933void AliUEHist::WeightHistogram(TH3* hist1, TH1* hist2)
934{
935 // weights each entry of the 3d histogram hist1 with the 1d histogram hist2
936 // where the matching is done of the z axis of hist1 with the x axis of hist2
937
938 if (hist1->GetNbinsZ() != hist2->GetNbinsX())
939 AliFatal(Form("Inconsistent binning %d %d", hist1->GetNbinsZ(), hist2->GetNbinsX()));
940
941 for (Int_t x=1; x<=hist1->GetNbinsX(); x++)
942 {
943 for (Int_t y=1; y<=hist1->GetNbinsY(); y++)
944 {
945 for (Int_t z=1; z<=hist1->GetNbinsZ(); z++)
946 {
947 if (hist2->GetBinContent(z) > 0)
948 {
949 hist1->SetBinContent(x, y, z, hist1->GetBinContent(x, y, z) / hist2->GetBinContent(z));
950 hist1->SetBinError(x, y, z, hist1->GetBinError(x, y, z) / hist2->GetBinContent(z));
951 }
952 else
953 {
954 hist1->SetBinContent(x, y, z, 0);
955 hist1->SetBinError(x, y, z, 0);
956 }
957 }
958 }
959 }
960}
961
962//____________________________________________________________________
144bd037 963TH1* AliUEHist::GetBias(CFStep step1, CFStep step2, Int_t region, const char* axis, Float_t leadPtMin, Float_t leadPtMax)
a75aacd6 964{
965 // extracts the track-level bias (integrating out the multiplicity) between two steps (dividing step2 by step1)
144bd037 966 // in the given region (sum over all regions is calculated if region == -1)
a75aacd6 967 // done by weighting the track-level distribution with the number of events as function of leading pT
968 // and then calculating the ratio between the distributions
969 // projected to axis which is a TH3::Project3D string, e.g. "x", or "yx"
970 // no projection is done if axis == 0
971
144bd037 972 AliCFContainer* tmp = 0;
973
974 if (region == -1)
975 {
976 tmp = (AliCFContainer*) fTrackHist[0]->Clone();
977 for (Int_t i = 1; i < fkRegions; i++)
978 if (fTrackHist[i])
979 tmp->Add(fTrackHist[i]);
980 }
981 else if (region == kMin && fCombineMinMax)
982 {
983 tmp = (AliCFContainer*) fTrackHist[kMin]->Clone();
984 tmp->Add(fTrackHist[kMax]);
985 }
986 else
987 tmp = fTrackHist[region];
988
989 ResetBinLimits(tmp->GetGrid(step1));
990 ResetBinLimits(fEventHist->GetGrid(step1));
991 SetBinLimits(tmp->GetGrid(step1));
992
993 ResetBinLimits(tmp->GetGrid(step2));
994 ResetBinLimits(fEventHist->GetGrid(step2));
995 SetBinLimits(tmp->GetGrid(step2));
a75aacd6 996
df269636 997 TH1D* events1 = (TH1D*)fEventHist->Project(0, step1);
998 TH3D* hist1 = (TH3D*)tmp->Project(0, tmp->GetNVar()-1, 2, step1);
a75aacd6 999 WeightHistogram(hist1, events1);
1000
df269636 1001 TH1D* events2 = (TH1D*)fEventHist->Project(0, step2);
1002 TH3D* hist2 = (TH3D*)tmp->Project(0, tmp->GetNVar()-1, 2, step2);
a75aacd6 1003 WeightHistogram(hist2, events2);
1004
1005 TH1* generated = hist1;
1006 TH1* measured = hist2;
1007
1008 if (axis)
1009 {
1010 if (leadPtMax > leadPtMin)
1011 {
1012 hist1->GetZaxis()->SetRangeUser(leadPtMin, leadPtMax);
1013 hist2->GetZaxis()->SetRangeUser(leadPtMin, leadPtMax);
1014 }
1015
1016 if (fEtaMax > fEtaMin && !TString(axis).Contains("x"))
1017 {
1018 hist1->GetXaxis()->SetRangeUser(fEtaMin, fEtaMax);
1019 hist2->GetXaxis()->SetRangeUser(fEtaMin, fEtaMax);
1020 }
ada1a03f 1021
a75aacd6 1022 generated = hist1->Project3D(axis);
1023 measured = hist2->Project3D(axis);
1024
1025 // delete hists here if projection has been done
1026 delete hist1;
1027 delete hist2;
1028 }
1029
1030 measured->Divide(generated);
1031
1032 delete events1;
1033 delete events2;
1034 delete generated;
144bd037 1035
1036 ResetBinLimits(tmp->GetGrid(step1));
1037 ResetBinLimits(tmp->GetGrid(step2));
1038
29e8465c 1039 if ((region == -1) || (region == kMin && fCombineMinMax))
144bd037 1040 delete tmp;
a75aacd6 1041
1042 return measured;
1043}
1044
1045//____________________________________________________________________
1046TH2D* AliUEHist::GetTrackingEfficiency()
1047{
1048 // extracts the tracking efficiency by calculating the efficiency from step kCFStepAnaTopology to kCFStepTrackedOnlyPrim
1049 // integrates over the regions and all other variables than pT and eta to increase the statistics
1050 //
1051 // returned histogram has to be deleted by the user
1052
1053 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepAnaTopology, kCFStepTrackedOnlyPrim, 0, 1));
1054}
1055
1056//____________________________________________________________________
1057TH1D* AliUEHist::GetTrackingEfficiency(Int_t axis)
1058{
1059 // extracts the tracking efficiency by calculating the efficiency from step kCFStepAnaTopology to kCFStepTrackedOnlyPrim
1060 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
1061
1062 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepAnaTopology, kCFStepTrackedOnlyPrim, axis));
1063}
1064
1065//____________________________________________________________________
1066TH2D* AliUEHist::GetTrackingCorrection()
1067{
1068 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1069 // integrates over the regions and all other variables than pT and eta to increase the statistics
1070 //
1071 // returned histogram has to be deleted by the user
1072
1073 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTracked, kCFStepAnaTopology, 0, 1));
1074}
1075
1076//____________________________________________________________________
1077TH1D* AliUEHist::GetTrackingCorrection(Int_t axis)
1078{
1079 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1080 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
1081
1082 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepTracked, kCFStepAnaTopology, axis));
1083}
1084
144bd037 1085//____________________________________________________________________
1086TH2D* AliUEHist::GetTrackingEfficiencyCorrection()
1087{
1088 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1089 // integrates over the regions and all other variables than pT and eta to increase the statistics
1090 //
1091 // returned histogram has to be deleted by the user
1092
1093 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, 0, 1));
1094}
1095
1096//____________________________________________________________________
1097TH1D* AliUEHist::GetTrackingEfficiencyCorrection(Int_t axis)
1098{
1099 // extracts the tracking correction by calculating the efficiency from step kCFStepAnaTopology to kCFStepTracked
1100 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
1101
1102 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepTrackedOnlyPrim, kCFStepAnaTopology, axis));
1103}
1104
a75aacd6 1105//____________________________________________________________________
1106TH2D* AliUEHist::GetTrackingContamination()
1107{
1108 // extracts the tracking contamination by secondaries by calculating the efficiency from step kCFStepTrackedOnlyPrim to kCFStepTracked
1109 // integrates over the regions and all other variables than pT and eta to increase the statistics
1110 //
1111 // returned histogram has to be deleted by the user
1112
1113 return dynamic_cast<TH2D*> (GetTrackEfficiency(kCFStepTracked, kCFStepTrackedOnlyPrim, 0, 1));
1114}
1115
1116//____________________________________________________________________
1117TH1D* AliUEHist::GetTrackingContamination(Int_t axis)
1118{
1119 // extracts the tracking contamination by secondaries by calculating the efficiency from step kCFStepTrackedOnlyPrim to kCFStepTracked
1120 // integrates over the regions and all other variables than pT (axis == 0) and eta (axis == 1) to increase the statistics
1121
1122 return dynamic_cast<TH1D*> (GetTrackEfficiency(kCFStepTracked, kCFStepTrackedOnlyPrim, axis));
1123}
1124
1125//____________________________________________________________________
1126const char* AliUEHist::GetRegionTitle(Region region)
1127{
1128 // returns the name of the given region
1129
1130 switch (region)
1131 {
1132 case kToward:
1133 return "Towards";
1134 case kAway:
1135 return "Away";
1136 case kMin:
1137 return (fCombineMinMax) ? "Transverse" : "Min";
1138 case kMax:
1139 return "Max";
1140 }
1141
1142 return 0;
1143}
1144
1145//____________________________________________________________________
1146const char* AliUEHist::GetStepTitle(CFStep step)
1147{
1148 // returns the name of the given step
1149
1150 switch (step)
1151 {
1152 case kCFStepAll:
1153 return "All events";
1154 case kCFStepTriggered:
1155 return "Triggered";
1156 case kCFStepVertex:
1157 return "Primary Vertex";
1158 case kCFStepAnaTopology:
1159 return "Required analysis topology";
1160 case kCFStepTrackedOnlyPrim:
1161 return "Tracked (matched MC, only primaries)";
1162 case kCFStepTracked:
1163 return "Tracked (matched MC, all)";
1164 case kCFStepReconstructed:
1165 return "Reconstructed";
1166 case kCFStepRealLeading:
1167 return "Correct leading particle identified";
1168 case kCFStepBiasStudy:
1169 return "Bias study applying tracking efficiency";
1170 case kCFStepBiasStudy2:
1171 return "Bias study applying tracking efficiency in two steps";
1172 }
1173
1174 return 0;
1175}
b1831bcb 1176
1177//____________________________________________________________________
1178void AliUEHist::CopyReconstructedData(AliUEHist* from)
1179{
1180 // copies those histograms extracted from ESD to this object
1181
1182 // TODO at present only the pointers are copied
1183
1184 for (Int_t region=0; region<4; region++)
1185 {
1186 if (!fTrackHist[region])
1187 continue;
1188
1189 fTrackHist[region]->SetGrid(AliUEHist::kCFStepReconstructed, from->fTrackHist[region]->GetGrid(AliUEHist::kCFStepReconstructed));
df269636 1190 //fTrackHist[region]->SetGrid(AliUEHist::kCFStepTrackedOnlyPrim, from->fTrackHist[region]->GetGrid(AliUEHist::kCFStepTrackedOnlyPrim));
b1831bcb 1191 fTrackHist[region]->SetGrid(AliUEHist::kCFStepBiasStudy, from->fTrackHist[region]->GetGrid(AliUEHist::kCFStepBiasStudy));
1192 }
1193
1194 fEventHist->SetGrid(AliUEHist::kCFStepReconstructed, from->fEventHist->GetGrid(AliUEHist::kCFStepReconstructed));
df269636 1195 //fEventHist->SetGrid(AliUEHist::kCFStepTrackedOnlyPrim, from->fEventHist->GetGrid(AliUEHist::kCFStepTrackedOnlyPrim));
b1831bcb 1196 fEventHist->SetGrid(AliUEHist::kCFStepBiasStudy, from->fEventHist->GetGrid(AliUEHist::kCFStepBiasStudy));
1197}
6f803f6c 1198
1199//____________________________________________________________________
df269636 1200void AliUEHist::ExtendTrackingEfficiency(Bool_t verbose)
6f803f6c 1201{
1202 // fits the tracking efficiency at high pT with a constant and fills all bins with this tracking efficiency
1203
1204 Float_t fitRangeBegin = 5.01;
1205 Float_t fitRangeEnd = 14.99;
1206 Float_t extendRangeBegin = 10.01;
1207
1208 TH1* obj = GetTrackingEfficiency(1);
1209
df269636 1210 if (verbose)
1211 new TCanvas; obj->Draw();
1212 obj->Fit("pol0", (verbose) ? "+" : "+0", "SAME", fitRangeBegin, fitRangeEnd);
6f803f6c 1213
1214 Float_t trackingEff = obj->GetFunction("pol0")->GetParameter(0);
1215
1216 obj = GetTrackingContamination(1);
1217
df269636 1218 if (verbose)
1219 new TCanvas; obj->Draw();
1220 obj->Fit("pol0", (verbose) ? "+" : "+0", "SAME", fitRangeBegin, fitRangeEnd);
6f803f6c 1221
1222 Float_t trackingCont = obj->GetFunction("pol0")->GetParameter(0);
1223
1224 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);
1225
1226 // extend up to pT 100
1227 for (Int_t x = fTrackHistEfficiency->GetAxis(0, 0)->FindBin(fEtaMin); x <= fTrackHistEfficiency->GetAxis(0, 0)->FindBin(fEtaMax); x++)
1228 for (Int_t y = fTrackHistEfficiency->GetAxis(1, 0)->FindBin(extendRangeBegin); y <= fTrackHistEfficiency->GetNBins(1); y++)
df269636 1229 for (Int_t z = 1; z <= fTrackHistEfficiency->GetNBins(2); z++) // particle type axis
6f803f6c 1230 {
6f803f6c 1231 Int_t bins[3];
1232 bins[0] = x;
1233 bins[1] = y;
1234 bins[2] = z;
1235
df269636 1236 fTrackHistEfficiency->GetGrid(0)->SetElement(bins, 100);
1237 fTrackHistEfficiency->GetGrid(1)->SetElement(bins, 100.0 * trackingEff);
1238 fTrackHistEfficiency->GetGrid(2)->SetElement(bins, 100.0 * trackingEff / trackingCont);
6f803f6c 1239 }
1240}
e741fadd 1241
1242void AliUEHist::AdditionalDPhiCorrection(Int_t step)
1243{
1244 // corrects the dphi distribution with an extra factor close to dphi ~ 0
1245
1246 Printf("WARNING: In AliUEHist::AdditionalDPhiCorrection.");
1247
1248 THnSparse* grid = fTrackHist[0]->GetGrid(step)->GetGrid();
1249
1250 // optimized implementation
1251 for (Int_t binIdx = 0; binIdx < grid->GetNbins(); binIdx++)
1252 {
1253 Int_t bins[5];
1254 Double_t value = grid->GetBinContent(binIdx, bins);
1255 Double_t error = grid->GetBinError(binIdx);
1256
1257 Float_t binCenter = grid->GetAxis(4)->GetBinCenter(bins[4]);
1258 if (TMath::Abs(binCenter) < 0.2)
1259 {
1260 value *= 0.985;
1261 error *= 0.985;
1262 }
1263 else if (TMath::Abs(binCenter) < 0.3)
1264 {
1265 value *= 0.9925;
1266 error *= 0.9925;
1267 }
1268
1269 grid->SetBinContent(bins, value);
1270 grid->SetBinError(bins, error);
1271 }
1272}