]>
Commit | Line | Data |
---|---|---|
c0757458 | 1 | #include "AliVEvent.h" |
2 | #include "AliMCEvent.h" | |
3 | #include "TParticle.h" | |
4 | #include "AliVParticle.h" | |
5 | #include "AliESDEvent.h" | |
6 | #include "AliAODEvent.h" | |
7 | #include "AliVVertex.h" | |
8 | #include "AliLog.h" | |
9 | #include "AliGenEventHeader.h" | |
10 | #include "AliInputEventHandler.h" | |
11 | #include "AliAnalysisManager.h" | |
12 | #include "AliAODMCHeader.h" | |
13 | #include "AliAODMCParticle.h" | |
14 | #include "AliMCParticle.h" | |
15 | #include "AliVParticle.h" | |
16 | #include "AliStack.h" | |
17 | #include "AliMCEventHandler.h" | |
18 | #include "AliPIDResponse.h" | |
19 | ||
20 | #include "AliSingleTrackEffCuts.h" | |
21 | ||
a0ec15ff | 22 | using std::cout; |
23 | using std::endl; | |
c0757458 | 24 | |
25 | ClassImp(AliSingleTrackEffCuts) | |
26 | ||
27 | //_____________________________________________________ | |
28 | AliSingleTrackEffCuts::AliSingleTrackEffCuts(): | |
29 | AliAnalysisCuts(), | |
30 | fisAOD(kTRUE), | |
31 | fIsPdgCode(kFALSE), | |
32 | fPdgCode(0), | |
33 | fEtaMin(-12), | |
34 | fEtaMax(12), | |
35 | fYMin(-12), | |
36 | fYMax(12), | |
37 | fPtMin(-15), | |
38 | fPtMax(15), | |
39 | fIsCharged(kTRUE), | |
40 | fTriggerMask(AliVEvent::kAny), | |
41 | fMinVtxType(0), | |
42 | fMinVtxContr(1), | |
43 | fMaxVtxZ(10.), | |
44 | fCutOnZVertexSPD(0), | |
45 | fnClusITS(0), | |
46 | fnClusTPC(0), | |
47 | fnClusTOF(0), | |
48 | fnClusMUON(0), | |
49 | fusePid(kFALSE), | |
50 | fParticlePid(AliPID::kPion), | |
51 | fuseTPCPid(kTRUE), | |
52 | fnPTPCBins(0), | |
53 | fnPTPCBinLimits(0), | |
54 | fPTPCBinLimits(0), | |
55 | fnSigmaTPC(0), | |
56 | fPmaxTPC(9999.), | |
57 | fuseTOFPid(kTRUE), | |
58 | fnPTOFBins(0), | |
59 | fnPTOFBinLimits(0), | |
60 | fPTOFBinLimits(0), | |
61 | fnSigmaTOF(0), | |
62 | fPmaxTOF(9999.) | |
63 | { | |
64 | // | |
65 | // Default constructor | |
66 | // | |
67 | } | |
68 | ||
69 | //________________________________________________________________________________ | |
70 | AliSingleTrackEffCuts::AliSingleTrackEffCuts(const char* name, const char* title): | |
71 | AliAnalysisCuts(name,title), | |
72 | fisAOD(kTRUE), | |
73 | fIsPdgCode(kFALSE), | |
74 | fPdgCode(0), | |
75 | fEtaMin(-12), | |
76 | fEtaMax(12), | |
77 | fYMin(-12), | |
78 | fYMax(12), | |
79 | fPtMin(-15), | |
80 | fPtMax(15), | |
81 | fIsCharged(kTRUE), | |
82 | fTriggerMask(AliVEvent::kAny), | |
83 | fMinVtxType(0), | |
84 | fMinVtxContr(1), | |
85 | fMaxVtxZ(10.), | |
86 | fCutOnZVertexSPD(0), | |
87 | fnClusITS(0), | |
88 | fnClusTPC(0), | |
89 | fnClusTOF(0), | |
90 | fnClusMUON(0), | |
91 | fusePid(kFALSE), | |
92 | fParticlePid(AliPID::kPion), | |
93 | fuseTPCPid(kTRUE), | |
94 | fnPTPCBins(0), | |
95 | fnPTPCBinLimits(0), | |
96 | fPTPCBinLimits(0), | |
97 | fnSigmaTPC(0), | |
98 | fPmaxTPC(9999.), | |
99 | fuseTOFPid(kTRUE), | |
100 | fnPTOFBins(0), | |
101 | fnPTOFBinLimits(0), | |
102 | fPTOFBinLimits(0), | |
103 | fnSigmaTOF(0), | |
104 | fPmaxTOF(9999.) | |
105 | { | |
106 | // | |
107 | // Default constructor | |
108 | // | |
109 | } | |
110 | ||
111 | //_________________________________________________________________________________ | |
112 | AliSingleTrackEffCuts::AliSingleTrackEffCuts(const AliSingleTrackEffCuts &source): | |
113 | AliAnalysisCuts(source), | |
114 | fisAOD(source.fisAOD), | |
115 | fIsPdgCode(source.fIsPdgCode), | |
116 | fPdgCode(source.fPdgCode), | |
117 | fEtaMin(source.fEtaMin), | |
118 | fEtaMax(source.fEtaMax), | |
119 | fYMin(source.fYMin), | |
120 | fYMax(source.fYMax), | |
121 | fPtMin(source.fPtMin), | |
122 | fPtMax(source.fPtMax), | |
123 | fIsCharged(source.fIsCharged), | |
124 | fTriggerMask(source.fTriggerMask), | |
125 | fMinVtxType(source.fMinVtxType), | |
126 | fMinVtxContr(source.fMinVtxContr), | |
127 | fMaxVtxZ(source.fMaxVtxZ), | |
128 | fCutOnZVertexSPD(source.fCutOnZVertexSPD), | |
129 | fnClusITS(source.fnClusITS), | |
130 | fnClusTPC(source.fnClusTPC), | |
131 | fnClusTOF(source.fnClusTOF), | |
132 | fnClusMUON(source.fnClusMUON), | |
133 | fusePid(source.fusePid), | |
134 | fParticlePid(source.fParticlePid), | |
135 | fuseTPCPid(source.fuseTPCPid), | |
136 | fnPTPCBins(source.fnPTPCBins), | |
137 | fnPTPCBinLimits(source.fnPTPCBinLimits), | |
138 | fPTPCBinLimits(source.fPTPCBinLimits), | |
139 | fnSigmaTPC(source.fnSigmaTPC), | |
140 | fPmaxTPC(source.fPmaxTPC), | |
141 | fuseTOFPid(source.fuseTOFPid), | |
142 | fnPTOFBins(source.fnPTOFBins), | |
143 | fnPTOFBinLimits(source.fnPTOFBinLimits), | |
144 | fPTOFBinLimits(source.fPTOFBinLimits), | |
145 | fnSigmaTOF(source.fnSigmaTOF), | |
146 | fPmaxTOF(source.fPmaxTOF) | |
147 | { | |
148 | // | |
149 | // Copy constructor | |
150 | // | |
151 | } | |
152 | ||
153 | ||
154 | //_________________________________________________________________________________________ | |
155 | AliSingleTrackEffCuts &AliSingleTrackEffCuts::operator=(const AliSingleTrackEffCuts &source) | |
156 | { | |
157 | // | |
158 | // assignment operator | |
159 | // | |
160 | if(&source == this) return *this; | |
161 | ||
162 | fisAOD = source.fisAOD; | |
163 | ||
164 | fIsPdgCode = source.fIsPdgCode; | |
165 | fPdgCode = source.fPdgCode; | |
166 | fEtaMin = source.fEtaMin; | |
167 | fEtaMax = source.fEtaMax; | |
168 | fYMin = source.fYMin; | |
169 | fYMax = source.fYMax; | |
170 | fPtMin = source.fPtMin; | |
171 | fPtMax = source.fPtMax; | |
172 | fIsCharged = source.fIsCharged; | |
173 | ||
174 | fTriggerMask = source.fTriggerMask; | |
175 | fMinVtxType = source.fMinVtxType; | |
176 | fMinVtxContr = source.fMinVtxContr; | |
177 | fMaxVtxZ = source.fMaxVtxZ; | |
178 | fCutOnZVertexSPD = source.fCutOnZVertexSPD; | |
179 | ||
180 | fnClusITS = source.fnClusITS; | |
181 | fnClusTPC = source.fnClusTPC; | |
182 | fnClusTOF = source.fnClusTOF; | |
183 | fnClusMUON = source.fnClusMUON; | |
184 | ||
185 | fusePid = source.fusePid; | |
186 | fParticlePid = source.fParticlePid; | |
187 | fuseTPCPid = source.fuseTPCPid; | |
188 | fnPTPCBins = source.fnPTPCBins; | |
189 | fnPTPCBinLimits = source.fnPTPCBinLimits; | |
190 | if(source.fPTPCBinLimits && source.fnSigmaTPC) | |
191 | SetTPCSigmaPtBins(source.fnPTPCBins,source.fPTPCBinLimits,source.fnSigmaTPC); | |
192 | fPmaxTPC = source.fPmaxTPC; | |
193 | fuseTOFPid = source.fuseTOFPid; | |
194 | fnPTOFBins = source.fnPTOFBins; | |
195 | fnPTOFBinLimits = source.fnPTOFBinLimits; | |
196 | if(source.fPTOFBinLimits && source.fnSigmaTOF) | |
197 | SetTOFSigmaPtBins(source.fnPTOFBins,source.fPTOFBinLimits,source.fnSigmaTOF); | |
198 | fPmaxTOF = source.fPmaxTOF; | |
199 | ||
200 | return *this; | |
201 | } | |
202 | ||
203 | //______________________________________________ | |
204 | AliSingleTrackEffCuts::~AliSingleTrackEffCuts() | |
205 | { | |
206 | // | |
207 | // Destructor | |
208 | // | |
209 | ||
210 | if(fPTPCBinLimits){ | |
211 | delete [] fPTPCBinLimits; | |
212 | fPTPCBinLimits=NULL; | |
213 | } | |
214 | if(fnSigmaTPC){ | |
215 | delete [] fnSigmaTPC; | |
216 | fnSigmaTPC=NULL; | |
217 | } | |
218 | if(fPTOFBinLimits){ | |
219 | delete [] fPTOFBinLimits; | |
220 | fPTOFBinLimits=NULL; | |
221 | } | |
222 | if(fnSigmaTOF){ | |
223 | delete [] fnSigmaTOF; | |
224 | fnSigmaTOF=NULL; | |
225 | } | |
226 | ||
227 | } | |
228 | ||
229 | //______________________________________________ | |
230 | Bool_t AliSingleTrackEffCuts::IsMCEventSelected(TObject* obj) | |
231 | { | |
232 | // | |
233 | // Event selection at MC level | |
234 | // |zvtx|<=fMaxVtxZ | |
235 | // | |
236 | if(!obj) return kFALSE; | |
237 | Bool_t isSelected = kTRUE; | |
238 | ||
239 | AliMCEvent *event=0; | |
240 | AliGenEventHeader *genHeader=0; //ESDs | |
241 | AliAODMCHeader *mcHeader=0; // AODs | |
242 | Bool_t isAOD = obj->IsA()->InheritsFrom("AliAODEvent"); | |
243 | ||
244 | if(!isAOD) { | |
245 | event = dynamic_cast<AliMCEvent*>(obj); | |
246 | if (!event) return kFALSE; | |
247 | genHeader = event->GenEventHeader(); | |
248 | if (!genHeader) return kFALSE; | |
249 | } else { | |
250 | AliAODEvent *aodEvent = dynamic_cast<AliAODEvent*> (obj); | |
251 | if (!aodEvent) return kFALSE; | |
252 | mcHeader = dynamic_cast<AliAODMCHeader*>(aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName())); | |
253 | if (!mcHeader) { | |
254 | AliError("Could not find MC Header in AOD"); | |
255 | return kFALSE; | |
256 | } | |
257 | ||
258 | // Check for not null trigger mask to evict pPb MC buggy-events | |
259 | Int_t runnumber = aodEvent->GetRunNumber(); | |
260 | if(aodEvent->GetTriggerMask()==0 && | |
261 | (runnumber>=195344 && runnumber<=195677)){ | |
262 | AliDebug(3,"Event rejected because of null trigger mask"); | |
263 | return kFALSE; | |
264 | } | |
265 | } | |
266 | ||
267 | ||
268 | // Cut on Z Vertex ( |z-vtx| <= fMaxVtxZ ) | |
269 | TArrayF vtxPos(3); | |
270 | Double_t zMCVertex=-1000; | |
271 | if(!isAOD) { | |
272 | genHeader->PrimaryVertex(vtxPos); | |
273 | zMCVertex = vtxPos[2]; | |
274 | } else { | |
275 | zMCVertex = mcHeader->GetVtxZ(); | |
276 | } | |
277 | if( TMath::Abs(zMCVertex)>fMaxVtxZ ) isSelected = kFALSE; | |
278 | ||
279 | ||
280 | return isSelected; | |
281 | } | |
282 | ||
283 | //__________________________________________________________ | |
284 | Bool_t AliSingleTrackEffCuts::IsMCParticleGenerated(TObject* obj) | |
285 | { | |
286 | // | |
287 | // Check generated particles (primary, charged, pdgcode) | |
288 | // | |
289 | ||
290 | if(!obj) return kFALSE; | |
291 | if(!obj->InheritsFrom("AliVParticle")) { | |
292 | AliError("object must derived from AliVParticle !"); | |
293 | return kFALSE; | |
294 | } | |
295 | AliVParticle* particle = dynamic_cast<AliVParticle *>(obj); | |
296 | if(!particle) return kFALSE; | |
297 | ||
298 | Bool_t isSelected = kTRUE; | |
299 | ||
300 | // Check particle Pdg Code | |
301 | if(fIsPdgCode && TMath::Abs( particle->PdgCode() )!= fPdgCode) isSelected = kFALSE; | |
302 | ||
303 | // Charge selection | |
304 | if(fIsCharged && !(particle->Charge()!=0)) isSelected = kFALSE; | |
305 | ||
306 | // Selection of Physical Primary particles | |
307 | if(!fisAOD) { // check on ESDs | |
308 | AliMCEventHandler* mcinfo = (AliMCEventHandler*) (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
309 | AliMCEvent* mcevent = mcinfo->MCEvent(); | |
310 | AliStack* stack = ((AliMCEvent*)mcevent)->Stack(); | |
311 | AliMCParticle* mcPart = dynamic_cast<AliMCParticle *>(obj); | |
312 | if(!stack->IsPhysicalPrimary(mcPart->GetLabel())) { | |
313 | isSelected = kFALSE; | |
314 | } | |
315 | } else { // Check on AODs | |
316 | AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle *>(obj); | |
317 | if(!mcPart->IsPhysicalPrimary()) isSelected = kFALSE; | |
318 | } | |
319 | ||
320 | return isSelected; | |
321 | } | |
322 | ||
323 | ||
324 | //_____________________________________________________________________ | |
325 | Bool_t AliSingleTrackEffCuts::IsMCParticleInKineAcceptance(TObject *obj) | |
326 | { | |
327 | // | |
328 | // Check generated particles (eta, y, pt) | |
329 | // | |
330 | ||
331 | if(!obj) return kFALSE; | |
332 | if(!obj->InheritsFrom("AliVParticle")) AliError("object must derived from AliVParticle !"); | |
333 | AliVParticle* particle = dynamic_cast<AliVParticle *>(obj); | |
334 | if(!particle) return kFALSE; | |
335 | ||
336 | Bool_t isSelected = kTRUE; | |
337 | ||
338 | // Cut on eta | |
339 | if(particle->Eta()<fEtaMin || particle->Eta()>fEtaMax) isSelected = kFALSE; | |
340 | ||
341 | // Cut on y | |
342 | Double_t energy = particle->E(); | |
343 | Double_t pz = particle->Pz(); | |
344 | Double_t particleY = (TMath::Abs(energy-pz)>1e-10) ? 0.5*TMath::Log( (energy+pz)/(energy-pz) ) : 1e6; | |
345 | if(particleY<fYMin || particleY>fYMax) isSelected = kFALSE; | |
346 | ||
347 | // Cut on pt | |
348 | if(particle->Pt()<fPtMin || particle->Pt()>fPtMax) isSelected = kFALSE; | |
349 | ||
350 | return isSelected; | |
351 | } | |
352 | ||
353 | ||
354 | //_______________________________________________________________________ | |
355 | Bool_t AliSingleTrackEffCuts::IsMCParticleInReconstructable(TObject *obj) | |
356 | { | |
357 | // | |
358 | // Check if particle has left enough hits in the detectors (only at ESD level) | |
359 | // | |
360 | ||
361 | if(!obj) return kFALSE; | |
362 | TString className(obj->ClassName()); | |
363 | if (className.CompareTo("AliMCParticle") != 0) { | |
364 | AliError("obj must point to an AliMCParticle !"); | |
365 | return kTRUE; // <===================================== FIX ME !! | |
366 | } | |
367 | ||
368 | AliMCParticle * part = dynamic_cast<AliMCParticle*>(obj); | |
369 | if(!part) return kFALSE; | |
370 | ||
371 | Bool_t isSelected = kTRUE; | |
372 | ||
373 | Int_t nHitsITS=0, nHitsTPC=0, nHitsTRD=0, nHitsTOF=0, nHitsMUON=0; | |
374 | for(Int_t iTrackRef=0; iTrackRef<part->GetNumberOfTrackReferences(); iTrackRef++) { | |
375 | AliTrackReference * trackRef = part->GetTrackReference(iTrackRef); | |
376 | if(trackRef){ | |
377 | Int_t detectorId = trackRef->DetectorId(); | |
378 | switch(detectorId) { | |
5cc7b66d | 379 | case AliTrackReference::kITS : |
380 | nHitsITS++; | |
381 | break; | |
382 | case AliTrackReference::kTPC : | |
383 | nHitsTPC++; | |
384 | break; | |
385 | case AliTrackReference::kTRD : | |
386 | nHitsTRD++; | |
387 | break; | |
388 | case AliTrackReference::kTOF : | |
389 | nHitsTOF++; | |
390 | break; | |
391 | case AliTrackReference::kMUON : | |
392 | nHitsMUON++; | |
393 | break; | |
394 | default : break; | |
c0757458 | 395 | } |
396 | } | |
397 | } | |
398 | ||
399 | if(nHitsITS<fnClusITS) isSelected = kFALSE; | |
400 | if(nHitsTPC<fnClusTPC) isSelected = kFALSE; | |
401 | if(nHitsTOF<fnClusTOF) isSelected = kFALSE; | |
402 | if(nHitsMUON<fnClusMUON) isSelected = kFALSE; | |
403 | ||
404 | return isSelected; | |
405 | } | |
406 | ||
407 | ||
408 | //_____________________________________________________________ | |
409 | Bool_t AliSingleTrackEffCuts::IsRecoEventSelected(TObject* obj) | |
410 | { | |
411 | // | |
412 | // Event selection at reconstructed level (trigger, zvtx) | |
413 | // | |
414 | ||
415 | AliVEvent *event = dynamic_cast<AliVEvent*>(obj); | |
416 | if(!event) return kFALSE; | |
417 | ||
418 | Bool_t isSelected = kTRUE; | |
419 | ||
420 | // Check if event is accepted by the Physics selection | |
421 | UInt_t trigFired = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected(); | |
422 | Bool_t isEvtSelected = (trigFired & fTriggerMask); | |
423 | if(!isEvtSelected) isSelected = kFALSE; | |
424 | ||
425 | // Vertex selection | |
426 | Bool_t isVtxSelected = IsVertexSelected(event); | |
427 | if(!isVtxSelected) isSelected = kFALSE; | |
428 | ||
429 | return isSelected; | |
430 | } | |
431 | ||
432 | ||
433 | //______________________________________________________________________ | |
434 | Bool_t AliSingleTrackEffCuts::IsRecoParticleKineAcceptance(TObject *obj) | |
435 | { | |
436 | // | |
437 | // Check if reconstructed particle is in the acceptance (eta, y, pt) | |
438 | // | |
439 | ||
440 | Bool_t isSelected = kTRUE; | |
441 | ||
442 | AliVParticle *track = dynamic_cast<AliVParticle*>(obj); | |
443 | ||
444 | // Cut on eta | |
445 | if(track->Eta()<fEtaMin || track->Eta()>fEtaMax) isSelected = kFALSE; | |
446 | ||
447 | // Cut on y | |
448 | if(track->Y()<fYMin || track->Y()>fYMax) isSelected = kFALSE; | |
449 | ||
450 | // Cut on pt | |
451 | if(track->Pt()<fPtMin || track->Pt() >fPtMax) isSelected = kFALSE; | |
452 | ||
453 | return isSelected; | |
454 | } | |
455 | ||
456 | //_______________________________________________________________ | |
457 | Bool_t AliSingleTrackEffCuts::IsVertexSelected(AliVEvent *event) | |
458 | { | |
459 | // | |
460 | // Check if the reconstructed vertex is selected | |
461 | // | |
462 | ||
463 | Bool_t accept = kTRUE; | |
464 | Bool_t isAOD = event->IsA()->InheritsFrom("AliAODEvent"); | |
465 | ||
466 | const AliVVertex *vertex = event->GetPrimaryVertex(); | |
467 | if(!vertex){ | |
468 | accept = kFALSE; | |
469 | AliInfo("no vtx"); | |
470 | return accept; | |
471 | } | |
472 | ||
473 | // Cut on vertex type | |
474 | TString title=vertex->GetTitle(); | |
475 | if(title.Contains("Z") && fMinVtxType>1){ | |
476 | accept=kFALSE; | |
477 | } else if(title.Contains("3D") && fMinVtxType>2){ | |
478 | accept=kFALSE; | |
479 | } | |
480 | ||
481 | // cut on minimum number of contributors | |
482 | if(vertex->GetNContributors()<fMinVtxContr){ | |
483 | AliInfo(Form("too few contributors %d",vertex->GetNContributors())); | |
484 | accept=kFALSE; | |
485 | } | |
486 | ||
487 | // cut on absolute |z| of the vertex | |
488 | if(TMath::Abs(vertex->GetZ())>fMaxVtxZ) { | |
489 | AliInfo("outside the Vtx range"); | |
490 | accept=kFALSE; | |
491 | } | |
492 | ||
493 | // cut on distance of SPD and TRK vertexes | |
494 | if(fCutOnZVertexSPD==1) { | |
495 | const AliVVertex *vSPD = NULL; | |
496 | if(isAOD) { | |
497 | vSPD = ((AliAODEvent*)event)->GetPrimaryVertexSPD(); | |
498 | }else { | |
499 | vSPD = ((AliESDEvent*)event)->GetPrimaryVertexSPD(); | |
500 | } | |
501 | ||
502 | if(vSPD && vSPD->GetNContributors()>=fMinVtxContr) { | |
503 | if(TMath::Abs(vSPD->GetZ()-vertex->GetZ())>0.5) accept = kFALSE; | |
504 | } | |
505 | } | |
506 | ||
507 | return accept; | |
508 | } | |
509 | ||
510 | //_________________________________________________________________________________________________ | |
511 | void AliSingleTrackEffCuts::SetTPCSigmaPtBins(Int_t nPtBins, Float_t *pBinLimits, Float_t *sigmaBin) | |
512 | { | |
513 | // | |
514 | // Set TPC Pid number-of-Sigma in P bins | |
515 | // | |
516 | ||
517 | // Set the pt bins | |
518 | if(fPTPCBinLimits) { | |
519 | delete [] fPTPCBinLimits; | |
520 | fPTPCBinLimits = NULL; | |
521 | printf("Changing the TPC cut P bins\n"); | |
522 | } | |
523 | if(fnSigmaTPC) { | |
524 | delete [] fnSigmaTPC; | |
525 | fnSigmaTPC = NULL; | |
526 | printf("Changing the TPC Sigma cut per p bin\n"); | |
527 | } | |
528 | ||
529 | fnPTPCBins = nPtBins; | |
530 | fnPTPCBinLimits = nPtBins+1; | |
531 | fPTPCBinLimits = new Float_t[fnPTPCBinLimits]; | |
532 | for(Int_t ib=0; ib<nPtBins+1; ib++) fPTPCBinLimits[ib]=pBinLimits[ib]; | |
533 | fnSigmaTPC = new Float_t[fnPTPCBins]; | |
534 | for(Int_t ib=0; ib<nPtBins; ib++) fnSigmaTPC[ib]=sigmaBin[ib]; | |
535 | ||
536 | return; | |
537 | } | |
538 | //_____________________________________________________________________________________________________ | |
539 | void AliSingleTrackEffCuts::SetTOFSigmaPtBins(Int_t nPtBins, Float_t *pBinLimits, Float_t *sigmaBin) | |
540 | { | |
541 | // | |
542 | // Set TOF Pid number-of-Sigma in P bins | |
543 | // | |
544 | ||
545 | // Set the pt bins | |
546 | if(fPTOFBinLimits) { | |
547 | delete [] fPTOFBinLimits; | |
548 | fPTOFBinLimits = NULL; | |
549 | printf("Changing the TOF cut P bins\n"); | |
550 | } | |
551 | if(fnSigmaTOF) { | |
552 | delete [] fnSigmaTOF; | |
553 | fnSigmaTOF = NULL; | |
554 | printf("Changing the TOF Sigma cut per p bin\n"); | |
555 | } | |
556 | ||
557 | fnPTOFBins = nPtBins; | |
558 | fnPTOFBinLimits = nPtBins+1; | |
559 | fPTOFBinLimits = new Float_t[fnPTOFBinLimits]; | |
560 | for(Int_t ib=0; ib<nPtBins+1; ib++) fPTOFBinLimits[ib]=pBinLimits[ib]; | |
561 | fnSigmaTOF = new Float_t[fnPTOFBins]; | |
562 | for(Int_t ib=0; ib<nPtBins; ib++) fnSigmaTOF[ib]=sigmaBin[ib]; | |
563 | ||
564 | return; | |
565 | } | |
566 | ||
567 | //___________________________________________________________________________ | |
568 | Bool_t AliSingleTrackEffCuts::CheckTPCPIDStatus(AliAODTrack *track) const{ | |
569 | // | |
570 | // Check TPC PID status | |
571 | // | |
572 | ||
573 | if ((track->GetStatus() & AliESDtrack::kTPCin)==0) return kFALSE; | |
574 | UShort_t nTPCClus=track->GetTPCClusterMap().CountBits(); | |
575 | if (nTPCClus<70) return kFALSE; | |
576 | return kTRUE; | |
577 | } | |
578 | ||
579 | //___________________________________________________________________________ | |
580 | Bool_t AliSingleTrackEffCuts::CheckTOFPIDStatus(AliAODTrack *track) const{ | |
581 | // | |
582 | // Check TOC PID status | |
583 | // | |
584 | ||
585 | if ((track->GetStatus()&AliESDtrack::kTOFout)==0) return kFALSE; | |
586 | if ((track->GetStatus()&AliESDtrack::kTIME)==0) return kFALSE; | |
587 | if ((track->GetStatus()&AliESDtrack::kTOFpid)==0) return kFALSE; | |
588 | if (!(track->GetStatus()&AliESDtrack::kTOFmismatch)==0) return kFALSE; | |
589 | return kTRUE; | |
590 | } | |
591 | ||
592 | //___________________________________________________________________________ | |
593 | Bool_t AliSingleTrackEffCuts::IsRecoParticlePID(TObject *obj) | |
594 | { | |
595 | // | |
596 | // Check Particle PID (AOD only for now!) | |
597 | // | |
598 | ||
599 | Bool_t isSelected = kFALSE; | |
600 | Bool_t isAOD = obj->IsA()->InheritsFrom("AliAODTrack"); | |
601 | ||
602 | if(!isAOD || !GetUsePid()) return isSelected; | |
603 | if(!fuseTPCPid && !fuseTOFPid) return isSelected; | |
604 | ||
605 | AliAODTrack *track = dynamic_cast<AliAODTrack*>(obj); | |
606 | if(!track) { cout<<"No track found"<<endl; return isSelected; } | |
607 | ||
608 | // AliAODPid *pid = track->GetDetPid(); | |
609 | // if(!pid) { cout<<"No AliAODPid found"<<endl; return isSelected; } | |
610 | ||
611 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
612 | AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler(); | |
613 | AliPIDResponse *pidResp=inputHandler->GetPIDResponse(); | |
614 | if(!pidResp) { cout<<"No PidResponse found"<<endl; return isSelected;} | |
615 | ||
616 | Double_t pPart = track->P(); | |
617 | ||
618 | // Check detector status | |
619 | Bool_t okTPC = CheckTPCPIDStatus(track); | |
620 | Bool_t okTOF = CheckTOFPIDStatus(track); | |
621 | ||
622 | // Check Number of Sigmas | |
623 | Double_t nsigmaTPC=pidResp->NumberOfSigmasTPC((AliVParticle*)track,(AliPID::EParticleType)fParticlePid); | |
624 | Double_t nsigmaTOF=pidResp->NumberOfSigmasTOF((AliVParticle*)track,(AliPID::EParticleType)fParticlePid); | |
625 | Bool_t isTPCPid=false, isTOFPid=false; | |
626 | ||
627 | // If use TPC and TPC infos are ok, check whether the sigma is ok in the given p range | |
628 | if(fuseTPCPid && okTPC) { | |
629 | for(Int_t j=0; j<fnPTPCBins; j++) { | |
630 | // cout<<" checking bin: ("<<fPTPCBinLimits[j]<<","<<fPTPCBinLimits[j+1]<<") should be nsigma < "<<fnSigmaTPC[j]<<endl; | |
631 | if ((pPart>fPTPCBinLimits[j]) && (pPart<fPTPCBinLimits[j+1]) && nsigmaTPC<fnSigmaTPC[j]) isTPCPid=true; | |
632 | } | |
633 | if(pPart>fPmaxTPC) isTPCPid=true; | |
634 | } | |
635 | ||
636 | // If use TPC and TPC infos are ok, check whether the sigma is ok in the given p range | |
637 | if(fuseTOFPid && okTOF) { | |
638 | for(Int_t j=0; j<fnPTOFBins; j++) { | |
639 | if ((pPart>fPTOFBinLimits[j]) && (pPart<fPTOFBinLimits[j+1]) && nsigmaTOF<fnSigmaTOF[j]) isTPCPid=true; | |
640 | } | |
641 | if(pPart>fPmaxTOF) isTOFPid=true; | |
642 | } | |
643 | ||
644 | isSelected = (isTPCPid || isTOFPid) ? true : false; | |
645 | ||
646 | return isSelected; | |
647 | } |