]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnCutPIDTPC.cxx
Implementation of all needed changes in the package in order to speed-up the executio...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPIDTPC.cxx
CommitLineData
659ef4f0 1//
2// Class AliRsnCutPIDTPC
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"
c865cb1d 21#include "AliESDpid.h"
22#include "AliAODpidUtil.h"
23
659ef4f0 24#include "AliRsnCutPIDTPC.h"
25
26ClassImp(AliRsnCutPIDTPC)
27
28//_________________________________________________________________________________________________
29AliRsnCutPIDTPC::AliRsnCutPIDTPC
80e49c8b 30(const char *name, AliPID::EParticleType type, Double_t min, Double_t max, Bool_t rejectOutside) :
2a1c7696 31 AliRsnCut(name, AliRsnCut::kDaughter, min, max),
2a1c7696 32 fRejectOutside(rejectOutside),
33 fMomMin(0.0),
34 fMomMax(1E+20),
35 fRefType(type),
c865cb1d 36 fESDpid(0x0),
37 fAODpid(0x0)
659ef4f0 38{
39//
40// Main constructor.
41//
42}
43
44//_________________________________________________________________________________________________
45AliRsnCutPIDTPC::AliRsnCutPIDTPC
46(const AliRsnCutPIDTPC& copy) :
2a1c7696 47 AliRsnCut(copy),
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//
58}
59
60//_________________________________________________________________________________________________
61AliRsnCutPIDTPC& AliRsnCutPIDTPC::operator=(const AliRsnCutPIDTPC& copy)
62{
63//
64// Assignment operator
65//
66
2a1c7696 67 AliRsnCut::operator=(copy);
659ef4f0 68
2a1c7696 69 fRejectOutside = copy.fRejectOutside;
70 fMomMin = copy.fMomMin;
71 fMomMax = copy.fMomMax;
72 fRefType = copy.fRefType;
73 fESDpid = copy.fESDpid;
74 fAODpid = copy.fAODpid;
75
76 return (*this);
659ef4f0 77}
78
79//_________________________________________________________________________________________________
80void AliRsnCutPIDTPC::SetBBParam(Double_t p0, Double_t p1, Double_t p2, Double_t p3, Double_t p4)
81{
82//
83// Properly set the Bethe-Bloch parameters in all places where it is needed.
84//
85
c865cb1d 86 fBB[0] = p0;
87 fBB[1] = p1;
88 fBB[2] = p2;
89 fBB[3] = p3;
90 fBB[4] = p4;
659ef4f0 91}
92
93//_________________________________________________________________________________________________
94Bool_t AliRsnCutPIDTPC::IsSelected(TObject *object)
95{
96//
97// Cut checker.
98//
99
2a1c7696 100 // coherence check
101 if (!TargetOK(object)) return kFALSE;
102
2a1c7696 103 // common evaluation variables
104 Double_t mom;
105 AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
106 AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
107
2654b757 108 // get inner momentum, needed for BB computation
c865cb1d 109 if (esdTrack) {
110 if (!esdTrack->GetInnerParam()) {
111 AliDebug(AliLog::kDebug + 2, "No inner param");
112 return kFALSE;
113 }
2a1c7696 114 mom = esdTrack->GetInnerParam()->P();
c865cb1d 115 } else if (aodTrack) {
116 if (!aodTrack->GetDetPid()) {
117 AliDebug(AliLog::kDebug + 2, "No def-pid object");
118 return kFALSE;
119 }
2a1c7696 120 mom = aodTrack->GetDetPid()->GetTPCmomentum();
c865cb1d 121 if (mom < 1E-6) return kFALSE;
122 } else {
2a1c7696 123 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
124 return kFALSE;
125 }
2a1c7696 126
127 // assign PID nsigmas to default cut check value
128 // since bad object types are rejected before, here we have an ESD track or AOD track
c865cb1d 129 if (esdTrack) {
130 if (!fESDpid) {
131 fESDpid = new AliESDpid;
132 fESDpid->GetTPCResponse().SetBetheBlochParameters(fBB[0], fBB[1], fBB[2], fBB[3], fBB[4]);
133 }
134 fCutValueD = fESDpid->GetTPCResponse().GetNumberOfSigmas(mom, esdTrack->GetTPCsignal(), esdTrack->GetTPCsignalN(), fRefType);
135 } else {
136 if (!fAODpid) {
137 fAODpid = new AliAODpidUtil;
138 fAODpid->GetTPCResponse().SetBetheBlochParameters(fBB[0], fBB[1], fBB[2], fBB[3], fBB[4]);
139 }
140 if (aodTrack->GetTPCsignalN() == 0) aodTrack->GetDetPid()->SetTPCsignalN(aodTrack->GetTPCNcls());
141 fCutValueD = fAODpid->NumberOfSigmasTPC(aodTrack, fRefType);
142 }
2a1c7696 143
144 // use AliRsnCut default method to check cut
2654b757 145 Bool_t cutCheck = OkRangeD();
146
147 // now check the momentum:
148 // -- if it stays inside the accepted range, track just checked
149 // with respect to the nsigma band
150 // -- if it stays outside the accepted range and 'fRejectOutside' is kTRUE,
151 // track is always rejected, while if 'fRejectOutside' is kFALSE,
152 // track is accepted if it stays inside the nsigma band
153 if ((mom >= fMomMin && mom <= fMomMax))
154 return cutCheck;
155 else {
156 AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
157 return ((!fRejectOutside) && cutCheck);
158 }
659ef4f0 159}
160
161//_________________________________________________________________________________________________
162void AliRsnCutPIDTPC::Print(const Option_t *) const
163{
164//
165// Print information on this cut
166//
167
2a1c7696 168 AliInfo(Form("Cut name : %s", GetName()));
169 AliInfo(Form("--> cut range (nsigma) : %.3f %.3f", fMinD, fMaxD));
170 AliInfo(Form("--> momentum range : %.3f %.3f", fMomMin, fMomMax));
171 AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted")));
659ef4f0 172}