]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutPIDITS.cxx
introduce the option to analyze with PROOF, plus cosmetics
[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 "AliESDtrackCuts.h"
20 #include "AliAODpidUtil.h"
21 #include "AliAnalysisManager.h"
22 #include "AliESDInputHandler.h"
23
24 #include "AliRsnDaughter.h"
25
26 #include "AliRsnCutPIDITS.h"
27
28 ClassImp(AliRsnCutPIDITS)
29
30 //_________________________________________________________________________________________________
31 AliRsnCutPIDITS::AliRsnCutPIDITS
32 (const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectOutside) :
33    AliRsnCut(name, AliRsnCut::kDaughter, min, max),
34    fIsMC(kFALSE),
35    fRejectOutside(rejectOutside),
36    fMomMin(0.0),
37    fMomMax(1E+20),
38    fRefType(ref),
39    fESDpid(),
40    fAODpid()
41 {
42 //
43 // Main constructor.
44 //
45 }
46
47 //_________________________________________________________________________________________________
48 AliRsnCutPIDITS::AliRsnCutPIDITS
49 (const AliRsnCutPIDITS& copy) :
50    AliRsnCut(copy),
51    fIsMC(copy.fIsMC),
52    fRejectOutside(copy.fRejectOutside),
53    fMomMin(copy.fMomMin),
54    fMomMax(copy.fMomMax),
55    fRefType(copy.fRefType),
56    fESDpid(copy.fESDpid),
57    fAODpid(copy.fAODpid)
58 {
59 //
60 // Copy constructor.
61 //
62 }
63
64 //_________________________________________________________________________________________________
65 AliRsnCutPIDITS& AliRsnCutPIDITS::operator=(const AliRsnCutPIDITS& copy)
66 {
67 //
68 // Assignment operator
69 //
70
71    AliRsnCut::operator=(copy);
72
73    fIsMC          = copy.fIsMC;
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);
82 }
83
84 //_________________________________________________________________________________________________
85 Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
86 {
87 //
88 // Cut checker.
89 //
90
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
96    AliVTrack *vtrack = fDaughter->Ref2Vtrack();
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();
115    AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
116    AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
117
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
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    }
143
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    }
159 }
160
161 //_________________________________________________________________________________________________
162 void AliRsnCutPIDITS::Print(const Option_t *) const
163 {
164 //
165 // Print information on this cut
166 //
167
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")));
172 }