]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowTasks/AliFlowEventCuts.cxx
vzero refmult + updates to QA
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliFlowEventCuts.cxx
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>
25 #include "TMath.h"
26 #include "TNamed.h"
27 #include "AliVVertex.h"
28 #include "AliVEvent.h"
29 #include "AliESDEvent.h"
30 #include "AliESDVZERO.h"
31 #include "AliMultiplicity.h"
32 #include "AliMCEvent.h"
33 #include "AliFlowEventCuts.h"
34 #include "AliFlowTrackCuts.h"
35
36 ClassImp(AliFlowEventCuts)
37
38 //-----------------------------------------------------------------------
39 AliFlowEventCuts::AliFlowEventCuts():
40   TNamed(),
41   fCutNumberOfTracks(kFALSE),
42   fNumberOfTracksMax(INT_MAX),
43   fNumberOfTracksMin(INT_MIN),
44   fCutRefMult(kFALSE),
45   fRefMultMethod(kTPConly),
46   fRefMultMax(INT_MAX),
47   fRefMultMin(INT_MIN),
48   fRefMultCuts(NULL),
49   fCutPrimaryVertexX(kFALSE),
50   fPrimaryVertexXmax(INT_MAX),
51   fPrimaryVertexXmin(INT_MIN),
52   fCutPrimaryVertexY(kFALSE),
53   fPrimaryVertexYmax(INT_MAX),
54   fPrimaryVertexYmin(INT_MIN),
55   fCutPrimaryVertexZ(kFALSE),
56   fPrimaryVertexZmax(INT_MAX),
57   fPrimaryVertexZmin(INT_MIN),
58   fCutNContributors(kFALSE),
59   fNContributorsMax(INT_MAX),
60   fNContributorsMin(INT_MIN)
61 {
62   //constructor 
63 }
64
65 //-----------------------------------------------------------------------
66 AliFlowEventCuts::AliFlowEventCuts(const char* name, const char* title):
67   TNamed(name, title),
68   fCutNumberOfTracks(kFALSE),
69   fNumberOfTracksMax(INT_MAX),
70   fNumberOfTracksMin(INT_MIN),
71   fCutRefMult(kFALSE),
72   fRefMultMethod(kTPConly),
73   fRefMultMax(INT_MAX),
74   fRefMultMin(INT_MIN),
75   fRefMultCuts(NULL),
76   fCutPrimaryVertexX(kFALSE),
77   fPrimaryVertexXmax(INT_MAX),
78   fPrimaryVertexXmin(INT_MIN),
79   fCutPrimaryVertexY(kFALSE),
80   fPrimaryVertexYmax(INT_MAX),
81   fPrimaryVertexYmin(INT_MIN),
82   fCutPrimaryVertexZ(kFALSE),
83   fPrimaryVertexZmax(INT_MAX),
84   fPrimaryVertexZmin(INT_MIN),
85   fCutNContributors(kFALSE),
86   fNContributorsMax(INT_MAX),
87   fNContributorsMin(INT_MIN)
88 {
89   //constructor 
90 }
91
92 ////-----------------------------------------------------------------------
93 AliFlowEventCuts::AliFlowEventCuts(const AliFlowEventCuts& that):
94   TNamed(that),
95   fCutNumberOfTracks(that.fCutNumberOfTracks),
96   fNumberOfTracksMax(that.fNumberOfTracksMax),
97   fNumberOfTracksMin(that.fNumberOfTracksMin),
98   fCutRefMult(that.fCutRefMult),
99   fRefMultMethod(that.fRefMultMethod),
100   fRefMultMax(that.fRefMultMax),
101   fRefMultMin(that.fRefMultMin),
102   fRefMultCuts(NULL),
103   fCutPrimaryVertexX(that.fCutPrimaryVertexX),
104   fPrimaryVertexXmax(that.fPrimaryVertexXmax),
105   fPrimaryVertexXmin(that.fPrimaryVertexXmin),
106   fCutPrimaryVertexY(that.fCutPrimaryVertexX),
107   fPrimaryVertexYmax(that.fPrimaryVertexYmax),
108   fPrimaryVertexYmin(that.fPrimaryVertexYmin),
109   fCutPrimaryVertexZ(that.fCutPrimaryVertexX),
110   fPrimaryVertexZmax(that.fPrimaryVertexZmax),
111   fPrimaryVertexZmin(that.fPrimaryVertexZmin),
112   fCutNContributors(that.fCutNContributors),
113   fNContributorsMax(that.fNContributorsMax),
114   fNContributorsMin(that.fNContributorsMin)
115 {
116   //copy constructor 
117   if (that.fRefMultCuts)
118     fRefMultCuts = new AliFlowTrackCuts(*(that.fRefMultCuts));
119 }
120
121 ////-----------------------------------------------------------------------
122 AliFlowEventCuts& AliFlowEventCuts::operator=(const AliFlowEventCuts& that)
123 {
124   //assignment
125   fCutNumberOfTracks=that.fCutNumberOfTracks;
126   fNumberOfTracksMax=that.fNumberOfTracksMax;
127   fNumberOfTracksMin=that.fNumberOfTracksMin;
128   fCutRefMult=that.fCutRefMult;
129   fRefMultMethod=that.fRefMultMethod;
130   fRefMultMax=that.fRefMultMax;
131   fRefMultMin=that.fRefMultMin;
132   if (that.fRefMultCuts) *fRefMultCuts=*(that.fRefMultCuts);
133   fCutPrimaryVertexX=that.fCutPrimaryVertexX;
134   fPrimaryVertexXmin=that.fPrimaryVertexXmin;
135   fPrimaryVertexXmax=that.fPrimaryVertexXmax;
136   fPrimaryVertexYmin=that.fPrimaryVertexYmin;
137   fPrimaryVertexYmax=that.fPrimaryVertexYmax;
138   fPrimaryVertexZmin=that.fPrimaryVertexZmin;
139   fPrimaryVertexZmax=that.fPrimaryVertexZmax;
140   fCutNContributors=that.fCutNContributors;
141   fNContributorsMax=that.fNContributorsMax;
142   fNContributorsMin=that.fNContributorsMin;
143   return *this;
144 }
145
146 //----------------------------------------------------------------------- 
147 Bool_t AliFlowEventCuts::IsSelected(const TObject* obj)
148 {
149   //check cuts
150   const AliVEvent* vevent = dynamic_cast<const AliVEvent*>(obj);
151   if (vevent) return PassesCuts(vevent);
152   return kFALSE;  //when passed wrong type of object
153 }
154 //----------------------------------------------------------------------- 
155 Bool_t AliFlowEventCuts::PassesCuts(const AliVEvent *event)
156 {
157   ///check if event passes cuts
158   if(fCutNumberOfTracks) {if (event->GetNumberOfTracks() < fNumberOfTracksMin || event->GetNumberOfTracks() >= fNumberOfTracksMax ) return kFALSE;}
159   if(fCutRefMult)
160   {
161     //reference multiplicity still to be defined
162     Double_t refMult = RefMult(event);
163     if (refMult < fRefMultMin || refMult >= fRefMultMax )
164       return kFALSE;
165   }
166   const AliVVertex* pvtx=event->GetPrimaryVertex();
167   Double_t pvtxx = pvtx->GetX();
168   Double_t pvtxy = pvtx->GetY();
169   Double_t pvtxz = pvtx->GetZ();
170   Int_t ncontrib = pvtx->GetNContributors();
171   if (fCutNContributors)
172   {
173     if (ncontrib < fNContributorsMin || ncontrib >= fNContributorsMax)
174       return kFALSE;
175   }
176   if (fCutPrimaryVertexX)
177   {
178     if (pvtxx < fPrimaryVertexXmin || pvtxx >= fPrimaryVertexXmax)
179       return kFALSE;
180   }
181   if (fCutPrimaryVertexY)
182   {
183     if (pvtxy < fPrimaryVertexYmin || pvtxy >= fPrimaryVertexYmax)
184       return kFALSE;
185   }
186   if (fCutPrimaryVertexZ)
187   {
188     if (pvtxz < fPrimaryVertexZmin || pvtxz >= fPrimaryVertexZmax)
189       return kFALSE;
190   }
191   return kTRUE;
192 }
193
194 //----------------------------------------------------------------------- 
195 AliFlowEventCuts* AliFlowEventCuts::StandardCuts()
196 {
197   //make a set of standard event cuts, caller becomes owner
198   AliFlowEventCuts* cuts = new AliFlowEventCuts();
199   return cuts;
200 }
201
202 //----------------------------------------------------------------------- 
203 Int_t AliFlowEventCuts::RefMult(const AliVEvent* event)
204 {
205   //calculate the reference multiplicity, if all fails return 0
206   AliESDVZERO* vzero = NULL;
207   const AliESDEvent* esdevent = dynamic_cast<const AliESDEvent*>(event);
208   Int_t refmult=0;
209   if (!fRefMultCuts)
210   {
211     switch (fRefMultMethod)
212     {
213       case kTPConly:
214         fRefMultCuts = AliFlowTrackCuts::GetStandardTPCOnlyTrackCuts();
215         fRefMultCuts->SetEtaRange(-0.8,0.8);
216         fRefMultCuts->SetPtMin(0.15);
217         break;
218       case kSPDtracklets:
219         fRefMultCuts = new AliFlowTrackCuts();
220         fRefMultCuts->SetParamType(AliFlowTrackCuts::kESD_SPDtracklet);
221         fRefMultCuts->SetEtaRange(-0.8,0.8);
222         break;
223       case kV0:
224         if (!esdevent) return 0;
225         vzero=esdevent->GetVZEROData();
226         if (!vzero) return 0;
227         refmult+=TMath::Nint(vzero->GetMTotV0A());
228         refmult+=TMath::Nint(vzero->GetMTotV0C());
229         return refmult;
230       default:
231         return 0;
232     }
233   }
234
235   fRefMultCuts->SetEvent(const_cast<AliVEvent*>(event));
236   for (Int_t i=0; i<fRefMultCuts->GetNumberOfInputObjects(); i++)
237   {
238     if (fRefMultCuts->IsSelected(fRefMultCuts->GetInputObject(i),i))
239       refmult++;
240   }
241   return refmult;
242 }