1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //=========================================================================
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 [--> MatchesValue() ]
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.
29 // authors: Martin Vala (martin.vala@cern.ch)
30 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
31 //=========================================================================
35 #include "AliRsnDaughter.h"
36 #include "AliRsnMCInfo.h"
37 #include "AliRsnPairParticle.h"
38 #include "AliRsnPairDef.h"
39 #include "AliRsnCut.h"
41 const Double_t AliRsnCut::fgkDSmallNumber = 1e-100;
42 const Double_t AliRsnCut::fgkDBigNumber = 1e10;
43 const Int_t AliRsnCut::fgkIBigNumber = 32767;
47 //________________________________________________________________________________________________________________
48 AliRsnCut::AliRsnCut() :
50 fDMin(-fgkDBigNumber),
51 fDMax( fgkDBigNumber),
52 fIMin(-fgkIBigNumber),
53 fIMax( fgkIBigNumber),
55 fUIMax(2 * (UInt_t)fgkIBigNumber),
56 fRsnCutType (kLastCutType),
57 fRsnCutVarType (kDouble_t)
64 //________________________________________________________________________________________________________________
65 AliRsnCut::AliRsnCut (const char *name, const char *title, ERsnCutType type) :
67 fDMin(-fgkDBigNumber),
68 fDMax( fgkDBigNumber),
69 fIMin(-fgkIBigNumber),
70 fIMax( fgkIBigNumber),
72 fUIMax(2 * (UInt_t)fgkIBigNumber),
74 fRsnCutVarType (kDouble_t)
77 // Constructor with arguments but not limits
81 //________________________________________________________________________________________________________________
82 AliRsnCut::AliRsnCut (const char *name, const char *title, ERsnCutType type, Double_t min, Double_t max) :
86 fIMin(-fgkIBigNumber),
87 fIMax( fgkIBigNumber),
89 fUIMax(2 * (UInt_t)fgkIBigNumber),
91 fRsnCutVarType (kDouble_t)
94 // Constructor with arguments and limits
98 //________________________________________________________________________________________________________________
99 AliRsnCut::AliRsnCut (const char * name, const char * title, ERsnCutType type, Int_t min, Int_t max) :
101 fDMin(-fgkDBigNumber),
102 fDMax( fgkDBigNumber),
106 fUIMax(2 * (UInt_t)fgkIBigNumber),
108 fRsnCutVarType (kInt_t)
111 // Constructor with arguments and limits
115 //________________________________________________________________________________________________________________
116 AliRsnCut::AliRsnCut (const char * name, const char * title, ERsnCutType type, UInt_t min, UInt_t max) :
118 fDMin(-fgkDBigNumber),
119 fDMax( fgkDBigNumber),
120 fIMin(-fgkIBigNumber),
121 fIMax( fgkIBigNumber),
125 fRsnCutVarType (kUInt_t)
128 // Constructor with arguments and limits
132 //________________________________________________________________________________________________________________
133 AliRsnCut::~ AliRsnCut()
137 // Does absolutely nothing.
141 //________________________________________________________________________________________________________________
142 Bool_t AliRsnCut::IsBetween (const Double_t & theValue)
146 // Question: "Is the argument included between fDMin and fDMax?"
147 // (not implemented for integer values because usually it is not used with them)
149 return ((theValue >= fDMin) && (theValue <= fDMax));
152 //________________________________________________________________________________________________________________
153 Bool_t AliRsnCut::MatchesValue (const Int_t &theValue)
157 // Question: "Is the argument equal to fIMin?" (fIMax is assumed never used)
159 return (theValue == fIMin);
162 //________________________________________________________________________________________________________________
163 Bool_t AliRsnCut::MatchesValue (const UInt_t &theValue)
167 // Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used)
169 return (theValue == fUIMin);
172 //________________________________________________________________________________________________________________
173 Bool_t AliRsnCut::MatchesValue (const Double_t &theValue)
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
181 return (TMath::Abs (theValue - fDMin) < fgkDSmallNumber);
184 //________________________________________________________________________________________________________________
185 void AliRsnCut::SetCutValues (ERsnCutType type, const Double_t & theValue, const Double_t & theValue2)
188 // (Re)assignment of cut values
195 //________________________________________________________________________________________________________________
196 void AliRsnCut::SetCutValues (ERsnCutType type, const Int_t& theValue, const Int_t& theValue2)
199 // (Re)assignment of cut values
206 //________________________________________________________________________________________________________________
207 void AliRsnCut::SetCutValues (ERsnCutType type, const UInt_t& theValue, const UInt_t& theValue2)
210 // (Re)assignment of cut values
217 //________________________________________________________________________________________________________________
218 Bool_t AliRsnCut::IsSelected(ECutSetType type, AliRsnDaughter *daughter)
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.
228 AliDebug (AliLog::kDebug, "<-");
229 AliRsnMCInfo *mcinfo = daughter->GetMCInfo();
232 if (type != kParticle) {
233 AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnDaughter)", type, kParticle, daughter->ClassName()));
237 switch (fRsnCutType) {
239 return IsBetween (daughter->P());
241 return IsBetween (daughter->Pt());
243 return IsBetween (daughter->Eta());
244 case kRadialImpactParam:
245 return IsBetween (daughter->Vt());
247 if (mcinfo) return IsBetween (mcinfo->P());
249 case kTransMomentumMC:
250 if (mcinfo) return IsBetween (mcinfo->P());
253 return daughter->CheckFlag(fUIMin);
255 return (daughter->Charge() > 0);
257 return (daughter->Charge() < 0);
259 return MatchesValue((Int_t)daughter->PIDType());
262 if (mcinfo) return IsBetween (mcinfo->Eta());
265 if (mcinfo) return IsBetween (mcinfo->Vt());
268 return IsBetween (daughter->GetNSigma());
269 case kEsdNSigmaCalculate:
270 return IsBetween (daughter->GetESDInfo()->GetNSigmaCalculate());
273 AliWarning("Requested a cut which cannot be applied to a single track");
280 //________________________________________________________________________________________________________________
281 Bool_t AliRsnCut::IsSelected(ECutSetType type, AliRsnPairParticle * pair)
283 AliDebug (AliLog::kDebug, "<-");
287 AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnPairParticle)", type, kPair, pair->ClassName()));
291 switch (fRsnCutType) {
293 return IsBetween (pair->GetP());
295 return IsBetween (pair->GetPt());
298 return IsBetween (daughter->Eta());
301 return IsBetween (pair->GetPMC());
302 case kTransMomentumMC:
303 return IsBetween (pair->GetPtMC());
305 return CheckRestMomentum(pair);
307 return pair->IsPDGEqual();
309 return pair->IsLabelEqual();
311 return pair->IsTruePair(fIMin);
313 AliWarning("Requested a cut which cannot be applied to a pair");
320 //________________________________________________________________________________________________________________
321 void AliRsnCut::PrintAllValues()
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));
329 //________________________________________________________________________________________________________________
330 Bool_t AliRsnCut::CheckRestMomentum(AliRsnPairParticle *pair)
333 // Check the cut on daughter momenta in rest reference frame of mother
336 Double_t beta = pair->GetP() / pair->GetMass();
337 Double_t gamma = 1. / TMath::Sqrt(1. - beta*beta);
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();
345 p1labT = TMath::Sqrt(pair->GetDaughter(0)->P2() - p1labP*p1labP);
347 p1restP = gamma*p1labP - beta*gamma*pair->GetDaughter(0)->E();
349 p1restTot = TMath::Sqrt(p1restP*p1restP + p1labT*p1labT);
351 return IsBetween(p1restTot);