2 // Class AliRsnCutPIDITS
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()]
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.
15 // authors: Martin Vala (martin.vala@cern.ch)
16 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
19 #include "AliAnalysisManager.h"
20 #include "AliESDInputHandler.h"
22 #include "AliRsnCutPIDITS.h"
24 ClassImp(AliRsnCutPIDITS)
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),
31 fRejectOutside(rejectOutside),
43 //_________________________________________________________________________________________________
44 AliRsnCutPIDITS::AliRsnCutPIDITS
45 (const AliRsnCutPIDITS& copy) :
48 fRejectOutside(copy.fRejectOutside),
49 fMomMin(copy.fMomMin),
50 fMomMax(copy.fMomMax),
51 fRefType(copy.fRefType),
52 fESDpid(copy.fESDpid),
60 //_________________________________________________________________________________________________
61 AliRsnCutPIDITS& AliRsnCutPIDITS::operator=(const AliRsnCutPIDITS& copy)
64 // Assignment operator
67 AliRsnCut::operator=(copy);
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;
80 //_________________________________________________________________________________________________
81 void AliRsnCutPIDITS::SetMC(Bool_t yn)
84 // Properly set the PID response
87 AliITSPIDResponse itsresponse(yn);
89 fESDpid.GetITSResponse() = itsresponse;
90 fAODpid.GetITSResponse() = itsresponse;
93 //_________________________________________________________________________________________________
94 Bool_t AliRsnCutPIDITS::IsSelected(TObject *object)
100 // initialize if needed
101 if (!fInitialized) Initialize();
104 if (!TargetOK(object)) return kFALSE;
106 // reject not ITS tracks
107 // status is checked in the same way for all tracks
108 AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
110 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
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;
120 AliDebug(AliLog::kDebug + 2, "Status flags unmatched");
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();
130 // count number of PID layers...
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;
137 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
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");
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
149 fCutValueD = fESDpid.GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA);
151 fCutValueD = fAODpid.NumberOfSigmasITS(aodTrack, fRefType);
153 // use AliRsnCut default method to check cut
154 Bool_t cutCheck = OkRangeD();
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))
165 AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
166 return ((!fRejectOutside) && cutCheck);
170 //_________________________________________________________________________________________________
171 void AliRsnCutPIDITS::Print(const Option_t *) const
174 // Print information on this cut
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")));
183 //_________________________________________________________________________________________________
184 void AliRsnCutPIDITS::Initialize()
187 // Initialize ESD pid object from global one
190 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
191 AliESDInputHandler *handler = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
193 AliESDpid *pid = handler->GetESDpid();
197 fInitialized = kTRUE;