utilities
Loading...
Searching...
No Matches
gemcUtilities.h
Go to the documentation of this file.
1#pragma once
2
3// qt
4#include <QCoreApplication>
5
6// geant4
7#include "G4MTRunManager.hh"
8#include "G4UImanager.hh"
9
10// cpp
11#include <memory>
12
13// gemc
14#include <gemc/glogging/glogger.h>
15#include <gemc/gsplash/gsplash.h>
16#include <gemc/glogging/gbatch_session.h>
17#include "gQtTranslation.h"
18
20namespace gemc {
21
33
48
76inline std::unique_ptr<QCoreApplication>
77makeQtApplication(int& argc, char* argv[], bool gui, const GOptions* options = nullptr) {
78
79 if (!gui) {
80 auto gbatch = std::make_unique<GBatch_Session>();
81 G4UImanager::GetUIpointer()->SetCoutDestination(gbatch.release()); // release ownership to Geant4
82
83 return std::make_unique<QCoreApplication>(argc, argv);
84 }
85 auto application = std::make_unique<QApplication>(argc, argv);
86 installGuiTranslations(*application, options);
87 return application;
88}
89
108int get_nthreads(const std::shared_ptr<GOptions>& gopts, const std::shared_ptr<GLogger>& log);
109
123std::vector<std::string> verbosity_commands(const std::shared_ptr<GOptions>& gopts,
124 const std::shared_ptr<GLogger>& log);
125
151std::vector<std::string> initial_commands(const std::shared_ptr<GOptions>& gopts,
152 const std::shared_ptr<GLogger>& log,
153 bool configure_visualization = true);
154
166void run_manager_commands(const std::shared_ptr<GOptions>& gopts,
167 const std::shared_ptr<GLogger>& log,
168 const std::vector<std::string>& commands);
169
176void execute_macro(const std::string& filename, const std::shared_ptr<GLogger>& log);
177
179
202void start_random_engine(const std::shared_ptr<GOptions>& gopts, const std::shared_ptr<GLogger>& log);
203 // end of group gemc_utilities_module
205
206} // namespace gemc
void define_new_gemc_units()
std::vector< std::string > initial_commands(const std::shared_ptr< GOptions > &gopts, const std::shared_ptr< GLogger > &log, bool configure_visualization)
Build a list of Geant4 UI commands needed at startup.
void start_random_engine(const std::shared_ptr< GOptions > &gopts, const std::shared_ptr< GLogger > &log)
Select and start the random engine, then seed it.
std::vector< std::string > 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::unique_ptr< QCoreApplication > makeQtApplication(int &argc, char *argv[], bool gui, const GOptions *options=nullptr)
Create a Qt application instance suitable for GUI or batch execution.
void 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 execute_macro(const std::string &filename, const std::shared_ptr< GLogger > &log)
Execute a Geant4 macro file, terminating with an error if it cannot complete.
int 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.
GEMC runtime setup, command, and translation utilities.
void installGuiTranslations(QCoreApplication &application, const GOptions *options=nullptr)
Install GUI translations before constructing widgets, using the same language as GLogger.