2 // Class AliRsnCutPIDTPC
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"
21 #include "AliRsnCutPIDTPC.h"
23 ClassImp(AliRsnCutPIDTPC)
25 //_________________________________________________________________________________________________
26 AliRsnCutPIDTPC::AliRsnCutPIDTPC
27 (const char *name, AliPID::EParticleType type, Double_t min, Double_t max, Bool_t rejectOutside) :
28 AliRsnCut(name, AliRsnCut::kDaughter, min, max),
30 fRejectOutside(rejectOutside),
42 //_________________________________________________________________________________________________
43 AliRsnCutPIDTPC::AliRsnCutPIDTPC
44 (const AliRsnCutPIDTPC& copy) :
47 fRejectOutside(copy.fRejectOutside),
48 fMomMin(copy.fMomMin),
49 fMomMax(copy.fMomMax),
50 fRefType(copy.fRefType),
51 fESDpid(copy.fESDpid),
59 //_________________________________________________________________________________________________
60 AliRsnCutPIDTPC& AliRsnCutPIDTPC::operator=(const AliRsnCutPIDTPC& copy)
63 // Assignment operator
66 AliRsnCut::operator=(copy);
68 fInitialized = kFALSE;
69 fRejectOutside = copy.fRejectOutside;
70 fMomMin = copy.fMomMin;
71 fMomMax = copy.fMomMax;
72 fRefType = copy.fRefType;
73 fESDpid = copy.fESDpid;
74 fAODpid = copy.fAODpid;
79 //_________________________________________________________________________________________________
80 void AliRsnCutPIDTPC::SetBBParam(Double_t p0, Double_t p1, Double_t p2, Double_t p3, Double_t p4)
83 // Properly set the Bethe-Bloch parameters in all places where it is needed.
86 fESDpid.GetTPCResponse().SetBetheBlochParameters(p0, p1, p2, p3, p4);
87 fAODpid.GetTPCResponse().SetBetheBlochParameters(p0, p1, p2, p3, p4);
90 //_________________________________________________________________________________________________
91 Bool_t AliRsnCutPIDTPC::IsSelected(TObject *object)
97 // initialize if needed
98 if (!fInitialized) Initialize();
101 if (!TargetOK(object)) return kFALSE;
103 // reject not TPC tracks
104 AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
105 if (!vtrack) return kFALSE;
106 if (!IsTPC(vtrack)) {
107 AliDebug(AliLog::kDebug + 2, "Track is not found in TPC");
111 // common evaluation variables
113 AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
114 AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
116 // get inner momentum, needed for BB computation
118 mom = esdTrack->GetInnerParam()->P();
120 mom = aodTrack->GetDetPid()->GetTPCmomentum();
122 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
126 // assign PID nsigmas to default cut check value
127 // since bad object types are rejected before, here we have an ESD track or AOD track
129 fCutValueD = fESDpid.GetTPCResponse().GetNumberOfSigmas(mom, esdTrack->GetTPCsignal(), esdTrack->GetTPCsignalN(), fRefType);
131 fCutValueD = fAODpid.NumberOfSigmasTPC(aodTrack, fRefType);
133 // use AliRsnCut default method to check cut
134 Bool_t cutCheck = OkRangeD();
136 // now check the momentum:
137 // -- if it stays inside the accepted range, track just checked
138 // with respect to the nsigma band
139 // -- if it stays outside the accepted range and 'fRejectOutside' is kTRUE,
140 // track is always rejected, while if 'fRejectOutside' is kFALSE,
141 // track is accepted if it stays inside the nsigma band
142 if ((mom >= fMomMin && mom <= fMomMax))
145 AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
146 return ((!fRejectOutside) && cutCheck);
150 //_________________________________________________________________________________________________
151 void AliRsnCutPIDTPC::Print(const Option_t *) const
154 // Print information on this cut
157 AliInfo(Form("Cut name : %s", GetName()));
158 AliInfo(Form("--> cut range (nsigma) : %.3f %.3f", fMinD, fMaxD));
159 AliInfo(Form("--> momentum range : %.3f %.3f", fMomMin, fMomMax));
160 AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted")));
163 //_________________________________________________________________________________________________
164 void AliRsnCutPIDTPC::Initialize()
167 // Initialize ESD pid object from global one
170 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
171 AliESDInputHandler *handler = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
173 AliESDpid *pid = handler->GetESDpid();
177 fInitialized = kTRUE;