]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCut.cxx
using TObjString::String instead of GetString to get directly to reference to TString...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCut.cxx
1 //
2 // *** Class AliRsnCut ***
3 //
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.
7 //
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.
11 //
12 // authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
13 //          Martin Vala (martin.vala@cern.ch)
14 //
15
16 #include "AliRsnCut.h"
17
18 ClassImp(AliRsnCut)
19
20 //______________________________________________________________________________
21 AliRsnCut::AliRsnCut(const char *name, RSNTARGET target) :
22    AliRsnTarget(name, target),
23    fMinI(0),
24    fMaxI(0),
25    fMinD(0.),
26    fMaxD(0.),
27    fCutValueI(0),
28    fCutValueD(0.0),
29    fCutResult(kTRUE)
30 {
31 //
32 // Default constructor.
33 //
34 }
35
36 //______________________________________________________________________________
37 AliRsnCut::AliRsnCut
38 (const char *name, RSNTARGET target, Int_t imin, Int_t imax, Double_t dmin, Double_t dmax) :
39    AliRsnTarget(name, target),
40    fMinI(imin),
41    fMaxI(imax),
42    fMinD(dmin),
43    fMaxD(dmax),
44    fCutValueI(0),
45    fCutValueD(0.0),
46    fCutResult(kTRUE)
47 {
48 //
49 // Constructor with arguments.
50 // This is provided to allow a quick setting of all data members.
51 //
52 }
53
54 //______________________________________________________________________________
55 AliRsnCut::AliRsnCut
56 (const char *name, RSNTARGET target, Double_t dmin, Double_t dmax, Int_t imin, Int_t imax) :
57    AliRsnTarget(name, target),
58    fMinI(imin),
59    fMaxI(imax),
60    fMinD(dmin),
61    fMaxD(dmax),
62    fCutValueI(0),
63    fCutValueD(0.0),
64    fCutResult(kTRUE)
65 {
66 //
67 // Constructor with arguments.
68 // This is provided to allow a quick setting of all data members.
69 //
70 }
71
72 //______________________________________________________________________________
73 AliRsnCut::AliRsnCut(const AliRsnCut& copy) :
74    AliRsnTarget(copy),
75    fMinI(copy.fMinI),
76    fMaxI(copy.fMaxI),
77    fMinD(copy.fMinD),
78    fMaxD(copy.fMaxD),
79    fCutValueI(copy.fCutValueI),
80    fCutValueD(copy.fCutValueD),
81    fCutResult(copy.fCutResult)
82 {
83 //
84 // Copy constructor.
85 // Don't duplicate memory occupancy for pointer
86 //
87 }
88
89 //______________________________________________________________________________
90 AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy)
91 {
92 //
93 // Assignment operator.
94 // Don't duplicate memory occupancy for pointer
95 //
96
97    AliRsnTarget::operator=(copy);
98
99    fMinI      = copy.fMinI;
100    fMaxI      = copy.fMaxI;
101    fMinD      = copy.fMinD;
102    fMaxD      = copy.fMaxD;
103    fCutValueI = copy.fCutValueI;
104    fCutValueD = copy.fCutValueD;
105    fCutResult = copy.fCutResult;
106
107    return (*this);
108 }
109
110 //______________________________________________________________________________
111 Bool_t AliRsnCut::IsSelected(TObject* /*object*/)
112 {
113 //
114 // Virtual cut-checking method.
115 // In this implementation, it does nothing, and all classes
116 // inheriting from this, should provide a proper implementation
117 // which must return kTRUE if the cut is passed, and kFALSE otherwise.
118 //
119
120    AliWarning("This virtual function must be implemented properly");
121    return kTRUE;
122 }
123
124 //______________________________________________________________________________
125 Bool_t AliRsnCut::OkValueI()
126 {
127 //
128 // This method is used to compare a value with a reference.
129 // In the case of integers, the equality must be exact.
130 //
131
132    // eval result
133    fCutResult = (fCutValueI == fMinI);
134
135    // print debug message
136    AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ========================================================");
137    AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
138    AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
139    AliDebug(AliLog::kDebug + 2, Form("Cut value    : %d", fMinI));
140    AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
141    AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ====================================================");
142
143    return fCutResult;
144 }
145
146 //______________________________________________________________________________
147 Bool_t AliRsnCut::OkValueD()
148 {
149 //
150 // This method is used to compare a value with a reference.
151 // In the case of doubles, the equality consists in being very close.
152 //
153
154    // eval result
155    fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6);
156
157    // print debug message
158    AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG =======================================================");
159    AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
160    AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
161    AliDebug(AliLog::kDebug + 2, Form("Cut value    : %f", fMinD));
162    AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
163    AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ===================================================");
164
165    return fCutResult;
166 }
167
168 //______________________________________________________________________________
169 Bool_t AliRsnCut::OkRangeI()
170 {
171 //
172 // This method is used to compare a value with an integer range.
173 //
174
175    // eval result
176    fCutResult = ((fCutValueI >= fMinI) && (fCutValueI <= fMaxI));
177
178    // print debug message
179    AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ========================================================");
180    AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
181    AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
182    AliDebug(AliLog::kDebug + 2, Form("Cut range    : %d , %d", fMinI, fMaxI));
183    AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
184    AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ====================================================");
185
186    return fCutResult;
187 }
188
189 //______________________________________________________________________________
190 Bool_t AliRsnCut::OkRangeD()
191 {
192 //
193 // This method is used to compare a value with a double-float range.
194 //
195
196    // eval result
197    fCutResult = ((fCutValueD >= fMinD) && (fCutValueD <= fMaxD));
198
199    // print debug message
200    AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ========================================================");
201    AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
202    AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
203    AliDebug(AliLog::kDebug + 2, Form("Cut range    : %f , %f", fMinD, fMaxD));
204    AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
205    AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ====================================================");
206
207    return fCutResult;
208 }
209
210 //______________________________________________________________________________
211 void AliRsnCut::Print(Option_t*) const
212 {
213 //
214 // Override TObject::Print() method,
215 // and print some useful info about the cut general parameters.
216 //
217
218    AliInfo("=== CUT DETAILS ====================================");
219    AliInfo(Form("Cut name     : [%s]", GetName()));
220    AliInfo(Form("Cut target   : [%s]", GetTargetTypeName()));
221    AliInfo(Form("Cut edges [D]: [%f - %f]", fMinD, fMaxD));
222    AliInfo(Form("Cut edges [I]: [%d - %d]", fMinI, fMaxI));
223    AliInfo("====================================================");
224 }