2 // Class AliRsnPairParticle
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)
13 #include <TParticle.h>
16 #include "AliRsnDaughter.h"
17 #include "AliRsnPairParticle.h"
19 ClassImp(AliRsnPairParticle)
21 //_____________________________________________________________________________
22 AliRsnPairParticle::AliRsnPairParticle()
26 // Initializes all variables to meaningless values.
31 for (i = 0; i < 3; i++) {
39 for (j = 0; j < 2; j++) {
41 fPTrackMC[j][i] = 0.0;
46 //_____________________________________________________________________________
47 AliRsnPairParticle::AliRsnPairParticle(const AliRsnPairParticle &obj) :
52 // Initializes all variables to copy values.
53 // Does not duplicate pointers.
57 for (i = 0; i < 3; i++) {
58 fPTot[i] = obj.fPTot[i];
59 fPTotMC[i] = obj.fPTotMC[i];
61 fMotherLabel[i] = obj.fMotherLabel[i];
62 fMotherPDG[i] = obj.fMotherPDG[i];
63 fDaughter[i] = obj.fDaughter[i];
65 for (j = 0; j < 2; j++) {
66 fPTrack[j][i] = obj.fPTrack[j][i];
67 fPTrackMC[j][i] = obj.fPTrackMC[j][i];
72 //_____________________________________________________________________________
73 AliRsnPairParticle& AliRsnPairParticle::operator=(const AliRsnPairParticle &obj)
76 // Assignment operator.
77 // Initializes all variables to copy values.
78 // Does not duplicate pointers.
82 for (i = 0; i < 3; i++) {
83 fPTot[i] = obj.fPTot[i];
84 fPTotMC[i] = obj.fPTotMC[i];
86 fMotherLabel[i] = obj.fMotherLabel[i];
87 fMotherPDG[i] = obj.fMotherPDG[i];
88 fDaughter[i] = obj.fDaughter[i];
90 for (j = 0; j < 2; j++) {
91 fPTrack[j][i] = obj.fPTrack[j][i];
92 fPTrackMC[j][i] = obj.fPTrackMC[j][i];
99 //_____________________________________________________________________________
100 AliRsnPairParticle::~AliRsnPairParticle()
108 //_____________________________________________________________________________
109 Double_t AliRsnPairParticle::GetInvMass(Double_t mass0, Double_t mass1)
112 // Compute invariant mass using reconstructed values.
113 // Mass in argument #1 is assigned to first track in the pair (fDaughter[0]),
114 // mass in argument #2 is assigned to second track in the pair (fDaughter[1]).
115 // If the third argument is not zero, a rotation of that angle is applied to XY momentum of track #2
116 // before computing invariant mass.
117 // Then, the invariant mass of the pair is computed by using their total momentum
118 // and the sum of their energies computed after assigned masses.
121 if (!fDaughter[0] || !fDaughter[1]) {
122 AliError("One of the two tracks is NULL in this pair!");
126 // compute track energies using the shortcut method defined in AliRsnDaughter
128 etot += fDaughter[0]->E(mass0);
129 etot += fDaughter[1]->E(mass1);
131 // compute & return invariant mass
132 return TMath::Sqrt(etot * etot - GetP2());
135 //_____________________________________________________________________________
136 Double_t AliRsnPairParticle::GetInvMassMC(Double_t mass0, Double_t mass1)
139 // Compute invariant mass using MC values.
140 // Mass in argument #1 is assigned to first track in the pair (fDaughter[0]),
141 // mass in argument #2 is assigned to second track in the pair (fDaughter[1])
142 // Then, the invariant mass of the pair is computed by using their total momentum
143 // and the sum of their energies.
146 if (!fDaughter[0] || !fDaughter[1]) {
147 AliError("One of the two tracks is NULL in this pair!");
150 if (!fDaughter[0]->GetParticle() || !fDaughter[1]->GetParticle()) {
151 AliError("One of the two tracks has a NULL MCInfo in this pair!");
155 // compute track energies using the shortcut method defined in AliRsnDaughter
157 etot += fDaughter[0]->GetMCEnergy(mass0);
158 etot += fDaughter[1]->GetMCEnergy(mass1);
160 // compute & return invariant mass
161 return TMath::Sqrt(etot * etot - GetP2MC());
164 //_____________________________________________________________________________
165 Double_t AliRsnPairParticle::GetEtot(Double_t mass0, Double_t mass1) const
168 // Compute total pair energy from the sum of single track energies
169 // with a necessary mass hypothesis (rec. values).
173 etot += fDaughter[0]->E(mass0);
174 etot += fDaughter[1]->E(mass1);
179 //_____________________________________________________________________________
180 Double_t AliRsnPairParticle::GetEtotMC(Double_t mass0, Double_t mass1) const
183 // Compute total pair energy from the sum of single track energies
184 // with a necessary mass hypothesis (MC values).
187 etot += fDaughter[0]->GetMCEnergy(mass0);
188 etot += fDaughter[1]->GetMCEnergy(mass1);
193 //_____________________________________________________________________________
194 Double_t AliRsnPairParticle::GetAngle() const
197 // Returns the relative angle between the vector momenta of the tracks
198 // Return value is in DEGREES.
201 Double_t dotProd = 0.0;
202 dotProd += fDaughter[0]->Px() * fDaughter[1]->Px();
203 dotProd += fDaughter[0]->Py() * fDaughter[1]->Py();
204 dotProd += fDaughter[0]->Pz() * fDaughter[1]->Pz();
206 Double_t cosAngle = dotProd / (fDaughter[0]->P() * fDaughter[1]->P());
208 return TMath::ACos(cosAngle) * TMath::RadToDeg();
211 //_____________________________________________________________________________
212 Bool_t AliRsnPairParticle::IsTruePair(Int_t refPDG)
215 // Checks if the two tracks in the pair come from the same resonance.
216 // This can be known if MC info is present, looking at the GEANT label of mother
217 // (which should be the same).
218 // If the argument is 0, the answer is kTRUE whenever the labels of mothers of the
219 // two tracks is the same. When the argument is not zero, the answer is kTRUE only
220 // if the mother is the same and its PDG code is equal to the argument.
223 // if MC info is not available, the pairs is not true by default
224 if (!fDaughter[0]->GetParticle() || !fDaughter[1]->GetParticle()) {
225 AliInfo("Cannot know if the pairs is true or not because MC Info is not present");
229 // check that labels are the same
230 if (fDaughter[0]->GetParticle()->GetFirstMother() != fDaughter[1]->GetParticle()->GetFirstMother()) {
234 // if we reach this point, the two tracks have the same mother
235 // let's check now the PDG code of this common mother
236 Int_t motherPDG = TMath::Abs(fDaughter[0]->GetMotherPDG());
237 if (refPDG == 0) return kTRUE;
238 else return (motherPDG == refPDG);
241 //_____________________________________________________________________________
242 Int_t AliRsnPairParticle::CommonMother()
245 // Checks if the two tracks in the pair have the same mother.
246 // This can be known if MC info is present.
247 // If the mother label is the same, rhe PDG code of the mother is returned,
248 // otherwise the method returns 0.
251 // if MC info is not available, the pairs is not true by default
252 if (!fDaughter[0]->GetParticle() || !fDaughter[1]->GetParticle()) {
253 AliInfo("Cannot know if the pairs is true or not because MC Info is not present");
257 // check that labels are the same
258 if (fDaughter[0]->GetParticle()->GetFirstMother() != fDaughter[1]->GetParticle()->GetFirstMother()) {
262 // if we reach this point, the two tracks have the same mother
263 // let's check now the PDG code of this common mother
264 return TMath::Abs(fDaughter[0]->GetMotherPDG());
267 //_____________________________________________________________________________
268 void AliRsnPairParticle::SetPair(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2)
271 // Accepts two AliRsnDaughter's which are the two tracks in the pair,
272 // fills all data-members which contain their momenta & info,
273 // and computes the total momentum for REC data and MC if available
278 fDaughter[0] = daughter1;
279 fDaughter[1] = daughter2;
281 // copy MC info (if available)
282 if (fDaughter[0]->GetParticle() && fDaughter[1]->GetParticle()) {
283 for (i = 0; i < 2; i++) {
284 fPTrackMC[i][0] = fDaughter[i]->GetParticle()->Px();
285 fPTrackMC[i][1] = fDaughter[i]->GetParticle()->Py();
286 fPTrackMC[i][2] = fDaughter[i]->GetParticle()->Pz();
287 fMotherPDG[i] = fDaughter[i]->GetMotherPDG();
289 for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
292 // copy reconstructed info (always available)
293 for (i = 0; i < 2; i++) {
294 fPTrack[i][0] = fDaughter[i]->Px();
295 fPTrack[i][1] = fDaughter[i]->Py();
296 fPTrack[i][2] = fDaughter[i]->Pz();
298 for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
301 //_____________________________________________________________________________
302 void AliRsnPairParticle::ResetPair()
305 // Computes the total momentum for REC data and MC if available
310 // copy MC info (if available)
311 if (fDaughter[0]->GetParticle() && fDaughter[1]->GetParticle()) {
312 for (i = 0; i < 2; i++) {
313 fPTrackMC[i][0] = fDaughter[i]->GetParticle()->Px();
314 fPTrackMC[i][1] = fDaughter[i]->GetParticle()->Py();
315 fPTrackMC[i][2] = fDaughter[i]->GetParticle()->Pz();
316 fMotherPDG[i] = fDaughter[i]->GetMotherPDG();
318 for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
321 // copy reconstructed info (always available)
322 for (i = 0; i < 2; i++) {
323 fPTrack[i][0] = fDaughter[i]->Px();
324 fPTrack[i][1] = fDaughter[i]->Py();
325 fPTrack[i][2] = fDaughter[i]->Pz();
327 for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
330 //_____________________________________________________________________________
331 void AliRsnPairParticle::RotateTrack(Int_t idx, Double_t angle, Bool_t isDegrees)
334 // Computes the total momentum for REC data and MC if available
337 if (idx < 0 || idx > 1) return;
341 // copy MC info (if available)
342 if (fDaughter[0]->GetParticle() && fDaughter[1]->GetParticle()) {
343 for (i = 0; i < 2; i++) {
345 fDaughter[i]->RotateP(angle, fPTrackMC[i][0], fPTrackMC[i][1], isDegrees);
347 fPTrackMC[i][0] = fDaughter[i]->GetParticle()->Px();
348 fPTrackMC[i][1] = fDaughter[i]->GetParticle()->Py();
350 fPTrackMC[i][2] = fDaughter[i]->GetParticle()->Pz();
352 for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
355 for (i = 0; i < 2; i++) {
357 fDaughter[i]->RotateP(angle, fPTrack[i][0], fPTrack[i][1], isDegrees);
359 fPTrack[i][0] = fDaughter[i]->GetParticle()->Px();
360 fPTrack[i][1] = fDaughter[i]->GetParticle()->Py();
362 fPTrack[i][2] = fDaughter[i]->GetParticle()->Pz();
364 for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
368 //_____________________________________________________________________________
369 void AliRsnPairParticle::PrintInfo(const Option_t *option)
372 // Print some info of the pair.
373 // The options are passed to the AliRsnDaughter::Print() method
376 AliInfo("======== BEGIN PAIR INFO ===========");
378 fDaughter[0]->Print(option);
380 fDaughter[1]->Print(option);
381 AliInfo("========= END PAIR INFO ===========");