VMC Examples Version 6.8
Loading...
Searching...
No Matches
Ex03dParticle.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Virtual Monte Carlo examples
3// Copyright (C) 2014 - 2018 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
10/// \file Ex03dParticle.cxx
11/// \brief Implementation of the Ex03dParticle class
12///
13/// Simplified version of ROOT's TParticle to store in RNTuple
14///
15/// \date 07/07/2026
16/// \author Radoslaw Karabowicz; GSI
17
18#include "Ex03dParticle.h"
19
20//_____________________________________________________________________________
22 : fPdgCode(0),
23 fStatusCode(0),
24 fWeight(0),
25 fCalcMass(0),
26 fPx(0),
27 fPy(0),
28 fPz(0),
29 fE(0),
30 fVx(0),
31 fVy(0),
32 fVz(0),
33 fVt(0),
34 fPolarTheta(0),
35 fPolarPhi(0)
36{
37 fMother[0] = 0;
38 fMother[1] = 0;
39 fDaughter[0] = 0;
40 fDaughter[1] = 0;
41 fParticlePDG = 0;
42}
43
44//_____________________________________________________________________________
45Ex03dParticle::Ex03dParticle(Int_t pdg, Int_t status, Int_t mother1,
46 Int_t mother2, Int_t daughter1, Int_t daughter2, Double_t px, Double_t py,
47 Double_t pz, Double_t etot, Double_t vx, Double_t vy, Double_t vz,
48 Double_t time)
49 : fPdgCode(pdg),
50 fStatusCode(status),
51 fWeight(1.),
52 fPx(px),
53 fPy(py),
54 fPz(pz),
55 fE(etot),
56 fVx(vx),
57 fVy(vy),
58 fVz(vz),
59 fVt(time)
60{
61 fMother[0] = mother1;
62 fMother[1] = mother2;
63 fDaughter[0] = daughter1;
64 fDaughter[1] = daughter2;
65
66 SetPolarisation(0, 0, 0);
67
68 SetPdgCode(pdg);
69}
70
71//_____________________________________________________________________________
72Ex03dParticle::Ex03dParticle(Int_t pdg, Int_t status, Int_t mother1,
73 Int_t mother2, Int_t daughter1, Int_t daughter2, const TLorentzVector& p,
74 const TLorentzVector& v)
75 : fPdgCode(pdg),
76 fStatusCode(status),
77 fWeight(1.),
78 fPx(p.Px()),
79 fPy(p.Py()),
80 fPz(p.Pz()),
81 fE(p.E()),
82 fVx(v.X()),
83 fVy(v.Y()),
84 fVz(v.Z()),
85 fVt(v.T())
86{
87 fMother[0] = mother1;
88 fMother[1] = mother2;
89 fDaughter[0] = daughter1;
90 fDaughter[1] = daughter2;
91
92 SetPolarisation(0, 0, 0);
93
94 SetPdgCode(pdg);
95}
96
97//_____________________________________________________________________________
99 : fPdgCode(p.fPdgCode),
101 fWeight(p.fWeight),
103 fPx(p.fPx),
104 fPy(p.fPy),
105 fPz(p.fPz),
106 fE(p.fE),
107 fVx(p.fVx),
108 fVy(p.fVy),
109 fVz(p.fVz),
110 fVt(p.fVt),
114{
115 fMother[0] = p.fMother[0];
116 fMother[1] = p.fMother[1];
117 fDaughter[0] = p.fDaughter[0];
118 fDaughter[1] = p.fDaughter[1];
119}
120
121//_____________________________________________________________________________
123{
124 if (this != &p) {
125 fPdgCode = p.fPdgCode;
127 fMother[0] = p.fMother[0];
128 fMother[1] = p.fMother[1];
129 fDaughter[0] = p.fDaughter[0];
130 fDaughter[1] = p.fDaughter[1];
131 fWeight = p.fWeight;
132
134
135 fPx = p.fPx;
136 fPy = p.fPy;
137 fPz = p.fPz;
138 fE = p.fE;
139
140 fVx = p.fVx;
141 fVy = p.fVy;
142 fVz = p.fVz;
143 fVt = p.fVt;
144
147
149 }
150 return *this;
151}
152
153//_____________________________________________________________________________
155
156//_____________________________________________________________________________
158{
159 return 0.; // GetPDG()->Mass();
160}
161
162//_____________________________________________________________________________
164{
165 return 0; // GetPDG()->Beauty();
166}
167
168//_____________________________________________________________________________
170{
171 return 0; // GetPDG()->Charm();
172}
173
174//_____________________________________________________________________________
176{
177 return 0; // GetPDG()->Strangeness();
178}
179
180//_____________________________________________________________________________
181void Ex03dParticle::GetPolarisation(TVector3& v) const
182{
183 if (fPolarTheta == -99 && fPolarPhi == -99)
184 // No polarisation to return
185 v.SetXYZ(0., 0., 0.);
186 else
187 v.SetXYZ(TMath::Cos(fPolarPhi) * TMath::Sin(fPolarTheta),
188 TMath::Sin(fPolarPhi) * TMath::Sin(fPolarTheta), TMath::Cos(fPolarTheta));
189}
190
191//_____________________________________________________________________________
193{
194 // fParticlePDG = pdg;
195 /* fParticlePDG = TDatabasePDG::Instance()->GetParticle(pdg);
196 if (fParticlePDG) {
197 fCalcMass = fParticlePDG->Mass();
198 } else {
199 if (nWarnings < 10) {
200 Warning("SetPdgCode","PDG code %d unknown from TDatabasePDG",pdg);
201 nWarnings++;
202 }
203 Double_t a2 = fE*fE -fPx*fPx -fPy*fPy -fPz*fPz;
204 if (a2 >= 0) fCalcMass = TMath::Sqrt(a2);
205 else fCalcMass = -TMath::Sqrt(-a2);
206 }*/
207}
208
209//_____________________________________________________________________________
210void Ex03dParticle::SetPolarisation(Double_t polx, Double_t poly, Double_t polz)
211{
212 if (polx || poly || polz) {
214 TMath::ACos(polz / TMath::Sqrt(polx * polx + poly * poly + polz * polz));
215 fPolarPhi = TMath::Pi() + TMath::ATan2(-poly, -polx);
216 }
217 else {
218 fPolarTheta = -99;
219 fPolarPhi = -99;
220 }
221}
Definition of the Ex03dParticle class.
Double_t Py() const
Double_t Px() const
Double_t GetMass() const
Double_t Y() const
Double_t T() const
Ex03dParticle & operator=(const Ex03dParticle &)
Int_t Beauty() const
void SetPdgCode(Int_t pdg)
Int_t Strangeness() const
Double_t fPolarPhi
Int_t fDaughter[2]
Int_t Charm() const
Double_t fCalcMass
Double_t Pz() const
void SetPolarisation(Double_t theta, Double_t phi)
void GetPolarisation(TVector3 &v) const
Double_t fPolarTheta