]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCut.cxx
Update TPCCEda to write output file in parts (to avoid too big files produced in...
[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 "AliRsnDaughter.h"
17 #include "AliRsnMother.h"
18 #include "AliRsnEvent.h"
19
20 #include "AliRsnCut.h"
21
22 ClassImp(AliRsnCut)
23
24 //______________________________________________________________________________
25 AliRsnCut::AliRsnCut(const char *name, RSNTARGET target) :
26   AliRsnTarget(name, target),
27   fMinI(0),
28   fMaxI(0),
29   fMinD(0.),
30   fMaxD(0.),
31   fCutValueI(0),
32   fCutValueD(0.0),
33   fCutResult(kTRUE),
34   fEvent(0x0)
35 {
36 //
37 // Default constructor.
38 //
39 }
40
41 //______________________________________________________________________________
42 AliRsnCut::AliRsnCut
43 (const char *name, RSNTARGET target, Int_t imin, Int_t imax, Double_t dmin, Double_t dmax) :
44   AliRsnTarget(name, target),
45   fMinI(imin),
46   fMaxI(imax),
47   fMinD(dmin),
48   fMaxD(dmax),
49   fCutValueI(0),
50   fCutValueD(0.0),
51   fCutResult(kTRUE),
52   fEvent(0x0)
53 {
54 //
55 // Constructor with arguments.
56 // This is provided to allow a quick setting of all data members.
57 //
58 }
59
60 //______________________________________________________________________________
61 AliRsnCut::AliRsnCut
62 (const char *name, RSNTARGET target, Double_t dmin, Double_t dmax, Int_t imin, Int_t imax) :
63   AliRsnTarget(name, target),
64   fMinI(imin),
65   fMaxI(imax),
66   fMinD(dmin),
67   fMaxD(dmax),
68   fCutValueI(0),
69   fCutValueD(0.0),
70   fCutResult(kTRUE),
71   fEvent(0x0)
72 {
73 //
74 // Constructor with arguments.
75 // This is provided to allow a quick setting of all data members.
76 //
77 }
78
79 //______________________________________________________________________________
80 AliRsnCut::AliRsnCut(const AliRsnCut& copy) :
81   AliRsnTarget(copy),
82   fMinI(copy.fMinI),
83   fMaxI(copy.fMaxI),
84   fMinD(copy.fMinD),
85   fMaxD(copy.fMaxD),
86   fCutValueI(copy.fCutValueI),
87   fCutValueD(copy.fCutValueD),
88   fCutResult(copy.fCutResult),
89   fEvent(copy.fEvent)
90 {
91 //
92 // Copy constructor.
93 // Don't duplicate memory occupancy for pointer
94 //
95 }
96
97 //______________________________________________________________________________
98 AliRsnCut& AliRsnCut::operator=(const AliRsnCut& copy)
99 {
100 //
101 // Assignment operator.
102 // Don't duplicate memory occupancy for pointer
103 //
104
105   AliRsnTarget::operator=(copy);
106   
107   fMinI      = copy.fMinI;
108   fMaxI      = copy.fMaxI;
109   fMinD      = copy.fMinD;
110   fMaxD      = copy.fMaxD;
111   fCutValueI = copy.fCutValueI;
112   fCutValueD = copy.fCutValueD;
113   fCutResult = copy.fCutResult;
114   fEvent     = copy.fEvent;
115
116   return (*this);
117 }
118
119 //______________________________________________________________________________
120 Bool_t AliRsnCut::IsSelected(TObject* /*object*/)
121 {
122 //
123 // Virtual cut-checking method.
124 // In this implementation, it does nothing, and all classes
125 // inheriting from this, should provide a proper implementation
126 // which must return kTRUE if the cut is passed, and kFALSE otherwise.
127 //
128
129   AliWarning("This virtual function must be implemented properly");
130   return kTRUE;
131 }
132
133 //______________________________________________________________________________
134 Bool_t AliRsnCut::OkValueI()
135 {
136 //
137 // This method is used when the cut consists in comparing the cut value
138 // with a reference integer value to which it must be equal.
139 //
140
141   // eval result
142   fCutResult = (fCutValueI == fMinI);
143   
144   // print debug message
145   AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
146   AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
147   AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
148   AliDebug(AliLog::kDebug + 2, Form("Cut value    : %d", fMinI));
149   AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
150   AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
151   
152   return fCutResult;
153 }
154
155 //______________________________________________________________________________
156 Bool_t AliRsnCut::OkValueD()
157 {
158 //
159 // This method is used when the cut consists in comparing the cut value
160 // with a reference double value to which it must be equal (or at least, almost).
161 //
162
163   // eval result
164   fCutResult = (TMath::Abs(fCutValueD - fMinD) < 1E-6);
165   
166   // print debug message
167   AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
168   AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
169   AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
170   AliDebug(AliLog::kDebug + 2, Form("Cut value    : %f", fMinD));
171   AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
172   AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
173   
174   return fCutResult;
175 }
176
177 //______________________________________________________________________________
178 Bool_t AliRsnCut::OkRangeI()
179 {
180 //
181 // This method is used when the cut consists in an allowed range
182 // where the cut value must be included to pass the cut.
183 // Then, the cut result is kTRUE if the cut value is inside this range.
184 //
185
186   // eval result
187   fCutResult = ((fCutValueI >= fMinI) && (fCutValueI < fMaxI));
188   
189   // print debug message
190   AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
191   AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
192   AliDebug(AliLog::kDebug + 2, Form("Checked value: %d", fCutValueI));
193   AliDebug(AliLog::kDebug + 2, Form("Cut range    : %d , %d", fMinI, fMaxI));
194   AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
195   AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
196   
197   return fCutResult;
198 }
199
200 //______________________________________________________________________________
201 Bool_t AliRsnCut::OkRangeD()
202 {
203 //
204 // This method is used when the cut consists in an allowed range
205 // where the cut value must be included to pass the cut.
206 // Then, the cut result is kTRUE if the cut value is inside this range.
207 //
208
209   // eval result
210   fCutResult = ((fCutValueD >= fMinD) && (fCutValueD < fMaxD));
211    
212   // print debug message
213   AliDebug(AliLog::kDebug + 2, "=== CUT DEBUG ====================================");
214   AliDebug(AliLog::kDebug + 2, Form("Cut name     : %s", GetName()));
215   AliDebug(AliLog::kDebug + 2, Form("Checked value: %f", fCutValueD));
216   AliDebug(AliLog::kDebug + 2, Form("Cut range    : %f , %f", fMinD, fMaxD));
217   AliDebug(AliLog::kDebug + 2, Form("Cut result   : %s", (fCutResult ? "PASSED" : "NOT PASSED")));
218   AliDebug(AliLog::kDebug + 2, "=== END CUT DEBUG ================================");
219
220   return fCutResult;
221 }
222
223 //______________________________________________________________________________
224 void AliRsnCut::Print(Option_t*) const
225 {
226 //
227 // Override TObject::Print() method,
228 // and print some useful info about the cut general parameters.
229 //
230
231   AliInfo("=== CUT DETAILS ====================================");
232   AliInfo(Form("Cut name     : [%s]", GetName()));
233   AliInfo(Form("Cut target   : [%s]", GetTargetTypeName()));
234   AliInfo(Form("Cut edges [D]: [%f - %f]", fMinD, fMaxD));
235   AliInfo(Form("Cut edges [I]: [%d - %d]", fMinI, fMaxI));
236   AliInfo("====================================================");
237 }
238
239 //______________________________________________________________________________
240 void AliRsnCut::SetEvent(AliRsnEvent *event)
241 {
242 //
243 // Sets the reference event.
244 // When this requires some additional operation, this function
245 // should be overloaded by the specific cut implementation.
246 // For an example, see AliRsnCutESD2010 class.
247 //
248
249   fEvent = event;
250 }