]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutPIDITS.cxx
Added a new cut on comparison of daughters' momenta (needed for Deltas)
[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       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    // count number of PID layers...
131    if (esdTrack) {
132       UChar_t itsCluMap = esdTrack->GetITSClusterMap();
133       for (k = 2; k < 6; k++) if (itsCluMap & (1 << k)) ++nITSpidLayers;
134    } else if (aodTrack) {
135       for (k = 2; k < 6; k++) if (TESTBIT(aodTrack->GetITSClusterMap(), k)) ++nITSpidLayers;
136    } else {
137       AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
138       return kFALSE;
139    }
140    // ...and reject tracks where it is smaller than 3
141    if (nITSpidLayers < 3) {
142       AliDebug(AliLog::kDebug + 2, "Rejecting track with too few ITS pid layers");
143       return kFALSE;
144    }
145
146    // assign PID nsigmas to default cut check value
147    // since bad object types are rejected before, here we have an ESD track or AOD track
148    if (esdTrack)
149       fCutValueD = fESDpid.GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA);
150    else
151       fCutValueD = fAODpid.NumberOfSigmasITS(aodTrack, fRefType);
152
153    // use AliRsnCut default method to check cut
154    Bool_t cutCheck = OkRangeD();
155
156    // now check the momentum:
157    // -- if it stays inside the accepted range, track just checked
158    //    with respect to the nsigma band
159    // -- if it stays outside the accepted range and 'fRejectOutside' is kTRUE,
160    //    track is always rejected, while if 'fRejectOutside' is kFALSE,
161    //    track is accepted if it stays inside the nsigma band
162    if ((mom >= fMomMin && mom <= fMomMax))
163       return cutCheck;
164    else {
165       AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
166       return ((!fRejectOutside) && cutCheck);
167    }
168 }
169
170 //_________________________________________________________________________________________________
171 void AliRsnCutPIDITS::Print(const Option_t *) const
172 {
173 //
174 // Print information on this cut
175 //
176
177    AliInfo(Form("Cut name                    : %s", GetName()));
178    AliInfo(Form("--> cut range (nsigma)      : %.3f %.3f", fMinD, fMaxD));
179    AliInfo(Form("--> momentum range          : %.3f %.3f", fMomMin, fMomMax));
180    AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted")));
181 }
182
183 //_________________________________________________________________________________________________
184 void AliRsnCutPIDITS::Initialize()
185 {
186 //
187 // Initialize ESD pid object from global one
188 //
189
190    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
191    AliESDInputHandler *handler = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
192    if (handler) {
193       AliESDpid *pid = handler->GetESDpid();
194       fESDpid = (*pid);
195    }
196
197    fInitialized = kTRUE;
198 }