]>
Commit | Line | Data |
---|---|---|
d560b581 | 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 | ||
55e05544 | 16 | /* $Id$ */ |
17 | ||
18 | #include "AlidNdEtaCorrection.h" | |
19 | ||
74fd10b3 | 20 | #include <AliLog.h> |
55e05544 | 21 | #include <TCanvas.h> |
847489f7 | 22 | #include <TH3F.h> |
23 | #include <TH1D.h> | |
d560b581 | 24 | #include <TDirectory.h> |
74fd10b3 | 25 | #include <AliCorrection.h> |
26 | #include <AliCorrectionMatrix2D.h> | |
27 | #include <AliCorrectionMatrix3D.h> | |
55e05544 | 28 | |
29 | //____________________________________________________________________ | |
30 | ClassImp(AlidNdEtaCorrection) | |
31 | ||
32 | //____________________________________________________________________ | |
8b3563f4 | 33 | AlidNdEtaCorrection::AlidNdEtaCorrection() |
34 | : TNamed(), | |
35 | fTrack2ParticleCorrection(0), | |
36 | fVertexRecoCorrection(0), | |
7584d357 | 37 | fTriggerBiasCorrectionMBToINEL(0), |
38 | fTriggerBiasCorrectionMBToNSD(0), | |
39 | fTriggerBiasCorrectionMBToND(0) | |
8b3563f4 | 40 | { |
41 | // default constructor | |
42 | } | |
43 | ||
44 | //____________________________________________________________________ | |
0f67a57c | 45 | AlidNdEtaCorrection::AlidNdEtaCorrection(const Char_t* name, const Char_t* title, const char* analysis) |
8b3563f4 | 46 | : TNamed(name, title), |
38233af1 | 47 | fTrack2ParticleCorrection(0), |
48 | fVertexRecoCorrection(0), | |
7584d357 | 49 | fTriggerBiasCorrectionMBToINEL(0), |
50 | fTriggerBiasCorrectionMBToNSD(0), | |
51 | fTriggerBiasCorrectionMBToND(0) | |
8b3563f4 | 52 | { |
74fd10b3 | 53 | // |
55e05544 | 54 | // constructor |
55 | // | |
56 | ||
0f67a57c | 57 | fTrack2ParticleCorrection = new AliCorrection("Track2Particle", "Track2Particle", analysis); |
58 | fVertexRecoCorrection = new AliCorrection("VertexReconstruction", "VertexReconstruction", analysis); | |
1afae8ff | 59 | |
0f67a57c | 60 | fTriggerBiasCorrectionMBToINEL = new AliCorrection("TriggerBias_MBToINEL", "TriggerBias_MBToINEL", analysis); |
61 | fTriggerBiasCorrectionMBToNSD = new AliCorrection("TriggerBias_MBToNSD", "TriggerBias_MBToNSD", analysis); | |
62 | fTriggerBiasCorrectionMBToND = new AliCorrection("TriggerBias_MBToND", "TriggerBias_MBToND", analysis); | |
55e05544 | 63 | } |
64 | ||
38233af1 | 65 | //____________________________________________________________________ |
66 | AlidNdEtaCorrection::~AlidNdEtaCorrection() | |
67 | { | |
68 | // destructor | |
69 | ||
7584d357 | 70 | if (fTrack2ParticleCorrection) { |
38233af1 | 71 | delete fTrack2ParticleCorrection; |
72 | fTrack2ParticleCorrection = 0; | |
73 | } | |
74 | ||
7584d357 | 75 | if (fVertexRecoCorrection) { |
38233af1 | 76 | delete fVertexRecoCorrection; |
77 | fVertexRecoCorrection = 0; | |
78 | } | |
79 | ||
7584d357 | 80 | if (fTriggerBiasCorrectionMBToINEL) { |
81 | delete fTriggerBiasCorrectionMBToINEL; | |
82 | fTriggerBiasCorrectionMBToINEL = 0; | |
38233af1 | 83 | } |
84 | ||
7584d357 | 85 | if (fTriggerBiasCorrectionMBToNSD) { |
86 | delete fTriggerBiasCorrectionMBToNSD; | |
87 | fTriggerBiasCorrectionMBToNSD = 0; | |
88 | } | |
89 | ||
90 | if (fTriggerBiasCorrectionMBToND) { | |
91 | delete fTriggerBiasCorrectionMBToND; | |
92 | fTriggerBiasCorrectionMBToND = 0; | |
38233af1 | 93 | } |
94 | } | |
95 | ||
55e05544 | 96 | //____________________________________________________________________ |
97 | void | |
45e97e28 | 98 | AlidNdEtaCorrection::Finish() { |
55e05544 | 99 | // |
100 | // finish method | |
101 | // | |
45e97e28 | 102 | // divide the histograms in the AliCorrectionMatrix2D objects to get the corrections |
55e05544 | 103 | |
45e97e28 | 104 | fTrack2ParticleCorrection->Divide(); |
55e05544 | 105 | fVertexRecoCorrection->Divide(); |
7584d357 | 106 | fTriggerBiasCorrectionMBToINEL->Divide(); |
107 | fTriggerBiasCorrectionMBToNSD->Divide(); | |
108 | fTriggerBiasCorrectionMBToND->Divide(); | |
55e05544 | 109 | } |
110 | ||
111 | //____________________________________________________________________ | |
74fd10b3 | 112 | Long64_t AlidNdEtaCorrection::Merge(TCollection* list) |
113 | { | |
55e05544 | 114 | // Merge a list of dNdEtaCorrection objects with this (needed for |
7af955da | 115 | // PROOF). |
55e05544 | 116 | // Returns the number of merged objects (including this). |
117 | ||
118 | if (!list) | |
119 | return 0; | |
7af955da | 120 | |
55e05544 | 121 | if (list->IsEmpty()) |
122 | return 1; | |
123 | ||
124 | TIterator* iter = list->MakeIterator(); | |
125 | TObject* obj; | |
126 | ||
127 | // collections of measured and generated histograms | |
7584d357 | 128 | TList* collectionNtrackToNparticle = new TList; |
129 | TList* collectionVertexReco = new TList; | |
130 | TList* collectionTriggerBiasMBToINEL = new TList; | |
131 | TList* collectionTriggerBiasMBToNSD = new TList; | |
132 | TList* collectionTriggerBiasMBToND = new TList; | |
55e05544 | 133 | |
134 | Int_t count = 0; | |
135 | while ((obj = iter->Next())) { | |
7af955da | 136 | |
55e05544 | 137 | AlidNdEtaCorrection* entry = dynamic_cast<AlidNdEtaCorrection*> (obj); |
7af955da | 138 | if (entry == 0) |
55e05544 | 139 | continue; |
140 | ||
74fd10b3 | 141 | collectionNtrackToNparticle ->Add(entry->fTrack2ParticleCorrection); |
142 | collectionVertexReco ->Add(entry->fVertexRecoCorrection); | |
143 | collectionTriggerBiasMBToINEL->Add(entry->fTriggerBiasCorrectionMBToINEL); | |
144 | collectionTriggerBiasMBToNSD ->Add(entry->fTriggerBiasCorrectionMBToNSD); | |
145 | collectionTriggerBiasMBToND ->Add(entry->fTriggerBiasCorrectionMBToND); | |
55e05544 | 146 | |
147 | count++; | |
148 | } | |
7584d357 | 149 | fTrack2ParticleCorrection ->Merge(collectionNtrackToNparticle); |
150 | fVertexRecoCorrection ->Merge(collectionVertexReco); | |
151 | fTriggerBiasCorrectionMBToINEL ->Merge(collectionTriggerBiasMBToINEL); | |
152 | fTriggerBiasCorrectionMBToNSD ->Merge(collectionTriggerBiasMBToNSD); | |
153 | fTriggerBiasCorrectionMBToND ->Merge(collectionTriggerBiasMBToND); | |
10ebe68d | 154 | |
55e05544 | 155 | delete collectionNtrackToNparticle; |
156 | delete collectionVertexReco; | |
7584d357 | 157 | delete collectionTriggerBiasMBToINEL; |
158 | delete collectionTriggerBiasMBToNSD; | |
159 | delete collectionTriggerBiasMBToND; | |
10ebe68d | 160 | |
55e05544 | 161 | return count+1; |
162 | } | |
163 | ||
2e88424e | 164 | //____________________________________________________________________ |
165 | void AlidNdEtaCorrection::Add(AlidNdEtaCorrection* aCorrectionsToAdd, Float_t c) { | |
166 | // | |
167 | // adds the measured and generated of aCorrectionsToAdd to measured and generated | |
168 | // of all corrections in this | |
169 | ||
170 | fTrack2ParticleCorrection ->Add(aCorrectionsToAdd->GetTrack2ParticleCorrection() ,c); | |
171 | fVertexRecoCorrection ->Add(aCorrectionsToAdd->GetVertexRecoCorrection() ,c); | |
172 | fTriggerBiasCorrectionMBToINEL ->Add(aCorrectionsToAdd->GetTriggerBiasCorrectionINEL(),c); | |
173 | fTriggerBiasCorrectionMBToNSD ->Add(aCorrectionsToAdd->GetTriggerBiasCorrectionNSD() ,c); | |
174 | fTriggerBiasCorrectionMBToND ->Add(aCorrectionsToAdd->GetTriggerBiasCorrectionND() ,c); | |
175 | ||
176 | } | |
177 | ||
178 | //____________________________________________________________________ | |
179 | void AlidNdEtaCorrection::Reset(void) { | |
180 | // | |
181 | // reset all corrections | |
182 | // | |
183 | ||
184 | fTrack2ParticleCorrection ->Reset(); | |
185 | fVertexRecoCorrection ->Reset(); | |
186 | fTriggerBiasCorrectionMBToINEL ->Reset(); | |
187 | fTriggerBiasCorrectionMBToNSD ->Reset(); | |
188 | fTriggerBiasCorrectionMBToND ->Reset(); | |
189 | ||
190 | } | |
191 | ||
192 | ||
193 | ||
55e05544 | 194 | //____________________________________________________________________ |
74fd10b3 | 195 | Bool_t AlidNdEtaCorrection::LoadHistograms(const Char_t* dir) |
196 | { | |
55e05544 | 197 | // |
198 | // loads the histograms | |
74fd10b3 | 199 | // if dir is empty a directory with the name of this object is taken (like in SaveHistogram) |
55e05544 | 200 | // |
201 | ||
74fd10b3 | 202 | if (!dir) |
203 | dir = GetName(); | |
7584d357 | 204 | |
74fd10b3 | 205 | if (!gDirectory->cd(dir)) |
206 | return kFALSE; | |
207 | ||
208 | fTrack2ParticleCorrection ->LoadHistograms(); | |
209 | fVertexRecoCorrection ->LoadHistograms(); | |
210 | fTriggerBiasCorrectionMBToINEL ->LoadHistograms(); | |
211 | fTriggerBiasCorrectionMBToNSD ->LoadHistograms(); | |
212 | fTriggerBiasCorrectionMBToND ->LoadHistograms(); | |
213 | ||
214 | gDirectory->cd(".."); | |
1afae8ff | 215 | |
55e05544 | 216 | return kTRUE; |
217 | } | |
218 | ||
55e05544 | 219 | //____________________________________________________________________ |
74fd10b3 | 220 | void AlidNdEtaCorrection::SaveHistograms() |
221 | { | |
55e05544 | 222 | // |
223 | // save the histograms | |
224 | // | |
225 | ||
226 | gDirectory->mkdir(fName.Data()); | |
227 | gDirectory->cd(fName.Data()); | |
228 | ||
7584d357 | 229 | fTrack2ParticleCorrection ->SaveHistograms(); |
230 | fVertexRecoCorrection ->SaveHistograms(); | |
231 | fTriggerBiasCorrectionMBToINEL->SaveHistograms(); | |
232 | fTriggerBiasCorrectionMBToNSD ->SaveHistograms(); | |
233 | fTriggerBiasCorrectionMBToND ->SaveHistograms(); | |
55e05544 | 234 | |
74fd10b3 | 235 | gDirectory->cd(".."); |
55e05544 | 236 | } |
237 | ||
238 | //____________________________________________________________________ | |
239 | void AlidNdEtaCorrection::DrawHistograms() | |
240 | { | |
241 | // | |
dd367a14 | 242 | // call the draw histogram method of the corrections |
74fd10b3 | 243 | // |
55e05544 | 244 | |
7584d357 | 245 | fTrack2ParticleCorrection ->DrawHistograms(); |
246 | fVertexRecoCorrection ->DrawHistograms(); | |
247 | fTriggerBiasCorrectionMBToINEL->DrawHistograms(); | |
248 | fTriggerBiasCorrectionMBToNSD ->DrawHistograms(); | |
249 | fTriggerBiasCorrectionMBToND ->DrawHistograms(); | |
7584d357 | 250 | } |
251 | ||
dd367a14 | 252 | //____________________________________________________________________ |
253 | void AlidNdEtaCorrection::DrawOverview(const char* canvasName) | |
254 | { | |
255 | // | |
256 | // call the DrawOverview histogram method of the corrections | |
257 | // | |
258 | ||
259 | fTrack2ParticleCorrection ->DrawOverview(canvasName); | |
260 | fVertexRecoCorrection ->DrawOverview(canvasName); | |
261 | fTriggerBiasCorrectionMBToINEL->DrawOverview(canvasName); | |
262 | fTriggerBiasCorrectionMBToNSD ->DrawOverview(canvasName); | |
263 | fTriggerBiasCorrectionMBToND ->DrawOverview(canvasName); | |
264 | } | |
265 | ||
7584d357 | 266 | //____________________________________________________________________ |
74fd10b3 | 267 | void AlidNdEtaCorrection::FillMCParticle(Float_t vtx, Float_t eta, Float_t pt, Bool_t trigger, Bool_t vertex, Int_t processType) |
7584d357 | 268 | { |
74fd10b3 | 269 | // fills a particle in the corrections |
270 | // it is filled in generated or measured depending of the flags | |
7584d357 | 271 | |
74fd10b3 | 272 | fTriggerBiasCorrectionMBToINEL->GetTrackCorrection()->FillGene(vtx, eta, pt); |
7584d357 | 273 | |
74fd10b3 | 274 | if (processType != 92 && processType != 93) |
275 | fTriggerBiasCorrectionMBToNSD->GetTrackCorrection()->FillGene(vtx, eta, pt); | |
276 | ||
277 | if (processType!=92 && processType!=93 && processType!=94) | |
278 | fTriggerBiasCorrectionMBToND->GetTrackCorrection()->FillGene(vtx, eta, pt); | |
279 | ||
280 | if (!trigger) | |
281 | return; | |
282 | ||
283 | fTriggerBiasCorrectionMBToINEL->GetTrackCorrection()->FillMeas(vtx, eta, pt); | |
284 | fTriggerBiasCorrectionMBToNSD->GetTrackCorrection()->FillMeas(vtx, eta, pt); | |
285 | fTriggerBiasCorrectionMBToND->GetTrackCorrection()->FillMeas(vtx, eta, pt); | |
286 | fVertexRecoCorrection->GetTrackCorrection()->FillGene(vtx, eta, pt); | |
287 | ||
288 | if (!vertex) | |
289 | return; | |
290 | ||
291 | fVertexRecoCorrection->GetTrackCorrection()->FillMeas(vtx, eta, pt); | |
292 | fTrack2ParticleCorrection->GetTrackCorrection()->FillGene(vtx, eta, pt); | |
7584d357 | 293 | } |
55e05544 | 294 | |
7584d357 | 295 | //____________________________________________________________________ |
74fd10b3 | 296 | void AlidNdEtaCorrection::FillTrackedParticle(Float_t vtx, Float_t eta, Float_t pt) |
7584d357 | 297 | { |
74fd10b3 | 298 | // fills a tracked particle in the corrections |
299 | ||
300 | fTrack2ParticleCorrection->GetTrackCorrection()->FillMeas(vtx, eta, pt); | |
55e05544 | 301 | } |
847489f7 | 302 | |
7584d357 | 303 | //____________________________________________________________________ |
74fd10b3 | 304 | void AlidNdEtaCorrection::FillEvent(Float_t vtx, Float_t n, Bool_t trigger, Bool_t vertex, Int_t processType) |
7584d357 | 305 | { |
74fd10b3 | 306 | // fills an event int he correction |
307 | // it is filled in generated or measured depending of the flags | |
308 | ||
309 | fTriggerBiasCorrectionMBToINEL->GetEventCorrection()->FillGene(vtx, n); | |
310 | ||
311 | if (processType != 92 && processType != 93) | |
312 | fTriggerBiasCorrectionMBToNSD->GetEventCorrection()->FillGene(vtx, n); | |
7584d357 | 313 | |
74fd10b3 | 314 | if (processType!=92 && processType!=93 && processType!=94) |
315 | fTriggerBiasCorrectionMBToND->GetEventCorrection()->FillGene(vtx, n); | |
316 | ||
317 | if (!trigger) | |
318 | return; | |
319 | ||
320 | fTriggerBiasCorrectionMBToINEL->GetEventCorrection()->FillMeas(vtx, n); | |
321 | fTriggerBiasCorrectionMBToNSD->GetEventCorrection()->FillMeas(vtx, n); | |
322 | fTriggerBiasCorrectionMBToND->GetEventCorrection()->FillMeas(vtx, n); | |
323 | fVertexRecoCorrection->GetEventCorrection()->FillGene(vtx, n); | |
324 | ||
325 | if (!vertex) | |
326 | return; | |
327 | ||
328 | fVertexRecoCorrection->GetEventCorrection()->FillMeas(vtx, n); | |
329 | } | |
7584d357 | 330 | |
847489f7 | 331 | //____________________________________________________________________ |
74fd10b3 | 332 | Float_t AlidNdEtaCorrection::GetMeasuredFraction(CorrectionType correctionType, Float_t ptCutOff, Float_t eta, Bool_t debug) |
847489f7 | 333 | { |
334 | // calculates the fraction of particles measured (some are missed due to the pt cut off) | |
74fd10b3 | 335 | // |
336 | // uses the generated particle histogram from the correction passed, e.g. pass GetTrack2ParticleCorrection() | |
847489f7 | 337 | |
0448e811 | 338 | if (!GetCorrection(correctionType)) |
339 | return -1; | |
340 | ||
341 | const TH3F* generated = GetCorrection(correctionType)->GetTrackCorrection()->GetGeneratedHistogram(); | |
847489f7 | 342 | |
343 | // find eta borders, if eta is negative assume -0.8 ... 0.8 | |
344 | Int_t etaBegin = 0; | |
345 | Int_t etaEnd = 0; | |
72e597d7 | 346 | if (eta < -99) |
847489f7 | 347 | { |
348 | etaBegin = generated->GetYaxis()->FindBin(-0.8); | |
349 | etaEnd = generated->GetYaxis()->FindBin(0.8); | |
350 | } | |
351 | else | |
352 | { | |
353 | etaBegin = generated->GetYaxis()->FindBin(eta); | |
354 | etaEnd = etaBegin; | |
355 | } | |
356 | ||
0448e811 | 357 | Int_t vertexBegin = generated->GetXaxis()->FindBin(-9.99); |
358 | Int_t vertexEnd = generated->GetXaxis()->FindBin(9.99); | |
847489f7 | 359 | |
92d2d8ad | 360 | TH1D* ptProj = dynamic_cast<TH1D*> (generated->ProjectionZ(Form("%s_pt", generated->GetName()), vertexBegin, vertexEnd, etaBegin, etaEnd)); |
b4b9cacc | 361 | //printf("GetMeasuredFraction: bin range %d %d %d %d\n", vertexBegin, vertexEnd, etaBegin, etaEnd); |
1afae8ff | 362 | ptProj->GetXaxis()->SetTitle(generated->GetZaxis()->GetTitle()); |
847489f7 | 363 | |
364 | Int_t ptBin = ptProj->FindBin(ptCutOff); | |
b4b9cacc | 365 | //printf("GetMeasuredFraction: bin range %d %d\n", ptBin, ptProj->GetNbinsX()); |
847489f7 | 366 | Float_t abovePtCut = ptProj->Integral(ptBin, ptProj->GetNbinsX()); |
367 | Float_t all = ptProj->Integral(); | |
368 | ||
369 | if (all == 0) | |
370 | return -1; | |
371 | ||
372 | Float_t fraction = abovePtCut / all; | |
373 | ||
b4b9cacc | 374 | //printf("GetMeasuredFraction: all %f above %f fraction %f\n", all, abovePtCut, fraction); |
74fd10b3 | 375 | |
847489f7 | 376 | if (debug) |
377 | { | |
378 | new TCanvas; | |
379 | ptProj->Draw(); | |
380 | } | |
92d2d8ad | 381 | else |
382 | delete ptProj; | |
847489f7 | 383 | |
72e597d7 | 384 | if (debug) |
385 | printf("AlidNdEtaCorrection::GetMeasuredFraction: pt cut off = %f, eta = %f, => fraction = %f\n", ptCutOff, eta, fraction); | |
386 | ||
847489f7 | 387 | return fraction; |
388 | } | |
389 | ||
74fd10b3 | 390 | //____________________________________________________________________ |
0ab29cfa | 391 | void AlidNdEtaCorrection::ReduceInformation() |
392 | { | |
393 | // this function deletes the measured and generated histograms from the corrections to reduce the amount of data | |
394 | // in memory | |
395 | ||
396 | // these are needed for GetMeasuredFraction(): fTrack2ParticleCorrection->ReduceInformation(); | |
7584d357 | 397 | fVertexRecoCorrection ->ReduceInformation(); |
398 | fTriggerBiasCorrectionMBToINEL ->ReduceInformation(); | |
399 | fTriggerBiasCorrectionMBToNSD ->ReduceInformation(); | |
400 | fTriggerBiasCorrectionMBToND ->ReduceInformation(); | |
0ab29cfa | 401 | } |
7af955da | 402 | |
0448e811 | 403 | //____________________________________________________________________ |
404 | AliCorrection* AlidNdEtaCorrection::GetCorrection(CorrectionType correctionType) | |
405 | { | |
406 | // returns the given correction | |
407 | ||
408 | switch (correctionType) | |
409 | { | |
410 | case kNone : return 0; | |
411 | case kTrack2Particle : return fTrack2ParticleCorrection; | |
412 | case kVertexReco : return fVertexRecoCorrection; | |
413 | case kINEL : return fTriggerBiasCorrectionMBToINEL; | |
414 | case kNSD : return fTriggerBiasCorrectionMBToNSD; | |
415 | case kND : return fTriggerBiasCorrectionMBToND; | |
416 | } | |
417 | ||
418 | return 0; | |
419 | } |