]>
Commit | Line | Data |
---|---|---|
e2bafbbc | 1 | // |
06351446 | 2 | // Class AliRsnCut |
3 | // | |
4 | // General implementation of a single cut strategy, which can be: | |
e2bafbbc | 5 | // - a value contained in a given interval [--> IsBetween() ] |
6 | // - a value equal to a given reference [--> MatchesValue()] | |
7 | // | |
06351446 | 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) | |
e2bafbbc | 17 | // |
06351446 | 18 | #include "AliLog.h" |
19 | ||
5eb970a4 | 20 | #include "AliRsnCut.h" |
06351446 | 21 | |
aec0ec32 | 22 | ClassImp(AliRsnCut) |
06351446 | 23 | |
5eb970a4 | 24 | //_________________________________________________________________________________________________ |
06351446 | 25 | AliRsnCut::AliRsnCut() : |
4fbb2459 | 26 | TNamed(), |
27 | fVarType(kInt), | |
28 | fMinI(0), | |
29 | fMaxI(0), | |
30 | fMinU(0), | |
31 | fMaxU(0), | |
32 | fMinD(0.0), | |
33 | fMaxD(0.0), | |
34 | fCutValueI(0), | |
35 | fCutValueU(0), | |
36 | fCutValueD(0.0), | |
37 | fCutResult(kTRUE) | |
06351446 | 38 | { |
39 | // | |
5eb970a4 | 40 | // Default constructor. |
06351446 | 41 | // |
42 | } | |
43 | ||
5eb970a4 | 44 | //_________________________________________________________________________________________________ |
45 | AliRsnCut::AliRsnCut | |
46 | (const char *name, Int_t min, Int_t max) : | |
4fbb2459 | 47 | TNamed(name, ""), |
48 | fVarType(kInt), | |
49 | fMinI(min), | |
50 | fMaxI(max), | |
51 | fMinU(0), | |
52 | fMaxU(0), | |
53 | fMinD(0.0), | |
54 | fMaxD(0.0), | |
55 | fCutValueI(0), | |
56 | fCutValueU(0), | |
57 | fCutValueD(0.0), | |
58 | fCutResult(kTRUE) | |
06351446 | 59 | { |
60 | // | |
5eb970a4 | 61 | // Constructor. |
62 | // If the cut must check values inside a range, | |
63 | // both 'value' arguments must be used, and they are, in the order, | |
64 | // the minimum and maximum of the allowed range. | |
65 | // If the cut must check a value, the second 'value' argument will never be used. | |
06351446 | 66 | // |
67 | } | |
68 | ||
5eb970a4 | 69 | //_________________________________________________________________________________________________ |
70 | AliRsnCut::AliRsnCut | |
71 | (const char *name, ULong_t min, ULong_t max) : | |
4fbb2459 | 72 | TNamed(name, ""), |
73 | fVarType(kULong), | |
74 | fMinI(0), | |
75 | fMaxI(0), | |
76 | fMinU(min), | |
77 | fMaxU(max), | |
78 | fMinD(0.0), | |
79 | fMaxD(0.0), | |
80 | fCutValueI(0), | |
81 | fCutValueU(0), | |
82 | fCutValueD(0.0), | |
83 | fCutResult(kTRUE) | |
06351446 | 84 | { |
85 | // | |
5eb970a4 | 86 | // Constructor. |
87 | // If the cut must check values inside a range, | |
88 | // both 'value' arguments must be used, and they are, in the order, | |
89 | // the minimum and maximum of the allowed range. | |
90 | // If the cut must check a value, the second 'value' argument will never be used. | |
06351446 | 91 | // |
92 | } | |
93 | ||
5eb970a4 | 94 | //_________________________________________________________________________________________________ |
95 | AliRsnCut::AliRsnCut | |
96 | (const char *name, Double_t min, Double_t max) : | |
4fbb2459 | 97 | TNamed(name, ""), |
98 | fVarType(kDouble), | |
99 | fMinI(0), | |
100 | fMaxI(0), | |
101 | fMinU(0), | |
102 | fMaxU(0), | |
103 | fMinD(min), | |
104 | fMaxD(max), | |
105 | fCutValueI(0), | |
106 | fCutValueU(0), | |
107 | fCutValueD(0.0), | |
108 | fCutResult(kTRUE) | |
06351446 | 109 | { |
110 | // | |
5eb970a4 | 111 | // Constructor. |
112 | // If the cut must check values inside a range, | |
113 | // both 'value' arguments must be used, and they are, in the order, | |
114 | // the minimum and maximum of the allowed range. | |
115 | // If the cut must check a value, the second 'value' argument will never be used. | |
06351446 | 116 | // |
117 | } | |
118 | ||
5eb970a4 | 119 | //_________________________________________________________________________________________________ |
e79f56bd | 120 | Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnDaughter* /*track*/) |
aec0ec32 | 121 | { |
122 | // | |
5eb970a4 | 123 | // Virtual cut-checking method. |
124 | // In base class, these methods compare the argument type | |
125 | // with the defined target, in order to detect a mismatch | |
aec0ec32 | 126 | // |
aec0ec32 | 127 | |
4fbb2459 | 128 | AliWarning("This cut does not provide checks on AliRsnDaughter. This function will return kTRUE"); |
5eb970a4 | 129 | return kTRUE; |
06351446 | 130 | } |
131 | ||
5eb970a4 | 132 | //_________________________________________________________________________________________________ |
e79f56bd | 133 | Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnPairParticle* /*pair*/) |
06351446 | 134 | { |
135 | // | |
5eb970a4 | 136 | // Virtual cut-checking method. |
137 | // In base class, these methods compare the argument type | |
138 | // with the defined target, in order to detect a mismatch | |
06351446 | 139 | // |
06351446 | 140 | |
4fbb2459 | 141 | AliWarning("This cut does not provide checks on AliRsnPairParticle. This function will return kTRUE"); |
5eb970a4 | 142 | return kTRUE; |
06351446 | 143 | } |
144 | ||
5eb970a4 | 145 | //_________________________________________________________________________________________________ |
e79f56bd | 146 | Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*event*/) |
06351446 | 147 | { |
148 | // | |
5eb970a4 | 149 | // Virtual cut-checking method. |
150 | // In base class, these methods compare the argument type | |
151 | // with the defined target, in order to detect a mismatch | |
06351446 | 152 | // |
06351446 | 153 | |
4fbb2459 | 154 | AliWarning("This cut does not provide checks on AliRsnEvent. This function will return kTRUE"); |
5eb970a4 | 155 | return kTRUE; |
06351446 | 156 | } |
157 | ||
5eb970a4 | 158 | //_________________________________________________________________________________________________ |
e79f56bd | 159 | Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*ev1*/, AliRsnEvent* /*ev2*/) |
06351446 | 160 | { |
161 | // | |
5eb970a4 | 162 | // Virtual cut-checking method. |
163 | // In base class, these methods compare the argument type | |
164 | // with the defined target, in order to detect a mismatch | |
06351446 | 165 | // |
aec0ec32 | 166 | |
4fbb2459 | 167 | AliWarning("This cut does not provide checks on two AliRsnEvent's. This function will return kTRUE"); |
5eb970a4 | 168 | return kTRUE; |
06351446 | 169 | } |
170 | ||
5eb970a4 | 171 | //_________________________________________________________________________________________________ |
172 | Bool_t AliRsnCut::OkValue() | |
06351446 | 173 | { |
174 | // | |
5eb970a4 | 175 | // This method is used when the cut consists in comparing the cut value |
176 | // with a reference value to which it must be equal (in case of doubles, 'almost' equal). | |
177 | // Then, the cut result is kTRUE if the cut value is equal to this reference value. | |
06351446 | 178 | // |
aec0ec32 | 179 | |
4fbb2459 | 180 | switch (fVarType) { |
181 | case kInt: | |
182 | // eval result | |
183 | fCutResult = (fCutValueI == fMinI); | |
184 | // print debug message | |
185 | AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ===================================="); | |
186 | AliDebug(AliLog::kDebug + 3, Form("Cut name : %s", GetName())); | |
187 | AliDebug(AliLog::kDebug + 3, Form("Checked value: %d", fCutValueI)); | |
188 | AliDebug(AliLog::kDebug + 3, Form("Cut value : %d", fMinI)); | |
189 | AliDebug(AliLog::kDebug + 3, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED"))); | |
190 | AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================"); | |
191 | break; | |
192 | case kULong: | |
193 | // eval result | |
194 | fCutResult = (fCutValueU == fMinU); | |
195 | // print debug message | |
196 | AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ===================================="); | |
197 | AliDebug(AliLog::kDebug + 3, Form("Cut name : %s", GetName())); | |
198 | AliDebug(AliLog::kDebug + 3, Form("Checked value: %d", fCutValueU)); | |
199 | AliDebug(AliLog::kDebug + 3, Form("Cut value : %d", fMinU)); | |
200 | AliDebug(AliLog::kDebug + 3, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED"))); | |
201 | AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================"); | |
202 | break; | |
203 | case kDouble: | |
204 | // eval result | |
205 | fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6); | |
206 | // print debug message | |
207 | AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ===================================="); | |
208 | AliDebug(AliLog::kDebug + 3, Form("Cut name : %s", GetName())); | |
209 | AliDebug(AliLog::kDebug + 3, Form("Checked value: %f", fCutValueD)); | |
210 | AliDebug(AliLog::kDebug + 3, Form("Cut value : %f", fMinD)); | |
211 | AliDebug(AliLog::kDebug + 3, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED"))); | |
212 | AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================"); | |
213 | break; | |
214 | default: | |
215 | AliError(Form("fVarType = %d --> not allowed", fVarType)); | |
216 | return kFALSE; | |
aec0ec32 | 217 | } |
218 | ||
5eb970a4 | 219 | return fCutResult; |
06351446 | 220 | } |
221 | ||
5eb970a4 | 222 | //_________________________________________________________________________________________________ |
223 | Bool_t AliRsnCut::OkRange() | |
e0baff8c | 224 | { |
5eb970a4 | 225 | // |
226 | // This method is used when the cut consists in an allowed range | |
227 | // where the cut value must be included to pass the cut. | |
228 | // Then, the cut result is kTRUE if the cut value is inside this range. | |
229 | // | |
e0baff8c | 230 | |
4fbb2459 | 231 | switch (fVarType) { |
232 | case kInt: | |
233 | // eval result | |
234 | fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI)); | |
235 | // print debug message | |
236 | AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ===================================="); | |
237 | AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName())); | |
238 | AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI)); | |
239 | AliDebug(AliLog::kDebug + 2, Form("Cut range : %d , %d", fMinI, fMaxI)); | |
240 | AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED"))); | |
241 | AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================"); | |
242 | break; | |
243 | case kULong: | |
244 | // eval result | |
245 | fCutResult = ((fCutValueU >= fMinU) && (fCutValueU <= fMaxU)); | |
246 | // print debug message | |
247 | AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ===================================="); | |
248 | AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName())); | |
249 | AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueU)); | |
250 | AliDebug(AliLog::kDebug + 2, Form("Cut range : %d , %d", fMinU, fMaxU)); | |
251 | AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED"))); | |
252 | AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================"); | |
253 | break; | |
254 | case kDouble: | |
255 | // eval result | |
256 | fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD)); | |
257 | // print debug message | |
258 | AliDebug(AliLog::kDebug + 3, "=== CUT DEBUG ===================================="); | |
259 | AliDebug(AliLog::kDebug + 2, Form("Cut name : %s", GetName())); | |
260 | AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD)); | |
261 | AliDebug(AliLog::kDebug + 2, Form("Cut range : %f , %f", fMinD, fMaxD)); | |
262 | AliDebug(AliLog::kDebug + 2, Form("Cut result : %s", (fCutResult ? "PASSED" : "NOT PASSED"))); | |
263 | AliDebug(AliLog::kDebug + 3, "=== END CUT DEBUG ================================"); | |
264 | break; | |
265 | default: | |
266 | AliError(Form("fVarType = %d --> not allowed", fVarType)); | |
267 | return kFALSE; | |
e0baff8c | 268 | } |
269 | ||
5eb970a4 | 270 | return fCutResult; |
e0baff8c | 271 | } |
272 |