]>
Commit | Line | Data |
---|---|---|
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" | |
659ef4f0 | 21 | #include "AliRsnCutPIDTPC.h" |
22 | ||
23 | ClassImp(AliRsnCutPIDTPC) | |
24 | ||
25 | //_________________________________________________________________________________________________ | |
26 | AliRsnCutPIDTPC::AliRsnCutPIDTPC | |
80e49c8b | 27 | (const char *name, AliPID::EParticleType type, Double_t min, Double_t max, Bool_t rejectOutside) : |
2a1c7696 | 28 | AliRsnCut(name, AliRsnCut::kDaughter, min, max), |
29 | fInitialized(kFALSE), | |
30 | fRejectOutside(rejectOutside), | |
31 | fMomMin(0.0), | |
32 | fMomMax(1E+20), | |
33 | fRefType(type), | |
34 | fESDpid(), | |
35 | fAODpid() | |
659ef4f0 | 36 | { |
37 | // | |
38 | // Main constructor. | |
39 | // | |
40 | } | |
41 | ||
42 | //_________________________________________________________________________________________________ | |
43 | AliRsnCutPIDTPC::AliRsnCutPIDTPC | |
44 | (const AliRsnCutPIDTPC& copy) : | |
2a1c7696 | 45 | AliRsnCut(copy), |
46 | fInitialized(kFALSE), | |
47 | fRejectOutside(copy.fRejectOutside), | |
48 | fMomMin(copy.fMomMin), | |
49 | fMomMax(copy.fMomMax), | |
50 | fRefType(copy.fRefType), | |
51 | fESDpid(copy.fESDpid), | |
52 | fAODpid(copy.fAODpid) | |
659ef4f0 | 53 | { |
54 | // | |
55 | // Copy constructor. | |
56 | // | |
57 | } | |
58 | ||
59 | //_________________________________________________________________________________________________ | |
60 | AliRsnCutPIDTPC& AliRsnCutPIDTPC::operator=(const AliRsnCutPIDTPC& copy) | |
61 | { | |
62 | // | |
63 | // Assignment operator | |
64 | // | |
65 | ||
2a1c7696 | 66 | AliRsnCut::operator=(copy); |
659ef4f0 | 67 | |
2a1c7696 | 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; | |
75 | ||
76 | return (*this); | |
659ef4f0 | 77 | } |
78 | ||
79 | //_________________________________________________________________________________________________ | |
80 | void 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 | ||
2a1c7696 | 86 | fESDpid.GetTPCResponse().SetBetheBlochParameters(p0, p1, p2, p3, p4); |
87 | fAODpid.GetTPCResponse().SetBetheBlochParameters(p0, p1, p2, p3, p4); | |
659ef4f0 | 88 | } |
89 | ||
90 | //_________________________________________________________________________________________________ | |
91 | Bool_t AliRsnCutPIDTPC::IsSelected(TObject *object) | |
92 | { | |
93 | // | |
94 | // Cut checker. | |
95 | // | |
96 | ||
2a1c7696 | 97 | // initialize if needed |
98 | if (!fInitialized) Initialize(); | |
99 | ||
100 | // coherence check | |
101 | if (!TargetOK(object)) return kFALSE; | |
102 | ||
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"); | |
108 | return kFALSE; | |
109 | } | |
110 | ||
111 | // common evaluation variables | |
112 | Double_t mom; | |
113 | AliESDtrack *esdTrack = fDaughter->GetRefESDtrack(); | |
114 | AliAODTrack *aodTrack = fDaughter->GetRefAODtrack(); | |
115 | ||
116 | // get inner momentum and check it w.r. to allowed range: | |
117 | // all tracks outside it will pass the cut or not, depending on 'fRejectOutside' | |
118 | if (esdTrack) | |
119 | mom = esdTrack->GetInnerParam()->P(); | |
120 | else if (aodTrack) | |
121 | mom = aodTrack->GetDetPid()->GetTPCmomentum(); | |
122 | else { | |
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 | } | |
126 | if ((mom < fMomMin || mom > fMomMax)) { | |
127 | AliDebug(AliLog::kDebug + 2, Form("Track momentum = %.5f, outside allowed range", mom)); | |
128 | return (!fRejectOutside); | |
129 | } | |
130 | ||
131 | // assign PID nsigmas to default cut check value | |
132 | // since bad object types are rejected before, here we have an ESD track or AOD track | |
133 | if (esdTrack) | |
134 | fCutValueD = fESDpid.GetTPCResponse().GetNumberOfSigmas(mom, esdTrack->GetTPCsignal(), esdTrack->GetTPCsignalN(), fRefType); | |
135 | else | |
136 | fCutValueD = fAODpid.NumberOfSigmasTPC(aodTrack, fRefType); | |
137 | ||
138 | // use AliRsnCut default method to check cut | |
139 | return OkRangeD(); | |
659ef4f0 | 140 | } |
141 | ||
142 | //_________________________________________________________________________________________________ | |
143 | void AliRsnCutPIDTPC::Print(const Option_t *) const | |
144 | { | |
145 | // | |
146 | // Print information on this cut | |
147 | // | |
148 | ||
2a1c7696 | 149 | AliInfo(Form("Cut name : %s", GetName())); |
150 | AliInfo(Form("--> cut range (nsigma) : %.3f %.3f", fMinD, fMaxD)); | |
151 | AliInfo(Form("--> momentum range : %.3f %.3f", fMomMin, fMomMax)); | |
152 | AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted"))); | |
659ef4f0 | 153 | } |
223b8750 | 154 | |
155 | //_________________________________________________________________________________________________ | |
156 | void AliRsnCutPIDTPC::Initialize() | |
157 | { | |
158 | // | |
159 | // Initialize ESD pid object from global one | |
160 | // | |
161 | ||
2a1c7696 | 162 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); |
163 | AliESDInputHandler *handler = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler()); | |
164 | if (handler) { | |
165 | AliESDpid *pid = handler->GetESDpid(); | |
166 | fESDpid = (*pid); | |
167 | } | |
223b8750 | 168 | |
2a1c7696 | 169 | fInitialized = kTRUE; |
223b8750 | 170 | } |