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