New AliFlowTrackCuts and AliFlowEventCuts, allow running of centrality train
[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)
22
23#include <limits.h>
24#include <float.h>
25#include "AliMCEvent.h"
26#include "AliVParticle.h"
27#include "AliMCParticle.h"
28#include "AliESDtrack.h"
29#include "AliAODTrack.h"
30#include "AliFlowTrack.h"
31#include "AliFlowTrackCuts.h"
32#include "AliLog.h"
33
34ClassImp(AliFlowTrackCuts)
35
36//-----------------------------------------------------------------------
37AliFlowTrackCuts::AliFlowTrackCuts():
38 AliFlowTrackSimpleCuts(),
39 fAliESDtrackCuts(new AliESDtrackCuts()),
40 fCutMCprocessType(kFALSE),
41 fMCprocessType(kPNoProcess),
42 fCutMCPID(kFALSE),
43 fMCPID(0),
44 fCutMCisPrimary(kFALSE),
45 fMCisPrimary(kFALSE),
46 fParamType(kESD_Global),
47 fParamMix(kPure),
48 fMCevent(NULL),
49 fCleanupTrack(kFALSE),
50 fTrack(NULL),
51 fMCparticle(NULL)
52{
53 //constructor
54}
55
56//-----------------------------------------------------------------------
57AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& someCuts):
58 AliFlowTrackSimpleCuts(someCuts),
59 fAliESDtrackCuts(new AliESDtrackCuts(*(someCuts.fAliESDtrackCuts))),
60 fCutMCprocessType(someCuts.fCutMCprocessType),
61 fMCprocessType(someCuts.fMCprocessType),
62 fCutMCPID(someCuts.fCutMCPID),
63 fMCPID(someCuts.fMCPID),
64 fCutMCisPrimary(someCuts.fCutMCisPrimary),
65 fMCisPrimary(someCuts.fMCisPrimary),
66 fParamType(someCuts.fParamType),
67 fParamMix(someCuts.fParamMix),
68 fMCevent(NULL),
69 fCleanupTrack(kFALSE),
70 fTrack(NULL),
71 fMCparticle(NULL)
72{
73 //copy constructor
74}
75
76//-----------------------------------------------------------------------
77AliFlowTrackCuts& AliFlowTrackCuts::operator=(const AliFlowTrackCuts& someCuts)
78{
79 //assignment
80 AliFlowTrackSimpleCuts::operator=(someCuts);
81 *fAliESDtrackCuts=*(someCuts.fAliESDtrackCuts);
82 fCutMCprocessType=someCuts.fCutMCprocessType;
83 fMCprocessType=someCuts.fMCprocessType;
84 fCutMCPID=someCuts.fCutMCPID;
85 fMCPID=someCuts.fMCPID;
86 fCutMCisPrimary=someCuts.fCutMCisPrimary;
87 fMCisPrimary=someCuts.fMCisPrimary;
88 fParamType=someCuts.fParamType;
89 fParamMix=someCuts.fParamMix;
90
91 fMCevent=NULL;
92 fCleanupTrack=kFALSE;
93 fTrack=NULL;
94 fMCparticle=NULL;
95
96 return *this;
97}
98
99//-----------------------------------------------------------------------
100AliFlowTrackCuts::~AliFlowTrackCuts()
101{
102 //dtor
103 if (fCleanupTrack) delete fTrack;
104 delete fAliESDtrackCuts;
105}
106
107//-----------------------------------------------------------------------
108Bool_t AliFlowTrackCuts::IsSelected(TObject* obj)
109{
110 //check cuts
111 AliVParticle* vparticle = dynamic_cast<AliVParticle*>(obj);
112 if (vparticle) return PassesCuts(vparticle);
113 AliFlowTrackSimple* flowtrack = dynamic_cast<AliFlowTrackSimple*>(obj);
114 if (flowtrack) return PassesCuts(flowtrack);
115 return kFALSE; //default when passed wrong type of object
116}
117
118//-----------------------------------------------------------------------
119Bool_t AliFlowTrackCuts::PassesCuts(AliFlowTrackSimple* track)
120{
121 //check cuts on a flowtracksimple
122 if (fCleanupTrack) delete fTrack;
123 fTrack = NULL;
124 return AliFlowTrackSimpleCuts::PassesCuts(track);
125}
126
127//-----------------------------------------------------------------------
128Bool_t AliFlowTrackCuts::PassesCuts(AliVParticle* vparticle)
129{
130 //check cuts for an ESD vparticle
131
132 Int_t mcLabel = vparticle->GetLabel();
133 if (fMCevent) fMCparticle = static_cast<AliMCParticle*>(fMCevent->GetTrack(mcLabel));
134 else fMCparticle=NULL;
135
136 AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*>(vparticle);
137 if (esdTrack)
138 HandleESDtrack(esdTrack);
139 else
140 HandleVParticle(vparticle);
141
142 //check the common cuts for the current particle (MC,AOD,ESD)
143 if (fCutPt) {if (fTrack->Pt() < fPtMin || fTrack->Pt() >= fPtMax ) return kFALSE;}
144 if (fCutEta) {if (fTrack->Eta() < fEtaMin || fTrack->Eta() >= fEtaMax ) return kFALSE;}
145 if (fCutPhi) {if (fTrack->Phi() < fPhiMin || fTrack->Phi() >= fPhiMax ) return kFALSE;}
146 if (fCutCharge) {if (fTrack->Charge() != fCharge) return kFALSE;}
147 //if(fCutPID) {if (fTrack->PID() != fPID) return kFALSE;}
148
149 //when MC info is required
150 if (fCutMCisPrimary)
151 {
152 if (!fMCevent) {AliError("no MC info"); return kFALSE;}
153 if (fMCevent->IsPhysicalPrimary(mcLabel) != fMCisPrimary) return kFALSE;
154 }
155 if (fCutMCPID)
156 {
157 if (!fMCparticle) {AliError("no MC info"); return kFALSE;}
158 Int_t pdgCode = fMCparticle->PdgCode();
159 if (fMCPID != pdgCode) return kFALSE;
160 }
161 if ( fCutMCprocessType )
162 {
163 if (!fMCparticle) {AliError("no MC info"); return kFALSE;}
164 TParticle* particle = fMCparticle->Particle();
165 Int_t processID = particle->GetUniqueID();
166 if (processID != fMCprocessType ) return kFALSE;
167 }
168
169 //check all else for ESDs using aliesdtrackcuts
170 if (esdTrack && (fParamType!=kMC) ) return fAliESDtrackCuts->IsSelected(static_cast<AliESDtrack*>(fTrack));
171
172 return kTRUE; //true by default, if we didn't set any cuts
173}
174
175//-----------------------------------------------------------------------
176void AliFlowTrackCuts::HandleVParticle(AliVParticle* track)
177{
178 //handle the general case
179 if (fCleanupTrack) delete fTrack;
180 switch (fParamType)
181 {
182 case kMC:
183 fCleanupTrack = kFALSE;
184 fTrack = fMCparticle;
185 break;
186 default:
187 fCleanupTrack = kFALSE;
188 fTrack = track;
189 }
190}
191
192//-----------------------------------------------------------------------
193void AliFlowTrackCuts::HandleESDtrack(AliESDtrack* track)
194{
195 //handle esd track
196 if (fCleanupTrack) delete fTrack;
197 switch (fParamType)
198 {
199 case kESD_Global:
200 fTrack = track;
201 fCleanupTrack = kFALSE;
202 break;
203 case kESD_TPConly:
204 fTrack = new AliESDtrack();
205 track->FillTPCOnlyTrack(*(static_cast<AliESDtrack*>(fTrack)));
206 fCleanupTrack = kTRUE;
207 break;
208 case kMC:
209 fCleanupTrack = kFALSE;
210 fTrack = fMCparticle;
211 break;
212 default:
213 fTrack = track;
214 fCleanupTrack = kFALSE;
215 }
216}
217
218//-----------------------------------------------------------------------
219AliFlowTrackCuts* AliFlowTrackCuts::GetStandardTPCOnlyTrackCuts()
220{
221 //get standard cuts
222 AliFlowTrackCuts* cuts = new AliFlowTrackCuts();
223 cuts->SetName("standard global track cuts 2009");
224 delete cuts->fAliESDtrackCuts;
225 cuts->fAliESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
226 return cuts;
227}
228
229//-----------------------------------------------------------------------
230AliFlowTrackCuts* AliFlowTrackCuts::GetStandardITSTPCTrackCuts2009(Bool_t selPrimaries)
231{
232 //get standard cuts
233 AliFlowTrackCuts* cuts = new AliFlowTrackCuts();
234 cuts->SetName("standard global track cuts 2009");
235 delete cuts->fAliESDtrackCuts;
236 cuts->fAliESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(selPrimaries);
237 return cuts;
238}
239
240//-----------------------------------------------------------------------
241AliFlowTrack* AliFlowTrackCuts::MakeFlowTrack() const
242{
243 //get a flow track constructed from whatever we applied cuts on
244 //caller is resposible for deletion
245 AliFlowTrack* flowtrack=NULL;
246 switch(fParamMix)
247 {
248 case kPure:
249 flowtrack = new AliFlowTrack(fTrack);
250 break;
251 case kTrackWithMCkine:
252 flowtrack = new AliFlowTrack(fMCparticle);
253 break;
254 case kTrackWithMCPID:
255 flowtrack = new AliFlowTrack(fTrack);
256 break;
257 default:
258 flowtrack = new AliFlowTrack(fTrack);
259 }
260 if (fParamType==kMC) flowtrack->SetSource(AliFlowTrack::kFromMC);
261 else if (dynamic_cast<AliMCParticle*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromMC);
262 else if (dynamic_cast<AliESDtrack*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromESD);
263 else if (dynamic_cast<AliAODTrack*>(fTrack)) flowtrack->SetSource(AliFlowTrack::kFromAOD);
264 return flowtrack;
265}