]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - PWGLF/RESONANCES/AliRsnCutPIDTPC.cxx
update on v2 calculation
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnCutPIDTPC.cxx
... / ...
CommitLineData
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
19#include "AliPID.h"
20#include "AliAnalysisManager.h"
21#include "AliESDInputHandler.h"
22#include "AliESDpid.h"
23#include "AliAODpidUtil.h"
24
25#include "AliRsnCutPIDTPC.h"
26
27ClassImp(AliRsnCutPIDTPC)
28
29//_________________________________________________________________________________________________
30AliRsnCutPIDTPC::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),
34 fMomMin(0.0),
35 fMomMax(1E+20),
36 fRefType(type),
37 fESDpid(0x0),
38 fAODpid(0x0)
39{
40//
41// Main constructor.
42//
43
44 fBB[0] = fBB[1] = fBB[2] = fBB[3] = fBB[4] = 0.0;
45}
46
47//_________________________________________________________________________________________________
48AliRsnCutPIDTPC::AliRsnCutPIDTPC
49(const AliRsnCutPIDTPC &copy) :
50 AliRsnCut(copy),
51 fRejectOutside(copy.fRejectOutside),
52 fMomMin(copy.fMomMin),
53 fMomMax(copy.fMomMax),
54 fRefType(copy.fRefType),
55 fESDpid(copy.fESDpid),
56 fAODpid(copy.fAODpid)
57{
58//
59// Copy constructor.
60//
61
62 Int_t i;
63 for (i = 0; i < 5; i++) fBB[i] = copy.fBB[i];
64}
65
66//_________________________________________________________________________________________________
67AliRsnCutPIDTPC &AliRsnCutPIDTPC::operator=(const AliRsnCutPIDTPC &copy)
68{
69//
70// Assignment operator
71//
72
73 AliRsnCut::operator=(copy);
74 if (this == &copy)
75 return *this;
76
77 fRejectOutside = copy.fRejectOutside;
78 fMomMin = copy.fMomMin;
79 fMomMax = copy.fMomMax;
80 fRefType = copy.fRefType;
81 fESDpid = copy.fESDpid;
82 fAODpid = copy.fAODpid;
83
84 Int_t i;
85 for (i = 0; i < 5; i++) fBB[i] = copy.fBB[i];
86
87 return (*this);
88}
89
90//_________________________________________________________________________________________________
91void AliRsnCutPIDTPC::SetBBParam(Double_t p0, Double_t p1, Double_t p2, Double_t p3, Double_t p4)
92{
93//
94// Properly set the Bethe-Bloch parameters in all places where it is needed.
95//
96
97 fBB[0] = p0;
98 fBB[1] = p1;
99 fBB[2] = p2;
100 fBB[3] = p3;
101 fBB[4] = p4;
102}
103
104//_________________________________________________________________________________________________
105Bool_t AliRsnCutPIDTPC::IsSelected(TObject *object)
106{
107//
108// Cut checker.
109//
110
111 // coherence check
112 if (!TargetOK(object)) return kFALSE;
113
114 // common evaluation variables
115 Double_t mom;
116 AliESDtrack *esdTrack = fDaughter->Ref2ESDtrack();
117 AliAODTrack *aodTrack = fDaughter->Ref2AODtrack();
118
119 // get inner momentum, needed for BB computation
120 if (esdTrack) {
121 if (!esdTrack->GetInnerParam()) {
122 AliDebug(AliLog::kDebug + 2, "No inner param");
123 return kFALSE;
124 }
125 mom = esdTrack->GetInnerParam()->P();
126 } else if (aodTrack) {
127 if (!aodTrack->GetDetPid()) {
128 AliDebug(AliLog::kDebug + 2, "No def-pid object");
129 return kFALSE;
130 }
131 mom = aodTrack->GetDetPid()->GetTPCmomentum();
132 if (mom < 1E-6) return kFALSE;
133 } else {
134 AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName()));
135 return kFALSE;
136 }
137
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
140 if (esdTrack) {
141 if (!fESDpid) {
142 fESDpid = new AliESDpid;
143 fESDpid->GetTPCResponse().SetBetheBlochParameters(fBB[0], fBB[1], fBB[2], fBB[3], fBB[4]);
144 }
145 fCutValueD = fESDpid->GetTPCResponse().GetNumberOfSigmas(mom, esdTrack->GetTPCsignal(), esdTrack->GetTPCsignalN(), fRefType);
146 } else {
147 if (!fAODpid) {
148 fAODpid = new AliAODpidUtil;
149 fAODpid->GetTPCResponse().SetBetheBlochParameters(fBB[0], fBB[1], fBB[2], fBB[3], fBB[4]);
150 }
151 if (aodTrack->GetTPCsignalN() == 0) aodTrack->GetDetPid()->SetTPCsignalN(aodTrack->GetTPCNcls());
152 fCutValueD = fAODpid->NumberOfSigmasTPC(aodTrack, fRefType);
153 }
154
155 // use AliRsnCut default method to check cut
156 Bool_t cutCheck = OkRangeD();
157
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))
165 return cutCheck;
166 else {
167 AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom));
168 return ((!fRejectOutside) && cutCheck);
169 }
170}
171
172//_________________________________________________________________________________________________
173void AliRsnCutPIDTPC::Print(const Option_t *) const
174{
175//
176// Print information on this cut
177//
178
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")));
183}