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);
150 fSupportObject = copy.fSupportObject;
151 fValueType = copy.fValueType;
156 //_____________________________________________________________________________
157 const char* AliRsnValueStd::GetValueTypeName() const
160 // This method returns a string to give a name to each possible
161 // computation value.
164 switch (fValueType) {
165 case kTrackP: return "SingleTrackPtot";
166 case kTrackPt: return "SingleTrackPt";
167 case kTrackPtpc: return "SingleTrackPtpc";
168 case kTrackEta: return "SingleTrackEta";
169 case kTrackY: return "SingleTrackRapidity";
170 case kTrackITSsignal: return "SingleTrackITSsignal";
171 case kTrackTPCsignal: return "SingleTrackTPCsignal";
172 case kTrackTOFsignal: return "SingleTrackTOFsignal";
173 case kTrackTOFbeta: return "SingleTrackTOFbeta";
174 case kTrackLength: return "SingleTrackLength";
176 case kPairP1: return "PairPtotDaughter1";
177 case kPairP2: return "PairPtotDaughter2";
178 case kPairP1t: return "PairPtDaughter1";
179 case kPairP2t: return "PairPtDaughter2";
180 case kPairP1z: return "PairPzDaughter1";
181 case kPairP2z: return "PairPzDaughter2";
182 case kPairInvMass: return "PairInvMass";
183 case kPairInvMassMC: return "PairInvMassMC";
184 case kPairInvMassRes: return "PairInvMassResolution";
185 case kPairPt: return "PairPt";
186 case kPairPz: return "PairPz";
187 case kPairEta: return "PairEta";
188 case kPairMt: return "PairMt";
189 case kPairY: return "PairY";
190 case kPairPhi: return "PairPhi";
191 case kPairPhiMC: return "PairPhiMC";
192 case kPairPtRatio: return "PairPtRatio";
193 case kPairDipAngle: return "PairDipAngle";
194 case kPairCosThetaStar: return "PairCosThetaStar";
195 case kPairQInv: return "PairQInv";
196 case kPairAngleToLeading: return "PairAngleToLeading";
198 case kEventLeadingPt: return "EventLeadingPt";
199 case kEventMult: return "EventMult";
200 case kEventMultMC: return "EventMultMC";
201 case kEventMultESDCuts: return "EventMultESDCuts";
202 case kEventMultSPD: return "EventMultSPD";
203 case kEventVz: return "EventVz";
204 case kEventCentralityV0: return "EventCentralityV0";
205 case kEventCentralityTrack: return "EventCentralityTrack";
206 case kEventCentralityCL1: return "EventCentralityCL1";
207 default: return "Undefined";
211 //_____________________________________________________________________________
212 Bool_t AliRsnValueStd::Eval(TObject *object, Bool_t useMC)
215 // Evaluation of the required value.
216 // Checks that the passed object is of the right type
217 // and if this check is successful, computes the required value.
218 // The output of the function tells if computing was successful,
219 // and the values must be taken with GetValue().
224 const Double_t fgkVeryBig = 1E20;
226 Int_t leadingID = -1;
227 ULong_t status = 0x0;
229 // coherence check, which also casts object
230 // to AliRsnTarget data members and returns kFALSE
231 // in case the object is NULL
232 if (!TargetOK(object)) return kFALSE;
234 // these variables are initialized
235 // from the target object, once it
236 // is casted to one of the expected
237 // types (daughter/mother/event)
238 // -- not all are initialized always
239 TLorentzVector pRec; // 4-momentum for single track or pair sum (reco)
240 TLorentzVector pSim; // 4-momentum for single track or pair sum (MC)
241 TLorentzVector pRec0; // 4-momentum of first daughter (reco)
242 TLorentzVector pSim0; // 4-momentum of first daughter (MC)
243 TLorentzVector pRec1; // 4-momentum of second daughter (reco)
244 TLorentzVector pSim1; // 4-momentum of second daughter (MC)
245 AliESDEvent *esdev = 0x0; // reference ESD event
246 AliAODEvent *aodev = 0x0; // reference AOD event
247 AliESDtrack *esdt = 0x0; // reference ESD track
248 AliAODTrack *aodt = 0x0; // reference AOD track
249 AliAODPid *pidObj = 0x0; // reference AOD PID object
251 // initialize the above 4-vectors according to the
252 // expected target type (which has been checked above)
253 // in particular, the 'fEvent' data member of base AliRsnTarget
254 // will be *always* well initialized if the TargetOK() returns kTRUE
255 switch (fTargetType) {
256 case AliRsnTarget::kDaughter:
257 pRec = fDaughter->Prec();
258 pSim = fDaughter->Psim();
259 esdt = fDaughter->GetRefESDtrack();
260 aodt = fDaughter->GetRefAODtrack();
261 if (aodt) pidObj = aodt->GetDetPid();
263 case AliRsnTarget::kMother:
264 pRec = fMother->Sum();
265 pSim = fMother->SumMC();
266 pRec0 = fMother->GetDaughter(0)->Prec();
267 pRec1 = fMother->GetDaughter(1)->Prec();
268 pSim0 = fMother->GetDaughter(0)->Psim();
269 pSim1 = fMother->GetDaughter(1)->Psim();
271 case AliRsnTarget::kEvent:
274 AliError(Form("[%s] Wrong type", GetName()));
277 leadingID = fEvent->GetLeadingParticleID();
278 esdev = fEvent->GetRefESD();
279 aodev = fEvent->GetRefAOD();
281 // if leading index is negative, assume that leading particle was not searched
282 // and then searches for it
284 fEvent->SelectLeadingParticle();
285 leadingID = fEvent->GetLeadingParticleID();
288 if (esdt) status = esdt->GetStatus();
289 if (aodt) status = aodt->GetStatus();
291 // these objects are all types of supports
292 // which could be needed for some values
293 AliRsnPairDef *pairDef = 0x0;
294 AliRsnDaughterDef *daughterDef = 0x0;
295 AliESDpid *esdPID = 0x0;
296 if (fSupportObject) {
297 if (fSupportObject->InheritsFrom(AliRsnPairDef ::Class())) pairDef = static_cast<AliRsnPairDef*>(fSupportObject);
298 if (fSupportObject->InheritsFrom(AliRsnDaughterDef::Class())) daughterDef = static_cast<AliRsnDaughterDef*>(fSupportObject);
299 if (fSupportObject->InheritsFrom(AliESDpid ::Class())) esdPID = static_cast<AliESDpid*>(fSupportObject);
302 // compute value depending on types in the enumeration
303 // if the type does not match any available choice, or if
304 // the computation is not doable due to any problem
305 // (not initialized support object, wrong values, risk of floating point errors)
306 // the method returng kFALSE and sets the computed value to a meaningless number
307 switch (fValueType) {
311 fComputedValue = useMC ? pSim.Vect().Mag() : pRec.Vect().Mag();
315 // transverse momentum
316 fComputedValue = useMC ? pSim.Perp() : pRec.Perp();
320 // transverse momentum
322 if (esdt->GetInnerParam()) {
323 fComputedValue = esdt->GetInnerParam()->P();
326 AliError(Form("[%s] TPC inner param is not initialized", GetName()));
330 else if (aodt && pidObj) {
331 fComputedValue = pidObj->GetTPCmomentum();
334 AliError(Form("[%s] Cannot retrieve TPC momentum", GetName()));
340 fComputedValue = useMC ? pSim.Eta() : pRec.Eta();
344 // rapidity (requires an AliRsnDaughterDef support)
346 pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), daughterDef->GetMass());
347 pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), daughterDef->GetMass());
348 fComputedValue = useMC ? pSim.Rapidity() : pRec.Rapidity();
352 AliError(Form("[%s] Required a correctly initialized AliRsnDaughterDef support object to compute this value", GetName()));
353 fComputedValue = fgkVeryBig;
356 case kTrackITSsignal:
358 // ITS signal (successful only for tracks)
359 // works only if the status is OK
360 if ((status & AliESDtrack::kITSin) == 0) {
361 AliDebug(AliLog::kDebug + 2, "Rejecting non-ITS track");
365 fComputedValue = esdt->GetITSsignal();
368 else if (aodt && pidObj) {
369 fComputedValue = pidObj->GetITSsignal();
373 AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName()));
374 fComputedValue = fgkVeryBig;
377 case kTrackTPCsignal:
379 // TPC signal (successful only for tracks)
380 // works only if the status is OK
381 if ((status & AliESDtrack::kTPCin) == 0) {
382 AliDebug(AliLog::kDebug + 2, "Rejecting non-TPC track");
386 fComputedValue = esdt->GetTPCsignal();
389 else if (aodt && pidObj) {
390 fComputedValue = pidObj->GetTPCsignal();
394 AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName()));
395 fComputedValue = fgkVeryBig;
398 case kTrackTOFsignal:
400 // TOF signal (successful only for tracks, for ESD requires an AliESDpid support)
401 // works only if the status is OK
402 if ((status & AliESDtrack::kTOFout) == 0 || (status & AliESDtrack::kTIME) == 0) {
403 AliDebug(AliLog::kDebug + 2, "Rejecting non-TOF track");
407 if (!esdPID || !esdev) {
408 AliError(Form("[%s] Required a correctly initialized AliRsnEvent and AliESDpid support object to compute this value with ESDs", GetName()));
409 fComputedValue = fgkVeryBig;
413 esdPID->SetTOFResponse(esdev, AliESDpid::kTOF_T0);
414 fComputedValue = (esdt->GetTOFsignal() - esdPID->GetTOFResponse().GetStartTime(esdt->P()));
418 else if (aodt && pidObj) {
419 fComputedValue = pidObj->GetTOFsignal();
423 AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName()));
424 fComputedValue = fgkVeryBig;
429 // TOF beta (successful only for tracks, for ESD requires an AliESDpid support)
432 AliError(Form("[%s] Required a correctly initialized AliESDpid support object to compute this value with ESDs", GetName()));
433 fComputedValue = fgkVeryBig;
437 AliError(Form("[%s] Required a correctly initialized AliESDEvent to compute this value with ESDs", GetName()));
438 fComputedValue = fgkVeryBig;
442 esdPID->SetTOFResponse(esdev, AliESDpid::kTOF_T0);
443 fComputedValue = esdt->GetIntegratedLength();
444 time = (esdt->GetTOFsignal() - esdPID->GetTOFResponse().GetStartTime(esdt->P()));
446 fComputedValue /= time;
447 fComputedValue /= 2.99792458E-2;
450 fComputedValue = fgkVeryBig;
456 AliError(Form("[%s] Length information not available in AODs", GetName()));
457 fComputedValue = fgkVeryBig;
462 // integrated length (computed only on ESDs)
464 fComputedValue = esdt->GetIntegratedLength();
468 AliError(Form("[%s] Length information not available in AODs", GetName()));
469 fComputedValue = fgkVeryBig;
472 //---------------------------------------------------------------------------------------------------------------------
475 // momentum of first daughter (which matches definition #1 in pairDef)
476 fComputedValue = useMC ? pSim0.Mag() : pRec0.Mag();
480 // momentum of second daughter (which matches definition #2 in pairDef)
481 fComputedValue = useMC ? pSim1.Mag() : pRec1.Mag();
485 // transverse momentum of first daughter
486 fComputedValue = useMC ? pSim0.Perp() : pRec0.Perp();
490 // transverse momentum of second daughter
491 fComputedValue = useMC ? pSim1.Perp() : pRec1.Perp();
495 // longitudinal momentum of first daughter
496 fComputedValue = useMC ? pSim0.Z() : pRec0.Z();
500 // longitudinal momentum of second daughter
501 fComputedValue = useMC ? pSim1.Z() : pRec1.Z();
506 fComputedValue = useMC ? pSim.M() : pRec.M();
508 case kPairInvMassRes:
510 // invariant mass resolution (requires MC)
511 if (TMath::Abs(pSim.M()) > 0.0) {
512 fComputedValue = (pSim.M() - pRec.M()) / pSim.M();
516 AliError(Form("[%s] Caught a null MC mass", GetName()));
521 // total transverse momentum
522 fComputedValue = useMC ? pSim.Perp() : pRec.Perp();
527 fComputedValue = useMC ? pSim.Eta() : pRec.Eta();
531 // transverse mass (requires an AliRsnPairDef to get mass hypothesis)
533 pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass());
534 pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass());
535 fComputedValue = useMC ? pSim.Mt() : pRec.Mt();
539 AliError(Form("[%s] Required a correctly initialized AliRsnPairDef support object to compute this value", GetName()));
540 fComputedValue = fgkVeryBig;
545 // rapidity (requires an AliRsnPairDef to get mass hypothesis)
547 pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass());
548 pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass());
549 fComputedValue = useMC ? pSim.Rapidity() : pRec.Rapidity();
553 AliError(Form("[%s] Required a correctly initialized AliRsnPairDef support object to compute this value", GetName()));
554 fComputedValue = fgkVeryBig;
559 // phi angle of total momentum
560 fComputedValue = useMC ? pSim.Phi() : pRec.Phi();
564 // ratio of relative sum and difference of daughter transverse momenta
566 fComputedValue = TMath::Abs(pSim0.Perp() - pSim1.Perp());
567 fComputedValue /= TMath::Abs(pSim0.Perp() + pSim1.Perp());
569 fComputedValue = TMath::Abs(pRec0.Perp() - pRec1.Perp());
570 fComputedValue /= TMath::Abs(pRec0.Perp() + pRec1.Perp());
575 // dip-angle in the transverse-Z plane
576 // (used to check conversion electrons)
578 fComputedValue = pSim0.Perp() * pSim1.Perp() + pSim0.Z() * pSim1.Z();
579 fComputedValue /= pSim0.Mag() * pSim1.Mag();
581 fComputedValue = pRec0.Perp() * pRec1.Perp() + pRec0.Z() * pRec1.Z();
582 fComputedValue /= pRec0.Mag() * pRec1.Mag();
584 fComputedValue = TMath::Abs(TMath::ACos(fComputedValue));
586 case kPairCosThetaStar:
588 // cosine of theta star angle
589 // (= angle of first daughter to the total momentum, in resonance rest frame)
590 fComputedValue = fMother->CosThetaStar(useMC);
597 fComputedValue = useMC ? pSim0.M() : pRec0.M();
599 case kPairAngleToLeading:
601 // angle w.r. to leading particle (if any)
602 fComputedValue = fMother->AngleToLeading(success);
604 //---------------------------------------------------------------------------------------------------------------------
607 // multiplicity of tracks
608 fComputedValue = (Double_t)fEvent->GetMultiplicityFromTracks();
609 return (fComputedValue >= 0);
612 // multiplicity of MC tracks
613 fComputedValue = (Double_t)fEvent->GetMultiplicityFromMC();
614 return (fComputedValue >= 0);
615 case kEventMultESDCuts:
617 // multiplicity of good quality tracks
618 fComputedValue = fEvent->GetMultiplicityFromESDCuts();
619 return (fComputedValue >= 0);
622 // multiplicity of good quality tracks
623 fComputedValue = fEvent->GetMultiplicityFromSPD();
624 return (fComputedValue >= 0);
625 case kEventLeadingPt:
627 // transverse momentum of leading particle
628 if (leadingID >= 0) {
629 AliRsnDaughter leadingPart = fEvent->GetDaughter(leadingID);
630 AliVParticle *ref = leadingPart.GetRef();
631 fComputedValue = ref->Pt();
634 AliError(Form("[%s] Leading ID has bad value (%d)", GetName(), leadingID));
639 // Z position of primary vertex
640 fComputedValue = fEvent->GetRef()->GetPrimaryVertex()->GetZ();
642 case kEventCentralityV0:
644 // centrality using V0 method
646 AliCentrality *centrality = esdev->GetCentrality();
647 fComputedValue = centrality->GetCentralityPercentile("V0M");
650 AliCentrality *centrality = aodev->GetCentrality();
651 fComputedValue = centrality->GetCentralityPercentile("V0M");
654 AliError(Form("[%s] Neither the ESD nor the AOD events are initialized", GetName()));
657 case kEventCentralityTrack:
659 // centrality using tracks method
661 AliCentrality *centrality = esdev->GetCentrality();
662 fComputedValue = centrality->GetCentralityPercentile("TRK");
665 AliCentrality *centrality = aodev->GetCentrality();
666 fComputedValue = centrality->GetCentralityPercentile("TRK");
669 AliError(Form("[%s] Neither the ESD nor the AOD events are initialized", GetName()));
672 case kEventCentralityCL1:
674 // centrality using CL1 method
676 AliCentrality *centrality = esdev->GetCentrality();
677 fComputedValue = centrality->GetCentralityPercentile("CL1");
680 AliCentrality *centrality = aodev->GetCentrality();
681 fComputedValue = centrality->GetCentralityPercentile("CL1");
684 AliError(Form("[%s] Neither the ESD nor the AOD events are initialized", GetName()));
688 AliError(Form("[%s] Invalid value type for this computation", GetName()));
693 //_____________________________________________________________________________
694 void AliRsnValueStd::Print(Option_t *option) const
697 // Print informations about this object
700 AliInfo("=== VALUE INFO =================================================");
701 AliInfo(Form(" Name : %s", GetName()));
702 AliInfo(Form(" Type : %s", GetValueTypeName()));
703 AliInfo(Form(" Current computed value: %f", fComputedValue));
704 if (!strcmp(option, "BINS")) {
706 for (i = 0; i < fBinArray.GetSize(); i++) {
707 AliInfo(Form(" Bin limit #%03d = %f", i, fBinArray[i]));
710 AliInfo(Form(" Support object : %s", (fSupportObject ? fSupportObject->ClassName() : " NO SUPPORT")));
711 AliInfo("=== END VALUE INFO =============================================");
714 //_____________________________________________________________________________
715 RSNTARGET AliRsnValueStd::TargetType(EValueType type)
718 // This method assigns the target to be expected by this object
719 // in the computation, depending on its type chosen in the enum.
722 if (type < kTrackValues)
723 return AliRsnTarget::kDaughter;
724 else if (type < kPairValues)
725 return AliRsnTarget::kMother;
727 return AliRsnTarget::kEvent;