]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutPIDITS.cxx
Recovery ESDpid from InputHandler
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPIDITS.cxx
1 //
2 // Class AliRsnCutPIDITS
3 //
4 // General implementation of a single cut strategy, which can be:
5 // - a value contained in a given interval  [--> IsBetween()   ]
6 // - a value equal to a given reference     [--> MatchesValue()]
7 //
8 // In all cases, the reference value(s) is (are) given as data members
9 // and each kind of cut requires a given value type (Int, UInt, Double),
10 // but the cut check procedure is then automatized and chosen thanks to
11 // an enumeration of the implemented cut types.
12 // At the end, the user (or any other point which uses this object) has
13 // to use the method IsSelected() to check if this cut has been passed.
14 //
15 // authors: Martin Vala (martin.vala@cern.ch)
16 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
17 //
18
19 #include "AliAnalysisManager.h"
20 #include "AliESDInputHandler.h"
21
22 #include "AliRsnCutPIDITS.h"
23
24 ClassImp(AliRsnCutPIDITS)
25
26 //_________________________________________________________________________________________________
27 AliRsnCutPIDITS::AliRsnCutPIDITS
28 (const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectOutside) :
29   AliRsnCut(name, AliRsnCut::kDaughter, min, max),
30   fInitialized(kFALSE),
31   fRejectOutside(rejectOutside),
32   fMomMin(0.0),
33   fMomMax(1E+20),
34   fRefType(ref),
35   fESDpid(),
36   fAODpid()
37 {
38 //
39 // Main constructor.
40 //
41 }
42
43 //_________________________________________________________________________________________________
44 AliRsnCutPIDITS::AliRsnCutPIDITS
45 (const AliRsnCutPIDITS& copy) :
46   AliRsnCut(copy),
47   fInitialized(kFALSE),
48   fRejectOutside(copy.fRejectOutside),
49   fMomMin(copy.fMomMin),
50   fMomMax(copy.fMomMax),
51   fRefType(copy.fRefType),
52   fESDpid(copy.fESDpid),
53   fAODpid(copy.fAODpid)
54 {
55 //
56 // Copy constructor.
57 //
58 }
59
60 //_________________________________________________________________________________________________
61 AliRsnCutPIDITS& AliRsnCutPIDITS::operator=(const AliRsnCutPIDITS& copy)
62 {
63 //
64 // Assignment operator
65 //
66
67   AliRsnCut::operator=(copy);
68
69   fInitialized   = kFALSE;
70   fRejectOutside = copy.fRejectOutside;
71   fMomMin        = copy.fMomMin;
72   fMomMax        = copy.fMomMax;
73   fRefType       = copy.fRefType;
74   fESDpid        = copy.fESDpid;
75   fAODpid        = copy.fAODpid;
76   
77   return (*this);
78 }
79
80 //_________________________________________________________________________________________________
81 void AliRsnCutPIDITS::SetMC(Bool_t yn)
82 {
83 //
84 // Properly set the PID response
85 //
86
87   AliITSPIDResponse itsresponse(yn);
88   
89   fESDpid.GetITSResponse() = itsresponse;
90   fAODpid.GetITSResponse() = itsresponse;
91 }
92
93 //_________________________________________________________________________________________________
94 Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
95 {
96 //
97 // Cut checker.
98 //
99
100   // initialize if needed
101   if (!fInitialized) Initialize();
102
103   // coherence check
104   if (!TargetOK(object)) return kFALSE;
105   
106   // reject not ITS tracks
107   // status is checked in the same way for all tracks
108   AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
109   if (!vtrack)
110   {
111     AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
112     return kFALSE;
113   }
114   
115   // check status, to know it track is an ITS+TPC or ITS standalone
116   // and reject it if it is of none of them
117   Bool_t isSA = kFALSE;
118   if (IsTPC(vtrack)) isSA = kFALSE;
119   else if (IsSA(vtrack)) isSA = kTRUE;
120   else
121   {
122     AliDebug(AliLog::kDebug + 2, "Status flags unmatched");
123     return kFALSE;
124   }
125
126   // common evaluation variables
127   Int_t        k, nITSpidLayers = 0;
128   Double_t     mom      = vtrack->P();
129   AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
130   AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
131
132   // check momentum
133   if (mom < fMomMin || mom > fMomMax)
134   {
135     AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
136     return (!fRejectOutside);
137   }
138
139   // count number of PID layers...
140   if (esdTrack) 
141   {
142     UChar_t itsCluMap = esdTrack->GetITSClusterMap();
143     for(k = 2; k < 6; k++) if(itsCluMap & (1 << k)) ++nITSpidLayers;
144   }
145   else if (aodTrack)
146   {
147     for(k = 2; k < 6; k++) if (TESTBIT(aodTrack->GetITSClusterMap(), k)) ++nITSpidLayers;
148   }
149   else
150   {
151     AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
152     return kFALSE;
153   }
154   // ...and reject tracks where it is smaller than 3
155   if (nITSpidLayers < 3)
156   {
157     AliDebug(AliLog::kDebug+2, "Rejecting track with too few ITS pid layers");
158     return kFALSE;
159   }
160     
161   // assign PID nsigmas to default cut check value
162   // since bad object types are rejected before, here we have an ESD track or AOD track
163   if (esdTrack) 
164     fCutValueD = fESDpid.GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA);
165   else
166     fCutValueD = fAODpid.NumberOfSigmasITS(aodTrack, fRefType);
167   
168   // use default cut checking method
169   return OkRangeD();
170 }
171
172 //_________________________________________________________________________________________________
173 void AliRsnCutPIDITS::Print(const Option_t *) const
174 {
175 //
176 // Print information on this cut
177 //
178
179   AliInfo(Form("Cut name                    : %s", GetName()));
180   AliInfo(Form("--> cut range (nsigma)      : %.3f %.3f", fMinD, fMaxD));
181   AliInfo(Form("--> momentum range          : %.3f %.3f", fMomMin, fMomMax));
182   AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted")));
183 }
184
185 //_________________________________________________________________________________________________
186 void AliRsnCutPIDITS::Initialize()
187 {
188 //
189 // Initialize ESD pid object from global one
190 //
191
192   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
193   AliESDInputHandler *handler = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
194   if (handler)
195   {
196     AliESDpid *pid = handler->GetESDpid();
197     fESDpid = (*pid);
198   }
199   
200   fInitialized = kTRUE;
201 }