]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnDaughter.cxx
removed eff-c++ warnings
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnDaughter.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 AliRsnDaughter
18 //                     ----------------------
19 //           A simple object which describes a reconstructed track
20 //           with some references to its related generated particle
21 //           and some facilities which could help in composing its
22 //           4-momentum, for resonance study.
23 // 
24 // author: A. Pulvirenti             (email: alberto.pulvirenti@ct.infn.it)
25 //-------------------------------------------------------------------------
26
27 #include <TParticle.h>
28 #include <TString.h>
29
30 #include "AliLog.h"
31 #include "AliESDtrack.h"
32 #include "AliRsnDaughter.h"
33
34 ClassImp(AliRsnDaughter)
35
36 //--------------------------------------------------------------------------------------------------------
37 AliRsnDaughter::AliRsnDaughter() :
38   TObject(),
39   fSign((Char_t)0),
40   fPDG((UShort_t)0),
41   fIndex((UShort_t)0),
42   fMass(0.0),
43   fLabel(-1),
44   fTruePDG((Short_t)0),
45   fMother(-1),
46   fMotherPDG((Short_t)0)
47 {
48 // 
49 // Default constructor.
50 // Its unique argument defines how many PID weights are allowed. 
51 // Actually, it should be the same as AliESDtrack::kSPECIES (=5).
52 // 
53         
54         Int_t i;
55         for (i = 0; i < AliPID::kSPECIES; i++) {
56                 if (i < 3) {
57                         fP[i] = 0.0;
58                         fV[i] = 0.0;
59                 }
60                 fPIDwgt[i] = 0.0;
61         }
62 }
63 //--------------------------------------------------------------------------------------------------------
64 AliRsnDaughter::AliRsnDaughter(Int_t label, UShort_t index, Double_t *p, Double_t *v, Char_t sign) :
65   TObject(),
66   fSign(sign),
67   fPDG((UShort_t)0),
68   fIndex(index),
69   fMass(0.0),
70   fLabel(label),
71   fTruePDG((Short_t)0),
72   fMother(-1),
73   fMotherPDG((Short_t)0)
74 {
75 //
76 // [PRIVATE]
77 // Constructor with arguments.
78 // To create an object with all its standard data members filled (the ones coming from ESD)
79 //
80         Int_t i;
81         for (i = 0; i < AliPID::kSPECIES; i++) {
82                 if (i < 3) {
83                         fP[i] = p[i];
84                         fV[i] = v[i];
85                 }
86                 fPIDwgt[i] = 0.0;
87         }
88 }
89 //--------------------------------------------------------------------------------------------------------
90 AliRsnDaughter * AliRsnDaughter::Adopt(AliESDtrack* esdTrack, Int_t index)
91 {
92 //
93 // Copies reconstructed data from an AliESDtrack:
94 //
95 // - charge sign
96 // - momentum
97 // - point of closest approach to primary vertex
98 // - ESD pid weights
99 // - track label (AliESDtrack::GetLabel())
100 //
101 // Given that it happened that tracks have exactly zero momentum and DCA point,
102 // these quantities are checked and skipped when caught.
103 //
104         Double_t p[3], v[3], pid[AliPID::kSPECIES];
105         
106         esdTrack->GetPxPyPz(p);
107         esdTrack->GetXYZ(v);
108         esdTrack->GetESDpid(pid);
109         
110         if (p[0] == 0.0 || p[1] == 0.0 || p[2] == 0.0) return 0x0;
111         if (v[0] == 0.0 || v[1] == 0.0 || v[2] == 0.0) return 0x0;
112                 
113         AliRsnDaughter *out = new AliRsnDaughter(esdTrack->GetLabel(), (UShort_t)index, p, v, (Char_t)esdTrack->GetSign());
114         
115         // store PID weights
116         out->SetPIDweights(pid);
117         
118         return out;
119 }
120 //--------------------------------------------------------------------------------------------------------
121 AliRsnDaughter * AliRsnDaughter::Adopt(TParticle* particle, Int_t label)
122 {
123 //
124 // Copies data from a generated particle:
125 // 
126 // - PDG code
127 // - charge sign
128 // - momentum
129 // - production vertex
130 // - GEANT label of mother track
131 //
132         Int_t    pdg;
133         Char_t   sign;
134         Double_t p[3], v[3];
135         
136         // get particle sign form the sign of PDG code
137         pdg = particle->GetPdgCode();
138         if (TMath::Abs(pdg) < 20) {
139                 if (pdg > 0) sign = -1; else sign = 1;
140         }
141         else if (TMath::Abs(pdg) < 3000) {
142                 if (pdg > 0) sign = 1; else sign = -1;
143         }
144         else {
145                 return 0x0;
146         }
147         
148         p[0] = particle->Px();
149         p[1] = particle->Py();
150         p[2] = particle->Pz();
151         
152         v[0] = particle->Vx();
153         v[1] = particle->Vy();
154         v[2] = particle->Vz();
155         
156         AliRsnDaughter *out = new AliRsnDaughter(label, (UShort_t)TMath::Abs(label), p, v, sign);
157         
158         // set simulation data
159         out->SetPDG(TMath::Abs(pdg));
160         out->SetTruePDG(TMath::Abs(pdg));
161         out->SetMother(particle->GetFirstMother());
162         
163         return out;
164 }
165 //--------------------------------------------------------------------------------------------------------
166 void AliRsnDaughter::Print(Option_t *option) const
167 {
168 // 
169 // Print informations about track.
170 // All options are used to add some specifical information as required:
171 // "S" --> charge sign
172 // "L" --> track label
173 // "I" --> assigned PID (PDG code)
174 // "T" --> true PDG code
175 // "V" --> coordinates of track vertex
176 // "P" --> coordinates of track momentum
177 // "M" --> mother label
178 // "N" --> mother PDG code
179 // "W" --> ESD PID weights
180 //
181
182         TString output("Track info: ");
183         TString opt(option);
184         opt.ToUpper();
185         
186         if (opt.Contains("S")) {
187                 output.Append(Form("sign = %d -- ", (Int_t)fSign));
188         }
189         if (opt.Contains("L")) {
190                 output.Append(Form("label = %d -- ", fLabel));
191         }
192         if (opt.Contains("I")) {
193                 output.Append(Form("PDG = %d -- ", fPDG));
194         }
195         if (opt.Contains("T")) {
196                 output.Append(Form("true PDG = %d -- ", fTruePDG));
197         }
198         if (opt.Contains("V")) {
199                 output.Append(Form("v = %f, %f, %f -- ", fV[0], fV[1], fV[2]));
200         }
201         if (opt.Contains("P")) {
202                 output.Append(Form("p = %f, %f, %f -- ", fP[0], fP[1], fP[2]));
203         }
204         if (opt.Contains("M")) {
205                 output.Append(Form("mum = %d -- ", fMother));
206         }
207         if (opt.Contains("N")) {
208                 output.Append(Form("mum PDG = %d -- ", fMotherPDG));
209         }
210         if (opt.Contains("W")) {
211                 output.Append(Form("PID wgts (e, mu, pi, K, p) = %f, %f, %f, %f, %f", fPIDwgt[0], fPIDwgt[1], fPIDwgt[2], fPIDwgt[3], fPIDwgt[4]));
212         }
213         
214         AliInfo(output.Data());
215 }
216 //--------------------------------------------------------------------------------------------------------
217 AliRsnDaughter AliRsnDaughter::Sum(AliRsnDaughter t1, AliRsnDaughter t2)
218 {
219 //
220 // Builds a new AliRsnDaughter object with the sum of momenta of two particles.
221 //
222         // create new AliRsnDaughter with default useless values for datamembers
223         AliRsnDaughter out;
224         
225         // if the summed particles are daughters of the same resonance
226         // their common mother label becomes the label of the sum
227         Int_t mum1 = t1.GetMother();
228         Int_t mum2 = t2.GetMother();
229         if (mum1 == mum2) {
230                 out.SetLabel(mum1);
231                 out.SetMotherPDG(t1.GetMotherPDG());
232         }
233         else {
234                 out.SetLabel(-1);
235                 out.SetMotherPDG(0);
236         }
237
238         // compute total 4-momentum
239         Double_t etot  = t1.GetEnergy() + t2.GetEnergy();
240         Double_t pxTot = t1.GetPx() + t2.GetPx();
241         Double_t pyTot = t1.GetPy() + t2.GetPy();
242         Double_t pzTot = t1.GetPz() + t2.GetPz();
243         Double_t mass  = TMath::Sqrt(etot*etot - pxTot*pxTot - pyTot*pyTot - pzTot*pzTot);
244         
245         out.SetPxPyPz(pxTot, pyTot, pzTot);
246         out.SetMass(mass);
247         
248         return out;
249 }