]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnCutPIDITS.cxx
Coverity fix
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPIDITS.cxx
CommitLineData
659ef4f0 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
223b8750 19#include "AliAnalysisManager.h"
20#include "AliESDInputHandler.h"
659ef4f0 21
659ef4f0 22#include "AliRsnCutPIDITS.h"
23
24ClassImp(AliRsnCutPIDITS)
25
26//_________________________________________________________________________________________________
27AliRsnCutPIDITS::AliRsnCutPIDITS
80e49c8b 28(const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectOutside) :
2a1c7696 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()
659ef4f0 37{
38//
39// Main constructor.
40//
659ef4f0 41}
42
43//_________________________________________________________________________________________________
44AliRsnCutPIDITS::AliRsnCutPIDITS
45(const AliRsnCutPIDITS& copy) :
2a1c7696 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)
659ef4f0 54{
55//
56// Copy constructor.
57//
659ef4f0 58}
59
60//_________________________________________________________________________________________________
61AliRsnCutPIDITS& AliRsnCutPIDITS::operator=(const AliRsnCutPIDITS& copy)
62{
63//
64// Assignment operator
65//
66
2a1c7696 67 AliRsnCut::operator=(copy);
659ef4f0 68
2a1c7696 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);
659ef4f0 78}
79
80//_________________________________________________________________________________________________
81void AliRsnCutPIDITS::SetMC(Bool_t yn)
82{
83//
84// Properly set the PID response
85//
86
2a1c7696 87 AliITSPIDResponse itsresponse(yn);
88
89 fESDpid.GetITSResponse() = itsresponse;
90 fAODpid.GetITSResponse() = itsresponse;
659ef4f0 91}
92
93//_________________________________________________________________________________________________
94Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
95{
96//
97// Cut checker.
98//
99
2a1c7696 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 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
111 return kFALSE;
112 }
113
114 // check status, to know it track is an ITS+TPC or ITS standalone
115 // and reject it if it is of none of them
116 Bool_t isSA = kFALSE;
117 if (IsTPC(vtrack)) isSA = kFALSE;
118 else if (IsSA(vtrack)) isSA = kTRUE;
119 else {
120 AliDebug(AliLog::kDebug + 2, "Status flags unmatched");
121 return kFALSE;
122 }
123
124 // common evaluation variables
125 Int_t k, nITSpidLayers = 0;
126 Double_t mom = vtrack->P();
127 AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
128 AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
129
130 // check momentum
131 if (mom < fMomMin || mom > fMomMax) {
132 AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
133 return (!fRejectOutside);
134 }
135
136 // count number of PID layers...
137 if (esdTrack) {
138 UChar_t itsCluMap = esdTrack->GetITSClusterMap();
139 for (k = 2; k < 6; k++) if (itsCluMap & (1 << k)) ++nITSpidLayers;
140 } else if (aodTrack) {
141 for (k = 2; k < 6; k++) if (TESTBIT(aodTrack->GetITSClusterMap(), k)) ++nITSpidLayers;
142 } else {
143 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
144 return kFALSE;
145 }
146 // ...and reject tracks where it is smaller than 3
147 if (nITSpidLayers < 3) {
148 AliDebug(AliLog::kDebug + 2, "Rejecting track with too few ITS pid layers");
149 return kFALSE;
150 }
151
152 // assign PID nsigmas to default cut check value
153 // since bad object types are rejected before, here we have an ESD track or AOD track
154 if (esdTrack)
155 fCutValueD = fESDpid.GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA);
156 else
157 fCutValueD = fAODpid.NumberOfSigmasITS(aodTrack, fRefType);
158
159 // use default cut checking method
160 return OkRangeD();
659ef4f0 161}
162
163//_________________________________________________________________________________________________
164void AliRsnCutPIDITS::Print(const Option_t *) const
165{
166//
167// Print information on this cut
168//
169
2a1c7696 170 AliInfo(Form("Cut name : %s", GetName()));
171 AliInfo(Form("--> cut range (nsigma) : %.3f %.3f", fMinD, fMaxD));
172 AliInfo(Form("--> momentum range : %.3f %.3f", fMomMin, fMomMax));
173 AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted")));
659ef4f0 174}
223b8750 175
176//_________________________________________________________________________________________________
177void AliRsnCutPIDITS::Initialize()
178{
179//
180// Initialize ESD pid object from global one
181//
182
2a1c7696 183 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
184 AliESDInputHandler *handler = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
185 if (handler) {
186 AliESDpid *pid = handler->GetESDpid();
187 fESDpid = (*pid);
188 }
189
190 fInitialized = kTRUE;
223b8750 191}