gparticle
Loading...
Searching...
No Matches
Gparticle Class Reference

Lightweight particle specification and primary vertex shooter. More...

#include <gparticle.h>

Public Member Functions

 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.
 
 Gparticle (const Gparticle &)=delete
 Copying is disabled.
 
Gparticleoperator= (const Gparticle &)=delete
 Copy assignment is disabled.
 
 ~Gparticle ()
 Destructor emits a debug-level lifecycle message.
 
void shootParticle (G4ParticleGun *particleGun, G4Event *anEvent)
 Shoots this particle configuration into a Geant4 event.
 

Static Public Member Functions

static std::shared_ptr< Gparticlecreate_default_gparticle (const std::shared_ptr< GLogger > &log)
 Creates a minimal default particle configuration.
 

Friends

std::ostream & operator<< (std::ostream &os, const Gparticle &gp)
 Stream insertion operator used for pretty-printing configuration summaries.
 
std::ostream & operator<< (std::ostream &os, const std::shared_ptr< Gparticle > &ptr)
 Stream insertion operator overload for shared pointers.
 

Detailed Description

A Gparticle instance represents a generator-level particle configuration that can be used to produce primary vertices in a G4Event through a G4ParticleGun.

The class stores:

  • Identity: particle name and resolved PDG id
  • Multiplicity: number of copies shot per event
  • Kinematics: momentum magnitude and angular parameters
  • Vertex: position and optional spread/randomization
  • Randomization models: selection of uniform/gaussian/cosine (angles) and sphere (vertex)

Configuration is typically created by option parsing utilities and then used during event generation by calling shootParticle().

Logging:

  • A logger is provided at construction and retained for diagnostics.
  • Verbosity 2 typically prints a full configuration summary via the stream operator.

Definition at line 70 of file gparticle.h.

Constructor & Destructor Documentation

◆ Gparticle() [1/2]

Gparticle::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 )

This constructor converts user-facing numeric values paired with unit strings into internal numeric values (in the unit system returned by gutilities helpers), and converts randomization model strings into gutilities::randomModel values.

The particle PDG id is resolved at construction time by consulting the G4ParticleTable using the provided particle name.

Parameters
nameParticle name as understood by G4ParticleTable (e.g. "e-").
multiplicityNumber of particles to shoot per event.
pNominal momentum magnitude (interpreted together with punit).
delta_pSpread parameter for momentum randomization (interpreted with punit).
punitUnit string used to interpret p and delta_p (e.g. "MeV", "GeV").
randomMomentumModelRandom model name for momentum (e.g. "uniform", "gaussian").
thetaNominal polar angle (interpreted together with aunit).
delta_thetaSpread parameter for theta (interpreted with aunit).
thetaModelRandom model name for theta (e.g. "uniform", "cosine", "gaussian").
phiNominal azimuthal angle (interpreted together with aunit).
delta_phiSpread parameter for phi (interpreted with aunit).
aunitUnit string used to interpret angles (typically "deg" or "rad").
avxNominal vertex x component (interpreted together with vunit).
avyNominal vertex y component (interpreted together with vunit).
avzNominal vertex z component (interpreted together with vunit).
adelta_vxSpread parameter for vertex x (interpreted with vunit).
adelta_vySpread parameter for vertex y (interpreted with vunit).
adelta_vzSpread parameter for vertex z (interpreted with vunit).
vunitUnit string used to interpret vertex components (e.g. "cm", "mm").
randomVertexModelRandom model name for vertex (e.g. "uniform", "gaussian", "sphere").
loggerLogger used for diagnostics and error reporting.

Definition at line 23 of file gparticle.cc.

◆ Gparticle() [2/2]

Gparticle::Gparticle ( const Gparticle & )
delete

The class is intended to be managed through std::shared_ptr and not copied.

◆ ~Gparticle()

Gparticle::~Gparticle ( )
inline

Definition at line 142 of file gparticle.h.

Member Function Documentation

◆ create_default_gparticle()

static std::shared_ptr< Gparticle > Gparticle::create_default_gparticle ( const std::shared_ptr< GLogger > & log)
inlinestatic

This helper returns an electron with:

  • momentum 1 GeV, no spread
  • angles 0 deg, no spread
  • vertex at (0,0,0) cm, no spread
  • uniform random models where relevant
Parameters
logLogger to associate with the constructed particle.
Returns
A shared pointer to the default Gparticle configuration.

Definition at line 176 of file gparticle.h.

◆ operator=()

Gparticle & Gparticle::operator= ( const Gparticle & )
delete

◆ shootParticle()

void Gparticle::shootParticle ( G4ParticleGun * particleGun,
G4Event * anEvent )

The method resolves the particle definition from the G4ParticleTable (using the stored particle name) and then, for each copy defined by the configured multiplicity:

  • sets the particle kinetic energy based on randomized momentum and mass
  • sets the momentum direction based on randomized theta/phi
  • sets the vertex position based on the configured vertex model
  • calls GeneratePrimaryVertex on the provided G4ParticleGun

Error handling:

  • If the G4ParticleTable is unavailable, an error is logged.
  • If the particle is not found, an error is logged.
Parameters
particleGunThe G4ParticleGun used to generate the primary vertices.
anEventThe G4Event that receives the generated primary vertices.

Definition at line 79 of file gparticle.cc.

Friends And Related Symbol Documentation

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream & os,
const Gparticle & gp )
friend

Definition at line 231 of file gparticle.cc.

◆ operator<< [2/2]

std::ostream & operator<< ( std::ostream & os,
const std::shared_ptr< Gparticle > & ptr )
friend
Parameters
osOutput stream.
ptrPointer to a Gparticle; prints "<null Gparticle>" if null.
Returns
Output stream.

Definition at line 261 of file gparticle.h.


The documentation for this class was generated from the following files: