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 "TParticle.h"
41 #include "TObjArray.h"
43 #include "AliMCEvent.h"
44 #include "AliESDEvent.h"
45 #include "AliVParticle.h"
46 #include "AliMCParticle.h"
47 #include "AliESDtrack.h"
48 #include "AliMultiplicity.h"
49 #include "AliAODTrack.h"
50 #include "AliFlowTrack.h"
51 #include "AliFlowTrackCuts.h"
53 #include "AliESDpid.h"
55 ClassImp(AliFlowTrackCuts)
57 //-----------------------------------------------------------------------
58 AliFlowTrackCuts::AliFlowTrackCuts():
59 AliFlowTrackSimpleCuts(),
60 fAliESDtrackCuts(NULL),
63 fCutMCprocessType(kFALSE),
64 fMCprocessType(kPNoProcess),
67 fIgnoreSignInPID(kFALSE),
68 fCutMCisPrimary(kFALSE),
69 fRequireTransportBitForPrimaries(kTRUE),
71 fRequireCharge(kFALSE),
73 fCutSPDtrackletDeltaPhi(kFALSE),
74 fSPDtrackletDeltaPhiMax(FLT_MAX),
75 fSPDtrackletDeltaPhiMin(-FLT_MAX),
76 fIgnoreTPCzRange(kFALSE),
77 fIgnoreTPCzRangeMax(FLT_MAX),
78 fIgnoreTPCzRangeMin(-FLT_MAX),
79 fCutChi2PerClusterTPC(kFALSE),
80 fMaxChi2PerClusterTPC(FLT_MAX),
81 fMinChi2PerClusterTPC(-FLT_MAX),
82 fCutNClustersTPC(kFALSE),
83 fNClustersTPCMax(INT_MAX),
84 fNClustersTPCMin(INT_MIN),
97 fPIDsource(kTPCTOFpid),
100 fTPCTOFpidCrossOverPt(0.4),
101 fAliPID(AliPID::kPion)
106 //-----------------------------------------------------------------------
107 AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
108 AliFlowTrackSimpleCuts(),
109 fAliESDtrackCuts(new AliESDtrackCuts()),
112 fCutMCprocessType(kFALSE),
113 fMCprocessType(kPNoProcess),
116 fIgnoreSignInPID(kFALSE),
117 fCutMCisPrimary(kFALSE),
118 fRequireTransportBitForPrimaries(kTRUE),
119 fMCisPrimary(kFALSE),
120 fRequireCharge(kFALSE),
122 fCutSPDtrackletDeltaPhi(kFALSE),
123 fSPDtrackletDeltaPhiMax(FLT_MAX),
124 fSPDtrackletDeltaPhiMin(-FLT_MAX),
125 fIgnoreTPCzRange(kFALSE),
126 fIgnoreTPCzRangeMax(FLT_MAX),
127 fIgnoreTPCzRangeMin(-FLT_MAX),
128 fCutChi2PerClusterTPC(kFALSE),
129 fMaxChi2PerClusterTPC(FLT_MAX),
130 fMinChi2PerClusterTPC(-FLT_MAX),
131 fCutNClustersTPC(kFALSE),
132 fNClustersTPCMax(INT_MAX),
133 fNClustersTPCMin(INT_MIN),
140 fTrackLabel(INT_MIN),
146 fPIDsource(kTPCTOFpid),
149 fTPCTOFpidCrossOverPt(0.4),
150 fAliPID(AliPID::kPion)
154 SetTitle("AliFlowTrackCuts");
157 //-----------------------------------------------------------------------
158 AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
159 AliFlowTrackSimpleCuts(that),
160 fAliESDtrackCuts(NULL),
163 fCutMCprocessType(that.fCutMCprocessType),
164 fMCprocessType(that.fMCprocessType),
165 fCutMCPID(that.fCutMCPID),
167 fIgnoreSignInPID(that.fIgnoreSignInPID),
168 fCutMCisPrimary(that.fCutMCisPrimary),
169 fRequireTransportBitForPrimaries(that.fRequireTransportBitForPrimaries),
170 fMCisPrimary(that.fMCisPrimary),
171 fRequireCharge(that.fRequireCharge),
172 fFakesAreOK(that.fFakesAreOK),
173 fCutSPDtrackletDeltaPhi(that.fCutSPDtrackletDeltaPhi),
174 fSPDtrackletDeltaPhiMax(that.fSPDtrackletDeltaPhiMax),
175 fSPDtrackletDeltaPhiMin(that.fSPDtrackletDeltaPhiMin),
176 fIgnoreTPCzRange(that.fIgnoreTPCzRange),
177 fIgnoreTPCzRangeMax(that.fIgnoreTPCzRangeMax),
178 fIgnoreTPCzRangeMin(that.fIgnoreTPCzRangeMin),
179 fCutChi2PerClusterTPC(that.fCutChi2PerClusterTPC),
180 fMaxChi2PerClusterTPC(that.fMaxChi2PerClusterTPC),
181 fMinChi2PerClusterTPC(that.fMinChi2PerClusterTPC),
182 fCutNClustersTPC(that.fCutNClustersTPC),
183 fNClustersTPCMax(that.fNClustersTPCMax),
184 fNClustersTPCMin(that.fNClustersTPCMin),
185 fParamType(that.fParamType),
186 fParamMix(that.fParamMix),
191 fTrackLabel(INT_MIN),
196 fESDpid(that.fESDpid),
197 fPIDsource(that.fPIDsource),
200 fTPCTOFpidCrossOverPt(that.fTPCTOFpidCrossOverPt),
201 fAliPID(that.fAliPID)
204 if (that.fTPCpidCuts) fTPCpidCuts = new TMatrixF(*(that.fTPCpidCuts));
205 if (that.fTOFpidCuts) fTOFpidCuts = new TMatrixF(*(that.fTOFpidCuts));
206 if (that.fAliESDtrackCuts) fAliESDtrackCuts = new AliESDtrackCuts(*(that.fAliESDtrackCuts));
209 //-----------------------------------------------------------------------
210 AliFlowTrackCuts& AliFlowTrackCuts::operator=(const AliFlowTrackCuts& that)
213 AliFlowTrackSimpleCuts::operator=(that);
214 if (that.fAliESDtrackCuts) *fAliESDtrackCuts=*(that.fAliESDtrackCuts);
217 fCutMCprocessType=that.fCutMCprocessType;
218 fMCprocessType=that.fMCprocessType;
219 fCutMCPID=that.fCutMCPID;
221 fIgnoreSignInPID=that.fIgnoreSignInPID,
222 fCutMCisPrimary=that.fCutMCisPrimary;
223 fRequireTransportBitForPrimaries=that.fRequireTransportBitForPrimaries;
224 fMCisPrimary=that.fMCisPrimary;
225 fRequireCharge=that.fRequireCharge;
226 fFakesAreOK=that.fFakesAreOK;
227 fCutSPDtrackletDeltaPhi=that.fCutSPDtrackletDeltaPhi;
228 fSPDtrackletDeltaPhiMax=that.fSPDtrackletDeltaPhiMax;
229 fSPDtrackletDeltaPhiMin=that.fSPDtrackletDeltaPhiMin;
230 fIgnoreTPCzRange=that.fIgnoreTPCzRange;
231 fIgnoreTPCzRangeMax=that.fIgnoreTPCzRangeMax;
232 fIgnoreTPCzRangeMin=that.fIgnoreTPCzRangeMin;
233 fCutChi2PerClusterTPC=that.fCutChi2PerClusterTPC;
234 fMaxChi2PerClusterTPC=that.fMaxChi2PerClusterTPC;
235 fMinChi2PerClusterTPC=that.fMinChi2PerClusterTPC;
236 fCutNClustersTPC=that.fCutNClustersTPC;
237 fNClustersTPCMax=that.fNClustersTPCMax;
238 fNClustersTPCMin=that.fNClustersTPCMin;
239 fParamType=that.fParamType;
240 fParamMix=that.fParamMix;
251 fESDpid = that.fESDpid;
252 fPIDsource = that.fPIDsource;
254 if (that.fTPCpidCuts) fTPCpidCuts = new TMatrixF(*(that.fTPCpidCuts));
255 if (that.fTOFpidCuts) fTOFpidCuts = new TMatrixF(*(that.fTOFpidCuts));
256 fTPCTOFpidCrossOverPt=that.fTPCTOFpidCrossOverPt;
258 fAliPID=that.fAliPID;
263 //-----------------------------------------------------------------------
264 AliFlowTrackCuts::~AliFlowTrackCuts()
267 delete fAliESDtrackCuts;
272 //-----------------------------------------------------------------------
273 Bool_t AliFlowTrackCuts::IsSelected(TObject* obj, Int_t id)
276 AliVParticle* vparticle = dynamic_cast<AliVParticle*>(obj);
277 if (vparticle) return PassesCuts(vparticle);
278 AliFlowTrackSimple* flowtrack = dynamic_cast<AliFlowTrackSimple*>(obj);
279 if (flowtrack) return PassesCuts(flowtrack);
280 AliMultiplicity* tracklets = dynamic_cast<AliMultiplicity*>(obj);
281 if (tracklets) return PassesCuts(tracklets,id);
282 return kFALSE; //default when passed wrong type of object
285 //-----------------------------------------------------------------------
286 Bool_t AliFlowTrackCuts::IsSelectedMCtruth(TObject* obj, Int_t id)
289 AliVParticle* vparticle = dynamic_cast<AliVParticle*>(obj);
292 return PassesMCcuts(fMCevent,vparticle->GetLabel());
294 AliMultiplicity* tracklets = dynamic_cast<AliMultiplicity*>(obj);
297 Int_t label0 = tracklets->GetLabel(id,0);
298 Int_t label1 = tracklets->GetLabel(id,1);
299 Int_t label = (label0==label1)?tracklets->GetLabel(id,1):-666;
300 return PassesMCcuts(fMCevent,label);
302 return kFALSE; //default when passed wrong type of object
305 //-----------------------------------------------------------------------
306 Bool_t AliFlowTrackCuts::PassesCuts(AliFlowTrackSimple* track)
308 //check cuts on a flowtracksimple
310 //clean up from last iteration
312 return AliFlowTrackSimpleCuts::PassesCuts(track);
315 //-----------------------------------------------------------------------
316 Bool_t AliFlowTrackCuts::PassesCuts(AliMultiplicity* tracklet, Int_t id)
318 //check cuts on a tracklets
320 //clean up from last iteration, and init label
325 fTrackPhi = tracklet->GetPhi(id);
326 fTrackEta = tracklet->GetEta(id);
328 if (fCutEta) {if ( fTrackEta < fEtaMin || fTrackEta >= fEtaMax ) return kFALSE;}
329 if (fCutPhi) {if ( fTrackPhi < fPhiMin || fTrackPhi >= fPhiMax ) return kFALSE;}
331 //check MC info if available
332 //if the 2 clusters have different label track cannot be good
333 //and should therefore not pass the mc cuts
334 Int_t label0 = tracklet->GetLabel(id,0);
335 Int_t label1 = tracklet->GetLabel(id,1);
336 //if possible get label and mcparticle
337 fTrackLabel = (label0==label1)?tracklet->GetLabel(id,1):-1;
338 if (!fFakesAreOK && fTrackLabel<0) return kFALSE;
339 if (fTrackLabel>=0 && fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
341 if (fCutMC && !PassesMCcuts()) return kFALSE;
345 //-----------------------------------------------------------------------
346 Bool_t AliFlowTrackCuts::PassesMCcuts(AliMCEvent* mcEvent, Int_t label)
349 if (!mcEvent) return kFALSE;
350 if (label<0) return kFALSE;//otherwise AliCMevent prints a warning before returning NULL
351 AliMCParticle* mcparticle = static_cast<AliMCParticle*>(mcEvent->GetTrack(label));
352 if (!mcparticle) {AliError("no MC track"); return kFALSE;}
356 if (IsPhysicalPrimary(mcEvent,label,fRequireTransportBitForPrimaries) != fMCisPrimary) return kFALSE;
360 Int_t pdgCode = mcparticle->PdgCode();
361 if (fIgnoreSignInPID)
363 if (TMath::Abs(fMCPID) != TMath::Abs(pdgCode)) return kFALSE;
367 if (fMCPID != pdgCode) return kFALSE;
370 if ( fCutMCprocessType )
372 TParticle* particle = mcparticle->Particle();
373 Int_t processID = particle->GetUniqueID();
374 if (processID != fMCprocessType ) return kFALSE;
378 //-----------------------------------------------------------------------
379 Bool_t AliFlowTrackCuts::PassesMCcuts()
381 if (!fMCevent) return kFALSE;
382 if (fTrackLabel<0) return kFALSE;//otherwise AliCMevent prints a warning before returning NULL
383 fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
384 return PassesMCcuts(fMCevent,fTrackLabel);
387 //-----------------------------------------------------------------------
388 Bool_t AliFlowTrackCuts::PassesCuts(AliVParticle* vparticle)
390 //check cuts for an ESD vparticle
392 ////////////////////////////////////////////////////////////////
393 // start by preparing the track parameters to cut on //////////
394 ////////////////////////////////////////////////////////////////
395 //clean up from last iteration
398 //get the label and the mc particle
399 fTrackLabel = (fFakesAreOK)?TMath::Abs(vparticle->GetLabel()):vparticle->GetLabel();
400 if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
401 else fMCparticle=NULL;
403 Bool_t isMCparticle = kFALSE; //some things are different for MC particles, check!
404 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*>(vparticle);
406 HandleESDtrack(esdTrack);
409 HandleVParticle(vparticle);
410 //now check if produced particle is MC
411 isMCparticle = (dynamic_cast<AliMCParticle*>(fTrack))!=NULL;
413 ////////////////////////////////////////////////////////////////
414 ////////////////////////////////////////////////////////////////
416 if (!fTrack) return kFALSE;
417 if (esdTrack) esdTrack=static_cast<AliESDtrack*>(fTrack); //because it may be different from global
420 //check the common cuts for the current particle fTrack (MC,AOD,ESD)
421 Double_t pt = fTrack->Pt();
422 if (!fFakesAreOK) {if (fTrackLabel<0) pass=kFALSE;}
423 if (fCutPt) {if (pt < fPtMin || pt >= fPtMax ) pass=kFALSE;}
424 if (fCutEta) {if (fTrack->Eta() < fEtaMin || fTrack->Eta() >= fEtaMax ) pass=kFALSE;}
425 if (fCutPhi) {if (fTrack->Phi() < fPhiMin || fTrack->Phi() >= fPhiMax ) pass=kFALSE;}
426 if (fRequireCharge) {if (fTrack->Charge() == 0) pass=kFALSE;}
427 if (fCutCharge && !isMCparticle) {if (fTrack->Charge() != fCharge) pass=kFALSE;}
428 if (fCutCharge && isMCparticle)
430 //in case of an MC particle the charge is stored in units of 1/3|e|
431 Int_t charge = TMath::Nint(fTrack->Charge()/3.0); //mc particles have charge in units of 1/3e
432 if (charge!=fCharge) pass=kFALSE;
434 //if(fCutPID) {if (fTrack->PID() != fPID) pass=kFALSE;}
436 //when additionally MC info is required
437 if (fCutMC && !PassesMCcuts()) pass=kFALSE;
439 //check all else for ESDs using aliesdtrackcuts
440 if (esdTrack && (fParamType!=kMC) )
442 if (fIgnoreTPCzRange)
444 const AliExternalTrackParam* pin = esdTrack->GetOuterParam();
445 const AliExternalTrackParam* pout = esdTrack->GetInnerParam();
448 Double_t zin = pin->GetZ();
449 Double_t zout = pout->GetZ();
450 if (zin*zout<0) pass=kFALSE; //reject if cross the membrane
451 if (zin < fIgnoreTPCzRangeMin || zin > fIgnoreTPCzRangeMax) pass=kFALSE;
452 if (zout < fIgnoreTPCzRangeMin || zout > fIgnoreTPCzRangeMax) pass=kFALSE;
456 if (fAliESDtrackCuts)
458 if (!fAliESDtrackCuts->IsSelected(static_cast<AliESDtrack*>(fTrack))) pass=kFALSE;
461 Int_t ntpccls = ( fParamType==kESD_TPConly )?
462 esdTrack->GetTPCNclsIter1():esdTrack->GetTPCNcls();
463 if (fCutChi2PerClusterTPC)
465 Float_t tpcchi2 = (fParamType==kESD_TPConly)?
466 esdTrack->GetTPCchi2Iter1():esdTrack->GetTPCchi2();
467 tpcchi2 = (ntpccls>0)?tpcchi2/ntpccls:-FLT_MAX;
468 if (tpcchi2<fMinChi2PerClusterTPC || tpcchi2 >=fMaxChi2PerClusterTPC)
472 if (fCutNClustersTPC)
474 if (ntpccls < fNClustersTPCMin || ntpccls > fNClustersTPCMax) pass=kFALSE;
482 if (!PassesTPCpidCut(esdTrack)) pass=kFALSE;
485 if (!PassesTOFpidCut(esdTrack)) pass=kFALSE;
488 if (pt< fTPCTOFpidCrossOverPt)
490 if (!PassesTPCpidCut(esdTrack)) pass=kFALSE;
492 else //if (pt>=fTPCTOFpidCrossOverPt)
494 if (!PassesTOFpidCut(esdTrack)) pass=kFALSE;
498 printf("AliFlowTrackCuts::PassesCuts() this should never be called!\n");
505 return pass; //true by default, if we didn't set any cuts
508 //-----------------------------------------------------------------------
509 void AliFlowTrackCuts::HandleVParticle(AliVParticle* track)
511 //handle the general case
520 //-----------------------------------------------------------------------
521 void AliFlowTrackCuts::HandleESDtrack(AliESDtrack* track)
530 if (!track->FillTPCOnlyTrack(fTPCtrack))
538 //recalculate the label and mc particle, they may differ as TPClabel != global label
539 fTrackLabel = (fFakesAreOK)?TMath::Abs(fTrack->GetLabel()):fTrack->GetLabel();
540 if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
541 else fMCparticle=NULL;
549 //-----------------------------------------------------------------------
550 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardTPCOnlyTrackCuts()
553 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard TPConly cuts");
554 delete cuts->fAliESDtrackCuts;
555 cuts->fAliESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
556 cuts->SetParamType(kESD_TPConly);
560 //-----------------------------------------------------------------------
561 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardITSTPCTrackCuts2009(Bool_t selPrimaries)
564 AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard global track cuts 2009");
565 delete cuts->fAliESDtrackCuts;
566 cuts->fAliESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(selPrimaries);
567 cuts->SetParamType(kGlobal);
571 //-----------------------------------------------------------------------
572 AliFlowTrack* AliFlowTrackCuts::MakeFlowTrack() const
574 //get a flow track constructed from whatever we applied cuts on
575 //caller is resposible for deletion
576 //if construction fails return NULL
577 AliFlowTrack* flowtrack=NULL;
578 TParticle *tmpTParticle=NULL;
579 AliMCParticle* tmpAliMCParticle=NULL;
580 if (fParamType==kESD_SPDtracklet)
585 flowtrack = new AliFlowTrack();
586 flowtrack->SetPhi(fTrackPhi);
587 flowtrack->SetEta(fTrackEta);
589 case kTrackWithMCkine:
590 if (!fMCparticle) return NULL;
591 flowtrack = new AliFlowTrack();
592 flowtrack->SetPhi( fMCparticle->Phi() );
593 flowtrack->SetEta( fMCparticle->Eta() );
594 flowtrack->SetPt( fMCparticle->Pt() );
597 if (!fMCparticle) return NULL;
598 flowtrack = new AliFlowTrack();
599 flowtrack->SetPhi(fTrackPhi);
600 flowtrack->SetEta(fTrackEta);
601 flowtrack->SetPt(fMCparticle->Pt());
603 case kTrackWithPtFromFirstMother:
604 if (!fMCparticle) return NULL;
605 flowtrack = new AliFlowTrack();
606 flowtrack->SetPhi(fTrackPhi);
607 flowtrack->SetEta(fTrackEta);
608 tmpTParticle = fMCparticle->Particle();
609 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
610 flowtrack->SetPt(tmpAliMCParticle->Pt());
613 flowtrack = new AliFlowTrack();
614 flowtrack->SetPhi(fTrackPhi);
615 flowtrack->SetEta(fTrackEta);
618 flowtrack->SetSource(AliFlowTrack::kFromTracklet);
622 if (!fTrack) return NULL;
626 flowtrack = new AliFlowTrack(fTrack);
628 case kTrackWithMCkine:
629 flowtrack = new AliFlowTrack(fMCparticle);
631 case kTrackWithMCPID:
632 flowtrack = new AliFlowTrack(fTrack);
633 //flowtrack->setPID(...) from mc, when implemented
636 if (!fMCparticle) return NULL;
637 flowtrack = new AliFlowTrack(fTrack);
638 flowtrack->SetPt(fMCparticle->Pt());
640 case kTrackWithPtFromFirstMother:
641 if (!fMCparticle) return NULL;
642 flowtrack = new AliFlowTrack(fTrack);
643 tmpTParticle = fMCparticle->Particle();
644 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
645 flowtrack->SetPt(tmpAliMCParticle->Pt());
648 flowtrack = new AliFlowTrack(fTrack);
651 if (fParamType==kMC) flowtrack->SetSource(AliFlowTrack::kFromMC);
652 else if (dynamic_cast<AliESDtrack*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromESD);
653 else if (dynamic_cast<AliAODTrack*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromAOD);
654 else if (dynamic_cast<AliMCParticle*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromMC);
659 //-----------------------------------------------------------------------
660 Bool_t AliFlowTrackCuts::IsPhysicalPrimary() const
662 //check if current particle is a physical primary
663 if (!fMCevent) return kFALSE;
664 if (fTrackLabel<0) return kFALSE;
665 return IsPhysicalPrimary(fMCevent, fTrackLabel, fRequireTransportBitForPrimaries);
668 //-----------------------------------------------------------------------
669 Bool_t AliFlowTrackCuts::IsPhysicalPrimary(AliMCEvent* mcEvent, Int_t label, Bool_t requiretransported)
671 //check if current particle is a physical primary
672 Bool_t physprim=mcEvent->IsPhysicalPrimary(label);
673 AliMCParticle* track = static_cast<AliMCParticle*>(mcEvent->GetTrack(label));
674 if (!track) return kFALSE;
675 TParticle* particle = track->Particle();
676 Bool_t transported = particle->TestBit(kTransportBit);
677 //printf("label: %i prim: %s, transp: %s, pass: %s\n",label, (physprim)?"YES":"NO ",(transported)?"YES":"NO ",
678 //(physprim && (transported || !requiretransported))?"YES":"NO" );
679 return (physprim && (transported || !requiretransported));
682 //-----------------------------------------------------------------------
683 const char* AliFlowTrackCuts::GetParamTypeName(trackParameterType type)
685 //return the name of the selected parameter type
694 case kESD_SPDtracklet:
695 return "SPD tracklet";
701 //-----------------------------------------------------------------------
702 void AliFlowTrackCuts::DefineHistograms()
704 //define qa histograms
707 //-----------------------------------------------------------------------
708 Int_t AliFlowTrackCuts::GetNumberOfInputObjects() const
710 //get the number of tracks in the input event according source
711 //selection (ESD tracks, tracklets, MC particles etc.)
712 AliESDEvent* esd=NULL;
715 case kESD_SPDtracklet:
716 esd = dynamic_cast<AliESDEvent*>(fEvent);
718 return esd->GetMultiplicity()->GetNumberOfTracklets();
720 if (!fMCevent) return 0;
721 return fMCevent->GetNumberOfTracks();
723 if (!fEvent) return 0;
724 return fEvent->GetNumberOfTracks();
729 //-----------------------------------------------------------------------
730 TObject* AliFlowTrackCuts::GetInputObject(Int_t i)
732 //get the input object according the data source selection:
733 //(esd tracks, traclets, mc particles,etc...)
734 AliESDEvent* esd=NULL;
737 case kESD_SPDtracklet:
738 esd = dynamic_cast<AliESDEvent*>(fEvent);
739 if (!esd) return NULL;
740 return const_cast<AliMultiplicity*>(esd->GetMultiplicity());
742 if (!fMCevent) return NULL;
743 return fMCevent->GetTrack(i);
745 if (!fEvent) return NULL;
746 return fEvent->GetTrack(i);
750 //-----------------------------------------------------------------------
751 void AliFlowTrackCuts::Clear(Option_t*)
763 //-----------------------------------------------------------------------
764 Bool_t AliFlowTrackCuts::PassesTOFpidCut(AliESDtrack* t )
766 //check if passes PID cut using timing in TOF
767 if (!fESDpid) return kFALSE;
768 if (!(t && (t->GetStatus() & AliESDtrack::kTOFout) && (t->GetStatus() & AliESDtrack::kTIME)
769 && (t->GetTOFsignal() > 12000) && (t->GetTOFsignal() < 100000) && (t->GetIntegratedLength() > 365)))
771 Float_t pt = t->Pt();
772 Float_t p = t->GetP();
773 Float_t trackT0 = fESDpid->GetTOFResponse().GetStartTime(p);
774 Float_t timeTOF = t->GetTOFsignal()- trackT0;
775 //2=pion 3=kaon 4=protons
776 Double_t inttimes[5] = {-1.0,-1.0,-1.0,-1.0,-1.0};
777 t->GetIntegratedTimes(inttimes);
778 //construct the pid index because it's screwed up in TOF
788 case AliPID::kProton:
794 Float_t s = timeTOF-inttimes[pid];
796 Float_t* arr = fTOFpidCuts->GetMatrixArray();
797 Int_t col = TMath::BinarySearch(fTOFpidCuts->GetNcols(),arr,static_cast<Float_t>(pt));
798 if (col<0) return kFALSE;
799 Float_t min = (*fTOFpidCuts)(1,col);
800 Float_t max = (*fTOFpidCuts)(2,col);
802 //printf("--------------TOF pid cut %s\n",(s>min && s<max)?"PASS":"FAIL");
803 return (s>min && s<max);
806 //-----------------------------------------------------------------------
807 Bool_t AliFlowTrackCuts::PassesTPCpidCut(AliESDtrack* track)
809 //check if passes PID cut using dedx signal in the TPC
816 printf("no TPCpidCuts\n");
820 const AliExternalTrackParam* tpcparam = track->GetInnerParam();
821 if (!tpcparam) return kFALSE;
822 Float_t sigExp = fESDpid->GetTPCResponse().GetExpectedSignal(tpcparam->GetP(), fAliPID);
823 Float_t sigTPC = track->GetTPCsignal();
824 Float_t s = (sigTPC-sigExp)/sigExp;
825 Double_t pt = track->Pt();
827 Float_t* arr = fTPCpidCuts->GetMatrixArray();
828 Int_t col = TMath::BinarySearch(fTPCpidCuts->GetNcols(),arr,static_cast<Float_t>(pt));
829 if (col<0) return kFALSE;
830 Float_t min = (*fTPCpidCuts)(1,col);
831 Float_t max = (*fTPCpidCuts)(2,col);
833 //printf("------------TPC pid cut %s\n",(s>min && s<max)?"PASS":"FAIL");
834 return (s>min && s<max);
837 //-----------------------------------------------------------------------
838 void AliFlowTrackCuts::InitPIDcuts()
840 //init matrices with PID cuts
844 if (fAliPID==AliPID::kPion)
846 t = new TMatrixF(3,10);
847 (*t)(0,0) = 0.20; (*t)(1,0) = -0.4; (*t)(2,0) = 0.2;
848 (*t)(0,1) = 0.25; (*t)(1,1) = -0.4; (*t)(2,1) = 0.2;
849 (*t)(0,2) = 0.30; (*t)(1,2) = -0.4; (*t)(2,2) = 0.25;
850 (*t)(0,3) = 0.35; (*t)(1,3) = -0.4; (*t)(2,3) = 0.25;
851 (*t)(0,4) = 0.40; (*t)(1,4) = -0.4; (*t)(2,4) = 0.3;
852 (*t)(0,5) = 0.45; (*t)(1,5) = -0.4; (*t)(2,5) = 0.3;
853 (*t)(0,6) = 0.50; (*t)(1,6) = -0.4; (*t)(2,6) = 0.25;
854 (*t)(0,7) = 0.55; (*t)(1,7) = -0.4; (*t)(2,7) = 0.15;
855 (*t)(0,8) = 0.60; (*t)(1,8) = -0.4; (*t)(2,8) = 0.1;
856 (*t)(0,9) = 0.65; (*t)(1,9) = 0; (*t)(2,9) = 0;
859 if (fAliPID==AliPID::kKaon)
861 t = new TMatrixF(3,7);
862 (*t)(0,0) = 0.20; (*t)(1,0) = -0.2; (*t)(2,0) = 0.4;
863 (*t)(0,1) = 0.25; (*t)(1,1) =-0.15; (*t)(2,1) = 0.4;
864 (*t)(0,2) = 0.30; (*t)(1,2) = -0.1; (*t)(2,2) = 0.4;
865 (*t)(0,3) = 0.35; (*t)(1,3) = -0.1; (*t)(2,3) = 0.4;
866 (*t)(0,4) = 0.40; (*t)(1,4) = -0.1; (*t)(2,4) = 0.6;
867 (*t)(0,5) = 0.45; (*t)(1,5) = -0.1; (*t)(2,5) = 0.6;
868 (*t)(0,6) = 0.50; (*t)(1,6) = 0; (*t)(2,6) = 0;
871 if (fAliPID==AliPID::kProton)
873 t = new TMatrixF(3,16);
874 (*t)(0,0) = 0.20; (*t)(1,0) = 0; (*t)(2,0) = 0;
875 (*t)(0,1) = 0.25; (*t)(1,1) = -0.2; (*t)(2,1) = 0.3;
876 (*t)(0,2) = 0.30; (*t)(1,2) = -0.2; (*t)(2,2) = 0.6;
877 (*t)(0,3) = 0.35; (*t)(1,3) = -0.2; (*t)(2,3) = 0.6;
878 (*t)(0,4) = 0.40; (*t)(1,4) = -0.2; (*t)(2,4) = 0.6;
879 (*t)(0,5) = 0.45; (*t)(1,5) = -0.15; (*t)(2,5) = 0.6;
880 (*t)(0,6) = 0.50; (*t)(1,6) = -0.1; (*t)(2,6) = 0.6;
881 (*t)(0,7) = 0.55; (*t)(1,7) = -0.05; (*t)(2,7) = 0.6;
882 (*t)(0,8) = 0.60; (*t)(1,8) = -0.05; (*t)(2,8) = 0.45;
883 (*t)(0,9) = 0.65; (*t)(1,9) = -0.05; (*t)(2,9) = 0.45;
884 (*t)(0,10) = 0.70; (*t)(1,10) = -0.05; (*t)(2,10) = 0.45;
885 (*t)(0,11) = 0.75; (*t)(1,11) = -0.05; (*t)(2,11) = 0.45;
886 (*t)(0,12) = 0.80; (*t)(1,12) = 0; (*t)(2,12) = 0.45;
887 (*t)(0,13) = 0.85; (*t)(1,13) = 0; (*t)(2,13) = 0.45;
888 (*t)(0,14) = 0.90; (*t)(1,14) = 0; (*t)(2,14) = 0.45;
889 (*t)(0,15) = 0.95; (*t)(1,15) = 0; (*t)(2,15) = 0;
896 if (fAliPID==AliPID::kPion)
898 t = new TMatrixF(3,27);
899 (*t)(0,0) = 0.3; (*t)(1,0) = -700; (*t)(2,0) = 700;
900 (*t)(0,1) = 0.35; (*t)(1,1) = -800; (*t)(2,1) = 800;
901 (*t)(0,2) = 0.40; (*t)(1,2) = -600; (*t)(2,2) = 800;
902 (*t)(0,3) = 0.45; (*t)(1,3) = -500; (*t)(2,3) = 700;
903 (*t)(0,4) = 0.50; (*t)(1,4) = -400; (*t)(2,4) = 700;
904 (*t)(0,5) = 0.55; (*t)(1,5) = -400; (*t)(2,5) = 700;
905 (*t)(0,6) = 0.60; (*t)(1,6) = -400; (*t)(2,6) = 700;
906 (*t)(0,7) = 0.65; (*t)(1,7) = -400; (*t)(2,7) = 700;
907 (*t)(0,8) = 0.70; (*t)(1,8) = -400; (*t)(2,8) = 700;
908 (*t)(0,9) = 0.75; (*t)(1,9) = -400; (*t)(2,9) = 700;
909 (*t)(0,10) = 0.80; (*t)(1,10) = -400; (*t)(2,10) = 600;
910 (*t)(0,11) = 0.85; (*t)(1,11) = -400; (*t)(2,11) = 600;
911 (*t)(0,12) = 0.90; (*t)(1,12) = -400; (*t)(2,12) = 600;
912 (*t)(0,13) = 0.95; (*t)(1,13) = -400; (*t)(2,13) = 600;
913 (*t)(0,14) = 1.00; (*t)(1,14) = -400; (*t)(2,14) = 550;
914 (*t)(0,15) = 1.10; (*t)(1,15) = -400; (*t)(2,15) = 450;
915 (*t)(0,16) = 1.20; (*t)(1,16) = -400; (*t)(2,16) = 400;
916 (*t)(0,17) = 1.30; (*t)(1,17) = -400; (*t)(2,17) = 300;
917 (*t)(0,18) = 1.40; (*t)(1,18) = -400; (*t)(2,18) = 300;
918 (*t)(0,19) = 1.50; (*t)(1,19) = -400; (*t)(2,19) = 250;
919 (*t)(0,20) = 1.60; (*t)(1,20) = -400; (*t)(2,20) = 200;
920 (*t)(0,21) = 1.70; (*t)(1,21) = -400; (*t)(2,21) = 150;
921 (*t)(0,22) = 1.80; (*t)(1,22) = -400; (*t)(2,22) = 100;
922 (*t)(0,23) = 1.90; (*t)(1,23) = -400; (*t)(2,23) = 70;
923 (*t)(0,24) = 2.00; (*t)(1,24) = -400; (*t)(2,24) = 50;
924 (*t)(0,25) = 2.10; (*t)(1,25) = -400; (*t)(2,25) = 0;
925 (*t)(0,26) = 2.20; (*t)(1,26) = 0; (*t)(2,26) = 0;
928 if (fAliPID==AliPID::kProton)
930 t = new TMatrixF(3,39);
931 (*t)(0,0) = 0.3; (*t)(1,0) = 0; (*t)(2,0) = 0;
932 (*t)(0,1) = 0.35; (*t)(1,1) = 0; (*t)(2,1) = 0;
933 (*t)(0,2) = 0.40; (*t)(1,2) = 0; (*t)(2,2) = 0;
934 (*t)(0,3) = 0.45; (*t)(1,3) = 0; (*t)(2,3) = 0;
935 (*t)(0,4) = 0.50; (*t)(1,4) = 0; (*t)(2,4) = 0;
936 (*t)(0,5) = 0.55; (*t)(1,5) = -900; (*t)(2,5) = 600;
937 (*t)(0,6) = 0.60; (*t)(1,6) = -800; (*t)(2,6) = 600;
938 (*t)(0,7) = 0.65; (*t)(1,7) = -800; (*t)(2,7) = 600;
939 (*t)(0,8) = 0.70; (*t)(1,8) = -800; (*t)(2,8) = 600;
940 (*t)(0,9) = 0.75; (*t)(1,9) = -700; (*t)(2,9) = 500;
941 (*t)(0,10) = 0.80; (*t)(1,10) = -700; (*t)(2,10) = 500;
942 (*t)(0,11) = 0.85; (*t)(1,11) = -700; (*t)(2,11) = 500;
943 (*t)(0,12) = 0.90; (*t)(1,12) = -600; (*t)(2,12) = 500;
944 (*t)(0,13) = 0.95; (*t)(1,13) = -600; (*t)(2,13) = 500;
945 (*t)(0,14) = 1.00; (*t)(1,14) = -600; (*t)(2,14) = 500;
946 (*t)(0,15) = 1.10; (*t)(1,15) = -600; (*t)(2,15) = 500;
947 (*t)(0,16) = 1.20; (*t)(1,16) = -500; (*t)(2,16) = 500;
948 (*t)(0,17) = 1.30; (*t)(1,17) = -500; (*t)(2,17) = 500;
949 (*t)(0,18) = 1.40; (*t)(1,18) = -500; (*t)(2,18) = 500;
950 (*t)(0,19) = 1.50; (*t)(1,19) = -500; (*t)(2,19) = 500;
951 (*t)(0,20) = 1.60; (*t)(1,20) = -400; (*t)(2,20) = 500;
952 (*t)(0,21) = 1.70; (*t)(1,21) = -400; (*t)(2,21) = 500;
953 (*t)(0,22) = 1.80; (*t)(1,22) = -400; (*t)(2,22) = 500;
954 (*t)(0,23) = 1.90; (*t)(1,23) = -400; (*t)(2,23) = 500;
955 (*t)(0,24) = 2.00; (*t)(1,24) = -400; (*t)(2,24) = 500;
956 (*t)(0,25) = 2.10; (*t)(1,25) = -350; (*t)(2,25) = 500;
957 (*t)(0,26) = 2.20; (*t)(1,26) = -350; (*t)(2,26) = 500;
958 (*t)(0,27) = 2.30; (*t)(1,27) = -300; (*t)(2,27) = 500;
959 (*t)(0,28) = 2.40; (*t)(1,28) = -300; (*t)(2,28) = 500;
960 (*t)(0,29) = 2.50; (*t)(1,29) = -300; (*t)(2,29) = 500;
961 (*t)(0,30) = 2.60; (*t)(1,30) = -250; (*t)(2,30) = 500;
962 (*t)(0,31) = 2.70; (*t)(1,31) = -200; (*t)(2,31) = 500;
963 (*t)(0,32) = 2.80; (*t)(1,32) = -150; (*t)(2,32) = 500;
964 (*t)(0,33) = 2.90; (*t)(1,33) = -150; (*t)(2,33) = 500;
965 (*t)(0,34) = 3.00; (*t)(1,34) = -100; (*t)(2,34) = 400;
966 (*t)(0,35) = 3.10; (*t)(1,35) = -100; (*t)(2,35) = 400;
967 (*t)(0,36) = 3.20; (*t)(1,36) = 0; (*t)(2,36) = 0;
968 (*t)(0,37) = 3.30; (*t)(1,37) = 0; (*t)(2,37) = 0;
969 (*t)(0,38) = 3.40; (*t)(1,38) = 0; (*t)(2,38) = 0;
972 if (fAliPID==AliPID::kKaon)
974 t = new TMatrixF(3,23);
975 (*t)(0,0) = 0.3; (*t)(1,0) = 0; (*t)(2,0) = 0;
976 (*t)(0,1) = 0.35; (*t)(1,1) = 0; (*t)(2,1) = 0;
977 (*t)(0,2) = 0.40; (*t)(1,2) = -800; (*t)(2,2) = 600;
978 (*t)(0,3) = 0.45; (*t)(1,3) = -800; (*t)(2,3) = 600;
979 (*t)(0,4) = 0.50; (*t)(1,4) = -800; (*t)(2,4) = 600;
980 (*t)(0,5) = 0.55; (*t)(1,5) = -800; (*t)(2,5) = 600;
981 (*t)(0,6) = 0.60; (*t)(1,6) = -800; (*t)(2,6) = 600;
982 (*t)(0,7) = 0.65; (*t)(1,7) = -700; (*t)(2,7) = 600;
983 (*t)(0,8) = 0.70; (*t)(1,8) = -600; (*t)(2,8) = 600;
984 (*t)(0,9) = 0.75; (*t)(1,9) = -600; (*t)(2,9) = 500;
985 (*t)(0,10) = 0.80; (*t)(1,10) = -500; (*t)(2,10) = 500;
986 (*t)(0,11) = 0.85; (*t)(1,11) = -500; (*t)(2,11) = 500;
987 (*t)(0,12) = 0.90; (*t)(1,12) = -400; (*t)(2,12) = 500;
988 (*t)(0,13) = 0.95; (*t)(1,13) = -400; (*t)(2,13) = 500;
989 (*t)(0,14) = 1.00; (*t)(1,14) = -400; (*t)(2,14) = 500;
990 (*t)(0,15) = 1.10; (*t)(1,15) = -350; (*t)(2,15) = 450;
991 (*t)(0,16) = 1.20; (*t)(1,16) = -300; (*t)(2,16) = 400;
992 (*t)(0,17) = 1.30; (*t)(1,17) = -300; (*t)(2,17) = 400;
993 (*t)(0,18) = 1.40; (*t)(1,18) = -250; (*t)(2,18) = 400;
994 (*t)(0,19) = 1.50; (*t)(1,19) = -200; (*t)(2,19) = 400;
995 (*t)(0,20) = 1.60; (*t)(1,20) = -150; (*t)(2,20) = 400;
996 (*t)(0,21) = 1.70; (*t)(1,21) = -100; (*t)(2,21) = 400;
997 (*t)(0,22) = 1.80; (*t)(1,22) = 0; (*t)(2,22) = 0;