5 // Definition of a single value which can be computed
6 // from any of the defined input objects implemented
7 // in the resonance package.
10 #include <Riostream.h>
11 #include "AliESDtrackCuts.h"
12 #include "AliRsnEvent.h"
13 #include "AliRsnDaughter.h"
14 #include "AliRsnMother.h"
15 #include "AliRsnPairDef.h"
17 #include "AliRsnValue.h"
21 //_____________________________________________________________________________
22 AliRsnValue::AliRsnValue() :
25 fValueType(kValueTypes),
30 // Default constructor without arguments.
31 // Initialize data members to meaningless values.
32 // This method is provided for ROOT streaming,
33 // but should never be used directly by a user.
39 //_____________________________________________________________________________
40 AliRsnValue::AliRsnValue
41 (const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) :
42 AliRsnTarget(name, AliRsnTarget::kTargetTypes),
49 // Main constructor (version 1).
50 // This constructor defines in meaningful way all data members,
51 // and defined a fixed binnings, subdividing the specified interval
52 // into that many bins as specified in the integer argument.
54 // This method is also the entry point for all instances
55 // of this class which don't need to do binning (e.g.: TNtuple inputs),
56 // since arguments 3 to 5 have default values which don't create any
57 // binning array, in order not to allocate memory when this is useless.
61 SetBins(nbins, min, max);
64 //_____________________________________________________________________________
65 AliRsnValue::AliRsnValue
66 (const char *name, EValueType type, Double_t min, Double_t max, Double_t step) :
67 AliRsnTarget(name, AliRsnTarget::kTargetTypes),
74 // Main constructor (version 2).
75 // This constructor defines in meaningful way all data members
76 // and creates enough equal bins of the specified size to cover
77 // the required interval.
81 SetBins(min, max, step);
84 //_____________________________________________________________________________
85 AliRsnValue::AliRsnValue
86 (const char *name, EValueType type, Int_t nbins, Double_t *array) :
87 AliRsnTarget(name, AliRsnTarget::kTargetTypes),
94 // Main constructor (version 3).
95 // This constructor defines in meaningful way all data members
96 // and creates a set of variable bins delimited by the passed array.
100 SetBins(nbins, array);
103 //_____________________________________________________________________________
104 AliRsnValue::AliRsnValue(const AliRsnValue& copy) :
106 fComputedValue(copy.fComputedValue),
107 fValueType(copy.fValueType),
108 fBinArray(copy.fBinArray),
109 fSupportObject(copy.fSupportObject)
113 // Duplicates the binning array and copies all settings.
114 // Calls also the function that assigns properly the
115 // expected target, depending on the computation type.
121 //_____________________________________________________________________________
122 AliRsnValue& AliRsnValue::operator=(const AliRsnValue& copy)
125 // Assignment operator.
126 // Works like copy constructor.
129 AliRsnTarget::operator=(copy);
131 fComputedValue = copy.fComputedValue;
132 fBinArray = copy.fBinArray;
133 fSupportObject = copy.fSupportObject;
140 //_____________________________________________________________________________
141 void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max)
144 // Set binning for the axis in equally spaced bins
145 // where the number of bins, minimum and maximum are given.
153 fBinArray.Set(nbins + 1);
155 Double_t mymax = TMath::Max(min, max);
156 Double_t mymin = TMath::Min(min, max);
159 Double_t binSize = (mymax - mymin) / ((Double_t)nbins);
161 fBinArray[0] = mymin;
162 for (k = 1; k <= nbins; k++) fBinArray[k] = fBinArray[k - 1] + binSize;
165 //_____________________________________________________________________________
166 void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step)
169 // Set binning for the axis in equally spaced bins
170 // where the bin size, minimum and maximum are given.
173 Double_t dblNbins = TMath::Abs(max - min) / step;
174 Int_t intNbins = ((Int_t)dblNbins) + 1;
176 SetBins(intNbins, min, max);
179 //_____________________________________________________________________________
180 void AliRsnValue::SetBins(Int_t nbins, Double_t *array)
183 // Set binning for the axis in unequally spaced bins
184 // using the same way it is done in TAxis
192 fBinArray.Adopt(nbins, array);
195 //_____________________________________________________________________________
196 const char* AliRsnValue::GetValueTypeName() const
199 // This method returns a string to give a name to each possible
200 // computation value.
203 switch (fValueType) {
204 case kTrackP: return "SingleTrackPtot";
205 case kTrackPt: return "SingleTrackPt";
206 case kTrackEta: return "SingleTrackEta";
207 case kPairP1: return "PairPtotDaughter1";
208 case kPairP2: return "PairPtotDaughter2";
209 case kPairP1t: return "PairPtDaughter1";
210 case kPairP2t: return "PairPtDaughter2";
211 case kPairP1z: return "PairPzDaughter1";
212 case kPairP2z: return "PairPzDaughter2";
213 case kPairInvMass: return "PairInvMass";
214 case kPairInvMassMC: return "PairInvMassMC";
215 case kPairInvMassRes: return "PairInvMassResolution";
216 case kPairPt: return "PairPt";
217 case kPairPz: return "PairPz";
218 case kPairEta: return "PairEta";
219 case kPairMt: return "PairMt";
220 case kPairY: return "PairY";
221 case kPairPhi: return "PairPhi";
222 case kPairPhiMC: return "PairPhiMC";
223 case kPairPtRatio: return "PairPtRatio";
224 case kPairDipAngle: return "PairDipAngle";
225 case kPairCosThetaStar: return "PairCosThetaStar";
226 case kPairQInv: return "PairQInv";
227 case kPairAngleToLeading: return "PairAngleToLeading";
228 case kEventLeadingPt: return "EventLeadingPt";
229 case kEventMult: return "EventMult";
230 case kEventMultESDCuts: return "EventMultESDCuts";
231 case kEventVz: return "EventVz";
232 default: return "Undefined";
236 //_____________________________________________________________________________
237 void AliRsnValue::AssignTarget()
240 // This method assigns the target to be expected by this object
241 // in the computation, depending on its type chosen in the enum.
244 switch (fValueType) {
245 // track related values
249 SetTargetType(AliRsnTarget::kDaughter); // end of track-related values
251 // pair related values
260 case kPairInvMassRes:
270 case kPairCosThetaStar:
272 case kPairAngleToLeading:
273 SetTargetType(AliRsnTarget::kMother); // end of pair-related values
275 // event related values
276 case kEventLeadingPt:
278 case kEventMultESDCuts:
280 SetTargetType(AliRsnTarget::kEvent); // end of event-related values
284 SetTargetType(AliRsnTarget::kTargetTypes); // undefined targets
288 //_____________________________________________________________________________
289 Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC)
292 // Evaluation of the required value.
293 // Checks that the passed object is of the right type
294 // and if this check is successful, computes the required value.
295 // The output of the function tells if computing was successful,
296 // and the values must be taken with GetValue().
299 // cast the input to the allowed types
300 AliRsnDaughter *daughter = dynamic_cast<AliRsnDaughter*>(object);
301 AliRsnMother *mother = dynamic_cast<AliRsnMother*>(object);
304 TLorentzVector pRec; // 4-momentum for single track or pair sum (reco)
305 TLorentzVector pSim; // 4-momentum for single track or pair sum (MC)
306 TLorentzVector pRec0; // 4-momentum of first daughter (reco)
307 TLorentzVector pSim0; // 4-momentum of first daughter (MC)
308 TLorentzVector pRec1; // 4-momentum of second daughter (reco)
309 TLorentzVector pSim1; // 4-momentum of second daughter (MC)
311 // check that the input object is the correct class type
312 switch (fTargetType) {
313 case AliRsnTarget::kDaughter:
315 pRec = daughter->Psim();
316 pSim = daughter->Prec();
318 AliError(Form("[%s] expected: AliRsnDaughter, passed: [%s]", GetName(), object->ClassName()));
322 case AliRsnTarget::kMother:
324 pRec = mother->Sum();
325 pSim = mother->SumMC();
326 pRec0 = mother->GetDaughter(0)->Prec();
327 pRec1 = mother->GetDaughter(1)->Prec();
328 pSim0 = mother->GetDaughter(0)->Psim();
329 pSim1 = mother->GetDaughter(1)->Psim();
331 AliError(Form("[%s] expected: AliRsnMother, passed: [%s]", GetName(), object->ClassName()));
335 case AliRsnTarget::kEvent:
336 if (!AliRsnTarget::GetCurrentEvent()) {
337 AliError(Form("[%s] expected: AliRsnEvent, passed: [%s]", GetName(), object->ClassName()));
342 AliError(Form("[%s] Wrong type", GetName()));
346 // cast the support object to the types which could be needed
347 AliESDtrackCuts *esdCuts = dynamic_cast<AliESDtrackCuts*>(fSupportObject);
348 AliRsnPairDef *pairDef = dynamic_cast<AliRsnPairDef*>(fSupportObject);
350 // compute value depending on type
351 switch (fValueType) {
353 fComputedValue = useMC ? pSim.Mag() : pRec.Mag();
356 fComputedValue = useMC ? pSim.Perp() : pRec.Perp();
359 fComputedValue = useMC ? pSim.Eta() : pRec.Eta();
362 fComputedValue = useMC ? pSim0.Mag() : pRec0.Mag();
365 fComputedValue = useMC ? pSim1.Mag() : pRec1.Mag();
368 fComputedValue = useMC ? pSim0.Perp() : pRec0.Perp();
371 fComputedValue = useMC ? pSim1.Perp() : pRec1.Perp();
374 fComputedValue = useMC ? pSim0.Z() : pRec0.Z();
377 fComputedValue = useMC ? pSim1.Z() : pRec1.Z();
380 fComputedValue = useMC ? pSim.M() : pRec.M();
382 case kPairInvMassRes:
383 fComputedValue = (pSim.M() - pRec.M()) / pSim.M();
386 fComputedValue = useMC ? pSim.Perp() : pRec.Perp();
389 fComputedValue = useMC ? pSim.Eta() : pRec.Eta();
392 // for this computation, replace the computed mass with the default mass
393 // for doing this, an initialized pairDef is required to get the mass
395 AliError(Form("[%s] Required a correctly initialized PairDef to compute this value", GetName()));
396 fComputedValue = 1E+10;
399 pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass());
400 pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass());
401 fComputedValue = useMC ? pSim.Mt() : pRec.Mt();
405 // for this computation, replace the computed mass with the default mass
406 // for doing this, an initialized pairDef is required to get the mass
408 AliError(Form("[%s] Required a correctly initialized PairDef to compute this value", GetName()));
409 fComputedValue = 1E+10;
412 pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass());
413 pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass());
414 fComputedValue = useMC ? pSim.Rapidity() : pRec.Rapidity();
418 fComputedValue = useMC ? pSim.Phi() : pRec.Phi();
422 fComputedValue = TMath::Abs(pSim0.Perp() - pSim1.Perp());
423 fComputedValue /= TMath::Abs(pSim0.Perp() + pSim1.Perp());
425 fComputedValue = TMath::Abs(pRec0.Perp() - pRec1.Perp());
426 fComputedValue /= TMath::Abs(pRec0.Perp() + pRec1.Perp());
430 fComputedValue = useMC ? pSim0.Angle(pSim1.Vect()) : pRec0.Angle(pRec1.Vect());
431 fComputedValue = TMath::Abs(TMath::Cos(fComputedValue));
433 case kPairCosThetaStar:
434 fComputedValue = mother->CosThetaStar(useMC);
439 fComputedValue = useMC ? pSim0.M() : pRec0.M();
441 case kPairAngleToLeading: {
442 AliRsnEvent *event = AliRsnTarget::GetCurrentEvent();
443 int ID1 = (mother->GetDaughter(0))->GetID();
444 int ID2 = (mother->GetDaughter(1))->GetID();
445 //int leadingID = event->SelectLeadingParticle(0);
446 Int_t leadingID = event->GetLeadingParticleID();
447 if (leadingID == ID1 || leadingID == ID2) return kFALSE;
448 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
449 AliVParticle *ref = leadingPart.GetRef();
450 fComputedValue = ref->Phi() - mother->Sum().Phi();
451 //return angle w.r.t. leading particle in the range -pi/2, 3/2pi
452 while (fComputedValue >= TMath::Pi()) fComputedValue -= 2 * TMath::Pi();
453 while (fComputedValue < -0.5 * TMath::Pi()) fComputedValue += 2 * TMath::Pi();
454 //Printf("%g", fComputedValue);
458 fComputedValue = (Double_t)AliRsnTarget::GetCurrentEvent()->GetMultiplicity(0x0);
460 case kEventMultESDCuts:
461 // this value requires an initialized ESDtrackCuts
463 AliError(Form("[%s] Required a correctly initialized ESDtrackCuts to compute this value", GetName()));
464 fComputedValue = 1E+10;
467 fComputedValue = (Double_t)AliRsnTarget::GetCurrentEvent()->GetMultiplicity(esdCuts);
469 case kEventLeadingPt: {
470 int leadingID = AliRsnTarget::GetCurrentEvent()->GetLeadingParticleID(); //fEvent->SelectLeadingParticle(0);
471 if (leadingID >= 0) {
472 AliRsnDaughter leadingPart = AliRsnTarget::GetCurrentEvent()->GetDaughter(leadingID);
473 AliVParticle *ref = leadingPart.GetRef();
474 fComputedValue = ref->Pt();
475 } else fComputedValue = 0;
479 fComputedValue = AliRsnTarget::GetCurrentEvent()->GetRef()->GetPrimaryVertex()->GetZ();
482 AliError(Form("[%s] Invalid value type for this computation", GetName()));
489 //_____________________________________________________________________________
490 void AliRsnValue::Print(Option_t * /*option */) const
493 // Print informations about this object
496 AliInfo("=== VALUE INFO =================================================");
497 AliInfo(Form(" Name : %s", GetName()));
498 AliInfo(Form(" Type : %s", GetValueTypeName()));
499 AliInfo(Form(" Current computed value: %f", fComputedValue));
501 for (i = 0; i < fBinArray.GetSize(); i++) {
502 AliInfo(Form(" Bin limit #%d = %f", i, fBinArray[i]));
504 AliInfo(Form(" Support object : %s", (fSupportObject ? fSupportObject->ClassName() : " NO SUPPORT")));
505 AliInfo("=== END VALUE INFO =============================================");