DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
|
Mini interface to THE random generator of the application. More...
#include <Geant4Random.h>
Public Member Functions | |
Geant4Random (Geant4Context *context, const std::string &name) | |
Standard constructor. More... | |
virtual | ~Geant4Random () |
Default destructor. More... | |
void | initialize () |
Initialize the instance. More... | |
CLHEP::HepRandomEngine * | engine () |
CLHEP random number engine (valid after initialization only) More... | |
virtual void | setSeed (long seed) |
Should initialise the status of the algorithm according to seed. More... | |
virtual void | setSeeds (const long *seeds, int size) |
Should initialise the status of the algorithm. More... | |
virtual void | saveStatus (const char filename[]="Config.conf") const |
Should save on a file specific to the instantiated engine in use the current status. More... | |
virtual void | restoreStatus (const char filename[]="Config.conf") |
Should read from a file and restore the last saved engine configuration. More... | |
virtual void | showStatus () const |
Should dump the current engine status on the screen. More... | |
double | rndm_clhep () |
Create flat distributed random numbers in the interval ]0,1] calling CLHEP. More... | |
double | rndm (int i=0) |
Create flat distributed random numbers in the interval ]0,1]. More... | |
void | rndmArray (int n, float *array) |
Create a float array of flat distributed random numbers in the interval ]0,1]. More... | |
void | rndmArray (int n, double *array) |
Create a double array of flat distributed random numbers in the interval ]0,1]. More... | |
double | uniform (double x1=1) |
Create uniformly disributed random numbers in the interval ]0,x1]. More... | |
double | uniform (double x1, double x2) |
Create uniformly disributed random numbers in the interval ]x1,x2]. More... | |
double | exp (double tau) |
Create exponentially distributed random numbers. More... | |
double | gauss (double mean=0, double sigma=1) |
Create gaussian distributed random numbers. More... | |
double | gamma (double k, double lambda) |
Create gamma distributed random numbers. More... | |
double | landau (double mean=0, double sigma=1) |
Create landau distributed random numbers. More... | |
void | circle (double &x, double &y, double r) |
Create tuple of randum number around a circle with radius r. More... | |
void | sphere (double &x, double &y, double &z, double r) |
Create tuple of randum number on a sphere with radius r. More... | |
double | poisson (double mean=1e0) |
Create poisson distributed random numbers. More... | |
double | breit_wigner (double mean=0e0, double gamma=1e0) |
Create breit wigner distributed random numbers. 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... | |
Geant4Context * | context () 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... | |
PropertyManager & | properties () |
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... | |
Geant4UIMessenger * | control () const |
Access to the UI messenger. More... | |
virtual void | enableUI () |
Enable and install UI messenger. More... | |
template<typename T > | |
Geant4Action & | declareProperty (const std::string &nam, T &val) |
Declare property. More... | |
template<typename T > | |
Geant4Action & | declareProperty (const char *nam, T &val) |
Declare property. More... | |
bool | hasProperty (const std::string &name) const |
Check property for existence. More... | |
Property & | property (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... | |
Geant4RunActionSequence & | runAction () const |
Access to the main run action sequence from the kernel object. More... | |
Geant4EventActionSequence & | eventAction () const |
Access to the main event action sequence from the kernel object. More... | |
Geant4SteppingActionSequence & | steppingAction () const |
Access to the main stepping action sequence from the kernel object. More... | |
Geant4TrackingActionSequence & | trackingAction () const |
Access to the main tracking action sequence from the kernel object. More... | |
Geant4StackingActionSequence & | stackingAction () const |
Access to the main stacking action sequence from the kernel object. More... | |
Geant4GeneratorActionSequence & | generatorAction () const |
Access to the main generator action sequence from the kernel object. More... | |
Static Public Member Functions | |
static Geant4Random * | instance (bool throw_exception=true) |
Access the main Geant4 random generator instance. Must be created before used! More... | |
static Geant4Random * | setMainInstance (Geant4Random *ptr) |
Make this random generator instance the one used by Geant4. More... | |
Protected Attributes | |
std::string | m_file |
Property: File name if initialized from file. If set, engine name and seeds are ignored. More... | |
std::string | m_engineType |
Property: Engine type. default: "HepJamesRandom". More... | |
long | m_seed |
Property: Initial random seed. Default: 123456789. More... | |
long | m_luxury |
bool | m_replace |
Property: Indicator to replace the ROOT gRandom instance. More... | |
CLHEP::HepRandomEngine * | m_engine |
Reference to the CLHEP random number engine (valid only after initialization) More... | |
TRandom * | m_rootRandom |
Reference to ROOT random instance. More... | |
TRandom * | m_rootOLD |
bool | m_inited |
Flag to remember initialization. More... | |
Protected Attributes inherited from dd4hep::sim::Geant4Action | |
Geant4Context * | m_context { nullptr } |
Reference to the Geant4 context. More... | |
Geant4UIMessenger * | m_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... | |
Friends | |
class | Geant4Exec |
Additional Inherited Members | |
Protected Member Functions inherited from dd4hep::sim::Geant4Action | |
DDG4_DEFINE_ACTION_CONSTRUCTORS (Geant4Action) | |
Define standard assignments and constructors. More... | |
virtual | ~Geant4Action () |
Default destructor. More... | |
Mini interface to THE random generator of the application.
Mini interface to THE random generator of the application. Necessary, that on every object creates its own instance, but accesses the main instance avaible throu the Geant4Context.
This is mandatory to ensure reproducability of the event generation process. Particular objects may use a dependent generator from an experiment framework like GAUDI.
This main interface is supposed to be stable. Unclear however is if the generation functions will have to become virtual.... Future will tell us.
The first instance of the random action is automatically set to be the Geant4 instance. If another instance should be used by Geant4, use setMainInstance(Geant4Random* ptr).
Definition at line 59 of file Geant4Random.h.
Geant4Random::Geant4Random | ( | Geant4Context * | context, |
const std::string & | name | ||
) |
Standard constructor.
Default constructor.
Please Note: Should be used only for initialization of the main instance. Subsequent usage should be invoked using the class member Geant4Random::instance().
context | Geant4 context for this action. |
name | Name of the action object |
Definition at line 82 of file Geant4Random.cpp.
|
virtual |
Default destructor.
Definition at line 97 of file Geant4Random.cpp.
double Geant4Random::breit_wigner | ( | double | mean = 0e0 , |
double | gamma = 1e0 |
||
) |
Create breit wigner distributed random numbers.
Definition at line 334 of file Geant4Random.cpp.
void Geant4Random::circle | ( | double & | x, |
double & | y, | ||
double | r | ||
) |
Create tuple of randum number around a circle with radius r.
Definition at line 316 of file Geant4Random.cpp.
|
inline |
CLHEP random number engine (valid after initialization only)
Access to the CLHEP random number engine. For further doc see CLHEP/Random/RandomEngine.h
Definition at line 116 of file Geant4Random.h.
double Geant4Random::exp | ( | double | tau | ) |
Create exponentially distributed random numbers.
Definition at line 298 of file Geant4Random.cpp.
double Geant4Random::gamma | ( | double | k, |
double | lambda | ||
) |
Create gamma distributed random numbers.
Definition at line 340 of file Geant4Random.cpp.
double Geant4Random::gauss | ( | double | mean = 0 , |
double | sigma = 1 |
||
) |
Create gaussian distributed random numbers.
Generates random vectors, uniformly distributed over a circle of given radius.
Definition at line 304 of file Geant4Random.cpp.
void Geant4Random::initialize | ( | ) |
Initialize the instance.
Called either by user or on request of the first random number. To propagate the engine to Geant4, initialize MUST be called by the user.
Create new engine if a type is specified
Definition at line 158 of file Geant4Random.cpp.
|
static |
Access the main Geant4 random generator instance. Must be created before used!
Definition at line 113 of file Geant4Random.cpp.
double Geant4Random::landau | ( | double | mean = 0 , |
double | sigma = 1 |
||
) |
Create landau distributed random numbers.
Definition at line 310 of file Geant4Random.cpp.
double Geant4Random::poisson | ( | double | mean = 1e0 | ) |
Create poisson distributed random numbers.
Definition at line 328 of file Geant4Random.cpp.
|
virtual |
Should read from a file and restore the last saved engine configuration.
Definition at line 224 of file Geant4Random.cpp.
double Geant4Random::rndm | ( | int | i = 0 | ) |
Create flat distributed random numbers in the interval ]0,1].
Definition at line 268 of file Geant4Random.cpp.
double Geant4Random::rndm_clhep | ( | ) |
Create flat distributed random numbers in the interval ]0,1] calling CLHEP.
Create flat distributed random numbers in the interval ]0,1].
Basic random generator functions
This is more or less a test function, since the result should be identical to calling rndm.
Definition at line 262 of file Geant4Random.cpp.
void Geant4Random::rndmArray | ( | int | n, |
double * | array | ||
) |
Create a double array of flat distributed random numbers in the interval ]0,1].
Definition at line 280 of file Geant4Random.cpp.
void Geant4Random::rndmArray | ( | int | n, |
float * | array | ||
) |
Create a float array of flat distributed random numbers in the interval ]0,1].
Definition at line 274 of file Geant4Random.cpp.
|
virtual |
Should save on a file specific to the instantiated engine in use the current status.
Definition at line 216 of file Geant4Random.cpp.
|
static |
Make this random generator instance the one used by Geant4.
Returns reference to previous instance. It is up to the user to manage the reference. Caveat: other code may hold references to this instance.
ptr | Reference to main random number generator |
Definition at line 121 of file Geant4Random.cpp.
|
virtual |
Should initialise the status of the algorithm according to seed.
Definition at line 199 of file Geant4Random.cpp.
|
virtual |
Should initialise the status of the algorithm.
Initialization according to the zero terminated array of seeds. It is allowed to ignore one or many seeds in this array.
Definition at line 209 of file Geant4Random.cpp.
|
virtual |
Should dump the current engine status on the screen.
Definition at line 230 of file Geant4Random.cpp.
void Geant4Random::sphere | ( | double & | x, |
double & | y, | ||
double & | z, | ||
double | r | ||
) |
Create tuple of randum number on a sphere with radius r.
Definition at line 322 of file Geant4Random.cpp.
double Geant4Random::uniform | ( | double | x1, |
double | x2 | ||
) |
Create uniformly disributed random numbers in the interval ]x1,x2].
Definition at line 292 of file Geant4Random.cpp.
double Geant4Random::uniform | ( | double | x1 = 1 | ) |
Create uniformly disributed random numbers in the interval ]0,x1].
Definition at line 286 of file Geant4Random.cpp.
|
friend |
Definition at line 60 of file Geant4Random.h.
|
protected |
Reference to the CLHEP random number engine (valid only after initialization)
Definition at line 73 of file Geant4Random.h.
|
protected |
Property: Engine type. default: "HepJamesRandom".
Definition at line 66 of file Geant4Random.h.
|
protected |
Property: File name if initialized from file. If set, engine name and seeds are ignored.
Definition at line 64 of file Geant4Random.h.
|
protected |
Flag to remember initialization.
Definition at line 78 of file Geant4Random.h.
|
protected |
Definition at line 68 of file Geant4Random.h.
|
protected |
Property: Indicator to replace the ROOT gRandom instance.
Definition at line 70 of file Geant4Random.h.
|
protected |
Definition at line 76 of file Geant4Random.h.
|
protected |
Reference to ROOT random instance.
Definition at line 76 of file Geant4Random.h.
|
protected |
Property: Initial random seed. Default: 123456789.
Definition at line 68 of file Geant4Random.h.