changes from Per Thomas:
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliFlowTrackCuts.cxx
CommitLineData
daf66719 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18// AliFlowTrackCuts:
19// ESD track cuts for flow framework
20//
21// origin: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch)
5559ce24 22//
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:
26// ESD, MC, AOD.
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.
daf66719 36
37#include <limits.h>
38#include <float.h>
9a0783cc 39#include "TParticle.h"
2948ac5a 40#include "TObjArray.h"
9a0783cc 41#include "AliStack.h"
daf66719 42#include "AliMCEvent.h"
9a0783cc 43#include "AliESDEvent.h"
daf66719 44#include "AliVParticle.h"
45#include "AliMCParticle.h"
46#include "AliESDtrack.h"
12b2b8bc 47#include "AliMultiplicity.h"
daf66719 48#include "AliAODTrack.h"
49#include "AliFlowTrack.h"
50#include "AliFlowTrackCuts.h"
51#include "AliLog.h"
52
53ClassImp(AliFlowTrackCuts)
54
55//-----------------------------------------------------------------------
56AliFlowTrackCuts::AliFlowTrackCuts():
57 AliFlowTrackSimpleCuts(),
58 fAliESDtrackCuts(new AliESDtrackCuts()),
a1c43d26 59 fQA(NULL),
1ff4bda1 60 fCutMC(kFALSE),
daf66719 61 fCutMCprocessType(kFALSE),
62 fMCprocessType(kPNoProcess),
63 fCutMCPID(kFALSE),
64 fMCPID(0),
4cbcbead 65 fIgnoreSignInPID(kFALSE),
daf66719 66 fCutMCisPrimary(kFALSE),
67 fMCisPrimary(kFALSE),
957517fa 68 fRequireCharge(kFALSE),
127a5825 69 fFakesAreOK(kTRUE),
9a0783cc 70 fCutSPDtrackletDeltaPhi(kFALSE),
71 fSPDtrackletDeltaPhiMax(FLT_MAX),
72 fSPDtrackletDeltaPhiMin(-FLT_MAX),
1ff4bda1 73 fIgnoreTPCzRange(kFALSE),
74 fIgnoreTPCzRangeMax(FLT_MAX),
75 fIgnoreTPCzRangeMin(-FLT_MAX),
2948ac5a 76 fCutChi2PerClusterTPC(kFALSE),
77 fMaxChi2PerClusterTPC(FLT_MAX),
78 fMinChi2PerClusterTPC(-FLT_MAX),
12b2b8bc 79 fParamType(kGlobal),
daf66719 80 fParamMix(kPure),
daf66719 81 fTrack(NULL),
12b2b8bc 82 fTrackPhi(0.),
83 fTrackEta(0.),
84 fTrackWeight(0.),
127a5825 85 fTrackLabel(INT_MIN),
957517fa 86 fMCevent(NULL),
9a0783cc 87 fMCparticle(NULL),
1ff4bda1 88 fEvent(NULL),
89 fTPCtrack()
daf66719 90{
91 //constructor
92}
93
94//-----------------------------------------------------------------------
ee242db3 95AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
96 AliFlowTrackSimpleCuts(that),
97 fAliESDtrackCuts(new AliESDtrackCuts(*(that.fAliESDtrackCuts))),
a1c43d26 98 fQA(NULL),
1ff4bda1 99 fCutMC(that.fCutMC),
ee242db3 100 fCutMCprocessType(that.fCutMCprocessType),
101 fMCprocessType(that.fMCprocessType),
102 fCutMCPID(that.fCutMCPID),
103 fMCPID(that.fMCPID),
4cbcbead 104 fIgnoreSignInPID(that.fIgnoreSignInPID),
ee242db3 105 fCutMCisPrimary(that.fCutMCisPrimary),
106 fMCisPrimary(that.fMCisPrimary),
107 fRequireCharge(that.fRequireCharge),
108 fFakesAreOK(that.fFakesAreOK),
109 fCutSPDtrackletDeltaPhi(that.fCutSPDtrackletDeltaPhi),
110 fSPDtrackletDeltaPhiMax(that.fSPDtrackletDeltaPhiMax),
111 fSPDtrackletDeltaPhiMin(that.fSPDtrackletDeltaPhiMin),
1ff4bda1 112 fIgnoreTPCzRange(that.fIgnoreTPCzRange),
113 fIgnoreTPCzRangeMax(that.fIgnoreTPCzRangeMax),
114 fIgnoreTPCzRangeMin(that.fIgnoreTPCzRangeMin),
2948ac5a 115 fCutChi2PerClusterTPC(that.fCutChi2PerClusterTPC),
116 fMaxChi2PerClusterTPC(that.fMaxChi2PerClusterTPC),
117 fMinChi2PerClusterTPC(that.fMinChi2PerClusterTPC),
ee242db3 118 fParamType(that.fParamType),
119 fParamMix(that.fParamMix),
daf66719 120 fTrack(NULL),
ee242db3 121 fTrackPhi(0.),
122 fTrackEta(0.),
123 fTrackWeight(0.),
127a5825 124 fTrackLabel(INT_MIN),
957517fa 125 fMCevent(NULL),
9a0783cc 126 fMCparticle(NULL),
1ff4bda1 127 fEvent(NULL),
a1c43d26 128 fTPCtrack()
daf66719 129{
130 //copy constructor
131}
132
133//-----------------------------------------------------------------------
ee242db3 134AliFlowTrackCuts& AliFlowTrackCuts::operator=(const AliFlowTrackCuts& that)
daf66719 135{
136 //assignment
ee242db3 137 AliFlowTrackSimpleCuts::operator=(that);
138 *fAliESDtrackCuts=*(that.fAliESDtrackCuts);
a1c43d26 139 fQA=NULL;
1ff4bda1 140 fCutMC=that.fCutMC;
ee242db3 141 fCutMCprocessType=that.fCutMCprocessType;
142 fMCprocessType=that.fMCprocessType;
143 fCutMCPID=that.fCutMCPID;
144 fMCPID=that.fMCPID;
4cbcbead 145 fIgnoreSignInPID=that.fIgnoreSignInPID,
ee242db3 146 fCutMCisPrimary=that.fCutMCisPrimary;
147 fMCisPrimary=that.fMCisPrimary;
148 fRequireCharge=that.fRequireCharge;
149 fFakesAreOK=that.fFakesAreOK;
150 fCutSPDtrackletDeltaPhi=that.fCutSPDtrackletDeltaPhi;
151 fSPDtrackletDeltaPhiMax=that.fSPDtrackletDeltaPhiMax;
152 fSPDtrackletDeltaPhiMin=that.fSPDtrackletDeltaPhiMin;
1ff4bda1 153 fIgnoreTPCzRange=that.fIgnoreTPCzRange;
154 fIgnoreTPCzRangeMax=that.fIgnoreTPCzRangeMax;
155 fIgnoreTPCzRangeMin=that.fIgnoreTPCzRangeMin;
2948ac5a 156 fCutChi2PerClusterTPC=that.fCutChi2PerClusterTPC;
157 fMaxChi2PerClusterTPC=that.fMaxChi2PerClusterTPC;
158 fMinChi2PerClusterTPC=that.fMinChi2PerClusterTPC;
ee242db3 159 fParamType=that.fParamType;
160 fParamMix=that.fParamMix;
daf66719 161
daf66719 162 fTrack=NULL;
ee242db3 163 fTrackPhi=0.;
164 fTrackPhi=0.;
165 fTrackWeight=0.;
127a5825 166 fTrackLabel=INT_MIN;
957517fa 167 fMCevent=NULL;
daf66719 168 fMCparticle=NULL;
9a0783cc 169 fEvent=NULL;
daf66719 170
171 return *this;
172}
173
174//-----------------------------------------------------------------------
175AliFlowTrackCuts::~AliFlowTrackCuts()
176{
177 //dtor
daf66719 178 delete fAliESDtrackCuts;
179}
180
181//-----------------------------------------------------------------------
12b2b8bc 182Bool_t AliFlowTrackCuts::IsSelected(TObject* obj, Int_t id)
daf66719 183{
184 //check cuts
185 AliVParticle* vparticle = dynamic_cast<AliVParticle*>(obj);
186 if (vparticle) return PassesCuts(vparticle);
187 AliFlowTrackSimple* flowtrack = dynamic_cast<AliFlowTrackSimple*>(obj);
188 if (flowtrack) return PassesCuts(flowtrack);
12b2b8bc 189 AliMultiplicity* tracklets = dynamic_cast<AliMultiplicity*>(obj);
190 if (tracklets) return PassesCuts(tracklets,id);
daf66719 191 return kFALSE; //default when passed wrong type of object
192}
193
194//-----------------------------------------------------------------------
1ff4bda1 195Bool_t AliFlowTrackCuts::IsSelectedMCtruth(TObject* obj, Int_t id)
196{
197 //check cuts
198 AliVParticle* vparticle = dynamic_cast<AliVParticle*>(obj);
199 if (vparticle)
200 {
201 return PassesMCcuts(fMCevent,vparticle->GetLabel());
202 }
203 AliMultiplicity* tracklets = dynamic_cast<AliMultiplicity*>(obj);
204 if (tracklets)
205 {
206 Int_t label0 = tracklets->GetLabel(id,0);
207 Int_t label1 = tracklets->GetLabel(id,1);
208 Int_t label = (label0==label1)?tracklets->GetLabel(id,1):-666;
209 return PassesMCcuts(fMCevent,label);
210 }
211 return kFALSE; //default when passed wrong type of object
212}
213
214//-----------------------------------------------------------------------
daf66719 215Bool_t AliFlowTrackCuts::PassesCuts(AliFlowTrackSimple* track)
216{
217 //check cuts on a flowtracksimple
5559ce24 218
219 //clean up from last iteration
1ff4bda1 220 fTrack = NULL;
daf66719 221 return AliFlowTrackSimpleCuts::PassesCuts(track);
222}
223
224//-----------------------------------------------------------------------
12b2b8bc 225Bool_t AliFlowTrackCuts::PassesCuts(AliMultiplicity* tracklet, Int_t id)
226{
227 //check cuts on a tracklets
228
9a0783cc 229 //clean up from last iteration, and init label
1ff4bda1 230 fTrack = NULL;
12b2b8bc 231 fMCparticle=NULL;
9a0783cc 232 fTrackLabel=-1;
12b2b8bc 233
234 fTrackPhi = tracklet->GetPhi(id);
235 fTrackEta = tracklet->GetEta(id);
236 fTrackWeight = 1.0;
237 if (fCutEta) {if ( fTrackEta < fEtaMin || fTrackEta >= fEtaMax ) return kFALSE;}
238 if (fCutPhi) {if ( fTrackPhi < fPhiMin || fTrackPhi >= fPhiMax ) return kFALSE;}
239
240 //check MC info if available
9a0783cc 241 //if the 2 clusters have different label track cannot be good
242 //and should therefore not pass the mc cuts
243 Int_t label0 = tracklet->GetLabel(id,0);
244 Int_t label1 = tracklet->GetLabel(id,1);
d0471ea0 245 //if possible get label and mcparticle
9a0783cc 246 fTrackLabel = (label0==label1)?tracklet->GetLabel(id,1):-1;
7afa829c 247 if (!fFakesAreOK && fTrackLabel<0) return kFALSE;
d0471ea0 248 if (fTrackLabel>=0 && fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
249 //check MC cuts
1ff4bda1 250 if (fCutMC && !PassesMCcuts()) return kFALSE;
12b2b8bc 251 return kTRUE;
252}
253
254//-----------------------------------------------------------------------
1ff4bda1 255Bool_t AliFlowTrackCuts::PassesMCcuts(AliMCEvent* mcEvent, Int_t label)
12b2b8bc 256{
257 //check the MC info
1ff4bda1 258 if (!mcEvent) return kFALSE;
259 if (label<0) return kFALSE;//otherwise AliCMevent prints a warning before returning NULL
260 AliMCParticle* mcparticle = static_cast<AliMCParticle*>(mcEvent->GetTrack(label));
261 if (!mcparticle) {AliError("no MC track"); return kFALSE;}
12b2b8bc 262
263 if (fCutMCisPrimary)
264 {
1ff4bda1 265 if (IsPhysicalPrimary(mcEvent,label) != fMCisPrimary) return kFALSE;
12b2b8bc 266 }
267 if (fCutMCPID)
268 {
1ff4bda1 269 Int_t pdgCode = mcparticle->PdgCode();
4cbcbead 270 if (fIgnoreSignInPID)
271 {
272 if (TMath::Abs(fMCPID) != TMath::Abs(pdgCode)) return kFALSE;
273 }
274 else
275 {
276 if (fMCPID != pdgCode) return kFALSE;
277 }
12b2b8bc 278 }
279 if ( fCutMCprocessType )
280 {
1ff4bda1 281 TParticle* particle = mcparticle->Particle();
12b2b8bc 282 Int_t processID = particle->GetUniqueID();
283 if (processID != fMCprocessType ) return kFALSE;
284 }
285 return kTRUE;
286}
1ff4bda1 287//-----------------------------------------------------------------------
288Bool_t AliFlowTrackCuts::PassesMCcuts()
289{
290 if (!fMCevent) return kFALSE;
291 if (fTrackLabel<0) return kFALSE;//otherwise AliCMevent prints a warning before returning NULL
292 fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
293 return PassesMCcuts(fMCevent,fTrackLabel);
294}
12b2b8bc 295
296//-----------------------------------------------------------------------
daf66719 297Bool_t AliFlowTrackCuts::PassesCuts(AliVParticle* vparticle)
298{
299 //check cuts for an ESD vparticle
300
127a5825 301 ////////////////////////////////////////////////////////////////
302 // start by preparing the track parameters to cut on //////////
303 ////////////////////////////////////////////////////////////////
5559ce24 304 //clean up from last iteration
1ff4bda1 305 fTrack=NULL;
5559ce24 306
957517fa 307 //get the label and the mc particle
127a5825 308 fTrackLabel = (fFakesAreOK)?TMath::Abs(vparticle->GetLabel()):vparticle->GetLabel();
309 if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
daf66719 310 else fMCparticle=NULL;
311
957517fa 312 Bool_t isMCparticle = kFALSE; //some things are different for MC particles, check!
daf66719 313 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*>(vparticle);
314 if (esdTrack)
315 HandleESDtrack(esdTrack);
316 else
957517fa 317 {
daf66719 318 HandleVParticle(vparticle);
957517fa 319 //now check if produced particle is MC
320 isMCparticle = (dynamic_cast<AliMCParticle*>(fTrack))!=NULL;
321 }
127a5825 322 ////////////////////////////////////////////////////////////////
323 ////////////////////////////////////////////////////////////////
324
1ff4bda1 325 if (!fTrack) return kFALSE;
2948ac5a 326
924b02b0 327 Bool_t pass=kTRUE;
9a0783cc 328 //check the common cuts for the current particle fTrack (MC,AOD,ESD)
7afa829c 329 if (!fFakesAreOK) {if (fTrackLabel<0) pass=kFALSE;}
924b02b0 330 if (fCutPt) {if (fTrack->Pt() < fPtMin || fTrack->Pt() >= fPtMax ) pass=kFALSE;}
331 if (fCutEta) {if (fTrack->Eta() < fEtaMin || fTrack->Eta() >= fEtaMax ) pass=kFALSE;}
332 if (fCutPhi) {if (fTrack->Phi() < fPhiMin || fTrack->Phi() >= fPhiMax ) pass=kFALSE;}
333 if (fRequireCharge) {if (fTrack->Charge() == 0) pass=kFALSE;}
334 if (fCutCharge && !isMCparticle) {if (fTrack->Charge() != fCharge) pass=kFALSE;}
957517fa 335 if (fCutCharge && isMCparticle)
336 {
337 //in case of an MC particle the charge is stored in units of 1/3|e|
338 Int_t charge = TMath::Nint(fTrack->Charge()/3.0); //mc particles have charge in units of 1/3e
339 return (charge==fCharge);
340 }
924b02b0 341 //if(fCutPID) {if (fTrack->PID() != fPID) pass=kFALSE;}
daf66719 342
957517fa 343 //when additionally MC info is required
1ff4bda1 344 if (fCutMC && !PassesMCcuts()) pass=kFALSE;
daf66719 345
346 //check all else for ESDs using aliesdtrackcuts
924b02b0 347 if (esdTrack && (fParamType!=kMC) )
1ff4bda1 348 {
349 if (fIgnoreTPCzRange)
350 {
351 const AliExternalTrackParam* pin = esdTrack->GetOuterParam();
352 const AliExternalTrackParam* pout = esdTrack->GetInnerParam();
353 if (pin&&pout)
354 {
355 Double_t zin = pin->GetZ();
356 Double_t zout = pout->GetZ();
357 if (zin*zout<0) pass=kFALSE; //reject if cross the membrane
358 if (zin < fIgnoreTPCzRangeMin || zin > fIgnoreTPCzRangeMax) pass=kFALSE;
359 if (zout < fIgnoreTPCzRangeMin || zout > fIgnoreTPCzRangeMax) pass=kFALSE;
360 }
361 }
924b02b0 362 if (!fAliESDtrackCuts->IsSelected(static_cast<AliESDtrack*>(fTrack))) pass=kFALSE;
2948ac5a 363 if (fCutChi2PerClusterTPC)
364 {
365 Float_t tpcchi2 = (fParamType==kESD_TPConly)?
366 esdTrack->GetTPCchi2Iter1():esdTrack->GetTPCchi2();
367 Int_t ntpccls = esdTrack->GetTPCNcls();
368 tpcchi2 = (ntpccls>0)?tpcchi2/ntpccls:-FLT_MAX;
369 if (tpcchi2<fMinChi2PerClusterTPC || tpcchi2 >=fMaxChi2PerClusterTPC)
370 pass=kFALSE;
371 }
1ff4bda1 372 }
daf66719 373
924b02b0 374 return pass; //true by default, if we didn't set any cuts
daf66719 375}
376
377//-----------------------------------------------------------------------
378void AliFlowTrackCuts::HandleVParticle(AliVParticle* track)
379{
380 //handle the general case
daf66719 381 switch (fParamType)
382 {
daf66719 383 default:
daf66719 384 fTrack = track;
385 }
386}
387
388//-----------------------------------------------------------------------
389void AliFlowTrackCuts::HandleESDtrack(AliESDtrack* track)
390{
391 //handle esd track
daf66719 392 switch (fParamType)
393 {
12b2b8bc 394 case kGlobal:
daf66719 395 fTrack = track;
daf66719 396 break;
397 case kESD_TPConly:
1ff4bda1 398 if (!track->FillTPCOnlyTrack(fTPCtrack))
399 {
400 fTrack=NULL;
401 fMCparticle=NULL;
402 fTrackLabel=-1;
403 return;
404 }
405 fTrack = &fTPCtrack;
957517fa 406 //recalculate the label and mc particle, they may differ as TPClabel != global label
127a5825 407 fTrackLabel = (fFakesAreOK)?TMath::Abs(fTrack->GetLabel()):fTrack->GetLabel();
408 if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(fTrackLabel));
957517fa 409 else fMCparticle=NULL;
daf66719 410 break;
daf66719 411 default:
412 fTrack = track;
daf66719 413 }
414}
415
416//-----------------------------------------------------------------------
417AliFlowTrackCuts* AliFlowTrackCuts::GetStandardTPCOnlyTrackCuts()
418{
419 //get standard cuts
420 AliFlowTrackCuts* cuts = new AliFlowTrackCuts();
5559ce24 421 cuts->SetName("standard TPConly cuts");
daf66719 422 delete cuts->fAliESDtrackCuts;
423 cuts->fAliESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
5559ce24 424 cuts->SetParamType(kESD_TPConly);
daf66719 425 return cuts;
426}
427
428//-----------------------------------------------------------------------
429AliFlowTrackCuts* AliFlowTrackCuts::GetStandardITSTPCTrackCuts2009(Bool_t selPrimaries)
430{
431 //get standard cuts
432 AliFlowTrackCuts* cuts = new AliFlowTrackCuts();
433 cuts->SetName("standard global track cuts 2009");
434 delete cuts->fAliESDtrackCuts;
435 cuts->fAliESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(selPrimaries);
12b2b8bc 436 cuts->SetParamType(kGlobal);
daf66719 437 return cuts;
438}
439
440//-----------------------------------------------------------------------
441AliFlowTrack* AliFlowTrackCuts::MakeFlowTrack() const
442{
443 //get a flow track constructed from whatever we applied cuts on
444 //caller is resposible for deletion
9a0783cc 445 //if construction fails return NULL
daf66719 446 AliFlowTrack* flowtrack=NULL;
d0471ea0 447 TParticle *tmpTParticle=NULL;
448 AliMCParticle* tmpAliMCParticle=NULL;
12b2b8bc 449 if (fParamType==kESD_SPDtracklet)
daf66719 450 {
9a0783cc 451 switch (fParamMix)
452 {
453 case kPure:
d0471ea0 454 flowtrack = new AliFlowTrack();
9a0783cc 455 flowtrack->SetPhi(fTrackPhi);
456 flowtrack->SetEta(fTrackEta);
457 break;
458 case kTrackWithMCkine:
459 if (!fMCparticle) return NULL;
d0471ea0 460 flowtrack = new AliFlowTrack();
9a0783cc 461 flowtrack->SetPhi( fMCparticle->Phi() );
462 flowtrack->SetEta( fMCparticle->Eta() );
463 flowtrack->SetPt( fMCparticle->Pt() );
464 break;
465 case kTrackWithMCpt:
466 if (!fMCparticle) return NULL;
d0471ea0 467 flowtrack = new AliFlowTrack();
9a0783cc 468 flowtrack->SetPhi(fTrackPhi);
469 flowtrack->SetEta(fTrackEta);
470 flowtrack->SetPt(fMCparticle->Pt());
471 break;
d0471ea0 472 case kTrackWithPtFromFirstMother:
473 if (!fMCparticle) return NULL;
474 flowtrack = new AliFlowTrack();
475 flowtrack->SetPhi(fTrackPhi);
476 flowtrack->SetEta(fTrackEta);
477 tmpTParticle = fMCparticle->Particle();
478 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
479 flowtrack->SetPt(tmpAliMCParticle->Pt());
9a0783cc 480 default:
d0471ea0 481 flowtrack = new AliFlowTrack();
9a0783cc 482 flowtrack->SetPhi(fTrackPhi);
483 flowtrack->SetEta(fTrackEta);
484 }
12b2b8bc 485 flowtrack->SetSource(AliFlowTrack::kFromTracklet);
486 }
487 else
488 {
1ff4bda1 489 if (!fTrack) return NULL;
12b2b8bc 490 switch(fParamMix)
491 {
492 case kPure:
493 flowtrack = new AliFlowTrack(fTrack);
494 break;
495 case kTrackWithMCkine:
496 flowtrack = new AliFlowTrack(fMCparticle);
497 break;
498 case kTrackWithMCPID:
499 flowtrack = new AliFlowTrack(fTrack);
9a0783cc 500 //flowtrack->setPID(...) from mc, when implemented
12b2b8bc 501 break;
9a0783cc 502 case kTrackWithMCpt:
503 if (!fMCparticle) return NULL;
504 flowtrack = new AliFlowTrack(fTrack);
505 flowtrack->SetPt(fMCparticle->Pt());
d0471ea0 506 case kTrackWithPtFromFirstMother:
507 if (!fMCparticle) return NULL;
508 flowtrack = new AliFlowTrack(fTrack);
509 tmpTParticle = fMCparticle->Particle();
510 tmpAliMCParticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(tmpTParticle->GetFirstMother()));
511 flowtrack->SetPt(tmpAliMCParticle->Pt());
12b2b8bc 512 default:
513 flowtrack = new AliFlowTrack(fTrack);
514 }
515 if (fParamType==kMC) flowtrack->SetSource(AliFlowTrack::kFromMC);
516 else if (dynamic_cast<AliESDtrack*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromESD);
517 else if (dynamic_cast<AliAODTrack*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromAOD);
518 else if (dynamic_cast<AliMCParticle*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromMC);
daf66719 519 }
daf66719 520 return flowtrack;
521}
127a5825 522
523//-----------------------------------------------------------------------
524Bool_t AliFlowTrackCuts::IsPhysicalPrimary() const
525{
526 //check if current particle is a physical primary
9a0783cc 527 if (!fMCevent) return kFALSE;
528 if (fTrackLabel<0) return kFALSE;
529 return IsPhysicalPrimary(fMCevent, fTrackLabel);
530}
531
532//-----------------------------------------------------------------------
533Bool_t AliFlowTrackCuts::IsPhysicalPrimary(AliMCEvent* mcEvent, Int_t label)
534{
535 //check if current particle is a physical primary
536 Bool_t physprim=mcEvent->IsPhysicalPrimary(label);
537 if (!physprim) return kFALSE;
538 AliMCParticle* track = static_cast<AliMCParticle*>(mcEvent->GetTrack(label));
539 if (!track) return kFALSE;
540 TParticle* particle = track->Particle();
541 Bool_t transported = particle->TestBit(kTransportBit);
542 //printf("prim: %s, transp: %s\n",(physprim)?"YES":"NO ",(transported)?"YES":"NO ");
543 return (physprim && transported);
127a5825 544}
12b2b8bc 545
546//-----------------------------------------------------------------------
547const char* AliFlowTrackCuts::GetParamTypeName(trackParameterType type)
548{
549 //return the name of the selected parameter type
550 switch (type)
551 {
552 case kMC:
553 return "MC";
554 case kGlobal:
555 return "ESD global";
556 case kESD_TPConly:
557 return "TPC only";
558 case kESD_SPDtracklet:
559 return "SPD tracklet";
560 default:
561 return "unknown";
562 }
563 return "unknown";
564}
924b02b0 565
566//-----------------------------------------------------------------------
567void AliFlowTrackCuts::DefineHistograms()
568{
569}
9a0783cc 570
571//-----------------------------------------------------------------------
572Int_t AliFlowTrackCuts::GetNumberOfInputObjects() const
573{
574 //get the number of tracks in the input event according source
575 //selection (ESD tracks, tracklets, MC particles etc.)
576 AliESDEvent* esd=NULL;
577 switch (fParamType)
578 {
579 case kESD_SPDtracklet:
580 esd = dynamic_cast<AliESDEvent*>(fEvent);
581 if (!esd) return 0;
582 return esd->GetMultiplicity()->GetNumberOfTracklets();
583 case kMC:
584 if (!fMCevent) return 0;
585 return fMCevent->GetNumberOfTracks();
586 default:
587 if (!fEvent) return 0;
588 return fEvent->GetNumberOfTracks();
589 }
590 return 0;
591}
592
593//-----------------------------------------------------------------------
594TObject* AliFlowTrackCuts::GetInputObject(Int_t i)
595{
596 //get the input object according the data source selection:
597 //(esd tracks, traclets, mc particles,etc...)
598 AliESDEvent* esd=NULL;
599 switch (fParamType)
600 {
601 case kESD_SPDtracklet:
602 esd = dynamic_cast<AliESDEvent*>(fEvent);
603 if (!esd) return NULL;
604 return const_cast<AliMultiplicity*>(esd->GetMultiplicity());
605 case kMC:
606 if (!fMCevent) return NULL;
607 return fMCevent->GetTrack(i);
608 default:
609 if (!fEvent) return NULL;
610 return fEvent->GetTrack(i);
611 }
612}
a1c43d26 613
614//-----------------------------------------------------------------------
615void AliFlowTrackCuts::Clear(Option_t*)
616{
617 //clean up
618 fTrack=NULL;
619 fMCevent=NULL;
620 fMCparticle=NULL;
621 fTrackLabel=0;
622 fTrackWeight=0.0;
623 fTrackEta=0.0;
624 fTrackPhi=0.0;
625}