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)
19 #include "TParticle.h"
22 #include "AliRsnDaughter.h"
23 #include "AliRsnEvent.h"
24 #include "AliRsnPairParticle.h"
26 #include "AliRsnCutStd.h"
28 ClassImp(AliRsnCutStd)
30 //_________________________________________________________________________________________________
31 AliRsnCutStd::AliRsnCutStd() :
38 // Default constructor.
42 //_________________________________________________________________________________________________
43 AliRsnCutStd::AliRsnCutStd
44 (const char *name, EType type, Int_t val1, Int_t val2, Bool_t useMC) :
45 AliRsnCut(name, val1, val2),
52 // Checks also that cut values are given in the correct type,
53 // in order to avoid that one passes, for example, a value which should be double
54 // but is interpreted as integer due to the overloading of constructors
70 if (fVarType != kULong) {
71 AliWarning(Form("[INT CONSTRUCTOR] Cut '%s' is based on ULONG. Casting values to ULONG", GetName()));
72 SetRange((ULong_t)val1, (ULong_t)val2);
73 AliWarning(Form("[INT CONSTRUCTOR] Cut '%s' ULONG range = %lu, %lu", GetName(), fMinU, fMaxU));
87 if (fVarType != kDouble) {
88 AliWarning(Form("[INT CONSTRUCTOR] Cut '%s' is based on DOUBLE. Casting values to DOUBLE", GetName()));
89 SetRange((Double_t)val1, (Double_t)val2);
90 AliWarning(Form("[INT CONSTRUCTOR] Cut '%s' DOUBLE range = %f, %f", GetName(), fMinD, fMaxD));
93 // other cuts are not based on a value, so no problem
99 //_________________________________________________________________________________________________
100 AliRsnCutStd::AliRsnCutStd
101 (const char *name, EType type, ULong_t val1, ULong_t val2, Bool_t useMC) :
102 AliRsnCut(name, val1, val2),
109 // Checks also that cut values are given in the correct type,
110 // in order to avoid that one passes, for example, a value which should be double
111 // but is interpreted as integer due to the overloading of constructors
124 if (fVarType != kInt) {
125 AliWarning(Form("[ULONG CONSTRUCTOR] Cut '%s' is based on INT. Casting values to INT", GetName()));
126 SetRange((Int_t)val1, (Int_t)val2);
127 AliWarning(Form("[ULONG CONSTRUCTOR] Cut '%s' INT range = %d, %d", GetName(), fMinI, fMaxI));
144 if (fVarType != kDouble) {
145 AliWarning(Form("[ULONG CONSTRUCTOR] Cut '%s' is based on DOUBLE. Casting values to DOUBLE", GetName()));
146 SetRange((Double_t)val1, (Double_t)val2);
147 AliWarning(Form("[ULONG CONSTRUCTOR] Cut '%s' DOUBLE range = %f, %f", GetName(), fMinD, fMaxD));
150 // other cuts are not based on a value, so no problem
156 //_________________________________________________________________________________________________
157 AliRsnCutStd::AliRsnCutStd
158 (const char *name, EType type, Double_t val1, Double_t val2, Bool_t useMC) :
159 AliRsnCut(name, val1, val2),
166 // Checks also that cut values are given in the correct type,
167 // in order to avoid that one passes, for example, a value which should be double
168 // but is interpreted as integer due to the overloading of constructors
181 if (fVarType != kInt) {
182 AliWarning(Form("[DOUBLE CONSTRUCTOR] Cut '%s' is based on INT. Casting values to INT", GetName()));
183 SetRange((Int_t)val1, (Int_t)val2);
184 AliWarning(Form("[DOUBLE CONSTRUCTOR] Cut '%s' INT range = %d, %d", GetName(), fMinI, fMaxI));
189 if (fVarType != kULong) {
190 AliWarning(Form("[DOUBLE CONSTRUCTOR] Cut '%s' is based on ULONG. Casting values to ULONG", GetName()));
191 SetRange((ULong_t)val1, (ULong_t)val2);
192 AliWarning(Form("[DOUBLE CONSTRUCTOR] Cut '%s' ULONG range = %lu, %lu", GetName(), fMinU, fMaxU));
207 // other cuts are not based on a value, so no problem
213 //_________________________________________________________________________________________________
214 Bool_t AliRsnCutStd::IsSelected(ETarget tgt, AliRsnDaughter * const track)
221 if (tgt != AliRsnCut::kParticle) {
222 AliError(Form("[%s] Wrong target. Skipping cut", GetName()));
227 // if MC info is required, try to retrieve the TParticle:
228 // if it is not present, the cut is skipped
229 // this avoids to raise a seg-fault when accessing the NULL TParticle object
230 TParticle *part = 0x0;
232 part = track->GetParticle();
234 AliError("Required MC info but it is not present. Cut Skipped.");
239 // loop on allowed possibilities
242 fCutValueD = fUseMC ? part->P() : track->P();
245 fCutValueD = fUseMC ? part->Pt() : track->Pt();
248 fCutValueD = track->ThetaDeg();
251 fCutValueD = fUseMC ? part->Eta() : track->Eta();
254 fCutValueD = track->Dr();
257 fCutValueD = track->Dz();
260 fCutValueU = track->GetStatus();
263 fCutValueI = track->IsKink();
266 fCutValueI = track->IsKinkMother();
269 fCutValueI = (Int_t)track->Charge();
272 fCutValueI = (Int_t)track->PerfectPID();
275 fCutValueI = (Int_t)track->AssignedPID();
278 fCutValueI = (Int_t)track->RequiredPID();
281 fCutValueI = (Int_t)track->RealisticPID();
284 fCutValueI = track->PairIndex();
287 return (track->PerfectPID() == track->RequiredPID());
288 case kRealisticPIDMatch:
289 return (track->RealisticPID() == track->RequiredPID());
291 AliWarning(Form("Value %d is not included in available cuts for DAUGHTER. Cut skipped.", fType));
296 //_________________________________________________________________________________________________
297 Bool_t AliRsnCutStd::IsSelected(ETarget tgt, AliRsnPairParticle * const pair)
304 if (tgt != AliRsnCut::kPair) {
305 AliError(Form("[%s] Wrong target. Skipping cut", GetName()));
309 // loop on allowed possibilities
312 fCutValueD = (fUseMC ? pair->GetPMC() : pair->GetP());
315 fCutValueD = (fUseMC ? pair->GetPtMC() : pair->GetPt());
318 fCutValueD = (fUseMC ? pair->GetEtaMC() : pair->GetEta());
321 fCutValueD = (fUseMC ? pair->GetYMC(fMass) : pair->GetY(fMass));
324 return pair->IsLabelEqual();
326 fCutValueI = TMath::Abs(pair->CommonMother());
329 AliWarning(Form("Value %d is not included in available cuts for PAIR. Cut skipped.", fType));
334 //_________________________________________________________________________________________________
335 Bool_t AliRsnCutStd::IsSelected(ETarget tgt, AliRsnEvent * const event)
342 if (tgt != AliRsnCut::kEvent) {
343 AliError(Form("[%s] Wrong target. Skipping cut", GetName()));
347 // loop on allowed possibilities
350 fCutValueI = event->GetMultiplicity();
353 AliWarning(Form("Value %d is not included in available cuts for EVENT. Cut skipped.", fType));
358 //_________________________________________________________________________________________________
359 Bool_t AliRsnCutStd::IsSelected(ETarget tgt, AliRsnEvent * const ev1, AliRsnEvent * const ev2)
366 if (tgt != AliRsnCut::kMixEvent) {
367 AliError(Form("[%s] Wrong target. Skipping cut", GetName()));
371 // loop on allowed possibilities
372 Double_t mult1, mult2;
375 fCutValueI = TMath::Abs(ev1->GetMultiplicity() - ev2->GetMultiplicity());
378 mult1 = (Double_t)ev1->GetMultiplicity();
379 mult2 = (Double_t)ev2->GetMultiplicity();
380 if (mult1 == 0.0 && mult2 == 0.0) return kTRUE;
381 fCutValueD = 100.0 * TMath::Abs(mult1 - mult2) / TMath::Max(mult1, mult2); // in %
384 fCutValueD = TMath::Abs(ev1->GetVz() - ev2->GetVz());
387 AliWarning(Form("Value %d is not included in available cuts for MIXEVENT. Cut skipped.", fType));