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 // Data selection 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 "AliESDUtils.h" //TODO
60 #include "AliFlowBayesianPID.h"
62 ClassImp(AliFlowTrackCuts)
64 //-----------------------------------------------------------------------
65 AliFlowTrackCuts::AliFlowTrackCuts():
66 AliFlowTrackSimpleCuts(),
67 fAliESDtrackCuts(NULL),
70 fCutMChasTrackReferences(kFALSE),
71 fCutMCprocessType(kFALSE),
72 fMCprocessType(kPNoProcess),
75 fCutMCfirstMotherPID(kFALSE),
77 fIgnoreSignInMCPID(kFALSE),
78 fCutMCisPrimary(kFALSE),
79 fRequireTransportBitForPrimaries(kTRUE),
81 fRequireCharge(kFALSE),
83 fCutSPDtrackletDeltaPhi(kFALSE),
84 fSPDtrackletDeltaPhiMax(FLT_MAX),
85 fSPDtrackletDeltaPhiMin(-FLT_MAX),
86 fIgnoreTPCzRange(kFALSE),
87 fIgnoreTPCzRangeMax(FLT_MAX),
88 fIgnoreTPCzRangeMin(-FLT_MAX),
89 fCutChi2PerClusterTPC(kFALSE),
90 fMaxChi2PerClusterTPC(FLT_MAX),
91 fMinChi2PerClusterTPC(-FLT_MAX),
92 fCutNClustersTPC(kFALSE),
93 fNClustersTPCMax(INT_MAX),
94 fNClustersTPCMin(INT_MIN),
95 fCutNClustersITS(kFALSE),
96 fNClustersITSMax(INT_MAX),
97 fNClustersITSMin(INT_MIN),
98 fUseAODFilterBit(kFALSE),
100 fCutDCAToVertexXY(kFALSE),
101 fCutDCAToVertexZ(kFALSE),
102 fCutMinimalTPCdedx(kFALSE),
104 fLinearizeVZEROresponse(kFALSE),
109 fCutPmdNcell(kFALSE),
117 fTrackLabel(INT_MIN),
122 fFlowTagType(AliFlowTrackSimple::kInvalid),
124 fBayesianResponse(NULL),
128 fParticleID(AliPID::kUnknown),
129 fParticleProbability(.9),
130 fAllowTOFmismatchFlag(kFALSE),
131 fRequireStrictTOFTPCagreement(kFALSE),
132 fCutRejectElectronsWithTPCpid(kFALSE),
137 SetPriors(); //init arrays
140 //-----------------------------------------------------------------------
141 AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
142 AliFlowTrackSimpleCuts(name),
143 fAliESDtrackCuts(NULL),
146 fCutMChasTrackReferences(kFALSE),
147 fCutMCprocessType(kFALSE),
148 fMCprocessType(kPNoProcess),
151 fCutMCfirstMotherPID(kFALSE),
152 fMCfirstMotherPID(0),
153 fIgnoreSignInMCPID(kFALSE),
154 fCutMCisPrimary(kFALSE),
155 fRequireTransportBitForPrimaries(kTRUE),
156 fMCisPrimary(kFALSE),
157 fRequireCharge(kFALSE),
159 fCutSPDtrackletDeltaPhi(kFALSE),
160 fSPDtrackletDeltaPhiMax(FLT_MAX),
161 fSPDtrackletDeltaPhiMin(-FLT_MAX),
162 fIgnoreTPCzRange(kFALSE),
163 fIgnoreTPCzRangeMax(FLT_MAX),
164 fIgnoreTPCzRangeMin(-FLT_MAX),
165 fCutChi2PerClusterTPC(kFALSE),
166 fMaxChi2PerClusterTPC(FLT_MAX),
167 fMinChi2PerClusterTPC(-FLT_MAX),
168 fCutNClustersTPC(kFALSE),
169 fNClustersTPCMax(INT_MAX),
170 fNClustersTPCMin(INT_MIN),
171 fCutNClustersITS(kFALSE),
172 fNClustersITSMax(INT_MAX),
173 fNClustersITSMin(INT_MIN),
174 fUseAODFilterBit(kFALSE),
176 fCutDCAToVertexXY(kFALSE),
177 fCutDCAToVertexZ(kFALSE),
178 fCutMinimalTPCdedx(kFALSE),
180 fLinearizeVZEROresponse(kFALSE),
185 fCutPmdNcell(kFALSE),
193 fTrackLabel(INT_MIN),
198 fFlowTagType(AliFlowTrackSimple::kInvalid),
200 fBayesianResponse(NULL),
204 fParticleID(AliPID::kUnknown),
205 fParticleProbability(.9),
206 fAllowTOFmismatchFlag(kFALSE),
207 fRequireStrictTOFTPCagreement(kFALSE),
208 fCutRejectElectronsWithTPCpid(kFALSE),
213 SetTitle("AliFlowTrackCuts");
214 fESDpid.GetTPCResponse().SetBetheBlochParameters( 0.0283086,
219 SetPriors(); //init arrays
221 // New PID procedure (Bayesian Combined PID)
222 fBayesianResponse = new AliFlowBayesianPID();
223 fBayesianResponse->SetNewTrackParam();
226 //-----------------------------------------------------------------------
227 AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
228 AliFlowTrackSimpleCuts(that),
229 fAliESDtrackCuts(NULL),
232 fCutMChasTrackReferences(that.fCutMChasTrackReferences),
233 fCutMCprocessType(that.fCutMCprocessType),
234 fMCprocessType(that.fMCprocessType),
235 fCutMCPID(that.fCutMCPID),
237 fCutMCfirstMotherPID(that.fCutMCfirstMotherPID),
238 fMCfirstMotherPID(that.fMCfirstMotherPID),
239 fIgnoreSignInMCPID(that.fIgnoreSignInMCPID),
240 fCutMCisPrimary(that.fCutMCisPrimary),
241 fRequireTransportBitForPrimaries(that.fRequireTransportBitForPrimaries),
242 fMCisPrimary(that.fMCisPrimary),
243 fRequireCharge(that.fRequireCharge),
244 fFakesAreOK(that.fFakesAreOK),
245 fCutSPDtrackletDeltaPhi(that.fCutSPDtrackletDeltaPhi),
246 fSPDtrackletDeltaPhiMax(that.fSPDtrackletDeltaPhiMax),
247 fSPDtrackletDeltaPhiMin(that.fSPDtrackletDeltaPhiMin),
248 fIgnoreTPCzRange(that.fIgnoreTPCzRange),
249 fIgnoreTPCzRangeMax(that.fIgnoreTPCzRangeMax),
250 fIgnoreTPCzRangeMin(that.fIgnoreTPCzRangeMin),
251 fCutChi2PerClusterTPC(that.fCutChi2PerClusterTPC),
252 fMaxChi2PerClusterTPC(that.fMaxChi2PerClusterTPC),
253 fMinChi2PerClusterTPC(that.fMinChi2PerClusterTPC),
254 fCutNClustersTPC(that.fCutNClustersTPC),
255 fNClustersTPCMax(that.fNClustersTPCMax),
256 fNClustersTPCMin(that.fNClustersTPCMin),
257 fCutNClustersITS(that.fCutNClustersITS),
258 fNClustersITSMax(that.fNClustersITSMax),
259 fNClustersITSMin(that.fNClustersITSMin),
260 fUseAODFilterBit(that.fUseAODFilterBit),
261 fAODFilterBit(that.fAODFilterBit),
262 fCutDCAToVertexXY(that.fCutDCAToVertexXY),
263 fCutDCAToVertexZ(that.fCutDCAToVertexZ),
264 fCutMinimalTPCdedx(that.fCutMinimalTPCdedx),
265 fMinimalTPCdedx(that.fMinimalTPCdedx),
266 fLinearizeVZEROresponse(that.fLinearizeVZEROresponse),
267 fCutPmdDet(that.fCutPmdDet),
268 fPmdDet(that.fPmdDet),
269 fCutPmdAdc(that.fCutPmdAdc),
270 fPmdAdc(that.fPmdAdc),
271 fCutPmdNcell(that.fCutPmdNcell),
272 fPmdNcell(that.fPmdNcell),
273 fParamType(that.fParamType),
274 fParamMix(that.fParamMix),
279 fTrackLabel(INT_MIN),
284 fFlowTagType(that.fFlowTagType),
285 fESDpid(that.fESDpid),
286 fBayesianResponse(NULL),
287 fPIDsource(that.fPIDsource),
290 fParticleID(that.fParticleID),
291 fParticleProbability(that.fParticleProbability),
292 fAllowTOFmismatchFlag(that.fAllowTOFmismatchFlag),
293 fRequireStrictTOFTPCagreement(that.fRequireStrictTOFTPCagreement),
294 fCutRejectElectronsWithTPCpid(that.fCutRejectElectronsWithTPCpid),
299 if (that.fTPCpidCuts) fTPCpidCuts = new TMatrixF(*(that.fTPCpidCuts));
300 if (that.fTOFpidCuts) fTOFpidCuts = new TMatrixF(*(that.fTOFpidCuts));
301 if (that.fAliESDtrackCuts) fAliESDtrackCuts = new AliESDtrackCuts(*(that.fAliESDtrackCuts));
302 SetPriors(); //init arrays
303 if (that.fQA) DefineHistograms();
305 // New PID procedure (Bayesian Combined PID)
306 fBayesianResponse = new AliFlowBayesianPID();
307 fBayesianResponse->SetNewTrackParam();
310 //-----------------------------------------------------------------------
311 AliFlowTrackCuts& AliFlowTrackCuts::operator=(const AliFlowTrackCuts& that)
314 if (this==&that) return *this;
316 AliFlowTrackSimpleCuts::operator=(that);
317 //the following may seem excessive but if AliESDtrackCuts properly does copy and clone
318 //this approach is better memory-fragmentation-wise in some cases
319 if (that.fAliESDtrackCuts && fAliESDtrackCuts) *fAliESDtrackCuts=*(that.fAliESDtrackCuts);
320 if (that.fAliESDtrackCuts && !fAliESDtrackCuts) fAliESDtrackCuts=new AliESDtrackCuts(*(that.fAliESDtrackCuts));
321 if (!that.fAliESDtrackCuts) delete fAliESDtrackCuts; fAliESDtrackCuts=NULL;
322 //these guys we don't need to copy, just reinit
323 if (that.fQA) {fQA->Delete(); delete fQA; fQA=NULL; DefineHistograms();}
325 fCutMChasTrackReferences=that.fCutMChasTrackReferences;
326 fCutMCprocessType=that.fCutMCprocessType;
327 fMCprocessType=that.fMCprocessType;
328 fCutMCPID=that.fCutMCPID;
330 fCutMCfirstMotherPID=that.fCutMCfirstMotherPID;
331 fMCfirstMotherPID=that.fMCfirstMotherPID;
332 fIgnoreSignInMCPID=that.fIgnoreSignInMCPID,
333 fCutMCisPrimary=that.fCutMCisPrimary;
334 fRequireTransportBitForPrimaries=that.fRequireTransportBitForPrimaries;
335 fMCisPrimary=that.fMCisPrimary;
336 fRequireCharge=that.fRequireCharge;
337 fFakesAreOK=that.fFakesAreOK;
338 fCutSPDtrackletDeltaPhi=that.fCutSPDtrackletDeltaPhi;
339 fSPDtrackletDeltaPhiMax=that.fSPDtrackletDeltaPhiMax;
340 fSPDtrackletDeltaPhiMin=that.fSPDtrackletDeltaPhiMin;
341 fIgnoreTPCzRange=that.fIgnoreTPCzRange;
342 fIgnoreTPCzRangeMax=that.fIgnoreTPCzRangeMax;
343 fIgnoreTPCzRangeMin=that.fIgnoreTPCzRangeMin;
344 fCutChi2PerClusterTPC=that.fCutChi2PerClusterTPC;
345 fMaxChi2PerClusterTPC=that.fMaxChi2PerClusterTPC;
346 fMinChi2PerClusterTPC=that.fMinChi2PerClusterTPC;
347 fCutNClustersTPC=that.fCutNClustersTPC;
348 fNClustersTPCMax=that.fNClustersTPCMax;
349 fNClustersTPCMin=that.fNClustersTPCMin;
350 fCutNClustersITS=that.fCutNClustersITS;
351 fNClustersITSMax=that.fNClustersITSMax;
352 fNClustersITSMin=that.fNClustersITSMin;
353 fUseAODFilterBit=that.fUseAODFilterBit;
354 fAODFilterBit=that.fAODFilterBit;
355 fCutDCAToVertexXY=that.fCutDCAToVertexXY;
356 fCutDCAToVertexZ=that.fCutDCAToVertexZ;
357 fCutMinimalTPCdedx=that.fCutMinimalTPCdedx;
358 fMinimalTPCdedx=that.fMinimalTPCdedx;
359 fLinearizeVZEROresponse=that.fLinearizeVZEROresponse;
360 fCutPmdDet=that.fCutPmdDet;
361 fPmdDet=that.fPmdDet;
362 fCutPmdAdc=that.fCutPmdAdc;
363 fPmdAdc=that.fPmdAdc;
364 fCutPmdNcell=that.fCutPmdNcell;
365 fPmdNcell=that.fPmdNcell;
366 fFlowTagType=that.fFlowTagType;
368 fParamType=that.fParamType;
369 fParamMix=that.fParamMix;
380 fESDpid = that.fESDpid;
381 fPIDsource = that.fPIDsource;
385 if (that.fTPCpidCuts) fTPCpidCuts = new TMatrixF(*(that.fTPCpidCuts));
386 if (that.fTOFpidCuts) fTOFpidCuts = new TMatrixF(*(that.fTOFpidCuts));
388 fParticleID=that.fParticleID;
389 fParticleProbability=that.fParticleProbability;
390 fAllowTOFmismatchFlag=that.fAllowTOFmismatchFlag;
391 fRequireStrictTOFTPCagreement=that.fRequireStrictTOFTPCagreement;
392 fCutRejectElectronsWithTPCpid=that.fCutRejectElectronsWithTPCpid;
393 fProbBayes = that.fProbBayes;
394 fCurrCentr = that.fCurrCentr;
396 // New PID procedure (Bayesian Combined PID)
397 fBayesianResponse = new AliFlowBayesianPID();
398 fBayesianResponse->SetNewTrackParam();
403 //-----------------------------------------------------------------------
404 AliFlowTrackCuts::~AliFlowTrackCuts()
407 delete fAliESDtrackCuts;
410 if (fQA) { fQA->SetOwner(); fQA->Delete(); delete fQA; }
413 //-----------------------------------------------------------------------
414 void AliFlowTrackCuts::SetEvent(AliVEvent* event, AliMCEvent* mcEvent)
421 //do the magic for ESD
422 AliESDEvent* myESD = dynamic_cast<AliESDEvent*>(event);
423 if (fCutPID && myESD)
425 //TODO: maybe call it only for the TOF options?
426 // Added by F. Noferini for TOF PID
427 // old procedure now implemented inside fBayesianResponse
428 // fESDpid.MakePID(myESD,kFALSE);
430 fBayesianResponse->SetDetResponse(myESD, fCurrCentr,AliESDpid::kTOF_T0,kTRUE); // centrality = PbPb centrality class (0-100%) or -1 for pp collisions
431 fESDpid.SetTOFResponse(myESD,AliESDpid::kTOF_T0);
432 // End F. Noferini added part
438 //-----------------------------------------------------------------------
439 void AliFlowTrackCuts::SetCutMC( Bool_t b )
441 //will we be cutting on MC information?
444 //if we cut on MC info then also the Bethe Bloch should be the one tuned for MC
447 fESDpid.GetTPCResponse().SetBetheBlochParameters( 2.15898e+00/50.,
455 //-----------------------------------------------------------------------
456 Bool_t AliFlowTrackCuts::IsSelected(TObject* obj, Int_t id)
459 AliVParticle* vparticle = dynamic_cast<AliVParticle*>(obj);
460 if (vparticle) return PassesCuts(vparticle);
461 AliFlowTrackSimple* flowtrack = dynamic_cast<AliFlowTrackSimple*>(obj);
462 if (flowtrack) return PassesCuts(flowtrack);
463 AliMultiplicity* tracklets = dynamic_cast<AliMultiplicity*>(obj);
464 if (tracklets) return PassesCuts(tracklets,id);
465 AliESDPmdTrack* pmdtrack = dynamic_cast<AliESDPmdTrack*>(obj);
466 if (pmdtrack) return PassesPMDcuts(pmdtrack);
467 AliVEvent* vvzero = dynamic_cast<AliVEvent*>(obj); // should be removed; left for protection only
468 if (vvzero) return PassesV0cuts(id);
469 return kFALSE; //default when passed wrong type of object
472 //-----------------------------------------------------------------------
473 Bool_t AliFlowTrackCuts::IsSelectedMCtruth(TObject* obj, Int_t id)
476 AliVParticle* vparticle = dynamic_cast<AliVParticle*>(obj);
479 return PassesMCcuts(fMCevent,(fFakesAreOK)?TMath::Abs(vparticle->GetLabel()):vparticle->GetLabel());
481 AliMultiplicity* tracklets = dynamic_cast<AliMultiplicity*>(obj);
484 Int_t label0 = tracklets->GetLabel(id,0);
485 Int_t label1 = tracklets->GetLabel(id,1);
486 Int_t label = (fFakesAreOK)?TMath::Abs(label0):label0;
487 if (label0!=label1) label = -666;
488 return PassesMCcuts(fMCevent,label);
490 return kFALSE; //default when passed wrong type of object
493 //-----------------------------------------------------------------------
494 Bool_t AliFlowTrackCuts::PassesCuts(const AliFlowTrackSimple* track)
496 //check cuts on a flowtracksimple
498 //clean up from last iteration
500 return AliFlowTrackSimpleCuts::PassesCuts(track);
503 //-----------------------------------------------------------------------
504 Bool_t AliFlowTrackCuts::PassesCuts(const AliMultiplicity* tracklet, Int_t id)
506 //check cuts on a tracklets
508 if (id<0) return kFALSE;
510 //clean up from last iteration, and init label
515 fTrackPhi = tracklet->GetPhi(id);
516 fTrackEta = tracklet->GetEta(id);
518 if (fCutEta) {if ( fTrackEta < fEtaMin || fTrackEta >= fEtaMax ) return kFALSE;}
519 if (fCutPhi) {if ( fTrackPhi < fPhiMin || fTrackPhi >= fPhiMax ) return kFALSE;}
521 //check MC info if available
522 //if the 2 clusters have different label track cannot be good
523 //and should therefore not pass the mc cuts
524 Int_t label0 = tracklet->GetLabel(id,0);
525 Int_t label1 = tracklet->GetLabel(id,1);
526 //if possible get label and mcparticle
527 fTrackLabel = (label0==label1)?tracklet->GetLabel(id,1):-1;
528 if (!fFakesAreOK && fTrackLabel<0) return kFALSE;
529 if (fTrackLabel>=0 && fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
531 if (fCutMC && !PassesMCcuts()) return kFALSE;
535 //-----------------------------------------------------------------------
536 Bool_t AliFlowTrackCuts::PassesMCcuts(AliMCEvent* mcEvent, Int_t label)
539 if (!mcEvent) return kFALSE;
540 if (label<0) return kFALSE;//otherwise AliCMevent prints a warning before returning NULL
541 AliMCParticle* mcparticle = static_cast<AliMCParticle*>(mcEvent->GetTrack(label));
542 if (!mcparticle) {AliError("no MC track"); return kFALSE;}
546 if (IsPhysicalPrimary(mcEvent,label,fRequireTransportBitForPrimaries) != fMCisPrimary) return kFALSE;
550 Int_t pdgCode = mcparticle->PdgCode();
551 if (fIgnoreSignInMCPID)
553 if (TMath::Abs(fMCPID) != TMath::Abs(pdgCode)) return kFALSE;
557 if (fMCPID != pdgCode) return kFALSE;
560 if (fCutMCfirstMotherPID)
563 TParticle* tparticle=mcparticle->Particle();
564 Int_t firstMotherLabel = 0;
565 if (tparticle) { firstMotherLabel = tparticle->GetFirstMother(); }
566 AliVParticle* firstMotherParticle = mcEvent->GetTrack(firstMotherLabel);
567 Int_t pdgcodeFirstMother = 0;
568 if (firstMotherParticle) { pdgcodeFirstMother = firstMotherParticle->PdgCode(); }
569 if (pdgcodeFirstMother != fMCfirstMotherPID) return kFALSE;
571 if ( fCutMCprocessType )
573 TParticle* particle = mcparticle->Particle();
574 Int_t processID = particle->GetUniqueID();
575 if (processID != fMCprocessType ) return kFALSE;
577 if (fCutMChasTrackReferences)
579 if (mcparticle->GetNumberOfTrackReferences()<1) return kFALSE;
584 //-----------------------------------------------------------------------
585 Bool_t AliFlowTrackCuts::PassesMCcuts()
588 if (!fMCevent) return kFALSE;
589 if (fTrackLabel<0) return kFALSE;//otherwise AliCMevent prints a warning before returning NULL
590 fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
591 return PassesMCcuts(fMCevent,fTrackLabel);
594 //-----------------------------------------------------------------------
595 Bool_t AliFlowTrackCuts::PassesCuts(AliVParticle* vparticle)
597 //check cuts for an ESD vparticle
599 ////////////////////////////////////////////////////////////////
600 // start by preparing the track parameters to cut on //////////
601 ////////////////////////////////////////////////////////////////
602 //clean up from last iteration
605 //get the label and the mc particle
606 fTrackLabel = (fFakesAreOK)?TMath::Abs(vparticle->GetLabel()):vparticle->GetLabel();
607 if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
608 else fMCparticle=NULL;
610 Bool_t isMCparticle = kFALSE; //some things are different for MC particles, check!
611 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*>(vparticle);
612 AliAODTrack* aodTrack = NULL;
615 //for an ESD track we do some magic sometimes like constructing TPC only parameters
616 //or doing some hybrid, handle that here
617 HandleESDtrack(esdTrack);
621 HandleVParticle(vparticle);
622 //now check if produced particle is MC
623 isMCparticle = (dynamic_cast<AliMCParticle*>(fTrack))!=NULL;
624 aodTrack = dynamic_cast<AliAODTrack*>(vparticle); //keep the additional dynamic cast out of the way for ESDs
626 ////////////////////////////////////////////////////////////////
627 ////////////////////////////////////////////////////////////////
629 if (!fTrack) return kFALSE;
630 //because it may be different from global, not needed for aodTrack because we dont do anything funky there
631 if (esdTrack) esdTrack = static_cast<AliESDtrack*>(fTrack);
634 //check the common cuts for the current particle fTrack (MC,AOD,ESD)
635 Double_t pt = fTrack->Pt();
636 Double_t p = fTrack->P();
637 if (!fFakesAreOK) {if (fTrackLabel<0) pass=kFALSE;}
638 if (fCutPt) {if (pt < fPtMin || pt >= fPtMax ) pass=kFALSE;}
639 if (fCutEta) {if (fTrack->Eta() < fEtaMin || fTrack->Eta() >= fEtaMax ) pass=kFALSE;}
640 if (fCutPhi) {if (fTrack->Phi() < fPhiMin || fTrack->Phi() >= fPhiMax ) pass=kFALSE;}
641 if (fRequireCharge) {if (fTrack->Charge() == 0) pass=kFALSE;}
642 if (fCutCharge && !isMCparticle) {if (fTrack->Charge() != fCharge) pass=kFALSE;}
643 if (fCutCharge && isMCparticle)
645 //in case of an MC particle the charge is stored in units of 1/3|e|
646 Int_t charge = TMath::Nint(fTrack->Charge()/3.0); //mc particles have charge in units of 1/3e
647 if (charge!=fCharge) pass=kFALSE;
649 //if(fCutPID) {if (fTrack->PID() != fPID) pass=kFALSE;}
651 //when additionally MC info is required
652 if (fCutMC && !PassesMCcuts()) pass=kFALSE;
654 //the case of ESD or AOD
655 if (esdTrack) { if (!PassesESDcuts(esdTrack)) { pass=kFALSE; } }
656 if (aodTrack) { if (!PassesAODcuts(aodTrack)) { pass=kFALSE; } }
662 TParticle* tparticle=fMCparticle->Particle();
663 Int_t processID = tparticle->GetUniqueID();
664 Int_t firstMotherLabel = tparticle->GetFirstMother();
665 Bool_t primary = IsPhysicalPrimary();
667 //mcparticle->Particle()->ProductionVertex(v);
668 //Double_t prodvtxX = v.X();
669 //Double_t prodvtxY = v.Y();
671 Int_t pdgcode = fMCparticle->PdgCode();
672 AliVParticle* firstMotherParticle = fMCevent->GetTrack(firstMotherLabel);
673 Int_t pdgcodeFirstMother = 0;
674 if (firstMotherParticle) {pdgcodeFirstMother = firstMotherParticle->PdgCode();}
677 switch (TMath::Abs(pdgcode))
680 pdg = AliPID::kElectron + 0.5; break;
682 pdg = AliPID::kMuon + 0.5; break;
684 pdg = AliPID::kPion + 0.5; break;
686 pdg = AliPID::kKaon + 0.5; break;
688 pdg = AliPID::kProton + 0.5; break;
690 pdg = AliPID::kUnknown + 0.5; break;
692 pdg = TMath::Sign(pdg,static_cast<Float_t>(pdgcode));
694 Float_t geantCode = 0;
695 switch (pdgcodeFirstMother)
706 case 12: case 14: case 16: //#nu
710 geantCode=5; //#mu^{+}
713 geantCode=6; //#mu^{-}
724 case 130: //K^{0}_{L}
740 geantCode=15; //#bar{p}
743 geantCode=16; //K^{0}_{S}
749 geantCode=18; //#Lambda
752 geantCode=19; //#Sigma^{+}
755 geantCode=20; //#Sigma^{0}
758 geantCode=21; //#Sigma^{-}
761 geantCode=22; //#Theta^{0}
764 geantCode=23; //#Theta^{-}
767 geantCode=24; //#Omega^{-}
770 geantCode=25; //#bar{n}
773 geantCode=26; //#bar{#Lambda}
776 geantCode=27; //#bar{#Sigma}^{-}
779 geantCode=28; //#bar{#Sigma}^{0}
782 geantCode=29; //#bar{#Sigma}^{+}
785 geantCode=30; //#bar{#Theta}^{0}
788 geantCode=31; //#bar{#Theta}^{+}
791 geantCode=32; //#bar{#Omega}^{+}
794 geantCode=33; //#tau^{+}
797 geantCode=34; //#tau^{-}
800 geantCode=35; //D^{+}
803 geantCode=36; //D^{-}
806 geantCode=37; //D^{0}
809 geantCode=38; //#bar{D}^{0}
812 geantCode=39; //D_{s}^{+}
815 geantCode=40; //#bar{D_{s}}^{-}
818 geantCode=41; //#Lambda_{c}^{+}
821 geantCode=42; //W^{+}
824 geantCode=43; //W^{-}
827 geantCode=44; //Z^{0}
834 QAbefore(2)->Fill(p,pdg);
835 QAbefore(3)->Fill(p,primary?0.5:-0.5);
836 QAbefore(4)->Fill(p,static_cast<Float_t>(processID));
837 QAbefore(7)->Fill(p,geantCode+0.5);
838 if (pass) QAafter(2)->Fill(p,pdg);
839 if (pass) QAafter(3)->Fill(p,primary?0.5:-0.5);
840 if (pass) QAafter(4)->Fill(p,static_cast<Float_t>(processID));
841 if (pass) QAafter(7)->Fill(p,geantCode);
845 //true by default, if we didn't set any cuts
849 //_______________________________________________________________________
850 Bool_t AliFlowTrackCuts::PassesAODcuts(const AliAODTrack* track)
855 if (fCutNClustersTPC)
857 Int_t ntpccls = track->GetTPCNcls();
858 if (ntpccls < fNClustersTPCMin || ntpccls > fNClustersTPCMax) pass=kFALSE;
861 if (fCutNClustersITS)
863 Int_t nitscls = track->GetITSNcls();
864 if (nitscls < fNClustersITSMin || nitscls > fNClustersITSMax) pass=kFALSE;
867 if (fCutChi2PerClusterTPC)
869 Double_t chi2tpc = track->Chi2perNDF();
870 if (chi2tpc < fMinChi2PerClusterTPC || chi2tpc > fMaxChi2PerClusterTPC) pass=kFALSE;
873 if (GetRequireTPCRefit() && !(track->GetStatus() & AliESDtrack::kTPCrefit) ) pass=kFALSE;
874 if (GetRequireITSRefit() && !(track->GetStatus() & AliESDtrack::kITSrefit) ) pass=kFALSE;
876 if (fUseAODFilterBit && !track->TestFilterBit(fAODFilterBit)) pass=kFALSE;
878 if (fCutDCAToVertexXY && track->DCA()>GetMaxDCAToVertexXY()) pass=kFALSE;
880 if (fCutDCAToVertexZ && track->ZAtDCA()>GetMaxDCAToVertexZ()) pass=kFALSE;
882 if (track->GetTPCsignal() < fMinimalTPCdedx) pass=kFALSE;
887 //_______________________________________________________________________
888 Bool_t AliFlowTrackCuts::PassesESDcuts(AliESDtrack* track)
890 //check cuts on ESD tracks
894 track->GetImpactParameters(dcaxy,dcaz);
895 const AliExternalTrackParam* pout = track->GetOuterParam();
896 const AliExternalTrackParam* pin = track->GetInnerParam();
897 if (fIgnoreTPCzRange)
901 Double_t zin = pin->GetZ();
902 Double_t zout = pout->GetZ();
903 if (zin*zout<0) pass=kFALSE; //reject if cross the membrane
904 if (zin < fIgnoreTPCzRangeMin || zin > fIgnoreTPCzRangeMax) pass=kFALSE;
905 if (zout < fIgnoreTPCzRangeMin || zout > fIgnoreTPCzRangeMax) pass=kFALSE;
909 Int_t ntpccls = ( fParamType==kTPCstandalone )?
910 track->GetTPCNclsIter1():track->GetTPCNcls();
911 if (fCutChi2PerClusterTPC)
913 Float_t tpcchi2 = (fParamType==kTPCstandalone)?
914 track->GetTPCchi2Iter1():track->GetTPCchi2();
915 tpcchi2 = (ntpccls>0)?tpcchi2/ntpccls:-FLT_MAX;
916 if (tpcchi2<fMinChi2PerClusterTPC || tpcchi2 >=fMaxChi2PerClusterTPC)
920 if (fCutMinimalTPCdedx)
922 if (track->GetTPCsignal() < fMinimalTPCdedx) pass=kFALSE;
925 if (fCutNClustersTPC)
927 if (ntpccls < fNClustersTPCMin || ntpccls > fNClustersTPCMax) pass=kFALSE;
930 Int_t nitscls = track->GetNcls(0);
931 if (fCutNClustersITS)
933 if (nitscls < fNClustersITSMin || nitscls > fNClustersITSMax) pass=kFALSE;
936 //some stuff is still handled by AliESDtrackCuts class - delegate
937 if (fAliESDtrackCuts)
939 if (!fAliESDtrackCuts->IsSelected(track)) pass=kFALSE;
942 //PID part with pid QA
943 Double_t beta = GetBeta(track);
944 Double_t dedx = Getdedx(track);
947 if (pass) QAbefore(0)->Fill(track->GetP(),beta);
948 if (pass) QAbefore(1)->Fill(pin->GetP(),dedx);
950 if (fCutPID && (fParticleID!=AliPID::kUnknown)) //if kUnknown don't cut on PID
952 if (!PassesESDpidCut(track)) pass=kFALSE;
954 if (fCutRejectElectronsWithTPCpid)
956 //reject electrons using standard TPC pid
957 //TODO this should be rethought....
958 Double_t pidTPC[AliPID::kSPECIES];
959 track->GetTPCpid(pidTPC);
960 if (pidTPC[AliPID::kElectron]<fParticleProbability) pass=kFALSE;
964 if (pass) QAafter(0)->Fill(track->GetP(),beta);
965 if (pass) QAafter(1)->Fill(pin->GetP(),dedx);
967 //end pid part with qa
971 Double_t pt = track->Pt();
972 QAbefore(5)->Fill(pt,dcaxy);
973 QAbefore(6)->Fill(pt,dcaz);
974 if (pass) QAafter(5)->Fill(pt,dcaxy);
975 if (pass) QAafter(6)->Fill(pt,dcaz);
981 //-----------------------------------------------------------------------
982 void AliFlowTrackCuts::HandleVParticle(AliVParticle* track)
984 //handle the general case
993 //-----------------------------------------------------------------------
994 void AliFlowTrackCuts::HandleESDtrack(AliESDtrack* track)
1002 case kTPCstandalone:
1003 if (!track->FillTPCOnlyTrack(fTPCtrack))
1010 fTrack = &fTPCtrack;
1011 //recalculate the label and mc particle, they may differ as TPClabel != global label
1012 fTrackLabel = (fFakesAreOK)?TMath::Abs(fTrack->GetLabel()):fTrack->GetLabel();
1013 if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
1014 else fMCparticle=NULL;
1022 //-----------------------------------------------------------------------
1023 Int_t AliFlowTrackCuts::Count(AliVEvent* event)
1025 //calculate the number of track in given event.
1026 //if argument is NULL(default) take the event attached
1028 Int_t multiplicity = 0;
1031 for (Int_t i=0; i<GetNumberOfInputObjects(); i++)
1033 if (IsSelected(GetInputObject(i))) multiplicity++;
1038 for (Int_t i=0; i<event->GetNumberOfTracks(); i++)
1040 if (IsSelected(event->GetTrack(i))) multiplicity++;
1043 return multiplicity;
1046 //-----------------------------------------------------------------------
1047 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts()
1049 //get standard V0 cuts
1050 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard vzero flow cuts");
1051 cuts->SetParamType(kV0);
1052 cuts->SetEtaRange( -10, +10 );
1053 cuts->SetPhiMin( 0 );
1054 cuts->SetPhiMax( TMath::TwoPi() );
1058 //-----------------------------------------------------------------------
1059 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardGlobalTrackCuts2010()
1062 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard Global tracks");
1063 cuts->SetParamType(kGlobal);
1064 cuts->SetPtRange(0.2,5.);
1065 cuts->SetEtaRange(-0.8,0.8);
1066 cuts->SetMinNClustersTPC(70);
1067 cuts->SetMinChi2PerClusterTPC(0.1);
1068 cuts->SetMaxChi2PerClusterTPC(4.0);
1069 cuts->SetMinNClustersITS(2);
1070 cuts->SetRequireITSRefit(kTRUE);
1071 cuts->SetRequireTPCRefit(kTRUE);
1072 cuts->SetMaxDCAToVertexXY(0.3);
1073 cuts->SetMaxDCAToVertexZ(0.3);
1074 cuts->SetAcceptKinkDaughters(kFALSE);
1075 cuts->SetMinimalTPCdedx(10.);
1080 //-----------------------------------------------------------------------
1081 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardTPCStandaloneTrackCuts2010()
1084 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard TPC standalone 2010");
1085 cuts->SetParamType(kTPCstandalone);
1086 cuts->SetPtRange(0.2,5.);
1087 cuts->SetEtaRange(-0.8,0.8);
1088 cuts->SetMinNClustersTPC(70);
1089 cuts->SetMinChi2PerClusterTPC(0.2);
1090 cuts->SetMaxChi2PerClusterTPC(4.0);
1091 cuts->SetMaxDCAToVertexXY(3.0);
1092 cuts->SetMaxDCAToVertexZ(3.0);
1093 cuts->SetDCAToVertex2D(kTRUE);
1094 cuts->SetAcceptKinkDaughters(kFALSE);
1095 cuts->SetMinimalTPCdedx(10.);
1100 //-----------------------------------------------------------------------
1101 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardTPCStandaloneTrackCuts()
1104 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard TPC standalone");
1105 cuts->SetParamType(kTPCstandalone);
1106 cuts->SetPtRange(0.2,5.);
1107 cuts->SetEtaRange(-0.8,0.8);
1108 cuts->SetMinNClustersTPC(70);
1109 cuts->SetMinChi2PerClusterTPC(0.2);
1110 cuts->SetMaxChi2PerClusterTPC(4.0);
1111 cuts->SetMaxDCAToVertexXY(3.0);
1112 cuts->SetMaxDCAToVertexZ(3.0);
1113 cuts->SetDCAToVertex2D(kTRUE);
1114 cuts->SetAcceptKinkDaughters(kFALSE);
1115 cuts->SetMinimalTPCdedx(10.);
1120 //-----------------------------------------------------------------------
1121 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardITSTPCTrackCuts2009(Bool_t selPrimaries)
1124 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard global track cuts 2009");
1125 delete cuts->fAliESDtrackCuts;
1126 cuts->fAliESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(selPrimaries);
1127 cuts->SetParamType(kGlobal);
1131 //-----------------------------------------------------------------------
1132 Bool_t AliFlowTrackCuts::FillFlowTrackGeneric(AliFlowTrack* flowtrack) const
1134 //fill a flow track from tracklet,vzero,pmd,...
1135 TParticle *tmpTParticle=NULL;
1136 AliMCParticle* tmpAliMCParticle=NULL;
1140 flowtrack->SetPhi(fTrackPhi);
1141 flowtrack->SetEta(fTrackEta);
1142 flowtrack->SetWeight(fTrackWeight);
1144 case kTrackWithMCkine:
1145 if (!fMCparticle) return kFALSE;
1146 flowtrack->SetPhi( fMCparticle->Phi() );
1147 flowtrack->SetEta( fMCparticle->Eta() );
1148 flowtrack->SetPt( fMCparticle->Pt() );
1150 case kTrackWithMCpt:
1151 if (!fMCparticle) return kFALSE;
1152 flowtrack->SetPhi(fTrackPhi);
1153 flowtrack->SetEta(fTrackEta);
1154 flowtrack->SetWeight(fTrackWeight);
1155 flowtrack->SetPt(fMCparticle->Pt());
1157 case kTrackWithPtFromFirstMother:
1158 if (!fMCparticle) return kFALSE;
1159 flowtrack->SetPhi(fTrackPhi);
1160 flowtrack->SetEta(fTrackEta);
1161 flowtrack->SetWeight(fTrackWeight);
1162 tmpTParticle = fMCparticle->Particle();
1163 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1164 flowtrack->SetPt(tmpAliMCParticle->Pt());
1167 flowtrack->SetPhi(fTrackPhi);
1168 flowtrack->SetEta(fTrackEta);
1169 flowtrack->SetWeight(fTrackWeight);
1172 flowtrack->SetSource(AliFlowTrack::kFromTracklet);
1176 //-----------------------------------------------------------------------
1177 Bool_t AliFlowTrackCuts::FillFlowTrackVParticle(AliFlowTrack* flowtrack) const
1179 //fill flow track from AliVParticle (ESD,AOD,MC)
1180 if (!fTrack) return kFALSE;
1181 TParticle *tmpTParticle=NULL;
1182 AliMCParticle* tmpAliMCParticle=NULL;
1183 AliExternalTrackParam* externalParams=NULL;
1184 AliESDtrack* esdtrack=NULL;
1188 flowtrack->Set(fTrack);
1190 case kTrackWithMCkine:
1191 flowtrack->Set(fMCparticle);
1193 case kTrackWithMCPID:
1194 flowtrack->Set(fTrack);
1195 //flowtrack->setPID(...) from mc, when implemented
1197 case kTrackWithMCpt:
1198 if (!fMCparticle) return kFALSE;
1199 flowtrack->Set(fTrack);
1200 flowtrack->SetPt(fMCparticle->Pt());
1202 case kTrackWithPtFromFirstMother:
1203 if (!fMCparticle) return kFALSE;
1204 flowtrack->Set(fTrack);
1205 tmpTParticle = fMCparticle->Particle();
1206 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1207 flowtrack->SetPt(tmpAliMCParticle->Pt());
1209 case kTrackWithTPCInnerParams:
1210 esdtrack = dynamic_cast<AliESDtrack*>(fTrack);
1211 if (!esdtrack) return kFALSE;
1212 externalParams = const_cast<AliExternalTrackParam*>(esdtrack->GetTPCInnerParam());
1213 if (!externalParams) return kFALSE;
1214 flowtrack->Set(externalParams);
1217 flowtrack->Set(fTrack);
1220 if (fParamType==kMC)
1222 flowtrack->SetSource(AliFlowTrack::kFromMC);
1223 flowtrack->SetID(fTrackLabel);
1225 else if (dynamic_cast<AliESDtrack*>(fTrack))
1227 flowtrack->SetSource(AliFlowTrack::kFromESD);
1228 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1230 else if (dynamic_cast<AliAODTrack*>(fTrack))
1232 flowtrack->SetSource(AliFlowTrack::kFromAOD);
1233 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1235 else if (dynamic_cast<AliMCParticle*>(fTrack))
1237 flowtrack->SetSource(AliFlowTrack::kFromMC);
1238 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1243 //-----------------------------------------------------------------------
1244 Bool_t AliFlowTrackCuts::FillFlowTrack(AliFlowTrack* track) const
1246 //fill a flow track constructed from whatever we applied cuts on
1247 //return true on success
1251 return FillFlowTrackGeneric(track);
1253 return FillFlowTrackGeneric(track);
1255 return FillFlowTrackGeneric(track);
1257 return FillFlowTrackVParticle(track);
1261 //-----------------------------------------------------------------------
1262 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackSPDtracklet() const
1264 //make a flow track from tracklet
1265 AliFlowTrack* flowtrack=NULL;
1266 TParticle *tmpTParticle=NULL;
1267 AliMCParticle* tmpAliMCParticle=NULL;
1271 flowtrack = new AliFlowTrack();
1272 flowtrack->SetPhi(fTrackPhi);
1273 flowtrack->SetEta(fTrackEta);
1274 flowtrack->SetWeight(fTrackWeight);
1276 case kTrackWithMCkine:
1277 if (!fMCparticle) return NULL;
1278 flowtrack = new AliFlowTrack();
1279 flowtrack->SetPhi( fMCparticle->Phi() );
1280 flowtrack->SetEta( fMCparticle->Eta() );
1281 flowtrack->SetPt( fMCparticle->Pt() );
1283 case kTrackWithMCpt:
1284 if (!fMCparticle) return NULL;
1285 flowtrack = new AliFlowTrack();
1286 flowtrack->SetPhi(fTrackPhi);
1287 flowtrack->SetEta(fTrackEta);
1288 flowtrack->SetWeight(fTrackWeight);
1289 flowtrack->SetPt(fMCparticle->Pt());
1291 case kTrackWithPtFromFirstMother:
1292 if (!fMCparticle) return NULL;
1293 flowtrack = new AliFlowTrack();
1294 flowtrack->SetPhi(fTrackPhi);
1295 flowtrack->SetEta(fTrackEta);
1296 flowtrack->SetWeight(fTrackWeight);
1297 tmpTParticle = fMCparticle->Particle();
1298 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1299 flowtrack->SetPt(tmpAliMCParticle->Pt());
1302 flowtrack = new AliFlowTrack();
1303 flowtrack->SetPhi(fTrackPhi);
1304 flowtrack->SetEta(fTrackEta);
1305 flowtrack->SetWeight(fTrackWeight);
1308 flowtrack->SetSource(AliFlowTrack::kFromTracklet);
1312 //-----------------------------------------------------------------------
1313 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackVParticle() const
1315 //make flow track from AliVParticle (ESD,AOD,MC)
1316 if (!fTrack) return NULL;
1317 AliFlowTrack* flowtrack=NULL;
1318 TParticle *tmpTParticle=NULL;
1319 AliMCParticle* tmpAliMCParticle=NULL;
1320 AliExternalTrackParam* externalParams=NULL;
1321 AliESDtrack* esdtrack=NULL;
1325 flowtrack = new AliFlowTrack(fTrack);
1327 case kTrackWithMCkine:
1328 flowtrack = new AliFlowTrack(fMCparticle);
1330 case kTrackWithMCPID:
1331 flowtrack = new AliFlowTrack(fTrack);
1332 //flowtrack->setPID(...) from mc, when implemented
1334 case kTrackWithMCpt:
1335 if (!fMCparticle) return NULL;
1336 flowtrack = new AliFlowTrack(fTrack);
1337 flowtrack->SetPt(fMCparticle->Pt());
1339 case kTrackWithPtFromFirstMother:
1340 if (!fMCparticle) return NULL;
1341 flowtrack = new AliFlowTrack(fTrack);
1342 tmpTParticle = fMCparticle->Particle();
1343 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1344 flowtrack->SetPt(tmpAliMCParticle->Pt());
1346 case kTrackWithTPCInnerParams:
1347 esdtrack = dynamic_cast<AliESDtrack*>(fTrack);
1348 if (!esdtrack) return NULL;
1349 externalParams = const_cast<AliExternalTrackParam*>(esdtrack->GetTPCInnerParam());
1350 if (!externalParams) return NULL;
1351 flowtrack = new AliFlowTrack(externalParams);
1354 flowtrack = new AliFlowTrack(fTrack);
1357 if (fParamType==kMC)
1359 flowtrack->SetSource(AliFlowTrack::kFromMC);
1360 flowtrack->SetID(fTrackLabel);
1362 else if (dynamic_cast<AliESDtrack*>(fTrack))
1364 flowtrack->SetSource(AliFlowTrack::kFromESD);
1365 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1367 else if (dynamic_cast<AliAODTrack*>(fTrack))
1369 flowtrack->SetSource(AliFlowTrack::kFromAOD);
1370 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1372 else if (dynamic_cast<AliMCParticle*>(fTrack))
1374 flowtrack->SetSource(AliFlowTrack::kFromMC);
1375 flowtrack->SetID(static_cast<AliVTrack*>(fTrack)->GetID());
1380 //-----------------------------------------------------------------------
1381 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackPMDtrack() const
1383 //make a flow track from PMD track
1384 AliFlowTrack* flowtrack=NULL;
1385 TParticle *tmpTParticle=NULL;
1386 AliMCParticle* tmpAliMCParticle=NULL;
1390 flowtrack = new AliFlowTrack();
1391 flowtrack->SetPhi(fTrackPhi);
1392 flowtrack->SetEta(fTrackEta);
1393 flowtrack->SetWeight(fTrackWeight);
1395 case kTrackWithMCkine:
1396 if (!fMCparticle) return NULL;
1397 flowtrack = new AliFlowTrack();
1398 flowtrack->SetPhi( fMCparticle->Phi() );
1399 flowtrack->SetEta( fMCparticle->Eta() );
1400 flowtrack->SetWeight(fTrackWeight);
1401 flowtrack->SetPt( fMCparticle->Pt() );
1403 case kTrackWithMCpt:
1404 if (!fMCparticle) return NULL;
1405 flowtrack = new AliFlowTrack();
1406 flowtrack->SetPhi(fTrackPhi);
1407 flowtrack->SetEta(fTrackEta);
1408 flowtrack->SetWeight(fTrackWeight);
1409 flowtrack->SetPt(fMCparticle->Pt());
1411 case kTrackWithPtFromFirstMother:
1412 if (!fMCparticle) return NULL;
1413 flowtrack = new AliFlowTrack();
1414 flowtrack->SetPhi(fTrackPhi);
1415 flowtrack->SetEta(fTrackEta);
1416 flowtrack->SetWeight(fTrackWeight);
1417 tmpTParticle = fMCparticle->Particle();
1418 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1419 flowtrack->SetPt(tmpAliMCParticle->Pt());
1422 flowtrack = new AliFlowTrack();
1423 flowtrack->SetPhi(fTrackPhi);
1424 flowtrack->SetEta(fTrackEta);
1425 flowtrack->SetWeight(fTrackWeight);
1429 flowtrack->SetSource(AliFlowTrack::kFromPMD);
1433 //-----------------------------------------------------------------------
1434 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrackV0() const
1436 //make a flow track from V0
1437 AliFlowTrack* flowtrack=NULL;
1438 TParticle *tmpTParticle=NULL;
1439 AliMCParticle* tmpAliMCParticle=NULL;
1443 flowtrack = new AliFlowTrack();
1444 flowtrack->SetPhi(fTrackPhi);
1445 flowtrack->SetEta(fTrackEta);
1446 flowtrack->SetWeight(fTrackWeight);
1448 case kTrackWithMCkine:
1449 if (!fMCparticle) return NULL;
1450 flowtrack = new AliFlowTrack();
1451 flowtrack->SetPhi( fMCparticle->Phi() );
1452 flowtrack->SetEta( fMCparticle->Eta() );
1453 flowtrack->SetWeight(fTrackWeight);
1454 flowtrack->SetPt( fMCparticle->Pt() );
1456 case kTrackWithMCpt:
1457 if (!fMCparticle) return NULL;
1458 flowtrack = new AliFlowTrack();
1459 flowtrack->SetPhi(fTrackPhi);
1460 flowtrack->SetEta(fTrackEta);
1461 flowtrack->SetWeight(fTrackWeight);
1462 flowtrack->SetPt(fMCparticle->Pt());
1464 case kTrackWithPtFromFirstMother:
1465 if (!fMCparticle) return NULL;
1466 flowtrack = new AliFlowTrack();
1467 flowtrack->SetPhi(fTrackPhi);
1468 flowtrack->SetEta(fTrackEta);
1469 flowtrack->SetWeight(fTrackWeight);
1470 tmpTParticle = fMCparticle->Particle();
1471 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
1472 flowtrack->SetPt(tmpAliMCParticle->Pt());
1475 flowtrack = new AliFlowTrack();
1476 flowtrack->SetPhi(fTrackPhi);
1477 flowtrack->SetEta(fTrackEta);
1478 flowtrack->SetWeight(fTrackWeight);
1482 flowtrack->SetSource(AliFlowTrack::kFromV0);
1486 //-----------------------------------------------------------------------
1487 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrack() const
1489 //get a flow track constructed from whatever we applied cuts on
1490 //caller is resposible for deletion
1491 //if construction fails return NULL
1492 //TODO: for tracklets, PMD and V0 we probably need just one method,
1493 //something like MakeFlowTrackGeneric(), wait with this until
1494 //requirements quirks are known.
1498 return MakeFlowTrackSPDtracklet();
1500 return MakeFlowTrackPMDtrack();
1502 return MakeFlowTrackV0();
1504 return MakeFlowTrackVParticle();
1508 //-----------------------------------------------------------------------
1509 Bool_t AliFlowTrackCuts::IsPhysicalPrimary() const
1511 //check if current particle is a physical primary
1512 if (!fMCevent) return kFALSE;
1513 if (fTrackLabel<0) return kFALSE;
1514 return IsPhysicalPrimary(fMCevent, fTrackLabel, fRequireTransportBitForPrimaries);
1517 //-----------------------------------------------------------------------
1518 Bool_t AliFlowTrackCuts::IsPhysicalPrimary(AliMCEvent* mcEvent, Int_t label, Bool_t requiretransported)
1520 //check if current particle is a physical primary
1521 Bool_t physprim=mcEvent->IsPhysicalPrimary(label);
1522 AliMCParticle* track = static_cast<AliMCParticle*>(mcEvent->GetTrack(label));
1523 if (!track) return kFALSE;
1524 TParticle* particle = track->Particle();
1525 Bool_t transported = particle->TestBit(kTransportBit);
1526 //printf("label: %i prim: %s, transp: %s, pass: %s\n",label, (physprim)?"YES":"NO ",(transported)?"YES":"NO ",
1527 //(physprim && (transported || !requiretransported))?"YES":"NO" );
1528 return (physprim && (transported || !requiretransported));
1531 //-----------------------------------------------------------------------
1532 void AliFlowTrackCuts::DefineHistograms()
1534 //define qa histograms
1537 const Int_t kNbinsP=200;
1538 Double_t binsP[kNbinsP+1];
1540 for(int i=1; i<kNbinsP+1; i++)
1542 //if(binsP[i-1]+0.05<1.01)
1543 // binsP[i]=binsP[i-1]+0.05;
1545 binsP[i]=binsP[i-1]+0.05;
1548 const Int_t nBinsDCA=1000;
1549 Double_t binsDCA[nBinsDCA+1];
1550 for(int i=0; i<nBinsDCA+1; i++) {binsDCA[i]=0.01*i-5.;}
1551 //for(int i=1; i<41; i++) {binsDCA[i+100]=0.1*i+1.0;}
1553 Bool_t adddirstatus = TH1::AddDirectoryStatus();
1554 TH1::AddDirectory(kFALSE);
1555 fQA=new TList(); fQA->SetOwner();
1556 fQA->SetName(Form("%s QA",GetName()));
1557 TList* before = new TList(); before->SetOwner();
1558 before->SetName("before");
1559 TList* after = new TList(); after->SetOwner();
1560 after->SetName("after");
1563 before->Add(new TH2F("TOFbeta",";p [GeV/c];#beta",kNbinsP,binsP,1000,0.4,1.1)); //0
1564 after->Add(new TH2F("TOFbeta",";p [GeV/c];#beta",kNbinsP,binsP,1000,0.4,1.1)); //0
1565 before->Add(new TH2F("TPCdedx",";p [GeV/c];dEdx",kNbinsP,binsP,500,0,500)); //1
1566 after->Add(new TH2F("TPCdedx",";p [GeV/c];dEdx",kNbinsP,binsP,500,0,500)); //1
1567 before->Add(new TH2F("MC pid",";p[GeV/c];species",kNbinsP,binsP,10,-5, 5)); //2
1568 after->Add(new TH2F("MC pid",";p[GeV/c];species",kNbinsP,binsP,10,-5, 5)); //2
1570 TH2F* hb = new TH2F("MC primary",";p[GeV/c];primary",kNbinsP,binsP,2,-1,1);
1571 TH2F* ha = new TH2F("MC primary",";p[GeV/c];primary",kNbinsP,binsP,2,-1,1);
1573 axis = hb->GetYaxis();
1574 axis->SetBinLabel(1,"secondary");
1575 axis->SetBinLabel(2,"primary");
1576 axis = ha->GetYaxis();
1577 axis->SetBinLabel(1,"secondary");
1578 axis->SetBinLabel(2,"primary");
1579 before->Add(hb); //3
1581 //production process
1582 hb = new TH2F("MC production process",";p[GeV/c];",kNbinsP,binsP,kMaxMCProcess,
1583 -0.5, kMaxMCProcess-0.5);
1584 ha = new TH2F("MC production process",";p[GeV/c];",kNbinsP,binsP,kMaxMCProcess,
1585 -0.5, kMaxMCProcess-0.5);
1586 axis = hb->GetYaxis();
1587 for (Int_t i=0; i<kMaxMCProcess; i++)
1589 axis->SetBinLabel(i+1,TMCProcessName[i]);
1591 axis = ha->GetYaxis();
1592 for (Int_t i=0; i<kMaxMCProcess; i++)
1594 axis->SetBinLabel(i+1,TMCProcessName[i]);
1596 before->Add(hb); //4
1599 before->Add(new TH2F("DCAxy",";p_{t}[GeV/c];DCAxy[cm]", 100, 0., 10., nBinsDCA, binsDCA));//5
1600 after->Add(new TH2F("DCAxy",";p_{t}[GeV/c];DCAxy[cm]", 100, 0., 10., nBinsDCA, binsDCA));//5
1601 before->Add(new TH2F("DCAz",";p_{t}[GeV/c];DCAz[cm]", 100, 0., 10., nBinsDCA, binsDCA));//6
1602 after->Add(new TH2F("DCAz",";p_{t}[GeV/c];DCAz[cm]", 100, 0., 10., nBinsDCA, binsDCA));//6
1604 hb = new TH2F("MC first mother",";p[GeV/c];",kNbinsP,binsP,44,1.,45.);
1605 ha = new TH2F("MC first mother",";p[GeV/c];",kNbinsP,binsP,44,1.,45.);
1606 hb->GetYaxis()->SetBinLabel(1, "#gamma");
1607 ha->GetYaxis()->SetBinLabel(1, "#gamma");
1608 hb->GetYaxis()->SetBinLabel(2, "e^{+}");
1609 ha->GetYaxis()->SetBinLabel(2, "e^{+}");
1610 hb->GetYaxis()->SetBinLabel(3, "e^{-}");
1611 ha->GetYaxis()->SetBinLabel(3, "e^{-}");
1612 hb->GetYaxis()->SetBinLabel(4, "#nu");
1613 ha->GetYaxis()->SetBinLabel(4, "#nu");
1614 hb->GetYaxis()->SetBinLabel(5, "#mu^{+}");
1615 ha->GetYaxis()->SetBinLabel(5, "#mu^{+}");
1616 hb->GetYaxis()->SetBinLabel(6, "#mu^{-}");
1617 ha->GetYaxis()->SetBinLabel(6, "#mu^{-}");
1618 hb->GetYaxis()->SetBinLabel(7, "#pi^{0}");
1619 ha->GetYaxis()->SetBinLabel(7, "#pi^{0}");
1620 hb->GetYaxis()->SetBinLabel(8, "#pi^{+}");
1621 ha->GetYaxis()->SetBinLabel(8, "#pi^{+}");
1622 hb->GetYaxis()->SetBinLabel(9, "#pi^{-}");
1623 ha->GetYaxis()->SetBinLabel(9, "#pi^{-}");
1624 hb->GetYaxis()->SetBinLabel(10, "K^{0}_{L}");
1625 ha->GetYaxis()->SetBinLabel(10, "K^{0}_{L}");
1626 hb->GetYaxis()->SetBinLabel(11, "K^{+}");
1627 ha->GetYaxis()->SetBinLabel(11, "K^{+}");
1628 hb->GetYaxis()->SetBinLabel(12, "K^{-}");
1629 ha->GetYaxis()->SetBinLabel(12, "K^{-}");
1630 hb->GetYaxis()->SetBinLabel( 13, "n");
1631 ha->GetYaxis()->SetBinLabel( 13, "n");
1632 hb->GetYaxis()->SetBinLabel( 14, "p");
1633 ha->GetYaxis()->SetBinLabel( 14, "p");
1634 hb->GetYaxis()->SetBinLabel(15, "#bar{p}");
1635 ha->GetYaxis()->SetBinLabel(15, "#bar{p}");
1636 hb->GetYaxis()->SetBinLabel(16, "K^{0}_{S}");
1637 ha->GetYaxis()->SetBinLabel(16, "K^{0}_{S}");
1638 hb->GetYaxis()->SetBinLabel(17, "#eta");
1639 ha->GetYaxis()->SetBinLabel(17, "#eta");
1640 hb->GetYaxis()->SetBinLabel(18, "#Lambda");
1641 ha->GetYaxis()->SetBinLabel(18, "#Lambda");
1642 hb->GetYaxis()->SetBinLabel(19, "#Sigma^{+}");
1643 ha->GetYaxis()->SetBinLabel(19, "#Sigma^{+}");
1644 hb->GetYaxis()->SetBinLabel(20, "#Sigma^{0}");
1645 ha->GetYaxis()->SetBinLabel(20, "#Sigma^{0}");
1646 hb->GetYaxis()->SetBinLabel(21, "#Sigma^{-}");
1647 ha->GetYaxis()->SetBinLabel(21, "#Sigma^{-}");
1648 hb->GetYaxis()->SetBinLabel(22, "#Theta^{0}");
1649 ha->GetYaxis()->SetBinLabel(22, "#Theta^{0}");
1650 hb->GetYaxis()->SetBinLabel(23, "#Theta^{-}");
1651 ha->GetYaxis()->SetBinLabel(23, "#Theta^{-}");
1652 hb->GetYaxis()->SetBinLabel(24, "#Omega^{-}");
1653 ha->GetYaxis()->SetBinLabel(24, "#Omega^{-}");
1654 hb->GetYaxis()->SetBinLabel(25, "#bar{n}");
1655 ha->GetYaxis()->SetBinLabel(25, "#bar{n}");
1656 hb->GetYaxis()->SetBinLabel(26, "#bar{#Lambda}");
1657 ha->GetYaxis()->SetBinLabel(26, "#bar{#Lambda}");
1658 hb->GetYaxis()->SetBinLabel(27, "#bar{#Sigma}^{-}");
1659 ha->GetYaxis()->SetBinLabel(27, "#bar{#Sigma}^{-}");
1660 hb->GetYaxis()->SetBinLabel(28, "#bar{#Sigma}^{0}");
1661 ha->GetYaxis()->SetBinLabel(28, "#bar{#Sigma}^{0}");
1662 hb->GetYaxis()->SetBinLabel(29, "#bar{#Sigma}^{+}");
1663 ha->GetYaxis()->SetBinLabel(29, "#bar{#Sigma}^{+}");
1664 hb->GetYaxis()->SetBinLabel(30, "#bar{#Theta}^{0}");
1665 ha->GetYaxis()->SetBinLabel(30, "#bar{#Theta}^{0}");
1666 hb->GetYaxis()->SetBinLabel(31, "#bar{#Theta}^{+}");
1667 ha->GetYaxis()->SetBinLabel(31, "#bar{#Theta}^{+}");
1668 hb->GetYaxis()->SetBinLabel(32, "#bar{#Omega}^{+}");
1669 ha->GetYaxis()->SetBinLabel(32, "#bar{#Omega}^{+}");
1670 hb->GetYaxis()->SetBinLabel(33, "#tau^{+}");
1671 ha->GetYaxis()->SetBinLabel(33, "#tau^{+}");
1672 hb->GetYaxis()->SetBinLabel(34, "#tau^{-}");
1673 ha->GetYaxis()->SetBinLabel(34, "#tau^{-}");
1674 hb->GetYaxis()->SetBinLabel(35, "D^{+}");
1675 ha->GetYaxis()->SetBinLabel(35, "D^{+}");
1676 hb->GetYaxis()->SetBinLabel(36, "D^{-}");
1677 ha->GetYaxis()->SetBinLabel(36, "D^{-}");
1678 hb->GetYaxis()->SetBinLabel(37, "D^{0}");
1679 ha->GetYaxis()->SetBinLabel(37, "D^{0}");
1680 hb->GetYaxis()->SetBinLabel(38, "#bar{D}^{0}");
1681 ha->GetYaxis()->SetBinLabel(38, "#bar{D}^{0}");
1682 hb->GetYaxis()->SetBinLabel(39, "D_{s}^{+}");
1683 ha->GetYaxis()->SetBinLabel(39, "D_{s}^{+}");
1684 hb->GetYaxis()->SetBinLabel(40, "#bar{D_{s}}^{-}");
1685 ha->GetYaxis()->SetBinLabel(40, "#bar{D_{s}}^{-}");
1686 hb->GetYaxis()->SetBinLabel(41, "#Lambda_{c}^{+}");
1687 ha->GetYaxis()->SetBinLabel(41, "#Lambda_{c}^{+}");
1688 hb->GetYaxis()->SetBinLabel(42, "W^{+}");
1689 ha->GetYaxis()->SetBinLabel(42, "W^{+}");
1690 hb->GetYaxis()->SetBinLabel(43, "W^{-}");
1691 ha->GetYaxis()->SetBinLabel(43, "W^{-}");
1692 hb->GetYaxis()->SetBinLabel(44, "Z^{0}");
1693 ha->GetYaxis()->SetBinLabel(44, "Z^{0}");
1697 TH1::AddDirectory(adddirstatus);
1700 //-----------------------------------------------------------------------
1701 Int_t AliFlowTrackCuts::GetNumberOfInputObjects() const
1703 //get the number of tracks in the input event according source
1704 //selection (ESD tracks, tracklets, MC particles etc.)
1705 AliESDEvent* esd=NULL;
1709 esd = dynamic_cast<AliESDEvent*>(fEvent);
1711 return esd->GetMultiplicity()->GetNumberOfTracklets();
1713 if (!fMCevent) return 0;
1714 return fMCevent->GetNumberOfTracks();
1716 esd = dynamic_cast<AliESDEvent*>(fEvent);
1718 return esd->GetNumberOfPmdTracks();
1720 return fgkNumberOfV0tracks;
1722 if (!fEvent) return 0;
1723 return fEvent->GetNumberOfTracks();
1728 //-----------------------------------------------------------------------
1729 TObject* AliFlowTrackCuts::GetInputObject(Int_t i)
1731 //get the input object according the data source selection:
1732 //(esd tracks, traclets, mc particles,etc...)
1733 AliESDEvent* esd=NULL;
1737 esd = dynamic_cast<AliESDEvent*>(fEvent);
1738 if (!esd) return NULL;
1739 return const_cast<AliMultiplicity*>(esd->GetMultiplicity());
1741 if (!fMCevent) return NULL;
1742 return fMCevent->GetTrack(i);
1744 esd = dynamic_cast<AliESDEvent*>(fEvent);
1745 if (!esd) return NULL;
1746 return esd->GetPmdTrack(i);
1748 //esd = dynamic_cast<AliESDEvent*>(fEvent);
1749 //if (!esd) //contributed by G.Ortona
1751 // AliAODEvent* aod = dynamic_cast<AliAODEvent*>(fEvent);
1752 // if(!aod)return NULL;
1753 // return aod->GetVZEROData();
1755 //return esd->GetVZEROData();
1756 return fEvent; // left only for compatibility
1758 if (!fEvent) return NULL;
1759 return fEvent->GetTrack(i);
1763 //-----------------------------------------------------------------------
1764 void AliFlowTrackCuts::Clear(Option_t*)
1776 //-----------------------------------------------------------------------
1777 Bool_t AliFlowTrackCuts::PassesESDpidCut(const AliESDtrack* track )
1779 //check if passes the selected pid cut for ESDs
1780 Bool_t pass = kTRUE;
1784 if (!PassesTPCpidCut(track)) pass=kFALSE;
1787 if (!PassesTPCdedxCut(track)) pass=kFALSE;
1790 if (!PassesTOFpidCut(track)) pass=kFALSE;
1793 if (!PassesTOFbetaCut(track)) pass=kFALSE;
1795 case kTOFbetaSimple:
1796 if (!PassesTOFbetaSimpleCut(track)) pass=kFALSE;
1799 if (!PassesTPCbayesianCut(track)) pass=kFALSE;
1801 // part added by F. Noferini
1803 if (!PassesTOFbayesianCut(track)) pass=kFALSE;
1805 // end part added by F. Noferini
1807 //part added by Natasha
1809 if (!PassesNucleiSelection(track)) pass=kFALSE;
1811 //end part added by Natasha
1814 printf("AliFlowTrackCuts::PassesCuts() this should never be called!\n");
1821 //-----------------------------------------------------------------------
1822 Bool_t AliFlowTrackCuts::PassesTOFbetaSimpleCut(const AliESDtrack* track )
1824 //check if passes PID cut using timing in TOF
1825 Bool_t goodtrack = (track->GetStatus() & AliESDtrack::kTOFpid) &&
1826 (track->GetTOFsignal() > 12000) &&
1827 (track->GetTOFsignal() < 100000) &&
1828 (track->GetIntegratedLength() > 365);
1830 if (!fAllowTOFmismatchFlag) {if ((track->GetStatus() & AliESDtrack::kTOFmismatch)) return kFALSE;}
1832 Bool_t statusMatchingHard = TPCTOFagree(track);
1833 if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
1836 if (!goodtrack) return kFALSE;
1838 const Float_t c = 2.99792457999999984e-02;
1839 Float_t p = track->GetP();
1840 Float_t l = track->GetIntegratedLength();
1841 Float_t trackT0 = fESDpid.GetTOFResponse().GetStartTime(p);
1842 Float_t timeTOF = track->GetTOFsignal()- trackT0;
1843 Float_t beta = l/timeTOF/c;
1844 Double_t integratedTimes[5] = {-1.0,-1.0,-1.0,-1.0,-1.0};
1845 track->GetIntegratedTimes(integratedTimes);
1846 Float_t betaHypothesis[5] = {0.0,0.0,0.0,0.0,0.0};
1847 Float_t s[5] = {0.0,0.0,0.0,0.0,0.0};
1848 for (Int_t i=0;i<5;i++)
1850 betaHypothesis[i] = l/integratedTimes[i]/c;
1851 s[i] = beta-betaHypothesis[i];
1854 switch (fParticleID)
1857 return ( (s[2]<0.015) && (s[2]>-0.015) &&
1861 return ( (s[3]<0.015) && (s[3]>-0.015) &&
1864 case AliPID::kProton:
1865 return ( (s[4]<0.015) && (s[4]>-0.015) &&
1874 //-----------------------------------------------------------------------
1875 Float_t AliFlowTrackCuts::GetBeta(const AliESDtrack* track)
1878 const Float_t c = 2.99792457999999984e-02;
1879 Float_t p = track->GetP();
1880 Float_t l = track->GetIntegratedLength();
1881 Float_t trackT0 = fESDpid.GetTOFResponse().GetStartTime(p);
1882 Float_t timeTOF = track->GetTOFsignal()- trackT0;
1886 //-----------------------------------------------------------------------
1887 Bool_t AliFlowTrackCuts::PassesTOFbetaCut(const AliESDtrack* track )
1889 //check if track passes pid selection with an asymmetric TOF beta cut
1892 //printf("no TOFpidCuts\n");
1896 //check if passes PID cut using timing in TOF
1897 Bool_t goodtrack = (track->GetStatus() & AliESDtrack::kTOFpid) &&
1898 (track->GetTOFsignal() > 12000) &&
1899 (track->GetTOFsignal() < 100000) &&
1900 (track->GetIntegratedLength() > 365);
1902 if (!fAllowTOFmismatchFlag) {if ((track->GetStatus() & AliESDtrack::kTOFmismatch)) return kFALSE;}
1904 Bool_t statusMatchingHard = TPCTOFagree(track);
1905 if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
1908 if (!goodtrack) return kFALSE;
1910 Float_t beta = GetBeta(track);
1912 Double_t integratedTimes[5] = {-1.0,-1.0,-1.0,-1.0,-1.0};
1913 track->GetIntegratedTimes(integratedTimes);
1915 //construct the pid index because it's not AliPID::EParticleType
1917 switch (fParticleID)
1925 case AliPID::kProton:
1933 const Float_t c = 2.99792457999999984e-02;
1934 Float_t l = track->GetIntegratedLength();
1935 Float_t p = track->GetP();
1936 Float_t betahypothesis = l/integratedTimes[pid]/c;
1937 Float_t betadiff = beta-betahypothesis;
1939 Float_t* arr = fTOFpidCuts->GetMatrixArray();
1940 Int_t col = TMath::BinarySearch(fTOFpidCuts->GetNcols(),arr,static_cast<Float_t>(p));
1941 if (col<0) return kFALSE;
1942 Float_t min = (*fTOFpidCuts)(1,col);
1943 Float_t max = (*fTOFpidCuts)(2,col);
1945 Bool_t pass = (betadiff>min && betadiff<max);
1950 //-----------------------------------------------------------------------
1951 Bool_t AliFlowTrackCuts::PassesTOFpidCut(const AliESDtrack* track) const
1953 //check if passes PID cut using default TOF pid
1954 Double_t pidTOF[AliPID::kSPECIES];
1955 track->GetTOFpid(pidTOF);
1956 if (pidTOF[fParticleID]>=fParticleProbability) return kTRUE;
1960 //-----------------------------------------------------------------------
1961 Bool_t AliFlowTrackCuts::PassesTPCpidCut(const AliESDtrack* track) const
1963 //check if passes PID cut using default TPC pid
1964 Double_t pidTPC[AliPID::kSPECIES];
1965 track->GetTPCpid(pidTPC);
1966 Double_t probablity = 0.;
1967 switch (fParticleID)
1970 probablity = pidTPC[AliPID::kPion] + pidTPC[AliPID::kMuon];
1973 probablity = pidTPC[fParticleID];
1975 if (probablity >= fParticleProbability) return kTRUE;
1979 //-----------------------------------------------------------------------
1980 Float_t AliFlowTrackCuts::Getdedx(const AliESDtrack* track) const
1983 return track->GetTPCsignal();
1986 //-----------------------------------------------------------------------
1987 Bool_t AliFlowTrackCuts::PassesTPCdedxCut(const AliESDtrack* track)
1989 //check if passes PID cut using dedx signal in the TPC
1992 //printf("no TPCpidCuts\n");
1996 const AliExternalTrackParam* tpcparam = track->GetInnerParam(); //tpc only params at the inner wall
1997 if (!tpcparam) return kFALSE;
1998 Double_t p = tpcparam->GetP();
1999 Float_t sigExp = fESDpid.GetTPCResponse().GetExpectedSignal(p, fParticleID);
2000 Float_t sigTPC = track->GetTPCsignal();
2001 Float_t s = (sigTPC-sigExp)/sigExp;
2003 Float_t* arr = fTPCpidCuts->GetMatrixArray();
2004 Int_t arrSize = fTPCpidCuts->GetNcols();
2005 Int_t col = TMath::BinarySearch( arrSize, arr, static_cast<Float_t>(p));
2006 if (col<0) return kFALSE;
2007 Float_t min = (*fTPCpidCuts)(1,col);
2008 Float_t max = (*fTPCpidCuts)(2,col);
2010 //printf("------------TPC pid cut %s\n",(s>min && s<max)?"PASS":"FAIL");
2011 return (s>min && s<max);
2014 //-----------------------------------------------------------------------
2015 void AliFlowTrackCuts::InitPIDcuts()
2017 //init matrices with PID cuts
2021 if (fParticleID==AliPID::kPion)
2023 t = new TMatrixF(3,15);
2024 (*t)(0,0) = 0.20; (*t)(1,0) = -0.4; (*t)(2,0) = 0.0;
2025 (*t)(0,1) = 0.25; (*t)(1,1) = -0.4; (*t)(2,1) = 0.1;
2026 (*t)(0,2) = 0.30; (*t)(1,2) = -0.4; (*t)(2,2) = 0.2;
2027 (*t)(0,3) = 0.35; (*t)(1,3) = -0.4; (*t)(2,3) = 0.2;
2028 (*t)(0,4) = 0.40; (*t)(1,4) = -0.4; (*t)(2,4) = 0.3;
2029 (*t)(0,5) = 0.45; (*t)(1,5) = -0.4; (*t)(2,5) = 0.3;
2030 (*t)(0,6) = 0.50; (*t)(1,6) = -0.4; (*t)(2,6) = 0.25;
2031 (*t)(0,7) = 0.55; (*t)(1,7) = -0.4; (*t)(2,7) = 0.15;
2032 (*t)(0,8) = 0.60; (*t)(1,8) = -0.4; (*t)(2,8) = 0.1;
2033 (*t)(0,9) = 0.65; (*t)(1,9) = -0.4; (*t)(2,9) = 0.05;
2034 (*t)(0,10) = 0.70; (*t)(1,10) = -0.4; (*t)(2,10) = 0;
2035 (*t)(0,11) = 0.75; (*t)(1,11) = -0.4; (*t)(2,11) = 0;
2036 (*t)(0,12) = 0.80; (*t)(1,12) = -0.4; (*t)(2,12) = -0.05;
2037 (*t)(0,13) = 0.85; (*t)(1,13) = -0.4; (*t)(2,13) = -0.1;
2038 (*t)(0,14) = 0.90; (*t)(1,14) = 0; (*t)(2,14) = 0;
2041 if (fParticleID==AliPID::kKaon)
2043 t = new TMatrixF(3,12);
2044 (*t)(0,0) = 0.20; (*t)(1,0) = -0.2; (*t)(2,0) = 0.2;
2045 (*t)(0,1) = 0.25; (*t)(1,1) = -0.2; (*t)(2,1) = 0.2;
2046 (*t)(0,2) = 0.30; (*t)(1,2) = -0.2; (*t)(2,2) = 0.2;
2047 (*t)(0,3) = 0.35; (*t)(1,3) = -0.2; (*t)(2,3) = 0.2;
2048 (*t)(0,4) = 0.40; (*t)(1,4) = -0.1; (*t)(2,4) = 0.2;
2049 (*t)(0,5) = 0.45; (*t)(1,5) = -0.1; (*t)(2,5) = 0.2;
2050 (*t)(0,6) = 0.50; (*t)(1,6) =-0.05; (*t)(2,6) = 0.2;
2051 (*t)(0,7) = 0.55; (*t)(1,7) = -0.1; (*t)(2,7) = 0.1;
2052 (*t)(0,8) = 0.60; (*t)(1,8) =-0.05; (*t)(2,8) = 0.1;
2053 (*t)(0,9) = 0.65; (*t)(1,9) = 0; (*t)(2,9) = 0.15;
2054 (*t)(0,10) = 0.70; (*t)(1,10) = 0.05; (*t)(2,10) = 0.2;
2055 (*t)(0,11) = 0.75; (*t)(1,11) = 0; (*t)(2,11) = 0;
2058 if (fParticleID==AliPID::kProton)
2060 t = new TMatrixF(3,9);
2061 (*t)(0,0) = 0.20; (*t)(1,0) = -0.1; (*t)(2,0) = 0.1;
2062 (*t)(0,1) = 0.25; (*t)(1,1) = -0.2; (*t)(2,1) = 0.2;
2063 (*t)(0,2) = 0.80; (*t)(1,2) = -0.1; (*t)(2,2) = 0.2;
2064 (*t)(0,3) = 0.85; (*t)(1,3) =-0.05; (*t)(2,3) = 0.2;
2065 (*t)(0,4) = 0.90; (*t)(1,4) =-0.05; (*t)(2,4) = 0.25;
2066 (*t)(0,5) = 0.95; (*t)(1,5) =-0.05; (*t)(2,5) = 0.25;
2067 (*t)(0,6) = 1.00; (*t)(1,6) = -0.1; (*t)(2,6) = 0.25;
2068 (*t)(0,7) = 1.10; (*t)(1,7) =-0.05; (*t)(2,7) = 0.3;
2069 (*t)(0,8) = 1.20; (*t)(1,8) = 0; (*t)(2,8) = 0;
2077 if (fParticleID==AliPID::kPion)
2079 //TOF pions, 0.9 purity
2080 t = new TMatrixF(3,61);
2081 (*t)(0,0) = 0.000; (*t)(1,0) = 0.000; (*t)(2,0) = 0.000;
2082 (*t)(0,1) = 0.050; (*t)(1,1) = 0.000; (*t)(2,1) = 0.000;
2083 (*t)(0,2) = 0.100; (*t)(1,2) = 0.000; (*t)(2,2) = 0.000;
2084 (*t)(0,3) = 0.150; (*t)(1,3) = 0.000; (*t)(2,3) = 0.000;
2085 (*t)(0,4) = 0.200; (*t)(1,4) = -0.030; (*t)(2,4) = 0.030;
2086 (*t)(0,5) = 0.250; (*t)(1,5) = -0.036; (*t)(2,5) = 0.032;
2087 (*t)(0,6) = 0.300; (*t)(1,6) = -0.038; (*t)(2,6) = 0.032;
2088 (*t)(0,7) = 0.350; (*t)(1,7) = -0.034; (*t)(2,7) = 0.032;
2089 (*t)(0,8) = 0.400; (*t)(1,8) = -0.032; (*t)(2,8) = 0.020;
2090 (*t)(0,9) = 0.450; (*t)(1,9) = -0.030; (*t)(2,9) = 0.020;
2091 (*t)(0,10) = 0.500; (*t)(1,10) = -0.030; (*t)(2,10) = 0.020;
2092 (*t)(0,11) = 0.550; (*t)(1,11) = -0.030; (*t)(2,11) = 0.020;
2093 (*t)(0,12) = 0.600; (*t)(1,12) = -0.030; (*t)(2,12) = 0.020;
2094 (*t)(0,13) = 0.650; (*t)(1,13) = -0.030; (*t)(2,13) = 0.020;
2095 (*t)(0,14) = 0.700; (*t)(1,14) = -0.030; (*t)(2,14) = 0.020;
2096 (*t)(0,15) = 0.750; (*t)(1,15) = -0.030; (*t)(2,15) = 0.020;
2097 (*t)(0,16) = 0.800; (*t)(1,16) = -0.030; (*t)(2,16) = 0.020;
2098 (*t)(0,17) = 0.850; (*t)(1,17) = -0.030; (*t)(2,17) = 0.020;
2099 (*t)(0,18) = 0.900; (*t)(1,18) = -0.030; (*t)(2,18) = 0.020;
2100 (*t)(0,19) = 0.950; (*t)(1,19) = -0.028; (*t)(2,19) = 0.028;
2101 (*t)(0,20) = 1.000; (*t)(1,20) = -0.028; (*t)(2,20) = 0.028;
2102 (*t)(0,21) = 1.100; (*t)(1,21) = -0.028; (*t)(2,21) = 0.028;
2103 (*t)(0,22) = 1.200; (*t)(1,22) = -0.026; (*t)(2,22) = 0.028;
2104 (*t)(0,23) = 1.300; (*t)(1,23) = -0.024; (*t)(2,23) = 0.028;
2105 (*t)(0,24) = 1.400; (*t)(1,24) = -0.020; (*t)(2,24) = 0.028;
2106 (*t)(0,25) = 1.500; (*t)(1,25) = -0.018; (*t)(2,25) = 0.028;
2107 (*t)(0,26) = 1.600; (*t)(1,26) = -0.016; (*t)(2,26) = 0.028;
2108 (*t)(0,27) = 1.700; (*t)(1,27) = -0.014; (*t)(2,27) = 0.028;
2109 (*t)(0,28) = 1.800; (*t)(1,28) = -0.012; (*t)(2,28) = 0.026;
2110 (*t)(0,29) = 1.900; (*t)(1,29) = -0.010; (*t)(2,29) = 0.026;
2111 (*t)(0,30) = 2.000; (*t)(1,30) = -0.008; (*t)(2,30) = 0.026;
2112 (*t)(0,31) = 2.100; (*t)(1,31) = -0.008; (*t)(2,31) = 0.024;
2113 (*t)(0,32) = 2.200; (*t)(1,32) = -0.006; (*t)(2,32) = 0.024;
2114 (*t)(0,33) = 2.300; (*t)(1,33) = -0.004; (*t)(2,33) = 0.024;
2115 (*t)(0,34) = 2.400; (*t)(1,34) = -0.004; (*t)(2,34) = 0.024;
2116 (*t)(0,35) = 2.500; (*t)(1,35) = -0.002; (*t)(2,35) = 0.024;
2117 (*t)(0,36) = 2.600; (*t)(1,36) = -0.002; (*t)(2,36) = 0.024;
2118 (*t)(0,37) = 2.700; (*t)(1,37) = 0.000; (*t)(2,37) = 0.024;
2119 (*t)(0,38) = 2.800; (*t)(1,38) = 0.000; (*t)(2,38) = 0.026;
2120 (*t)(0,39) = 2.900; (*t)(1,39) = 0.000; (*t)(2,39) = 0.024;
2121 (*t)(0,40) = 3.000; (*t)(1,40) = 0.002; (*t)(2,40) = 0.026;
2122 (*t)(0,41) = 3.100; (*t)(1,41) = 0.002; (*t)(2,41) = 0.026;
2123 (*t)(0,42) = 3.200; (*t)(1,42) = 0.002; (*t)(2,42) = 0.026;
2124 (*t)(0,43) = 3.300; (*t)(1,43) = 0.002; (*t)(2,43) = 0.026;
2125 (*t)(0,44) = 3.400; (*t)(1,44) = 0.002; (*t)(2,44) = 0.026;
2126 (*t)(0,45) = 3.500; (*t)(1,45) = 0.002; (*t)(2,45) = 0.026;
2127 (*t)(0,46) = 3.600; (*t)(1,46) = 0.002; (*t)(2,46) = 0.026;
2128 (*t)(0,47) = 3.700; (*t)(1,47) = 0.002; (*t)(2,47) = 0.026;
2129 (*t)(0,48) = 3.800; (*t)(1,48) = 0.002; (*t)(2,48) = 0.026;
2130 (*t)(0,49) = 3.900; (*t)(1,49) = 0.004; (*t)(2,49) = 0.024;
2131 (*t)(0,50) = 4.000; (*t)(1,50) = 0.004; (*t)(2,50) = 0.026;
2132 (*t)(0,51) = 4.100; (*t)(1,51) = 0.004; (*t)(2,51) = 0.026;
2133 (*t)(0,52) = 4.200; (*t)(1,52) = 0.004; (*t)(2,52) = 0.024;
2134 (*t)(0,53) = 4.300; (*t)(1,53) = 0.006; (*t)(2,53) = 0.024;
2135 (*t)(0,54) = 4.400; (*t)(1,54) = 0.000; (*t)(2,54) = 0.000;
2136 (*t)(0,55) = 4.500; (*t)(1,55) = 0.000; (*t)(2,55) = 0.000;
2137 (*t)(0,56) = 4.600; (*t)(1,56) = 0.000; (*t)(2,56) = 0.000;
2138 (*t)(0,57) = 4.700; (*t)(1,57) = 0.000; (*t)(2,57) = 0.000;
2139 (*t)(0,58) = 4.800; (*t)(1,58) = 0.000; (*t)(2,58) = 0.000;
2140 (*t)(0,59) = 4.900; (*t)(1,59) = 0.000; (*t)(2,59) = 0.000;
2141 (*t)(0,60) = 5.900; (*t)(1,60) = 0.000; (*t)(2,60) = 0.000;
2144 if (fParticleID==AliPID::kProton)
2146 //TOF protons, 0.9 purity
2147 t = new TMatrixF(3,61);
2148 (*t)(0,0) = 0.000; (*t)(1,0) = 0.000; (*t)(2,0) = 0.000;
2149 (*t)(0,1) = 0.050; (*t)(1,1) = 0.000; (*t)(2,1) = 0.000;
2150 (*t)(0,2) = 0.100; (*t)(1,2) = 0.000; (*t)(2,2) = 0.000;
2151 (*t)(0,3) = 0.150; (*t)(1,3) = 0.000; (*t)(2,3) = 0.000;
2152 (*t)(0,4) = 0.200; (*t)(1,4) = -0.07; (*t)(2,4) = 0.07;
2153 (*t)(0,5) = 0.200; (*t)(1,5) = -0.07; (*t)(2,5) = 0.07;
2154 (*t)(0,6) = 0.200; (*t)(1,6) = -0.07; (*t)(2,6) = 0.07;
2155 (*t)(0,7) = 0.200; (*t)(1,7) = -0.07; (*t)(2,7) = 0.07;
2156 (*t)(0,8) = 0.200; (*t)(1,8) = -0.07; (*t)(2,8) = 0.07;
2157 (*t)(0,9) = 0.200; (*t)(1,9) = -0.07; (*t)(2,9) = 0.07;
2158 (*t)(0,10) = 0.200; (*t)(1,10) = -0.07; (*t)(2,10) = 0.07;
2159 (*t)(0,11) = 0.200; (*t)(1,11) = -0.07; (*t)(2,11) = 0.07;
2160 (*t)(0,12) = 0.200; (*t)(1,12) = -0.07; (*t)(2,12) = 0.07;
2161 (*t)(0,13) = 0.200; (*t)(1,13) = -0.07; (*t)(2,13) = 0.07;
2162 (*t)(0,14) = 0.200; (*t)(1,14) = -0.07; (*t)(2,14) = 0.07;
2163 (*t)(0,15) = 0.200; (*t)(1,15) = -0.07; (*t)(2,15) = 0.07;
2164 (*t)(0,16) = 0.200; (*t)(1,16) = -0.07; (*t)(2,16) = 0.07;
2165 (*t)(0,17) = 0.850; (*t)(1,17) = -0.070; (*t)(2,17) = 0.070;
2166 (*t)(0,18) = 0.900; (*t)(1,18) = -0.072; (*t)(2,18) = 0.072;
2167 (*t)(0,19) = 0.950; (*t)(1,19) = -0.072; (*t)(2,19) = 0.072;
2168 (*t)(0,20) = 1.000; (*t)(1,20) = -0.074; (*t)(2,20) = 0.074;
2169 (*t)(0,21) = 1.100; (*t)(1,21) = -0.032; (*t)(2,21) = 0.032;
2170 (*t)(0,22) = 1.200; (*t)(1,22) = -0.026; (*t)(2,22) = 0.026;
2171 (*t)(0,23) = 1.300; (*t)(1,23) = -0.026; (*t)(2,23) = 0.026;
2172 (*t)(0,24) = 1.400; (*t)(1,24) = -0.024; (*t)(2,24) = 0.024;
2173 (*t)(0,25) = 1.500; (*t)(1,25) = -0.024; (*t)(2,25) = 0.024;
2174 (*t)(0,26) = 1.600; (*t)(1,26) = -0.026; (*t)(2,26) = 0.026;
2175 (*t)(0,27) = 1.700; (*t)(1,27) = -0.026; (*t)(2,27) = 0.026;
2176 (*t)(0,28) = 1.800; (*t)(1,28) = -0.026; (*t)(2,28) = 0.026;
2177 (*t)(0,29) = 1.900; (*t)(1,29) = -0.026; (*t)(2,29) = 0.026;
2178 (*t)(0,30) = 2.000; (*t)(1,30) = -0.026; (*t)(2,30) = 0.026;
2179 (*t)(0,31) = 2.100; (*t)(1,31) = -0.026; (*t)(2,31) = 0.026;
2180 (*t)(0,32) = 2.200; (*t)(1,32) = -0.026; (*t)(2,32) = 0.024;
2181 (*t)(0,33) = 2.300; (*t)(1,33) = -0.028; (*t)(2,33) = 0.022;
2182 (*t)(0,34) = 2.400; (*t)(1,34) = -0.028; (*t)(2,34) = 0.020;
2183 (*t)(0,35) = 2.500; (*t)(1,35) = -0.028; (*t)(2,35) = 0.018;
2184 (*t)(0,36) = 2.600; (*t)(1,36) = -0.028; (*t)(2,36) = 0.016;
2185 (*t)(0,37) = 2.700; (*t)(1,37) = -0.028; (*t)(2,37) = 0.016;
2186 (*t)(0,38) = 2.800; (*t)(1,38) = -0.030; (*t)(2,38) = 0.014;
2187 (*t)(0,39) = 2.900; (*t)(1,39) = -0.030; (*t)(2,39) = 0.012;
2188 (*t)(0,40) = 3.000; (*t)(1,40) = -0.030; (*t)(2,40) = 0.012;
2189 (*t)(0,41) = 3.100; (*t)(1,41) = -0.030; (*t)(2,41) = 0.010;
2190 (*t)(0,42) = 3.200; (*t)(1,42) = -0.030; (*t)(2,42) = 0.010;
2191 (*t)(0,43) = 3.300; (*t)(1,43) = -0.030; (*t)(2,43) = 0.010;
2192 (*t)(0,44) = 3.400; (*t)(1,44) = -0.030; (*t)(2,44) = 0.008;
2193 (*t)(0,45) = 3.500; (*t)(1,45) = -0.030; (*t)(2,45) = 0.008;
2194 (*t)(0,46) = 3.600; (*t)(1,46) = -0.030; (*t)(2,46) = 0.008;
2195 (*t)(0,47) = 3.700; (*t)(1,47) = -0.030; (*t)(2,47) = 0.006;
2196 (*t)(0,48) = 3.800; (*t)(1,48) = -0.030; (*t)(2,48) = 0.006;
2197 (*t)(0,49) = 3.900; (*t)(1,49) = -0.030; (*t)(2,49) = 0.006;
2198 (*t)(0,50) = 4.000; (*t)(1,50) = -0.028; (*t)(2,50) = 0.004;
2199 (*t)(0,51) = 4.100; (*t)(1,51) = -0.030; (*t)(2,51) = 0.004;
2200 (*t)(0,52) = 4.200; (*t)(1,52) = -0.030; (*t)(2,52) = 0.004;
2201 (*t)(0,53) = 4.300; (*t)(1,53) = -0.028; (*t)(2,53) = 0.002;
2202 (*t)(0,54) = 4.400; (*t)(1,54) = -0.030; (*t)(2,54) = 0.002;
2203 (*t)(0,55) = 4.500; (*t)(1,55) = -0.028; (*t)(2,55) = 0.002;
2204 (*t)(0,56) = 4.600; (*t)(1,56) = -0.028; (*t)(2,56) = 0.002;
2205 (*t)(0,57) = 4.700; (*t)(1,57) = -0.028; (*t)(2,57) = 0.000;
2206 (*t)(0,58) = 4.800; (*t)(1,58) = -0.028; (*t)(2,58) = 0.002;
2207 (*t)(0,59) = 4.900; (*t)(1,59) = 0.000; (*t)(2,59) = 0.000;
2208 (*t)(0,60) = 5.900; (*t)(1,60) = 0.000; (*t)(2,60) = 0.000;
2211 if (fParticleID==AliPID::kKaon)
2213 //TOF kaons, 0.9 purity
2214 t = new TMatrixF(3,61);
2215 (*t)(0,0) = 0.000; (*t)(1,0) = 0.000; (*t)(2,0) = 0.000;
2216 (*t)(0,1) = 0.050; (*t)(1,1) = 0.000; (*t)(2,1) = 0.000;
2217 (*t)(0,2) = 0.100; (*t)(1,2) = 0.000; (*t)(2,2) = 0.000;
2218 (*t)(0,3) = 0.150; (*t)(1,3) = 0.000; (*t)(2,3) = 0.000;
2219 (*t)(0,4) = 0.200; (*t)(1,4) = -0.05; (*t)(2,4) = 0.05;
2220 (*t)(0,5) = 0.200; (*t)(1,5) = -0.05; (*t)(2,5) = 0.05;
2221 (*t)(0,6) = 0.200; (*t)(1,6) = -0.05; (*t)(2,6) = 0.05;
2222 (*t)(0,7) = 0.200; (*t)(1,7) = -0.05; (*t)(2,7) = 0.05;
2223 (*t)(0,8) = 0.200; (*t)(1,8) = -0.05; (*t)(2,8) = 0.05;
2224 (*t)(0,9) = 0.200; (*t)(1,9) = -0.05; (*t)(2,9) = 0.05;
2225 (*t)(0,10) = 0.200; (*t)(1,10) = -0.05; (*t)(2,10) = 0.05;
2226 (*t)(0,11) = 0.550; (*t)(1,11) = -0.026; (*t)(2,11) = 0.026;
2227 (*t)(0,12) = 0.600; (*t)(1,12) = -0.026; (*t)(2,12) = 0.026;
2228 (*t)(0,13) = 0.650; (*t)(1,13) = -0.026; (*t)(2,13) = 0.026;
2229 (*t)(0,14) = 0.700; (*t)(1,14) = -0.026; (*t)(2,14) = 0.026;
2230 (*t)(0,15) = 0.750; (*t)(1,15) = -0.026; (*t)(2,15) = 0.026;
2231 (*t)(0,16) = 0.800; (*t)(1,16) = -0.026; (*t)(2,16) = 0.026;
2232 (*t)(0,17) = 0.850; (*t)(1,17) = -0.024; (*t)(2,17) = 0.024;
2233 (*t)(0,18) = 0.900; (*t)(1,18) = -0.024; (*t)(2,18) = 0.024;
2234 (*t)(0,19) = 0.950; (*t)(1,19) = -0.024; (*t)(2,19) = 0.024;
2235 (*t)(0,20) = 1.000; (*t)(1,20) = -0.024; (*t)(2,20) = 0.024;
2236 (*t)(0,21) = 1.100; (*t)(1,21) = -0.024; (*t)(2,21) = 0.024;
2237 (*t)(0,22) = 1.200; (*t)(1,22) = -0.024; (*t)(2,22) = 0.022;
2238 (*t)(0,23) = 1.300; (*t)(1,23) = -0.024; (*t)(2,23) = 0.020;
2239 (*t)(0,24) = 1.400; (*t)(1,24) = -0.026; (*t)(2,24) = 0.016;
2240 (*t)(0,25) = 1.500; (*t)(1,25) = -0.028; (*t)(2,25) = 0.014;
2241 (*t)(0,26) = 1.600; (*t)(1,26) = -0.028; (*t)(2,26) = 0.012;
2242 (*t)(0,27) = 1.700; (*t)(1,27) = -0.028; (*t)(2,27) = 0.010;
2243 (*t)(0,28) = 1.800; (*t)(1,28) = -0.028; (*t)(2,28) = 0.010;
2244 (*t)(0,29) = 1.900; (*t)(1,29) = -0.028; (*t)(2,29) = 0.008;
2245 (*t)(0,30) = 2.000; (*t)(1,30) = -0.028; (*t)(2,30) = 0.006;
2246 (*t)(0,31) = 2.100; (*t)(1,31) = -0.026; (*t)(2,31) = 0.006;
2247 (*t)(0,32) = 2.200; (*t)(1,32) = -0.024; (*t)(2,32) = 0.004;
2248 (*t)(0,33) = 2.300; (*t)(1,33) = -0.020; (*t)(2,33) = 0.002;
2249 (*t)(0,34) = 2.400; (*t)(1,34) = -0.020; (*t)(2,34) = 0.002;
2250 (*t)(0,35) = 2.500; (*t)(1,35) = -0.018; (*t)(2,35) = 0.000;
2251 (*t)(0,36) = 2.600; (*t)(1,36) = -0.016; (*t)(2,36) = 0.000;
2252 (*t)(0,37) = 2.700; (*t)(1,37) = -0.014; (*t)(2,37) = -0.002;
2253 (*t)(0,38) = 2.800; (*t)(1,38) = -0.014; (*t)(2,38) = -0.004;
2254 (*t)(0,39) = 2.900; (*t)(1,39) = -0.012; (*t)(2,39) = -0.004;
2255 (*t)(0,40) = 3.000; (*t)(1,40) = -0.010; (*t)(2,40) = -0.006;
2256 (*t)(0,41) = 3.100; (*t)(1,41) = 0.000; (*t)(2,41) = 0.000;
2257 (*t)(0,42) = 3.200; (*t)(1,42) = 0.000; (*t)(2,42) = 0.000;
2258 (*t)(0,43) = 3.300; (*t)(1,43) = 0.000; (*t)(2,43) = 0.000;
2259 (*t)(0,44) = 3.400; (*t)(1,44) = 0.000; (*t)(2,44) = 0.000;
2260 (*t)(0,45) = 3.500; (*t)(1,45) = 0.000; (*t)(2,45) = 0.000;
2261 (*t)(0,46) = 3.600; (*t)(1,46) = 0.000; (*t)(2,46) = 0.000;
2262 (*t)(0,47) = 3.700; (*t)(1,47) = 0.000; (*t)(2,47) = 0.000;
2263 (*t)(0,48) = 3.800; (*t)(1,48) = 0.000; (*t)(2,48) = 0.000;
2264 (*t)(0,49) = 3.900; (*t)(1,49) = 0.000; (*t)(2,49) = 0.000;
2265 (*t)(0,50) = 4.000; (*t)(1,50) = 0.000; (*t)(2,50) = 0.000;
2266 (*t)(0,51) = 4.100; (*t)(1,51) = 0.000; (*t)(2,51) = 0.000;
2267 (*t)(0,52) = 4.200; (*t)(1,52) = 0.000; (*t)(2,52) = 0.000;
2268 (*t)(0,53) = 4.300; (*t)(1,53) = 0.000; (*t)(2,53) = 0.000;
2269 (*t)(0,54) = 4.400; (*t)(1,54) = 0.000; (*t)(2,54) = 0.000;
2270 (*t)(0,55) = 4.500; (*t)(1,55) = 0.000; (*t)(2,55) = 0.000;
2271 (*t)(0,56) = 4.600; (*t)(1,56) = 0.000; (*t)(2,56) = 0.000;
2272 (*t)(0,57) = 4.700; (*t)(1,57) = 0.000; (*t)(2,57) = 0.000;
2273 (*t)(0,58) = 4.800; (*t)(1,58) = 0.000; (*t)(2,58) = 0.000;
2274 (*t)(0,59) = 4.900; (*t)(1,59) = 0.000; (*t)(2,59) = 0.000;
2275 (*t)(0,60) = 5.900; (*t)(1,60) = 0.000; (*t)(2,60) = 0.000;
2282 //-----------------------------------------------------------------------
2283 Bool_t AliFlowTrackCuts::PassesTPCbayesianCut(const AliESDtrack* track)
2285 //cut on TPC bayesian pid
2286 //if (! fAllowTOFmismatchFlag) {if (track->GetStatus() & AliESDtrack::kTOFmismatch) return kFALSE;}
2288 //Bool_t statusMatchingHard = TPCTOFagree(track);
2289 //if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
2291 fBayesianResponse->ComputeProb(track,fCurrCentr); // fCurrCentr is needed for mismatch fraction
2292 Int_t kTPC = fBayesianResponse->GetCurrentMask(0); // is TPC on
2293 Int_t kTOF = fBayesianResponse->GetCurrentMask(1); // is TOF on
2295 if(! kTPC) return kFALSE;
2297 Bool_t statusMatchingHard = 1;
2298 Float_t mismProb = 0;
2300 statusMatchingHard = TPCTOFagree(track);
2301 mismProb = fBayesianResponse->GetTOFMismProb();
2303 if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
2306 Float_t *probabilities = fBayesianResponse->GetProb(); // Bayesian Probability (from 0 to 4) (Combined TPC || TOF) including a tuning of priors and TOF mismatch parameterization
2310 switch (fParticleID)
2313 fProbBayes = probabilities[2];
2316 fProbBayes = probabilities[3];
2318 case AliPID::kProton:
2319 fProbBayes = probabilities[4];
2321 case AliPID::kElectron:
2322 fProbBayes = probabilities[0];
2325 fProbBayes = probabilities[1];
2327 case AliPID::kDeuteron:
2328 fProbBayes = probabilities[5];
2330 case AliPID::kTriton:
2331 fProbBayes = probabilities[6];
2334 fProbBayes = probabilities[7];
2340 if(fProbBayes > fParticleProbability && mismProb < 0.5)
2344 else if (fCutCharge && fCharge * track->GetSign() > 0)
2350 //-----------------------------------------------------------------------
2351 // part added by F. Noferini (some methods)
2352 Bool_t AliFlowTrackCuts::PassesTOFbayesianCut(const AliESDtrack* track)
2354 //check is track passes bayesian combined TOF+TPC pid cut
2355 Bool_t goodtrack = (track->GetStatus() & AliESDtrack::kTOFout) &&
2356 (track->GetStatus() & AliESDtrack::kTIME) &&
2357 (track->GetTOFsignal() > 12000) &&
2358 (track->GetTOFsignal() < 100000) &&
2359 (track->GetIntegratedLength() > 365);
2364 if (! fAllowTOFmismatchFlag) {if (track->GetStatus() & AliESDtrack::kTOFmismatch) return kFALSE;}
2366 Bool_t statusMatchingHard = TPCTOFagree(track);
2367 if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
2370 fBayesianResponse->ComputeProb(track,fCurrCentr); // fCurrCentr is needed for mismatch fraction
2371 Float_t *probabilities = fBayesianResponse->GetProb(); // Bayesian Probability (from 0 to 4) (Combined TPC || TOF) including a tuning of priors and TOF mismatch parameterization
2373 Float_t mismProb = fBayesianResponse->GetTOFMismProb(); // mismatch Bayesian probabilities
2377 switch (fParticleID)
2380 fProbBayes = probabilities[2];
2383 fProbBayes = probabilities[3];
2385 case AliPID::kProton:
2386 fProbBayes = probabilities[4];
2388 case AliPID::kElectron:
2389 fProbBayes = probabilities[0];
2392 fProbBayes = probabilities[1];
2394 case AliPID::kDeuteron:
2395 fProbBayes = probabilities[5];
2397 case AliPID::kTriton:
2398 fProbBayes = probabilities[6];
2401 fProbBayes = probabilities[7];
2407 // 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);
2408 if(fProbBayes > fParticleProbability && mismProb < 0.5){
2411 else if (fCutCharge && fCharge * track->GetSign() > 0)
2418 //-----------------------------------------------------------------------
2419 // part added by Natasha
2420 Bool_t AliFlowTrackCuts::PassesNucleiSelection(const AliESDtrack* track)
2422 //pid selection for heavy nuclei
2423 Bool_t select=kFALSE;
2425 //if (!track) continue;
2427 if (!track->GetInnerParam())
2428 return kFALSE; //break;
2430 const AliExternalTrackParam* tpcTrack = track->GetInnerParam();
2432 Double_t ptotTPC = tpcTrack->GetP();
2433 Double_t sigTPC = track->GetTPCsignal();
2434 Double_t dEdxBBA = 0.;
2435 Double_t dSigma = 0.;
2437 switch (fParticleID)
2439 case AliPID::kDeuteron:
2441 dEdxBBA = AliExternalTrackParam::BetheBlochAleph(ptotTPC/1.8756,
2447 dSigma = (sigTPC - dEdxBBA)/dEdxBBA;
2449 if( ptotTPC<=1.1 && (dSigma < (0.5 - (0.1818*ptotTPC)) ) && (dSigma > ( (0.218*ptotTPC - 0.4) ) ) )
2453 case AliPID::kTriton:
2460 // ----- Pass 2 -------
2461 dEdxBBA = 4.0 * AliExternalTrackParam::BetheBlochAleph( (2.*ptotTPC)/2.8084,
2467 dSigma = (sigTPC - dEdxBBA)/dEdxBBA;
2468 if(ptotTPC<=5.0 && (dSigma >= (-0.03968*ptotTPC - 0.1)) && (dSigma <= (0.31 - 0.0217*ptotTPC)))
2472 case AliPID::kAlpha:
2483 // end part added by Natasha
2484 //-----------------------------------------------------------------------
2485 void AliFlowTrackCuts::SetPriors(Float_t centrCur){
2486 //set priors for the bayesian pid selection
2487 fCurrCentr = centrCur;
2489 fBinLimitPID[0] = 0.300000;
2490 fBinLimitPID[1] = 0.400000;
2491 fBinLimitPID[2] = 0.500000;
2492 fBinLimitPID[3] = 0.600000;
2493 fBinLimitPID[4] = 0.700000;
2494 fBinLimitPID[5] = 0.800000;
2495 fBinLimitPID[6] = 0.900000;
2496 fBinLimitPID[7] = 1.000000;
2497 fBinLimitPID[8] = 1.200000;
2498 fBinLimitPID[9] = 1.400000;
2499 fBinLimitPID[10] = 1.600000;
2500 fBinLimitPID[11] = 1.800000;
2501 fBinLimitPID[12] = 2.000000;
2502 fBinLimitPID[13] = 2.200000;
2503 fBinLimitPID[14] = 2.400000;
2504 fBinLimitPID[15] = 2.600000;
2505 fBinLimitPID[16] = 2.800000;
2506 fBinLimitPID[17] = 3.000000;
2619 else if(centrCur < 20){
2729 else if(centrCur < 30){
2839 else if(centrCur < 40){
2949 else if(centrCur < 50){
3059 else if(centrCur < 60){
3169 else if(centrCur < 70){
3279 else if(centrCur < 80){
3499 for(Int_t i=18;i<fgkPIDptBin;i++){
3500 fBinLimitPID[i] = 3.0 + 0.2 * (i-18);
3501 fC[i][0] = fC[17][0];
3502 fC[i][1] = fC[17][1];
3503 fC[i][2] = fC[17][2];
3504 fC[i][3] = fC[17][3];
3505 fC[i][4] = fC[17][4];
3509 //---------------------------------------------------------------//
3510 Bool_t AliFlowTrackCuts::TPCTOFagree(const AliESDtrack *track)
3512 //check pid agreement between TPC and TOF
3513 Bool_t status = kFALSE;
3515 Float_t mass[5] = {5.10998909999999971e-04,1.05658000000000002e-01,1.39570000000000000e-01,4.93676999999999977e-01,9.38271999999999995e-01};
3518 Double_t exptimes[5];
3519 track->GetIntegratedTimes(exptimes);
3521 Float_t dedx = track->GetTPCsignal();
3523 Float_t p = track->P();
3524 Float_t time = track->GetTOFsignal()- fESDpid.GetTOFResponse().GetStartTime(p);
3525 Float_t tl = track->GetIntegratedLength();
3527 Float_t betagammares = fESDpid.GetTOFResponse().GetExpectedSigma(p, exptimes[4], mass[4]);
3529 Float_t betagamma1 = tl/(time-5 *betagammares) * 33.3564095198152043;
3531 // printf("betagamma1 = %f\n",betagamma1);
3533 if(betagamma1 < 0.1) betagamma1 = 0.1;
3535 if(betagamma1 < 0.99999) betagamma1 /= TMath::Sqrt(1-betagamma1*betagamma1);
3536 else betagamma1 = 100;
3538 Float_t betagamma2 = tl/(time+5 *betagammares) * 33.3564095198152043;
3539 // printf("betagamma2 = %f\n",betagamma2);
3541 if(betagamma2 < 0.1) betagamma2 = 0.1;
3543 if(betagamma2 < 0.99999) betagamma2 /= TMath::Sqrt(1-betagamma2*betagamma2);
3544 else betagamma2 = 100;
3548 track->GetInnerPxPyPz(ptpc);
3549 Float_t momtpc=TMath::Sqrt(ptpc[0]*ptpc[0] + ptpc[1]*ptpc[1] + ptpc[2]*ptpc[2]);
3551 for(Int_t i=0;i < 5;i++){
3552 Float_t resolutionTOF = fESDpid.GetTOFResponse().GetExpectedSigma(p, exptimes[i], mass[i]);
3553 if(TMath::Abs(exptimes[i] - time) < 5 * resolutionTOF){
3554 Float_t dedxExp = 0;
3555 if(i==0) dedxExp = fESDpid.GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kElectron);
3556 else if(i==1) dedxExp = fESDpid.GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kMuon);
3557 else if(i==2) dedxExp = fESDpid.GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kPion);
3558 else if(i==3) dedxExp = fESDpid.GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kKaon);
3559 else if(i==4) dedxExp = fESDpid.GetTPCResponse().GetExpectedSignal(momtpc,AliPID::kProton);
3561 Float_t resolutionTPC = 2;
3562 if(i==0) resolutionTPC = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kElectron);
3563 else if(i==1) resolutionTPC = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kMuon);
3564 else if(i==2) resolutionTPC = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kPion);
3565 else if(i==3) resolutionTPC = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kKaon);
3566 else if(i==4) resolutionTPC = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kProton);
3568 if(TMath::Abs(dedx - dedxExp) < 3 * resolutionTPC){
3574 Float_t bb1 = fESDpid.GetTPCResponse().Bethe(betagamma1);
3575 Float_t bb2 = fESDpid.GetTPCResponse().Bethe(betagamma2);
3576 Float_t bbM = fESDpid.GetTPCResponse().Bethe((betagamma1+betagamma2)*0.5);
3581 Float_t resolutionTOFpr = fESDpid.GetTOFResponse().GetExpectedSigma(p, exptimes[4], mass[4]);
3582 Float_t resolutionTPCpr = fESDpid.GetTPCResponse().GetExpectedSigma(momtpc,track->GetTPCsignalN(),AliPID::kProton);
3583 if(TMath::Abs(dedx-bb1) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
3586 else if(TMath::Abs(dedx-bb2) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
3589 else if(TMath::Abs(dedx-bbM) < resolutionTPCpr*3 && exptimes[4] < time-7*resolutionTOFpr){
3595 // end part added by F. Noferini
3596 //-----------------------------------------------------------------------
3598 //-----------------------------------------------------------------------
3599 const char* AliFlowTrackCuts::PIDsourceName(PIDsource s)
3601 //get the name of the particle id source
3607 return "TPCbayesian";
3615 return "TOFbayesianPID";
3616 case kTOFbetaSimple:
3617 return "TOFbetaSimple";
3625 //-----------------------------------------------------------------------
3626 const char* AliFlowTrackCuts::GetParamTypeName(trackParameterType type)
3628 //return the name of the selected parameter type
3635 case kTPCstandalone:
3636 return "TPCstandalone";
3638 return "SPDtracklets";
3648 //-----------------------------------------------------------------------
3649 Bool_t AliFlowTrackCuts::PassesPMDcuts(const AliESDPmdTrack* track )
3651 //check PMD specific cuts
3652 //clean up from last iteration, and init label
3653 Int_t det = track->GetDetector();
3654 //Int_t smn = track->GetSmn();
3655 Float_t clsX = track->GetClusterX();
3656 Float_t clsY = track->GetClusterY();
3657 Float_t clsZ = track->GetClusterZ();
3658 Float_t ncell = track->GetClusterCells();
3659 Float_t adc = track->GetClusterADC();
3665 fTrackEta = GetPmdEta(clsX,clsY,clsZ);
3666 fTrackPhi = GetPmdPhi(clsX,clsY);
3670 if (fCutEta) {if ( fTrackEta < fEtaMin || fTrackEta >= fEtaMax ) pass = kFALSE;}
3671 if (fCutPhi) {if ( fTrackPhi < fPhiMin || fTrackPhi >= fPhiMax ) pass = kFALSE;}
3672 if (fCutPmdDet) {if(det != fPmdDet) pass = kFALSE;}
3673 if (fCutPmdAdc) {if(adc < fPmdAdc) pass = kFALSE;}
3674 if (fCutPmdNcell) {if(ncell < fPmdNcell) pass = kFALSE;}
3679 //-----------------------------------------------------------------------
3680 Bool_t AliFlowTrackCuts::PassesV0cuts(Int_t id)
3683 if (id<0) return kFALSE;
3685 //clean up from last iter
3690 fTrackPhi = TMath::PiOver4()*(0.5+id%8);
3693 fTrackEta = -3.45+0.5*(id/8);
3695 fTrackEta = +4.8-0.6*((id/8)-4);
3697 fTrackWeight = fEvent->GetVZEROEqMultiplicity(id);
3699 if (fLinearizeVZEROresponse)
3701 //this is only needed in pass1 of LHC10h
3702 Float_t multV0[fgkNumberOfV0tracks];
3704 AliESDUtils::GetCorrV0((AliESDEvent*)fEvent,dummy,multV0);
3705 fTrackWeight = multV0[id];
3709 if (fCutEta) {if ( fTrackEta < fEtaMin || fTrackEta >= fEtaMax ) pass = kFALSE;}
3710 if (fCutPhi) {if ( fTrackPhi < fPhiMin || fTrackPhi >= fPhiMax ) pass = kFALSE;}
3715 //----------------------------------------------------------------------------//
3716 Double_t AliFlowTrackCuts::GetPmdEta(Float_t xPos, Float_t yPos, Float_t zPos)
3718 //get PMD "track" eta coordinate
3719 Float_t rpxpy, theta, eta;
3720 rpxpy = TMath::Sqrt(xPos*xPos + yPos*yPos);
3721 theta = TMath::ATan2(rpxpy,zPos);
3722 eta = -TMath::Log(TMath::Tan(0.5*theta));
3726 //--------------------------------------------------------------------------//
3727 Double_t AliFlowTrackCuts::GetPmdPhi(Float_t xPos, Float_t yPos)
3729 //Get PMD "track" phi coordinate
3730 Float_t pybypx, phi = 0., phi1;
3733 if(yPos>0) phi = 90.;
3734 if(yPos<0) phi = 270.;
3739 if(pybypx < 0) pybypx = - pybypx;
3740 phi1 = TMath::ATan(pybypx)*180./3.14159;
3742 if(xPos > 0 && yPos > 0) phi = phi1; // 1st Quadrant
3743 if(xPos < 0 && yPos > 0) phi = 180 - phi1; // 2nd Quadrant
3744 if(xPos < 0 && yPos < 0) phi = 180 + phi1; // 3rd Quadrant
3745 if(xPos > 0 && yPos < 0) phi = 360 - phi1; // 4th Quadrant
3748 phi = phi*3.14159/180.;
3752 //---------------------------------------------------------------//
3753 void AliFlowTrackCuts::Browse(TBrowser* b)
3755 //some browsing capabilities
3756 if (fQA) b->Add(fQA);
3759 //---------------------------------------------------------------//
3760 Long64_t AliFlowTrackCuts::Merge(TCollection* list)
3763 if (!fQA || !list) return 0;
3764 if (list->IsEmpty()) return 0;
3765 AliFlowTrackCuts* obj=NULL;
3768 while ( (obj = dynamic_cast<AliFlowTrackCuts*>(next())) )
3770 if (obj==this) continue;
3771 tmplist.Add(obj->GetQA());
3773 return fQA->Merge(&tmplist);