|
utilities
|
Runtime utilities used during GEMC initialization and configuration. More...
Functions | |
| std::unique_ptr< QCoreApplication > | gemc::makeQtApplication (int &argc, char *argv[], bool gui) |
| Create a Qt application instance suitable for GUI or batch execution. | |
| int | gemc::get_nthreads (const std::shared_ptr< GOptions > &gopts, const std::shared_ptr< GLogger > &log) |
| Determine the number of worker threads to use for the run. | |
| std::vector< std::string > | gemc::verbosity_commands (const std::shared_ptr< GOptions > &gopts, const std::shared_ptr< GLogger > &log) |
| Build a list of Geant4 UI commands that reduce verbosity across subsystems. | |
| std::vector< std::string > | gemc::initial_commands (const std::shared_ptr< GOptions > &gopts, const std::shared_ptr< GLogger > &log) |
| Build a list of Geant4 UI commands needed at startup. | |
| void | gemc::run_manager_commands (const std::shared_ptr< GOptions > &gopts, const std::shared_ptr< GLogger > &log, const std::vector< std::string > &commands) |
| Execute a sequence of Geant4 UI commands through the UI manager. | |
| void | gemc::start_random_engine (const std::shared_ptr< GOptions > &gopts, const std::shared_ptr< GLogger > &log) |
| Select and start the random engine, then seed it. | |
This module is focused on startup/runtime glue code:
Ownership and lifecycle considerations are documented per-function.
| int gemc::get_nthreads | ( | const std::shared_ptr< GOptions > & | gopts, |
| const std::shared_ptr< GLogger > & | log ) |
This helper reads the nthreads option from gopts and clamps it to the available CPU core count reported by G4Threading::G4GetNumberOfCores().
Behavior:
nthreads == 0, the maximum number of available cores is used.nthreads > available_cores, the value is clamped to available_cores.nthreads value is used.The function logs the chosen number of threads using log.
| gopts | Runtime options provider. The key used is nthreads. |
| log | Logger used to report the chosen thread count. |
Definition at line 20 of file gemcUtilities.cc.
| std::vector< std::string > gemc::initial_commands | ( | const std::shared_ptr< GOptions > & | gopts, |
| const std::shared_ptr< GLogger > & | log ) |
This function prepares commands based on options:
check_overlaps (typically provided by the G4 system options set)guiBehavior:
check_overlaps == 2, schedule an overlap test with a resolution of 50 points.check_overlaps >= 100, schedule an overlap test with that many points."/run/initialize" after overlap configuration.gui is false, return the list after initialization.gui is true, append visualization scene/viewer configuration commands: drawing the volume, configuring trajectories/hits, background color, disabling/enabling auto-refresh around setup, and finally flushing the viewer.| gopts | Runtime options provider. Keys used include check_overlaps and gui. |
| log | Logger used to report which overlap test (if any) will be executed. |
Definition at line 74 of file gemcUtilities.cc.
|
inline |
gui is true, this function returns a QApplication instance (returned as a std::unique_ptr<QCoreApplication> for uniform handling).gui is false, this function:GBatch_Session instance.G4UImanager::GetUIpointer()->SetCoutDestination(...).QCoreApplication instance.std::unique_ptr<QCoreApplication> owns the Qt application object.GBatch_Session is released and then owned by Geant4 via SetCoutDestination. The caller must not delete it.| argc | Standard main() argument count (passed by reference as required by Qt). |
| argv | Standard main() argument array (passed through to Qt). |
| gui | If true, create a QApplication; otherwise create a QCoreApplication and redirect Geant4 cout to a GBatch_Session. |
std::unique_ptr<QCoreApplication> owning either a QCoreApplication or a QApplication instance. Definition at line 72 of file gemcUtilities.h.
| void gemc::run_manager_commands | ( | const std::shared_ptr< GOptions > & | gopts, |
| const std::shared_ptr< GLogger > & | log, | ||
| const std::vector< std::string > & | commands ) |
This function obtains the global UI manager pointer and applies each command in commands in order. Each command is logged at an informational verbosity suitable for tracing configuration activity.
| gopts | Runtime options provider (currently unused by this implementation). |
| log | Logger used to trace command execution. |
| commands | List of UI command strings to apply, in order. |
Definition at line 128 of file gemcUtilities.cc.
| void gemc::start_random_engine | ( | const std::shared_ptr< GOptions > & | gopts, |
| const std::shared_ptr< GLogger > & | log ) |
This function reads:
randomEngine : the name of the random engine implementationseed : the numeric seed valueIf the seed is SEEDNOTSET, a seed is generated from a combination of wall time, process CPU clock, and the process id.
DRand48Engine, DualRand, HepJamesRandom, MTwistEngine, RanluxEngine, etc.). The selection is performed by matching the randomEngine option string.EC__RANDOMENGINENOTFOUND.| gopts | Runtime options provider. Keys used: randomEngine, seed. |
| log | Logger used to report the chosen engine and seed, or errors. |
Definition at line 140 of file gemcUtilities.cc.
| std::vector< std::string > gemc::verbosity_commands | ( | const std::shared_ptr< GOptions > & | gopts, |
| const std::shared_ptr< GLogger > & | log ) |
The returned commands are intended to keep Geant4 output quiet in typical runs. They include .../verbose 0 style settings for major categories such as: control, hit, process, tracking, geometry navigator, event, cuts, run, material, visualization, and particle messages.
| gopts | Runtime options provider (currently unused by this implementation). |
| log | Logger (currently unused by this implementation). |
Definition at line 36 of file gemcUtilities.cc.