Removed warnings
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairParticle.cxx
CommitLineData
06351446 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16//
17// Class AliRsnPairParticle
18//
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
22//
23// author: Martin Vala (martin.vala@cern.ch)
24// revised by: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
25//
26
27#include "AliLog.h"
28
29#include "AliRsnPairParticle.h"
30
31ClassImp (AliRsnPairParticle)
32
33//_____________________________________________________________________________
34AliRsnPairParticle::AliRsnPairParticle() :
35 fMass(0.0)
36{
37//
38// Constructor.
39// Initializes all variables to meaningless values.
40//
41 Int_t i, j;
42 for (i = 0; i < 3; i++) {
43 fPTot[i] = 0.0;
44 fPTotMC[i] = 0.0;
45 if (i < 2) {
46 fMotherLabel[i] = -1;
47 fMotherPDG[i] = 0;
48 fDaughter[i] = 0x0;
49 }
50 for (j = 0; j < 2; j++) {
51 fPTrack[j][i] = 0.0;
52 fPTrackMC[j][i] = 0.0;
53 }
54 }
55}
56
57//_____________________________________________________________________________
58AliRsnPairParticle::AliRsnPairParticle(const AliRsnPairParticle &obj) :
59 TObject(obj),
60 fMass(obj.fMass)
61{
62//
63// Copy constructor.
64// Initializes all variables to copy values.
65// Does not duplicate pointers.
66//
67 Int_t i, j;
68 for (i = 0; i < 3; i++) {
69 fPTot[i] = obj.fPTot[i];
70 fPTotMC[i] = obj.fPTotMC[i];
71 if (i < 2) {
72 fMotherLabel[i] = obj.fMotherLabel[i];
73 fMotherPDG[i] = obj.fMotherPDG[i];
74 fDaughter[i] = obj.fDaughter[i];
75 }
76 for (j = 0; j < 2; j++) {
77 fPTrack[j][i] = obj.fPTrack[j][i];
78 fPTrackMC[j][i] = obj.fPTrackMC[j][i];
79 }
80 }
81}
82
83//_____________________________________________________________________________
84AliRsnPairParticle& AliRsnPairParticle::operator=(const AliRsnPairParticle &obj)
85{
86//
87// Assignment operator.
88// Initializes all variables to copy values.
89// Does not duplicate pointers.
90//
91
92 fMass = obj.fMass;
93
94 Int_t i, j;
95 for (i = 0; i < 3; i++) {
96 fPTot[i] = obj.fPTot[i];
97 fPTotMC[i] = obj.fPTotMC[i];
98 if (i < 2) {
99 fMotherLabel[i] = obj.fMotherLabel[i];
100 fMotherPDG[i] = obj.fMotherPDG[i];
101 fDaughter[i] = obj.fDaughter[i];
102 }
103 for (j = 0; j < 2; j++) {
104 fPTrack[j][i] = obj.fPTrack[j][i];
105 fPTrackMC[j][i] = obj.fPTrackMC[j][i];
106 }
107 }
108
109 return (*this);
110}
111
112//_____________________________________________________________________________
113AliRsnPairParticle::~AliRsnPairParticle()
114{
115//
116// Desctructor.
117// Does nothing.
118//
119}
120
121//_____________________________________________________________________________
122Double_t AliRsnPairParticle::GetInvMass(Double_t m1, Double_t m2)
123{
124//
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.
129//
130 Double_t etot = 0.0;
131
132 // energy of particle 1
133 if (m1 > 0.0) etot = GetDaughterEnergy(0, m1);
134 else etot = fDaughter[0]->E();
135
136 // energy of particle 2
137 if (m2 > 0.0) etot += GetDaughterEnergy(1, m2);
138 else etot += fDaughter[1]->E();
139
140 // total momentum square module
141 Double_t p2Tot = fPTot[0]*fPTot[0] + fPTot[1]*fPTot[1] + fPTot[2]*fPTot[2];
142
143 // invariant mass returned
144 return TMath::Sqrt (etot * etot - p2Tot);
145}
146
147//_____________________________________________________________________________
148Double_t AliRsnPairParticle::GetInvMassMC(Double_t m1, Double_t m2)
149{
150//
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.
156//
157 Double_t etot = 0.0;
158
159 // energy of particle 1
160 if (m1 > 0.0) etot = GetDaughterEnergyMC(0, m1);
161 else etot = fDaughter[0]->GetMCInfo()->E();
162
163 // energy of particle 2
164 if (m2 > 0.0) etot += GetDaughterEnergyMC(1, m2);
165 else etot += fDaughter[1]->GetMCInfo()->E();
166
167 // total momentum square module
168 Double_t p2Tot = fPTotMC[0]*fPTotMC[0] + fPTotMC[1]*fPTotMC[1] +fPTotMC[2]*fPTotMC[2];
169
170 // invariant mass returned
171 return TMath::Sqrt (etot * etot - p2Tot);
172}
173
174//_____________________________________________________________________________
175Double_t AliRsnPairParticle::GetDaughterEnergy(const Int_t &index, const Double_t &mass)
176{
177//
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.
180//
181
06351446 182 if (mass > 0 && index >= 0 && index < 2) {
183 AliRsnDaughter temp(*fDaughter[index]);
184 temp.SetM(mass);
185 return temp.E();
186 }
187
188 AliWarning("Negative mass or wrong index passed. Returning 0");
189 return 0.0;
190}
191
192//_____________________________________________________________________________
193Double_t AliRsnPairParticle::GetDaughterEnergyMC(const Int_t &index, const Double_t &mass)
194{
195//
196// Compute track energy from MC momentum using a passed mass value.
197// The index argument refers to the used track among the two of the pair.
198//
199 Int_t i;
200 Double_t p2Tot = 0.0;
201 if (mass > 0 && index >= 0 && index < 2) {
202 for (i = 0; i < 3; i++) p2Tot += fPTrackMC[index][i] * fPTrackMC[index][i];
203 return TMath::Sqrt(mass*mass + p2Tot);
204 }
205
206 AliWarning("Negative mass or wrong index passed. Returning 0");
207 return 0.0;
208}
209
210//_____________________________________________________________________________
211Int_t AliRsnPairParticle::GetPDG(const Int_t &index)
212{
213//
214// Return PDG code of one track in the pair
215//
216
217 if (index < 0 || index > 1) {
218 AliError("Index out of range");
219 return 0;
220 }
221 if (!fDaughter[index]->GetMCInfo()) {
222 AliError(Form("MCInfo not initialized for track %d", index));
223 return 0;
224 }
225 return fDaughter[index]->GetMCInfo()->PDG();
226}
227
228//_____________________________________________________________________________
229Bool_t AliRsnPairParticle::IsTruePair(Int_t refPDG)
230{
231//
232// Checks if the tweo tracks in the pair come from the same resonance.
233// This can be known if MC info is present, looking at the GEANT label of mother
234// (which should be the same).
235// If the argument is 0, the answer is kTRUE whenever the labels of mothers of the
236// two tracks is the same. When the argument is not zero, the answer is kTRUE only
237// if the mother is the same and its PDG code is equal to the argument.
238
239 // if MC info is not available, the pairs is not true by default
240 if (!fDaughter[0]->GetMCInfo() || !fDaughter[1]->GetMCInfo()) {
241 return kFALSE;
242 }
243
244 // check that labels are the same
245 if (fDaughter[0]->GetMCInfo()->Mother() != fDaughter[1]->GetMCInfo()->Mother()) {
246 return kFALSE;
247 }
248
249 // if we reach this point, the two tracks have the same mother
250 // let's check now the PDG code of this common mother
251 Int_t motherPDG = TMath::Abs(fDaughter[0]->GetMCInfo()->MotherPDG());
252 if (refPDG == 0) return kTRUE;
253 else return (motherPDG == refPDG);
254}
255
256//_____________________________________________________________________________
257void AliRsnPairParticle::SetPair(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2)
258{
259//
260// Main object filling method.
261// Accepts two AliRsnDaughter's which are the two tracks in the pair,
262// fills all data-members which contain their momenta & info,
263// and computes the total momentum for REC data and MC if available
264//
265
266 Int_t i;
267
268 fDaughter[0] = daughter1;
269 fDaughter[1] = daughter2;
270
271 // copy MC info (if available)
272 if (fDaughter[0]->GetMCInfo() && fDaughter[1]->GetMCInfo()) {
273 for (i = 0; i < 2; i++) {
274 fPTrackMC[i][0] = fDaughter[i]->GetMCInfo()->Px();
275 fPTrackMC[i][1] = fDaughter[i]->GetMCInfo()->Py();
276 fPTrackMC[i][2] = fDaughter[i]->GetMCInfo()->Pz();
277 fMotherPDG[i] = fDaughter[i]->GetMCInfo()->MotherPDG();
278 }
279 for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
280 }
281
282 // copy reconstructed info (always available)
283 for (i = 0; i < 2; i++) {
284 fPTrack[i][0] = fDaughter[i]->Px();
285 fPTrack[i][1] = fDaughter[i]->Py();
286 fPTrack[i][2] = fDaughter[i]->Pz();
287 }
288 for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
289}
290
291//_____________________________________________________________________________
292void AliRsnPairParticle::PrintInfo (const Option_t *option)
293{
294//
295// Print some info of the pair
296//
297
298 TString s(option);
299
300 AliInfo ( "======== BEGIN PAIR INFO ===========" );
301 if (s.Contains("p")) {
302 AliInfo (Form("Px1 = %.6f --- Py1 = %.6f --- Pz1 = %.6f", fPTrack[0][0], fPTrack[0][1], fPTrack[0][2]));
303 AliInfo (Form("Px2 = %.6f --- Py2 = %.6f --- Pz2 = %.6f", fPTrack[1][0], fPTrack[1][1], fPTrack[1][2]));
304 }
305 if (s.Contains("t")) {
306 AliInfo (Form("PDG1 = %d --- PDG2 = %d", GetPDG(0), GetPDG(1)));
307 AliInfo (Form("type1 = %d --- type2 = %d", GetType(0), GetType(1)));
308 AliInfo (Form("label1 = %d --- label2 = %d", GetLabel(0), GetLabel(1)));
309 }
310 AliInfo ( "====== END PAIR INFO =========" );
311}