]>
Commit | Line | Data |
---|---|---|
5eb970a4 | 1 | // |
2 | // Class AliRsnCutStd | |
3 | // | |
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()] | |
7 | // | |
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. | |
14 | // | |
15 | // authors: Martin Vala (martin.vala@cern.ch) | |
16 | // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) | |
17 | // | |
4fbb2459 | 18 | |
2dab9030 | 19 | #include <TMath.h> |
20 | #include <TLorentzVector.h> | |
5eb970a4 | 21 | |
c680166d | 22 | #include "AliStack.h" |
23 | #include "AliMCEvent.h" | |
5eb970a4 | 24 | #include "AliRsnDaughter.h" |
2dab9030 | 25 | #include "AliRsnMother.h" |
5eb970a4 | 26 | #include "AliRsnEvent.h" |
5eb970a4 | 27 | |
28 | #include "AliRsnCutStd.h" | |
29 | ||
30 | ClassImp(AliRsnCutStd) | |
31 | ||
32 | //_________________________________________________________________________________________________ | |
33 | AliRsnCutStd::AliRsnCutStd() : | |
2dab9030 | 34 | AliRsnCut(), |
35 | fType(kLastType), | |
36 | fUseMC(kFALSE), | |
37 | fMass(0.0) | |
5eb970a4 | 38 | { |
39 | // | |
40 | // Default constructor. | |
41 | // | |
42 | } | |
43 | ||
44 | //_________________________________________________________________________________________________ | |
45 | AliRsnCutStd::AliRsnCutStd | |
2dab9030 | 46 | (const char *name, ETarget target, EType type, Int_t val1, Int_t val2, Bool_t useMC) : |
47 | AliRsnCut(name, target, val1, val2), | |
48 | fType(type), | |
49 | fUseMC(useMC), | |
50 | fMass(0.0) | |
5eb970a4 | 51 | { |
52 | // | |
53 | // Main constructor. | |
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 | |
2dab9030 | 56 | // but is interpreted as integer due to the overloading of constructors. |
5eb970a4 | 57 | // |
58 | ||
2dab9030 | 59 | switch (fType) |
60 | { | |
5eb970a4 | 61 | // int |
2dab9030 | 62 | case kMult: |
63 | case kCharge: | |
64 | break; | |
5eb970a4 | 65 | // double |
2dab9030 | 66 | case kP: |
67 | case kPt: | |
11ba7ebc | 68 | case kPtLeading: |
2dab9030 | 69 | case kEta: |
70 | case kY: | |
8fee9e63 | 71 | case kDipAngle: |
2dab9030 | 72 | case kThetaDeg: |
73 | if (fVarType != kDouble) | |
74 | { | |
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)); | |
78 | } | |
79 | break; | |
5eb970a4 | 80 | // other cuts are not based on a value, so no problem |
2dab9030 | 81 | default: |
82 | break; | |
5eb970a4 | 83 | } |
84 | } | |
85 | ||
86 | //_________________________________________________________________________________________________ | |
87 | AliRsnCutStd::AliRsnCutStd | |
2dab9030 | 88 | (const char *name, ETarget target, EType type, Double_t val1, Double_t val2, Bool_t useMC) : |
89 | AliRsnCut(name, target, val1, val2), | |
90 | fType(type), | |
91 | fUseMC(useMC), | |
92 | fMass(0.0) | |
5eb970a4 | 93 | { |
94 | // | |
95 | // Main constructor. | |
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 | |
99 | // | |
100 | ||
2dab9030 | 101 | switch (fType) |
102 | { | |
5eb970a4 | 103 | // int |
2dab9030 | 104 | case kMult: |
105 | case kCharge: | |
106 | if (fVarType != kInt) | |
107 | { | |
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)); | |
111 | } | |
112 | break; | |
5eb970a4 | 113 | // double |
2dab9030 | 114 | case kP: |
115 | case kPt: | |
11ba7ebc | 116 | case kPtLeading: |
2dab9030 | 117 | case kEta: |
118 | case kY: | |
8fee9e63 | 119 | case kDipAngle: |
2dab9030 | 120 | case kThetaDeg: |
121 | break; | |
5eb970a4 | 122 | // other cuts are not based on a value, so no problem |
2dab9030 | 123 | default: |
124 | break; | |
5eb970a4 | 125 | } |
126 | } | |
127 | ||
128 | //_________________________________________________________________________________________________ | |
2dab9030 | 129 | AliRsnCut::EVarType AliRsnCutStd::CheckType() |
5eb970a4 | 130 | { |
131 | // | |
2dab9030 | 132 | // Returns the variable type expected for the selected cut type |
5eb970a4 | 133 | // |
134 | ||
2dab9030 | 135 | switch (fType) |
136 | { | |
137 | // integer cuts | |
138 | case kMult: | |
139 | case kCharge: | |
140 | return kInt; | |
141 | // double couts | |
142 | case kP: | |
143 | case kPt: | |
11ba7ebc | 144 | case kPtLeading: |
2dab9030 | 145 | case kEta: |
146 | case kY: | |
8fee9e63 | 147 | case kDipAngle: |
2dab9030 | 148 | case kThetaDeg: |
149 | return kDouble; | |
5eb970a4 | 150 | // other cuts are not based on a value, so no problem |
2dab9030 | 151 | default: |
152 | return kNoVar; | |
5eb970a4 | 153 | } |
154 | } | |
155 | ||
156 | //_________________________________________________________________________________________________ | |
2dab9030 | 157 | Bool_t AliRsnCutStd::IsSelected(TObject *obj1, TObject *obj2) |
5eb970a4 | 158 | { |
2dab9030 | 159 | // coherence check using the mother class method |
160 | if (!TargetOK(obj1, obj2)) | |
161 | { | |
162 | AliError("Wrong target. Skipping cut"); | |
4fbb2459 | 163 | return kTRUE; |
5eb970a4 | 164 | } |
2dab9030 | 165 | |
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); | |
175 | else return kTRUE; | |
5eb970a4 | 176 | } |
177 | ||
178 | //_________________________________________________________________________________________________ | |
2dab9030 | 179 | Bool_t AliRsnCutStd::IsDaughterSelected(AliRsnDaughter *daughter) |
5eb970a4 | 180 | { |
181 | // | |
2dab9030 | 182 | // Cut checker. |
5eb970a4 | 183 | // |
184 | ||
2dab9030 | 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(); | |
5eb970a4 | 188 | |
189 | // loop on allowed possibilities | |
2dab9030 | 190 | switch (fType) |
191 | { | |
192 | case kP: | |
193 | fCutValueD = ref->P(); | |
194 | return OkRange(); | |
195 | case kPt: | |
196 | fCutValueD = ref->Pt(); | |
197 | return OkRange(); | |
198 | case kThetaDeg: | |
199 | fCutValueD = ref->Theta() * TMath::RadToDeg(); | |
200 | return OkRange(); | |
201 | case kEta: | |
202 | fCutValueD = ref->Eta(); | |
203 | return OkRange(); | |
204 | case kCharge: | |
205 | fCutValueI = (Int_t)ref->Charge(); | |
206 | return OkValue(); | |
c680166d | 207 | case kPhysPrimary: |
208 | if (!fEvent->GetRefMC()) return kFALSE; | |
209 | else | |
210 | { | |
a378358c | 211 | return fEvent->GetRefMCESD()->Stack()->IsPhysicalPrimary(TMath::Abs(((AliVTrack*)ref)->GetLabel())); |
c680166d | 212 | } |
2dab9030 | 213 | default: |
214 | AliWarning(Form("Value %d is not included in available cuts for DAUGHTER. Cut skipped.", fType)); | |
215 | return kTRUE; | |
5eb970a4 | 216 | } |
217 | } | |
218 | ||
219 | //_________________________________________________________________________________________________ | |
2dab9030 | 220 | Bool_t AliRsnCutStd::IsMotherSelected(AliRsnMother * const mother) |
5eb970a4 | 221 | { |
222 | // | |
223 | // Cut checker | |
224 | // | |
2dab9030 | 225 | |
226 | // use MC flag if required | |
227 | TLorentzVector &sum = fUseMC ? mother->SumMC() : mother->Sum(); | |
228 | TLorentzVector &ref = fUseMC ? mother->RefMC() : mother->Ref(); | |
229 | ||
5eb970a4 | 230 | // loop on allowed possibilities |
2dab9030 | 231 | switch (fType) |
232 | { | |
233 | case kP: | |
234 | fCutValueD = sum.P(); | |
235 | return OkRange(); | |
236 | case kPt: | |
237 | fCutValueD = sum.Perp(); | |
238 | return OkRange(); | |
239 | case kEta: | |
240 | fCutValueD = sum.Eta(); | |
241 | return OkRange(); | |
242 | case kY: | |
243 | fCutValueD = ref.Rapidity(); | |
244 | return OkRange(); | |
8fee9e63 | 245 | case kDipAngle: |
a378358c | 246 | fCutValueD = mother->GetDaughter(0)->Prec().Angle(mother->GetDaughter(1)->Prec().Vect()); |
89202f72 | 247 | fCutValueD = TMath::Abs(TMath::ACos(fCutValueD)); |
248 | return OkRangeD(); | |
2dab9030 | 249 | case kSameLabel: |
250 | return mother->IsLabelEqual(); | |
251 | default: | |
252 | AliWarning(Form("Value %d is not included in available cuts for PAIR. Cut skipped.", fType)); | |
253 | return kTRUE; | |
5eb970a4 | 254 | } |
255 | } | |
256 | ||
257 | //_________________________________________________________________________________________________ | |
2dab9030 | 258 | Bool_t AliRsnCutStd::IsEventSelected(AliRsnEvent * const event) |
5eb970a4 | 259 | { |
260 | // | |
261 | // Cut checker | |
262 | // | |
263 | ||
5eb970a4 | 264 | // loop on allowed possibilities |
2dab9030 | 265 | switch (fType) |
266 | { | |
267 | case kMult: | |
268 | fCutValueI = event->GetMultiplicity(); | |
269 | return OkRange(); | |
11ba7ebc | 270 | case kPtLeading: |
271 | { | |
272 | int leadingID = event->SelectLeadingParticle(0); | |
273 | if(leadingID >= 0) { | |
274 | AliRsnDaughter leadingPart = event->GetDaughter(leadingID); | |
275 | AliVParticle *ref = fUseMC ? leadingPart.GetRefMC() : leadingPart.GetRef(); | |
276 | fCutValueD = ref->Pt(); | |
277 | } | |
278 | else fCutValueD = 0; | |
279 | return OkRange(); | |
280 | } | |
2dab9030 | 281 | default: |
282 | AliWarning(Form("Value %d is not included in available cuts for EVENT. Cut skipped.", fType)); | |
283 | return kTRUE; | |
5eb970a4 | 284 | } |
c680166d | 285 | } |