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)
20 #include <TLorentzVector.h>
23 #include "AliMCEvent.h"
24 #include "AliRsnDaughter.h"
25 #include "AliRsnMother.h"
26 #include "AliRsnEvent.h"
28 #include "AliRsnCutStd.h"
30 ClassImp(AliRsnCutStd)
32 //_________________________________________________________________________________________________
33 AliRsnCutStd::AliRsnCutStd() :
40 // Default constructor.
44 //_________________________________________________________________________________________________
45 AliRsnCutStd::AliRsnCutStd
46 (const char *name, ETarget target, EType type, Int_t val1, Int_t val2, Bool_t useMC) :
47 AliRsnCut(name, target, val1, val2),
54 // Checks also that cut values are given in the correct type,
55 // in order to avoid that one passes, for example, a value which should be double
56 // but is interpreted as integer due to the overloading of constructors.
73 if (fVarType != kDouble)
75 AliWarning(Form("[INT CONSTRUCTOR] Cut '%s' is based on DOUBLE. Casting values to DOUBLE", GetName()));
76 SetRange((Double_t)val1, (Double_t)val2);
77 AliWarning(Form("[INT CONSTRUCTOR] Cut '%s' DOUBLE range = %f, %f", GetName(), fMinD, fMaxD));
80 // other cuts are not based on a value, so no problem
86 //_________________________________________________________________________________________________
87 AliRsnCutStd::AliRsnCutStd
88 (const char *name, ETarget target, EType type, Double_t val1, Double_t val2, Bool_t useMC) :
89 AliRsnCut(name, target, val1, val2),
96 // Checks also that cut values are given in the correct type,
97 // in order to avoid that one passes, for example, a value which should be double
98 // but is interpreted as integer due to the overloading of constructors
106 if (fVarType != kInt)
108 AliWarning(Form("[DOUBLE CONSTRUCTOR] Cut '%s' is based on INT. Casting values to INT", GetName()));
109 SetRange((Int_t)val1, (Int_t)val2);
110 AliWarning(Form("[DOUBLE CONSTRUCTOR] Cut '%s' INT range = %d, %d", GetName(), fMinI, fMaxI));
122 // other cuts are not based on a value, so no problem
128 //_________________________________________________________________________________________________
129 AliRsnCut::EVarType AliRsnCutStd::CheckType()
132 // Returns the variable type expected for the selected cut type
150 // other cuts are not based on a value, so no problem
156 //_________________________________________________________________________________________________
157 Bool_t AliRsnCutStd::IsSelected(TObject *obj1, TObject *obj2)
159 // coherence check using the mother class method
160 if (!TargetOK(obj1, obj2))
162 AliError("Wrong target. Skipping cut");
166 // if coherence check is OK, only one of the following
167 // dynamic casts will be successful, and it will trigger
168 // the correct internal method to check the cut
169 AliRsnDaughter *objD = dynamic_cast<AliRsnDaughter*>(obj1);
170 AliRsnMother *objM = dynamic_cast<AliRsnMother*>(obj1);
171 AliRsnEvent *objE = dynamic_cast<AliRsnEvent*>(obj1);
172 if (objD) return IsDaughterSelected(objD);
173 else if (objM) return IsMotherSelected(objM);
174 else if (objE) return IsEventSelected(objE);
178 //_________________________________________________________________________________________________
179 Bool_t AliRsnCutStd::IsDaughterSelected(AliRsnDaughter *daughter)
185 // get the correct reference object for kinematic cuts
186 // and check that this reference is not NULL, to avoid segfaults
187 AliVParticle *ref = fUseMC ? daughter->GetRefMC() : daughter->GetRef();
189 // loop on allowed possibilities
193 fCutValueD = ref->P();
196 fCutValueD = ref->Pt();
199 fCutValueD = ref->Theta() * TMath::RadToDeg();
202 fCutValueD = ref->Eta();
205 fCutValueI = (Int_t)ref->Charge();
208 if (!fEvent->GetRefMC()) return kFALSE;
211 return fEvent->GetRefMC()->Stack()->IsPhysicalPrimary(TMath::Abs(((AliVTrack*)ref)->GetLabel()));
214 AliWarning(Form("Value %d is not included in available cuts for DAUGHTER. Cut skipped.", fType));
219 //_________________________________________________________________________________________________
220 Bool_t AliRsnCutStd::IsMotherSelected(AliRsnMother * const mother)
226 // use MC flag if required
227 TLorentzVector &sum = fUseMC ? mother->SumMC() : mother->Sum();
228 TLorentzVector &ref = fUseMC ? mother->RefMC() : mother->Ref();
230 // loop on allowed possibilities
234 fCutValueD = sum.P();
237 fCutValueD = sum.Perp();
240 fCutValueD = sum.Eta();
243 fCutValueD = ref.Rapidity();
246 fCutValueD = mother->GetDaughter(0)->P().Perp() * mother->GetDaughter(1)->P().Perp();
247 fCutValueD += mother->GetDaughter(0)->P().Pz() * mother->GetDaughter(1)->P().Pz();
248 fCutValueD += mother->GetDaughter(0)->P().Mag() * mother->GetDaughter(1)->P().Mag();
249 fCutValueD = TMath::ACos(fCutValueD);
252 return mother->IsLabelEqual();
254 AliWarning(Form("Value %d is not included in available cuts for PAIR. Cut skipped.", fType));
259 //_________________________________________________________________________________________________
260 Bool_t AliRsnCutStd::IsEventSelected(AliRsnEvent * const event)
266 // loop on allowed possibilities
270 fCutValueI = event->GetMultiplicity();
274 int leadingID = event->SelectLeadingParticle(0);
276 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
277 AliVParticle *ref = fUseMC ? leadingPart.GetRefMC() : leadingPart.GetRef();
278 fCutValueD = ref->Pt();
284 AliWarning(Form("Value %d is not included in available cuts for EVENT. Cut skipped.", fType));