]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPairParticle.cxx
Package upgrade.
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairParticle.cxx
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
31 ClassImp (AliRsnPairParticle)
32
33 //_____________________________________________________________________________
34 AliRsnPairParticle::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 //_____________________________________________________________________________
58 AliRsnPairParticle::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 //_____________________________________________________________________________
84 AliRsnPairParticle& 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 //_____________________________________________________________________________
113 AliRsnPairParticle::~AliRsnPairParticle()
114 {
115 //
116 // Desctructor.
117 // Does nothing.
118 //
119 }
120
121 //_____________________________________________________________________________
122 Double_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 //_____________________________________________________________________________
148 Double_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 //_____________________________________________________________________________
175 Double_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
182     Int_t i;
183     Double_t p2Tot = 0.0;
184     if (mass > 0 && index >= 0 && index < 2) {
185         AliRsnDaughter temp(*fDaughter[index]);
186         temp.SetM(mass);
187         return temp.E();
188     }
189
190     AliWarning("Negative mass or wrong index passed. Returning 0");
191     return 0.0;
192 }
193
194 //_____________________________________________________________________________
195 Double_t AliRsnPairParticle::GetDaughterEnergyMC(const Int_t &index, const Double_t &mass)
196 {
197 //
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.
200 //
201     Int_t i;
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);
206     }
207
208     AliWarning("Negative mass or wrong index passed. Returning 0");
209     return 0.0;
210 }
211
212 //_____________________________________________________________________________
213 Int_t AliRsnPairParticle::GetPDG(const Int_t &index)
214 {
215 //
216 // Return PDG code of one track in the pair
217 //
218
219     if (index < 0 || index > 1) {
220         AliError("Index out of range");
221         return 0;
222     }
223     if (!fDaughter[index]->GetMCInfo()) {
224         AliError(Form("MCInfo not initialized for track %d", index));
225         return 0;
226     }
227     return fDaughter[index]->GetMCInfo()->PDG();
228 }
229
230 //_____________________________________________________________________________
231 Bool_t AliRsnPairParticle::IsTruePair(Int_t refPDG)
232 {
233 //
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.
240
241     // if MC info is not available, the pairs is not true by default
242     if (!fDaughter[0]->GetMCInfo() || !fDaughter[1]->GetMCInfo()) {
243         return kFALSE;
244     }
245
246     // check that labels are the same
247     if (fDaughter[0]->GetMCInfo()->Mother() != fDaughter[1]->GetMCInfo()->Mother()) {
248         return kFALSE;
249     }
250
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);
256 }
257
258 //_____________________________________________________________________________
259 void AliRsnPairParticle::SetPair(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2)
260 {
261 //
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
266 //
267
268     Int_t i;
269
270     fDaughter[0] = daughter1;
271     fDaughter[1] = daughter2;
272
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();
280         }
281         for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
282     }
283
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();
289     }
290     for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
291 }
292
293 //_____________________________________________________________________________
294 void AliRsnPairParticle::PrintInfo (const Option_t *option)
295 {
296 //
297 // Print some info of the pair
298 //
299
300     TString s(option);
301
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]));
306     }
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)));
311     }
312     AliInfo ( "====== END PAIR INFO =========" );
313 }