]>
Commit | Line | Data |
---|---|---|
2dab9030 | 1 | |
b9bbd271 | 2 | // |
3 | // Class AliRsnValue | |
4 | // | |
5 | // Definition of a single value which can be computed | |
6 | // from any of the defined input objects implemented | |
7 | // in the resonance package. | |
8 | // | |
9 | ||
10 | #include "AliRsnEvent.h" | |
11 | #include "AliRsnDaughter.h" | |
2dab9030 | 12 | #include "AliRsnMother.h" |
b9bbd271 | 13 | #include "AliRsnPairDef.h" |
14 | ||
15 | #include "AliRsnValue.h" | |
16 | ||
17 | ClassImp(AliRsnValue) | |
18 | ||
19 | //_____________________________________________________________________________ | |
2dab9030 | 20 | AliRsnValue::AliRsnValue() : |
0d73200d | 21 | TNamed(), |
b2b08ca2 | 22 | fValue(0.0), |
63a2738c | 23 | fType(kValueTypes), |
45bb0283 | 24 | fArray(0), |
25 | fESDCuts() | |
2dab9030 | 26 | { |
27 | // | |
28 | // Main constructor (version 1) | |
29 | // This can also be created without any argument. | |
30 | // | |
31 | } | |
32 | ||
33 | //_____________________________________________________________________________ | |
34 | AliRsnValue::AliRsnValue | |
0d73200d | 35 | (const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) : |
36 | TNamed(name, ""), | |
b2b08ca2 | 37 | fValue(0.0), |
63a2738c | 38 | fType(type), |
45bb0283 | 39 | fArray(0), |
40 | fESDCuts() | |
b9bbd271 | 41 | { |
42 | // | |
2dab9030 | 43 | // Main constructor (version 1) |
44 | // This can also be created without any argument. | |
b9bbd271 | 45 | // |
2dab9030 | 46 | |
47 | SetBins(nbins, min, max); | |
48 | } | |
49 | ||
50 | //_____________________________________________________________________________ | |
51 | AliRsnValue::AliRsnValue | |
0d73200d | 52 | (const char *name, EValueType type, Double_t min, Double_t max, Double_t step) : |
53 | TNamed(name, ""), | |
b2b08ca2 | 54 | fValue(0.0), |
63a2738c | 55 | fType(type), |
45bb0283 | 56 | fArray(0), |
57 | fESDCuts() | |
2dab9030 | 58 | { |
59 | // | |
60 | // Main constructor (version 2) | |
61 | // | |
62 | ||
63 | SetBins(min, max, step); | |
b9bbd271 | 64 | } |
65 | ||
66 | //_____________________________________________________________________________ | |
b2b08ca2 | 67 | AliRsnValue::AliRsnValue |
68 | (const char *name, EValueType type, Int_t nbins, Double_t *array) : | |
69 | TNamed(name, ""), | |
b2b08ca2 | 70 | fValue(0.0), |
63a2738c | 71 | fType(type), |
45bb0283 | 72 | fArray(0), |
73 | fESDCuts() | |
b9bbd271 | 74 | { |
75 | // | |
b2b08ca2 | 76 | // Main constructor (version 2) |
77 | // | |
78 | ||
79 | SetBins(nbins, array); | |
b9bbd271 | 80 | } |
81 | ||
82 | //_____________________________________________________________________________ | |
52944696 | 83 | AliRsnValue::AliRsnValue(const AliRsnValue& copy) : |
84 | TNamed(copy), | |
85 | fValue(copy.fValue), | |
86 | fType(copy.fType), | |
87 | fArray(copy.fArray), | |
88 | fESDCuts(copy.fESDCuts) | |
89 | { | |
90 | // | |
91 | // Copy constructor | |
92 | // | |
93 | } | |
94 | ||
95 | //_____________________________________________________________________________ | |
96 | AliRsnValue& AliRsnValue::operator=(const AliRsnValue& copy) | |
97 | { | |
98 | // | |
99 | // Assignment operator | |
100 | // | |
101 | ||
102 | SetName(copy.GetName()); | |
103 | ||
104 | fType = copy.fType; | |
105 | fValue = copy.fValue; | |
106 | fArray = copy.fArray; | |
107 | fESDCuts = copy.fESDCuts; | |
108 | ||
109 | return (*this); | |
110 | } | |
111 | ||
112 | //_____________________________________________________________________________ | |
b2b08ca2 | 113 | void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max) |
b9bbd271 | 114 | { |
115 | // | |
b2b08ca2 | 116 | // Set binning for the axis in equally spaced bins |
117 | // where the number of bins, minimum and maximum are given. | |
118 | // | |
119 | ||
120 | fArray.Set(nbins + 1); | |
121 | ||
122 | Double_t mymax = TMath::Max(min, max); | |
123 | Double_t mymin = TMath::Min(min, max); | |
124 | ||
125 | Int_t k = 0; | |
126 | Double_t binSize = (mymax - mymin) / ((Double_t)nbins); | |
127 | ||
128 | fArray[0] = mymin; | |
129 | for (k = 1; k <= nbins; k++) fArray[k] = fArray[k-1] + binSize; | |
130 | for (k = 0; k < fArray.GetSize() - 1; k++) AliDebug(AliLog::kDebug + 3, Form("Bin #%d: %f - %f", k, fArray[k], fArray[k+1])); | |
2dab9030 | 131 | } |
132 | ||
133 | //_____________________________________________________________________________ | |
b2b08ca2 | 134 | void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step) |
2dab9030 | 135 | { |
136 | // | |
b2b08ca2 | 137 | // Set binning for the axis in equally spaced bins |
138 | // where the bin size, minimum and maximum are given. | |
2dab9030 | 139 | // |
140 | ||
b2b08ca2 | 141 | Double_t dblNbins = TMath::Abs(max - min) / step; |
142 | Int_t intNbins = ((Int_t)dblNbins) + 1; | |
143 | ||
144 | SetBins(intNbins, min, max); | |
b9bbd271 | 145 | } |
146 | ||
147 | //_____________________________________________________________________________ | |
b2b08ca2 | 148 | void AliRsnValue::SetBins(Int_t nbins, Double_t *array) |
2dab9030 | 149 | { |
150 | // | |
b2b08ca2 | 151 | // Set binning for the axis in unequally spaced bins |
152 | // using the same way it is done in TAxis | |
2dab9030 | 153 | // |
154 | ||
b2b08ca2 | 155 | fArray.Adopt(nbins, array); |
156 | for (Int_t k = 0; k < fArray.GetSize() - 1; k++) AliDebug(AliLog::kDebug + 3, Form("Bin #%d: %f - %f", k, fArray[k], fArray[k+1])); | |
2dab9030 | 157 | } |
158 | ||
159 | //_____________________________________________________________________________ | |
2e521c29 | 160 | Bool_t AliRsnValue::Eval(AliRsnMother * const mother, AliRsnPairDef * const pairDef, AliRsnEvent * const event) |
b9bbd271 | 161 | { |
162 | // | |
163 | // Evaluation of the required value. | |
164 | // Checks that the passed object is of the right type | |
165 | // and if this check is successful, returns the required value. | |
166 | // The output of the function tells if it was successful, | |
167 | // and the values must be taken with GetValue(). | |
168 | // | |
169 | ||
2dab9030 | 170 | // avoid segfaults |
171 | if (!mother) return kFALSE; | |
172 | if (!pairDef) return kFALSE; | |
b9bbd271 | 173 | |
2dab9030 | 174 | Double_t mass = pairDef->GetMotherMass(); |
b9bbd271 | 175 | |
176 | switch (fType) | |
177 | { | |
b9bbd271 | 178 | case kTrack1P: |
2dab9030 | 179 | fValue = mother->GetDaughter(0)->P().Mag(); |
180 | break; | |
b9bbd271 | 181 | case kTrack2P: |
2dab9030 | 182 | fValue = mother->GetDaughter(1)->P().Mag(); |
183 | break; | |
b9bbd271 | 184 | case kTrack1Pt: |
2dab9030 | 185 | fValue = mother->GetDaughter(0)->P().Perp(); |
186 | break; | |
b9bbd271 | 187 | case kTrack2Pt: |
2dab9030 | 188 | fValue = mother->GetDaughter(1)->P().Perp(); |
189 | break; | |
3c07ce75 | 190 | case kTrack1Px: |
191 | fValue = mother->GetDaughter(0)->P().X(); | |
192 | break; | |
193 | case kTrack1Py: | |
194 | fValue = mother->GetDaughter(0)->P().Y(); | |
195 | break; | |
196 | case kTrack1Pz: | |
197 | fValue = mother->GetDaughter(0)->P().Z(); | |
198 | break; | |
199 | case kTrack2Px: | |
200 | fValue = mother->GetDaughter(1)->P().X(); | |
201 | break; | |
202 | case kTrack2Py: | |
203 | fValue = mother->GetDaughter(1)->P().Y(); | |
204 | break; | |
205 | case kTrack2Pz: | |
206 | fValue = mother->GetDaughter(1)->P().Z(); | |
207 | break; | |
b9bbd271 | 208 | case kPairInvMass: |
2dab9030 | 209 | fValue = mother->Sum().M(); |
210 | break; | |
b9bbd271 | 211 | case kPairInvMassMC: |
2dab9030 | 212 | fValue = mother->SumMC().M(); |
213 | break; | |
b9bbd271 | 214 | case kPairInvMassRes: |
2dab9030 | 215 | fValue = (mother->SumMC().M() - mother->Sum().M()) / mother->SumMC().M(); |
216 | break; | |
b9bbd271 | 217 | case kPairPt: |
2dab9030 | 218 | fValue = mother->Sum().Perp(); |
219 | break; | |
b9bbd271 | 220 | case kPairEta: |
2dab9030 | 221 | fValue = mother->Sum().Eta(); |
222 | break; | |
b9bbd271 | 223 | case kPairMt: |
224 | if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass)); | |
2dab9030 | 225 | fValue = (TMath::Sqrt(mother->Sum().Perp2() + mass*mass) - mass); |
226 | break; | |
b9bbd271 | 227 | case kPairY: |
228 | if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass)); | |
2dab9030 | 229 | mother->SetDefaultMass(mass); |
230 | fValue = mother->Ref().Rapidity(); | |
231 | break; | |
b8718678 | 232 | case kPairPhi: |
233 | fValue = mother->Sum().Phi(); | |
234 | break; | |
235 | case kPairPhiMC: | |
236 | fValue = mother->SumMC().Phi(); | |
237 | break; | |
238 | case kPairPtRatio: | |
239 | fValue = TMath::Abs(mother->GetDaughter(0)->P().Perp() - mother->GetDaughter(1)->P().Perp()); | |
240 | fValue /= TMath::Abs(mother->GetDaughter(0)->P().Perp() + mother->GetDaughter(1)->P().Perp()); | |
241 | break; | |
f9b1a0cc | 242 | case kPairDipAngle: |
89202f72 | 243 | fValue = mother->GetDaughter(0)->P().Angle(mother->GetDaughter(1)->P().Vect()); |
244 | fValue = TMath::Abs(TMath::ACos(fValue)); | |
f9b1a0cc | 245 | break; |
2e521c29 | 246 | case kPairCosThetaStar: |
247 | fValue = mother->CosThetaStar(); | |
248 | break; | |
cadcd9e0 | 249 | case kPairCosThetaStar1: |
2e521c29 | 250 | //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kFALSE)); |
cadcd9e0 | 251 | break; |
252 | case kPairCosThetaStar2: | |
2e521c29 | 253 | //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kFALSE)); |
cadcd9e0 | 254 | break; |
255 | case kPairCosThetaStarMC1: | |
2e521c29 | 256 | //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kTRUE)); |
cadcd9e0 | 257 | break; |
258 | case kPairCosThetaStarMC2: | |
2e521c29 | 259 | //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kTRUE)); |
cadcd9e0 | 260 | break; |
11ba7ebc | 261 | case kAngleToLeading: |
262 | { | |
263 | int ID1 = (mother->GetDaughter(0))->GetID(); | |
264 | int ID2 = (mother->GetDaughter(1))->GetID(); | |
265 | int leadingID = event->SelectLeadingParticle(0); | |
266 | if(leadingID == ID1 || leadingID == ID2) return kFALSE; | |
267 | AliRsnDaughter leadingPart = event->GetDaughter(leadingID); | |
268 | AliVParticle *ref = leadingPart.GetRef(); | |
269 | ||
270 | fValue = ref->Phi() - mother->Sum().Phi(); | |
271 | //return angle w.r.t. leading particle in the range -pi/2, 3/2pi | |
272 | while(fValue >= TMath::Pi()) fValue -= 2*TMath::Pi(); | |
273 | while(fValue < -0.5*TMath::Pi()) fValue += 2*TMath::Pi(); | |
274 | //Printf("%g", fValue); | |
11ba7ebc | 275 | } |
276 | break; | |
b9bbd271 | 277 | case kEventMult: |
96e9d35d | 278 | if (!event) |
279 | { | |
280 | fValue = 0.0; | |
281 | return kFALSE; | |
282 | } | |
283 | else fValue = (Double_t)event->GetMultiplicity(); | |
2dab9030 | 284 | break; |
45bb0283 | 285 | case kEventMultESDcuts: |
286 | if (!event) | |
287 | { | |
288 | fValue = 0.0; | |
289 | return kFALSE; | |
290 | } | |
291 | else | |
292 | { | |
293 | AliESDEvent *esd = event->GetRefESD(); | |
294 | if (!esd) | |
295 | { | |
296 | AliError("Cannot use method based on ESD cuts when input is not ESD."); | |
297 | fValue = 0.0; | |
298 | return kFALSE; | |
299 | } | |
300 | fValue = (Double_t)fESDCuts.CountAcceptedTracks(esd); | |
301 | } | |
11ba7ebc | 302 | case kLeadingPt: |
96e9d35d | 303 | if (!event) |
304 | { | |
305 | fValue = 0.0; | |
306 | return kFALSE; | |
307 | } | |
308 | else | |
11ba7ebc | 309 | { |
310 | int leadingID = event->SelectLeadingParticle(0); | |
311 | if(leadingID >= 0) { | |
312 | AliRsnDaughter leadingPart = event->GetDaughter(leadingID); | |
313 | AliVParticle *ref = leadingPart.GetRef(); | |
314 | fValue = ref->Pt(); | |
315 | } | |
316 | else fValue = 0; | |
317 | } | |
318 | break; | |
2467e7c3 | 319 | case kQInv: |
320 | { | |
321 | TLorentzVector diff = mother->GetDaughter(0)->P() - mother->GetDaughter(1)->P(); | |
322 | fValue = diff.M(); | |
323 | } | |
324 | break; | |
b9bbd271 | 325 | default: |
326 | AliWarning("Invalid value type"); | |
2dab9030 | 327 | return kFALSE; |
b9bbd271 | 328 | } |
2dab9030 | 329 | |
330 | return kTRUE; | |
b9bbd271 | 331 | } |
c18b1218 | 332 | |
69fbb331 | 333 | //_____________________________________________________________________________ |
334 | Bool_t AliRsnValue::Eval(AliRsnDaughter * const daughter, AliRsnEvent * const event) | |
335 | { | |
336 | // | |
337 | // Evaluation of the required value. | |
338 | // Checks that the passed object is of the right type | |
339 | // and if this check is successful, returns the required value. | |
340 | // The output of the function tells if it was successful, | |
341 | // and the values must be taken with GetValue(). | |
342 | // | |
343 | ||
344 | // avoid segfaults | |
345 | if (!daughter) return kFALSE; | |
346 | ||
347 | switch (fType) | |
348 | { | |
96e9d35d | 349 | case kEventMult: |
350 | if (!event) | |
351 | { | |
352 | fValue = 0.0; | |
353 | return kFALSE; | |
354 | } | |
355 | else fValue = (Double_t)event->GetMultiplicity(); | |
356 | break; | |
357 | case kLeadingPt: | |
358 | if (!event) | |
359 | { | |
360 | fValue = 0.0; | |
361 | return kFALSE; | |
362 | } | |
363 | else | |
364 | { | |
365 | int leadingID = event->SelectLeadingParticle(0); | |
366 | if(leadingID >= 0) { | |
367 | AliRsnDaughter leadingPart = event->GetDaughter(leadingID); | |
368 | AliVParticle *ref = leadingPart.GetRef(); | |
369 | fValue = ref->Pt(); | |
370 | } | |
371 | else fValue = 0; | |
372 | } | |
373 | break; | |
69fbb331 | 374 | default: |
375 | AliWarning("Invalid value type"); | |
376 | return kFALSE; | |
377 | } | |
378 | ||
379 | return kTRUE; | |
380 | } | |
381 | ||
c18b1218 | 382 | //_____________________________________________________________________________ |
383 | void AliRsnValue::Print(Option_t *) const | |
384 | { | |
385 | // | |
386 | // Print all bins | |
387 | // | |
388 | ||
389 | Int_t i, n = fArray.GetSize(); | |
390 | TString msg("Array values: "); | |
391 | ||
392 | for (i = 0; i < n; i++) msg += Form("%f, ", fArray[i]); | |
393 | ||
394 | AliInfo(Form("Axis name: %s", GetName())); | |
395 | AliInfo(msg.Data()); | |
396 | } |