]>
Commit | Line | Data |
---|---|---|
0a28d543 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: ALICE Offline. * | |
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 | //=========================================================================// | |
17 | // AliEbyE Analysis for Particle Ratio Fluctuation // | |
18 | // Deepika Rathee | Satyajit Jena // | |
19 | // drathee@cern.ch | sjena@cern.ch // | |
20 | // Date: Wed Jul 9 18:38:30 CEST 2014 // | |
21 | // New approch to find particle ratio to reduce memory // | |
22 | // (Test Only) // | |
23 | //=========================================================================// | |
24 | ||
25 | #include "TMath.h" | |
26 | #include "TAxis.h" | |
27 | #include "TSystem.h" | |
28 | #include "TFile.h" | |
29 | #include "TPRegexp.h" | |
30 | ||
31 | #include "AliStack.h" | |
32 | #include "AliMCEvent.h" | |
33 | #include "AliMCParticle.h" | |
34 | #include "AliESDtrackCuts.h" | |
35 | #include "AliESDInputHandler.h" | |
36 | #include "AliESDpid.h" | |
37 | #include "AliAODInputHandler.h" | |
38 | #include "AliAODEvent.h" | |
39 | #include "AliAODMCParticle.h" | |
40 | #include "AliCentrality.h" | |
41 | #include "AliTracker.h" | |
42 | ||
43 | #include "AliEbyEPidRatioHelper.h" | |
44 | ||
45 | using namespace std; | |
46 | ||
47 | ||
48 | ClassImp(AliEbyEPidRatioHelper) | |
49 | //________________________________________________________________________ | |
50 | AliEbyEPidRatioHelper::AliEbyEPidRatioHelper() : | |
51 | fModeDistCreation(0), | |
52 | ||
53 | fInputEventHandler(NULL), | |
54 | fPIDResponse(NULL), | |
55 | fESD(NULL), | |
56 | fESDTrackCuts(NULL), | |
57 | fAOD(NULL), | |
58 | fAODtrackCutBit(1024), | |
59 | fIsMC(kFALSE), | |
60 | fMCEvent(NULL), | |
61 | fStack(NULL), | |
62 | ||
63 | fCentralityBin(-1), | |
64 | fCentralityPercentile(-1.), | |
65 | ||
bdb6c35e | 66 | fCentralityBinMax(11), |
0a28d543 | 67 | fVertexZMax(10.), |
68 | fRapidityMax(0.5), | |
69 | fPhiMin(0.), | |
70 | fPhiMax(TMath::TwoPi()), | |
71 | fMinTrackLengthMC(70.), | |
72 | fNSigmaMaxCdd(3.), | |
73 | fNSigmaMaxCzz(3.), | |
74 | ||
75 | fPIDStrategy(0), | |
76 | fNSigmaMaxITS(4.), | |
77 | fNSigmaMaxTPC(4.), | |
78 | fNSigmaMaxTPClow(3.), | |
79 | fNSigmaMaxTOF(4.), | |
80 | fMinPtForTOFRequired(0.69), | |
81 | fMaxPtForTPClow(0.69), | |
82 | ||
83 | fHEventStat0(NULL), | |
84 | fHEventStat1(NULL), | |
85 | fHEventStatMax(6), | |
86 | ||
87 | fHTriggerStat(NULL), | |
88 | fNTriggers(5), | |
89 | ||
90 | fHCentralityStat(NULL), | |
bdb6c35e | 91 | fNCentralityBins(11), |
0a28d543 | 92 | |
93 | fRandom(NULL) { | |
94 | // Constructor | |
95 | ||
96 | AliLog::SetClassDebugLevel("AliEbyEPidRatioHelper",10); | |
97 | } | |
98 | ||
99 | const Float_t AliEbyEPidRatioHelper::fgkfHistBinWitdthRap = 0.075; | |
100 | const Float_t AliEbyEPidRatioHelper::fgkfHistBinWitdthPt = 0.3; // 0.08 // 300 MeV // was 80 MeV | |
101 | ||
102 | const Float_t AliEbyEPidRatioHelper::fgkfHistRangeCent[] = {-0.5, 10.5}; | |
103 | const Int_t AliEbyEPidRatioHelper::fgkfHistNBinsCent = 11 ; | |
104 | ||
105 | const Float_t AliEbyEPidRatioHelper::fgkfHistRangeEta[] = {-0.9, 0.9}; | |
106 | const Int_t AliEbyEPidRatioHelper::fgkfHistNBinsEta = Int_t((AliEbyEPidRatioHelper::fgkfHistRangeEta[1] - | |
107 | AliEbyEPidRatioHelper::fgkfHistRangeEta[0]) / | |
108 | AliEbyEPidRatioHelper::fgkfHistBinWitdthRap) +1; | |
109 | ||
110 | const Float_t AliEbyEPidRatioHelper::fgkfHistRangeRap[] = {-0.5, 0.5}; | |
111 | const Int_t AliEbyEPidRatioHelper::fgkfHistNBinsRap = Int_t((AliEbyEPidRatioHelper::fgkfHistRangeRap[1] - AliEbyEPidRatioHelper::fgkfHistRangeRap[0]) / AliEbyEPidRatioHelper::fgkfHistBinWitdthRap) +1; | |
112 | ||
113 | const Float_t AliEbyEPidRatioHelper::fgkfHistRangePhi[] = {0.0, TMath::TwoPi()}; | |
114 | const Int_t AliEbyEPidRatioHelper::fgkfHistNBinsPhi = 42 ; | |
115 | ||
116 | const Float_t AliEbyEPidRatioHelper::fgkfHistRangePt[] = {0.2, 2.9}; // {0.2, 5.}; // was {0.3, 2.22} | |
117 | const Int_t AliEbyEPidRatioHelper::fgkfHistNBinsPt = Int_t((AliEbyEPidRatioHelper::fgkfHistRangePt[1] - AliEbyEPidRatioHelper::fgkfHistRangePt[0]) / AliEbyEPidRatioHelper::fgkfHistBinWitdthPt); | |
118 | ||
119 | const Float_t AliEbyEPidRatioHelper::fgkfHistRangeSign[] = {-1.5, 1.5}; | |
120 | const Int_t AliEbyEPidRatioHelper::fgkfHistNBinsSign = 3; | |
121 | ||
bdb6c35e | 122 | const Char_t* AliEbyEPidRatioHelper::fgkEventNames[] = {"All", "IsTriggered", "HasVertex", "Vz<Vz_{Max}", "Centrality [0,100]%"}; |
0a28d543 | 123 | const Char_t* AliEbyEPidRatioHelper::fgkCentralityMaxNames[] = {"5", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"}; |
124 | const Char_t* AliEbyEPidRatioHelper::fgkTriggerNames[] = {"kMB", "kCentral", "kSemiCentral", "kEMCEJE", "kEMCEGA" }; | |
125 | const Char_t* AliEbyEPidRatioHelper::fgkCentralityNames[] = {"0-5%", "5-10%", "10-20%", "20-30%", "30-40%", "40-50%","50-60%", "60-70%", "70-80%", "80-90%", "90-100%"}; | |
126 | ||
127 | const Char_t* AliEbyEPidRatioHelper::fgkPidName[4] = {"Nch","Npi","Nka","Npr"}; | |
128 | const Char_t* AliEbyEPidRatioHelper::fgkPidLatex[4][2] = {{"N_{-}","N_{+}"}, {"N_{#pi^{-}}","N_{#pi^{+}}"},{"N_{K^{-}}","N_{K^{+}}"}, {"N_{#bar{p}}","N_{p}"}}; | |
129 | const Char_t* AliEbyEPidRatioHelper::fgkPidTitles[4][2] = {{"Negative","Positive"},{"Anti-Pions","Pions"},{"Anti-Kaons","Kaons"}, {"Anti-Protons","Protons"}}; | |
130 | ||
131 | ||
132 | ||
133 | //________________________________________________________________________ | |
134 | AliEbyEPidRatioHelper::~AliEbyEPidRatioHelper() { | |
135 | // Destructor | |
136 | ||
137 | if (fRandom) | |
138 | delete fRandom; | |
139 | ||
140 | return; | |
141 | } | |
142 | ||
143 | //________________________________________________________________________ | |
144 | void AliEbyEPidRatioHelper::SetPhiRange(Float_t f1, Float_t f2) { | |
145 | // -- Set phi range and adopt to phi-histogram | |
146 | ||
147 | fPhiMin = f1; | |
148 | fPhiMax = (f1 < f2) ? f2 : f2+TMath::TwoPi(); | |
149 | ||
150 | Float_t phiMin = fPhiMin; | |
151 | Float_t phiMax = fPhiMax; | |
152 | ||
153 | // -- Update Ranges | |
154 | Float_t binWidth = (AliEbyEPidRatioHelper::fgkfHistRangePhi[1] - AliEbyEPidRatioHelper::fgkfHistRangePhi[0]) / | |
155 | Float_t(AliEbyEPidRatioHelper::fgkfHistNBinsPhi); | |
156 | ||
157 | Float_t lowEdge = AliEbyEPidRatioHelper::fgkfHistRangePhi[0] - binWidth; | |
158 | Float_t highEdge = AliEbyEPidRatioHelper::fgkfHistRangePhi[0]; | |
159 | ||
160 | for (Int_t ii = 1; ii <= AliEbyEPidRatioHelper::fgkfHistNBinsPhi; ++ii) { | |
161 | lowEdge += binWidth; | |
162 | highEdge += binWidth; | |
163 | ||
164 | if (phiMin >= lowEdge && phiMin < highEdge ) | |
165 | phiMin = lowEdge; | |
166 | if (phiMax > lowEdge && phiMax <= highEdge ) | |
167 | phiMax = highEdge; | |
168 | } | |
169 | ||
170 | printf(">>>> Update Phi Range : [%f,%f] -> [%f,%f]\n", fPhiMin, fPhiMax, phiMin, phiMax); | |
171 | fPhiMin = phiMin; | |
172 | fPhiMax = phiMax; | |
173 | } | |
174 | ||
175 | ||
176 | ||
177 | //________________________________________________________________________ | |
178 | Int_t AliEbyEPidRatioHelper::Initialize(AliESDtrackCuts *cuts, Bool_t isMC, Int_t trackCutBit, Int_t modeDistCreation) { | |
179 | // -- Initialize helper | |
180 | ||
181 | Int_t iResult = 0; | |
182 | ||
183 | // -- ESD track cuts | |
184 | fESDTrackCuts = cuts; | |
185 | ||
186 | // -- Is MC | |
187 | fIsMC = isMC; | |
188 | ||
189 | // -- AOD track filter bit | |
190 | fAODtrackCutBit = trackCutBit; | |
191 | ||
192 | // -- mode Distribution creation | |
193 | fModeDistCreation = modeDistCreation; | |
194 | ||
195 | // -- Setup event cut statistics | |
196 | InitializeEventStats(); | |
197 | ||
198 | // -- Setup trigger statistics | |
199 | InitializeTriggerStats(); | |
200 | ||
201 | // -- Setup centrality statistics | |
202 | InitializeCentralityStats(); | |
203 | ||
204 | // -- PRINT PID Strategy | |
205 | // 0 : TPC(TPClow+TPCHigh) | |
206 | // 1 : ITS | |
207 | // 2 : TOF | |
208 | // 3 : ITS+TPC(TPClow+TPCHigh) | |
209 | // 4 : TPC(TPClow+TPCHigh)+TOF | |
210 | // 5 : TPC(TPClow+TPCHigh)+TOF for pT >= fMinPtForTOFRequired TOF is required, below, only used if there | |
211 | // 6 : TPC(TPClow+TPCHigh)+ITS+TOF with TOF only for those tracks which have TOF information | |
212 | // 7 : TPC(TPClow+TPCHigh)+ITS+TOF for pT >= fMinPtForTOFRequired TOF is required, below, only used if there | |
213 | // 8 : TPC(TPClow+TPCHigh)+ITS+TOF | |
214 | printf(">>>> PID STRATEGY: %d || sigmaMax: ITS %.2f TPC %.2f TOF %.2f \n", fPIDStrategy, fNSigmaMaxITS, fNSigmaMaxTPC, fNSigmaMaxTOF); | |
215 | ||
216 | // -- Initialize random number generator | |
217 | fRandom = new TRandom3(); | |
218 | fRandom->SetSeed(); | |
219 | ||
220 | return iResult; | |
221 | } | |
222 | ||
223 | //________________________________________________________________________ | |
224 | Int_t AliEbyEPidRatioHelper::SetupEvent(AliESDInputHandler *esdHandler, AliAODInputHandler *aodHandler, AliMCEvent *mcEvent) { | |
225 | // -- Setup Event | |
226 | ||
227 | // -- Get ESD objects | |
228 | if(esdHandler){ | |
229 | fInputEventHandler = static_cast<AliInputEventHandler*>(esdHandler); | |
230 | fESD = dynamic_cast<AliESDEvent*>(fInputEventHandler->GetEvent()); | |
231 | if (!fESD) { | |
232 | AliError("ESD event handler not available"); | |
233 | return -1; | |
234 | } | |
235 | } | |
236 | ||
237 | // -- Get AOD objects | |
238 | else if(aodHandler){ | |
239 | fInputEventHandler = static_cast<AliInputEventHandler*>(aodHandler); | |
240 | fAOD = dynamic_cast<AliAODEvent*>(fInputEventHandler->GetEvent()); | |
241 | if (!fAOD) { | |
242 | AliError("AOD event handler not available"); | |
243 | return -1; | |
244 | } | |
245 | } | |
246 | ||
247 | // -- Get Common objects | |
248 | fPIDResponse = fInputEventHandler->GetPIDResponse(); | |
249 | ||
250 | // -- Get MC objects | |
251 | fMCEvent = mcEvent; | |
252 | if (fMCEvent) | |
253 | fStack = fMCEvent->Stack(); | |
254 | ||
255 | // -- Get event centrality | |
bdb6c35e | 256 | // > 0-5|5-10|10-20|20-30|30-40|40-50|50-60|60-70|70-80|80-90|90-100 --> 11 bins |
257 | // > 0 1 2 3 4 5 6 7 8 9 10 | |
0a28d543 | 258 | |
259 | AliCentrality *centrality = NULL; | |
260 | ||
261 | if(esdHandler) | |
262 | centrality = fESD->GetCentrality(); | |
263 | else if(aodHandler) | |
264 | centrality = fAOD->GetHeader()->GetCentralityP(); | |
265 | ||
266 | if (!centrality) { | |
267 | AliError("Centrality not available"); | |
268 | return -1; | |
269 | } | |
270 | ||
271 | Int_t centBin = centrality->GetCentralityClass10("V0M"); | |
bdb6c35e | 272 | if (centBin == 0) { fCentralityBin = centrality->GetCentralityClass5("V0M"); } |
273 | else if (centBin == 11 || centBin == -1.) { fCentralityBin = -1; } | |
274 | else if (centBin > 0 && centBin < fNCentralityBins) { fCentralityBin = centBin + 1; } | |
275 | else { fCentralityBin = -2; } | |
276 | ||
0a28d543 | 277 | if (fCentralityBin >= fCentralityBinMax) |
278 | fCentralityBin = -2; | |
279 | ||
280 | fCentralityPercentile = centrality->GetCentralityPercentile("V0M"); | |
0a28d543 | 281 | |
282 | return 0; | |
283 | } | |
284 | //________________________________________________________________________ | |
285 | Bool_t AliEbyEPidRatioHelper::IsEventTriggered() { | |
286 | // -- Check if Event is triggered and fill Trigger Histogram | |
287 | ||
288 | Bool_t *aTriggerFired = new Bool_t[fNTriggers]; | |
289 | for (Int_t ii = 0; ii < fNTriggers; ++ii) | |
290 | aTriggerFired[ii] = kFALSE; | |
291 | ||
292 | if ((fInputEventHandler->IsEventSelected() & AliVEvent::kMB)) aTriggerFired[0] = kTRUE; | |
293 | if ((fInputEventHandler->IsEventSelected() & AliVEvent::kCentral)) aTriggerFired[1] = kTRUE; | |
294 | if ((fInputEventHandler->IsEventSelected() & AliVEvent::kSemiCentral)) aTriggerFired[2] = kTRUE; | |
295 | if ((fInputEventHandler->IsEventSelected() & AliVEvent::kEMCEJE)) aTriggerFired[3] = kTRUE; | |
296 | if ((fInputEventHandler->IsEventSelected() & AliVEvent::kEMCEGA)) aTriggerFired[4] = kTRUE; | |
297 | ||
298 | Bool_t isTriggered = kFALSE; | |
299 | ||
300 | for (Int_t ii=0; ii<fNTriggers; ++ii) { | |
301 | if(aTriggerFired[ii]) { | |
302 | isTriggered = kTRUE; | |
303 | fHTriggerStat->Fill(ii); | |
304 | } | |
305 | } | |
306 | ||
307 | delete[] aTriggerFired; | |
308 | ||
309 | return isTriggered; | |
310 | } | |
311 | ||
312 | //________________________________________________________________________ | |
313 | Bool_t AliEbyEPidRatioHelper::IsEventRejected() { | |
314 | // -- Evaluate event statistics histograms | |
315 | ||
316 | Int_t *aEventCuts = new Int_t[fHEventStatMax]; | |
317 | // set aEventCuts[ii] to 1 in case of reject | |
318 | ||
319 | for (Int_t ii=0;ii<fHEventStatMax; ++ii) | |
320 | aEventCuts[ii] = 0; | |
321 | ||
322 | Int_t iCut = 0; | |
323 | ||
324 | // -- 0 - Before Physics Selection | |
325 | aEventCuts[iCut] = 0; | |
326 | ||
327 | // -- 1 - No Trigger fired | |
328 | ++iCut; | |
329 | if (!IsEventTriggered()) | |
330 | aEventCuts[iCut] = 1; | |
331 | ||
332 | // -- 2 - No Vertex | |
333 | ++iCut; | |
334 | const AliESDVertex* vtxESD = NULL; | |
335 | const AliAODVertex* vtxAOD = NULL; | |
336 | if (fESD){ | |
337 | vtxESD = fESD->GetPrimaryVertexTracks(); | |
338 | if (!vtxESD) | |
339 | aEventCuts[iCut] = 1; | |
340 | } | |
341 | else if (fAOD){ | |
342 | vtxAOD = fAOD->GetPrimaryVertex(); | |
343 | if (!vtxAOD) | |
344 | aEventCuts[iCut] = 1; | |
345 | } | |
346 | ||
347 | // -- 3 - Vertex z outside cut window | |
348 | ++iCut; | |
349 | if (vtxESD){ | |
350 | if(TMath::Abs(vtxESD->GetZv()) > fVertexZMax) | |
351 | aEventCuts[iCut] = 1; | |
352 | } | |
353 | else if(vtxAOD){ | |
354 | if(TMath::Abs(vtxAOD->GetZ()) > fVertexZMax) | |
355 | aEventCuts[iCut] = 1; | |
356 | } | |
357 | else | |
358 | aEventCuts[iCut] = 1; | |
359 | ||
360 | // -- 4 - Centrality = -1 (no centrality or not hadronic) | |
361 | ++iCut; | |
362 | if(fCentralityBin == -1.) | |
363 | aEventCuts[iCut] = 1; | |
364 | ||
365 | // -- 5 - Centrality < fCentralityMax | |
366 | ++iCut; | |
367 | if(fCentralityBin == -2.) | |
368 | aEventCuts[iCut] = 1; | |
369 | ||
370 | // -- Fill statistics / reject event | |
371 | Bool_t isRejected = FillEventStats(aEventCuts); | |
372 | ||
373 | // -- Cleanup | |
374 | delete[] aEventCuts; | |
375 | ||
376 | //cout << isRejected << endl; | |
377 | ||
378 | return isRejected; | |
379 | } | |
380 | ||
381 | //________________________________________________________________________ | |
382 | Bool_t AliEbyEPidRatioHelper::IsParticleAcceptedBasicCharged(AliVParticle *particle, Int_t idxMC) { | |
383 | // -- Check if MC particle is accepted for basic parameters | |
384 | ||
385 | if (!particle) | |
386 | return kFALSE; | |
387 | ||
388 | // -- check if charged | |
389 | if (particle->Charge() == 0.0) | |
390 | return kFALSE; | |
391 | ||
392 | // -- check if physical primary - ESD | |
393 | if (fESD) { | |
394 | if(!fStack->IsPhysicalPrimary(idxMC)) | |
395 | return kFALSE; | |
396 | } | |
397 | // -- check if physical primary - AOD | |
398 | else { | |
399 | if(!(static_cast<AliAODMCParticle*>(particle))->IsPhysicalPrimary()) | |
400 | return kFALSE; | |
401 | } | |
402 | ||
403 | return kTRUE; | |
404 | } | |
405 | ||
406 | //________________________________________________________________________ | |
407 | Bool_t AliEbyEPidRatioHelper::IsParticleAcceptedBasicNeutral(AliVParticle *particle, Int_t idxMC) { | |
408 | // -- Check if MC particle is accepted for basic parameters | |
409 | ||
410 | if (!particle) | |
411 | return kFALSE; | |
412 | ||
413 | // -- check if charged | |
414 | if (particle->Charge() != 0.0) | |
415 | return kFALSE; | |
416 | ||
417 | // -- check if physical primary - ESD | |
418 | if (fESD) { | |
419 | if(!fStack->IsPhysicalPrimary(idxMC)) | |
420 | return kFALSE; | |
421 | } | |
422 | // -- check if physical primary - AOD | |
423 | else { | |
424 | if(!(static_cast<AliAODMCParticle*>(particle))->IsPhysicalPrimary()) | |
425 | return kFALSE; | |
426 | } | |
427 | ||
428 | return kTRUE; | |
429 | } | |
430 | ||
431 | //________________________________________________________________________ | |
432 | Bool_t AliEbyEPidRatioHelper::IsParticleAcceptedRapidity(AliVParticle *particle, Double_t &yP, Int_t gCurPid) { | |
433 | // -- Check if particle is accepted | |
434 | // > in rapidity | |
435 | // > if no pid : return kTRUE, yP = eta | |
436 | // > return 0 if not accepted | |
437 | ||
438 | if (gCurPid == 0) { | |
439 | yP = particle->Eta(); | |
440 | return kTRUE; | |
441 | } | |
442 | ||
443 | Double_t mP; | |
444 | if(gCurPid == 1) mP = AliPID::ParticleMass(AliPID::kPion); | |
445 | if(gCurPid == 2) mP = AliPID::ParticleMass(AliPID::kKaon); | |
446 | if(gCurPid == 3) mP = AliPID::ParticleMass(AliPID::kProton); | |
447 | ||
448 | // -- Calculate rapidities and kinematics | |
449 | Double_t p = particle->P(); | |
450 | Double_t pz = particle->Pz(); | |
451 | ||
452 | Double_t eP = TMath::Sqrt(p*p + mP*mP); | |
453 | yP = 0.5 * TMath::Log((eP + pz) / (eP - pz)); | |
454 | ||
455 | // -- Check Rapidity window | |
456 | if (TMath::Abs(yP) > fRapidityMax) | |
457 | return kFALSE; | |
458 | ||
459 | return kTRUE; | |
460 | } | |
461 | ||
462 | //________________________________________________________________________ | |
463 | Bool_t AliEbyEPidRatioHelper::IsParticleAcceptedPhi(AliVParticle *particle) { | |
464 | // -- Check if particle is accepted | |
465 | // > in phi | |
466 | // > return 0 if not accepted | |
467 | ||
468 | if (particle->Phi() > fPhiMin && particle->Phi() <= fPhiMax) | |
469 | return kTRUE; | |
470 | else if (particle->Phi() < fPhiMin && (particle->Phi() + TMath::TwoPi()) <= fPhiMax) | |
471 | return kTRUE; | |
472 | else | |
473 | return kFALSE; | |
474 | } | |
475 | ||
476 | //_____________________________________________________________________________ | |
477 | Bool_t AliEbyEPidRatioHelper::IsParticleFindable(Int_t label) { | |
478 | // -- Check if MC particle is findable tracks | |
479 | ||
480 | AliMCParticle *mcParticle = static_cast<AliMCParticle*>(fMCEvent->GetTrack(label)); | |
481 | if(!mcParticle) | |
482 | return kFALSE; | |
483 | ||
484 | Int_t counter; | |
485 | Float_t tpcTrackLength = mcParticle->GetTPCTrackLength(AliTracker::GetBz(), 0.05, counter, 3.0); | |
486 | ||
487 | return (tpcTrackLength > fMinTrackLengthMC); | |
488 | } | |
489 | //________________________________________________________________________ | |
490 | Bool_t AliEbyEPidRatioHelper::IsTrackAcceptedBasicCharged(AliVTrack* track) { | |
491 | // -- Check if track is accepted | |
492 | // > for basic parameters | |
493 | ||
494 | if (!track) | |
495 | return kFALSE; | |
496 | ||
497 | if (track->Charge() == 0) | |
498 | return kFALSE; | |
499 | ||
500 | return kTRUE; | |
501 | } | |
502 | ||
503 | //________________________________________________________________________ | |
504 | Bool_t AliEbyEPidRatioHelper::IsTrackAcceptedRapidity(AliVTrack *track, Double_t &yP, Int_t gCurPid) { | |
505 | if (gCurPid == 0) { | |
506 | yP = track->Eta(); | |
507 | return kTRUE; | |
508 | } | |
509 | ||
510 | Double_t mP; | |
511 | if(gCurPid == 1) mP = AliPID::ParticleMass(AliPID::kPion); | |
512 | if(gCurPid == 2) mP = AliPID::ParticleMass(AliPID::kKaon); | |
513 | if(gCurPid == 3) mP = AliPID::ParticleMass(AliPID::kProton); | |
514 | ||
515 | // -- Calculate rapidities and kinematics | |
516 | Double_t pvec[3]; | |
517 | track->GetPxPyPz(pvec); | |
518 | ||
519 | Double_t p = track->P(); | |
520 | Double_t eP = TMath::Sqrt(p*p + mP*mP); | |
521 | yP = 0.5 * TMath::Log((eP + pvec[2]) / (eP - pvec[2])); | |
522 | ||
523 | // -- Check Rapidity window | |
524 | if (TMath::Abs(yP) > fRapidityMax) | |
525 | return kFALSE; | |
526 | ||
527 | return kTRUE; | |
528 | } | |
529 | ||
530 | //________________________________________________________________________ | |
531 | Bool_t AliEbyEPidRatioHelper::IsTrackAcceptedDCA(AliVTrack *vTrack) { | |
532 | Bool_t isAccepted = kTRUE; | |
533 | ||
534 | if (!fESD) | |
535 | return isAccepted; | |
536 | ||
537 | AliESDtrack* track = dynamic_cast<AliESDtrack*>(vTrack); | |
538 | if (!track) | |
539 | return kFALSE; | |
540 | ||
541 | // -- Get nHits SPD | |
542 | if (track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1)) { | |
543 | ||
544 | // -- Get DCA nSigmas | |
545 | Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z | |
546 | track->GetImpactParameters(dca,cov); | |
547 | ||
548 | Float_t nSigmaCdd = (cov[0] != 0.) ? dca[0]/TMath::Sqrt(cov[0]) : -9.99; | |
549 | Float_t nSigmaCzz = (cov[2] != 0.) ? dca[1]/TMath::Sqrt(cov[2]) : -9.99; | |
550 | ||
551 | if (fNSigmaMaxCdd != 0.) { | |
552 | if (TMath::Abs(nSigmaCdd) > fNSigmaMaxCdd) | |
553 | isAccepted = kFALSE; | |
554 | } | |
555 | ||
556 | if (fNSigmaMaxCzz != 0.) { | |
557 | if (TMath::Abs(nSigmaCzz) > fNSigmaMaxCzz) | |
558 | isAccepted = kFALSE; | |
559 | } | |
560 | } | |
561 | ||
562 | return isAccepted; | |
563 | } | |
564 | ||
565 | //________________________________________________________________________ | |
566 | Bool_t AliEbyEPidRatioHelper::IsTrackAcceptedPID(AliVTrack *track, Double_t* pid, AliPID::EParticleType gCurPid) { | |
567 | ||
568 | Bool_t isAcceptedITS = kFALSE; | |
569 | Bool_t isAcceptedTPC = kFALSE; | |
570 | Bool_t isAcceptedTPClow = kFALSE; | |
571 | Bool_t isAcceptedTOF = kFALSE; | |
572 | Bool_t isAccepted = kFALSE; | |
573 | ||
574 | // -- In case not PID is used | |
575 | if (gCurPid == 0) { | |
576 | pid[0] = 10.; | |
577 | pid[1] = 10.; | |
578 | pid[2] = 10.; | |
579 | return kTRUE; | |
580 | } | |
581 | ||
582 | if (fPIDResponse->NumberOfSigmas(AliPIDResponse::kITS, track, gCurPid, pid[0]) == AliPIDResponse::kDetPidOk) { | |
583 | if (TMath::Abs(pid[0]) < fNSigmaMaxITS) | |
584 | isAcceptedITS = kTRUE; | |
585 | } | |
586 | ||
587 | if (fPIDResponse->NumberOfSigmas(AliPIDResponse::kTPC, track, gCurPid, pid[1]) == AliPIDResponse::kDetPidOk) { | |
588 | if (TMath::Abs(pid[1]) < fNSigmaMaxTPC) | |
589 | isAcceptedTPC = kTRUE; | |
590 | if (TMath::Abs(pid[1]) < fNSigmaMaxTPClow) | |
591 | isAcceptedTPClow = kTRUE; | |
592 | if (track->Pt() < fMaxPtForTPClow) | |
593 | isAcceptedTPC = isAcceptedTPClow; | |
594 | } | |
595 | ||
596 | Bool_t hasPIDTOF = kFALSE; | |
597 | if (fPIDResponse->NumberOfSigmas(AliPIDResponse::kTOF, track, gCurPid, pid[2]) == AliPIDResponse::kDetPidOk) { | |
598 | hasPIDTOF = kTRUE; | |
599 | if (TMath::Abs(pid[2]) < fNSigmaMaxTOF) | |
600 | isAcceptedTOF = kTRUE; | |
601 | } | |
602 | ||
603 | // -- Check TOF missmatch for MC | |
604 | ||
605 | //if (ESD) | |
606 | if (fIsMC && isAcceptedTOF) { | |
607 | Int_t tofLabel[3]; | |
608 | // AliESDtrack* track = dynamic_cast<AliESDtrack*>(vTrack); | |
609 | // TODO add code for AOD | |
610 | ||
611 | (dynamic_cast<AliESDtrack*>(track))->GetTOFLabel(tofLabel); | |
612 | ||
613 | Bool_t hasMatchTOF = kTRUE; | |
614 | if (TMath::Abs(track->GetLabel()) != TMath::Abs(tofLabel[0]) || tofLabel[1] > 0) | |
615 | hasMatchTOF = kFALSE; | |
616 | ||
617 | TParticle *matchedTrack = fStack->Particle(TMath::Abs(tofLabel[0])); | |
618 | if (TMath::Abs(matchedTrack->GetFirstMother()) == TMath::Abs(track->GetLabel())) | |
619 | hasMatchTOF = kTRUE; | |
620 | ||
621 | isAcceptedTOF = hasMatchTOF; | |
622 | } | |
623 | ||
624 | // 0 : TPC(TPClow+TPCHigh) | |
625 | // 1 : ITS | |
626 | // 2 : TOF | |
627 | // 3 : ITS+TPC(TPClow+TPCHigh) | |
628 | // 4 : TPC(TPClow+TPCHigh)+TOF | |
629 | // 5 : TPC(TPClow+TPCHigh)+TOF for pT >= fMinPtForTOFRequired TOF is required, below, only used if there | |
630 | // 6 : TPC(TPClow+TPCHigh)+ITS+TOF with TOF only for those tracks which have TOF information | |
631 | // 7 : TPC(TPClow+TPCHigh)+ITS+TOF for pT >= fMinPtForTOFRequired TOF is required, below, only used if there | |
632 | // 8 : TPC(TPClow+TPCHigh)+ITS+TOF | |
633 | if (fPIDStrategy == 0) { // TPC PID | |
634 | isAccepted = isAcceptedTPC; | |
635 | } | |
636 | else if (fPIDStrategy == 1) { // ITS PID | |
637 | isAccepted = isAcceptedITS; | |
638 | } | |
639 | else if (fPIDStrategy == 2) { // TOF PID | |
640 | isAccepted = isAcceptedTOF; | |
641 | } | |
642 | else if (fPIDStrategy == 3) { // TPC+ITS PID | |
643 | isAccepted = isAcceptedTPC && isAcceptedITS; | |
644 | } | |
645 | else if (fPIDStrategy == 4) { // TPC+TOF PID | |
646 | isAccepted = isAcceptedTPC && isAcceptedTOF; | |
647 | } | |
648 | else if (fPIDStrategy == 5) { // TPC+TOF PID -- for pT >= fMinPtForTOFRequired TOF is required | |
649 | if (!hasPIDTOF && track->Pt() < fMinPtForTOFRequired) | |
650 | isAcceptedTOF = kTRUE; | |
651 | isAccepted = isAcceptedTPC && isAcceptedTOF; | |
652 | } | |
653 | else if (fPIDStrategy == 6) { // ITS+TPC+TOF PID -- TOF only for those tracks which have TOF information | |
654 | isAccepted = isAcceptedTPC && isAcceptedITS; | |
655 | if (hasPIDTOF) | |
656 | isAccepted = isAccepted && isAcceptedTOF; | |
657 | } | |
658 | else if (fPIDStrategy == 7) { // ITS+TPC+TOF PID -- for pT >= fMinPtForTOFRequired TOF is required | |
659 | if (!hasPIDTOF && track->Pt() < fMinPtForTOFRequired) | |
660 | isAcceptedTOF = kTRUE; | |
661 | isAccepted = isAcceptedITS && isAcceptedTPC && isAcceptedTOF; | |
662 | } | |
663 | else if (fPIDStrategy == 8) { // ITS+TPC+TOF PID | |
664 | isAccepted = isAcceptedITS && isAcceptedTPC && isAcceptedTOF; | |
665 | } | |
666 | ||
667 | return isAccepted; | |
668 | } | |
669 | ||
670 | //________________________________________________________________________ | |
671 | Bool_t AliEbyEPidRatioHelper::IsTrackAcceptedPhi(AliVTrack *track) { | |
672 | // -- Check if track is accepted | |
673 | // > in phi | |
674 | // > return 0 if not accepted | |
675 | ||
676 | if (track->Phi() > fPhiMin && track->Phi() <= fPhiMax) | |
677 | return kTRUE; | |
678 | else if (track->Phi() < fPhiMin && (track->Phi() + TMath::TwoPi()) <= fPhiMax) | |
679 | return kTRUE; | |
680 | else | |
681 | return kFALSE; | |
682 | } | |
683 | ||
684 | //________________________________________________________________________ | |
685 | void AliEbyEPidRatioHelper::BinLogAxis(const THnBase *hn, Int_t axisNumber, AliESDtrackCuts* cuts) { | |
686 | AliESDtrackCuts* esdTrackCuts = (cuts) ? cuts : fESDTrackCuts; | |
687 | ||
688 | // -- Make logarithmic binning | |
689 | TAxis *axis = hn->GetAxis(axisNumber); | |
690 | Int_t nBins = axis->GetNbins(); | |
691 | ||
692 | Double_t from = axis->GetXmin(); | |
693 | Double_t to = axis->GetXmax(); | |
694 | Double_t *newBins = new Double_t[nBins + 1]; | |
695 | ||
696 | newBins[0] = from; | |
697 | Double_t factor = TMath::Power(to/from, 1./nBins); | |
698 | ||
699 | for (int ii = 1; ii <= nBins; ii++) | |
700 | newBins[ii] = factor * newBins[ii-1]; | |
701 | ||
702 | axis->Set(nBins, newBins); | |
703 | ||
704 | delete [] newBins; | |
705 | ||
706 | // -- Update Ranges | |
707 | // ------------------ | |
708 | Float_t ptRange[2]; | |
709 | Float_t oldPtRange[2]; | |
710 | esdTrackCuts->GetPtRange(ptRange[0],ptRange[1]); | |
711 | esdTrackCuts->GetPtRange(oldPtRange[0],oldPtRange[1]); | |
712 | ||
713 | Float_t minPtForTOFRequired = fMinPtForTOFRequired; | |
714 | Float_t maxPtForTPClow = fMaxPtForTPClow; | |
715 | ||
716 | // -- Update minPt Cut | |
717 | Int_t bin = axis->FindBin(ptRange[0]+10e-6); | |
718 | ptRange[0] = axis->GetBinLowEdge(bin); | |
719 | ||
720 | // -- Update maxPt Cut | |
721 | bin = axis->FindBin(ptRange[1]-10e-6); | |
722 | ptRange[1] = axis->GetBinUpEdge(bin); | |
723 | ||
724 | if (ptRange[0] != oldPtRange[0] || ptRange[1] != oldPtRange[1]) { | |
725 | printf(">>>> Update Pt Range : [%f,%f] -> [%f,%f]\n", oldPtRange[0], oldPtRange[1], ptRange[0], ptRange[1]); | |
726 | esdTrackCuts->SetPtRange(ptRange[0],ptRange[1]); | |
727 | } | |
728 | ||
729 | // -- Update MinPtForTOFRequired | |
730 | bin = axis->FindBin(minPtForTOFRequired-10e-6); | |
731 | minPtForTOFRequired = axis->GetBinUpEdge(bin); | |
732 | ||
733 | if (minPtForTOFRequired != fMinPtForTOFRequired) { | |
734 | printf(">>>> Update Min Pt for TOF : %f -> %f\n", fMinPtForTOFRequired, minPtForTOFRequired); | |
735 | fMinPtForTOFRequired = minPtForTOFRequired; | |
736 | } | |
737 | ||
738 | // -- Update MaxPtForTPClow | |
739 | bin = axis->FindBin(maxPtForTPClow-10e-6); | |
740 | maxPtForTPClow = axis->GetBinUpEdge(bin); | |
741 | ||
742 | if (maxPtForTPClow != fMaxPtForTPClow) { | |
743 | printf(">>>> Update Max Pt for TPC Low : %f -> %f\n", fMaxPtForTPClow, maxPtForTPClow); | |
744 | fMaxPtForTPClow = maxPtForTPClow; | |
745 | } | |
746 | } | |
747 | ||
748 | //________________________________________________________________________ | |
749 | void AliEbyEPidRatioHelper::InitializeEventStats() { | |
750 | // -- Initialize event statistics histograms | |
751 | ||
752 | fHEventStat0 = new TH1F("hEventStat0","Event cut statistics 0;Event Cuts;Events", fHEventStatMax,-0.5,fHEventStatMax-0.5); | |
753 | fHEventStat1 = new TH1F("hEventStat1","Event cut statistics 1;Event Cuts;Events", fHEventStatMax,-0.5,fHEventStatMax-0.5); | |
754 | ||
755 | for ( Int_t ii=0; ii < fHEventStatMax-1; ii++ ) { | |
756 | fHEventStat0->GetXaxis()->SetBinLabel(ii+1, AliEbyEPidRatioHelper::fgkEventNames[ii]); | |
757 | fHEventStat1->GetXaxis()->SetBinLabel(ii+1, AliEbyEPidRatioHelper::fgkEventNames[ii]); | |
758 | } | |
759 | ||
760 | fHEventStat0->GetXaxis()->SetBinLabel(fHEventStatMax, Form("Centrality [0-%s]%%", AliEbyEPidRatioHelper::fgkCentralityMaxNames[fCentralityBinMax-1])); | |
761 | fHEventStat1->GetXaxis()->SetBinLabel(fHEventStatMax, Form("Centrality [0-%s]%%", AliEbyEPidRatioHelper::fgkCentralityMaxNames[fCentralityBinMax-1])); | |
762 | } | |
763 | ||
764 | //________________________________________________________________________ | |
765 | void AliEbyEPidRatioHelper::InitializeTriggerStats() { | |
766 | // -- Initialize trigger statistics histograms | |
767 | ||
768 | fHTriggerStat = new TH1F("hTriggerStat","Trigger statistics;Trigger;Events", fNTriggers,-0.5,fNTriggers-0.5); | |
769 | ||
770 | for ( Int_t ii=0; ii < fNTriggers; ii++ ) | |
771 | fHTriggerStat->GetXaxis()->SetBinLabel(ii+1, AliEbyEPidRatioHelper::fgkTriggerNames[ii]); | |
772 | } | |
773 | ||
774 | //________________________________________________________________________ | |
775 | void AliEbyEPidRatioHelper::InitializeCentralityStats() { | |
776 | // -- Initialize trigger statistics histograms | |
777 | ||
778 | fHCentralityStat = new TH1F("hCentralityStat","Centrality statistics;Centrality Bins;Events", | |
779 | fNCentralityBins,-0.5,fNCentralityBins-0.5); | |
780 | ||
781 | for ( Int_t ii=0; ii < fNCentralityBins; ii++ ) | |
782 | fHCentralityStat->GetXaxis()->SetBinLabel(ii+1, AliEbyEPidRatioHelper::fgkCentralityNames[ii]); | |
783 | } | |
784 | //________________________________________________________________________ | |
785 | Bool_t AliEbyEPidRatioHelper::FillEventStats(Int_t *aEventCuts) { | |
786 | // -- Fill event / centrality statistics | |
787 | ||
788 | Bool_t isRejected = kFALSE; | |
789 | ||
790 | // -- Fill event statistics | |
791 | for (Int_t idx = 0; idx < fHEventStatMax ; ++idx) { | |
792 | ||
793 | if (aEventCuts[idx]) | |
794 | isRejected = kTRUE; | |
795 | else | |
796 | fHEventStat0->Fill(idx); | |
797 | } | |
798 | ||
799 | for (Int_t idx = 0; idx < fHEventStatMax; ++idx) { | |
800 | if (aEventCuts[idx]) | |
801 | break; | |
802 | fHEventStat1->Fill(idx); | |
803 | } | |
804 | ||
805 | // -- Fill centrality statistics of accepted events | |
806 | if (!isRejected) | |
807 | fHCentralityStat->Fill(fCentralityBin); | |
808 | ||
809 | return isRejected; | |
810 | } |