IO fixes for the new root release. Deleting the list posted at the task output now...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCut.cxx
CommitLineData
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()]
21// - a value equal to a given reference [--> IsEqual() ]
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
41const Double_t AliRsnCut::fgkDSmallNumber = 1e-100;
42const Double_t AliRsnCut::fgkDBigNumber = 1e10;
43const Int_t AliRsnCut::fgkIBigNumber = 32767;
44
45ClassImp (AliRsnCut)
46
47//________________________________________________________________________________________________________________
48AliRsnCut::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//________________________________________________________________________________________________________________
65AliRsnCut::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//________________________________________________________________________________________________________________
82AliRsnCut::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//________________________________________________________________________________________________________________
99AliRsnCut::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//________________________________________________________________________________________________________________
116AliRsnCut::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//________________________________________________________________________________________________________________
133AliRsnCut::~ AliRsnCut()
134{
135//
136// Destructor.
137// Does absolutely nothing.
138//
139}
140
141//________________________________________________________________________________________________________________
142Bool_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//________________________________________________________________________________________________________________
153Bool_t AliRsnCut::IsEqual (const Int_t &theValue)
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//________________________________________________________________________________________________________________
163Bool_t AliRsnCut::IsEqual (const UInt_t &theValue)
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//________________________________________________________________________________________________________________
173Bool_t AliRsnCut::IsEqual (const Double_t &theValue)
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//________________________________________________________________________________________________________________
185void 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//________________________________________________________________________________________________________________
196void 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//________________________________________________________________________________________________________________
207void 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//________________________________________________________________________________________________________________
218Bool_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:
259 return IsEqual((Int_t)daughter->PIDType());
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 */
272 }
273
274 return kTRUE;
275}
276
277//________________________________________________________________________________________________________________
278Bool_t AliRsnCut::IsSelected(ECutSetType type, AliRsnPairParticle * pair)
279{
280 AliDebug (AliLog::kDebug, "<-");
281
282 // check type
283 if (type != kPair) {
284 AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnPairParticle)", type, kPair, pair->ClassName()));
285 return kTRUE;
286 }
287
288 switch (fRsnCutType) {
289 case kMomentum:
290 return IsBetween (pair->GetP());
291 case kTransMomentum:
292 return IsBetween (pair->GetPt());
293 /*
294 case kEta:
295 return IsBetween (daughter->Eta());
296 */
297 case kMomentumMC:
298 return IsBetween (pair->GetPMC());
299 case kTransMomentumMC:
300 return IsBetween (pair->GetPtMC());
301 case kRestMomentum:
302 return CheckRestMomentum(pair);
303 case kIsPdgEqual:
304 return pair->IsPDGEqual();
305 case kIsLabelEqual:
306 return pair->IsLabelEqual();
307 case kIsTruePair:
308 return pair->IsTruePair(fIMin);
309 }
310
311 return kTRUE;
312}
313
314//________________________________________________________________________________________________________________
315void AliRsnCut::PrintAllValues()
316{
317 AliInfo (Form ("fRsnCutType=%d fRsnCutVarType=%d",fRsnCutType,fRsnCutVarType));
318 AliInfo (Form ("fDMin=%.2e fDMax=%.2e",fDMin,fDMax));
319 AliInfo (Form ("fIMin=%d fIMax=%d",fIMin,fIMax));
320 AliInfo (Form ("fUIMin=%d fUIMax=%d",fUIMin,fUIMax));
321}
322
323//________________________________________________________________________________________________________________
324Bool_t AliRsnCut::CheckRestMomentum(AliRsnPairParticle *pair)
325{
326//
327// Check the cut on daughter momenta in rest reference frame of mother
328//
329
330 Double_t beta = pair->GetP() / pair->GetMass();
331 Double_t gamma = 1. / TMath::Sqrt(1. - beta*beta);
332
333 Double_t p1labP = 0.0, p1labT, p1restP, p1restTot;
334 p1labP += pair->GetDaughter(0)->Px() * pair->GetP(0);
335 p1labP += pair->GetDaughter(0)->Py() * pair->GetP(1);
336 p1labP += pair->GetDaughter(0)->Pz() * pair->GetP(2);
337 p1labP /= pair->GetP();
338
339 p1labT = TMath::Sqrt(pair->GetDaughter(0)->P2() - p1labP*p1labP);
340
341 p1restP = gamma*p1labP - beta*gamma*pair->GetDaughter(0)->E();
342
343 p1restTot = TMath::Sqrt(p1restP*p1restP + p1labT*p1labT);
344
345 return IsBetween(p1restTot);
346}
347
348
349