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());
111 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
115 // check status, to know it track is an ITS+TPC or ITS standalone
116 // and reject it if it is of none of them
117 Bool_t isSA = kFALSE;
118 if (IsTPC(vtrack)) isSA = kFALSE;
119 else if (IsSA(vtrack)) isSA = kTRUE;
122 AliDebug(AliLog::kDebug + 2, "Status flags unmatched");
126 // common evaluation variables
127 Int_t k, nITSpidLayers = 0;
128 Double_t mom = vtrack->P();
129 AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
130 AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
133 if (mom < fMomMin || mom > fMomMax)
135 AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
136 return (!fRejectOutside);
139 // count number of PID layers...
142 UChar_t itsCluMap = esdTrack->GetITSClusterMap();
143 for(k = 2; k < 6; k++) if(itsCluMap & (1 << k)) ++nITSpidLayers;
147 for(k = 2; k < 6; k++) if (TESTBIT(aodTrack->GetITSClusterMap(), k)) ++nITSpidLayers;
151 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
154 // ...and reject tracks where it is smaller than 3
155 if (nITSpidLayers < 3)
157 AliDebug(AliLog::kDebug+2, "Rejecting track with too few ITS pid layers");
161 // assign PID nsigmas to default cut check value
162 // since bad object types are rejected before, here we have an ESD track or AOD track
164 fCutValueD = fESDpid.GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA);
166 fCutValueD = fAODpid.NumberOfSigmasITS(aodTrack, fRefType);
168 // use default cut checking method
172 //_________________________________________________________________________________________________
173 void AliRsnCutPIDITS::Print(const Option_t *) const
176 // Print information on this cut
179 AliInfo(Form("Cut name : %s", GetName()));
180 AliInfo(Form("--> cut range (nsigma) : %.3f %.3f", fMinD, fMaxD));
181 AliInfo(Form("--> momentum range : %.3f %.3f", fMomMin, fMomMax));
182 AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted")));
185 //_________________________________________________________________________________________________
186 void AliRsnCutPIDITS::Initialize()
189 // Initialize ESD pid object from global one
192 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
193 AliESDInputHandler *handler = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
196 AliESDpid *pid = handler->GetESDpid();
200 fInitialized = kTRUE;