]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowTasks/AliFlowEventCuts.cxx
changes from Per Thomas:
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliFlowEventCuts.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// AliFlowEventCuts:
19// An event cut class for the flow framework
20//
21// origin: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch)
22
23#include <limits.h>
24#include <float.h>
1c4a5bf7 25#include "TMath.h"
daf66719 26#include "TNamed.h"
ee242db3 27#include "AliVVertex.h"
daf66719 28#include "AliVEvent.h"
333ce021 29#include "AliESDEvent.h"
1c4a5bf7 30#include "AliESDVZERO.h"
9a0783cc 31#include "AliMultiplicity.h"
333ce021 32#include "AliMCEvent.h"
daf66719 33#include "AliFlowEventCuts.h"
9a0783cc 34#include "AliFlowTrackCuts.h"
daf66719 35
36ClassImp(AliFlowEventCuts)
37
38//-----------------------------------------------------------------------
39AliFlowEventCuts::AliFlowEventCuts():
40 TNamed(),
41 fCutNumberOfTracks(kFALSE),
42 fNumberOfTracksMax(INT_MAX),
5559ce24 43 fNumberOfTracksMin(INT_MIN),
44 fCutRefMult(kFALSE),
9a0783cc 45 fRefMultMethod(kTPConly),
5559ce24 46 fRefMultMax(INT_MAX),
333ce021 47 fRefMultMin(INT_MIN),
ee242db3 48 fRefMultCuts(NULL),
2279052e 49 fMeanPtCuts(NULL),
ee242db3 50 fCutPrimaryVertexX(kFALSE),
51 fPrimaryVertexXmax(INT_MAX),
52 fPrimaryVertexXmin(INT_MIN),
53 fCutPrimaryVertexY(kFALSE),
54 fPrimaryVertexYmax(INT_MAX),
55 fPrimaryVertexYmin(INT_MIN),
56 fCutPrimaryVertexZ(kFALSE),
57 fPrimaryVertexZmax(INT_MAX),
58 fPrimaryVertexZmin(INT_MIN),
59 fCutNContributors(kFALSE),
60 fNContributorsMax(INT_MAX),
d32716f4 61 fNContributorsMin(INT_MIN),
62 fCutMeanPt(kFALSE),
e90a4b03 63 fMeanPtMax(-DBL_MAX),
d7e66a39 64 fMeanPtMin(DBL_MAX),
65 fCutSPDvertexerAnomaly(kTRUE)
daf66719 66{
67 //constructor
68}
69
957517fa 70//-----------------------------------------------------------------------
71AliFlowEventCuts::AliFlowEventCuts(const char* name, const char* title):
72 TNamed(name, title),
73 fCutNumberOfTracks(kFALSE),
74 fNumberOfTracksMax(INT_MAX),
75 fNumberOfTracksMin(INT_MIN),
76 fCutRefMult(kFALSE),
9a0783cc 77 fRefMultMethod(kTPConly),
957517fa 78 fRefMultMax(INT_MAX),
333ce021 79 fRefMultMin(INT_MIN),
ee242db3 80 fRefMultCuts(NULL),
2279052e 81 fMeanPtCuts(NULL),
ee242db3 82 fCutPrimaryVertexX(kFALSE),
83 fPrimaryVertexXmax(INT_MAX),
84 fPrimaryVertexXmin(INT_MIN),
85 fCutPrimaryVertexY(kFALSE),
86 fPrimaryVertexYmax(INT_MAX),
87 fPrimaryVertexYmin(INT_MIN),
88 fCutPrimaryVertexZ(kFALSE),
89 fPrimaryVertexZmax(INT_MAX),
90 fPrimaryVertexZmin(INT_MIN),
91 fCutNContributors(kFALSE),
92 fNContributorsMax(INT_MAX),
d32716f4 93 fNContributorsMin(INT_MIN),
94 fCutMeanPt(kFALSE),
e90a4b03 95 fMeanPtMax(-DBL_MAX),
d7e66a39 96 fMeanPtMin(DBL_MAX),
97 fCutSPDvertexerAnomaly(kTRUE)
957517fa 98{
99 //constructor
100}
101
daf66719 102////-----------------------------------------------------------------------
03d364db 103AliFlowEventCuts::AliFlowEventCuts(const AliFlowEventCuts& that):
104 TNamed(that),
105 fCutNumberOfTracks(that.fCutNumberOfTracks),
106 fNumberOfTracksMax(that.fNumberOfTracksMax),
107 fNumberOfTracksMin(that.fNumberOfTracksMin),
108 fCutRefMult(that.fCutRefMult),
109 fRefMultMethod(that.fRefMultMethod),
110 fRefMultMax(that.fRefMultMax),
111 fRefMultMin(that.fRefMultMin),
ee242db3 112 fRefMultCuts(NULL),
2279052e 113 fMeanPtCuts(NULL),
ee242db3 114 fCutPrimaryVertexX(that.fCutPrimaryVertexX),
115 fPrimaryVertexXmax(that.fPrimaryVertexXmax),
116 fPrimaryVertexXmin(that.fPrimaryVertexXmin),
117 fCutPrimaryVertexY(that.fCutPrimaryVertexX),
118 fPrimaryVertexYmax(that.fPrimaryVertexYmax),
119 fPrimaryVertexYmin(that.fPrimaryVertexYmin),
120 fCutPrimaryVertexZ(that.fCutPrimaryVertexX),
121 fPrimaryVertexZmax(that.fPrimaryVertexZmax),
122 fPrimaryVertexZmin(that.fPrimaryVertexZmin),
123 fCutNContributors(that.fCutNContributors),
124 fNContributorsMax(that.fNContributorsMax),
d32716f4 125 fNContributorsMin(that.fNContributorsMin),
126 fCutMeanPt(that.fCutMeanPt),
127 fMeanPtMax(that.fMeanPtMax),
d7e66a39 128 fMeanPtMin(that.fMeanPtMin),
129 fCutSPDvertexerAnomaly(that.fCutSPDvertexerAnomaly)
03d364db 130{
131 //copy constructor
ee242db3 132 if (that.fRefMultCuts)
133 fRefMultCuts = new AliFlowTrackCuts(*(that.fRefMultCuts));
2279052e 134 if (that.fMeanPtCuts)
135 fMeanPtCuts = new AliFlowTrackCuts(*(that.fMeanPtCuts));
136}
137
138////-----------------------------------------------------------------------
139AliFlowEventCuts::~AliFlowEventCuts()
140{
141 //dtor
142 delete fMeanPtCuts;
143 delete fRefMultCuts;
03d364db 144}
145
daf66719 146////-----------------------------------------------------------------------
03d364db 147AliFlowEventCuts& AliFlowEventCuts::operator=(const AliFlowEventCuts& that)
148{
149 //assignment
150 fCutNumberOfTracks=that.fCutNumberOfTracks;
151 fNumberOfTracksMax=that.fNumberOfTracksMax;
152 fNumberOfTracksMin=that.fNumberOfTracksMin;
153 fCutRefMult=that.fCutRefMult;
154 fRefMultMethod=that.fRefMultMethod;
155 fRefMultMax=that.fRefMultMax;
156 fRefMultMin=that.fRefMultMin;
ee242db3 157 if (that.fRefMultCuts) *fRefMultCuts=*(that.fRefMultCuts);
2279052e 158 if (that.fMeanPtCuts) *fMeanPtCuts=*(that.fMeanPtCuts);
ee242db3 159 fCutPrimaryVertexX=that.fCutPrimaryVertexX;
160 fPrimaryVertexXmin=that.fPrimaryVertexXmin;
161 fPrimaryVertexXmax=that.fPrimaryVertexXmax;
162 fPrimaryVertexYmin=that.fPrimaryVertexYmin;
163 fPrimaryVertexYmax=that.fPrimaryVertexYmax;
164 fPrimaryVertexZmin=that.fPrimaryVertexZmin;
165 fPrimaryVertexZmax=that.fPrimaryVertexZmax;
166 fCutNContributors=that.fCutNContributors;
167 fNContributorsMax=that.fNContributorsMax;
168 fNContributorsMin=that.fNContributorsMin;
d32716f4 169 fCutMeanPt=that.fCutMeanPt;
170 fMeanPtMax=that.fMeanPtMax;
171 fMeanPtMin=that.fMeanPtMin;
d7e66a39 172 fCutSPDvertexerAnomaly=that.fCutSPDvertexerAnomaly;
03d364db 173 return *this;
174}
daf66719 175
176//-----------------------------------------------------------------------
177Bool_t AliFlowEventCuts::IsSelected(const TObject* obj)
178{
179 //check cuts
180 const AliVEvent* vevent = dynamic_cast<const AliVEvent*>(obj);
181 if (vevent) return PassesCuts(vevent);
182 return kFALSE; //when passed wrong type of object
183}
184//-----------------------------------------------------------------------
185Bool_t AliFlowEventCuts::PassesCuts(const AliVEvent *event)
186{
187 ///check if event passes cuts
5559ce24 188 if(fCutNumberOfTracks) {if (event->GetNumberOfTracks() < fNumberOfTracksMin || event->GetNumberOfTracks() >= fNumberOfTracksMax ) return kFALSE;}
189 if(fCutRefMult)
190 {
191 //reference multiplicity still to be defined
03d364db 192 Double_t refMult = RefMult(event);
193 if (refMult < fRefMultMin || refMult >= fRefMultMax )
5559ce24 194 return kFALSE;
195 }
ee242db3 196 const AliVVertex* pvtx=event->GetPrimaryVertex();
197 Double_t pvtxx = pvtx->GetX();
198 Double_t pvtxy = pvtx->GetY();
199 Double_t pvtxz = pvtx->GetZ();
200 Int_t ncontrib = pvtx->GetNContributors();
201 if (fCutNContributors)
202 {
203 if (ncontrib < fNContributorsMin || ncontrib >= fNContributorsMax)
204 return kFALSE;
205 }
206 if (fCutPrimaryVertexX)
207 {
208 if (pvtxx < fPrimaryVertexXmin || pvtxx >= fPrimaryVertexXmax)
209 return kFALSE;
210 }
211 if (fCutPrimaryVertexY)
212 {
213 if (pvtxy < fPrimaryVertexYmin || pvtxy >= fPrimaryVertexYmax)
214 return kFALSE;
215 }
216 if (fCutPrimaryVertexZ)
217 {
218 if (pvtxz < fPrimaryVertexZmin || pvtxz >= fPrimaryVertexZmax)
219 return kFALSE;
220 }
d32716f4 221 if (fCutMeanPt)
222 {
223 Float_t meanpt=0.0;
224 Int_t ntracks=event->GetNumberOfTracks();
f33c7420 225 Int_t nselected=0;
d32716f4 226 for (Int_t i=0; i<ntracks; i++)
227 {
228 AliVParticle* track = event->GetTrack(i);
229 if (!track) continue;
2279052e 230 Bool_t pass=kTRUE;
231 if (fMeanPtCuts) pass=fMeanPtCuts->IsSelected(track);
f33c7420 232 if (pass)
233 {
234 meanpt += track->Pt();
235 nselected++;
236 }
d32716f4 237 }
f33c7420 238 meanpt=meanpt/nselected;
d32716f4 239 if (meanpt<fMeanPtMin || meanpt >= fMeanPtMax) return kFALSE;
240 }
d7e66a39 241 const AliESDEvent* esdevent = dynamic_cast<const AliESDEvent*>(event);
242 if (fCutSPDvertexerAnomaly&&esdevent)
243 {
244 const AliESDVertex* sdpvertex = esdevent->GetPrimaryVertexSPD();
245 if (sdpvertex->GetNContributors()<1) return kFALSE;
246 if (sdpvertex->GetDispersion()>0.04) return kFALSE;
247 if (sdpvertex->GetZRes()>0.25) return kFALSE;
248 const AliESDVertex* tpcvertex = esdevent->GetPrimaryVertexTPC();
249 if (tpcvertex->GetNContributors()<1) return kFALSE;
250 const AliMultiplicity* tracklets = esdevent->GetMultiplicity();
251 if (tpcvertex->GetNContributors()<(-10.0+0.25*tracklets->GetNumberOfITSClusters(0)))
252 return kFALSE;
253 }
daf66719 254 return kTRUE;
255}
256
257//-----------------------------------------------------------------------
258AliFlowEventCuts* AliFlowEventCuts::StandardCuts()
259{
260 //make a set of standard event cuts, caller becomes owner
261 AliFlowEventCuts* cuts = new AliFlowEventCuts();
262 return cuts;
263}
333ce021 264
265//-----------------------------------------------------------------------
03d364db 266Int_t AliFlowEventCuts::RefMult(const AliVEvent* event)
333ce021 267{
9a0783cc 268 //calculate the reference multiplicity, if all fails return 0
1c4a5bf7 269 AliESDVZERO* vzero = NULL;
270 const AliESDEvent* esdevent = dynamic_cast<const AliESDEvent*>(event);
2cdf5762 271 const AliMultiplicity* mult = esdevent->GetMultiplicity();
1c4a5bf7 272 Int_t refmult=0;
2948ac5a 273 if (!fRefMultCuts)
9a0783cc 274 {
9a0783cc 275 switch (fRefMultMethod)
276 {
277 case kTPConly:
2948ac5a 278 fRefMultCuts = AliFlowTrackCuts::GetStandardTPCOnlyTrackCuts();
279 fRefMultCuts->SetEtaRange(-0.8,0.8);
280 fRefMultCuts->SetPtMin(0.15);
9a0783cc 281 break;
282 case kSPDtracklets:
2948ac5a 283 fRefMultCuts = new AliFlowTrackCuts();
284 fRefMultCuts->SetParamType(AliFlowTrackCuts::kESD_SPDtracklet);
285 fRefMultCuts->SetEtaRange(-0.8,0.8);
9a0783cc 286 break;
1c4a5bf7 287 case kV0:
288 if (!esdevent) return 0;
289 vzero=esdevent->GetVZEROData();
290 if (!vzero) return 0;
d7e66a39 291 refmult = TMath::Nint(vzero->GetMTotV0A()+vzero->GetMTotV0C());
1c4a5bf7 292 return refmult;
2cdf5762 293 case kSPD1clusters:
a1c43d26 294 if (!mult) return 0;
2cdf5762 295 refmult = mult->GetNumberOfITSClusters(1);
a1c43d26 296 return refmult;
9a0783cc 297 default:
298 return 0;
299 }
9a0783cc 300 }
301
2948ac5a 302 fRefMultCuts->SetEvent(const_cast<AliVEvent*>(event));
2948ac5a 303 for (Int_t i=0; i<fRefMultCuts->GetNumberOfInputObjects(); i++)
304 {
305 if (fRefMultCuts->IsSelected(fRefMultCuts->GetInputObject(i),i))
306 refmult++;
307 }
308 return refmult;
333ce021 309}