Changes for #82873: Module debugging broken (Christian)
[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
b63357a0 19#include "AliESDtrackCuts.h"
20#include "AliAODpidUtil.h"
223b8750 21#include "AliAnalysisManager.h"
22#include "AliESDInputHandler.h"
659ef4f0 23
b63357a0 24#include "AliRsnDaughter.h"
25
659ef4f0 26#include "AliRsnCutPIDITS.h"
27
28ClassImp(AliRsnCutPIDITS)
29
30//_________________________________________________________________________________________________
31AliRsnCutPIDITS::AliRsnCutPIDITS
80e49c8b 32(const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectOutside) :
2a1c7696 33 AliRsnCut(name, AliRsnCut::kDaughter, min, max),
c865cb1d 34 fIsMC(kFALSE),
2a1c7696 35 fRejectOutside(rejectOutside),
36 fMomMin(0.0),
37 fMomMax(1E+20),
38 fRefType(ref),
39 fESDpid(),
40 fAODpid()
659ef4f0 41{
42//
43// Main constructor.
44//
659ef4f0 45}
46
47//_________________________________________________________________________________________________
48AliRsnCutPIDITS::AliRsnCutPIDITS
49(const AliRsnCutPIDITS& copy) :
2a1c7696 50 AliRsnCut(copy),
c865cb1d 51 fIsMC(copy.fIsMC),
2a1c7696 52 fRejectOutside(copy.fRejectOutside),
53 fMomMin(copy.fMomMin),
54 fMomMax(copy.fMomMax),
55 fRefType(copy.fRefType),
56 fESDpid(copy.fESDpid),
57 fAODpid(copy.fAODpid)
659ef4f0 58{
59//
60// Copy constructor.
61//
659ef4f0 62}
63
64//_________________________________________________________________________________________________
65AliRsnCutPIDITS& AliRsnCutPIDITS::operator=(const AliRsnCutPIDITS& copy)
66{
67//
68// Assignment operator
69//
70
2a1c7696 71 AliRsnCut::operator=(copy);
659ef4f0 72
c865cb1d 73 fIsMC = copy.fIsMC;
2a1c7696 74 fRejectOutside = copy.fRejectOutside;
75 fMomMin = copy.fMomMin;
76 fMomMax = copy.fMomMax;
77 fRefType = copy.fRefType;
78 fESDpid = copy.fESDpid;
79 fAODpid = copy.fAODpid;
80
81 return (*this);
659ef4f0 82}
83
84//_________________________________________________________________________________________________
659ef4f0 85Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
86{
87//
88// Cut checker.
89//
90
2a1c7696 91 // coherence check
92 if (!TargetOK(object)) return kFALSE;
93
94 // reject not ITS tracks
95 // status is checked in the same way for all tracks
f34f960b 96 AliVTrack *vtrack = fDaughter->Ref2Vtrack();
2a1c7696 97 if (!vtrack) {
98 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
99 return kFALSE;
100 }
101
102 // check status, to know it track is an ITS+TPC or ITS standalone
103 // and reject it if it is of none of them
104 Bool_t isSA = kFALSE;
105 if (IsTPC(vtrack)) isSA = kFALSE;
106 else if (IsSA(vtrack)) isSA = kTRUE;
107 else {
108 AliDebug(AliLog::kDebug + 2, "Status flags unmatched");
109 return kFALSE;
110 }
111
112 // common evaluation variables
113 Int_t k, nITSpidLayers = 0;
114 Double_t mom = vtrack->P();
f34f960b 115 AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
116 AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
2a1c7696 117
2a1c7696 118 // count number of PID layers...
119 if (esdTrack) {
120 UChar_t itsCluMap = esdTrack->GetITSClusterMap();
121 for (k = 2; k < 6; k++) if (itsCluMap & (1 << k)) ++nITSpidLayers;
122 } else if (aodTrack) {
123 for (k = 2; k < 6; k++) if (TESTBIT(aodTrack->GetITSClusterMap(), k)) ++nITSpidLayers;
124 } else {
125 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
126 return kFALSE;
127 }
128 // ...and reject tracks where it is smaller than 3
129 if (nITSpidLayers < 3) {
130 AliDebug(AliLog::kDebug + 2, "Rejecting track with too few ITS pid layers");
131 return kFALSE;
132 }
133
134 // assign PID nsigmas to default cut check value
135 // since bad object types are rejected before, here we have an ESD track or AOD track
c865cb1d 136 if (esdTrack) {
137 if (!fESDpid) fESDpid = new AliESDpid(fIsMC);
138 fCutValueD = fESDpid->GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA);
139 } else {
140 if (!fAODpid) fAODpid = new AliAODpidUtil(fIsMC);
141 fCutValueD = fAODpid->NumberOfSigmasITS(aodTrack, fRefType);
142 }
2a1c7696 143
2654b757 144 // use AliRsnCut default method to check cut
145 Bool_t cutCheck = OkRangeD();
146
147 // now check the momentum:
148 // -- if it stays inside the accepted range, track just checked
149 // with respect to the nsigma band
150 // -- if it stays outside the accepted range and 'fRejectOutside' is kTRUE,
151 // track is always rejected, while if 'fRejectOutside' is kFALSE,
152 // track is accepted if it stays inside the nsigma band
153 if ((mom >= fMomMin && mom <= fMomMax))
154 return cutCheck;
155 else {
156 AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
157 return ((!fRejectOutside) && cutCheck);
158 }
659ef4f0 159}
160
161//_________________________________________________________________________________________________
162void AliRsnCutPIDITS::Print(const Option_t *) const
163{
164//
165// Print information on this cut
166//
167
2a1c7696 168 AliInfo(Form("Cut name : %s", GetName()));
169 AliInfo(Form("--> cut range (nsigma) : %.3f %.3f", fMinD, fMaxD));
170 AliInfo(Form("--> momentum range : %.3f %.3f", fMomMin, fMomMax));
171 AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted")));
659ef4f0 172}