CbmRoot
UParticle.cxx
Go to the documentation of this file.
1 #include "UParticle.h"
2 
3 #include "TParticle.h"
4 
5 #include <iostream>
6 using namespace std;
7 
8 
9 //____________________________________________________________________
10 //
11 // UParticle
12 //
13 // Class for particle description.
14 //
15 
16 
17 //--------------------------------------------------------------------
19  : TObject()
20  , fIndex(0)
21  , fPdg(0)
22  , fStatus(0)
23  , fParent(0)
24  , fParentDecay(0)
25  , fMate(0)
26  , fDecay(0)
27  , fChild()
28  , fPx(0.)
29  , fPy(0.)
30  , fPz(0.)
31  , fE(0.)
32  , fX(0.)
33  , fY(0.)
34  , fZ(0.)
35  , fT(0.)
36  , fWeight(0.) {
37  fChild[0] = 0;
38  fChild[1] = 0;
39 }
40 //--------------------------------------------------------------------
41 
42 
43 //--------------------------------------------------------------------
45  Int_t pdg,
46  Int_t status,
47  Int_t parent,
48  Int_t parentDecay,
49  Int_t mate,
50  Int_t decay,
51  Int_t child[2],
52  Double_t px,
53  Double_t py,
54  Double_t pz,
55  Double_t e,
56  Double_t x,
57  Double_t y,
58  Double_t z,
59  Double_t t,
60  Double_t weight)
61  : TObject()
62  , fIndex(index)
63  , fPdg(pdg)
64  , fStatus(status)
65  , fParent(parent)
66  , fParentDecay(parentDecay)
67  , fMate(mate)
68  , fDecay(decay)
69  , fPx(px)
70  , fPy(py)
71  , fPz(pz)
72  , fE(e)
73  , fX(x)
74  , fY(y)
75  , fZ(z)
76  , fT(t)
77  , fWeight(weight) {
78  fChild[0] = child[0];
79  fChild[1] = child[1];
80 }
81 //--------------------------------------------------------------------
82 
83 
84 //--------------------------------------------------------------------
86  Int_t pdg,
87  Int_t status,
88  Int_t parent,
89  Int_t parentDecay,
90  Int_t mate,
91  Int_t decay,
92  Int_t child[2],
93  TLorentzVector mom,
94  TLorentzVector pos,
95  Double_t weight)
96  : TObject()
97  , fIndex(index)
98  , fPdg(pdg)
99  , fStatus(status)
100  , fParent(parent)
101  , fParentDecay(parentDecay)
102  , fMate(mate)
103  , fDecay(decay)
104  , fPx(mom.Px())
105  , fPy(mom.Py())
106  , fPz(mom.Pz())
107  , fE(mom.E())
108  , fX(pos.X())
109  , fY(pos.Y())
110  , fZ(pos.Z())
111  , fT(pos.T())
112  , fWeight(weight) {
113  fChild[0] = child[0];
114  fChild[1] = child[1];
115 }
116 //--------------------------------------------------------------------
117 
118 
119 //--------------------------------------------------------------------
121  : TObject(right)
122  , fIndex(right.fIndex)
123  , fPdg(right.fPdg)
124  , fStatus(right.fStatus)
125  , fParent(right.fParent)
126  , fParentDecay(right.fParentDecay)
127  , fMate(right.fMate)
128  , fDecay(right.fDecay)
129  , fPx(right.fPx)
130  , fPy(right.fPy)
131  , fPz(right.fPz)
132  , fE(right.fE)
133  , fX(right.fX)
134  , fY(right.fY)
135  , fZ(right.fZ)
136  , fT(right.fT)
137  , fWeight(right.fWeight) {}
138 //--------------------------------------------------------------------
139 
140 
141 //--------------------------------------------------------------------
142 UParticle::UParticle(const TParticle& right)
143  : TObject()
144  , fIndex(0)
145  , fPdg(right.GetPdgCode())
146  , fStatus(right.GetStatusCode())
147  , fParent(right.GetFirstMother())
148  , fParentDecay(0)
149  , fMate(0)
150  , fDecay(0)
151  , fPx(right.Px())
152  , fPy(right.Py())
153  , fPz(right.Pz())
154  , fE(right.Energy())
155  , fX(right.Vx())
156  , fY(right.Vy())
157  , fZ(right.Vz())
158  , fT(right.T())
159  , fWeight(right.GetWeight()) {
160  fChild[0] = right.GetFirstDaughter();
161  fChild[1] = right.GetLastDaughter();
162 }
163 //--------------------------------------------------------------------
164 
165 
166 //--------------------------------------------------------------------
168  // Destructor
169 }
170 //--------------------------------------------------------------------
171 
172 
173 //--------------------------------------------------------------------
175  // Assignment operator
176  TObject::operator=(right);
177  fIndex = right.fIndex;
178  fPdg = right.fPdg;
179  fStatus = right.fStatus;
180  fParent = right.fParent;
181  fParentDecay = right.fParentDecay;
182  fMate = right.fMate;
183  fDecay = right.fDecay;
184  fChild[0] = right.fChild[0];
185  fChild[1] = right.fChild[1];
186  fPx = right.fPx;
187  fPy = right.fPy;
188  fPz = right.fPz;
189  fE = right.fE;
190  fX = right.fX;
191  fY = right.fY;
192  fZ = right.fZ;
193  fT = right.fT;
194  fWeight = right.fWeight;
195  return (*this);
196 }
197 //--------------------------------------------------------------------
198 
199 
200 //--------------------------------------------------------------------
201 const UParticle& UParticle::operator=(const TParticle& right) {
202  // Assignment operator from the TParticle
203  fIndex = 0;
204  fPdg = right.GetPdgCode();
205  fStatus = right.GetStatusCode();
206  fParent = right.GetFirstMother();
207  fParentDecay = 0;
208  fMate = 0;
209  fDecay = 0;
210  fChild[0] = right.GetFirstDaughter();
211  fChild[1] = right.GetLastDaughter();
212  fPx = right.Px();
213  fPy = right.Py();
214  fPz = right.Pz();
215  fE = right.Energy();
216  fX = right.Vx();
217  fY = right.Vy();
218  fZ = right.Vz();
219  fT = right.T();
220  fWeight = right.GetWeight();
221  return (*this);
222 }
223 //--------------------------------------------------------------------
224 
225 
226 //--------------------------------------------------------------------
227 Bool_t UParticle::operator==(const UParticle& right) const {
228  // If equal operator
229  return (
230  fIndex == right.fIndex && fPdg == right.fPdg && fStatus == right.fStatus
231  && fParent == right.fParent && fParentDecay == right.fParentDecay
232  && fMate == right.fMate && fDecay == right.fDecay
233  && fChild[0] == right.fChild[0] && fChild[1] == right.fChild[1]
234  && ((TMath::Abs((fPx - right.fPx) / fPx) < 0.0001)
235  || (TMath::Abs(fPx) < 1e-16 && TMath::Abs(right.fPx) < 1e-16))
236  && ((TMath::Abs((fPy - right.fPy) / fPy) < 0.0001)
237  || (TMath::Abs(fPy) < 1e-16 && TMath::Abs(right.fPy) < 1e-16))
238  && ((TMath::Abs((fPz - right.fPz) / fPz) < 0.0001)
239  || (TMath::Abs(fPz) < 1e-16 && TMath::Abs(right.fPz) < 1e-16))
240  && ((TMath::Abs((fE - right.fE) / fE) < 0.0001)
241  || (TMath::Abs(fE) < 1e-16 && TMath::Abs(right.fE) < 1e-16))
242  && ((TMath::Abs((fX - right.fX) / fX) < 0.0001)
243  || (TMath::Abs(fX) < 1e-16 && TMath::Abs(right.fX) < 1e-16))
244  && ((TMath::Abs((fY - right.fY) / fY) < 0.0001)
245  || (TMath::Abs(fY) < 1e-16 && TMath::Abs(right.fY) < 1e-16))
246  && ((TMath::Abs((fZ - right.fZ) / fZ) < 0.0001)
247  || (TMath::Abs(fZ) < 1e-16 && TMath::Abs(right.fZ) < 1e-16))
248  && ((TMath::Abs((fT - right.fT) / fT) < 0.0001)
249  || (TMath::Abs(fT) < 1e-16 && TMath::Abs(right.fT) < 1e-16))
250  && ((TMath::Abs((fWeight - right.fWeight) / fWeight) < 0.0001)
251  || (TMath::Abs(fWeight) < 1e-16 && TMath::Abs(right.fWeight) < 1e-16)));
252 }
253 //--------------------------------------------------------------------
254 
255 
256 //--------------------------------------------------------------------
257 void UParticle::Print(Option_t* /*option*/) const {
258  // Print the data members to the standard output
259  cout << "------------------------------------------------" << endl
260  << "-I- Particle -I-" << endl
261  << "Index : " << fIndex << endl
262  << "PDG code : " << fPdg << endl
263  << "Status code : " << fStatus << endl
264  << "Parent index : " << fParent << endl
265  << "Parent decay index : " << fParentDecay << endl
266  << "Last collision partner : " << fMate << endl
267  << "Decay index : " << fDecay << endl
268  << "First child index : " << fChild[0] << endl
269  << "Last child index : " << fChild[1] << endl
270  << "Momentum (px, py, pz) (GeV) : (" << fPx << ", " << fPy << ", " << fPz
271  << ")" << endl
272  << "Energy (GeV) : " << fE << endl
273  << "Position (x, y, z) (fm) : (" << fX << ", " << fY << ", " << fZ
274  << ")" << endl
275  << "Creation time (fm) : " << fT << endl
276  << "Weight : " << fWeight << endl
277  << "------------------------------------------------" << endl;
278 }
279 //--------------------------------------------------------------------
280 
281 
UParticle::fZ
Double32_t fZ
Definition: UParticle.h:27
UParticle::~UParticle
virtual ~UParticle()
Definition: UParticle.cxx:167
UParticle
Definition: UParticle.h:10
UParticle::fDecay
Int_t fDecay
Definition: UParticle.h:19
UParticle::fMate
Int_t fMate
Definition: UParticle.h:18
UParticle::fChild
Int_t fChild[2]
Definition: UParticle.h:20
UParticle::fT
Double32_t fT
Definition: UParticle.h:28
UParticle::fPz
Double32_t fPz
Definition: UParticle.h:23
UParticle::operator=
const UParticle & operator=(const UParticle &right)
Definition: UParticle.cxx:174
UParticle::fPy
Double32_t fPy
Definition: UParticle.h:22
UParticle::operator==
Bool_t operator==(const UParticle &right) const
Definition: UParticle.cxx:227
UParticle.h
UParticle::UParticle
UParticle()
Definition: UParticle.cxx:18
UParticle::fParent
Int_t fParent
Definition: UParticle.h:16
UParticle::fPdg
Int_t fPdg
Definition: UParticle.h:14
UParticle::fX
Double32_t fX
Definition: UParticle.h:25
UParticle::Print
void Print(Option_t *="") const
Definition: UParticle.cxx:257
UParticle::fWeight
Double32_t fWeight
Definition: UParticle.h:29
UParticle::fY
Double32_t fY
Definition: UParticle.h:26
UParticle::fPx
Double32_t fPx
Definition: UParticle.h:21
UParticle::fE
Double32_t fE
Definition: UParticle.h:24
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
UParticle::fParentDecay
Int_t fParentDecay
Definition: UParticle.h:17
ClassImp
ClassImp(UParticle)
UParticle::fStatus
Int_t fStatus
Definition: UParticle.h:15
UParticle::fIndex
Int_t fIndex
Definition: UParticle.h:13