28#include <gemc/glogging/glogger.h>
29#include <gemc/guts/gutilities.h>
32#include "G4ThreeVector.hh"
33#include "G4ParticleGun.hh"
129 const std::string& randomMomentumModel,
132 const std::string& thetaModel,
141 const std::string& randomVertexModel,
142 const std::shared_ptr<GLogger>& logger,
143 int generator_type = 1);
181 [[nodiscard]] std::vector<GparticleRuntimeRecord>
shootParticle(G4ParticleGun* particleGun,
182 G4Event* anEvent)
const;
197 return std::make_shared<Gparticle>(
224 [[nodiscard]]
const std::string&
getName()
const {
return name; }
231 [[nodiscard]]
int getPid()
const {
return pid; }
252 [[nodiscard]]
double getTheta()
const {
return theta; }
259 [[nodiscard]]
double getPhi()
const {
return phi; }
266 [[nodiscard]]
const G4ThreeVector&
getVertex()
const {
return v; }
308 void setName(
const std::string& n) { name = n; pid = get_pdg_id(); }
316 void setPhi(
double ph_rad) { phi = ph_rad; }
367 G4ThreeVector delta_v;
373 std::shared_ptr<GLogger> log;
376 [[nodiscard]]
double get_mass()
const;
388 friend std::ostream&
operator<<(std::ostream& os,
const std::shared_ptr<Gparticle>& ptr) {
389 if (ptr)
return os << *ptr;
390 else return os <<
"<null Gparticle>";
401 [[nodiscard]]
double randomizeNumberFromSigmaWithModel(
double center,
406 [[nodiscard]]
double calculateMomentum()
const;
413 [[nodiscard]]
double calculateKinEnergy(
double mass)
const;
416 [[nodiscard]] G4ThreeVector calculateBeamDirection(
double thetaRad,
double phiRad)
const;
419 [[nodiscard]] G4ThreeVector calculateVertex()
const;
Lightweight particle specification and primary vertex shooter.
double getDeltaPhi() const
Returns the azimuthal-angle spread parameter (GEMC internal units, radians).
const G4ThreeVector & getDeltaVertex() const
Returns the vertex spread vector (GEMC internal units, mm).
void setDeltaMomentum(double dp)
void setVertexX(double x)
const std::string & getName() const
Returns the particle name stored in this generator definition.
std::string getMomentumModel() const
Returns the momentum randomization model as a string token.
int getPid() const
Returns the resolved PDG particle id.
int getMultiplicity() const
Returns how many copies are generated per event.
friend std::ostream & operator<<(std::ostream &os, const Gparticle &gp)
Stream insertion operator used for pretty-printing configuration summaries.
void setVertexY(double y)
double getPhi() const
Returns the nominal azimuthal angle.
Gparticle(const Gparticle &)=delete
Copying is disabled.
std::vector< GparticleRuntimeRecord > shootParticle(G4ParticleGun *particleGun, G4Event *anEvent) const
Shoots this particle configuration into a Geant4 event.
void setName(const std::string &n)
double getMomentum() const
Returns the nominal momentum magnitude.
Gparticle(const std::string &name, int multiplicity, double p, double delta_p, const std::string &randomMomentumModel, double theta, double delta_theta, const std::string &thetaModel, double phi, double delta_phi, double avx, double avy, double avz, double adelta_vx, double adelta_vy, double adelta_vz, const std::string &randomVertexModel, const std::shared_ptr< GLogger > &logger, int generator_type=1)
Constructs a particle configuration from pre-converted G4-unit values.
void setDeltaTheta(double dt)
int getGeneratorType() const
Returns the generator source type.
void setPhi(double ph_rad)
void setMomentum(double p_mev)
double getDeltaTheta() const
Returns the polar-angle spread parameter (GEMC internal units, radians).
void setDeltaVertexX(double x)
void setTheta(double t_rad)
void setVertexZ(double z)
void setDeltaVertexY(double y)
double getTheta() const
Returns the nominal polar angle.
void setThetaModel(const std::string &s)
friend std::ostream & operator<<(std::ostream &os, const std::shared_ptr< Gparticle > &ptr)
Stream insertion operator overload for shared pointers.
static std::shared_ptr< Gparticle > create_default_gparticle(const std::shared_ptr< GLogger > &log)
Creates a minimal default particle configuration.
~Gparticle()
Destructor emits a debug-level lifecycle message.
void setMomentumModel(const std::string &s)
const G4ThreeVector & getVertex() const
Returns the nominal vertex position.
double getDeltaMomentum() const
Returns the momentum spread parameter (GEMC internal units, MeV).
void setVertexModel(const std::string &s)
Gparticle & operator=(const Gparticle &)=delete
Copy assignment is disabled.
void setMultiplicity(int m)
std::string getVertexModel() const
Returns the vertex randomization model as a string token.
void setDeltaPhi(double dp)
void setDeltaVertexZ(double z)
std::string getThetaModel() const
Returns the theta randomization model as a string token.
std::shared_ptr< Gparticle > GparticlePtr
Shared pointer type used for Gparticle instances.
double getG4Number(const string &v, bool warnIfNotUnit=false)
randomModel stringToRandomModel(const std::string &str)
constexpr const char * to_string(randomModel m) noexcept
Runtime values for one generated primary particle.