]>
Commit | Line | Data |
---|---|---|
e2bafbbc | 1 | // |
32992791 | 2 | // *** Class AliRsnCut *** |
06351446 | 3 | // |
32992791 | 4 | // Cut base class: all other cuts inherit from it. |
5 | // The 'core' of the class is the method "IsSelected()" which | |
6 | // must be overloaded by any specific cut implementation. | |
e2bafbbc | 7 | // |
32992791 | 8 | // This class provides some default instruments to check values |
9 | // agains a reference or an allowed range, in order to permit | |
10 | // a unique way to execute such kind of checks. | |
06351446 | 11 | // |
32992791 | 12 | // authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) |
13 | // Martin Vala (martin.vala@cern.ch) | |
e2bafbbc | 14 | // |
06351446 | 15 | |
669ee453 | 16 | #include <TFormula.h> |
5eb970a4 | 17 | #include "AliRsnCut.h" |
06351446 | 18 | |
aec0ec32 | 19 | ClassImp(AliRsnCut) |
06351446 | 20 | |
32992791 | 21 | //______________________________________________________________________________ |
22 | AliRsnCut::AliRsnCut(const char *name, RSNTARGET target) : | |
2a1c7696 | 23 | AliRsnTarget(name, target), |
24 | fMinI(0), | |
25 | fMaxI(0), | |
26 | fMinD(0.), | |
27 | fMaxD(0.), | |
fda16e8d | 28 | fMinIptdep(0), |
29 | fMaxIptdep(0), | |
30 | fMinDptdep(0), | |
31 | fMaxDptdep(0), | |
2a1c7696 | 32 | fCutValueI(0), |
33 | fCutValueD(0.0), | |
669ee453 | 34 | fPtDepCut(kFALSE), |
35 | fRefPtValueD(0.0), | |
36 | fMaxPt(1E20), | |
37 | fMinPt(0.0), | |
38 | fPtDepCutMaxFormula(""), | |
39 | fPtDepCutMinFormula(""), | |
2a1c7696 | 40 | fCutResult(kTRUE) |
06351446 | 41 | { |
42 | // | |
5eb970a4 | 43 | // Default constructor. |
06351446 | 44 | // |
45 | } | |
46 | ||
32992791 | 47 | //______________________________________________________________________________ |
5eb970a4 | 48 | AliRsnCut::AliRsnCut |
32992791 | 49 | (const char *name, RSNTARGET target, Int_t imin, Int_t imax, Double_t dmin, Double_t dmax) : |
2a1c7696 | 50 | AliRsnTarget(name, target), |
51 | fMinI(imin), | |
52 | fMaxI(imax), | |
53 | fMinD(dmin), | |
54 | fMaxD(dmax), | |
fda16e8d | 55 | fMinIptdep(0), |
56 | fMaxIptdep(0), | |
57 | fMinDptdep(0), | |
58 | fMaxDptdep(0), | |
2a1c7696 | 59 | fCutValueI(0), |
60 | fCutValueD(0.0), | |
669ee453 | 61 | fPtDepCut(kFALSE), |
62 | fRefPtValueD(0.0), | |
63 | fMaxPt(1E20), | |
64 | fMinPt(0.0), | |
65 | fPtDepCutMaxFormula(""), | |
66 | fPtDepCutMinFormula(""), | |
2a1c7696 | 67 | fCutResult(kTRUE) |
06351446 | 68 | { |
69 | // | |
32992791 | 70 | // Constructor with arguments. |
71 | // This is provided to allow a quick setting of all data members. | |
06351446 | 72 | // |
73 | } | |
74 | ||
32992791 | 75 | //______________________________________________________________________________ |
5eb970a4 | 76 | AliRsnCut::AliRsnCut |
32992791 | 77 | (const char *name, RSNTARGET target, Double_t dmin, Double_t dmax, Int_t imin, Int_t imax) : |
2a1c7696 | 78 | AliRsnTarget(name, target), |
79 | fMinI(imin), | |
80 | fMaxI(imax), | |
81 | fMinD(dmin), | |
82 | fMaxD(dmax), | |
fda16e8d | 83 | fMinIptdep(0), |
84 | fMaxIptdep(0), | |
85 | fMinDptdep(0), | |
86 | fMaxDptdep(0), | |
2a1c7696 | 87 | fCutValueI(0), |
88 | fCutValueD(0.0), | |
669ee453 | 89 | fPtDepCut(kFALSE), |
90 | fRefPtValueD(0.0), | |
91 | fMaxPt(1E20), | |
92 | fMinPt(0.0), | |
93 | fPtDepCutMaxFormula(""), | |
94 | fPtDepCutMinFormula(""), | |
2a1c7696 | 95 | fCutResult(kTRUE) |
06351446 | 96 | { |
97 | // | |
32992791 | 98 | // Constructor with arguments. |
99 | // This is provided to allow a quick setting of all data members. | |
06351446 | 100 | // |
101 | } | |
102 | ||
32992791 | 103 | //______________________________________________________________________________ |
61f275d1 | 104 | AliRsnCut::AliRsnCut(const AliRsnCut ©) : |
2a1c7696 | 105 | AliRsnTarget(copy), |
106 | fMinI(copy.fMinI), | |
107 | fMaxI(copy.fMaxI), | |
108 | fMinD(copy.fMinD), | |
109 | fMaxD(copy.fMaxD), | |
fda16e8d | 110 | fMinIptdep(copy.fMinIptdep), |
111 | fMaxIptdep(copy.fMaxIptdep), | |
112 | fMinDptdep(copy.fMinDptdep), | |
113 | fMaxDptdep(copy.fMaxDptdep), | |
2a1c7696 | 114 | fCutValueI(copy.fCutValueI), |
115 | fCutValueD(copy.fCutValueD), | |
669ee453 | 116 | fPtDepCut(copy.fPtDepCut), |
117 | fRefPtValueD(copy.fRefPtValueD), | |
118 | fMaxPt(copy.fMaxPt), | |
119 | fMinPt(copy.fMinPt), | |
120 | fPtDepCutMaxFormula(copy.fPtDepCutMaxFormula), | |
121 | fPtDepCutMinFormula(copy.fPtDepCutMinFormula), | |
2a1c7696 | 122 | fCutResult(copy.fCutResult) |
32992791 | 123 | { |
124 | // | |
125 | // Copy constructor. | |
126 | // Don't duplicate memory occupancy for pointer | |
127 | // | |
128 | } | |
129 | ||
130 | //______________________________________________________________________________ | |
61f275d1 | 131 | AliRsnCut &AliRsnCut::operator=(const AliRsnCut ©) |
413bbf44 | 132 | { |
133 | // | |
32992791 | 134 | // Assignment operator. |
135 | // Don't duplicate memory occupancy for pointer | |
413bbf44 | 136 | // |
137 | ||
61f275d1 | 138 | AliRsnTarget::operator=(copy); |
e6f3a909 | 139 | if (this == ©) |
61f275d1 | 140 | return *this; |
413bbf44 | 141 | |
2a1c7696 | 142 | fMinI = copy.fMinI; |
143 | fMaxI = copy.fMaxI; | |
144 | fMinD = copy.fMinD; | |
145 | fMaxD = copy.fMaxD; | |
fda16e8d | 146 | fMinIptdep = copy.fMinIptdep; |
147 | fMaxIptdep = copy.fMaxIptdep; | |
148 | fMinDptdep = copy.fMinDptdep; | |
149 | fMaxDptdep = copy.fMaxDptdep; | |
2a1c7696 | 150 | fCutValueI = copy.fCutValueI; |
151 | fCutValueD = copy.fCutValueD; | |
669ee453 | 152 | fPtDepCut = copy.fPtDepCut; |
153 | fRefPtValueD = copy.fRefPtValueD; | |
154 | fMaxPt = copy.fMaxPt; | |
155 | fMinPt = copy.fMinPt; | |
156 | fPtDepCutMaxFormula = copy.fPtDepCutMaxFormula; | |
157 | fPtDepCutMinFormula = copy.fPtDepCutMinFormula; | |
eaa44581 | 158 | fCutResult = copy.fCutResult; |
2a1c7696 | 159 | |
160 | return (*this); | |
413bbf44 | 161 | } |
162 | ||
32992791 | 163 | //______________________________________________________________________________ |
3da8cef7 | 164 | Bool_t AliRsnCut::IsSelected(TObject * /*object*/) |
aec0ec32 | 165 | { |
166 | // | |
32992791 | 167 | // Virtual cut-checking method. |
168 | // In this implementation, it does nothing, and all classes | |
169 | // inheriting from this, should provide a proper implementation | |
170 | // which must return kTRUE if the cut is passed, and kFALSE otherwise. | |
aec0ec32 | 171 | // |
aec0ec32 | 172 | |
2a1c7696 | 173 | AliWarning("This virtual function must be implemented properly"); |
174 | return kTRUE; | |
06351446 | 175 | } |
176 | ||
32992791 | 177 | //______________________________________________________________________________ |
2dab9030 | 178 | Bool_t AliRsnCut::OkValueI() |
06351446 | 179 | { |
180 | // | |
eaa44581 | 181 | // This method is used to compare a value with a reference. |
182 | // In the case of integers, the equality must be exact. | |
06351446 | 183 | // |
aec0ec32 | 184 | |
2a1c7696 | 185 | // eval result |
669ee453 | 186 | |
187 | if (fPtDepCut){ | |
188 | if(fRefPtValueD > fMaxPt) { | |
189 | AliDebug(2,Form("pt = %f (> %f), cutting at %d\n",fRefPtValueD, fMaxPt, fMinI)); | |
190 | fCutResult = (fCutValueI == fMinI); | |
191 | } else if (fRefPtValueD < fMinPt){ | |
192 | AliDebug(2,Form("pt = %f (< %f), cutting at %d\n",fRefPtValueD, fMinPt, fMinI)); | |
193 | fCutResult = (fCutValueI == fMinI); | |
194 | }else{ | |
195 | TString str(fPtDepCutMinFormula); | |
196 | str.ReplaceAll("pt", "x"); | |
197 | TFormula ptdepcut(Form("%s_ptdepcut", GetName()), str.Data()); | |
fda16e8d | 198 | fMinIptdep = static_cast<int> (ptdepcut.Eval(fRefPtValueD)); |
199 | AliDebug(2,Form("pt = %f (> %f and < %f), cutting at %d\n",fRefPtValueD, fMinPt, fMaxPt, fMinIptdep)); | |
200 | fCutResult = (fCutValueI == fMinIptdep); | |
669ee453 | 201 | } |
202 | } | |
203 | else fCutResult = (fCutValueI == fMinI); | |
2a1c7696 | 204 | |
205 | // print debug message | |
eaa44581 | 206 | AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ========================================================"); |
2a1c7696 | 207 | AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName())); |
208 | AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI)); | |
209 | AliDebug(AliLog::kDebug + 2, Form("Cut value : %d", fMinI)); | |
210 | AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED"))); | |
eaa44581 | 211 | AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ===================================================="); |
2a1c7696 | 212 | |
213 | return fCutResult; | |
2dab9030 | 214 | } |
aec0ec32 | 215 | |
32992791 | 216 | //______________________________________________________________________________ |
2dab9030 | 217 | Bool_t AliRsnCut::OkValueD() |
218 | { | |
219 | // | |
eaa44581 | 220 | // This method is used to compare a value with a reference. |
221 | // In the case of doubles, the equality consists in being very close. | |
2dab9030 | 222 | // |
223 | ||
2a1c7696 | 224 | // eval result |
669ee453 | 225 | |
226 | if (fPtDepCut){ | |
227 | if(fRefPtValueD > fMaxPt) { | |
228 | AliDebug(2,Form("pt = %f (> %f), cutting at %f\n",fRefPtValueD, fMaxPt, fMinD)); | |
229 | fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6); | |
230 | } else if (fRefPtValueD < fMinPt){ | |
231 | AliDebug(2,Form("pt = %f (< %f), cutting at %f\n",fRefPtValueD, fMinPt, fMinD)); | |
232 | fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6); | |
233 | }else{ | |
234 | TString str(fPtDepCutMinFormula); | |
235 | str.ReplaceAll("pt", "x"); | |
236 | TFormula ptdepcut(Form("%s_ptdepcut", GetName()), str.Data()); | |
fda16e8d | 237 | fMinDptdep = ptdepcut.Eval(fRefPtValueD); |
238 | AliDebug(2,Form("pt = %f (> %f and < %f), cutting at %f\n",fRefPtValueD, fMinPt, fMaxPt, fMinDptdep)); | |
239 | fCutResult = (TMath::Abs(fCutValueD - fMinDptdep) < 1E-6); | |
669ee453 | 240 | } |
241 | } | |
242 | else fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6); | |
2a1c7696 | 243 | |
244 | // print debug message | |
eaa44581 | 245 | AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ======================================================="); |
2a1c7696 | 246 | AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName())); |
247 | AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD)); | |
248 | AliDebug(AliLog::kDebug + 2, Form("Cut value : %f", fMinD)); | |
249 | AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED"))); | |
eaa44581 | 250 | AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ==================================================="); |
2a1c7696 | 251 | |
252 | return fCutResult; | |
06351446 | 253 | } |
254 | ||
32992791 | 255 | //______________________________________________________________________________ |
2dab9030 | 256 | Bool_t AliRsnCut::OkRangeI() |
e0baff8c | 257 | { |
5eb970a4 | 258 | // |
eaa44581 | 259 | // This method is used to compare a value with an integer range. |
5eb970a4 | 260 | // |
e0baff8c | 261 | |
669ee453 | 262 | // eval result |
263 | if (fPtDepCut){ | |
264 | if(fRefPtValueD > fMaxPt) { | |
265 | AliDebug(2,Form("pt = %f (> %f), cutting between [%d, %d]\n",fRefPtValueD, fMaxPt, fMinI, fMaxI)); | |
266 | fCutResult = ((fCutValueI >= fMinI) && (fCutValueD <= fMaxI)); | |
267 | } else if (fRefPtValueD < fMinPt){ | |
268 | AliDebug(2,Form("pt = %f (< %f), cutting between [%d, %d]\n",fRefPtValueD, fMinPt, fMinI, fMaxI)); | |
269 | fCutResult = ((fCutValueI >= fMinI) && (fCutValueD <= fMaxI)); | |
270 | } else { | |
271 | TString str(fPtDepCutMinFormula); | |
272 | str.ReplaceAll("pt", "x"); | |
273 | TFormula ptdepcut(Form("%s_ptdepcut", GetName()), str.Data()); | |
fda16e8d | 274 | fMinIptdep = static_cast<int> (ptdepcut.Eval(fRefPtValueD)); |
669ee453 | 275 | |
276 | TString str2(fPtDepCutMaxFormula); | |
277 | str2.ReplaceAll("pt", "x"); | |
278 | TFormula ptdepcut2(Form("%s_ptdepcut", GetName()), str2.Data()); | |
fda16e8d | 279 | fMaxIptdep = static_cast<int> (ptdepcut2.Eval(fRefPtValueD)); |
669ee453 | 280 | |
fda16e8d | 281 | AliDebug(2,Form("pt = %f (> %f and < %f), cutting according to the fiducial zone [%d, %d]\n",fRefPtValueD, fMinPt, fMaxPt, fMinIptdep, fMaxIptdep)); |
282 | fCutResult = ((fCutValueI >= fMinIptdep) && (fCutValueI <= fMaxIptdep)); | |
669ee453 | 283 | } |
284 | } | |
285 | else fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI)); | |
2a1c7696 | 286 | |
287 | // print debug message | |
eaa44581 | 288 | AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ========================================================"); |
2a1c7696 | 289 | AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName())); |
290 | AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI)); | |
291 | AliDebug(AliLog::kDebug + 2, Form("Cut range : %d , %d", fMinI, fMaxI)); | |
292 | AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED"))); | |
eaa44581 | 293 | AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ===================================================="); |
2a1c7696 | 294 | |
295 | return fCutResult; | |
2dab9030 | 296 | } |
297 | ||
32992791 | 298 | //______________________________________________________________________________ |
2dab9030 | 299 | Bool_t AliRsnCut::OkRangeD() |
300 | { | |
301 | // | |
eaa44581 | 302 | // This method is used to compare a value with a double-float range. |
2dab9030 | 303 | // |
304 | ||
669ee453 | 305 | // eval result |
306 | ||
307 | if (fPtDepCut){ | |
308 | if(fRefPtValueD > fMaxPt) { | |
309 | AliDebug(2,Form("pt = %f (> %f), cutting between [%f, %f]\n",fRefPtValueD, fMaxPt, fMinD, fMaxD)); | |
310 | fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD)); | |
311 | } else if (fRefPtValueD < fMinPt) { | |
312 | AliDebug(2,Form("pt = %f (< %f), cutting between [%f, %f]\n",fRefPtValueD, fMinPt, fMinD, fMaxD)); | |
313 | fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD)); | |
314 | } else { | |
315 | TString str(fPtDepCutMinFormula); | |
316 | str.ReplaceAll("pt", "x"); | |
317 | TFormula ptdepcut(Form("%s_ptdepcut", GetName()), str.Data()); | |
fda16e8d | 318 | fMinDptdep = ptdepcut.Eval(fRefPtValueD); |
669ee453 | 319 | |
320 | TString str2(fPtDepCutMaxFormula); | |
321 | str2.ReplaceAll("pt", "x"); | |
322 | TFormula ptdepcut2(Form("%s_ptdepcut", GetName()), str2.Data()); | |
fda16e8d | 323 | fMaxDptdep = ptdepcut2.Eval(fRefPtValueD); |
669ee453 | 324 | |
fda16e8d | 325 | AliDebug(2,Form("pt = %f (> %f and < %f), cutting according to the fiducial zone [%f, %f]\n",fRefPtValueD, fMinPt, fMaxPt, fMinDptdep, fMaxDptdep)); |
326 | fCutResult = ((fCutValueD >= fMinDptdep) && (fCutValueD <= fMaxDptdep)); | |
669ee453 | 327 | } |
328 | } | |
329 | else fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD)); | |
2a1c7696 | 330 | |
331 | // print debug message | |
eaa44581 | 332 | AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ========================================================"); |
2a1c7696 | 333 | AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName())); |
334 | AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD)); | |
335 | AliDebug(AliLog::kDebug + 2, Form("Cut range : %f , %f", fMinD, fMaxD)); | |
336 | AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED"))); | |
eaa44581 | 337 | AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ===================================================="); |
e0baff8c | 338 | |
2a1c7696 | 339 | return fCutResult; |
e0baff8c | 340 | } |
341 | ||
669ee453 | 342 | |
32992791 | 343 | //______________________________________________________________________________ |
61f275d1 | 344 | void AliRsnCut::Print(Option_t *) const |
2dab9030 | 345 | { |
346 | // | |
32992791 | 347 | // Override TObject::Print() method, |
348 | // and print some useful info about the cut general parameters. | |
2dab9030 | 349 | // |
350 | ||
2a1c7696 | 351 | AliInfo("=== CUT DETAILS ===================================="); |
352 | AliInfo(Form("Cut name : [%s]", GetName())); | |
353 | AliInfo(Form("Cut target : [%s]", GetTargetTypeName())); | |
354 | AliInfo(Form("Cut edges [D]: [%f - %f]", fMinD, fMaxD)); | |
355 | AliInfo(Form("Cut edges [I]: [%d - %d]", fMinI, fMaxI)); | |
669ee453 | 356 | AliInfo(Form("Cut pt dependent: %s", (fPtDepCut ? "YES" : "NO"))); |
2a1c7696 | 357 | AliInfo("===================================================="); |
2dab9030 | 358 | } |