1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ////////////////////////////////////////////////////////////////////////////////
18 // This class contains all code which is used to compute any of the values
19 // which can be of interest within a resonance analysis. Besides the obvious
20 // invariant mass, it allows to compute other utility values on all possible
21 // targets, in order to allow a wide spectrum of binning and checks.
22 // When needed, this object can also define a binning in the variable which
23 // it is required to compute, which is used for initializing axes of output
24 // histograms (see AliRsnFunction).
25 // The value computation requires this object to be passed the object whose
26 // informations will be used. This object can be of any allowed input type
27 // (track, pair, event), then this class must inherit from AliRsnTarget.
28 // Then, when value computation is attempted, a check on target type is done
29 // and computation is successful only if expected target matches that of the
31 // In some cases, the value computation can require a support external object,
32 // which must then be passed to this class. It can be of any type inheriting
35 // authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
36 // M. Vala (martin.vala@cern.ch)
38 ////////////////////////////////////////////////////////////////////////////////
40 #include "AliESDtrackCuts.h"
41 #include "AliESDpid.h"
42 #include "AliAODPid.h"
43 #include "AliCentrality.h"
45 #include "AliRsnEvent.h"
46 #include "AliRsnDaughter.h"
47 #include "AliRsnMother.h"
48 #include "AliRsnPairDef.h"
49 #include "AliRsnDaughterDef.h"
51 #include "AliRsnValueStd.h"
53 ClassImp(AliRsnValueStd)
55 //_____________________________________________________________________________
56 AliRsnValueStd::AliRsnValueStd() :
58 fValueType(kValueTypes),
62 // Default constructor without arguments.
63 // Initialize data members to meaningless values.
64 // This method is provided for ROOT streaming,
65 // but should never be used directly by a user.
69 //_____________________________________________________________________________
70 AliRsnValueStd::AliRsnValueStd
71 (const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) :
77 // Main constructor (version 1).
78 // This constructor defines in meaningful way all data members,
79 // and defined a fixed binnings, subdividing the specified interval
80 // into that many bins as specified in the integer argument.
82 // This method is also the entry point for all instances
83 // of this class which don't need to do binning (e.g.: TNtuple inputs),
84 // since arguments 3 to 5 have default values which don't create any
85 // binning array, in order not to allocate memory when this is useless.
88 SetTargetType(TargetType(type));
89 SetBins(nbins, min, max);
92 //_____________________________________________________________________________
93 AliRsnValueStd::AliRsnValueStd
94 (const char *name, EValueType type, Double_t min, Double_t max, Double_t step) :
100 // Main constructor (version 2).
101 // This constructor defines in meaningful way all data members
102 // and creates enough equal bins of the specified size to cover
103 // the required interval.
106 SetTargetType(TargetType(type));
107 SetBins(min, max, step);
110 //_____________________________________________________________________________
111 AliRsnValueStd::AliRsnValueStd
112 (const char *name, EValueType type, Int_t nbins, Double_t *array) :
118 // Main constructor (version 3).
119 // This constructor defines in meaningful way all data members
120 // and creates a set of variable bins delimited by the passed array.
123 SetTargetType(TargetType(type));
124 SetBins(nbins, array);
127 //_____________________________________________________________________________
128 AliRsnValueStd::AliRsnValueStd(const AliRsnValueStd& copy) :
130 fValueType(copy.fValueType),
131 fSupportObject(copy.fSupportObject)
135 // Duplicates the binning array and copies all settings.
139 //_____________________________________________________________________________
140 AliRsnValueStd& AliRsnValueStd::operator=(const AliRsnValueStd& copy)
143 // Assignment operator.
144 // Works like copy constructor.
147 AliRsnValue::operator=(copy);
149 fSupportObject = copy.fSupportObject;
150 fValueType = copy.fValueType;
155 //_____________________________________________________________________________
156 const char* AliRsnValueStd::GetValueTypeName() const
159 // This method returns a string to give a name to each possible
160 // computation value.
163 switch (fValueType) {
164 case kTrackP: return "SingleTrackPtot";
165 case kTrackPt: return "SingleTrackPt";
166 case kTrackPtpc: return "SingleTrackPtpc";
167 case kTrackEta: return "SingleTrackEta";
168 case kTrackY: return "SingleTrackRapidity";
169 case kTrackITSsignal: return "SingleTrackITSsignal";
170 case kTrackTPCsignal: return "SingleTrackTPCsignal";
171 case kTrackTOFsignal: return "SingleTrackTOFsignal";
172 case kTrackTOFbeta: return "SingleTrackTOFbeta";
173 case kTrackLength: return "SingleTrackLength";
175 case kPairP1: return "PairPtotDaughter1";
176 case kPairP2: return "PairPtotDaughter2";
177 case kPairP1t: return "PairPtDaughter1";
178 case kPairP2t: return "PairPtDaughter2";
179 case kPairP1z: return "PairPzDaughter1";
180 case kPairP2z: return "PairPzDaughter2";
181 case kPairInvMass: return "PairInvMass";
182 case kPairInvMassMC: return "PairInvMassMC";
183 case kPairInvMassRes: return "PairInvMassResolution";
184 case kPairPt: return "PairPt";
185 case kPairPz: return "PairPz";
186 case kPairEta: return "PairEta";
187 case kPairMt: return "PairMt";
188 case kPairY: return "PairY";
189 case kPairPhi: return "PairPhi";
190 case kPairPhiMC: return "PairPhiMC";
191 case kPairPtRatio: return "PairPtRatio";
192 case kPairDipAngle: return "PairDipAngle";
193 case kPairCosThetaStar: return "PairCosThetaStar";
194 case kPairQInv: return "PairQInv";
195 case kPairAngleToLeading: return "PairAngleToLeading";
197 case kEventLeadingPt: return "EventLeadingPt";
198 case kEventMult: return "EventMult";
199 case kEventMultMC: return "EventMultMC";
200 case kEventMultESDCuts: return "EventMultESDCuts";
201 case kEventMultSPD: return "EventMultSPD";
202 case kEventVz: return "EventVz";
203 case kEventCentralityV0: return "EventCentralityV0";
204 case kEventCentralityTrack: return "EventCentralityTrack";
205 case kEventCentralityCL1: return "EventCentralityCL1";
206 default: return "Undefined";
210 //_____________________________________________________________________________
211 Bool_t AliRsnValueStd::Eval(TObject *object, Bool_t useMC)
214 // Evaluation of the required value.
215 // Checks that the passed object is of the right type
216 // and if this check is successful, computes the required value.
217 // The output of the function tells if computing was successful,
218 // and the values must be taken with GetValue().
223 const Double_t fgkVeryBig = 1E20;
225 Int_t leadingID = -1;
226 ULong_t status = 0x0;
228 // coherence check, which also casts object
229 // to AliRsnTarget data members and returns kFALSE
230 // in case the object is NULL
231 if (!TargetOK(object)) return kFALSE;
233 // these variables are initialized
234 // from the target object, once it
235 // is casted to one of the expected
236 // types (daughter/mother/event)
237 // -- not all are initialized always
238 TLorentzVector pRec; // 4-momentum for single track or pair sum (reco)
239 TLorentzVector pSim; // 4-momentum for single track or pair sum (MC)
240 TLorentzVector pRec0; // 4-momentum of first daughter (reco)
241 TLorentzVector pSim0; // 4-momentum of first daughter (MC)
242 TLorentzVector pRec1; // 4-momentum of second daughter (reco)
243 TLorentzVector pSim1; // 4-momentum of second daughter (MC)
244 AliESDEvent *esdev = 0x0; // reference ESD event
245 AliAODEvent *aodev = 0x0; // reference AOD event
246 AliESDtrack *esdt = 0x0; // reference ESD track
247 AliAODTrack *aodt = 0x0; // reference AOD track
248 AliAODPid *pidObj = 0x0; // reference AOD PID object
250 // initialize the above 4-vectors according to the
251 // expected target type (which has been checked above)
252 // in particular, the 'fEvent' data member of base AliRsnTarget
253 // will be *always* well initialized if the TargetOK() returns kTRUE
254 switch (fTargetType) {
255 case AliRsnTarget::kDaughter:
256 pRec = fDaughter->Prec();
257 pSim = fDaughter->Psim();
258 esdt = fDaughter->GetRefESDtrack();
259 aodt = fDaughter->GetRefAODtrack();
260 if (aodt) pidObj = aodt->GetDetPid();
262 case AliRsnTarget::kMother:
263 pRec = fMother->Sum();
264 pSim = fMother->SumMC();
265 pRec0 = fMother->GetDaughter(0)->Prec();
266 pRec1 = fMother->GetDaughter(1)->Prec();
267 pSim0 = fMother->GetDaughter(0)->Psim();
268 pSim1 = fMother->GetDaughter(1)->Psim();
270 case AliRsnTarget::kEvent:
273 AliError(Form("[%s] Wrong type", GetName()));
276 leadingID = fEvent->GetLeadingParticleID();
277 esdev = fEvent->GetRefESD();
278 aodev = fEvent->GetRefAOD();
280 // if leading index is negative, assume that leading particle was not searched
281 // and then searches for it
283 fEvent->SelectLeadingParticle();
284 leadingID = fEvent->GetLeadingParticleID();
287 if (esdt) status = esdt->GetStatus();
288 if (aodt) status = aodt->GetStatus();
290 // these objects are all types of supports
291 // which could be needed for some values
292 AliRsnPairDef *pairDef = 0x0;
293 AliRsnDaughterDef *daughterDef = 0x0;
294 AliESDpid *esdPID = 0x0;
295 if (fSupportObject) {
296 if (fSupportObject->InheritsFrom(AliRsnPairDef ::Class())) pairDef = static_cast<AliRsnPairDef*>(fSupportObject);
297 if (fSupportObject->InheritsFrom(AliRsnDaughterDef::Class())) daughterDef = static_cast<AliRsnDaughterDef*>(fSupportObject);
298 if (fSupportObject->InheritsFrom(AliESDpid ::Class())) esdPID = static_cast<AliESDpid*>(fSupportObject);
301 // compute value depending on types in the enumeration
302 // if the type does not match any available choice, or if
303 // the computation is not doable due to any problem
304 // (not initialized support object, wrong values, risk of floating point errors)
305 // the method returng kFALSE and sets the computed value to a meaningless number
306 switch (fValueType) {
310 fComputedValue = useMC ? pSim.Vect().Mag() : pRec.Vect().Mag();
314 // transverse momentum
315 fComputedValue = useMC ? pSim.Perp() : pRec.Perp();
319 // transverse momentum
321 if (esdt->GetInnerParam()) {
322 fComputedValue = esdt->GetInnerParam()->P();
325 AliError(Form("[%s] TPC inner param is not initialized", GetName()));
329 else if (aodt && pidObj) {
330 fComputedValue = pidObj->GetTPCmomentum();
333 AliError(Form("[%s] Cannot retrieve TPC momentum", GetName()));
339 fComputedValue = useMC ? pSim.Eta() : pRec.Eta();
343 // rapidity (requires an AliRsnDaughterDef support)
345 pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), daughterDef->GetMass());
346 pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), daughterDef->GetMass());
347 fComputedValue = useMC ? pSim.Rapidity() : pRec.Rapidity();
351 AliError(Form("[%s] Required a correctly initialized AliRsnDaughterDef support object to compute this value", GetName()));
352 fComputedValue = fgkVeryBig;
355 case kTrackITSsignal:
357 // ITS signal (successful only for tracks)
358 // works only if the status is OK
359 if ((status & AliESDtrack::kITSin) == 0) {
360 AliDebug(AliLog::kDebug + 2, "Rejecting non-ITS track");
364 fComputedValue = esdt->GetITSsignal();
367 else if (aodt && pidObj) {
368 fComputedValue = pidObj->GetITSsignal();
372 AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName()));
373 fComputedValue = fgkVeryBig;
376 case kTrackTPCsignal:
378 // TPC signal (successful only for tracks)
379 // works only if the status is OK
380 if ((status & AliESDtrack::kTPCin) == 0) {
381 AliDebug(AliLog::kDebug + 2, "Rejecting non-TPC track");
385 fComputedValue = esdt->GetTPCsignal();
388 else if (aodt && pidObj) {
389 fComputedValue = pidObj->GetTPCsignal();
393 AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName()));
394 fComputedValue = fgkVeryBig;
397 case kTrackTOFsignal:
399 // TOF signal (successful only for tracks, for ESD requires an AliESDpid support)
400 // works only if the status is OK
401 if ((status & AliESDtrack::kTOFout) == 0 || (status & AliESDtrack::kTIME) == 0) {
402 AliDebug(AliLog::kDebug + 2, "Rejecting non-TOF track");
406 if (!esdPID || !esdev) {
407 AliError(Form("[%s] Required a correctly initialized AliRsnEvent and AliESDpid support object to compute this value with ESDs", GetName()));
408 fComputedValue = fgkVeryBig;
412 esdPID->SetTOFResponse(esdev, AliESDpid::kTOF_T0);
413 fComputedValue = (esdt->GetTOFsignal() - esdPID->GetTOFResponse().GetStartTime(esdt->P()));
417 else if (aodt && pidObj) {
418 fComputedValue = pidObj->GetTOFsignal();
422 AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName()));
423 fComputedValue = fgkVeryBig;
428 // TOF beta (successful only for tracks, for ESD requires an AliESDpid support)
431 AliError(Form("[%s] Required a correctly initialized AliESDpid support object to compute this value with ESDs", GetName()));
432 fComputedValue = fgkVeryBig;
436 AliError(Form("[%s] Required a correctly initialized AliESDEvent to compute this value with ESDs", GetName()));
437 fComputedValue = fgkVeryBig;
441 esdPID->SetTOFResponse(esdev, AliESDpid::kTOF_T0);
442 fComputedValue = esdt->GetIntegratedLength();
443 time = (esdt->GetTOFsignal() - esdPID->GetTOFResponse().GetStartTime(esdt->P()));
445 fComputedValue /= time;
446 fComputedValue /= 2.99792458E-2;
449 fComputedValue = fgkVeryBig;
455 AliError(Form("[%s] Length information not available in AODs", GetName()));
456 fComputedValue = fgkVeryBig;
461 // integrated length (computed only on ESDs)
463 fComputedValue = esdt->GetIntegratedLength();
467 AliError(Form("[%s] Length information not available in AODs", GetName()));
468 fComputedValue = fgkVeryBig;
471 //---------------------------------------------------------------------------------------------------------------------
474 // momentum of first daughter (which matches definition #1 in pairDef)
475 fComputedValue = useMC ? pSim0.Mag() : pRec0.Mag();
479 // momentum of second daughter (which matches definition #2 in pairDef)
480 fComputedValue = useMC ? pSim1.Mag() : pRec1.Mag();
484 // transverse momentum of first daughter
485 fComputedValue = useMC ? pSim0.Perp() : pRec0.Perp();
489 // transverse momentum of second daughter
490 fComputedValue = useMC ? pSim1.Perp() : pRec1.Perp();
494 // longitudinal momentum of first daughter
495 fComputedValue = useMC ? pSim0.Z() : pRec0.Z();
499 // longitudinal momentum of second daughter
500 fComputedValue = useMC ? pSim1.Z() : pRec1.Z();
505 fComputedValue = useMC ? pSim.M() : pRec.M();
507 case kPairInvMassRes:
509 // invariant mass resolution (requires MC)
510 if (TMath::Abs(pSim.M()) > 0.0) {
511 fComputedValue = (pSim.M() - pRec.M()) / pSim.M();
515 AliError(Form("[%s] Caught a null MC mass", GetName()));
520 // total transverse momentum
521 fComputedValue = useMC ? pSim.Perp() : pRec.Perp();
526 fComputedValue = useMC ? pSim.Eta() : pRec.Eta();
530 // transverse mass (requires an AliRsnPairDef to get mass hypothesis)
532 pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass());
533 pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass());
534 fComputedValue = useMC ? pSim.Mt() : pRec.Mt();
538 AliError(Form("[%s] Required a correctly initialized AliRsnPairDef support object to compute this value", GetName()));
539 fComputedValue = fgkVeryBig;
544 // rapidity (requires an AliRsnPairDef to get mass hypothesis)
546 pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass());
547 pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass());
548 fComputedValue = useMC ? pSim.Rapidity() : pRec.Rapidity();
552 AliError(Form("[%s] Required a correctly initialized AliRsnPairDef support object to compute this value", GetName()));
553 fComputedValue = fgkVeryBig;
558 // phi angle of total momentum
559 fComputedValue = useMC ? pSim.Phi() : pRec.Phi();
563 // ratio of relative sum and difference of daughter transverse momenta
565 fComputedValue = TMath::Abs(pSim0.Perp() - pSim1.Perp());
566 fComputedValue /= TMath::Abs(pSim0.Perp() + pSim1.Perp());
568 fComputedValue = TMath::Abs(pRec0.Perp() - pRec1.Perp());
569 fComputedValue /= TMath::Abs(pRec0.Perp() + pRec1.Perp());
574 // dip-angle in the transverse-Z plane
575 // (used to check conversion electrons)
577 fComputedValue = pSim0.Perp() * pSim1.Perp() + pSim0.Z() * pSim1.Z();
578 fComputedValue /= pSim0.Mag() * pSim1.Mag();
580 fComputedValue = pRec0.Perp() * pRec1.Perp() + pRec0.Z() * pRec1.Z();
581 fComputedValue /= pRec0.Mag() * pRec1.Mag();
583 fComputedValue = TMath::Abs(TMath::ACos(fComputedValue));
585 case kPairCosThetaStar:
587 // cosine of theta star angle
588 // (= angle of first daughter to the total momentum, in resonance rest frame)
589 fComputedValue = fMother->CosThetaStar(useMC);
596 fComputedValue = useMC ? pSim0.M() : pRec0.M();
598 case kPairAngleToLeading:
600 // angle w.r. to leading particle (if any)
601 fComputedValue = fMother->AngleToLeading(success);
603 //---------------------------------------------------------------------------------------------------------------------
606 // multiplicity of tracks
607 fComputedValue = (Double_t)fEvent->GetMultiplicityFromTracks();
608 return (fComputedValue >= 0);
611 // multiplicity of MC tracks
612 fComputedValue = (Double_t)fEvent->GetMultiplicityFromMC();
613 return (fComputedValue >= 0);
614 case kEventMultESDCuts:
616 // multiplicity of good quality tracks
617 fComputedValue = fEvent->GetMultiplicityFromESDCuts();
618 return (fComputedValue >= 0);
621 // multiplicity of good quality tracks
622 fComputedValue = fEvent->GetMultiplicityFromSPD();
623 return (fComputedValue >= 0);
624 case kEventLeadingPt:
626 // transverse momentum of leading particle
627 if (leadingID >= 0) {
628 AliRsnDaughter leadingPart = fEvent->GetDaughter(leadingID);
629 AliVParticle *ref = leadingPart.GetRef();
630 fComputedValue = ref->Pt();
633 AliError(Form("[%s] Leading ID has bad value (%d)", GetName(), leadingID));
638 // Z position of primary vertex
639 fComputedValue = fEvent->GetRef()->GetPrimaryVertex()->GetZ();
641 case kEventCentralityV0:
643 // centrality using V0 method
645 AliCentrality *centrality = esdev->GetCentrality();
646 fComputedValue = centrality->GetCentralityPercentile("V0M");
649 AliCentrality *centrality = aodev->GetCentrality();
650 fComputedValue = centrality->GetCentralityPercentile("V0M");
653 AliError(Form("[%s] Neither the ESD nor the AOD events are initialized", GetName()));
656 case kEventCentralityTrack:
658 // centrality using tracks method
660 AliCentrality *centrality = esdev->GetCentrality();
661 fComputedValue = centrality->GetCentralityPercentile("TRK");
664 AliCentrality *centrality = aodev->GetCentrality();
665 fComputedValue = centrality->GetCentralityPercentile("TRK");
668 AliError(Form("[%s] Neither the ESD nor the AOD events are initialized", GetName()));
671 case kEventCentralityCL1:
673 // centrality using CL1 method
675 AliCentrality *centrality = esdev->GetCentrality();
676 fComputedValue = centrality->GetCentralityPercentile("CL1");
679 AliCentrality *centrality = aodev->GetCentrality();
680 fComputedValue = centrality->GetCentralityPercentile("CL1");
683 AliError(Form("[%s] Neither the ESD nor the AOD events are initialized", GetName()));
687 AliError(Form("[%s] Invalid value type for this computation", GetName()));
692 //_____________________________________________________________________________
693 void AliRsnValueStd::Print(Option_t *option) const
696 // Print informations about this object
699 AliInfo("=== VALUE INFO =================================================");
700 AliInfo(Form(" Name : %s", GetName()));
701 AliInfo(Form(" Type : %s", GetValueTypeName()));
702 AliInfo(Form(" Current computed value: %f", fComputedValue));
703 if (!strcmp(option, "BINS")) {
705 for (i = 0; i < fBinArray.GetSize(); i++) {
706 AliInfo(Form(" Bin limit #%03d = %f", i, fBinArray[i]));
709 AliInfo(Form(" Support object : %s", (fSupportObject ? fSupportObject->ClassName() : " NO SUPPORT")));
710 AliInfo("=== END VALUE INFO =============================================");
713 //_____________________________________________________________________________
714 RSNTARGET AliRsnValueStd::TargetType(EValueType type)
717 // This method assigns the target to be expected by this object
718 // in the computation, depending on its type chosen in the enum.
721 if (type < kTrackValues)
722 return AliRsnTarget::kDaughter;
723 else if (type < kPairValues)
724 return AliRsnTarget::kMother;
726 return AliRsnTarget::kEvent;