]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnCutPIDITS.cxx
Implementation of all needed changes in the package in order to speed-up the executio...
[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),
c865cb1d 30 fIsMC(kFALSE),
2a1c7696 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),
c865cb1d 47 fIsMC(copy.fIsMC),
2a1c7696 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
c865cb1d 69 fIsMC = copy.fIsMC;
2a1c7696 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
659ef4f0 80//_________________________________________________________________________________________________
81Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
82{
83//
84// Cut checker.
85//
86
2a1c7696 87 // coherence check
88 if (!TargetOK(object)) return kFALSE;
89
90 // reject not ITS tracks
91 // status is checked in the same way for all tracks
99261e24 92 AliVTrack *vtrack = fDaughter->GetRefVtrack();
2a1c7696 93 if (!vtrack) {
94 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
95 return kFALSE;
96 }
97
98 // check status, to know it track is an ITS+TPC or ITS standalone
99 // and reject it if it is of none of them
100 Bool_t isSA = kFALSE;
101 if (IsTPC(vtrack)) isSA = kFALSE;
102 else if (IsSA(vtrack)) isSA = kTRUE;
103 else {
104 AliDebug(AliLog::kDebug + 2, "Status flags unmatched");
105 return kFALSE;
106 }
107
108 // common evaluation variables
109 Int_t k, nITSpidLayers = 0;
110 Double_t mom = vtrack->P();
111 AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
112 AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
113
2a1c7696 114 // count number of PID layers...
115 if (esdTrack) {
116 UChar_t itsCluMap = esdTrack->GetITSClusterMap();
117 for (k = 2; k < 6; k++) if (itsCluMap & (1 << k)) ++nITSpidLayers;
118 } else if (aodTrack) {
119 for (k = 2; k < 6; k++) if (TESTBIT(aodTrack->GetITSClusterMap(), k)) ++nITSpidLayers;
120 } else {
121 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
122 return kFALSE;
123 }
124 // ...and reject tracks where it is smaller than 3
125 if (nITSpidLayers < 3) {
126 AliDebug(AliLog::kDebug + 2, "Rejecting track with too few ITS pid layers");
127 return kFALSE;
128 }
129
130 // assign PID nsigmas to default cut check value
131 // since bad object types are rejected before, here we have an ESD track or AOD track
c865cb1d 132 if (esdTrack) {
133 if (!fESDpid) fESDpid = new AliESDpid(fIsMC);
134 fCutValueD = fESDpid->GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA);
135 } else {
136 if (!fAODpid) fAODpid = new AliAODpidUtil(fIsMC);
137 fCutValueD = fAODpid->NumberOfSigmasITS(aodTrack, fRefType);
138 }
2a1c7696 139
2654b757 140 // use AliRsnCut default method to check cut
141 Bool_t cutCheck = OkRangeD();
142
143 // now check the momentum:
144 // -- if it stays inside the accepted range, track just checked
145 // with respect to the nsigma band
146 // -- if it stays outside the accepted range and 'fRejectOutside' is kTRUE,
147 // track is always rejected, while if 'fRejectOutside' is kFALSE,
148 // track is accepted if it stays inside the nsigma band
149 if ((mom >= fMomMin && mom <= fMomMax))
150 return cutCheck;
151 else {
152 AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
153 return ((!fRejectOutside) && cutCheck);
154 }
659ef4f0 155}
156
157//_________________________________________________________________________________________________
158void AliRsnCutPIDITS::Print(const Option_t *) const
159{
160//
161// Print information on this cut
162//
163
2a1c7696 164 AliInfo(Form("Cut name : %s", GetName()));
165 AliInfo(Form("--> cut range (nsigma) : %.3f %.3f", fMinD, fMaxD));
166 AliInfo(Form("--> momentum range : %.3f %.3f", fMomMin, fMomMax));
167 AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted")));
659ef4f0 168}