DD4hep  1.36.0
Detector Description Toolkit for High Energy Physics
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
dd4hep::sim::Geant4IsotropeGenerator Class Reference

Generate particles isotrop in space around origine (0,0,0) More...

#include <Geant4IsotropeGenerator.h>

Inheritance diagram for dd4hep::sim::Geant4IsotropeGenerator:
dd4hep::sim::Geant4ParticleGenerator dd4hep::sim::Geant4GeneratorAction dd4hep::sim::Geant4Action dd4hep::sim::Geant4ParticleGun

Public Member Functions

 Geant4IsotropeGenerator ()=delete
 Inhibit default constructor. More...
 
 Geant4IsotropeGenerator (const Geant4IsotropeGenerator &copy)=delete
 Inhibit copy constructor. More...
 
 Geant4IsotropeGenerator (Geant4Context *context, const std::string &name)
 Standard constructor. More...
 
virtual ~Geant4IsotropeGenerator ()
 Default destructor. More...
 
- Public Member Functions inherited from dd4hep::sim::Geant4ParticleGenerator
 Geant4ParticleGenerator (Geant4Context *context, const std::string &name)
 Standard constructor. More...
 
virtual ~Geant4ParticleGenerator ()
 Default destructor. More...
 
virtual void operator() (G4Event *event) override
 Callback to generate primary particles. More...
 
- Public Member Functions inherited from dd4hep::sim::Geant4GeneratorAction
 Geant4GeneratorAction (Geant4Context *context, const std::string &name)
 Standard constructor. More...
 
virtual ~Geant4GeneratorAction ()
 Default destructor. More...
 
- Public Member Functions inherited from dd4hep::sim::Geant4Action
 Geant4Action (Geant4Context *context, const std::string &nam)
 Standard constructor. More...
 
long addRef ()
 Increase reference count. More...
 
long release ()
 Decrease reference count. Implicit destruction. More...
 
Geant4Contextcontext () const
 Access the context. More...
 
virtual void updateContext (Geant4Context *ctxt)
 Set or update client context. More...
 
virtual void configureFiber (Geant4Context *thread_context)
 Set or update client for the use in a new thread fiber. More...
 
const std::string & name () const
 Access name of the action. More...
 
const char * c_name () const
 Access name of the action. More...
 
void setName (const std::string &new_name)
 Set the object name. More...
 
PropertyManagerproperties ()
 Access to the properties of the object. More...
 
PrintLevel outputLevel () const
 Access the output level. More...
 
PrintLevel setOutputLevel (PrintLevel new_level)
 Set the output level; returns previous value. More...
 
Geant4UIMessengercontrol () const
 Access to the UI messenger. More...
 
virtual void enableUI ()
 Enable and install UI messenger. More...
 
template<typename T >
Geant4ActiondeclareProperty (const std::string &nam, T &val)
 Declare property. More...
 
template<typename T >
Geant4ActiondeclareProperty (const char *nam, T &val)
 Declare property. More...
 
bool hasProperty (const std::string &name) const
 Check property for existence. More...
 
Propertyproperty (const std::string &name)
 Access single property. More...
 
virtual void installMessengers ()
 Install property control messenger if wanted. More...
 
virtual void installCommandMessenger ()
 Install command control messenger if wanted. More...
 
virtual void installPropertyMessenger ()
 Install property control messenger if wanted. More...
 
void print (const char *fmt,...) const
 Support for messages with variable output level using output level. More...
 
void printM1 (const char *fmt,...) const
 Support for messages with variable output level using output level-1. More...
 
void printM2 (const char *fmt,...) const
 Support for messages with variable output level using output level-2. More...
 
void printP1 (const char *fmt,...) const
 Support for messages with variable output level using output level+1. More...
 
void printP2 (const char *fmt,...) const
 Support for messages with variable output level using output level+2. More...
 
void always (const char *fmt,...) const
 Support of always printed messages. More...
 
void debug (const char *fmt,...) const
 Support of debug messages. More...
 
void info (const char *fmt,...) const
 Support of info messages. More...
 
void warning (const char *fmt,...) const
 Support of warning messages. More...
 
void error (const char *fmt,...) const
 Support of error messages. More...
 
bool return_error (bool return_value, const char *fmt,...) const
 Action to support error messages. More...
 
void fatal (const char *fmt,...) const
 Support of fatal messages. Throws exception. More...
 
void except (const char *fmt,...) const
 Support of exceptions: Print fatal message and throw runtime_error. More...
 
void abortRun (const std::string &exception, const char *fmt,...) const
 Abort Geant4 Run by throwing a G4Exception with type RunMustBeAborted. More...
 
Geant4RunActionSequencerunAction () const
 Access to the main run action sequence from the kernel object. More...
 
Geant4EventActionSequenceeventAction () const
 Access to the main event action sequence from the kernel object. More...
 
Geant4SteppingActionSequencesteppingAction () const
 Access to the main stepping action sequence from the kernel object. More...
 
Geant4TrackingActionSequencetrackingAction () const
 Access to the main tracking action sequence from the kernel object. More...
 
Geant4StackingActionSequencestackingAction () const
 Access to the main stacking action sequence from the kernel object. More...
 
Geant4GeneratorActionSequencegeneratorAction () const
 Access to the main generator action sequence from the kernel object. More...
 

Protected Member Functions

void initHalton (Geant4Random &rnd) const
 Initialize Cranley-Patterson shifts using rnd; set m_haltonIndex = m_haltonOffset. More...
 
double haltonScrambled (uint64_t index, unsigned int dim) const
 Return the scrambled Halton sample for dimension dim (0=phi,1=theta,2=momentum) More...
 
std::function< double(unsigned int)> makeSampler (Geant4Random &rnd) const
 Build a per-particle sampler: PRNG or Halton depending on m_halton. More...
 
void sampleMomentum (double h, double &momentum) const
 Sample momentum from [m_momentumMin, m_momentumMax] using a pre-computed [0,1) value h. More...
 
virtual void getParticleDirection (int num, ROOT::Math::XYZVector &direction, double &momentum) const override
 Particle modification. Caller presets defaults to: ( direction = m_direction, momentum = [m_momentumMin, m_momentumMax]) More...
 
void getParticleDirectionFFbar (int num, ROOT::Math::XYZVector &direction, double &momentum) const
 e+e- --> ffbar particle distribution ~ 1 + cos^2(theta) (PRNG only; incompatible with Halton) More...
 
void getParticleDirectionEta (int num, const std::function< double(unsigned int)> &sample, ROOT::Math::XYZVector &direction, double &momentum) const
 Flat pseudorapidity (eta) distribution. More...
 
void getParticleDirectionCosTheta (int num, const std::function< double(unsigned int)> &sample, ROOT::Math::XYZVector &direction, double &momentum) const
 Particle distribution ~ cos(theta) More...
 
void getParticleDirectionUniform (int num, const std::function< double(unsigned int)> &sample, ROOT::Math::XYZVector &direction, double &momentum) const
 Uniform particle distribution. More...
 
- Protected Member Functions inherited from dd4hep::sim::Geant4ParticleGenerator
virtual void getParticleMultiplicity (int &multiplicity) const
 Particle modification. Caller presets defaults to: (multiplicity=m_multiplicity) More...
 
virtual void getVertexPosition (ROOT::Math::XYZVector &position) const
 Particle's vertex modification. Caller presets defaults to: (multiplicity=m_multiplicity) More...
 
void getParticleMomentumUniform (double &momentum) const
 Uniform particle momentum. More...
 
virtual void printInteraction (int mask) const
 Print single particle interaction identified by its mask. More...
 
virtual void printInteraction (Geant4PrimaryInteraction *inter) const
 Print single particle interaction identified by its reference. More...
 
- Protected Member Functions inherited from dd4hep::sim::Geant4GeneratorAction
 DDG4_DEFINE_ACTION_CONSTRUCTORS (Geant4GeneratorAction)
 Define standard assignments and constructors. More...
 
- Protected Member Functions inherited from dd4hep::sim::Geant4Action
 DDG4_DEFINE_ACTION_CONSTRUCTORS (Geant4Action)
 Define standard assignments and constructors. More...
 
virtual ~Geant4Action ()
 Default destructor. More...
 

Static Protected Member Functions

static double haltonValue (uint64_t index, int base)
 Compute the radical inverse of index in the given base (standard Halton value) More...
 

Protected Attributes

std::string m_distribution
 Property: Distribution name. Default: "uniform". Allowed: "uniform", "cos(theta)", "ffbar", "eta". More...
 
double m_phiMin
 Property: Minimal phi angular value. More...
 
double m_phiMax
 Property: Maximal phi angular value. More...
 
double m_thetaMin
 Property: Minimal theta angular value. More...
 
double m_thetaMax
 Property: Maximal theta angular value. More...
 
bool m_halton
 Property: Enable scrambled Halton sequence sampling (RQMC mode) More...
 
uint64_t m_haltonOffset
 Property: Starting index in the Halton sequence (use for parallel-job partitioning) More...
 
uint64_t m_haltonIndex
 Current Halton sequence index (incremented per generated particle) More...
 
std::array< double, 3 > m_haltonShift
 Per-dimension additive scramble shifts in [0,1), sampled from Geant4Random on first use. More...
 
std::once_flag m_haltonOnce
 Ensures initHalton() runs exactly once across all events. More...
 
- Protected Attributes inherited from dd4hep::sim::Geant4ParticleGenerator
ROOT::Math::XYZVector m_direction
 Property: Shooting direction of the gun. More...
 
ROOT::Math::XYZVector m_position
 Property: Position of the gun in space. More...
 
std::string m_particleName
 Property: Particle name. More...
 
G4ParticleDefinition * m_particle
 Pointer to geant4 particle definition. More...
 
double m_energy
 Property: Fixed momentum value, overwrites momentumMin and momentumMax if set. More...
 
double m_momentumMin
 Property: Minimal momentum value. More...
 
double m_momentumMax
 Property: Maximal momentum value. More...
 
int m_multiplicity
 Property: Desired multiplicity of the particles to be shot. More...
 
int m_mask
 Property: User mask passed to all particles in the generated interaction. More...
 
- Protected Attributes inherited from dd4hep::sim::Geant4GeneratorAction
Callback m_calls
 
- Protected Attributes inherited from dd4hep::sim::Geant4Action
Geant4Contextm_context { nullptr }
 Reference to the Geant4 context. More...
 
Geant4UIMessengerm_control { nullptr }
 Control directory of this action. More...
 
int m_outputLevel { 3 }
 Default property: Output level. More...
 
bool m_needsControl { false }
 Default property: Flag to create control instance. More...
 
std::string m_name { }
 Action name. More...
 
PropertyManager m_properties { }
 Property pool. More...
 
long m_refCount { 1 }
 Reference count. Initial value: 1. More...
 

Additional Inherited Members

- Public Types inherited from dd4hep::sim::Geant4GeneratorAction
typedef Geant4SharedGeneratorAction shared_type
 

Detailed Description

Generate particles isotrop in space around origine (0,0,0)

Supports both standard PRNG-based sampling and Randomized Quasi-Monte Carlo sampling via scrambled Halton sequences (Cranley-Patterson rotation).

When Halton mode is enabled (property "Halton" = true), the three sampling dimensions use low-discrepancy Halton sequences in bases 2 (phi), 3 (theta), and 5 (momentum), each additively scrambled by a per-dimension shift derived from the Geant4Random seed. This provides superior phase-space coverage relative to a PRNG while remaining reproducible and independent across jobs (using different seeds or "HaltonOffset" values).

Note: the "ffbar" distribution is incompatible with Halton mode because its acceptance-rejection loop cannot be driven by a fixed per-particle Halton point.

Author
M.Frank
Version
1.0

Definition at line 54 of file Geant4IsotropeGenerator.h.

Constructor & Destructor Documentation

◆ Geant4IsotropeGenerator() [1/3]

dd4hep::sim::Geant4IsotropeGenerator::Geant4IsotropeGenerator ( )
delete

Inhibit default constructor.

◆ Geant4IsotropeGenerator() [2/3]

dd4hep::sim::Geant4IsotropeGenerator::Geant4IsotropeGenerator ( const Geant4IsotropeGenerator copy)
delete

Inhibit copy constructor.

◆ Geant4IsotropeGenerator() [3/3]

Geant4IsotropeGenerator::Geant4IsotropeGenerator ( Geant4Context context,
const std::string &  name 
)

Standard constructor.

Definition at line 23 of file Geant4IsotropeGenerator.cpp.

◆ ~Geant4IsotropeGenerator()

Geant4IsotropeGenerator::~Geant4IsotropeGenerator ( )
virtual

Default destructor.

Definition at line 39 of file Geant4IsotropeGenerator.cpp.

Member Function Documentation

◆ getParticleDirection()

void Geant4IsotropeGenerator::getParticleDirection ( int  num,
ROOT::Math::XYZVector &  direction,
double &  momentum 
) const
overrideprotectedvirtual

Particle modification. Caller presets defaults to: ( direction = m_direction, momentum = [m_momentumMin, m_momentumMax])

Particle modification. Caller presets defaults to: ( direction = m_direction, momentum = [mMin, mMax])

Use this function to implement isotrop guns, multiple guns etc. User must return a UNIT vector, which gets scaled with momentum.

Reimplemented from dd4hep::sim::Geant4ParticleGenerator.

Reimplemented in dd4hep::sim::Geant4ParticleGun.

Definition at line 156 of file Geant4IsotropeGenerator.cpp.

◆ getParticleDirectionCosTheta()

void Geant4IsotropeGenerator::getParticleDirectionCosTheta ( int  num,
const std::function< double(unsigned int)> &  sample,
ROOT::Math::XYZVector &  direction,
double &  momentum 
) const
protected

Particle distribution ~ cos(theta)

Definition at line 102 of file Geant4IsotropeGenerator.cpp.

◆ getParticleDirectionEta()

void Geant4IsotropeGenerator::getParticleDirectionEta ( int  num,
const std::function< double(unsigned int)> &  sample,
ROOT::Math::XYZVector &  direction,
double &  momentum 
) const
protected

Flat pseudorapidity (eta) distribution.

Particle distribution flat in eta (pseudo rapidity)

Definition at line 112 of file Geant4IsotropeGenerator.cpp.

◆ getParticleDirectionFFbar()

void Geant4IsotropeGenerator::getParticleDirectionFFbar ( int  num,
ROOT::Math::XYZVector &  direction,
double &  momentum 
) const
protected

e+e- --> ffbar particle distribution ~ 1 + cos^2(theta) (PRNG only; incompatible with Halton)

Definition at line 131 of file Geant4IsotropeGenerator.cpp.

◆ getParticleDirectionUniform()

void Geant4IsotropeGenerator::getParticleDirectionUniform ( int  num,
const std::function< double(unsigned int)> &  sample,
ROOT::Math::XYZVector &  direction,
double &  momentum 
) const
protected

Uniform particle distribution.

Definition at line 93 of file Geant4IsotropeGenerator.cpp.

◆ haltonScrambled()

double Geant4IsotropeGenerator::haltonScrambled ( uint64_t  index,
unsigned int  dim 
) const
protected

Return the scrambled Halton sample for dimension dim (0=phi,1=theta,2=momentum)

Cranley-Patterson scrambled Halton sample for dimension dim (0=phi, 1=theta, 2=momentum)

Definition at line 62 of file Geant4IsotropeGenerator.cpp.

◆ haltonValue()

double Geant4IsotropeGenerator::haltonValue ( uint64_t  index,
int  base 
)
staticprotected

Compute the radical inverse of index in the given base (standard Halton value)

Compute the radical inverse of index in the given base (Halton value in [0,1))

Definition at line 50 of file Geant4IsotropeGenerator.cpp.

◆ initHalton()

void Geant4IsotropeGenerator::initHalton ( Geant4Random rnd) const
protected

Initialize Cranley-Patterson shifts using rnd; set m_haltonIndex = m_haltonOffset.

Initialize Cranley-Patterson shifts using rnd; set m_haltonIndex = m_haltonOffset.

Definition at line 44 of file Geant4IsotropeGenerator.cpp.

◆ makeSampler()

std::function< double(unsigned int)> Geant4IsotropeGenerator::makeSampler ( Geant4Random rnd) const
protected

Build a per-particle sampler: PRNG or Halton depending on m_halton.

Build and return a per-particle sampler: either PRNG or Halton, depending on m_halton. For Halton mode, advances m_haltonIndex by one.

Definition at line 71 of file Geant4IsotropeGenerator.cpp.

◆ sampleMomentum()

void Geant4IsotropeGenerator::sampleMomentum ( double  h,
double &  momentum 
) const
protected

Sample momentum from [m_momentumMin, m_momentumMax] using a pre-computed [0,1) value h.

Sample momentum from [m_momentumMin, m_momentumMax] using a pre-computed [0,1) value h.

Definition at line 81 of file Geant4IsotropeGenerator.cpp.

Member Data Documentation

◆ m_distribution

std::string dd4hep::sim::Geant4IsotropeGenerator::m_distribution
protected

Property: Distribution name. Default: "uniform". Allowed: "uniform", "cos(theta)", "ffbar", "eta".

Definition at line 57 of file Geant4IsotropeGenerator.h.

◆ m_halton

bool dd4hep::sim::Geant4IsotropeGenerator::m_halton
protected

Property: Enable scrambled Halton sequence sampling (RQMC mode)

Definition at line 67 of file Geant4IsotropeGenerator.h.

◆ m_haltonIndex

uint64_t dd4hep::sim::Geant4IsotropeGenerator::m_haltonIndex
mutableprotected

Current Halton sequence index (incremented per generated particle)

Definition at line 71 of file Geant4IsotropeGenerator.h.

◆ m_haltonOffset

uint64_t dd4hep::sim::Geant4IsotropeGenerator::m_haltonOffset
protected

Property: Starting index in the Halton sequence (use for parallel-job partitioning)

Definition at line 69 of file Geant4IsotropeGenerator.h.

◆ m_haltonOnce

std::once_flag dd4hep::sim::Geant4IsotropeGenerator::m_haltonOnce
mutableprotected

Ensures initHalton() runs exactly once across all events.

Definition at line 75 of file Geant4IsotropeGenerator.h.

◆ m_haltonShift

std::array<double,3> dd4hep::sim::Geant4IsotropeGenerator::m_haltonShift
mutableprotected

Per-dimension additive scramble shifts in [0,1), sampled from Geant4Random on first use.

Definition at line 73 of file Geant4IsotropeGenerator.h.

◆ m_phiMax

double dd4hep::sim::Geant4IsotropeGenerator::m_phiMax
protected

Property: Maximal phi angular value.

Definition at line 61 of file Geant4IsotropeGenerator.h.

◆ m_phiMin

double dd4hep::sim::Geant4IsotropeGenerator::m_phiMin
protected

Property: Minimal phi angular value.

Definition at line 59 of file Geant4IsotropeGenerator.h.

◆ m_thetaMax

double dd4hep::sim::Geant4IsotropeGenerator::m_thetaMax
protected

Property: Maximal theta angular value.

Definition at line 65 of file Geant4IsotropeGenerator.h.

◆ m_thetaMin

double dd4hep::sim::Geant4IsotropeGenerator::m_thetaMin
protected

Property: Minimal theta angular value.

Definition at line 63 of file Geant4IsotropeGenerator.h.


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