VMC Examples Version 6.8
Loading...
Searching...
No Matches
Ex03dParticle.h
Go to the documentation of this file.
1#ifndef EX03_PARTICLE_H
2#define EX03_PARTICLE_H
3
4//------------------------------------------------
5// The Virtual Monte Carlo examples
6// Copyright (C) 2014 - 2018 Ivana Hrivnacova
7// All rights reserved.
8//
9// For the licensing terms see geant4_vmc/LICENSE.
10// Contact: root-vmc@cern.ch
11//-------------------------------------------------
12
13/// \file Ex03dParticle.h
14/// \brief Definition of the Ex03dParticle class
15///
16/// Simplified version of ROOT's TParticle to store in RNTuple
17///
18/// \author Radoslaw Karabowicz; GSI
19
20#include "TLorentzVector.h"
21
22/// \ingroup E03
23/// \brief Replacement of the TParticle
24///
25/// A variant of the TParticle class
26/// that can be stored in the RNTuple.
27///
28
29/// \date 07/07/2026
30/// \author Radoslaw Karabowicz, GSI
31
33{
34 public:
35 // ****** constructors and destructor
37
38 Ex03dParticle(Int_t pdg, Int_t status, Int_t mother1, Int_t mother2,
39 Int_t daughter1, Int_t daughter2, Double_t px, Double_t py, Double_t pz,
40 Double_t etot, Double_t vx, Double_t vy, Double_t vz, Double_t time);
41
42 Ex03dParticle(Int_t pdg, Int_t status, Int_t mother1, Int_t mother2,
43 Int_t daughter1, Int_t daughter2, const TLorentzVector& p,
44 const TLorentzVector& v);
45
46 Ex03dParticle(const Ex03dParticle& part);
47
49
50 // methods
52
53 Double_t Ek() const { return fE - fCalcMass; }
54 Int_t GetStatusCode() const { return fStatusCode; }
55 Int_t GetPdgCode() const { return fPdgCode; }
56 Int_t GetFirstMother() const { return fMother[0]; }
57 Int_t GetMother(Int_t i) const { return fMother[i]; }
58 Int_t GetSecondMother() const { return fMother[1]; }
59 Bool_t IsPrimary() const
60 {
61 return fMother[0] > -1 ? kFALSE : kTRUE;
62 } // Is this particle primary one?
63 Int_t GetFirstDaughter() const { return fDaughter[0]; }
64 Int_t GetDaughter(Int_t i) const { return fDaughter[i]; }
65 Int_t GetLastDaughter() const { return fDaughter[1]; }
66 Double_t GetCalcMass() const { return fCalcMass; }
67 Double_t GetMass() const;
68 Int_t GetNDaughters() const
69 {
70 return fDaughter[1] > 0 ? fDaughter[1] - fDaughter[0] + 1 : 0;
71 }
72 Float_t GetWeight() const { return fWeight; }
73 void GetPolarisation(TVector3& v) const;
74 // TParticlePDG* GetPDG (Int_t mode = 0) const;
75 Int_t Beauty() const;
76 Int_t Charm() const;
77 Int_t Strangeness() const;
78 Double_t PhiX() const
79 {
80 return TMath::Pi() + TMath::ATan2(-fPz, -fPy);
81 } // note that PhiX() returns an angle between 0 and 2pi
82 Double_t PhiY() const
83 {
84 return TMath::Pi() + TMath::ATan2(-fPx, -fPz);
85 } // note that PhiY() returns an angle between 0 and 2pi
86 Double_t PhiZ() const
87 {
88 return TMath::Pi() + TMath::ATan2(-fPy, -fPx);
89 } // note that PhiZ() returns an angle between 0 and 2pi
90 Double_t ThetaX() const
91 {
92 return (fPx == 0) ? TMath::PiOver2() : TMath::ACos(fPx / P());
93 }
94 Double_t ThetaY() const
95 {
96 return (fPy == 0) ? TMath::PiOver2() : TMath::ACos(fPy / P());
97 }
98 Double_t ThetaZ() const
99 {
100 return (fPz == 0) ? TMath::PiOver2() : TMath::ACos(fPz / P());
101 }
102 Double_t GetPolarTheta() const { return fPolarTheta; }
103 Double_t GetPolarPhi() const { return fPolarPhi; }
104 void GetPolarisation(Double_t& theta, Double_t& phi) const
105 {
106 theta = fPolarTheta;
107 phi = fPolarPhi;
108 }
109 void SetPolarTheta(Double_t theta) { fPolarTheta = theta; }
110 void SetPolarPhi(Double_t phi) { fPolarPhi = phi; }
111 void SetPolarisation(Double_t theta, Double_t phi)
112 {
113 fPolarTheta = theta;
114 fPolarPhi = phi;
115 }
116 void Momentum(TLorentzVector& v) const { v.SetPxPyPzE(fPx, fPy, fPz, fE); }
117 void ProductionVertex(TLorentzVector& v) const
118 {
119 v.SetXYZT(fVx, fVy, fVz, fVt);
120 }
121
122 Double_t Theta(
123 const Ex03dParticle& p) // Returns the angle between momenta of particles
124 {
125 Double_t v = P() * p.P();
126 if (v == 0)
127 v = 1;
128 else
129 v = (fPx * p.Px() + fPy * p.Py() + fPz * p.Pz()) / v;
130 if (v > 1)
131 v = 1;
132 else if (v < -1)
133 v = -1; // just a precaution
134 return TMath::ACos(v);
135 }
136
137 // ****** redefine several most oftenly used methods of LORENTZ_VECTOR
138
139 Double_t Vx() const { return fVx; }
140 Double_t Vy() const { return fVy; }
141 Double_t Vz() const { return fVz; }
142 Double_t T() const { return fVt; }
143 Double_t R() const
144 {
145 return TMath::Sqrt(fVx * fVx + fVy * fVy);
146 } // Radius of production vertex in cylindrical system
147 Double_t Rho() const
148 {
149 return TMath::Sqrt(fVx * fVx + fVy * fVy + fVz * fVz);
150 } // Radius of production vertex in spherical system
151 Double_t Px() const { return fPx; }
152 Double_t Py() const { return fPy; }
153 Double_t Pz() const { return fPz; }
154 Double_t P() const { return TMath::Sqrt(fPx * fPx + fPy * fPy + fPz * fPz); }
155 Double_t Pt() const { return TMath::Sqrt(fPx * fPx + fPy * fPy); }
156 Double_t Energy() const { return fE; }
157 Double_t Eta() const
158 {
159 Double_t pmom = P();
160 if (pmom != TMath::Abs(fPz))
161 return 0.5 * TMath::Log((pmom + fPz) / (pmom - fPz));
162 else
163 return 1.e30;
164 }
165 Double_t Y() const
166 {
167 if (fE != TMath::Abs(fPz))
168 return 0.5 * TMath::Log((fE + fPz) / (fE - fPz));
169 else
170 return 1.e30;
171 }
172
173 Double_t Phi() const
174 {
175 return TMath::Pi() + TMath::ATan2(-fPy, -fPx);
176 } // note that Phi() returns an angle between 0 and 2pi
177 Double_t Theta() const
178 {
179 return (fPz == 0) ? TMath::PiOver2() : TMath::ACos(fPz / P());
180 }
181
182 // setters
183
184 void SetFirstMother(int code) { fMother[0] = code; }
185 void SetMother(int i, int code) { fMother[i] = code; }
186 void SetLastMother(int code) { fMother[1] = code; }
187 void SetFirstDaughter(int code) { fDaughter[0] = code; }
188 void SetDaughter(int i, int code) { fDaughter[i] = code; }
189 void SetLastDaughter(int code) { fDaughter[1] = code; }
190 void SetCalcMass(Double_t mass) { fCalcMass = mass; }
191 void SetPdgCode(Int_t pdg);
192 void SetPolarisation(Double_t polx, Double_t poly, Double_t polz);
193 void SetPolarisation(const TVector3& v)
194 {
195 SetPolarisation(v.X(), v.Y(), v.Z());
196 }
197 void SetStatusCode(int status) { fStatusCode = status; }
198 void SetWeight(Float_t weight = 1) { fWeight = weight; }
199 void SetMomentum(Double_t px, Double_t py, Double_t pz, Double_t e)
200 {
201 fPx = px;
202 fPy = py;
203 fPz = pz;
204 fE = e;
205 }
206 void SetMomentum(const TLorentzVector& p)
207 {
208 SetMomentum(p.Px(), p.Py(), p.Pz(), p.Energy());
209 }
210 void SetProductionVertex(Double_t vx, Double_t vy, Double_t vz, Double_t t)
211 {
212 fVx = vx;
213 fVy = vy;
214 fVz = vz;
215 fVt = t;
216 }
217 void SetProductionVertex(const TLorentzVector& v)
218 {
219 SetProductionVertex(v.X(), v.Y(), v.Z(), v.T());
220 }
221
222 protected:
223 // data members
224
225 Int_t fPdgCode; // PDG code of the particle
226 Int_t fStatusCode; // generation status code
227 Int_t fMother[2]; // Indices of the mother particles
228 Int_t fDaughter[2]; // Indices of the daughter particles
229 Float_t fWeight; // particle weight
230
231 Double_t fCalcMass; // Calculated mass
232
233 Double_t fPx; // x component of momentum
234 Double_t fPy; // y component of momentum
235 Double_t fPz; // z component of momentum
236 Double_t fE; // Energy
237
238 Double_t fVx; // x of production vertex
239 Double_t fVy; // y of production vertex
240 Double_t fVz; // z of production vertex
241 Double_t fVt; // t of production vertex
242
243 Double_t fPolarTheta; // Polar angle of polarisation
244 Double_t fPolarPhi; // azymutal angle of polarisation
245
246 Int_t fParticlePDG; // PDG number
247 //----------------------------------------------------------------------------
248 // functions
249 //----------------------------------------------------------------------------
250
251 // ClassDef(Ex03dParticle,1) // Ex03dParticle vertex particle information
252};
253
254#endif
Double_t Py() const
void SetPolarisation(const TVector3 &v)
Double_t Px() const
void Momentum(TLorentzVector &v) const
Double_t GetMass() const
Double_t Y() const
void SetPolarPhi(Double_t phi)
Double_t Theta(const Ex03dParticle &p)
void SetProductionVertex(Double_t vx, Double_t vy, Double_t vz, Double_t t)
Double_t Phi() const
Double_t GetPolarTheta() const
Double_t T() const
void SetMomentum(Double_t px, Double_t py, Double_t pz, Double_t e)
Double_t PhiY() const
Ex03dParticle & operator=(const Ex03dParticle &)
Double_t Theta() const
Int_t Beauty() const
Int_t GetMother(Int_t i) const
Int_t GetFirstMother() const
void SetLastMother(int code)
void SetPdgCode(Int_t pdg)
Double_t Vz() const
void SetDaughter(int i, int code)
Float_t GetWeight() const
Double_t Energy() const
void GetPolarisation(Double_t &theta, Double_t &phi) const
Int_t Strangeness() const
void SetMother(int i, int code)
void SetFirstMother(int code)
Double_t fPolarPhi
Int_t GetStatusCode() const
void SetPolarTheta(Double_t theta)
Int_t GetPdgCode() const
Double_t ThetaY() const
Double_t PhiX() const
void SetWeight(Float_t weight=1)
void SetCalcMass(Double_t mass)
Double_t ThetaZ() const
Double_t GetPolarPhi() const
Int_t fDaughter[2]
Double_t Eta() const
Double_t Rho() const
Int_t GetNDaughters() const
void SetFirstDaughter(int code)
Int_t GetLastDaughter() const
Int_t Charm() const
Int_t GetFirstDaughter() const
Double_t GetCalcMass() const
Double_t Ek() const
Double_t fCalcMass
Double_t Vy() const
void SetLastDaughter(int code)
Double_t ThetaX() const
Double_t Vx() const
void SetMomentum(const TLorentzVector &p)
void ProductionVertex(TLorentzVector &v) const
Double_t Pz() const
void SetStatusCode(int status)
void SetPolarisation(Double_t theta, Double_t phi)
Double_t Pt() const
void GetPolarisation(TVector3 &v) const
Int_t GetSecondMother() const
Double_t P() const
Bool_t IsPrimary() const
Double_t PhiZ() const
Double_t fPolarTheta
void SetProductionVertex(const TLorentzVector &v)
Double_t R() const
Int_t GetDaughter(Int_t i) const