1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 // ESD track cuts for flow framework
21 // origin: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch)
23 // This class gurantees consistency of cut methods, trackparameter
24 // selection (global tracks, TPC only, etc..) and parameter mixing
25 // in the flow framework. Transparently handles different input types:
27 // This class works in 2 steps: first the requested track parameters are
28 // constructed (to be set by SetParamType() ), then cuts are applied.
29 // the constructed track can be requested AFTER checking the cuts by
30 // calling GetTrack(), in this case the cut object stays in control,
31 // caller does not have to delete the track.
32 // Additionally caller can request an AliFlowTrack object to be constructed
33 // according the parameter mixing scenario requested by SetParamMix().
34 // AliFlowTrack is made using MakeFlowTrack() method, its an 'object factory'
35 // so caller needs to take care of the freshly created object.
40 #include "TMCProcess.h"
41 #include "TParticle.h"
45 #include "AliMCEvent.h"
46 #include "AliESDEvent.h"
47 #include "AliAODEvent.h"
48 #include "AliVParticle.h"
49 #include "AliMCParticle.h"
50 #include "AliESDtrack.h"
51 #include "AliMultiplicity.h"
52 #include "AliAODTrack.h"
53 #include "AliFlowTrackSimple.h"
54 #include "AliFlowTrack.h"
55 #include "AliFlowTrackCuts.h"
57 #include "AliESDpid.h"
58 #include "AliESDPmdTrack.h"
59 #include "AliVVZERO.h"
61 ClassImp(AliFlowTrackCuts)
63 //-----------------------------------------------------------------------
64 AliFlowTrackCuts::AliFlowTrackCuts():
65 AliFlowTrackSimpleCuts(),
66 fAliESDtrackCuts(NULL),
69 fCutMChasTrackReferences(kFALSE),
70 fCutMCprocessType(kFALSE),
71 fMCprocessType(kPNoProcess),
74 fIgnoreSignInMCPID(kFALSE),
75 fCutMCisPrimary(kFALSE),
76 fRequireTransportBitForPrimaries(kTRUE),
78 fRequireCharge(kFALSE),
80 fCutSPDtrackletDeltaPhi(kFALSE),
81 fSPDtrackletDeltaPhiMax(FLT_MAX),
82 fSPDtrackletDeltaPhiMin(-FLT_MAX),
83 fIgnoreTPCzRange(kFALSE),
84 fIgnoreTPCzRangeMax(FLT_MAX),
85 fIgnoreTPCzRangeMin(-FLT_MAX),
86 fCutChi2PerClusterTPC(kFALSE),
87 fMaxChi2PerClusterTPC(FLT_MAX),
88 fMinChi2PerClusterTPC(-FLT_MAX),
89 fCutNClustersTPC(kFALSE),
90 fNClustersTPCMax(INT_MAX),
91 fNClustersTPCMin(INT_MIN),
92 fCutNClustersITS(kFALSE),
93 fNClustersITSMax(INT_MAX),
94 fNClustersITSMin(INT_MIN),
95 fUseAODFilterBit(kFALSE),
97 fCutDCAToVertexXY(kFALSE),
98 fCutDCAToVertexZ(kFALSE),
99 fCutMinimalTPCdedx(kFALSE),
105 fCutPmdNcell(kFALSE),
113 fTrackLabel(INT_MIN),
118 fFlowTagType(AliFlowTrackSimple::kInvalid),
123 fParticleID(AliPID::kUnknown),
124 fParticleProbability(.9),
125 fAllowTOFmismatchFlag(kFALSE),
126 fRequireStrictTOFTPCagreement(kFALSE),
127 fCutRejectElectronsWithTPCpid(kFALSE)
130 for ( Int_t i=0; i<5; i++ ) { fProbBayes[i]=0.0; }
131 SetPriors(); //init arrays
134 //-----------------------------------------------------------------------
135 AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
136 AliFlowTrackSimpleCuts(),
137 fAliESDtrackCuts(NULL),
140 fCutMChasTrackReferences(kFALSE),
141 fCutMCprocessType(kFALSE),
142 fMCprocessType(kPNoProcess),
145 fIgnoreSignInMCPID(kFALSE),
146 fCutMCisPrimary(kFALSE),
147 fRequireTransportBitForPrimaries(kTRUE),
148 fMCisPrimary(kFALSE),
149 fRequireCharge(kFALSE),
151 fCutSPDtrackletDeltaPhi(kFALSE),
152 fSPDtrackletDeltaPhiMax(FLT_MAX),
153 fSPDtrackletDeltaPhiMin(-FLT_MAX),
154 fIgnoreTPCzRange(kFALSE),
155 fIgnoreTPCzRangeMax(FLT_MAX),
156 fIgnoreTPCzRangeMin(-FLT_MAX),
157 fCutChi2PerClusterTPC(kFALSE),
158 fMaxChi2PerClusterTPC(FLT_MAX),
159 fMinChi2PerClusterTPC(-FLT_MAX),
160 fCutNClustersTPC(kFALSE),
161 fNClustersTPCMax(INT_MAX),
162 fNClustersTPCMin(INT_MIN),
163 fCutNClustersITS(kFALSE),
164 fNClustersITSMax(INT_MAX),
165 fNClustersITSMin(INT_MIN),
166 fUseAODFilterBit(kFALSE),
168 fCutDCAToVertexXY(kFALSE),
169 fCutDCAToVertexZ(kFALSE),
170 fCutMinimalTPCdedx(kFALSE),
176 fCutPmdNcell(kFALSE),
184 fTrackLabel(INT_MIN),
189 fFlowTagType(AliFlowTrackSimple::kInvalid),
194 fParticleID(AliPID::kUnknown),
195 fParticleProbability(.9),
196 fAllowTOFmismatchFlag(kFALSE),
197 fRequireStrictTOFTPCagreement(kFALSE),
198 fCutRejectElectronsWithTPCpid(kFALSE)
202 SetTitle("AliFlowTrackCuts");
203 fESDpid.GetTPCResponse().SetBetheBlochParameters( 0.0283086,
208 for ( Int_t i=0; i<5; i++ ) { fProbBayes[i]=0.0; }
209 SetPriors(); //init arrays
213 //-----------------------------------------------------------------------
214 AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
215 AliFlowTrackSimpleCuts(that),
216 fAliESDtrackCuts(NULL),
219 fCutMChasTrackReferences(that.fCutMChasTrackReferences),
220 fCutMCprocessType(that.fCutMCprocessType),
221 fMCprocessType(that.fMCprocessType),
222 fCutMCPID(that.fCutMCPID),
224 fIgnoreSignInMCPID(that.fIgnoreSignInMCPID),
225 fCutMCisPrimary(that.fCutMCisPrimary),
226 fRequireTransportBitForPrimaries(that.fRequireTransportBitForPrimaries),
227 fMCisPrimary(that.fMCisPrimary),
228 fRequireCharge(that.fRequireCharge),
229 fFakesAreOK(that.fFakesAreOK),
230 fCutSPDtrackletDeltaPhi(that.fCutSPDtrackletDeltaPhi),
231 fSPDtrackletDeltaPhiMax(that.fSPDtrackletDeltaPhiMax),
232 fSPDtrackletDeltaPhiMin(that.fSPDtrackletDeltaPhiMin),
233 fIgnoreTPCzRange(that.fIgnoreTPCzRange),
234 fIgnoreTPCzRangeMax(that.fIgnoreTPCzRangeMax),
235 fIgnoreTPCzRangeMin(that.fIgnoreTPCzRangeMin),
236 fCutChi2PerClusterTPC(that.fCutChi2PerClusterTPC),
237 fMaxChi2PerClusterTPC(that.fMaxChi2PerClusterTPC),
238 fMinChi2PerClusterTPC(that.fMinChi2PerClusterTPC),
239 fCutNClustersTPC(that.fCutNClustersTPC),
240 fNClustersTPCMax(that.fNClustersTPCMax),
241 fNClustersTPCMin(that.fNClustersTPCMin),
242 fCutNClustersITS(that.fCutNClustersITS),
243 fNClustersITSMax(that.fNClustersITSMax),
244 fNClustersITSMin(that.fNClustersITSMin),
245 fUseAODFilterBit(that.fUseAODFilterBit),
246 fAODFilterBit(that.fAODFilterBit),
247 fCutDCAToVertexXY(that.fCutDCAToVertexXY),
248 fCutDCAToVertexZ(that.fCutDCAToVertexZ),
249 fCutMinimalTPCdedx(that.fCutMinimalTPCdedx),
250 fMinimalTPCdedx(that.fMinimalTPCdedx),
251 fCutPmdDet(that.fCutPmdDet),
252 fPmdDet(that.fPmdDet),
253 fCutPmdAdc(that.fCutPmdAdc),
254 fPmdAdc(that.fPmdAdc),
255 fCutPmdNcell(that.fCutPmdNcell),
256 fPmdNcell(that.fPmdNcell),
257 fParamType(that.fParamType),
258 fParamMix(that.fParamMix),
263 fTrackLabel(INT_MIN),
268 fFlowTagType(that.fFlowTagType),
269 fESDpid(that.fESDpid),
270 fPIDsource(that.fPIDsource),
273 fParticleID(that.fParticleID),
274 fParticleProbability(that.fParticleProbability),
275 fAllowTOFmismatchFlag(that.fAllowTOFmismatchFlag),
276 fRequireStrictTOFTPCagreement(that.fRequireStrictTOFTPCagreement),
277 fCutRejectElectronsWithTPCpid(that.fCutRejectElectronsWithTPCpid)
280 if (that.fTPCpidCuts) fTPCpidCuts = new TMatrixF(*(that.fTPCpidCuts));
281 if (that.fTOFpidCuts) fTOFpidCuts = new TMatrixF(*(that.fTOFpidCuts));
282 if (that.fAliESDtrackCuts) fAliESDtrackCuts = new AliESDtrackCuts(*(that.fAliESDtrackCuts));
283 memcpy(fProbBayes,that.fProbBayes,sizeof(fProbBayes));
284 SetPriors(); //init arrays
285 if (that.fQA) DefineHistograms();
288 //-----------------------------------------------------------------------
289 AliFlowTrackCuts& AliFlowTrackCuts::operator=(const AliFlowTrackCuts& that)
292 if (this==&that) return *this;
294 AliFlowTrackSimpleCuts::operator=(that);
295 //the following may seem excessive but if AliESDtrackCuts properly does copy and clone
296 //this approach is better memory-fragmentation-wise in some cases
297 if (that.fAliESDtrackCuts && fAliESDtrackCuts) *fAliESDtrackCuts=*(that.fAliESDtrackCuts);
298 if (that.fAliESDtrackCuts && !fAliESDtrackCuts) fAliESDtrackCuts=new AliESDtrackCuts(*(that.fAliESDtrackCuts));
299 if (!that.fAliESDtrackCuts) delete fAliESDtrackCuts; fAliESDtrackCuts=NULL;
300 //these guys we don't need to copy, just reinit
301 if (that.fQA) {fQA->Delete(); delete fQA; fQA=NULL; DefineHistograms();}
303 fCutMChasTrackReferences=that.fCutMChasTrackReferences;
304 fCutMCprocessType=that.fCutMCprocessType;
305 fMCprocessType=that.fMCprocessType;
306 fCutMCPID=that.fCutMCPID;
308 fIgnoreSignInMCPID=that.fIgnoreSignInMCPID,
309 fCutMCisPrimary=that.fCutMCisPrimary;
310 fRequireTransportBitForPrimaries=that.fRequireTransportBitForPrimaries;
311 fMCisPrimary=that.fMCisPrimary;
312 fRequireCharge=that.fRequireCharge;
313 fFakesAreOK=that.fFakesAreOK;
314 fCutSPDtrackletDeltaPhi=that.fCutSPDtrackletDeltaPhi;
315 fSPDtrackletDeltaPhiMax=that.fSPDtrackletDeltaPhiMax;
316 fSPDtrackletDeltaPhiMin=that.fSPDtrackletDeltaPhiMin;
317 fIgnoreTPCzRange=that.fIgnoreTPCzRange;
318 fIgnoreTPCzRangeMax=that.fIgnoreTPCzRangeMax;
319 fIgnoreTPCzRangeMin=that.fIgnoreTPCzRangeMin;
320 fCutChi2PerClusterTPC=that.fCutChi2PerClusterTPC;
321 fMaxChi2PerClusterTPC=that.fMaxChi2PerClusterTPC;
322 fMinChi2PerClusterTPC=that.fMinChi2PerClusterTPC;
323 fCutNClustersTPC=that.fCutNClustersTPC;
324 fNClustersTPCMax=that.fNClustersTPCMax;
325 fNClustersTPCMin=that.fNClustersTPCMin;
326 fCutNClustersITS=that.fCutNClustersITS;
327 fNClustersITSMax=that.fNClustersITSMax;
328 fNClustersITSMin=that.fNClustersITSMin;
329 fUseAODFilterBit=that.fUseAODFilterBit;
330 fAODFilterBit=that.fAODFilterBit;
331 fCutDCAToVertexXY=that.fCutDCAToVertexXY;
332 fCutDCAToVertexZ=that.fCutDCAToVertexZ;
333 fCutMinimalTPCdedx=that.fCutMinimalTPCdedx;
334 fMinimalTPCdedx=that.fMinimalTPCdedx;
335 fCutPmdDet=that.fCutPmdDet;
336 fPmdDet=that.fPmdDet;
337 fCutPmdAdc=that.fCutPmdAdc;
338 fPmdAdc=that.fPmdAdc;
339 fCutPmdNcell=that.fCutPmdNcell;
340 fPmdNcell=that.fPmdNcell;
341 fFlowTagType=that.fFlowTagType;
343 fParamType=that.fParamType;
344 fParamMix=that.fParamMix;
355 fESDpid = that.fESDpid;
356 fPIDsource = that.fPIDsource;
360 if (that.fTPCpidCuts) fTPCpidCuts = new TMatrixF(*(that.fTPCpidCuts));
361 if (that.fTOFpidCuts) fTOFpidCuts = new TMatrixF(*(that.fTOFpidCuts));
363 fParticleID=that.fParticleID;
364 fParticleProbability=that.fParticleProbability;
365 fAllowTOFmismatchFlag=that.fAllowTOFmismatchFlag;
366 fRequireStrictTOFTPCagreement=that.fRequireStrictTOFTPCagreement;
367 fCutRejectElectronsWithTPCpid=that.fCutRejectElectronsWithTPCpid;
368 memcpy(fProbBayes,that.fProbBayes,sizeof(fProbBayes));
373 //-----------------------------------------------------------------------
374 AliFlowTrackCuts::~AliFlowTrackCuts()
377 delete fAliESDtrackCuts;
380 if (fQA) { fQA->SetOwner(); fQA->Delete(); delete fQA; }
383 //-----------------------------------------------------------------------
384 void AliFlowTrackCuts::SetEvent(AliVEvent* event, AliMCEvent* mcEvent)
391 //do the magic for ESD
392 AliESDEvent* myESD = dynamic_cast<AliESDEvent*>(event);
393 if (fCutPID && myESD)
395 //TODO: maybe call it only for the TOF options?
396 // Added by F. Noferini for TOF PID
397 fESDpid.SetTOFResponse(myESD,AliESDpid::kTOF_T0);
398 fESDpid.MakePID(myESD,kFALSE);
399 // End F. Noferini added part
405 //-----------------------------------------------------------------------
406 void AliFlowTrackCuts::SetCutMC( Bool_t b )
408 //will we be cutting on MC information?
411 //if we cut on MC info then also the Bethe Bloch should be the one tuned for MC
414 fESDpid.GetTPCResponse().SetBetheBlochParameters( 2.15898e+00/50.,
422 //-----------------------------------------------------------------------
423 Bool_t AliFlowTrackCuts::IsSelected(TObject* obj, Int_t id)
426 AliVParticle* vparticle = dynamic_cast<AliVParticle*>(obj);
427 if (vparticle) return PassesCuts(vparticle);
428 AliFlowTrackSimple* flowtrack = dynamic_cast<AliFlowTrackSimple*>(obj);
429 if (flowtrack) return PassesCuts(flowtrack);
430 AliMultiplicity* tracklets = dynamic_cast<AliMultiplicity*>(obj);
431 if (tracklets) return PassesCuts(tracklets,id);
432 AliESDPmdTrack* pmdtrack = dynamic_cast<AliESDPmdTrack*>(obj);
433 if (pmdtrack) return PassesPMDcuts(pmdtrack);
434 AliVVZERO* vvzero = dynamic_cast<AliVVZERO*>(obj);
435 if (vvzero) return PassesV0cuts(vvzero,id);
436 return kFALSE; //default when passed wrong type of object
439 //-----------------------------------------------------------------------
440 Bool_t AliFlowTrackCuts::IsSelectedMCtruth(TObject* obj, Int_t id)
443 AliVParticle* vparticle = dynamic_cast<AliVParticle*>(obj);
446 return PassesMCcuts(fMCevent,vparticle->GetLabel());
448 AliMultiplicity* tracklets = dynamic_cast<AliMultiplicity*>(obj);
451 Int_t label0 = tracklets->GetLabel(id,0);
452 Int_t label1 = tracklets->GetLabel(id,1);
453 Int_t label = (label0==label1)?tracklets->GetLabel(id,1):-666;
454 return PassesMCcuts(fMCevent,label);
456 return kFALSE; //default when passed wrong type of object
459 //-----------------------------------------------------------------------
460 Bool_t AliFlowTrackCuts::PassesCuts(const AliFlowTrackSimple* track)
462 //check cuts on a flowtracksimple
464 //clean up from last iteration
466 return AliFlowTrackSimpleCuts::PassesCuts(track);
469 //-----------------------------------------------------------------------
470 Bool_t AliFlowTrackCuts::PassesCuts(const AliMultiplicity* tracklet, Int_t id)
472 //check cuts on a tracklets
474 //clean up from last iteration, and init label
479 fTrackPhi = tracklet->GetPhi(id);
480 fTrackEta = tracklet->GetEta(id);
482 if (fCutEta) {if ( fTrackEta < fEtaMin || fTrackEta >= fEtaMax ) return kFALSE;}
483 if (fCutPhi) {if ( fTrackPhi < fPhiMin || fTrackPhi >= fPhiMax ) return kFALSE;}
485 //check MC info if available
486 //if the 2 clusters have different label track cannot be good
487 //and should therefore not pass the mc cuts
488 Int_t label0 = tracklet->GetLabel(id,0);
489 Int_t label1 = tracklet->GetLabel(id,1);
490 //if possible get label and mcparticle
491 fTrackLabel = (label0==label1)?tracklet->GetLabel(id,1):-1;
492 if (!fFakesAreOK && fTrackLabel<0) return kFALSE;
493 if (fTrackLabel>=0 && fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
495 if (fCutMC && !PassesMCcuts()) return kFALSE;
499 //-----------------------------------------------------------------------
500 Bool_t AliFlowTrackCuts::PassesMCcuts(AliMCEvent* mcEvent, Int_t label)
503 if (!mcEvent) return kFALSE;
504 if (label<0) return kFALSE;//otherwise AliCMevent prints a warning before returning NULL
505 AliMCParticle* mcparticle = static_cast<AliMCParticle*>(mcEvent->GetTrack(label));
506 if (!mcparticle) {AliError("no MC track"); return kFALSE;}
510 if (IsPhysicalPrimary(mcEvent,label,fRequireTransportBitForPrimaries) != fMCisPrimary) return kFALSE;
514 Int_t pdgCode = mcparticle->PdgCode();
515 if (fIgnoreSignInMCPID)
517 if (TMath::Abs(fMCPID) != TMath::Abs(pdgCode)) return kFALSE;
521 if (fMCPID != pdgCode) return kFALSE;
524 if ( fCutMCprocessType )
526 TParticle* particle = mcparticle->Particle();
527 Int_t processID = particle->GetUniqueID();
528 if (processID != fMCprocessType ) return kFALSE;
530 if (fCutMChasTrackReferences)
532 if (mcparticle->GetNumberOfTrackReferences()<1) return kFALSE;
537 //-----------------------------------------------------------------------
538 Bool_t AliFlowTrackCuts::PassesMCcuts()
541 if (!fMCevent) return kFALSE;
542 if (fTrackLabel<0) return kFALSE;//otherwise AliCMevent prints a warning before returning NULL
543 fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
544 return PassesMCcuts(fMCevent,fTrackLabel);
547 //-----------------------------------------------------------------------
548 Bool_t AliFlowTrackCuts::PassesCuts(AliVParticle* vparticle)
550 //check cuts for an ESD vparticle
552 ////////////////////////////////////////////////////////////////
553 // start by preparing the track parameters to cut on //////////
554 ////////////////////////////////////////////////////////////////
555 //clean up from last iteration
558 //get the label and the mc particle
559 fTrackLabel = (fFakesAreOK)?TMath::Abs(vparticle->GetLabel()):vparticle->GetLabel();
560 if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
561 else fMCparticle=NULL;
563 Bool_t isMCparticle = kFALSE; //some things are different for MC particles, check!
564 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*>(vparticle);
565 AliAODTrack* aodTrack = NULL;
568 //for an ESD track we do some magic sometimes like constructing TPC only parameters
569 //or doing some hybrid, handle that here
570 HandleESDtrack(esdTrack);
574 HandleVParticle(vparticle);
575 //now check if produced particle is MC
576 isMCparticle = (dynamic_cast<AliMCParticle*>(fTrack))!=NULL;
577 aodTrack = dynamic_cast<AliAODTrack*>(vparticle); //keep the additional dynamic cast out of the way for ESDs
579 ////////////////////////////////////////////////////////////////
580 ////////////////////////////////////////////////////////////////
582 if (!fTrack) return kFALSE;
583 //because it may be different from global, not needed for aodTrack because we dont do anything funky there
584 if (esdTrack) esdTrack = static_cast<AliESDtrack*>(fTrack);
587 //check the common cuts for the current particle fTrack (MC,AOD,ESD)
588 Double_t pt = fTrack->Pt();
589 Double_t p = fTrack->P();
590 if (!fFakesAreOK) {if (fTrackLabel<0) pass=kFALSE;}
591 if (fCutPt) {if (pt < fPtMin || pt >= fPtMax ) pass=kFALSE;}
592 if (fCutEta) {if (fTrack->Eta() < fEtaMin || fTrack->Eta() >= fEtaMax ) pass=kFALSE;}
593 if (fCutPhi) {if (fTrack->Phi() < fPhiMin || fTrack->Phi() >= fPhiMax ) pass=kFALSE;}
594 if (fRequireCharge) {if (fTrack->Charge() == 0) pass=kFALSE;}
595 if (fCutCharge && !isMCparticle) {if (fTrack->Charge() != fCharge) pass=kFALSE;}
596 if (fCutCharge && isMCparticle)
598 //in case of an MC particle the charge is stored in units of 1/3|e|
599 Int_t charge = TMath::Nint(fTrack->Charge()/3.0); //mc particles have charge in units of 1/3e
600 if (charge!=fCharge) pass=kFALSE;
602 //if(fCutPID) {if (fTrack->PID() != fPID) pass=kFALSE;}
604 //when additionally MC info is required
605 if (fCutMC && !PassesMCcuts()) pass=kFALSE;
607 //the case of ESD or AOD
608 if (esdTrack) { if (!PassesESDcuts(esdTrack)) { pass=kFALSE; } }
609 if (aodTrack) { if (!PassesAODcuts(aodTrack)) { pass=kFALSE; } }
615 TParticle* tparticle=fMCparticle->Particle();
616 Int_t processID = tparticle->GetUniqueID();
617 Int_t firstMotherLabel = tparticle->GetFirstMother();
619 //mcparticle->Particle()->ProductionVertex(v);
620 //Double_t prodvtxX = v.X();
621 //Double_t prodvtxY = v.Y();
624 Int_t pdgcode = fMCparticle->PdgCode();
625 Float_t pdgFirstMother = 0;
626 Int_t pdgcodeFirstMother = fMCevent->GetTrack(firstMotherLabel)->PdgCode();
628 switch (TMath::Abs(pdgcode))
631 pdg = AliPID::kElectron + 0.5; break;
633 pdg = AliPID::kMuon + 0.5; break;
635 pdg = AliPID::kPion + 0.5; break;
637 pdg = AliPID::kKaon + 0.5; break;
639 pdg = AliPID::kProton + 0.5; break;
641 pdg = AliPID::kUnknown + 0.5; break;
643 pdg = TMath::Sign(pdg,static_cast<Float_t>(pdgcode));
645 switch (TMath::Abs(pdgcodeFirstMother))
648 pdgFirstMother = 0.5; break;
649 case 3222: case 3212: case 3112: //sigma+ sigma0 sigma-
650 pdgFirstMother = 1.5; break;
651 case 3322: case 3312: //xi0 xi+
652 pdgFirstMother = 2.5;
654 pdgFirstMother = 3.5;
656 pdgFirstMother = 1e10; break;
658 pdgFirstMother = TMath::Sign(pdgFirstMother,static_cast<Float_t>(pdgcodeFirstMother));
660 QAbefore(2)->Fill(p,pdg);
661 QAbefore(3)->Fill(p,IsPhysicalPrimary()?0.5:-0.5);
662 QAbefore(4)->Fill(p,static_cast<Float_t>(processID));
663 QAbefore(7)->Fill(p,pdgFirstMother);
664 if (pass) QAafter(2)->Fill(p,pdg);
665 if (pass) QAafter(3)->Fill(p,IsPhysicalPrimary()?0.5:-0.5);
666 if (pass) QAafter(4)->Fill(p,static_cast<Float_t>(processID));
667 if (pass) QAafter(7)->Fill(p,pdgFirstMother);
671 //true by default, if we didn't set any cuts
675 //_______________________________________________________________________
676 Bool_t AliFlowTrackCuts::PassesAODcuts(const AliAODTrack* track)
681 if (fCutNClustersTPC)
683 Int_t ntpccls = track->GetTPCNcls();
684 if (ntpccls < fNClustersTPCMin || ntpccls > fNClustersTPCMax) pass=kFALSE;
687 if (fCutNClustersITS)
689 Int_t nitscls = track->GetITSNcls();
690 if (nitscls < fNClustersITSMin || nitscls > fNClustersITSMax) pass=kFALSE;
693 if (fCutChi2PerClusterTPC)
695 Double_t chi2tpc = track->Chi2perNDF();
696 if (chi2tpc < fMinChi2PerClusterTPC || chi2tpc > fMaxChi2PerClusterTPC) pass=kFALSE;
699 if (GetRequireTPCRefit() && !(track->GetStatus() & AliESDtrack::kTPCrefit) ) pass=kFALSE;
700 if (GetRequireITSRefit() && !(track->GetStatus() & AliESDtrack::kITSrefit) ) pass=kFALSE;
702 if (fUseAODFilterBit && !track->TestFilterBit(fAODFilterBit)) pass=kFALSE;
704 if (fCutDCAToVertexXY && track->DCA()>GetMaxDCAToVertexXY()) pass=kFALSE;
706 if (fCutDCAToVertexZ && track->ZAtDCA()>GetMaxDCAToVertexZ()) pass=kFALSE;
708 if (track->GetTPCsignal() < fMinimalTPCdedx) pass=kFALSE;
713 //_______________________________________________________________________
714 Bool_t AliFlowTrackCuts::PassesESDcuts(AliESDtrack* track)
716 //check cuts on ESD tracks
720 track->GetImpactParameters(dcaxy,dcaz);
721 const AliExternalTrackParam* pout = track->GetOuterParam();
722 const AliExternalTrackParam* pin = track->GetInnerParam();
723 if (fIgnoreTPCzRange)
727 Double_t zin = pin->GetZ();
728 Double_t zout = pout->GetZ();
729 if (zin*zout<0) pass=kFALSE; //reject if cross the membrane
730 if (zin < fIgnoreTPCzRangeMin || zin > fIgnoreTPCzRangeMax) pass=kFALSE;
731 if (zout < fIgnoreTPCzRangeMin || zout > fIgnoreTPCzRangeMax) pass=kFALSE;
735 Int_t ntpccls = ( fParamType==kTPCstandalone )?
736 track->GetTPCNclsIter1():track->GetTPCNcls();
737 if (fCutChi2PerClusterTPC)
739 Float_t tpcchi2 = (fParamType==kTPCstandalone)?
740 track->GetTPCchi2Iter1():track->GetTPCchi2();
741 tpcchi2 = (ntpccls>0)?tpcchi2/ntpccls:-FLT_MAX;
742 if (tpcchi2<fMinChi2PerClusterTPC || tpcchi2 >=fMaxChi2PerClusterTPC)
746 if (fCutMinimalTPCdedx)
748 if (track->GetTPCsignal() < fMinimalTPCdedx) pass=kFALSE;
751 if (fCutNClustersTPC)
753 if (ntpccls < fNClustersTPCMin || ntpccls > fNClustersTPCMax) pass=kFALSE;
756 Int_t nitscls = track->GetNcls(0);
757 if (fCutNClustersITS)
759 if (nitscls < fNClustersITSMin || nitscls > fNClustersITSMax) pass=kFALSE;
762 //some stuff is still handled by AliESDtrackCuts class - delegate
763 if (fAliESDtrackCuts)
765 if (!fAliESDtrackCuts->IsSelected(track)) pass=kFALSE;
768 //PID part with pid QA
769 Double_t beta = GetBeta(track);
770 Double_t dedx = Getdedx(track);
773 if (pass) QAbefore(0)->Fill(track->GetP(),beta);
774 if (pass) QAbefore(1)->Fill(pin->GetP(),dedx);
776 if (fCutPID && (fParticleID!=AliPID::kUnknown)) //if kUnknown don't cut on PID
781 if (!PassesTPCpidCut(track)) pass=kFALSE;
784 if (!PassesTPCdedxCut(track)) pass=kFALSE;
787 if (!PassesTOFpidCut(track)) pass=kFALSE;
790 if (!PassesTOFbetaCut(track)) pass=kFALSE;
793 if (!PassesTOFbetaSimpleCut(track)) pass=kFALSE;
796 if (!PassesTPCbayesianCut(track)) pass=kFALSE;
798 // part added by F. Noferini
800 if (!PassesTOFbayesianCut(track)) pass=kFALSE;
802 // end part added by F. Noferini
804 //part added by Natasha
806 if (!PassesNucleiSelection(track)) pass=kFALSE;
808 //end part added by Natasha
811 printf("AliFlowTrackCuts::PassesCuts() this should never be called!\n");
816 if (fCutRejectElectronsWithTPCpid)
818 //reject electrons using standard TPC pid
819 Double_t pidTPC[AliPID::kSPECIES];
820 track->GetTPCpid(pidTPC);
821 if (pidTPC[AliPID::kElectron]<fParticleProbability) pass=kFALSE;
825 if (pass) QAafter(0)->Fill(track->GetP(),beta);
826 if (pass) QAafter(1)->Fill(pin->GetP(),dedx);
828 //end pid part with qa
831 Double_t pt = track->Pt();
832 QAbefore(5)->Fill(pt,dcaxy);
833 QAbefore(6)->Fill(pt,dcaz);
834 if (pass) QAafter(5)->Fill(pt,dcaxy);
835 if (pass) QAafter(6)->Fill(pt,dcaz);
841 //-----------------------------------------------------------------------
842 void AliFlowTrackCuts::HandleVParticle(AliVParticle* track)
844 //handle the general case
853 //-----------------------------------------------------------------------
854 void AliFlowTrackCuts::HandleESDtrack(AliESDtrack* track)
863 if (!track->FillTPCOnlyTrack(fTPCtrack))
871 //recalculate the label and mc particle, they may differ as TPClabel != global label
872 fTrackLabel = (fFakesAreOK)?TMath::Abs(fTrack->GetLabel()):fTrack->GetLabel();
873 if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
874 else fMCparticle=NULL;
882 //-----------------------------------------------------------------------
883 Int_t AliFlowTrackCuts::Count(AliVEvent* event)
885 //calculate the number of track in given event.
886 //if argument is NULL(default) take the event attached
888 Int_t multiplicity = 0;
891 for (Int_t i=0; i<GetNumberOfInputObjects(); i++)
893 if (IsSelected(GetInputObject(i))) multiplicity++;
898 for (Int_t i=0; i<event->GetNumberOfTracks(); i++)
900 if (IsSelected(event->GetTrack(i))) multiplicity++;
906 //-----------------------------------------------------------------------
907 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts()
909 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard vzero flow cuts");
910 cuts->SetParamType(kV0);
911 cuts->SetEtaRange( -10, +10 );
912 cuts->SetPhiMin( 0 );
913 cuts->SetPhiMax( TMath::TwoPi() );
917 //-----------------------------------------------------------------------
918 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardGlobalTrackCuts2010()
921 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard Global tracks");
922 cuts->SetParamType(kGlobal);
923 cuts->SetPtRange(0.2,5.);
924 cuts->SetEtaRange(-0.8,0.8);
925 cuts->SetMinNClustersTPC(70);
926 cuts->SetMinChi2PerClusterTPC(0.1);
927 cuts->SetMaxChi2PerClusterTPC(4.0);
928 cuts->SetMinNClustersITS(2);
929 cuts->SetRequireITSRefit(kTRUE);
930 cuts->SetRequireTPCRefit(kTRUE);
931 cuts->SetMaxDCAToVertexXY(0.3);
932 cuts->SetMaxDCAToVertexZ(0.3);
933 cuts->SetAcceptKinkDaughters(kFALSE);
934 cuts->SetMinimalTPCdedx(10.);
939 //-----------------------------------------------------------------------
940 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardTPCStandaloneTrackCuts2010()
943 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard TPC standalone 2010");
944 cuts->SetParamType(kTPCstandalone);
945 cuts->SetPtRange(0.2,5.);
946 cuts->SetEtaRange(-0.8,0.8);
947 cuts->SetMinNClustersTPC(70);
948 cuts->SetMinChi2PerClusterTPC(0.2);
949 cuts->SetMaxChi2PerClusterTPC(4.0);
950 cuts->SetMaxDCAToVertexXY(3.0);
951 cuts->SetMaxDCAToVertexZ(3.0);
952 cuts->SetDCAToVertex2D(kTRUE);
953 cuts->SetAcceptKinkDaughters(kFALSE);
954 cuts->SetMinimalTPCdedx(10.);
959 //-----------------------------------------------------------------------
960 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardTPCStandaloneTrackCuts()
963 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard TPC standalone");
964 cuts->SetParamType(kTPCstandalone);
965 cuts->SetPtRange(0.2,5.);
966 cuts->SetEtaRange(-0.8,0.8);
967 cuts->SetMinNClustersTPC(70);
968 cuts->SetMinChi2PerClusterTPC(0.2);
969 cuts->SetMaxChi2PerClusterTPC(4.0);
970 cuts->SetMaxDCAToVertexXY(3.0);
971 cuts->SetMaxDCAToVertexZ(3.0);
972 cuts->SetDCAToVertex2D(kTRUE);
973 cuts->SetAcceptKinkDaughters(kFALSE);
974 cuts->SetMinimalTPCdedx(10.);
979 //-----------------------------------------------------------------------
980 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardITSTPCTrackCuts2009(Bool_t selPrimaries)
983 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard global track cuts 2009");
984 delete cuts->fAliESDtrackCuts;
985 cuts->fAliESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(selPrimaries);
986 cuts->SetParamType(kGlobal);
990 //-----------------------------------------------------------------------
991 Bool_t AliFlowTrackCuts::FillFlowTrackGeneric(AliFlowTrack* flowtrack) const
993 //fill a flow track from tracklet,vzero,pmd,...
994 TParticle *tmpTParticle=NULL;
995 AliMCParticle* tmpAliMCParticle=NULL;
999 flowtrack->SetPhi(fTrackPhi);
1000 flowtrack->SetEta(fTrackEta);
1002 case kTrackWithMCkine:
1003 if (!fMCparticle) return kFALSE;
1004 flowtrack->SetPhi( fMCparticle->Phi() );
1005 flowtrack->SetEta( fMCparticle->Eta() );
1006 flowtrack->SetPt( fMCparticle->Pt() );
1008 case kTrackWithMCpt:
1009 if (!fMCparticle) return kFALSE;
1010 flowtrack->SetPhi(fTrackPhi);
1011 flowtrack->SetEta(fTrackEta);
1012 flowtrack->SetPt(fMCparticle->Pt());
1014 case kTrackWithPtFromFirstMother:
1015 if (!fMCparticle) return kFALSE;
1016 flowtrack->SetPhi(fTrackPhi);
1017 flowtrack->SetEta(fTrackEta);
1018 tmpTParticle = fMCparticle->Particle();
1019 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1020 flowtrack->SetPt(tmpAliMCParticle->Pt());
1023 flowtrack->SetPhi(fTrackPhi);
1024 flowtrack->SetEta(fTrackEta);
1027 flowtrack->SetSource(AliFlowTrack::kFromTracklet);
1031 //-----------------------------------------------------------------------
1032 Bool_t AliFlowTrackCuts::FillFlowTrackVParticle(AliFlowTrack* flowtrack) const
1034 //fill flow track from AliVParticle (ESD,AOD,MC)
1035 if (!fTrack) return kFALSE;
1036 TParticle *tmpTParticle=NULL;
1037 AliMCParticle* tmpAliMCParticle=NULL;
1038 AliExternalTrackParam* externalParams=NULL;
1039 AliESDtrack* esdtrack=NULL;
1043 flowtrack->Set(fTrack);
1045 case kTrackWithMCkine:
1046 flowtrack->Set(fMCparticle);
1048 case kTrackWithMCPID:
1049 flowtrack->Set(fTrack);
1050 //flowtrack->setPID(...) from mc, when implemented
1052 case kTrackWithMCpt:
1053 if (!fMCparticle) return kFALSE;
1054 flowtrack->Set(fTrack);
1055 flowtrack->SetPt(fMCparticle->Pt());
1057 case kTrackWithPtFromFirstMother:
1058 if (!fMCparticle) return kFALSE;
1059 flowtrack->Set(fTrack);
1060 tmpTParticle = fMCparticle->Particle();
1061 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1062 flowtrack->SetPt(tmpAliMCParticle->Pt());
1064 case kTrackWithTPCInnerParams:
1065 esdtrack = dynamic_cast<AliESDtrack*>(fTrack);
1066 if (!esdtrack) return kFALSE;
1067 externalParams = const_cast<AliExternalTrackParam*>(esdtrack->GetTPCInnerParam());
1068 if (!externalParams) return kFALSE;
1069 flowtrack->Set(externalParams);
1072 flowtrack->Set(fTrack);
1075 if (fParamType==kMC)
1077 flowtrack->SetSource(AliFlowTrack::kFromMC);
1078 flowtrack->SetID(fTrack->GetLabel());
1080 else if (dynamic_cast<AliESDtrack*>(fTrack))
1082 flowtrack->SetSource(AliFlowTrack::kFromESD);
1083 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1085 else if (dynamic_cast<AliAODTrack*>(fTrack))
1087 flowtrack->SetSource(AliFlowTrack::kFromAOD);
1088 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1090 else if (dynamic_cast<AliMCParticle*>(fTrack))
1092 flowtrack->SetSource(AliFlowTrack::kFromMC);
1093 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1098 //-----------------------------------------------------------------------
1099 Bool_t AliFlowTrackCuts::FillFlowTrack(AliFlowTrack* track) const
1101 //fill a flow track constructed from whatever we applied cuts on
1102 //return true on success
1106 return FillFlowTrackGeneric(track);
1108 return FillFlowTrackGeneric(track);
1110 return FillFlowTrackGeneric(track);
1112 return FillFlowTrackVParticle(track);
1116 //-----------------------------------------------------------------------
1117 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackSPDtracklet() const
1119 //make a flow track from tracklet
1120 AliFlowTrack* flowtrack=NULL;
1121 TParticle *tmpTParticle=NULL;
1122 AliMCParticle* tmpAliMCParticle=NULL;
1126 flowtrack = new AliFlowTrack();
1127 flowtrack->SetPhi(fTrackPhi);
1128 flowtrack->SetEta(fTrackEta);
1130 case kTrackWithMCkine:
1131 if (!fMCparticle) return NULL;
1132 flowtrack = new AliFlowTrack();
1133 flowtrack->SetPhi( fMCparticle->Phi() );
1134 flowtrack->SetEta( fMCparticle->Eta() );
1135 flowtrack->SetPt( fMCparticle->Pt() );
1137 case kTrackWithMCpt:
1138 if (!fMCparticle) return NULL;
1139 flowtrack = new AliFlowTrack();
1140 flowtrack->SetPhi(fTrackPhi);
1141 flowtrack->SetEta(fTrackEta);
1142 flowtrack->SetPt(fMCparticle->Pt());
1144 case kTrackWithPtFromFirstMother:
1145 if (!fMCparticle) return NULL;
1146 flowtrack = new AliFlowTrack();
1147 flowtrack->SetPhi(fTrackPhi);
1148 flowtrack->SetEta(fTrackEta);
1149 tmpTParticle = fMCparticle->Particle();
1150 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1151 flowtrack->SetPt(tmpAliMCParticle->Pt());
1154 flowtrack = new AliFlowTrack();
1155 flowtrack->SetPhi(fTrackPhi);
1156 flowtrack->SetEta(fTrackEta);
1159 flowtrack->SetSource(AliFlowTrack::kFromTracklet);
1163 //-----------------------------------------------------------------------
1164 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackVParticle() const
1166 //make flow track from AliVParticle (ESD,AOD,MC)
1167 if (!fTrack) return NULL;
1168 AliFlowTrack* flowtrack=NULL;
1169 TParticle *tmpTParticle=NULL;
1170 AliMCParticle* tmpAliMCParticle=NULL;
1171 AliExternalTrackParam* externalParams=NULL;
1172 AliESDtrack* esdtrack=NULL;
1176 flowtrack = new AliFlowTrack(fTrack);
1178 case kTrackWithMCkine:
1179 flowtrack = new AliFlowTrack(fMCparticle);
1181 case kTrackWithMCPID:
1182 flowtrack = new AliFlowTrack(fTrack);
1183 //flowtrack->setPID(...) from mc, when implemented
1185 case kTrackWithMCpt:
1186 if (!fMCparticle) return NULL;
1187 flowtrack = new AliFlowTrack(fTrack);
1188 flowtrack->SetPt(fMCparticle->Pt());
1190 case kTrackWithPtFromFirstMother:
1191 if (!fMCparticle) return NULL;
1192 flowtrack = new AliFlowTrack(fTrack);
1193 tmpTParticle = fMCparticle->Particle();
1194 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1195 flowtrack->SetPt(tmpAliMCParticle->Pt());
1197 case kTrackWithTPCInnerParams:
1198 esdtrack = dynamic_cast<AliESDtrack*>(fTrack);
1199 if (!esdtrack) return NULL;
1200 externalParams = const_cast<AliExternalTrackParam*>(esdtrack->GetTPCInnerParam());
1201 if (!externalParams) return NULL;
1202 flowtrack = new AliFlowTrack(externalParams);
1205 flowtrack = new AliFlowTrack(fTrack);
1208 if (fParamType==kMC)
1210 flowtrack->SetSource(AliFlowTrack::kFromMC);
1211 flowtrack->SetID(fTrack->GetLabel());
1213 else if (dynamic_cast<AliESDtrack*>(fTrack))
1215 flowtrack->SetSource(AliFlowTrack::kFromESD);
1216 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1218 else if (dynamic_cast<AliAODTrack*>(fTrack))
1220 flowtrack->SetSource(AliFlowTrack::kFromAOD);
1221 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1223 else if (dynamic_cast<AliMCParticle*>(fTrack))
1225 flowtrack->SetSource(AliFlowTrack::kFromMC);
1226 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1231 //-----------------------------------------------------------------------
1232 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackPMDtrack() const
1234 //make a flow track from PMD track
1235 AliFlowTrack* flowtrack=NULL;
1236 TParticle *tmpTParticle=NULL;
1237 AliMCParticle* tmpAliMCParticle=NULL;
1241 flowtrack = new AliFlowTrack();
1242 flowtrack->SetPhi(fTrackPhi);
1243 flowtrack->SetEta(fTrackEta);
1244 flowtrack->SetWeight(fTrackWeight);
1246 case kTrackWithMCkine:
1247 if (!fMCparticle) return NULL;
1248 flowtrack = new AliFlowTrack();
1249 flowtrack->SetPhi( fMCparticle->Phi() );
1250 flowtrack->SetEta( fMCparticle->Eta() );
1251 flowtrack->SetWeight(fTrackWeight);
1252 flowtrack->SetPt( fMCparticle->Pt() );
1254 case kTrackWithMCpt:
1255 if (!fMCparticle) return NULL;
1256 flowtrack = new AliFlowTrack();
1257 flowtrack->SetPhi(fTrackPhi);
1258 flowtrack->SetEta(fTrackEta);
1259 flowtrack->SetWeight(fTrackWeight);
1260 flowtrack->SetPt(fMCparticle->Pt());
1262 case kTrackWithPtFromFirstMother:
1263 if (!fMCparticle) return NULL;
1264 flowtrack = new AliFlowTrack();
1265 flowtrack->SetPhi(fTrackPhi);
1266 flowtrack->SetEta(fTrackEta);
1267 flowtrack->SetWeight(fTrackWeight);
1268 tmpTParticle = fMCparticle->Particle();
1269 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1270 flowtrack->SetPt(tmpAliMCParticle->Pt());
1273 flowtrack = new AliFlowTrack();
1274 flowtrack->SetPhi(fTrackPhi);
1275 flowtrack->SetEta(fTrackEta);
1276 flowtrack->SetWeight(fTrackWeight);
1280 flowtrack->SetSource(AliFlowTrack::kFromPMD);
1284 //-----------------------------------------------------------------------
1285 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackV0() const
1287 //make a flow track from V0
1288 AliFlowTrack* flowtrack=NULL;
1289 TParticle *tmpTParticle=NULL;
1290 AliMCParticle* tmpAliMCParticle=NULL;
1294 flowtrack = new AliFlowTrack();
1295 flowtrack->SetPhi(fTrackPhi);
1296 flowtrack->SetEta(fTrackEta);
1297 flowtrack->SetWeight(fTrackWeight);
1299 case kTrackWithMCkine:
1300 if (!fMCparticle) return NULL;
1301 flowtrack = new AliFlowTrack();
1302 flowtrack->SetPhi( fMCparticle->Phi() );
1303 flowtrack->SetEta( fMCparticle->Eta() );
1304 flowtrack->SetWeight(fTrackWeight);
1305 flowtrack->SetPt( fMCparticle->Pt() );
1307 case kTrackWithMCpt:
1308 if (!fMCparticle) return NULL;
1309 flowtrack = new AliFlowTrack();
1310 flowtrack->SetPhi(fTrackPhi);
1311 flowtrack->SetEta(fTrackEta);
1312 flowtrack->SetWeight(fTrackWeight);
1313 flowtrack->SetPt(fMCparticle->Pt());
1315 case kTrackWithPtFromFirstMother:
1316 if (!fMCparticle) return NULL;
1317 flowtrack = new AliFlowTrack();
1318 flowtrack->SetPhi(fTrackPhi);
1319 flowtrack->SetEta(fTrackEta);
1320 flowtrack->SetWeight(fTrackWeight);
1321 tmpTParticle = fMCparticle->Particle();
1322 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1323 flowtrack->SetPt(tmpAliMCParticle->Pt());
1326 flowtrack = new AliFlowTrack();
1327 flowtrack->SetPhi(fTrackPhi);
1328 flowtrack->SetEta(fTrackEta);
1329 flowtrack->SetWeight(fTrackWeight);
1333 flowtrack->SetSource(AliFlowTrack::kFromV0);
1337 //-----------------------------------------------------------------------
1338 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrack() const
1340 //get a flow track constructed from whatever we applied cuts on
1341 //caller is resposible for deletion
1342 //if construction fails return NULL
1343 //TODO: for tracklets, PMD and V0 we probably need just one method,
1344 //something like MakeFlowTrackGeneric(), wait with this until
1345 //requirements quirks are known.
1349 return MakeFlowTrackSPDtracklet();
1351 return MakeFlowTrackPMDtrack();
1353 return MakeFlowTrackV0();
1355 return MakeFlowTrackVParticle();
1359 //-----------------------------------------------------------------------
1360 Bool_t AliFlowTrackCuts::IsPhysicalPrimary() const
1362 //check if current particle is a physical primary
1363 if (!fMCevent) return kFALSE;
1364 if (fTrackLabel<0) return kFALSE;
1365 return IsPhysicalPrimary(fMCevent, fTrackLabel, fRequireTransportBitForPrimaries);
1368 //-----------------------------------------------------------------------
1369 Bool_t AliFlowTrackCuts::IsPhysicalPrimary(AliMCEvent* mcEvent, Int_t label, Bool_t requiretransported)
1371 //check if current particle is a physical primary
1372 Bool_t physprim=mcEvent->IsPhysicalPrimary(label);
1373 AliMCParticle* track = static_cast<AliMCParticle*>(mcEvent->GetTrack(label));
1374 if (!track) return kFALSE;
1375 TParticle* particle = track->Particle();
1376 Bool_t transported = particle->TestBit(kTransportBit);
1377 //printf("label: %i prim: %s, transp: %s, pass: %s\n",label, (physprim)?"YES":"NO ",(transported)?"YES":"NO ",
1378 //(physprim && (transported || !requiretransported))?"YES":"NO" );
1379 return (physprim && (transported || !requiretransported));
1382 //-----------------------------------------------------------------------
1383 void AliFlowTrackCuts::DefineHistograms()
1385 //define qa histograms
1388 const Int_t kNbinsP=60;
1389 Double_t binsP[kNbinsP+1];
1391 for(int i=1; i<kNbinsP+1; i++)
1393 if(binsP[i-1]+0.05<1.01)
1394 binsP[i]=binsP[i-1]+0.05;
1396 binsP[i]=binsP[i-1]+0.1;
1399 const Int_t nBinsDCA=1000;
1400 Double_t binsDCA[nBinsDCA+1];
1401 for(int i=0; i<nBinsDCA+1; i++) {binsDCA[i]=0.01*i-5.;}
1402 //for(int i=1; i<41; i++) {binsDCA[i+100]=0.1*i+1.0;}
1404 Bool_t adddirstatus = TH1::AddDirectoryStatus();
1405 TH1::AddDirectory(kFALSE);
1406 fQA=new TList(); fQA->SetOwner();
1407 fQA->SetName(Form("%s QA",GetName()));
1408 TList* before = new TList(); before->SetOwner();
1409 before->SetName("before");
1410 TList* after = new TList(); after->SetOwner();
1411 after->SetName("after");
1414 before->Add(new TH2F("TOFbeta",";p [GeV/c];#beta",kNbinsP,binsP,1000,0.4,1.1)); //0
1415 after->Add(new TH2F("TOFbeta",";p [GeV/c];#beta",kNbinsP,binsP,1000,0.4,1.1)); //0
1416 before->Add(new TH2F("TPCdedx",";p [GeV/c];dEdx",kNbinsP,binsP,500,0,500)); //1
1417 after->Add(new TH2F("TPCdedx",";p [GeV/c];dEdx",kNbinsP,binsP,500,0,500)); //1
1418 before->Add(new TH2F("MC pid",";p[GeV/c];species",kNbinsP,binsP,10,-5, 5)); //2
1419 after->Add(new TH2F("MC pid",";p[GeV/c];species",kNbinsP,binsP,10,-5, 5)); //2
1420 before->Add(new TH2F("MC primary",";p[GeV/c];primary",kNbinsP,binsP,2,-1,1)); //3
1421 after->Add(new TH2F("MC primary",";p[GeV/c];primary",kNbinsP,binsP,2,-1,1)); //3
1422 //production process
1423 TH2F* hb = new TH2F("MC production process",";p[GeV/c];",kNbinsP,binsP,kMaxMCProcess,
1424 -0.5, kMaxMCProcess-0.5);
1425 TH2F* ha = new TH2F("MC production process",";p[GeV/c];",kNbinsP,binsP,kMaxMCProcess,
1426 -0.5, kMaxMCProcess-0.5);
1427 TAxis* axis = hb->GetYaxis();
1428 for (Int_t i=0; i<kMaxMCProcess; i++)
1430 axis->SetBinLabel(i+1,TMCProcessName[i]);
1432 axis = ha->GetYaxis();
1433 for (Int_t i=0; i<kMaxMCProcess; i++)
1435 axis->SetBinLabel(i+1,TMCProcessName[i]);
1437 before->Add(hb); //4
1440 before->Add(new TH2F("DCAxy",";p_{t}[GeV/c];DCAxy[cm]", 100, 0., 10., nBinsDCA, binsDCA));//5
1441 after->Add(new TH2F("DCAxy",";p_{t}[GeV/c];DCAxy[cm]", 100, 0., 10., nBinsDCA, binsDCA));//5
1442 before->Add(new TH2F("DCAz",";p_{t}[GeV/c];DCAz[cm]", 100, 0., 10., nBinsDCA, binsDCA));//6
1443 after->Add(new TH2F("DCAz",";p_{t}[GeV/c];DCAz[cm]", 100, 0., 10., nBinsDCA, binsDCA));//6
1445 hb = new TH2F("MC first mother",";p[GeV/c];",kNbinsP,binsP,4,0.,4.);
1446 ha = new TH2F("MC first mother",";p[GeV/c];",kNbinsP,binsP,4,0.,4.);
1447 hb->GetYaxis()->SetBinLabel(1,"#Lambda");
1448 ha->GetYaxis()->SetBinLabel(1,"#Lambda");
1449 hb->GetYaxis()->SetBinLabel(2,"#Sigma");
1450 ha->GetYaxis()->SetBinLabel(2,"#Sigma");
1451 hb->GetYaxis()->SetBinLabel(3,"#Xi");
1452 ha->GetYaxis()->SetBinLabel(3,"#Xi");
1453 hb->GetYaxis()->SetBinLabel(4,"#Omega");
1454 ha->GetYaxis()->SetBinLabel(4,"#Omega");
1458 TH1::AddDirectory(adddirstatus);
1461 //-----------------------------------------------------------------------
1462 Int_t AliFlowTrackCuts::GetNumberOfInputObjects() const
1464 //get the number of tracks in the input event according source
1465 //selection (ESD tracks, tracklets, MC particles etc.)
1466 AliESDEvent* esd=NULL;
1470 esd = dynamic_cast<AliESDEvent*>(fEvent);
1472 return esd->GetMultiplicity()->GetNumberOfTracklets();
1474 if (!fMCevent) return 0;
1475 return fMCevent->GetNumberOfTracks();
1477 esd = dynamic_cast<AliESDEvent*>(fEvent);
1479 return esd->GetNumberOfPmdTracks();
1481 return fgkNumberOfV0tracks;
1483 if (!fEvent) return 0;
1484 return fEvent->GetNumberOfTracks();
1489 //-----------------------------------------------------------------------
1490 TObject* AliFlowTrackCuts::GetInputObject(Int_t i)
1492 //get the input object according the data source selection:
1493 //(esd tracks, traclets, mc particles,etc...)
1494 AliESDEvent* esd=NULL;
1498 esd = dynamic_cast<AliESDEvent*>(fEvent);
1499 if (!esd) return NULL;
1500 return const_cast<AliMultiplicity*>(esd->GetMultiplicity());
1502 if (!fMCevent) return NULL;
1503 return fMCevent->GetTrack(i);
1505 esd = dynamic_cast<AliESDEvent*>(fEvent);
1506 if (!esd) return NULL;
1507 return esd->GetPmdTrack(i);
1509 esd = dynamic_cast<AliESDEvent*>(fEvent);
1510 if (!esd) //contributed by G.Ortona
1512 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(fEvent);
1513 if(!aod)return NULL;
1514 return aod->GetVZEROData();
1516 return esd->GetVZEROData();
1518 if (!fEvent) return NULL;
1519 return fEvent->GetTrack(i);
1523 //-----------------------------------------------------------------------
1524 void AliFlowTrackCuts::Clear(Option_t*)
1536 //-----------------------------------------------------------------------
1537 Bool_t AliFlowTrackCuts::PassesTOFbetaSimpleCut(const AliESDtrack* track )
1539 //check if passes PID cut using timing in TOF
1540 Bool_t goodtrack = (track->GetStatus() & AliESDtrack::kTOFpid) &&
1541 (track->GetTOFsignal() > 12000) &&
1542 (track->GetTOFsignal() < 100000) &&
1543 (track->GetIntegratedLength() > 365);
1545 if (!fAllowTOFmismatchFlag) {if ((track->GetStatus() & AliESDtrack::kTOFmismatch)) return kFALSE;}
1547 Bool_t statusMatchingHard = TPCTOFagree(track);
1548 if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
1551 if (!goodtrack) return kFALSE;
1553 const Float_t c = 2.99792457999999984e-02;
1554 Float_t p = track->GetP();
1555 Float_t l = track->GetIntegratedLength();
1556 Float_t trackT0 = fESDpid.GetTOFResponse().GetStartTime(p);
1557 Float_t timeTOF = track->GetTOFsignal()- trackT0;
1558 Float_t beta = l/timeTOF/c;
1559 Double_t integratedTimes[5] = {-1.0,-1.0,-1.0,-1.0,-1.0};
1560 track->GetIntegratedTimes(integratedTimes);
1561 Float_t betaHypothesis[5] = {0.0,0.0,0.0,0.0,0.0};
1562 Float_t s[5] = {0.0,0.0,0.0,0.0,0.0};
1563 for (Int_t i=0;i<5;i++)
1565 betaHypothesis[i] = l/integratedTimes[i]/c;
1566 s[i] = beta-betaHypothesis[i];
1569 switch (fParticleID)
1572 return ( (s[2]<0.015) && (s[2]>-0.015) &&
1576 return ( (s[3]<0.015) && (s[3]>-0.015) &&
1579 case AliPID::kProton:
1580 return ( (s[4]<0.015) && (s[4]>-0.015) &&
1589 //-----------------------------------------------------------------------
1590 Float_t AliFlowTrackCuts::GetBeta(const AliESDtrack* track)
1593 const Float_t c = 2.99792457999999984e-02;
1594 Float_t p = track->GetP();
1595 Float_t l = track->GetIntegratedLength();
1596 Float_t trackT0 = fESDpid.GetTOFResponse().GetStartTime(p);
1597 Float_t timeTOF = track->GetTOFsignal()- trackT0;
1601 //-----------------------------------------------------------------------
1602 Bool_t AliFlowTrackCuts::PassesTOFbetaCut(const AliESDtrack* track )
1606 //printf("no TOFpidCuts\n");
1610 //check if passes PID cut using timing in TOF
1611 Bool_t goodtrack = (track->GetStatus() & AliESDtrack::kTOFpid) &&
1612 (track->GetTOFsignal() > 12000) &&
1613 (track->GetTOFsignal() < 100000) &&
1614 (track->GetIntegratedLength() > 365);
1616 if (!fAllowTOFmismatchFlag) {if ((track->GetStatus() & AliESDtrack::kTOFmismatch)) return kFALSE;}
1618 Bool_t statusMatchingHard = TPCTOFagree(track);
1619 if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
1622 if (!goodtrack) return kFALSE;
1624 Float_t beta = GetBeta(track);
1626 Double_t integratedTimes[5] = {-1.0,-1.0,-1.0,-1.0,-1.0};
1627 track->GetIntegratedTimes(integratedTimes);
1629 //construct the pid index because it's not AliPID::EParticleType
1631 switch (fParticleID)
1639 case AliPID::kProton:
1647 const Float_t c = 2.99792457999999984e-02;
1648 Float_t l = track->GetIntegratedLength();
1649 Float_t p = track->GetP();
1650 Float_t betahypothesis = l/integratedTimes[pid]/c;
1651 Float_t betadiff = beta-betahypothesis;
1653 Float_t* arr = fTOFpidCuts->GetMatrixArray();
1654 Int_t col = TMath::BinarySearch(fTOFpidCuts->GetNcols(),arr,static_cast<Float_t>(p));
1655 if (col<0) return kFALSE;
1656 Float_t min = (*fTOFpidCuts)(1,col);
1657 Float_t max = (*fTOFpidCuts)(2,col);
1659 Bool_t pass = (betadiff>min && betadiff<max);
1664 //-----------------------------------------------------------------------
1665 Bool_t AliFlowTrackCuts::PassesTOFpidCut(const AliESDtrack* track) const
1667 //check if passes PID cut using default TOF pid
1668 Double_t pidTOF[AliPID::kSPECIES];
1669 track->GetTOFpid(pidTOF);
1670 if (pidTOF[fParticleID]>=fParticleProbability) return kTRUE;
1674 //-----------------------------------------------------------------------
1675 Bool_t AliFlowTrackCuts::PassesTPCpidCut(const AliESDtrack* track) const
1677 //check if passes PID cut using default TPC pid
1678 Double_t pidTPC[AliPID::kSPECIES];
1679 track->GetTPCpid(pidTPC);
1680 Double_t probablity = 0.;
1681 switch (fParticleID)
1684 probablity = pidTPC[AliPID::kPion] + pidTPC[AliPID::kMuon];
1687 probablity = pidTPC[fParticleID];
1689 if (probablity >= fParticleProbability) return kTRUE;
1693 //-----------------------------------------------------------------------
1694 Float_t AliFlowTrackCuts::Getdedx(const AliESDtrack* track)
1697 return track->GetTPCsignal();
1700 //-----------------------------------------------------------------------
1701 Bool_t AliFlowTrackCuts::PassesTPCdedxCut(const AliESDtrack* track)
1703 //check if passes PID cut using dedx signal in the TPC
1706 //printf("no TPCpidCuts\n");
1710 const AliExternalTrackParam* tpcparam = track->GetInnerParam(); //tpc only params at the inner wall
1711 if (!tpcparam) return kFALSE;
1712 Double_t p = tpcparam->GetP();
1713 Float_t sigExp = fESDpid.GetTPCResponse().GetExpectedSignal(p, fParticleID);
1714 Float_t sigTPC = track->GetTPCsignal();
1715 Float_t s = (sigTPC-sigExp)/sigExp;
1717 Float_t* arr = fTPCpidCuts->GetMatrixArray();
1718 Int_t arrSize = fTPCpidCuts->GetNcols();
1719 Int_t col = TMath::BinarySearch( arrSize, arr, static_cast<Float_t>(p));
1720 if (col<0) return kFALSE;
1721 Float_t min = (*fTPCpidCuts)(1,col);
1722 Float_t max = (*fTPCpidCuts)(2,col);
1724 //printf("------------TPC pid cut %s\n",(s>min && s<max)?"PASS":"FAIL");
1725 return (s>min && s<max);
1728 //-----------------------------------------------------------------------
1729 void AliFlowTrackCuts::InitPIDcuts()
1731 //init matrices with PID cuts
1735 if (fParticleID==AliPID::kPion)
1737 t = new TMatrixF(3,15);
1738 (*t)(0,0) = 0.20; (*t)(1,0) = -0.4; (*t)(2,0) = 0.0;
1739 (*t)(0,1) = 0.25; (*t)(1,1) = -0.4; (*t)(2,1) = 0.1;
1740 (*t)(0,2) = 0.30; (*t)(1,2) = -0.4; (*t)(2,2) = 0.2;
1741 (*t)(0,3) = 0.35; (*t)(1,3) = -0.4; (*t)(2,3) = 0.2;
1742 (*t)(0,4) = 0.40; (*t)(1,4) = -0.4; (*t)(2,4) = 0.3;
1743 (*t)(0,5) = 0.45; (*t)(1,5) = -0.4; (*t)(2,5) = 0.3;
1744 (*t)(0,6) = 0.50; (*t)(1,6) = -0.4; (*t)(2,6) = 0.25;
1745 (*t)(0,7) = 0.55; (*t)(1,7) = -0.4; (*t)(2,7) = 0.15;
1746 (*t)(0,8) = 0.60; (*t)(1,8) = -0.4; (*t)(2,8) = 0.1;
1747 (*t)(0,9) = 0.65; (*t)(1,9) = -0.4; (*t)(2,9) = 0.05;
1748 (*t)(0,10) = 0.70; (*t)(1,10) = -0.4; (*t)(2,10) = 0;
1749 (*t)(0,11) = 0.75; (*t)(1,11) = -0.4; (*t)(2,11) = 0;
1750 (*t)(0,12) = 0.80; (*t)(1,12) = -0.4; (*t)(2,12) = -0.05;
1751 (*t)(0,13) = 0.85; (*t)(1,13) = -0.4; (*t)(2,13) = -0.1;
1752 (*t)(0,14) = 0.90; (*t)(1,14) = 0; (*t)(2,14) = 0;
1755 if (fParticleID==AliPID::kKaon)
1757 t = new TMatrixF(3,12);
1758 (*t)(0,0) = 0.20; (*t)(1,0) = -0.2; (*t)(2,0) = 0.2;
1759 (*t)(0,1) = 0.25; (*t)(1,1) = -0.2; (*t)(2,1) = 0.2;
1760 (*t)(0,2) = 0.30; (*t)(1,2) = -0.2; (*t)(2,2) = 0.2;
1761 (*t)(0,3) = 0.35; (*t)(1,3) = -0.2; (*t)(2,3) = 0.2;
1762 (*t)(0,4) = 0.40; (*t)(1,4) = -0.1; (*t)(2,4) = 0.2;
1763 (*t)(0,5) = 0.45; (*t)(1,5) = -0.1; (*t)(2,5) = 0.2;
1764 (*t)(0,6) = 0.50; (*t)(1,6) =-0.05; (*t)(2,6) = 0.2;
1765 (*t)(0,7) = 0.55; (*t)(1,7) = -0.1; (*t)(2,7) = 0.1;
1766 (*t)(0,8) = 0.60; (*t)(1,8) =-0.05; (*t)(2,8) = 0.1;
1767 (*t)(0,9) = 0.65; (*t)(1,9) = 0; (*t)(2,9) = 0.15;
1768 (*t)(0,10) = 0.70; (*t)(1,10) = 0.05; (*t)(2,10) = 0.2;
1769 (*t)(0,11) = 0.75; (*t)(1,11) = 0; (*t)(2,11) = 0;
1772 if (fParticleID==AliPID::kProton)
1774 t = new TMatrixF(3,9);
1775 (*t)(0,0) = 0.20; (*t)(1,0) = -0.1; (*t)(2,0) = 0.1;
1776 (*t)(0,1) = 0.25; (*t)(1,1) = -0.2; (*t)(2,1) = 0.2;
1777 (*t)(0,2) = 0.80; (*t)(1,2) = -0.1; (*t)(2,2) = 0.2;
1778 (*t)(0,3) = 0.85; (*t)(1,3) =-0.05; (*t)(2,3) = 0.2;
1779 (*t)(0,4) = 0.90; (*t)(1,4) =-0.05; (*t)(2,4) = 0.25;
1780 (*t)(0,5) = 0.95; (*t)(1,5) =-0.05; (*t)(2,5) = 0.25;
1781 (*t)(0,6) = 1.00; (*t)(1,6) = -0.1; (*t)(2,6) = 0.25;
1782 (*t)(0,7) = 1.10; (*t)(1,7) =-0.05; (*t)(2,7) = 0.3;
1783 (*t)(0,8) = 1.20; (*t)(1,8) = 0; (*t)(2,8) = 0;
1791 if (fParticleID==AliPID::kPion)
1793 //TOF pions, 0.9 purity
1794 t = new TMatrixF(3,61);
1795 (*t)(0,0) = 0.000; (*t)(1,0) = 0.000; (*t)(2,0) = 0.000;
1796 (*t)(0,1) = 0.050; (*t)(1,1) = 0.000; (*t)(2,1) = 0.000;
1797 (*t)(0,2) = 0.100; (*t)(1,2) = 0.000; (*t)(2,2) = 0.000;
1798 (*t)(0,3) = 0.150; (*t)(1,3) = 0.000; (*t)(2,3) = 0.000;
1799 (*t)(0,4) = 0.200; (*t)(1,4) = -0.030; (*t)(2,4) = 0.030;
1800 (*t)(0,5) = 0.250; (*t)(1,5) = -0.036; (*t)(2,5) = 0.032;
1801 (*t)(0,6) = 0.300; (*t)(1,6) = -0.038; (*t)(2,6) = 0.032;
1802 (*t)(0,7) = 0.350; (*t)(1,7) = -0.034; (*t)(2,7) = 0.032;
1803 (*t)(0,8) = 0.400; (*t)(1,8) = -0.032; (*t)(2,8) = 0.020;
1804 (*t)(0,9) = 0.450; (*t)(1,9) = -0.030; (*t)(2,9) = 0.020;
1805 (*t)(0,10) = 0.500; (*t)(1,10) = -0.030; (*t)(2,10) = 0.020;
1806 (*t)(0,11) = 0.550; (*t)(1,11) = -0.030; (*t)(2,11) = 0.020;
1807 (*t)(0,12) = 0.600; (*t)(1,12) = -0.030; (*t)(2,12) = 0.020;
1808 (*t)(0,13) = 0.650; (*t)(1,13) = -0.030; (*t)(2,13) = 0.020;
1809 (*t)(0,14) = 0.700; (*t)(1,14) = -0.030; (*t)(2,14) = 0.020;
1810 (*t)(0,15) = 0.750; (*t)(1,15) = -0.030; (*t)(2,15) = 0.020;
1811 (*t)(0,16) = 0.800; (*t)(1,16) = -0.030; (*t)(2,16) = 0.020;
1812 (*t)(0,17) = 0.850; (*t)(1,17) = -0.030; (*t)(2,17) = 0.020;
1813 (*t)(0,18) = 0.900; (*t)(1,18) = -0.030; (*t)(2,18) = 0.020;
1814 (*t)(0,19) = 0.950; (*t)(1,19) = -0.028; (*t)(2,19) = 0.028;
1815 (*t)(0,20) = 1.000; (*t)(1,20) = -0.028; (*t)(2,20) = 0.028;
1816 (*t)(0,21) = 1.100; (*t)(1,21) = -0.028; (*t)(2,21) = 0.028;
1817 (*t)(0,22) = 1.200; (*t)(1,22) = -0.026; (*t)(2,22) = 0.028;
1818 (*t)(0,23) = 1.300; (*t)(1,23) = -0.024; (*t)(2,23) = 0.028;
1819 (*t)(0,24) = 1.400; (*t)(1,24) = -0.020; (*t)(2,24) = 0.028;
1820 (*t)(0,25) = 1.500; (*t)(1,25) = -0.018; (*t)(2,25) = 0.028;
1821 (*t)(0,26) = 1.600; (*t)(1,26) = -0.016; (*t)(2,26) = 0.028;
1822 (*t)(0,27) = 1.700; (*t)(1,27) = -0.014; (*t)(2,27) = 0.028;
1823 (*t)(0,28) = 1.800; (*t)(1,28) = -0.012; (*t)(2,28) = 0.026;
1824 (*t)(0,29) = 1.900; (*t)(1,29) = -0.010; (*t)(2,29) = 0.026;
1825 (*t)(0,30) = 2.000; (*t)(1,30) = -0.008; (*t)(2,30) = 0.026;
1826 (*t)(0,31) = 2.100; (*t)(1,31) = -0.008; (*t)(2,31) = 0.024;
1827 (*t)(0,32) = 2.200; (*t)(1,32) = -0.006; (*t)(2,32) = 0.024;
1828 (*t)(0,33) = 2.300; (*t)(1,33) = -0.004; (*t)(2,33) = 0.024;
1829 (*t)(0,34) = 2.400; (*t)(1,34) = -0.004; (*t)(2,34) = 0.024;
1830 (*t)(0,35) = 2.500; (*t)(1,35) = -0.002; (*t)(2,35) = 0.024;
1831 (*t)(0,36) = 2.600; (*t)(1,36) = -0.002; (*t)(2,36) = 0.024;
1832 (*t)(0,37) = 2.700; (*t)(1,37) = 0.000; (*t)(2,37) = 0.024;
1833 (*t)(0,38) = 2.800; (*t)(1,38) = 0.000; (*t)(2,38) = 0.026;
1834 (*t)(0,39) = 2.900; (*t)(1,39) = 0.000; (*t)(2,39) = 0.024;
1835 (*t)(0,40) = 3.000; (*t)(1,40) = 0.002; (*t)(2,40) = 0.026;
1836 (*t)(0,41) = 3.100; (*t)(1,41) = 0.002; (*t)(2,41) = 0.026;
1837 (*t)(0,42) = 3.200; (*t)(1,42) = 0.002; (*t)(2,42) = 0.026;
1838 (*t)(0,43) = 3.300; (*t)(1,43) = 0.002; (*t)(2,43) = 0.026;
1839 (*t)(0,44) = 3.400; (*t)(1,44) = 0.002; (*t)(2,44) = 0.026;
1840 (*t)(0,45) = 3.500; (*t)(1,45) = 0.002; (*t)(2,45) = 0.026;
1841 (*t)(0,46) = 3.600; (*t)(1,46) = 0.002; (*t)(2,46) = 0.026;
1842 (*t)(0,47) = 3.700; (*t)(1,47) = 0.002; (*t)(2,47) = 0.026;
1843 (*t)(0,48) = 3.800; (*t)(1,48) = 0.002; (*t)(2,48) = 0.026;
1844 (*t)(0,49) = 3.900; (*t)(1,49) = 0.004; (*t)(2,49) = 0.024;
1845 (*t)(0,50) = 4.000; (*t)(1,50) = 0.004; (*t)(2,50) = 0.026;
1846 (*t)(0,51) = 4.100; (*t)(1,51) = 0.004; (*t)(2,51) = 0.026;
1847 (*t)(0,52) = 4.200; (*t)(1,52) = 0.004; (*t)(2,52) = 0.024;
1848 (*t)(0,53) = 4.300; (*t)(1,53) = 0.006; (*t)(2,53) = 0.024;
1849 (*t)(0,54) = 4.400; (*t)(1,54) = 0.000; (*t)(2,54) = 0.000;
1850 (*t)(0,55) = 4.500; (*t)(1,55) = 0.000; (*t)(2,55) = 0.000;
1851 (*t)(0,56) = 4.600; (*t)(1,56) = 0.000; (*t)(2,56) = 0.000;
1852 (*t)(0,57) = 4.700; (*t)(1,57) = 0.000; (*t)(2,57) = 0.000;
1853 (*t)(0,58) = 4.800; (*t)(1,58) = 0.000; (*t)(2,58) = 0.000;
1854 (*t)(0,59) = 4.900; (*t)(1,59) = 0.000; (*t)(2,59) = 0.000;
1855 (*t)(0,60) = 5.900; (*t)(1,60) = 0.000; (*t)(2,60) = 0.000;
1858 if (fParticleID==AliPID::kProton)
1860 //TOF protons, 0.9 purity
1861 t = new TMatrixF(3,61);
1862 (*t)(0,0) = 0.000; (*t)(1,0) = 0.000; (*t)(2,0) = 0.000;
1863 (*t)(0,1) = 0.050; (*t)(1,1) = 0.000; (*t)(2,1) = 0.000;
1864 (*t)(0,2) = 0.100; (*t)(1,2) = 0.000; (*t)(2,2) = 0.000;
1865 (*t)(0,3) = 0.150; (*t)(1,3) = 0.000; (*t)(2,3) = 0.000;
1866 (*t)(0,4) = 0.200; (*t)(1,4) = -0.07; (*t)(2,4) = 0.07;
1867 (*t)(0,5) = 0.200; (*t)(1,5) = -0.07; (*t)(2,5) = 0.07;
1868 (*t)(0,6) = 0.200; (*t)(1,6) = -0.07; (*t)(2,6) = 0.07;
1869 (*t)(0,7) = 0.200; (*t)(1,7) = -0.07; (*t)(2,7) = 0.07;
1870 (*t)(0,8) = 0.200; (*t)(1,8) = -0.07; (*t)(2,8) = 0.07;
1871 (*t)(0,9) = 0.200; (*t)(1,9) = -0.07; (*t)(2,9) = 0.07;
1872 (*t)(0,10) = 0.200; (*t)(1,10) = -0.07; (*t)(2,10) = 0.07;
1873 (*t)(0,11) = 0.200; (*t)(1,11) = -0.07; (*t)(2,11) = 0.07;
1874 (*t)(0,12) = 0.200; (*t)(1,12) = -0.07; (*t)(2,12) = 0.07;
1875 (*t)(0,13) = 0.200; (*t)(1,13) = -0.07; (*t)(2,13) = 0.07;
1876 (*t)(0,14) = 0.200; (*t)(1,14) = -0.07; (*t)(2,14) = 0.07;
1877 (*t)(0,15) = 0.200; (*t)(1,15) = -0.07; (*t)(2,15) = 0.07;
1878 (*t)(0,16) = 0.200; (*t)(1,16) = -0.07; (*t)(2,16) = 0.07;
1879 (*t)(0,17) = 0.850; (*t)(1,17) = -0.070; (*t)(2,17) = 0.070;
1880 (*t)(0,18) = 0.900; (*t)(1,18) = -0.072; (*t)(2,18) = 0.072;
1881 (*t)(0,19) = 0.950; (*t)(1,19) = -0.072; (*t)(2,19) = 0.072;
1882 (*t)(0,20) = 1.000; (*t)(1,20) = -0.074; (*t)(2,20) = 0.074;
1883 (*t)(0,21) = 1.100; (*t)(1,21) = -0.032; (*t)(2,21) = 0.032;
1884 (*t)(0,22) = 1.200; (*t)(1,22) = -0.026; (*t)(2,22) = 0.026;
1885 (*t)(0,23) = 1.300; (*t)(1,23) = -0.026; (*t)(2,23) = 0.026;
1886 (*t)(0,24) = 1.400; (*t)(1,24) = -0.024; (*t)(2,24) = 0.024;
1887 (*t)(0,25) = 1.500; (*t)(1,25) = -0.024; (*t)(2,25) = 0.024;
1888 (*t)(0,26) = 1.600; (*t)(1,26) = -0.026; (*t)(2,26) = 0.026;
1889 (*t)(0,27) = 1.700; (*t)(1,27) = -0.026; (*t)(2,27) = 0.026;
1890 (*t)(0,28) = 1.800; (*t)(1,28) = -0.026; (*t)(2,28) = 0.026;
1891 (*t)(0,29) = 1.900; (*t)(1,29) = -0.026; (*t)(2,29) = 0.026;
1892 (*t)(0,30) = 2.000; (*t)(1,30) = -0.026; (*t)(2,30) = 0.026;
1893 (*t)(0,31) = 2.100; (*t)(1,31) = -0.026; (*t)(2,31) = 0.026;
1894 (*t)(0,32) = 2.200; (*t)(1,32) = -0.026; (*t)(2,32) = 0.024;
1895 (*t)(0,33) = 2.300; (*t)(1,33) = -0.028; (*t)(2,33) = 0.022;
1896 (*t)(0,34) = 2.400; (*t)(1,34) = -0.028; (*t)(2,34) = 0.020;
1897 (*t)(0,35) = 2.500; (*t)(1,35) = -0.028; (*t)(2,35) = 0.018;
1898 (*t)(0,36) = 2.600; (*t)(1,36) = -0.028; (*t)(2,36) = 0.016;
1899 (*t)(0,37) = 2.700; (*t)(1,37) = -0.028; (*t)(2,37) = 0.016;
1900 (*t)(0,38) = 2.800; (*t)(1,38) = -0.030; (*t)(2,38) = 0.014;
1901 (*t)(0,39) = 2.900; (*t)(1,39) = -0.030; (*t)(2,39) = 0.012;
1902 (*t)(0,40) = 3.000; (*t)(1,40) = -0.030; (*t)(2,40) = 0.012;
1903 (*t)(0,41) = 3.100; (*t)(1,41) = -0.030; (*t)(2,41) = 0.010;
1904 (*t)(0,42) = 3.200; (*t)(1,42) = -0.030; (*t)(2,42) = 0.010;
1905 (*t)(0,43) = 3.300; (*t)(1,43) = -0.030; (*t)(2,43) = 0.010;
1906 (*t)(0,44) = 3.400; (*t)(1,44) = -0.030; (*t)(2,44) = 0.008;
1907 (*t)(0,45) = 3.500; (*t)(1,45) = -0.030; (*t)(2,45) = 0.008;
1908 (*t)(0,46) = 3.600; (*t)(1,46) = -0.030; (*t)(2,46) = 0.008;
1909 (*t)(0,47) = 3.700; (*t)(1,47) = -0.030; (*t)(2,47) = 0.006;
1910 (*t)(0,48) = 3.800; (*t)(1,48) = -0.030; (*t)(2,48) = 0.006;
1911 (*t)(0,49) = 3.900; (*t)(1,49) = -0.030; (*t)(2,49) = 0.006;
1912 (*t)(0,50) = 4.000; (*t)(1,50) = -0.028; (*t)(2,50) = 0.004;
1913 (*t)(0,51) = 4.100; (*t)(1,51) = -0.030; (*t)(2,51) = 0.004;
1914 (*t)(0,52) = 4.200; (*t)(1,52) = -0.030; (*t)(2,52) = 0.004;
1915 (*t)(0,53) = 4.300; (*t)(1,53) = -0.028; (*t)(2,53) = 0.002;
1916 (*t)(0,54) = 4.400; (*t)(1,54) = -0.030; (*t)(2,54) = 0.002;
1917 (*t)(0,55) = 4.500; (*t)(1,55) = -0.028; (*t)(2,55) = 0.002;
1918 (*t)(0,56) = 4.600; (*t)(1,56) = -0.028; (*t)(2,56) = 0.002;
1919 (*t)(0,57) = 4.700; (*t)(1,57) = -0.028; (*t)(2,57) = 0.000;
1920 (*t)(0,58) = 4.800; (*t)(1,58) = -0.028; (*t)(2,58) = 0.002;
1921 (*t)(0,59) = 4.900; (*t)(1,59) = 0.000; (*t)(2,59) = 0.000;
1922 (*t)(0,60) = 5.900; (*t)(1,60) = 0.000; (*t)(2,60) = 0.000;
1925 if (fParticleID==AliPID::kKaon)
1927 //TOF kaons, 0.9 purity
1928 t = new TMatrixF(3,61);
1929 (*t)(0,0) = 0.000; (*t)(1,0) = 0.000; (*t)(2,0) = 0.000;
1930 (*t)(0,1) = 0.050; (*t)(1,1) = 0.000; (*t)(2,1) = 0.000;
1931 (*t)(0,2) = 0.100; (*t)(1,2) = 0.000; (*t)(2,2) = 0.000;
1932 (*t)(0,3) = 0.150; (*t)(1,3) = 0.000; (*t)(2,3) = 0.000;
1933 (*t)(0,4) = 0.200; (*t)(1,4) = -0.05; (*t)(2,4) = 0.05;
1934 (*t)(0,5) = 0.200; (*t)(1,5) = -0.05; (*t)(2,5) = 0.05;
1935 (*t)(0,6) = 0.200; (*t)(1,6) = -0.05; (*t)(2,6) = 0.05;
1936 (*t)(0,7) = 0.200; (*t)(1,7) = -0.05; (*t)(2,7) = 0.05;
1937 (*t)(0,8) = 0.200; (*t)(1,8) = -0.05; (*t)(2,8) = 0.05;
1938 (*t)(0,9) = 0.200; (*t)(1,9) = -0.05; (*t)(2,9) = 0.05;
1939 (*t)(0,10) = 0.200; (*t)(1,10) = -0.05; (*t)(2,10) = 0.05;
1940 (*t)(0,11) = 0.550; (*t)(1,11) = -0.026; (*t)(2,11) = 0.026;
1941 (*t)(0,12) = 0.600; (*t)(1,12) = -0.026; (*t)(2,12) = 0.026;
1942 (*t)(0,13) = 0.650; (*t)(1,13) = -0.026; (*t)(2,13) = 0.026;
1943 (*t)(0,14) = 0.700; (*t)(1,14) = -0.026; (*t)(2,14) = 0.026;
1944 (*t)(0,15) = 0.750; (*t)(1,15) = -0.026; (*t)(2,15) = 0.026;
1945 (*t)(0,16) = 0.800; (*t)(1,16) = -0.026; (*t)(2,16) = 0.026;
1946 (*t)(0,17) = 0.850; (*t)(1,17) = -0.024; (*t)(2,17) = 0.024;
1947 (*t)(0,18) = 0.900; (*t)(1,18) = -0.024; (*t)(2,18) = 0.024;
1948 (*t)(0,19) = 0.950; (*t)(1,19) = -0.024; (*t)(2,19) = 0.024;
1949 (*t)(0,20) = 1.000; (*t)(1,20) = -0.024; (*t)(2,20) = 0.024;
1950 (*t)(0,21) = 1.100; (*t)(1,21) = -0.024; (*t)(2,21) = 0.024;
1951 (*t)(0,22) = 1.200; (*t)(1,22) = -0.024; (*t)(2,22) = 0.022;
1952 (*t)(0,23) = 1.300; (*t)(1,23) = -0.024; (*t)(2,23) = 0.020;
1953 (*t)(0,24) = 1.400; (*t)(1,24) = -0.026; (*t)(2,24) = 0.016;
1954 (*t)(0,25) = 1.500; (*t)(1,25) = -0.028; (*t)(2,25) = 0.014;
1955 (*t)(0,26) = 1.600; (*t)(1,26) = -0.028; (*t)(2,26) = 0.012;
1956 (*t)(0,27) = 1.700; (*t)(1,27) = -0.028; (*t)(2,27) = 0.010;
1957 (*t)(0,28) = 1.800; (*t)(1,28) = -0.028; (*t)(2,28) = 0.010;
1958 (*t)(0,29) = 1.900; (*t)(1,29) = -0.028; (*t)(2,29) = 0.008;
1959 (*t)(0,30) = 2.000; (*t)(1,30) = -0.028; (*t)(2,30) = 0.006;
1960 (*t)(0,31) = 2.100; (*t)(1,31) = -0.026; (*t)(2,31) = 0.006;
1961 (*t)(0,32) = 2.200; (*t)(1,32) = -0.024; (*t)(2,32) = 0.004;
1962 (*t)(0,33) = 2.300; (*t)(1,33) = -0.020; (*t)(2,33) = 0.002;
1963 (*t)(0,34) = 2.400; (*t)(1,34) = -0.020; (*t)(2,34) = 0.002;
1964 (*t)(0,35) = 2.500; (*t)(1,35) = -0.018; (*t)(2,35) = 0.000;
1965 (*t)(0,36) = 2.600; (*t)(1,36) = -0.016; (*t)(2,36) = 0.000;
1966 (*t)(0,37) = 2.700; (*t)(1,37) = -0.014; (*t)(2,37) = -0.002;
1967 (*t)(0,38) = 2.800; (*t)(1,38) = -0.014; (*t)(2,38) = -0.004;
1968 (*t)(0,39) = 2.900; (*t)(1,39) = -0.012; (*t)(2,39) = -0.004;
1969 (*t)(0,40) = 3.000; (*t)(1,40) = -0.010; (*t)(2,40) = -0.006;
1970 (*t)(0,41) = 3.100; (*t)(1,41) = 0.000; (*t)(2,41) = 0.000;
1971 (*t)(0,42) = 3.200; (*t)(1,42) = 0.000; (*t)(2,42) = 0.000;
1972 (*t)(0,43) = 3.300; (*t)(1,43) = 0.000; (*t)(2,43) = 0.000;
1973 (*t)(0,44) = 3.400; (*t)(1,44) = 0.000; (*t)(2,44) = 0.000;
1974 (*t)(0,45) = 3.500; (*t)(1,45) = 0.000; (*t)(2,45) = 0.000;
1975 (*t)(0,46) = 3.600; (*t)(1,46) = 0.000; (*t)(2,46) = 0.000;
1976 (*t)(0,47) = 3.700; (*t)(1,47) = 0.000; (*t)(2,47) = 0.000;
1977 (*t)(0,48) = 3.800; (*t)(1,48) = 0.000; (*t)(2,48) = 0.000;
1978 (*t)(0,49) = 3.900; (*t)(1,49) = 0.000; (*t)(2,49) = 0.000;
1979 (*t)(0,50) = 4.000; (*t)(1,50) = 0.000; (*t)(2,50) = 0.000;
1980 (*t)(0,51) = 4.100; (*t)(1,51) = 0.000; (*t)(2,51) = 0.000;
1981 (*t)(0,52) = 4.200; (*t)(1,52) = 0.000; (*t)(2,52) = 0.000;
1982 (*t)(0,53) = 4.300; (*t)(1,53) = 0.000; (*t)(2,53) = 0.000;
1983 (*t)(0,54) = 4.400; (*t)(1,54) = 0.000; (*t)(2,54) = 0.000;
1984 (*t)(0,55) = 4.500; (*t)(1,55) = 0.000; (*t)(2,55) = 0.000;
1985 (*t)(0,56) = 4.600; (*t)(1,56) = 0.000; (*t)(2,56) = 0.000;
1986 (*t)(0,57) = 4.700; (*t)(1,57) = 0.000; (*t)(2,57) = 0.000;
1987 (*t)(0,58) = 4.800; (*t)(1,58) = 0.000; (*t)(2,58) = 0.000;
1988 (*t)(0,59) = 4.900; (*t)(1,59) = 0.000; (*t)(2,59) = 0.000;
1989 (*t)(0,60) = 5.900; (*t)(1,60) = 0.000; (*t)(2,60) = 0.000;
1996 //-----------------------------------------------------------------------
1997 Bool_t AliFlowTrackCuts::PassesTPCbayesianCut(const AliESDtrack* track)
1999 //cut on TPC bayesian pid
2000 //TODO: maybe join all bayesian methods, make GetESDPdg aware of pid mode selected
2001 //if (! fAllowTOFmismatchFlag) {if (track->GetStatus() & AliESDtrack::kTOFmismatch) return kFALSE;}
2003 //Bool_t statusMatchingHard = TPCTOFagree(track);
2004 //if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
2007 Int_t pdg = GetESDPdg(track,"bayesianTPC");
2008 // printf("pdg set to %i\n",pdg);
2012 switch (fParticleID)
2016 prob = fProbBayes[2];
2020 prob = fProbBayes[3];
2022 case AliPID::kProton:
2024 prob = fProbBayes[4];
2026 case AliPID::kElectron:
2028 prob = fProbBayes[0];
2034 if(TMath::Abs(pdg) == TMath::Abs(pid) && prob > fParticleProbability)
2038 else if (fCutCharge && fCharge * track->GetSign() > 0)
2044 //-----------------------------------------------------------------------
2045 // part added by F. Noferini (some methods)
2046 Bool_t AliFlowTrackCuts::PassesTOFbayesianCut(const AliESDtrack* track)
2049 Bool_t goodtrack = (track->GetStatus() & AliESDtrack::kTOFpid) &&
2050 (track->GetTOFsignal() > 12000) &&
2051 (track->GetTOFsignal() < 100000) &&
2052 (track->GetIntegratedLength() > 365);
2057 if (! fAllowTOFmismatchFlag) {if (track->GetStatus() & AliESDtrack::kTOFmismatch) return kFALSE;}
2059 Bool_t statusMatchingHard = TPCTOFagree(track);
2060 if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
2063 Int_t pdg = GetESDPdg(track,"bayesianALL");
2064 // printf("pdg set to %i\n",pdg);
2068 switch (fParticleID)
2072 prob = fProbBayes[2];
2076 prob = fProbBayes[3];
2078 case AliPID::kProton:
2080 prob = fProbBayes[4];
2082 case AliPID::kElectron:
2084 prob = fProbBayes[0];
2090 // printf("pt = %f -- all prob = [%4.2f,%4.2f,%4.2f,%4.2f,%4.2f] -- prob = %f\n",track->Pt(),fProbBayes[0],fProbBayes[1],fProbBayes[2],fProbBayes[3],fProbBayes[4],prob);
2091 if(TMath::Abs(pdg) == TMath::Abs(pid) && prob > fParticleProbability){
2094 else if (fCutCharge && fCharge * track->GetSign() > 0)
2101 //-----------------------------------------------------------------------
2102 // part added by Natasha
2103 Bool_t AliFlowTrackCuts::PassesNucleiSelection(const AliESDtrack* track)
2105 Bool_t select=kFALSE;
2107 //if (!track) continue;
2109 if (!track->GetInnerParam())
2110 return kFALSE; //break;
2112 const AliExternalTrackParam* tpcTrack = track->GetInnerParam();
2114 Double_t ptotTPC = tpcTrack->GetP();
2115 Double_t sigTPC = track->GetTPCsignal();
2116 Double_t dEdxBBA = 0.;
2117 Double_t dSigma = 0.;
2119 switch (fParticleID)
2121 case AliPID::kDeuteron:
2123 dEdxBBA = AliExternalTrackParam::BetheBlochAleph(ptotTPC/1.8756,
2129 dSigma = (sigTPC - dEdxBBA)/dEdxBBA;
2131 if( ptotTPC<=1.1 && (dSigma < (0.5 - (0.1818*ptotTPC)) ) && (dSigma > ( (0.218*ptotTPC - 0.4) ) ) )
2135 case AliPID::kTriton:
2145 case AliPID::kAlpha:
2156 // end part added by Natasha
2160 //-----------------------------------------------------------------------
2161 Int_t AliFlowTrackCuts::GetESDPdg(const AliESDtrack *track,Option_t *option,Int_t ipart,Float_t cPi,Float_t cKa,Float_t cPr)
2165 Int_t pdgvalues[5] = {-11,-13,211,321,2212};
2166 Float_t mass[5] = {5.10998909999999971e-04,1.05658000000000002e-01,1.39570000000000000e-01,4.93676999999999977e-01,9.38271999999999995e-01};
2168 if(strstr(option,"bayesianTOF")){ // Bayesian TOF PID
2169 Double_t c[5]={0.01, 0.01, 0.85, 0.1, 0.05};
2172 Float_t pt = track->Pt();
2175 while(pt > fBinLimitPID[iptesd] && iptesd < fgkPIDptBin-1) iptesd++;
2178 c[0] = fC[iptesd][0];
2179 c[1] = fC[iptesd][1];
2180 c[2] = fC[iptesd][2];
2181 c[3] = fC[iptesd][3];
2182 c[4] = fC[iptesd][4];
2192 Double_t r1[10]; track->GetTOFpid(r1);
2195 for (i=0; i<5; i++) rcc+=(c[i]*r1[i]);
2198 for (i=0; i<5; i++){
2199 w[i]=c[i]*r1[i]/rcc;
2200 fProbBayes[i] = w[i];
2202 if (w[2]>=w[3] && w[2]>=w[4] && w[2]>=w[1] && w[2]>=w[0]) {//pion
2203 pdg = 211*Int_t(track->GetSign());
2205 else if (w[4]>=w[3] && w[4]>=w[1] && w[4]>=w[0]) {//proton
2206 pdg = 2212*Int_t(track->GetSign());
2208 else if (w[3]>=w[1] && w[3]>=w[0]){//kaon
2209 pdg = 321*Int_t(track->GetSign());
2211 else if (w[0]>=w[1]) { //electrons
2212 pdg = -11*Int_t(track->GetSign());
2215 pdg = -13*Int_t(track->GetSign());
2219 else if(strstr(option,"bayesianTPC")){ // Bayesian TPC PID
2220 Double_t c[5]={0.01, 0.01, 0.85, 0.1, 0.05};
2223 Float_t pt = track->Pt();
2226 while(pt > fBinLimitPID[iptesd] && iptesd < fgkPIDptBin-1) iptesd++;
2229 c[0] = fC[iptesd][0];
2230 c[1] = fC[iptesd][1];
2231 c[2] = fC[iptesd][2];
2232 c[3] = fC[iptesd][3];
2233 c[4] = fC[iptesd][4];
2243 Double_t r1[10]; track->GetTPCpid(r1);
2246 for (i=0; i<5; i++) rcc+=(c[i]*r1[i]);
2249 for (i=0; i<5; i++){
2250 w[i]=c[i]*r1[i]/rcc;
2251 fProbBayes[i] = w[i];
2253 if (w[2]>=w[3] && w[2]>=w[4] && w[2]>=w[1] && w[2]>=w[0]) {//pion
2254 pdg = 211*Int_t(track->GetSign());
2256 else if (w[4]>=w[3] && w[4]>=w[1] && w[4]>=w[0]) {//proton
2257 pdg = 2212*Int_t(track->GetSign());
2259 else if (w[3]>=w[1] && w[3]>=w[0]){//kaon
2260 pdg = 321*Int_t(track->GetSign());
2262 else if (w[0]>=w[1]) { //electrons
2263 pdg = -11*Int_t(track->GetSign());
2266 pdg = -13*Int_t(track->GetSign());
2270 else if(strstr(option,"bayesianALL")){
2271 Double_t c[5]={0.01, 0.01, 0.85, 0.1, 0.05};
2274 Float_t pt = track->Pt();
2277 while(pt > fBinLimitPID[iptesd] && iptesd < fgkPIDptBin-1) iptesd++;
2280 c[0] = fC[iptesd][0];
2281 c[1] = fC[iptesd][1];
2282 c[2] = fC[iptesd][2];
2283 c[3] = fC[iptesd][3];
2284 c[4] = fC[iptesd][4];
2294 Double_t r1[10]; track->GetTOFpid(r1);
2295 Double_t r2[10]; track->GetTPCpid(r2);
2297 r1[0] = TMath::Min(r1[2],r1[0]);
2298 r1[1] = TMath::Min(r1[2],r1[1]);
2301 for (i=0; i<5; i++) rcc+=(c[i]*r1[i]*r2[i]);
2305 for (i=0; i<5; i++){
2306 w[i]=c[i]*r1[i]*r2[i]/rcc;
2307 fProbBayes[i] = w[i];
2310 if (w[2]>=w[3] && w[2]>=w[4] && w[2]>=w[1] && w[2]>=w[0]) {//pion
2311 pdg = 211*Int_t(track->GetSign());
2313 else if (w[4]>=w[3] && w[4]>=w[1] && w[4]>=w[0]) {//proton
2314 pdg = 2212*Int_t(track->GetSign());
2316 else if (w[3]>=w[1] && w[3]>=w[0]){//kaon
2317 pdg = 321*Int_t(track->GetSign());
2319 else if (w[0]>=w[1]) { //electrons
2320 pdg = -11*Int_t(track->GetSign());
2323 pdg = -13*Int_t(track->GetSign());
2327 else if(strstr(option,"sigmacutTOF")){
2328 printf("PID not implemented yet: %s\nNO PID!!!!\n",option);
2329 Float_t p = track->P();
2331 // Take expected times
2332 Double_t exptimes[5];
2333 track->GetIntegratedTimes(exptimes);
2335 // Take resolution for TOF response
2336 // like fESDpid.GetTOFResponse().GetExpectedSigma(p, exptimes[ipart], mass[ipart]);
2337 Float_t resolution = fESDpid.GetTOFResponse().GetExpectedSigma(p, exptimes[ipart], mass[ipart]);
2339 if(TMath::Abs(exptimes[ipart] - track->GetTOFsignal()) < 3 * resolution){
2340 pdg = pdgvalues[ipart] * Int_t(track->GetSign());
2345 printf("Invalid PID option: %s\nNO PID!!!!\n",option);
2351 //-----------------------------------------------------------------------
2352 void AliFlowTrackCuts::SetPriors(Float_t centrCur){
2353 fBinLimitPID[0] = 0.300000;
2354 fBinLimitPID[1] = 0.400000;
2355 fBinLimitPID[2] = 0.500000;
2356 fBinLimitPID[3] = 0.600000;
2357 fBinLimitPID[4] = 0.700000;
2358 fBinLimitPID[5] = 0.800000;
2359 fBinLimitPID[6] = 0.900000;
2360 fBinLimitPID[7] = 1.000000;
2361 fBinLimitPID[8] = 1.200000;
2362 fBinLimitPID[9] = 1.400000;
2363 fBinLimitPID[10] = 1.600000;
2364 fBinLimitPID[11] = 1.800000;
2365 fBinLimitPID[12] = 2.000000;
2366 fBinLimitPID[13] = 2.200000;
2367 fBinLimitPID[14] = 2.400000;
2368 fBinLimitPID[15] = 2.600000;
2369 fBinLimitPID[16] = 2.800000;
2370 fBinLimitPID[17] = 3.000000;
2483 else if(centrCur < 20){
2593 else if(centrCur < 30){
2703 else if(centrCur < 40){
2813 else if(centrCur < 50){
2923 else if(centrCur < 60){
3033 else if(centrCur < 70){
3143 else if(centrCur < 80){
3363 for(Int_t i=18;i<fgkPIDptBin;i++){
3364 fBinLimitPID[i] = 3.0 + 0.2 * (i-18);
3365 fC[i][0] = fC[17][0];
3366 fC[i][1] = fC[17][1];
3367 fC[i][2] = fC[17][2];
3368 fC[i][3] = fC[17][3];
3369 fC[i][4] = fC[17][4];
3373 //---------------------------------------------------------------//
3374 Bool_t AliFlowTrackCuts::TPCTOFagree(const AliESDtrack *track)
3376 Bool_t status = kFALSE;
3378 Float_t mass[5] = {5.10998909999999971e-04,1.05658000000000002e-01,1.39570000000000000e-01,4.93676999999999977e-01,9.38271999999999995e-01};
3381 Double_t exptimes[5];
3382 track->GetIntegratedTimes(exptimes);
3384 Float_t dedx = track->GetTPCsignal();
3386 Float_t p = track->P();
3387 Float_t time = track->GetTOFsignal()- fESDpid.GetTOFResponse().GetStartTime(p);
3388 Float_t tl = track->GetIntegratedLength();
3390 Float_t betagammares = fESDpid.GetTOFResponse().GetExpectedSigma(p, exptimes[4], mass[4]);
3392 Float_t betagamma1 = tl/(time-5 *betagammares) * 33.3564095198152043;
3394 // printf("betagamma1 = %f\n",betagamma1);
3396 if(betagamma1 < 0.1) betagamma1 = 0.1;
3398 if(betagamma1 < 0.99999) betagamma1 /= TMath::Sqrt(1-betagamma1*betagamma1);
3399 else betagamma1 = 100;
3401 Float_t betagamma2 = tl/(time+5 *betagammares) * 33.3564095198152043;
3402 // printf("betagamma2 = %f\n",betagamma2);
3404 if(betagamma2 < 0.1) betagamma2 = 0.1;
3406 if(betagamma2 < 0.99999) betagamma2 /= TMath::Sqrt(1-betagamma2*betagamma2);
3407 else betagamma2 = 100;
3411 track->GetInnerPxPyPz(ptpc);
3412 Float_t momtpc=TMath::Sqrt(ptpc[0]*ptpc[0] + ptpc[1]*ptpc[1] + ptpc[2]*ptpc[2]);
3414 for(Int_t i=0;i < 5;i++){
3415 Float_t resolutionTOF = fESDpid.GetTOFResponse().GetExpectedSigma(p, exptimes[i], mass[i]);
3416 if(TMath::Abs(exptimes[i] - time) < 5 * resolutionTOF){
3417 Float_t dedxExp = 0;
3418 if(i==0) dedxExp = fESDpid.GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kElectron);
3419 else if(i==1) dedxExp = fESDpid.GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kMuon);
3420 else if(i==2) dedxExp = fESDpid.GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kPion);
3421 else if(i==3) dedxExp = fESDpid.GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kKaon);
3422 else if(i==4) dedxExp = fESDpid.GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kProton);
3424 Float_t resolutionTPC = 2;
3425 if(i==0) resolutionTPC = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kElectron);
3426 else if(i==1) resolutionTPC = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kMuon);
3427 else if(i==2) resolutionTPC = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kPion);
3428 else if(i==3) resolutionTPC = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kKaon);
3429 else if(i==4) resolutionTPC = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kProton);
3431 if(TMath::Abs(dedx - dedxExp) < 3 * resolutionTPC){
3437 Float_t bb1 = fESDpid.GetTPCResponse().Bethe(betagamma1);
3438 Float_t bb2 = fESDpid.GetTPCResponse().Bethe(betagamma2);
3439 Float_t bbM = fESDpid.GetTPCResponse().Bethe((betagamma1+betagamma2)*0.5);
3444 Float_t resolutionTOFpr = fESDpid.GetTOFResponse().GetExpectedSigma(p, exptimes[4], mass[4]);
3445 Float_t resolutionTPCpr = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kProton);
3446 if(TMath::Abs(dedx-bb1) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
3449 else if(TMath::Abs(dedx-bb2) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
3452 else if(TMath::Abs(dedx-bbM) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
3458 // end part added by F. Noferini
3459 //-----------------------------------------------------------------------
3461 //-----------------------------------------------------------------------
3462 const char* AliFlowTrackCuts::PIDsourceName(PIDsource s)
3464 //get the name of the particle id source
3470 return "TPCbayesian";
3478 return "TOFbayesianPID";
3479 case kTOFbetaSimple:
3480 return "TOFbetaSimple";
3488 //-----------------------------------------------------------------------
3489 const char* AliFlowTrackCuts::GetParamTypeName(trackParameterType type)
3491 //return the name of the selected parameter type
3498 case kTPCstandalone:
3499 return "TPCstandalone";
3501 return "SPDtracklets";
3511 //-----------------------------------------------------------------------
3512 Bool_t AliFlowTrackCuts::PassesPMDcuts(AliESDPmdTrack* track )
3514 //check PMD specific cuts
3515 //clean up from last iteration, and init label
3516 Int_t det = track->GetDetector();
3517 //Int_t smn = track->GetSmn();
3518 Float_t clsX = track->GetClusterX();
3519 Float_t clsY = track->GetClusterY();
3520 Float_t clsZ = track->GetClusterZ();
3521 Float_t ncell = track->GetClusterCells();
3522 Float_t adc = track->GetClusterADC();
3528 fTrackEta = GetPmdEta(clsX,clsY,clsZ);
3529 fTrackPhi = GetPmdPhi(clsX,clsY);
3533 if (fCutEta) {if ( fTrackEta < fEtaMin || fTrackEta >= fEtaMax ) pass = kFALSE;}
3534 if (fCutPhi) {if ( fTrackPhi < fPhiMin || fTrackPhi >= fPhiMax ) pass = kFALSE;}
3535 if (fCutPmdDet) {if(det != fPmdDet) pass = kFALSE;}
3536 if (fCutPmdAdc) {if(adc < fPmdAdc) pass = kFALSE;}
3537 if (fCutPmdNcell) {if(ncell < fPmdNcell) pass = kFALSE;}
3542 //-----------------------------------------------------------------------
3543 Bool_t AliFlowTrackCuts::PassesV0cuts(AliVVZERO* vzero, Int_t id)
3547 //clean up from last iter
3552 fTrackPhi = TMath::PiOver4()*(0.5+id%8);
3554 fTrackEta = -3.45+0.5*(id/8); // taken from PPR
3556 fTrackEta = +4.8-0.5*((id/8)-4); // taken from PPR
3557 fTrackWeight = vzero->GetMultiplicity(id); // not corrected yet: we should use AliESDUtils
3560 if (fCutEta) {if ( fTrackEta < fEtaMin || fTrackEta >= fEtaMax ) pass = kFALSE;}
3561 if (fCutPhi) {if ( fTrackPhi < fPhiMin || fTrackPhi >= fPhiMax ) pass = kFALSE;}
3566 //----------------------------------------------------------------------------//
3567 Double_t AliFlowTrackCuts::GetPmdEta(Float_t xPos, Float_t yPos, Float_t zPos)
3569 Float_t rpxpy, theta, eta;
3570 rpxpy = TMath::Sqrt(xPos*xPos + yPos*yPos);
3571 theta = TMath::ATan2(rpxpy,zPos);
3572 eta = -TMath::Log(TMath::Tan(0.5*theta));
3576 //--------------------------------------------------------------------------//
3577 Double_t AliFlowTrackCuts::GetPmdPhi(Float_t xPos, Float_t yPos)
3579 Float_t pybypx, phi = 0., phi1;
3582 if(yPos>0) phi = 90.;
3583 if(yPos<0) phi = 270.;
3588 if(pybypx < 0) pybypx = - pybypx;
3589 phi1 = TMath::ATan(pybypx)*180./3.14159;
3591 if(xPos > 0 && yPos > 0) phi = phi1; // 1st Quadrant
3592 if(xPos < 0 && yPos > 0) phi = 180 - phi1; // 2nd Quadrant
3593 if(xPos < 0 && yPos < 0) phi = 180 + phi1; // 3rd Quadrant
3594 if(xPos > 0 && yPos < 0) phi = 360 - phi1; // 4th Quadrant
3597 phi = phi*3.14159/180.;
3601 //---------------------------------------------------------------//
3602 void AliFlowTrackCuts::Browse(TBrowser* b)
3604 //some browsing capabilities
3605 if (fQA) b->Add(fQA);
3608 //---------------------------------------------------------------//
3609 Long64_t AliFlowTrackCuts::Merge(TCollection* list)
3612 if (!fQA || !list) return 0;
3613 if (list->IsEmpty()) return 0;
3614 AliFlowTrackCuts* obj=NULL;
3617 while ( (obj = dynamic_cast<AliFlowTrackCuts*>(next())) )
3619 if (obj==this) continue;
3620 tmplist.Add(obj->GetQA());
3622 return fQA->Merge(&tmplist);