4 // Implementation of a pair of tracks, for several purposes
5 // - computing the total 4-momentum & inv. mass for output histos filling
6 // - evaluating cut checks on the pair of particles
7 // - evaluating any kind of kinematic value over their sum
9 // authors: Martin Vala (martin.vala@cern.ch)
10 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
12 #include <Riostream.h>
14 #include "AliAODMCParticle.h"
15 #include "AliMCParticle.h"
16 #include "AliRsnDaughter.h"
17 #include "AliRsnPairDef.h"
18 #include "AliRsnMother.h"
20 ClassImp(AliRsnMother)
22 //_____________________________________________________________________________
23 AliRsnMother::AliRsnMother() :
30 // Initializes all variables to meaningless values.
34 for (i = 0; i < 2; i++) fDaughter[i] = 0x0;
37 //_____________________________________________________________________________
38 AliRsnMother::AliRsnMother(const AliRsnMother &obj) :
46 // Initializes all variables to copy values.
47 // Does not duplicate pointers.
51 for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i];
54 //_____________________________________________________________________________
55 AliRsnMother& AliRsnMother::operator=(const AliRsnMother &obj)
58 // Assignment operator.
59 // Initializes all variables to copy values.
60 // Does not duplicate pointers.
68 for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i];
73 //_____________________________________________________________________________
74 AliRsnMother::~AliRsnMother()
78 // Does nothing, since pointers are not created in this class.
82 //_____________________________________________________________________________
83 Int_t AliRsnMother::CommonMother(Int_t &m0, Int_t &m1) const
86 // Checks if the two tracks in the pair have the same mother.
87 // This can be known if MC info is present.
88 // If the mother label is the same, rhe PDG code of the mother is returned,
89 // otherwise the method returns 0.
90 // In the two arguments passed by reference, the mothers of the two daghters are stored
93 // if MC info is not available, the pairs is not true by default
94 if (!fDaughter[0]->GetRefMC() || !fDaughter[1]->GetRefMC())
96 AliInfo("Cannot know if the pairs is true or not because MC Info is not present");
100 // check that labels are the same
103 if (fDaughter[0]->IsESD() && fDaughter[1]->IsESD() )
105 if (fDaughter[0]->GetRefMCESD() && fDaughter[1]->GetRefMCESD())
107 m0 = fDaughter[0]->GetRefMCESD()->Particle()->GetFirstMother();
108 m1 = fDaughter[1]->GetRefMCESD()->Particle()->GetFirstMother();
111 if (fDaughter[0]->IsAOD() && fDaughter[1]->IsAOD())
113 if (fDaughter[0]->GetRefMCAOD() && fDaughter[1]->GetRefMCAOD())
115 m0 = fDaughter[0]->GetRefMCAOD()->GetMother();
116 m1 = fDaughter[1]->GetRefMCAOD()->GetMother();
119 if (m0 != m1) return 0;
121 // if we reach this point, the two tracks have the same mother
122 // let's check now the PDG code of this common mother
123 return TMath::Abs(fDaughter[0]->GetMotherPDG());
126 //_____________________________________________________________________________
127 void AliRsnMother::SetDaughters
128 (AliRsnDaughter *d0, Double_t mass0, AliRsnDaughter *d1, Double_t mass1)
131 // Sets the pair defined in this usind tso passed daughters and two masses
132 // which will be assigned to them, in order to recompute their 4-momenta
133 // and sum them into the datamembers of this object.
136 if (d0) fDaughter[0] = d0;
137 if (d1) fDaughter[1] = d1;
139 if (!d0 || !d1) return;
141 fDaughter[0]->SetMass(mass0);
142 fDaughter[1]->SetMass(mass1);
144 fSum = fDaughter[0]->P(kFALSE) + fDaughter[1]->P(kFALSE);
145 fSumMC = fDaughter[0]->P(kTRUE) + fDaughter[1]->P(kTRUE);
148 //_____________________________________________________________________________
149 void AliRsnMother::ResetPair()
152 // Resets the mother, nullifying all data members
156 for (i = 0; i < 2; i++) fDaughter[i] = 0x0;
158 fSum .SetXYZM(0.0, 0.0, 0.0, 0.0);
159 fSumMC.SetXYZM(0.0, 0.0, 0.0, 0.0);
162 //_____________________________________________________________________________
163 Double_t AliRsnMother::CosThetaStar(Bool_t first, Bool_t useMC)
165 TLorentzVector mother = (useMC ? fSumMC : fSum);
166 TLorentzVector daughter0 = (first ? fDaughter[0]->P() : fDaughter[1]->P());
167 TLorentzVector daughter1 = (first ? fDaughter[1]->P() : fDaughter[0]->P());
168 TVector3 momentumM (mother.Vect());
169 TVector3 normal (mother.Y()/momentumM.Mag(), -mother.X()/momentumM.Mag(), 0.0);
171 // Computes first the invariant mass of the mother
172 Double_t mass0 = fDaughter[0]->P().M();
173 Double_t mass1 = fDaughter[1]->P().M();
174 Double_t p0 = daughter0.Vect().Mag();
175 Double_t p1 = daughter1.Vect().Mag();
176 Double_t E0 = TMath::Sqrt(mass0*mass0+p0*p0);
177 Double_t E1 = TMath::Sqrt(mass1*mass1+p1*p1);
178 Double_t MotherMass = TMath::Sqrt((E0+E1)*(E0+E1)-(p0*p0+2.0*daughter0.Vect().Dot(daughter1.Vect())+p1*p1));
179 MotherMass = fSum.M();
181 // Computes components of beta
182 Double_t betaX = -mother.X()/mother.E();
183 Double_t betaY = -mother.Y()/mother.E();
184 Double_t betaZ = -mother.Z()/mother.E();
186 // Computes Lorentz transformation of the momentum of the first daughter
187 // into the rest frame of the mother and theta*
188 daughter0.Boost(betaX,betaY,betaZ);
189 TVector3 momentumD = daughter0.Vect();
191 Double_t cosThetaStar = normal.Dot(momentumD)/momentumD.Mag();
196 //_____________________________________________________________________________
197 void AliRsnMother::PrintInfo(const Option_t * /*option*/) const
200 // Print some info of the pair.
201 // The options are passed to the AliRsnDaughter::Print() method
204 AliInfo("======== BEGIN PAIR INFO ===========");
206 fDaughter[0]->Print();
208 fDaughter[1]->Print();
209 AliInfo("========= END PAIR INFO ===========");
212 //_____________________________________________________________________________
213 Bool_t AliRsnMother::CheckPair() const
216 // Checks that the pair is well initialized:
217 // - both daughters are good pointers
218 // - if MC is required, both daughters have a MC reference
221 if (!fDaughter[0] || !fDaughter[1])
223 AliError("One of the two tracks is NULL in this pair!");
229 if (fDaughter[0]->GetRefMC() == 0x0 || fDaughter[1]->GetRefMC() == 0x0)
231 AliError("Required MC info but not all MC refs are available");
239 //_____________________________________________________________________________
240 Bool_t AliRsnMother::MatchesDef(AliRsnPairDef *def)
243 // Checks if the daughters, in any order, do match a given decay channel,
244 // using the specified identification method, which can be the 'true' one
245 // or the 'realistic' one only.
248 if (!def) return kFALSE;
249 if (!fDaughter[0]->GetRefMC()) return kFALSE;
250 if (!fDaughter[1]->GetRefMC()) return kFALSE;
252 Bool_t decayMatch = kFALSE;
253 Int_t pdg[2], ref[2];
254 pdg[0] = fDaughter[0]->GetPDG();
255 pdg[1] = fDaughter[1]->GetPDG();
256 ref[0] = TMath::Abs(AliPID::ParticleCode(def->GetPID(0)));
257 ref[1] = TMath::Abs(AliPID::ParticleCode(def->GetPID(1)));
260 // if first member of pairDef has same sign as first member of this,
261 // daughter[0] perfect PID must match first member of pairDef
262 // daughter[1] perfect PID must march second member of pairDef
263 if (fDaughter[0]->IsSign(def->GetCharge(0)) && fDaughter[1]->IsSign(def->GetCharge(1)))
265 decayMatch = (pdg[0] == ref[0] && pdg[1] == ref[1]);
269 // if first member of pairDef has same sign as second member of this,
270 // daughter[0] perfect PID must match second member of pairDef
271 // daughter[1] perfect PID must march first member of pairDef
272 if (fDaughter[1]->IsSign(def->GetCharge(0)) && fDaughter[0]->IsSign(def->GetCharge(1)))
274 decayMatch = (pdg[0] == ref[1] && pdg[1] == ref[0]);
277 return (decayMatch && (CommonMother() == def->GetMotherPDG()));