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 implements a candidate resonance. It has two pointers to its
19 // two candidate daughters, whose 4-momenta are combined to obtain the mother
20 // invariant mass and other kinematical quantities.
21 // This class contains also some methods used to compute kinematical relations
22 // between the candidate resonance and other particles.
24 // authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
25 // M. Vala (martin.vala@cern.ch)
27 ////////////////////////////////////////////////////////////////////////////////
29 #include <Riostream.h>
32 #include "AliAODMCParticle.h"
33 #include "AliMCParticle.h"
34 #include "AliRsnDaughter.h"
35 #include "AliRsnEvent.h"
37 #include "AliRsnMother.h"
39 ClassImp(AliRsnMother)
41 //_____________________________________________________________________________
42 AliRsnMother::AliRsnMother(const AliRsnMother &obj) :
44 fRefEvent(obj.fRefEvent),
50 // Does not duplicate pointers.
54 for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i];
57 //_____________________________________________________________________________
58 AliRsnMother& AliRsnMother::operator=(const AliRsnMother &obj)
61 // Assignment operator.
62 // Does not duplicate pointers.
70 for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i];
72 fRefEvent = obj.fRefEvent;
77 //_____________________________________________________________________________
78 AliRsnMother::~AliRsnMother()
82 // Does nothing, since pointers are not created in this class.
86 //_____________________________________________________________________________
87 Int_t AliRsnMother::CommonMother(Int_t &m0, Int_t &m1) const
90 // If MC info is available, checks if the two tracks in the pair have the same mother.
91 // If the mother label is the same, the function returns the PDG code of mother,
92 // otherwise it returns 0.
93 // The two arguments passed by reference contain the GEANT labels of the mother
94 // of the two particles to which the two daughters point. This is for being able
95 // to check if they are really coming from a resonance (indexes >= 0) or not.
98 // if MC info is not available, the check can't be done
99 if (!fDaughter[0]->GetRefMC() || !fDaughter[1]->GetRefMC()) {
100 AliDebug(AliLog::kDebug, "MC Info absent --> cannot check common mother");
104 // check that labels are the same
107 if (fDaughter[0]->IsESD() && fDaughter[1]->IsESD()) {
108 if (fDaughter[0]->GetRefMCESD() && fDaughter[1]->GetRefMCESD()) {
109 m0 = fDaughter[0]->GetRefMCESD()->Particle()->GetFirstMother();
110 m1 = fDaughter[1]->GetRefMCESD()->Particle()->GetFirstMother();
113 if (fDaughter[0]->IsAOD() && fDaughter[1]->IsAOD()) {
114 if (fDaughter[0]->GetRefMCAOD() && fDaughter[1]->GetRefMCAOD()) {
115 m0 = fDaughter[0]->GetRefMCAOD()->GetMother();
116 m1 = fDaughter[1]->GetRefMCAOD()->GetMother();
120 // decide the answer depending on the two mother labels
124 return TMath::Abs(fDaughter[0]->GetMotherPDG());
127 //_____________________________________________________________________________
128 void AliRsnMother::ComputeSum(Double_t mass0, Double_t mass1)
131 // Sets the masses for the 4-momenta of the daughters and then
132 // sums them, taking into account that the space part is set to
133 // each of them when the reference object is set (see AliRsnDaughter::SetRef)
136 fDaughter[0]->SetMass(mass0);
137 fDaughter[1]->SetMass(mass1);
139 fSum = fDaughter[0]->Prec() + fDaughter[1]->Prec();
140 fSumMC = fDaughter[0]->Psim() + fDaughter[1]->Psim();
143 //_____________________________________________________________________________
144 void AliRsnMother::ResetPair()
147 // Resets the mother, zeroing all data members.
151 for (i = 0; i < 2; i++) fDaughter[i] = 0x0;
154 fSum .SetXYZM(0.0, 0.0, 0.0, 0.0);
155 fSumMC.SetXYZM(0.0, 0.0, 0.0, 0.0);
158 //_____________________________________________________________________________
159 Double_t AliRsnMother::AngleTo(AliRsnDaughter *track, Bool_t mc)
162 // Compute the angle betwee this and the passed object
163 // if second argument is kTRUE, use MC values.
166 TLorentzVector &me = (mc ? fSumMC : fSum);
167 TLorentzVector &he = track->P(mc);
169 return me.Angle(he.Vect());
172 //_____________________________________________________________________________
173 Double_t AliRsnMother::AngleToLeading(Bool_t &success)
176 // Compute the angle betwee this and the leading particls
177 // of the reference event (if this was set properly).
178 // In case one of the two daughters is the leading, return
179 // a meaningless value, in order to skip this pair.
180 // if second argument is kTRUE, use MC values.
188 Int_t id1 = fDaughter[0]->GetID();
189 Int_t id2 = fDaughter[1]->GetID();
190 Int_t idL = fRefEvent->GetLeadingParticleID();
192 if (id1 == idL || id2 == idL) {
197 AliRsnDaughter leading = fRefEvent->GetDaughter(idL);
198 AliVParticle *ref = leading.GetRef();
199 Double_t angle = ref->Phi() - fSum.Phi();
201 //return angle w.r.t. leading particle in the range -pi/2, 3/2pi
202 while (angle >= 1.5 * TMath::Pi()) angle -= 2 * TMath::Pi();
203 while (angle < -0.5 * TMath::Pi()) angle += 2 * TMath::Pi();
209 //_____________________________________________________________________________
210 Double_t AliRsnMother::CosThetaStar(Bool_t first, Bool_t useMC)
213 // Computes the cosine of theta*, which is the angle of one of the daughters
214 // with respect to the total momentum of the resonance, in its rest frame.
215 // The arguments are needed to choose which of the daughters one want to use
216 // and if reconstructed or MC momentum must be used.
217 // [Contribution from Z. Feckova]
220 TLorentzVector mother = (useMC ? fSumMC : fSum);
221 TLorentzVector daughter0 = (first ? fDaughter[0]->P(useMC) : fDaughter[1]->P(useMC));
222 TLorentzVector daughter1 = (first ? fDaughter[1]->P(useMC) : fDaughter[0]->P(useMC));
223 TVector3 momentumM(mother.Vect());
224 TVector3 normal(mother.Y() / momentumM.Mag(), -mother.X() / momentumM.Mag(), 0.0);
226 // Computes first the invariant mass of the mother
227 Double_t mass0 = fDaughter[0]->P(useMC).M();
228 Double_t mass1 = fDaughter[1]->P(useMC).M();
229 Double_t p0 = daughter0.Vect().Mag();
230 Double_t p1 = daughter1.Vect().Mag();
231 Double_t E0 = TMath::Sqrt(mass0 * mass0 + p0 * p0);
232 Double_t E1 = TMath::Sqrt(mass1 * mass1 + p1 * p1);
233 Double_t MotherMass = TMath::Sqrt((E0 + E1) * (E0 + E1) - (p0 * p0 + 2.0 * daughter0.Vect().Dot(daughter1.Vect()) + p1 * p1));
234 MotherMass = fSum.M();
236 // Computes components of beta
237 Double_t betaX = -mother.X() / mother.E();
238 Double_t betaY = -mother.Y() / mother.E();
239 Double_t betaZ = -mother.Z() / mother.E();
241 // Computes Lorentz transformation of the momentum of the first daughter
242 // into the rest frame of the mother and theta*
243 daughter0.Boost(betaX, betaY, betaZ);
244 TVector3 momentumD = daughter0.Vect();
246 Double_t cosThetaStar = normal.Dot(momentumD) / momentumD.Mag();
251 //_____________________________________________________________________________
252 void AliRsnMother::PrintInfo(const Option_t * /*option*/) const
255 // Print some info of the pair.
256 // The options are passed to the AliRsnDaughter::Print() method
259 AliInfo("======== BEGIN PAIR INFO ===========");
261 fDaughter[0]->Print();
263 fDaughter[1]->Print();
264 AliInfo("========= END PAIR INFO ===========");
267 //_____________________________________________________________________________
268 Bool_t AliRsnMother::CheckPair(Bool_t checkMC) const
271 // Checks that the pair is well initialized:
272 // - both daughters are good pointers
273 // - if MC is required, both daughters have a MC reference
276 if (!fDaughter[0] || !fDaughter[1]) {
277 AliError("One of the two tracks is NULL in this pair!");
282 if (fDaughter[0]->GetRefMC() == 0x0 || fDaughter[1]->GetRefMC() == 0x0) {
283 AliError("Required MC info but not all MC refs are available");