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 **************************************************************************/
17 // Class AliRsnPairParticle
19 // Implementation of a pair of tracks, for several purposes
20 // - computing the total 4-momentum & inv. mass for output histos filling
21 // - evaluating cut checks on the pair of particles
23 // author: Martin Vala (martin.vala@cern.ch)
24 // revised by: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
29 #include "AliRsnPairParticle.h"
31 ClassImp (AliRsnPairParticle)
33 //_____________________________________________________________________________
34 AliRsnPairParticle::AliRsnPairParticle() :
39 // Initializes all variables to meaningless values.
42 for (i = 0; i < 3; i++) {
50 for (j = 0; j < 2; j++) {
52 fPTrackMC[j][i] = 0.0;
57 //_____________________________________________________________________________
58 AliRsnPairParticle::AliRsnPairParticle(const AliRsnPairParticle &obj) :
64 // Initializes all variables to copy values.
65 // Does not duplicate pointers.
68 for (i = 0; i < 3; i++) {
69 fPTot[i] = obj.fPTot[i];
70 fPTotMC[i] = obj.fPTotMC[i];
72 fMotherLabel[i] = obj.fMotherLabel[i];
73 fMotherPDG[i] = obj.fMotherPDG[i];
74 fDaughter[i] = obj.fDaughter[i];
76 for (j = 0; j < 2; j++) {
77 fPTrack[j][i] = obj.fPTrack[j][i];
78 fPTrackMC[j][i] = obj.fPTrackMC[j][i];
83 //_____________________________________________________________________________
84 AliRsnPairParticle& AliRsnPairParticle::operator=(const AliRsnPairParticle &obj)
87 // Assignment operator.
88 // Initializes all variables to copy values.
89 // Does not duplicate pointers.
95 for (i = 0; i < 3; i++) {
96 fPTot[i] = obj.fPTot[i];
97 fPTotMC[i] = obj.fPTotMC[i];
99 fMotherLabel[i] = obj.fMotherLabel[i];
100 fMotherPDG[i] = obj.fMotherPDG[i];
101 fDaughter[i] = obj.fDaughter[i];
103 for (j = 0; j < 2; j++) {
104 fPTrack[j][i] = obj.fPTrack[j][i];
105 fPTrackMC[j][i] = obj.fPTrackMC[j][i];
112 //_____________________________________________________________________________
113 AliRsnPairParticle::~AliRsnPairParticle()
121 //_____________________________________________________________________________
122 Double_t AliRsnPairParticle::GetInvMass(Double_t m1, Double_t m2)
125 // Compute invariant mass using REC values.
126 // The masses in argument have default value = -1.0;
127 // when this is used, the mass for computation is taken from daughter object.
128 // Otherwise, the passed values are used.
132 // energy of particle 1
133 if (m1 > 0.0) etot = GetDaughterEnergy(0, m1);
134 else etot = fDaughter[0]->E();
136 // energy of particle 2
137 if (m2 > 0.0) etot += GetDaughterEnergy(1, m2);
138 else etot += fDaughter[1]->E();
140 // total momentum square module
141 Double_t p2Tot = fPTot[0]*fPTot[0] + fPTot[1]*fPTot[1] + fPTot[2]*fPTot[2];
143 // invariant mass returned
144 return TMath::Sqrt (etot * etot - p2Tot);
147 //_____________________________________________________________________________
148 Double_t AliRsnPairParticle::GetInvMassMC(Double_t m1, Double_t m2)
151 // Compute invariant mass using MC values.
152 // The masses in argument have default value = -1.0;
153 // when a negative mass value is passed as one of the arguments,
154 // the energy of tracks for computation is taken from daughter object.
155 // Otherwise, the passed mass values are used to re-compute the track energy.
159 // energy of particle 1
160 if (m1 > 0.0) etot = GetDaughterEnergyMC(0, m1);
161 else etot = fDaughter[0]->GetMCInfo()->E();
163 // energy of particle 2
164 if (m2 > 0.0) etot += GetDaughterEnergyMC(1, m2);
165 else etot += fDaughter[1]->GetMCInfo()->E();
167 // total momentum square module
168 Double_t p2Tot = fPTotMC[0]*fPTotMC[0] + fPTotMC[1]*fPTotMC[1] +fPTotMC[2]*fPTotMC[2];
170 // invariant mass returned
171 return TMath::Sqrt (etot * etot - p2Tot);
174 //_____________________________________________________________________________
175 Double_t AliRsnPairParticle::GetDaughterEnergy(const Int_t &index, const Double_t &mass)
178 // Compute track energy from REC momentum using a passed mass value.
179 // The index argument refers to the used track among the two of the pair.
183 Double_t p2Tot = 0.0;
184 if (mass > 0 && index >= 0 && index < 2) {
185 AliRsnDaughter temp(*fDaughter[index]);
190 AliWarning("Negative mass or wrong index passed. Returning 0");
194 //_____________________________________________________________________________
195 Double_t AliRsnPairParticle::GetDaughterEnergyMC(const Int_t &index, const Double_t &mass)
198 // Compute track energy from MC momentum using a passed mass value.
199 // The index argument refers to the used track among the two of the pair.
202 Double_t p2Tot = 0.0;
203 if (mass > 0 && index >= 0 && index < 2) {
204 for (i = 0; i < 3; i++) p2Tot += fPTrackMC[index][i] * fPTrackMC[index][i];
205 return TMath::Sqrt(mass*mass + p2Tot);
208 AliWarning("Negative mass or wrong index passed. Returning 0");
212 //_____________________________________________________________________________
213 Int_t AliRsnPairParticle::GetPDG(const Int_t &index)
216 // Return PDG code of one track in the pair
219 if (index < 0 || index > 1) {
220 AliError("Index out of range");
223 if (!fDaughter[index]->GetMCInfo()) {
224 AliError(Form("MCInfo not initialized for track %d", index));
227 return fDaughter[index]->GetMCInfo()->PDG();
230 //_____________________________________________________________________________
231 Bool_t AliRsnPairParticle::IsTruePair(Int_t refPDG)
234 // Checks if the tweo tracks in the pair come from the same resonance.
235 // This can be known if MC info is present, looking at the GEANT label of mother
236 // (which should be the same).
237 // If the argument is 0, the answer is kTRUE whenever the labels of mothers of the
238 // two tracks is the same. When the argument is not zero, the answer is kTRUE only
239 // if the mother is the same and its PDG code is equal to the argument.
241 // if MC info is not available, the pairs is not true by default
242 if (!fDaughter[0]->GetMCInfo() || !fDaughter[1]->GetMCInfo()) {
246 // check that labels are the same
247 if (fDaughter[0]->GetMCInfo()->Mother() != fDaughter[1]->GetMCInfo()->Mother()) {
251 // if we reach this point, the two tracks have the same mother
252 // let's check now the PDG code of this common mother
253 Int_t motherPDG = TMath::Abs(fDaughter[0]->GetMCInfo()->MotherPDG());
254 if (refPDG == 0) return kTRUE;
255 else return (motherPDG == refPDG);
258 //_____________________________________________________________________________
259 void AliRsnPairParticle::SetPair(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2)
262 // Main object filling method.
263 // Accepts two AliRsnDaughter's which are the two tracks in the pair,
264 // fills all data-members which contain their momenta & info,
265 // and computes the total momentum for REC data and MC if available
270 fDaughter[0] = daughter1;
271 fDaughter[1] = daughter2;
273 // copy MC info (if available)
274 if (fDaughter[0]->GetMCInfo() && fDaughter[1]->GetMCInfo()) {
275 for (i = 0; i < 2; i++) {
276 fPTrackMC[i][0] = fDaughter[i]->GetMCInfo()->Px();
277 fPTrackMC[i][1] = fDaughter[i]->GetMCInfo()->Py();
278 fPTrackMC[i][2] = fDaughter[i]->GetMCInfo()->Pz();
279 fMotherPDG[i] = fDaughter[i]->GetMCInfo()->MotherPDG();
281 for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
284 // copy reconstructed info (always available)
285 for (i = 0; i < 2; i++) {
286 fPTrack[i][0] = fDaughter[i]->Px();
287 fPTrack[i][1] = fDaughter[i]->Py();
288 fPTrack[i][2] = fDaughter[i]->Pz();
290 for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
293 //_____________________________________________________________________________
294 void AliRsnPairParticle::PrintInfo (const Option_t *option)
297 // Print some info of the pair
302 AliInfo ( "======== BEGIN PAIR INFO ===========" );
303 if (s.Contains("p")) {
304 AliInfo (Form("Px1 = %.6f --- Py1 = %.6f --- Pz1 = %.6f", fPTrack[0][0], fPTrack[0][1], fPTrack[0][2]));
305 AliInfo (Form("Px2 = %.6f --- Py2 = %.6f --- Pz2 = %.6f", fPTrack[1][0], fPTrack[1][1], fPTrack[1][2]));
307 if (s.Contains("t")) {
308 AliInfo (Form("PDG1 = %d --- PDG2 = %d", GetPDG(0), GetPDG(1)));
309 AliInfo (Form("type1 = %d --- type2 = %d", GetType(0), GetType(1)));
310 AliInfo (Form("label1 = %d --- label2 = %d", GetLabel(0), GetLabel(1)));
312 AliInfo ( "====== END PAIR INFO =========" );