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