gparticle
Loading...
Searching...
No Matches
gparticle.h
Go to the documentation of this file.
1#pragma once
2
27// gemc
28#include "glogger.h"
29#include "gutilities.h"
30
31// geant4
32#include "G4ThreeVector.hh"
33#include "G4ParticleGun.hh"
34
35// c++
36#include <string>
37
38
71{
72public:
105 Gparticle(const std::string& name,
106 int multiplicity,
107 double p,
108 double delta_p,
109 const std::string& punit,
110 const std::string& randomMomentumModel,
111 double theta,
112 double delta_theta,
113 const std::string& thetaModel,
114 double phi,
115 double delta_phi,
116 const std::string& aunit,
117 double avx,
118 double avy,
119 double avz,
120 double adelta_vx,
121 double adelta_vy,
122 double adelta_vz,
123 const std::string& vunit,
124 const std::string& randomVertexModel,
125 const std::shared_ptr<GLogger>& logger);
126
132 Gparticle(const Gparticle&) = delete;
133
137 Gparticle& operator=(const Gparticle&) = delete;
138
142 ~Gparticle() { log->debug(DESTRUCTOR, "Gparticle"); }
143
162 void shootParticle(G4ParticleGun* particleGun, G4Event* anEvent);
163
176 static std::shared_ptr<Gparticle> create_default_gparticle(const std::shared_ptr<GLogger>& log) {
177 return std::make_shared<Gparticle>(
178 "e-",
179 1,
180 1,
181 0,
182 "GeV",
183 "uniform",
184 0,
185 0,
186 "uniform",
187 0,
188 0,
189 "deg",
190 0,
191 0,
192 0,
193 0,
194 0,
195 0,
196 "cm",
197 "uniform",
198 log
199 );
200 }
201
202private:
204 std::string name;
205
207 int pid;
208
210 int multiplicity;
211
213 double p;
214
216 double delta_p;
217
219 gutilities::randomModel randomMomentumModel;
220
222 double theta;
223
225 double delta_theta;
226
228 gutilities::randomModel randomThetaModel;
229
231 double phi;
232
234 double delta_phi;
235
237 G4ThreeVector v;
238
240 G4ThreeVector delta_v;
241
243 gutilities::randomModel randomVertexModel;
244
246 std::shared_ptr<GLogger> log;
247
249 [[nodiscard]] double get_mass() const;
250
252 friend std::ostream& operator<<(std::ostream& os, const Gparticle& gp);
253
261 friend std::ostream& operator<<(std::ostream& os, const std::shared_ptr<Gparticle>& ptr) {
262 if (ptr) return os << *ptr;
263 else return os << "<null Gparticle>";
264 }
265
274 [[nodiscard]] double randomizeNumberFromSigmaWithModel(double center,
275 double delta,
276 gutilities::randomModel model) const;
277
279 double calculateMomentum();
280
286 double calculateKinEnergy(double mass);
287
289 G4ThreeVector calculateBeamDirection();
290
292 G4ThreeVector calculateVertex();
293
295 int get_pdg_id();
296};
297
303using GparticlePtr = std::shared_ptr<Gparticle>;
void debug(debug_type type, Args &&... args) const
Lightweight particle specification and primary vertex shooter.
Definition gparticle.h:71
void shootParticle(G4ParticleGun *particleGun, G4Event *anEvent)
Shoots this particle configuration into a Geant4 event.
Definition gparticle.cc:79
friend std::ostream & operator<<(std::ostream &os, const Gparticle &gp)
Stream insertion operator used for pretty-printing configuration summaries.
Definition gparticle.cc:231
Gparticle(const Gparticle &)=delete
Copying is disabled.
friend std::ostream & operator<<(std::ostream &os, const std::shared_ptr< Gparticle > &ptr)
Stream insertion operator overload for shared pointers.
Definition gparticle.h:261
static std::shared_ptr< Gparticle > create_default_gparticle(const std::shared_ptr< GLogger > &log)
Creates a minimal default particle configuration.
Definition gparticle.h:176
Gparticle(const std::string &name, int multiplicity, double p, double delta_p, const std::string &punit, const std::string &randomMomentumModel, double theta, double delta_theta, const std::string &thetaModel, double phi, double delta_phi, const std::string &aunit, double avx, double avy, double avz, double adelta_vx, double adelta_vy, double adelta_vz, const std::string &vunit, const std::string &randomVertexModel, const std::shared_ptr< GLogger > &logger)
Constructs a particle configuration from user-facing parameters.
Definition gparticle.cc:23
~Gparticle()
Destructor emits a debug-level lifecycle message.
Definition gparticle.h:142
Gparticle & operator=(const Gparticle &)=delete
Copy assignment is disabled.
DESTRUCTOR
std::shared_ptr< Gparticle > GparticlePtr
Shared pointer type used for Gparticle instances.
Definition gparticle.h:303