]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPairParticle.cxx
Fixed some errors
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairParticle.cxx
1 //
2 // Class AliRsnPairParticle
3 //
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
8 //
9 // authors: Martin Vala (martin.vala@cern.ch)
10 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
11 //
12
13 #include <TParticle.h>
14
15 #include "AliLog.h"
16 #include "AliRsnDaughter.h"
17 #include "AliRsnPairParticle.h"
18
19 ClassImp(AliRsnPairParticle)
20
21 //_____________________________________________________________________________
22 AliRsnPairParticle::AliRsnPairParticle()
23 {
24 //
25 // Constructor.
26 // Initializes all variables to meaningless values.
27 //
28
29   Int_t i, j;
30
31   for (i = 0; i < 3; i++) {
32     fPTot[i] = 0.0;
33     fPTotMC[i] = 0.0;
34     if (i < 2) {
35       fMotherLabel[i] = -1;
36       fMotherPDG[i] = 0;
37       fDaughter[i] = 0x0;
38     }
39     for (j = 0; j < 2; j++) {
40       fPTrack[j][i] = 0.0;
41       fPTrackMC[j][i] = 0.0;
42     }
43   }
44 }
45
46 //_____________________________________________________________________________
47 AliRsnPairParticle::AliRsnPairParticle(const AliRsnPairParticle &obj) :
48     TObject(obj)
49 {
50 //
51 // Copy constructor.
52 // Initializes all variables to copy values.
53 // Does not duplicate pointers.
54 //
55
56   Int_t i, j;
57   for (i = 0; i < 3; i++) {
58     fPTot[i] = obj.fPTot[i];
59     fPTotMC[i] = obj.fPTotMC[i];
60     if (i < 2) {
61       fMotherLabel[i] = obj.fMotherLabel[i];
62       fMotherPDG[i] = obj.fMotherPDG[i];
63       fDaughter[i] = obj.fDaughter[i];
64     }
65     for (j = 0; j < 2; j++) {
66       fPTrack[j][i] = obj.fPTrack[j][i];
67       fPTrackMC[j][i] = obj.fPTrackMC[j][i];
68     }
69   }
70 }
71
72 //_____________________________________________________________________________
73 AliRsnPairParticle& AliRsnPairParticle::operator=(const AliRsnPairParticle &obj)
74 {
75 //
76 // Assignment operator.
77 // Initializes all variables to copy values.
78 // Does not duplicate pointers.
79 //
80
81   Int_t i, j;
82   for (i = 0; i < 3; i++) {
83     fPTot[i] = obj.fPTot[i];
84     fPTotMC[i] = obj.fPTotMC[i];
85     if (i < 2) {
86       fMotherLabel[i] = obj.fMotherLabel[i];
87       fMotherPDG[i] = obj.fMotherPDG[i];
88       fDaughter[i] = obj.fDaughter[i];
89     }
90     for (j = 0; j < 2; j++) {
91       fPTrack[j][i] = obj.fPTrack[j][i];
92       fPTrackMC[j][i] = obj.fPTrackMC[j][i];
93     }
94   }
95
96   return (*this);
97 }
98
99 //_____________________________________________________________________________
100 AliRsnPairParticle::~AliRsnPairParticle()
101 {
102 //
103 // Desctructor.
104 // Does nothing.
105 //
106 }
107
108 //_____________________________________________________________________________
109 Double_t AliRsnPairParticle::GetInvMass(Double_t mass0, Double_t mass1)
110 {
111 //
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.
119 //
120
121   if (!fDaughter[0] || !fDaughter[1]) {
122     AliError("One of the two tracks is NULL in this pair!");
123     return -1000.0;
124   }
125
126   // compute track energies using the shortcut method defined in AliRsnDaughter
127   Double_t etot = 0.0;
128   etot += fDaughter[0]->E(mass0);
129   etot += fDaughter[1]->E(mass1);
130
131   // compute & return invariant mass
132   return  TMath::Sqrt(etot * etot - GetP2());
133 }
134
135 //_____________________________________________________________________________
136 Double_t AliRsnPairParticle::GetInvMassMC(Double_t mass0, Double_t mass1)
137 {
138 //
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.
144 //
145
146   if (!fDaughter[0] || !fDaughter[1]) {
147     AliError("One of the two tracks is NULL in this pair!");
148     return -1000.0;
149   }
150   if (!fDaughter[0]->GetParticle() || !fDaughter[1]->GetParticle()) {
151     AliError("One of the two tracks has a NULL MCInfo in this pair!");
152     return -1000.0;
153   }
154
155   // compute track energies using the shortcut method defined in AliRsnDaughter
156   Double_t etot = 0.0;
157   etot += fDaughter[0]->GetMCEnergy(mass0);
158   etot += fDaughter[1]->GetMCEnergy(mass1);
159
160   // compute & return invariant mass
161   return  TMath::Sqrt(etot * etot - GetP2MC());
162 }
163
164 //_____________________________________________________________________________
165 Double_t AliRsnPairParticle::GetEtot(Double_t mass0, Double_t mass1) const
166 {
167 //
168 // Compute total pair energy from the sum of single track energies
169 // with a necessary mass hypothesis (rec. values).
170 //
171
172   Double_t etot = 0.0;
173   etot += fDaughter[0]->E(mass0);
174   etot += fDaughter[1]->E(mass1);
175
176   return etot;
177 }
178
179 //_____________________________________________________________________________
180 Double_t AliRsnPairParticle::GetEtotMC(Double_t mass0, Double_t mass1) const
181 {
182 //
183 // Compute total pair energy from the sum of single track energies
184 // with a necessary mass hypothesis (MC values).
185 //
186   Double_t etot = 0.0;
187   etot += fDaughter[0]->GetMCEnergy(mass0);
188   etot += fDaughter[1]->GetMCEnergy(mass1);
189
190   return etot;
191 }
192
193 //_____________________________________________________________________________
194 Double_t AliRsnPairParticle::GetAngle() const
195 {
196 //
197 // Returns the relative angle between the vector momenta of the tracks
198 // Return value is in DEGREES.
199 //
200
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();
205
206   Double_t cosAngle = dotProd / (fDaughter[0]->P() * fDaughter[1]->P());
207
208   return TMath::ACos(cosAngle) * TMath::RadToDeg();
209 }
210
211 //_____________________________________________________________________________
212 Bool_t AliRsnPairParticle::IsTruePair(Int_t refPDG)
213 {
214 //
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.
221 //
222
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");
226     return kFALSE;
227   }
228
229   // check that labels are the same
230   if (fDaughter[0]->GetParticle()->GetFirstMother() != fDaughter[1]->GetParticle()->GetFirstMother()) {
231     return kFALSE;
232   }
233
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);
239 }
240
241 //_____________________________________________________________________________
242 Int_t AliRsnPairParticle::CommonMother()
243 {
244 //
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.
249 //
250
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");
254     return 0;
255   }
256
257   // check that labels are the same
258   if (fDaughter[0]->GetParticle()->GetFirstMother() != fDaughter[1]->GetParticle()->GetFirstMother()) {
259     return 0;
260   }
261
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());
265 }
266
267 //_____________________________________________________________________________
268 void AliRsnPairParticle::SetPair(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2)
269 {
270 //
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
274 //
275
276   Int_t i;
277
278   fDaughter[0] = daughter1;
279   fDaughter[1] = daughter2;
280
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();
288     }
289     for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
290   }
291
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();
297   }
298   for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
299 }
300
301 //_____________________________________________________________________________
302 void AliRsnPairParticle::ResetPair()
303 {
304 //
305 // Computes the total momentum for REC data and MC if available
306 //
307
308   Int_t i;
309
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();
317     }
318     for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
319   }
320
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();
326   }
327   for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
328 }
329
330 //_____________________________________________________________________________
331 void AliRsnPairParticle::RotateTrack(Int_t idx, Double_t angle, Bool_t isDegrees)
332 {
333 //
334 // Computes the total momentum for REC data and MC if available
335 //
336
337   if (idx < 0 || idx > 1) return;
338
339   Int_t    i;
340
341   // copy MC info (if available)
342   if (fDaughter[0]->GetParticle() && fDaughter[1]->GetParticle()) {
343     for (i = 0; i < 2; i++) {
344       if (i == idx) {
345         fDaughter[i]->RotateP(angle, fPTrackMC[i][0], fPTrackMC[i][1], isDegrees);
346       } else {
347         fPTrackMC[i][0] = fDaughter[i]->GetParticle()->Px();
348         fPTrackMC[i][1] = fDaughter[i]->GetParticle()->Py();
349       }
350       fPTrackMC[i][2] = fDaughter[i]->GetParticle()->Pz();
351     }
352     for (i = 0; i < 3; i++) fPTotMC[i] = fPTrackMC[0][i] + fPTrackMC[1][i];
353   }
354
355   for (i = 0; i < 2; i++) {
356     if (i == idx) {
357       fDaughter[i]->RotateP(angle, fPTrack[i][0], fPTrack[i][1], isDegrees);
358     } else {
359       fPTrack[i][0] = fDaughter[i]->GetParticle()->Px();
360       fPTrack[i][1] = fDaughter[i]->GetParticle()->Py();
361     }
362     fPTrack[i][2] = fDaughter[i]->GetParticle()->Pz();
363   }
364   for (i = 0; i < 3; i++) fPTot[i] = fPTrack[0][i] + fPTrack[1][i];
365
366 }
367
368 //_____________________________________________________________________________
369 void AliRsnPairParticle::PrintInfo(const Option_t *option)
370 {
371 //
372 // Print some info of the pair.
373 // The options are passed to the AliRsnDaughter::Print() method
374 //
375   option = "ALL";
376   AliInfo("======== BEGIN PAIR INFO ===========");
377   AliInfo("Track #1");
378   fDaughter[0]->Print(option);
379   AliInfo("Track #2");
380   fDaughter[1]->Print(option);
381   AliInfo("========= END PAIR INFO ===========");
382 }