]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCut.cxx
f1d2a38a66c95716b146bc065d2e213c35aaa898
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCut.cxx
1 //
2 // Class AliRsnCut
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 #include "AliLog.h"
19
20 #include "AliRsnCut.h"
21
22 ClassImp(AliRsnCut)
23
24 //_________________________________________________________________________________________________
25 AliRsnCut::AliRsnCut() :
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)
38 {
39 //
40 // Default constructor.
41 //
42 }
43
44 //_________________________________________________________________________________________________
45 AliRsnCut::AliRsnCut
46 (const char *name, Int_t min, Int_t max) :
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)
59 {
60 //
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.
66 //
67 }
68
69 //_________________________________________________________________________________________________
70 AliRsnCut::AliRsnCut
71 (const char *name, ULong_t min, ULong_t max) :
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)
84 {
85 //
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.
91 //
92 }
93
94 //_________________________________________________________________________________________________
95 AliRsnCut::AliRsnCut
96 (const char *name, Double_t min, Double_t max) :
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)
109 {
110 //
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.
116 //
117 }
118
119 //_________________________________________________________________________________________________
120 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnDaughter* /*track*/)
121 {
122 //
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
126 //
127
128   AliWarning("This cut does not provide checks on AliRsnDaughter. This function will return kTRUE");
129   return kTRUE;
130 }
131
132 //_________________________________________________________________________________________________
133 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnPairParticle* /*pair*/)
134 {
135 //
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
139 //
140
141   AliWarning("This cut does not provide checks on AliRsnPairParticle. This function will return kTRUE");
142   return kTRUE;
143 }
144
145 //_________________________________________________________________________________________________
146 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*event*/)
147 {
148 //
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
152 //
153
154   AliWarning("This cut does not provide checks on AliRsnEvent. This function will return kTRUE");
155   return kTRUE;
156 }
157
158 //_________________________________________________________________________________________________
159 Bool_t AliRsnCut::IsSelected(ETarget /*tgt*/, AliRsnEvent* /*ev1*/, AliRsnEvent* /*ev2*/)
160 {
161 //
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
165 //
166
167   AliWarning("This cut does not provide checks on two AliRsnEvent's. This function will return kTRUE");
168   return kTRUE;
169 }
170
171 //_________________________________________________________________________________________________
172 Bool_t AliRsnCut::OkValue()
173 {
174 //
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.
178 //
179
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;
217   }
218
219   return fCutResult;
220 }
221
222 //_________________________________________________________________________________________________
223 Bool_t AliRsnCut::OkRange()
224 {
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 //
230
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;
268   }
269
270   return fCutResult;
271 }
272