4 // General implementation of a single cut strategy, which can be:
5 // - a value contained in a given interval [--> IsBetween() ]
6 // - a value equal to a given reference [--> MatchesValue()]
8 // In all cases, the reference value(s) is (are) given as data members
9 // and each kind of cut requires a given value type (Int, UInt, Double),
10 // but the cut check procedure is then automatized and chosen thanks to
11 // an enumeration of the implemented cut types.
12 // At the end, the user (or any other point which uses this object) has
13 // to use the method IsSelected() to check if this cut has been passed.
15 // authors: Martin Vala (martin.vala@cern.ch)
16 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
21 #include "AliRsnDaughter.h"
22 #include "AliRsnMCInfo.h"
23 #include "AliRsnPairParticle.h"
24 #include "AliRsnPairDef.h"
25 #include "AliRsnEvent.h"
26 #include "AliRsnCut.h"
28 const Double_t AliRsnCut::fgkDSmallNumber = 1e-100;
29 const Double_t AliRsnCut::fgkDBigNumber = 1e10;
30 const Int_t AliRsnCut::fgkIBigNumber = 32767;
34 //________________________________________________________________________________________________________________
35 AliRsnCut::AliRsnCut() :
37 fDMin(-fgkDBigNumber),
39 fIMin(-fgkIBigNumber),
42 fUIMax(2 * (UInt_t) fgkIBigNumber),
44 fULMax(2 * (ULong_t) fgkIBigNumber),
53 //________________________________________________________________________________________________________________
54 AliRsnCut::AliRsnCut(const char *name, const char *title, EType type) :
56 fDMin(-fgkDBigNumber),
58 fIMin(-fgkIBigNumber),
61 fUIMax(2 * (UInt_t) fgkIBigNumber),
63 fULMax(2 * (ULong_t) fgkIBigNumber),
68 // Constructor with arguments but not limits
72 //________________________________________________________________________________________________________________
73 AliRsnCut::AliRsnCut(const char *name, const char *title, EType type, Double_t min, Double_t max) :
77 fIMin(-fgkIBigNumber),
80 fUIMax(2 * (UInt_t) fgkIBigNumber),
87 // Constructor with arguments and limits
91 //________________________________________________________________________________________________________________
92 AliRsnCut::AliRsnCut(const char * name, const char * title, EType type, Int_t min, Int_t max) :
94 fDMin(-fgkDBigNumber),
99 fUIMax(2 * (UInt_t) fgkIBigNumber),
106 // Constructor with arguments and limits
110 //________________________________________________________________________________________________________________
111 AliRsnCut::AliRsnCut(const char * name, const char * title, EType type, UInt_t min, UInt_t max) :
113 fDMin(-fgkDBigNumber),
114 fDMax(fgkDBigNumber),
115 fIMin(-fgkIBigNumber),
116 fIMax(fgkIBigNumber),
125 // Constructor with arguments and limits
129 //________________________________________________________________________________________________________________
130 AliRsnCut::AliRsnCut(const char * name, const char * title, EType type, ULong_t min, ULong_t max) :
132 fDMin(-fgkDBigNumber),
133 fDMax(fgkDBigNumber),
134 fIMin(-fgkIBigNumber),
135 fIMax(fgkIBigNumber),
144 // Constructor with arguments and limits
148 //________________________________________________________________________________________________________________
149 AliRsnCut::~AliRsnCut()
153 // Does absolutely nothing.
157 //________________________________________________________________________________________________________________
158 Bool_t AliRsnCut::IsBetween(const Double_t &theValue)
162 // Question: "Is the argument included between fDMin and fDMax?"
163 // (not implemented for integer values because usually it is not used with them)
165 return ((theValue >= fDMin) && (theValue <= fDMax));
168 //________________________________________________________________________________________________________________
169 Bool_t AliRsnCut::IsBetween(const Int_t &theValue)
173 // Question: "Is the argument included between fDMin and fDMax?"
174 // (not implemented for integer values because usually it is not used with them)
176 return ((theValue >= fIMin) && (theValue <= fIMax));
179 //________________________________________________________________________________________________________________
180 Bool_t AliRsnCut::MatchesValue(const Int_t &theValue)
184 // Question: "Is the argument equal to fIMin?" (fIMax is assumed never used)
186 return (theValue == fIMin);
189 //________________________________________________________________________________________________________________
190 Bool_t AliRsnCut::MatchesValue(const UInt_t &theValue)
194 // Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used)
196 return (theValue == fUIMin);
199 //________________________________________________________________________________________________________________
200 Bool_t AliRsnCut::MatchesValue(const ULong_t &theValue)
204 // Question: "Is the argument equal to fUIMin?" (fUIMax is assumed never used)
206 return (theValue == fULMin);
209 //________________________________________________________________________________________________________________
210 Bool_t AliRsnCut::MatchesValue(const Double_t &theValue)
214 // Question: "Is the argument reasonably close to fDMin?" (fDMax is assumed never used)
215 // Here, "reasonably close" means that the difference is smaller than the
216 // 'fgkSmallNumber' global static data member of this class
218 return (TMath::Abs(theValue - fDMin) < fgkDSmallNumber);
221 //________________________________________________________________________________________________________________
222 void AliRsnCut::SetCutValues(EType type, const Double_t &theValue, const Double_t &theValue2)
225 // (Re)assignment of cut values
232 //________________________________________________________________________________________________________________
233 void AliRsnCut::SetCutValues(EType type, const Int_t &theValue, const Int_t &theValue2)
236 // (Re)assignment of cut values
243 //________________________________________________________________________________________________________________
244 void AliRsnCut::SetCutValues(EType type, const UInt_t &theValue, const UInt_t &theValue2)
247 // (Re)assignment of cut values
254 //________________________________________________________________________________________________________________
255 void AliRsnCut::SetCutValues(EType type, const ULong_t &theValue, const ULong_t &theValue2)
258 // (Re)assignment of cut values
265 //________________________________________________________________________________________________________________
266 Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnDaughter *daughter)
269 // Core of the whole class.
270 // According to the kind of cut selected in the enumeration,
271 // checks the cut taking the right values from the argument.
272 // Depending on the second argument type, only some cuts are checked
273 // (the ones for that type of object), otherwise kTRUE is returned in order
274 // not to act as a cleaning factor for an AND with other cuts.
276 AliDebug(AliLog::kDebug, "<-");
277 AliRsnMCInfo *mcinfo = daughter->GetMCInfo();
280 if (type != kParticle)
282 AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnDaughter)", type, kParticle, daughter->ClassName()));
287 AliRsnPID::EType pidType;
293 return IsBetween(daughter->P());
295 return IsBetween(daughter->Pt());
297 return IsBetween(daughter->Eta());
298 case kRadialImpactParam:
299 return IsBetween(daughter->Dr());
301 if (mcinfo) return IsBetween(mcinfo->P());
303 case kTransMomentumMC:
304 if (mcinfo) return IsBetween(mcinfo->P());
307 return daughter->CheckFlag(fUIMin);
309 return (daughter->Charge() > 0);
311 return (daughter->Charge() < 0);
314 pidType = daughter->PIDType(prob);
315 if (fType == kPIDType) return MatchesValue((Int_t) pidType);
316 if (fType == kPIDProb) return IsBetween(prob);
318 if (mcinfo) return IsBetween(mcinfo->Eta());
321 if (mcinfo) return (mcinfo->Mother() < 0);
324 return IsBetween(daughter->NSigmaToVertex());
326 case kEsdNSigmaCalculate:
327 return IsBetween (daughter->GetESDInfo()->GetNSigmaCalculate());
330 AliWarning("Requested a cut which cannot be applied to a single track");
337 //________________________________________________________________________________________________________________
338 Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnPairParticle * pair)
340 AliDebug(AliLog::kDebug, "<-");
345 AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnPairParticle)", type, kPair, pair->ClassName()));
352 return IsBetween(pair->GetP());
354 return IsBetween(pair->GetPt());
357 return IsBetween (daughter->Eta());
360 return IsBetween(pair->GetPMC());
361 case kTransMomentumMC:
362 return IsBetween(pair->GetPtMC());
364 return pair->IsLabelEqual();
366 return pair->IsTruePair(fIMin);
368 AliWarning("Requested a cut which cannot be applied to a pair");
375 //________________________________________________________________________________________________________________
376 Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnEvent * event)
378 AliDebug(AliLog::kDebug, "<-");
383 AliWarning(Form("Mismatch: type = %d (expected %d), class type = %s (expected AliRsnEvent)", type, kEvent, event->ClassName()));
390 return IsBetween((Int_t) event->GetMultiplicity());
392 AliWarning("Requested a cut which cannot be applied to an event");
399 //________________________________________________________________________________________________________________
400 Bool_t AliRsnCut::IsSelected(ETarget type, AliRsnEvent * ev1, AliRsnEvent * ev2)
402 AliDebug(AliLog::kDebug, "<-");
405 if (type != kMixEvent)
407 AliWarning(Form("Mismatch: type = %d (expected %d)", type, kMixEvent));
411 Double_t valueD, mult1, mult2;
416 case kMultiplicityDifference:
417 valueI = TMath::Abs(ev1->GetMultiplicity() - ev2->GetMultiplicity());
418 return IsBetween((Int_t)valueI);
419 case kMultiplicityRatio:
420 mult1 = (Double_t)ev1->GetMultiplicity();
421 mult2 = (Double_t)ev2->GetMultiplicity();
422 if (mult1 == 0.0 && mult2 == 0.0) return kTRUE;
423 valueD = 100.0 * TMath::Abs(mult1 - mult2) / TMath::Max(mult1, mult2); // in %
424 return IsBetween((Double_t)valueD);
426 valueD = TMath::Abs(ev1->GetVz() - ev2->GetVz());
427 return IsBetween((Double_t)valueD);
428 case kPhiMeanDifference:
429 valueD = TMath::Abs(ev1->GetPhiMean() - ev2->GetPhiMean());
430 if (valueD > 180.0) valueD = 360.0 - valueD;
431 return IsBetween((Double_t)valueD);
433 AliWarning("Requested a cut which cannot be applied to an event");
440 //________________________________________________________________________________________________________________
441 void AliRsnCut::PrintAllValues()
443 AliInfo(Form("fType=%d fVarType=%d",fType,fVarType));
444 AliInfo(Form("fDMin=%.2e fDMax=%.2e",fDMin,fDMax));
445 AliInfo(Form("fIMin=%d fIMax=%d",fIMin,fIMax));
446 AliInfo(Form("fUIMin=%d fUIMax=%d",fUIMin,fUIMax));
447 AliInfo(Form("fULMin=%d fULMax=%d",fULMin,fULMax));