6 #include "G4RunManager.hh" 7 #include "G4UImanager.hh" 8 #include "G4UIExecutive.hh" 18 std::cout <<
"Usage: edep-sim [options] [macros]" <<
std::endl;
19 std::cout <<
" -C -- Toggle validating the geometry" <<
std::endl;
20 std::cout <<
" -d -- Increase the debug level" <<
std::endl;
21 std::cout <<
" -D <name>=[error,severe,warn,debug,trace]" 23 <<
" -- Change the named debug level" 25 std::cout <<
" -e <n> -- Add /run/beamOn <n> after last macro." 27 std::cout <<
" -g -- Set a GDML file" <<
std::endl;
28 std::cout <<
" -o -- Set the output file" <<
std::endl;
29 std::cout <<
" -p -- Select the physics list" <<
std::endl;
30 std::cout <<
" -s -- Set the seed from the time" <<
std::endl;
31 std::cout <<
" -u -- Do update before running the macros" 33 std::cout <<
" -U -- Start an interactive run after the macros" 37 std::cout <<
" -v -- Increase the verbosity" <<
std::endl;
38 std::cout <<
" -V <name>=[quiet,log,info,verbose]" << std::endl
39 <<
" -- Change the named log level" 41 std::cout <<
" -h -- This help message." <<
std::endl;
58 bool validateGeometry=
true;
60 std::map<std::string, EDepSim::LogManager::ErrorPriority> namedDebugLevel;
63 std::map<std::string, EDepSim::LogManager::LogPriority> namedLogLevel;
73 while (!errflg && ((c=getopt(argc,argv,
"CdD:e:g:o:p:qsuUvV:h")) != -1)) {
78 validateGeometry = !validateGeometry;
91 std::size_t sep = arg.find(
"=");
92 if (sep != std::string::npos) {
95 switch (levelName[0]) {
97 namedDebugLevel[name.c_str()]
101 namedDebugLevel[name.c_str()]
105 namedDebugLevel[name.c_str()]
109 namedDebugLevel[name.c_str()]
113 namedDebugLevel[name.c_str()]
125 beamOnCount = optarg;
129 gdmlFilename = optarg;
133 outputFilename = optarg;
137 physicsList = optarg;
158 if (logLevel>0) --logLevel;
165 if (logLevel>0) ++logLevel;
173 std::size_t sep = arg.find(
"=");
174 if (sep != std::string::npos) {
177 switch (levelName[0]) {
179 namedLogLevel[name.c_str()]
183 namedLogLevel[name.c_str()]
187 namedLogLevel[name.c_str()]
191 namedLogLevel[name.c_str()]
209 else if (logLevel == 1) {
213 else if (logLevel == 2) {
217 else if (logLevel >= 3) {
223 = namedLogLevel.begin();
224 i != namedLogLevel.end();
229 if (debugLevel == 1) {
233 else if (debugLevel == 2) {
237 else if (debugLevel >= 2) {
243 = namedDebugLevel.begin();
244 i != namedDebugLevel.end();
268 if (!persistencyManager) {
275 G4UImanager* UI = G4UImanager::GetUIpointer();
278 if (gdmlFilename !=
"") {
279 UI->ApplyCommand(
"/edep/gdml/read "+gdmlFilename);
283 UI->ApplyCommand(
"/edep/control edepsim-defaults 1.0");
286 if (persistencyManager && ! outputFilename.empty()) {
287 UI->ApplyCommand(
"/edep/db/open "+outputFilename);
290 std::signal(SIGILL, SIG_DFL);
291 std::signal(SIGBUS, SIG_DFL);
292 std::signal(SIGSEGV, SIG_DFL);
297 if (validateGeometry) UI->ApplyCommand(
"/edep/validateGeometry");
300 if (setSeed) UI->ApplyCommand(
"/edep/random/timeRandomSeed");
306 if (doUpdate) UI->ApplyCommand(
"/edep/update");
310 G4UIExecutive* ui =
new G4UIExecutive(argc, argv);
311 for (
int i=optind; i<argc; ++i) {
313 std::cout <<
"## Run macro: " << macroFilename <<
std::endl;
314 UI->ApplyCommand(
"/control/execute "+macroFilename);
319 else if (optind < argc) {
321 for (
int i=optind; i<argc; ++i) {
323 UI->ApplyCommand(
"/control/execute " +macroFilename);
330 if (!beamOnCount.empty()) {
331 UI->ApplyCommand(
"/run/beamOn " + beamOnCount);
336 if (persistencyManager) {
337 persistencyManager->
Close();
338 delete persistencyManager;
#define EDepSimLog(outStream)
static void SetLogLevel(LogPriority level)
Set the default logging level.
#define EDepSimInfo(outStream)
int main(int argc, char **argv)
#define EDepSimTrace(outStream)
#define EDepSimDebug(outStream)
#define EDepSimVerbose(outStream)
static void SetDebugLevel(ErrorPriority level)
#define EDepSimWarn(outStream)
G4RunManager * CreateRunManager(G4String physicsList)
static void Configure(const char *conf=NULL)
virtual G4bool Close(void)
Make sure the output file is closed.
QTextStream & endl(QTextStream &s)