]>
Commit | Line | Data |
---|---|---|
06351446 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | //========================================================================= | |
17 | // Class AliRsnCut | |
18 | // | |
19 | // General implementation of a single cut strategy, which can be: | |
20 | // - a value contained in a given interval [--> IsBetween()] | |
8ecf98c4 | 21 | // - a value equal to a given reference [--> MatchesValue() ] |
06351446 | 22 | // In all cases, the reference value(s) is (are) given as data members |
23 | // and each kind of cut requires a given value type (Int, UInt, Double), | |
24 | // but the cut check procedure is then automatized and chosen thanks to | |
25 | // an enumeration of the implemented cut types. | |
26 | // At the end, the user (or any other point which uses this object) has | |
27 | // to use the method IsSelected() to check if this cut has been passed. | |
28 | // | |
29 | // authors: Martin Vala (martin.vala@cern.ch) | |
30 | // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) | |
31 | //========================================================================= | |
32 | ||
33 | #include "AliLog.h" | |
34 | ||
35 | #include "AliRsnDaughter.h" | |
36 | #include "AliRsnMCInfo.h" | |
37 | #include "AliRsnPairParticle.h" | |
38 | #include "AliRsnPairDef.h" | |
39 | #include "AliRsnCut.h" | |
40 | ||
41 | const Double_t AliRsnCut::fgkDSmallNumber = 1e-100; | |
42 | const Double_t AliRsnCut::fgkDBigNumber = 1e10; | |
43 | const Int_t AliRsnCut::fgkIBigNumber = 32767; | |
44 | ||
45 | ClassImp (AliRsnCut) | |
46 | ||
47 | //________________________________________________________________________________________________________________ | |
48 | AliRsnCut::AliRsnCut() : | |
49 | TNamed(), | |
50 | fDMin(-fgkDBigNumber), | |
51 | fDMax( fgkDBigNumber), | |
52 | fIMin(-fgkIBigNumber), | |
53 | fIMax( fgkIBigNumber), | |
54 | fUIMin(0), | |
55 | fUIMax(2 * (UInt_t)fgkIBigNumber), | |
56 | fRsnCutType (kLastCutType), | |
57 | fRsnCutVarType (kDouble_t) | |
58 | { | |
59 | // | |
60 | // Constructor | |
61 | // | |
62 | } | |
63 | ||
64 | //________________________________________________________________________________________________________________ | |
65 | AliRsnCut::AliRsnCut (const char *name, const char *title, ERsnCutType type) : | |
66 | TNamed (name,title), | |
67 | fDMin(-fgkDBigNumber), | |
68 | fDMax( fgkDBigNumber), | |
69 | fIMin(-fgkIBigNumber), | |
70 | fIMax( fgkIBigNumber), | |
71 | fUIMin(0), | |
72 | fUIMax(2 * (UInt_t)fgkIBigNumber), | |
73 | fRsnCutType (type), | |
74 | fRsnCutVarType (kDouble_t) | |
75 | { | |
76 | // | |
77 | // Constructor with arguments but not limits | |
78 | // | |
79 | } | |
80 | ||
81 | //________________________________________________________________________________________________________________ | |
82 | AliRsnCut::AliRsnCut (const char *name, const char *title, ERsnCutType type, Double_t min, Double_t max) : | |
83 | TNamed (name,title), | |
84 | fDMin(min), | |
85 | fDMax(max), | |
86 | fIMin(-fgkIBigNumber), | |
87 | fIMax( fgkIBigNumber), | |
88 | fUIMin(0), | |
89 | fUIMax(2 * (UInt_t)fgkIBigNumber), | |
90 | fRsnCutType (type), | |
91 | fRsnCutVarType (kDouble_t) | |
92 | { | |
93 | // | |
94 | // Constructor with arguments and limits | |
95 | // | |
96 | } | |
97 | ||
98 | //________________________________________________________________________________________________________________ | |
99 | AliRsnCut::AliRsnCut (const char * name, const char * title, ERsnCutType type, Int_t min, Int_t max) : | |
100 | TNamed (name,title), | |
101 | fDMin(-fgkDBigNumber), | |
102 | fDMax( fgkDBigNumber), | |
103 | fIMin(min), | |
104 | fIMax(max), | |
105 | fUIMin(0), | |
106 | fUIMax(2 * (UInt_t)fgkIBigNumber), | |
107 | fRsnCutType (type), | |
108 | fRsnCutVarType (kInt_t) | |
109 | { | |
110 | // | |
111 | // Constructor with arguments and limits | |
112 | // | |
113 | } | |
114 | ||
115 | //________________________________________________________________________________________________________________ | |
116 | AliRsnCut::AliRsnCut (const char * name, const char * title, ERsnCutType type, UInt_t min, UInt_t max) : | |
117 | TNamed (name,title), | |
118 | fDMin(-fgkDBigNumber), | |
119 | fDMax( fgkDBigNumber), | |
120 | fIMin(-fgkIBigNumber), | |
121 | fIMax( fgkIBigNumber), | |
122 | fUIMin(min), | |
123 | fUIMax(max), | |
124 | fRsnCutType (type), | |
125 | fRsnCutVarType (kUInt_t) | |
126 | { | |
127 | // | |
128 | // Constructor with arguments and limits | |
129 | // | |
130 | } | |
131 | ||
132 | //________________________________________________________________________________________________________________ | |
133 | AliRsnCut::~ AliRsnCut() | |
134 | { | |
135 | // | |
136 | // Destructor. | |
137 | // Does absolutely nothing. | |
138 | // | |
139 | } | |
140 | ||
141 | //________________________________________________________________________________________________________________ | |
142 | Bool_t AliRsnCut::IsBetween (const Double_t & theValue) | |
143 | { | |
144 | // | |
145 | // Interval check. | |
146 | // Question: "Is the argument included between fDMin and fDMax?" | |
147 | // (not implemented for integer values because usually it is not used with them) | |
148 | // | |
149 | return ((theValue >= fDMin) && (theValue <= fDMax)); | |
150 | } | |
151 | ||
152 | //________________________________________________________________________________________________________________ | |
8ecf98c4 | 153 | Bool_t AliRsnCut::MatchesValue (const Int_t &theValue) |
06351446 | 154 | { |
155 | // | |
156 | // Reference check. | |
157 | // Question: "Is the argument equal to fIMin?" (fIMax is assumed never used) | |
158 | // | |
159 | return (theValue == fIMin); | |
160 | } | |
161 | ||
162 | //________________________________________________________________________________________________________________ | |
8ecf98c4 | 163 | Bool_t AliRsnCut::MatchesValue (const UInt_t &theValue) |
06351446 | 164 | { |
165 | // | |
166 | // Reference check. | |
167 | // Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used) | |
168 | // | |
169 | return (theValue == fUIMin); | |
170 | } | |
171 | ||
172 | //________________________________________________________________________________________________________________ | |
8ecf98c4 | 173 | Bool_t AliRsnCut::MatchesValue (const Double_t &theValue) |
06351446 | 174 | { |
175 | // | |
176 | // Reference check. | |
177 | // Question: "Is the argument reasonably close to fDMin?" (fDMax is assumed never used) | |
178 | // Here, "reasonably close" means that the difference is smaller than the | |
179 | // 'fgkSmallNumber' global static data member of this class | |
180 | // | |
181 | return (TMath::Abs (theValue - fDMin) < fgkDSmallNumber); | |
182 | } | |
183 | ||
184 | //________________________________________________________________________________________________________________ | |
185 | void AliRsnCut::SetCutValues (ERsnCutType type, const Double_t & theValue, const Double_t & theValue2) | |
186 | { | |
187 | // | |
188 | // (Re)assignment of cut values | |
189 | // | |
190 | fRsnCutType = type; | |
191 | fDMin = theValue; | |
192 | fDMax = theValue2; | |
193 | } | |
194 | ||
195 | //________________________________________________________________________________________________________________ | |
196 | void AliRsnCut::SetCutValues (ERsnCutType type, const Int_t& theValue, const Int_t& theValue2) | |
197 | { | |
198 | // | |
199 | // (Re)assignment of cut values | |
200 | // | |
201 | fRsnCutType = type; | |
202 | fIMin = theValue; | |
203 | fIMax = theValue2; | |
204 | } | |
205 | ||
206 | //________________________________________________________________________________________________________________ | |
207 | void AliRsnCut::SetCutValues (ERsnCutType type, const UInt_t& theValue, const UInt_t& theValue2) | |
208 | { | |
209 | // | |
210 | // (Re)assignment of cut values | |
211 | // | |
212 | fRsnCutType = type; | |
213 | fUIMin = theValue; | |
214 | fUIMax = theValue2; | |
215 | } | |
216 | ||
217 | //________________________________________________________________________________________________________________ | |
218 | Bool_t AliRsnCut::IsSelected(ECutSetType type, AliRsnDaughter *daughter) | |
219 | { | |
220 | // | |
221 | // Core of the whole class. | |
222 | // According to the kind of cut selected in the enumeration, | |
223 | // checks the cut taking the right values from the argument. | |
224 | // Depending on the second argument type, only some cuts are checked | |
225 | // (the ones for that type of object), otherwise kTRUE is returned in order | |
226 | // not to act as a cleaning factor for an AND with other cuts. | |
227 | // | |
228 | AliDebug (AliLog::kDebug, "<-"); | |
229 | AliRsnMCInfo *mcinfo = daughter->GetMCInfo(); | |
230 | ||
231 | // check type | |
232 | if (type != kParticle) { | |
233 | AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnDaughter)", type, kParticle, daughter->ClassName())); | |
234 | return kTRUE; | |
235 | } | |
236 | ||
237 | switch (fRsnCutType) { | |
238 | case kMomentum: | |
239 | return IsBetween (daughter->P()); | |
240 | case kTransMomentum: | |
241 | return IsBetween (daughter->Pt()); | |
242 | case kEta: | |
243 | return IsBetween (daughter->Eta()); | |
244 | case kRadialImpactParam: | |
245 | return IsBetween (daughter->Vt()); | |
246 | case kMomentumMC: | |
247 | if (mcinfo) return IsBetween (mcinfo->P()); | |
248 | else return kTRUE; | |
249 | case kTransMomentumMC: | |
250 | if (mcinfo) return IsBetween (mcinfo->P()); | |
251 | else return kTRUE; | |
252 | case kStatus: | |
253 | return daughter->CheckFlag(fUIMin); | |
254 | case kChargePos: | |
255 | return (daughter->Charge() > 0); | |
256 | case kChargeNeg: | |
257 | return (daughter->Charge() < 0); | |
258 | case kPIDType: | |
8ecf98c4 | 259 | return MatchesValue((Int_t)daughter->PIDType()); |
06351446 | 260 | /* |
261 | case kEtaMC: | |
262 | if (mcinfo) return IsBetween (mcinfo->Eta()); | |
263 | else return kTRUE; | |
264 | case kMcVt: | |
265 | if (mcinfo) return IsBetween (mcinfo->Vt()); | |
266 | else return kTRUE; | |
267 | case kEsdNSigma: | |
268 | return IsBetween (daughter->GetNSigma()); | |
269 | case kEsdNSigmaCalculate: | |
270 | return IsBetween (daughter->GetESDInfo()->GetNSigmaCalculate()); | |
271 | */ | |
8ecf98c4 | 272 | default: |
273 | AliWarning("Requested a cut which cannot be applied to a single track"); | |
274 | return kTRUE; | |
06351446 | 275 | } |
276 | ||
277 | return kTRUE; | |
278 | } | |
279 | ||
280 | //________________________________________________________________________________________________________________ | |
281 | Bool_t AliRsnCut::IsSelected(ECutSetType type, AliRsnPairParticle * pair) | |
282 | { | |
283 | AliDebug (AliLog::kDebug, "<-"); | |
284 | ||
285 | // check type | |
286 | if (type != kPair) { | |
287 | AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnPairParticle)", type, kPair, pair->ClassName())); | |
288 | return kTRUE; | |
289 | } | |
290 | ||
291 | switch (fRsnCutType) { | |
292 | case kMomentum: | |
293 | return IsBetween (pair->GetP()); | |
294 | case kTransMomentum: | |
295 | return IsBetween (pair->GetPt()); | |
296 | /* | |
297 | case kEta: | |
298 | return IsBetween (daughter->Eta()); | |
299 | */ | |
300 | case kMomentumMC: | |
301 | return IsBetween (pair->GetPMC()); | |
302 | case kTransMomentumMC: | |
303 | return IsBetween (pair->GetPtMC()); | |
304 | case kRestMomentum: | |
305 | return CheckRestMomentum(pair); | |
306 | case kIsPdgEqual: | |
307 | return pair->IsPDGEqual(); | |
308 | case kIsLabelEqual: | |
309 | return pair->IsLabelEqual(); | |
310 | case kIsTruePair: | |
311 | return pair->IsTruePair(fIMin); | |
8ecf98c4 | 312 | default: |
313 | AliWarning("Requested a cut which cannot be applied to a pair"); | |
314 | return kTRUE; | |
06351446 | 315 | } |
316 | ||
317 | return kTRUE; | |
318 | } | |
319 | ||
320 | //________________________________________________________________________________________________________________ | |
321 | void AliRsnCut::PrintAllValues() | |
322 | { | |
323 | AliInfo (Form ("fRsnCutType=%d fRsnCutVarType=%d",fRsnCutType,fRsnCutVarType)); | |
324 | AliInfo (Form ("fDMin=%.2e fDMax=%.2e",fDMin,fDMax)); | |
325 | AliInfo (Form ("fIMin=%d fIMax=%d",fIMin,fIMax)); | |
326 | AliInfo (Form ("fUIMin=%d fUIMax=%d",fUIMin,fUIMax)); | |
327 | } | |
328 | ||
329 | //________________________________________________________________________________________________________________ | |
330 | Bool_t AliRsnCut::CheckRestMomentum(AliRsnPairParticle *pair) | |
331 | { | |
332 | // | |
333 | // Check the cut on daughter momenta in rest reference frame of mother | |
334 | // | |
335 | ||
336 | Double_t beta = pair->GetP() / pair->GetMass(); | |
337 | Double_t gamma = 1. / TMath::Sqrt(1. - beta*beta); | |
338 | ||
339 | Double_t p1labP = 0.0, p1labT, p1restP, p1restTot; | |
340 | p1labP += pair->GetDaughter(0)->Px() * pair->GetP(0); | |
341 | p1labP += pair->GetDaughter(0)->Py() * pair->GetP(1); | |
342 | p1labP += pair->GetDaughter(0)->Pz() * pair->GetP(2); | |
343 | p1labP /= pair->GetP(); | |
344 | ||
345 | p1labT = TMath::Sqrt(pair->GetDaughter(0)->P2() - p1labP*p1labP); | |
346 | ||
347 | p1restP = gamma*p1labP - beta*gamma*pair->GetDaughter(0)->E(); | |
348 | ||
349 | p1restTot = TMath::Sqrt(p1restP*p1restP + p1labT*p1labT); | |
350 | ||
351 | return IsBetween(p1restTot); | |
352 | } | |
353 | ||
354 | ||
355 |