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)
20 #include "AliAnalysisManager.h"
21 #include "AliESDInputHandler.h"
22 #include "AliESDpid.h"
23 #include "AliAODpidUtil.h"
25 #include "AliRsnCutPIDTPC.h"
27 ClassImp(AliRsnCutPIDTPC)
29 //_________________________________________________________________________________________________
30 AliRsnCutPIDTPC::AliRsnCutPIDTPC
31 (const char *name, AliPID::EParticleType type, Double_t min, Double_t max, Bool_t rejectOutside) :
32 AliRsnCut(name, AliRsnCut::kDaughter, min, max),
33 fRejectOutside(rejectOutside),
44 fBB[0] = fBB[1] = fBB[2] = fBB[3] = fBB[4] = 0.0;
47 //_________________________________________________________________________________________________
48 AliRsnCutPIDTPC::AliRsnCutPIDTPC
49 (const AliRsnCutPIDTPC& copy) :
51 fRejectOutside(copy.fRejectOutside),
52 fMomMin(copy.fMomMin),
53 fMomMax(copy.fMomMax),
54 fRefType(copy.fRefType),
55 fESDpid(copy.fESDpid),
63 for (i = 0; i < 5; i++) fBB[i] = copy.fBB[i];
66 //_________________________________________________________________________________________________
67 AliRsnCutPIDTPC& AliRsnCutPIDTPC::operator=(const AliRsnCutPIDTPC& copy)
70 // Assignment operator
73 AliRsnCut::operator=(copy);
77 fRejectOutside = copy.fRejectOutside;
78 fMomMin = copy.fMomMin;
79 fMomMax = copy.fMomMax;
80 fRefType = copy.fRefType;
81 fESDpid = copy.fESDpid;
82 fAODpid = copy.fAODpid;
85 for (i = 0; i < 5; i++) fBB[i] = copy.fBB[i];
90 //_________________________________________________________________________________________________
91 void AliRsnCutPIDTPC::SetBBParam(Double_t p0, Double_t p1, Double_t p2, Double_t p3, Double_t p4)
94 // Properly set the Bethe-Bloch parameters in all places where it is needed.
104 //_________________________________________________________________________________________________
105 Bool_t AliRsnCutPIDTPC::IsSelected(TObject *object)
112 if (!TargetOK(object)) return kFALSE;
114 // common evaluation variables
116 AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
117 AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
119 // get inner momentum, needed for BB computation
121 if (!esdTrack->GetInnerParam()) {
122 AliDebug(AliLog::kDebug + 2, "No inner param");
125 mom = esdTrack->GetInnerParam()->P();
126 } else if (aodTrack) {
127 if (!aodTrack->GetDetPid()) {
128 AliDebug(AliLog::kDebug + 2, "No def-pid object");
131 mom = aodTrack->GetDetPid()->GetTPCmomentum();
132 if (mom < 1E-6) return kFALSE;
134 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
138 // assign PID nsigmas to default cut check value
139 // since bad object types are rejected before, here we have an ESD track or AOD track
142 fESDpid = new AliESDpid;
143 fESDpid->GetTPCResponse().SetBetheBlochParameters(fBB[0], fBB[1], fBB[2], fBB[3], fBB[4]);
145 fCutValueD = fESDpid->GetTPCResponse().GetNumberOfSigmas(mom, esdTrack->GetTPCsignal(), esdTrack->GetTPCsignalN(), fRefType);
148 fAODpid = new AliAODpidUtil;
149 fAODpid->GetTPCResponse().SetBetheBlochParameters(fBB[0], fBB[1], fBB[2], fBB[3], fBB[4]);
151 if (aodTrack->GetTPCsignalN() == 0) aodTrack->GetDetPid()->SetTPCsignalN(aodTrack->GetTPCNcls());
152 fCutValueD = fAODpid->NumberOfSigmasTPC(aodTrack, fRefType);
155 // use AliRsnCut default method to check cut
156 Bool_t cutCheck = OkRangeD();
158 // now check the momentum:
159 // -- if it stays inside the accepted range, track just checked
160 // with respect to the nsigma band
161 // -- if it stays outside the accepted range and 'fRejectOutside' is kTRUE,
162 // track is always rejected, while if 'fRejectOutside' is kFALSE,
163 // track is accepted if it stays inside the nsigma band
164 if ((mom >= fMomMin && mom <= fMomMax))
167 AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
168 return ((!fRejectOutside) && cutCheck);
172 //_________________________________________________________________________________________________
173 void AliRsnCutPIDTPC::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")));