LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ExUCN.cc File Reference

Main program of the exoticphysics/ucn example. More...

#include <unistd.h>
#include "G4Types.hh"
#include "ExUCNPhysicsList.hh"
#include "ExUCNDetectorConstruction.hh"
#include "ExUCNActionInitialization.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "Randomize.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the exoticphysics/ucn example.

Definition in file ExUCN.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 74 of file ExUCN.cc.

References PrintUsage(), and session.

75 {
76  // Evaluate arguments
77  //
78  if ( argc > 9 ) {
79  PrintUsage();
80  return 1;
81  }
82 
83  G4String macro;
85 #ifdef G4MULTITHREADED
86  G4int nThreads = 0;
87 #endif
88 
89  G4long myseed = 1234;
90  for ( G4int i=1; i<argc; i=i+2 ) {
91  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
92  else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
93  else if ( G4String(argv[i]) == "-r" ) myseed = atoi(argv[i+1]);
94 #ifdef G4MULTITHREADED
95  else if ( G4String(argv[i]) == "-t" ) {
96  nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
97  }
98 #endif
99  else {
100  PrintUsage();
101  return 1;
102  }
103  }
104 
105  // Instantiate G4UIExecutive if interactive mode
106  G4UIExecutive* ui = nullptr;
107  if ( argc == 1 ) {
108  ui = new G4UIExecutive(argc, argv);
109  }
110 
111  // Choose the Random engine
112  //
113  G4Random::setTheEngine(new CLHEP::RanecuEngine);
114 
115  // Construct the default run manager
116  //
117 #ifdef G4MULTITHREADED
118  G4MTRunManager * runManager = new G4MTRunManager;
119  if ( nThreads > 0 ) runManager->SetNumberOfThreads(nThreads);
120 #else
121  G4RunManager * runManager = new G4RunManager;
122 #endif
123 
124  // Seed the random number generator manually
125  G4Random::setTheSeed(myseed);
126 
127  // Set mandatory initialization classes
128  //
129  // Detector construction
130  runManager->SetUserInitialization(new ExUCNDetectorConstruction());
131  // Physics list
132  runManager->SetUserInitialization(new ExUCNPhysicsList());
133  // User action initialization
134  runManager->SetUserInitialization(new ExUCNActionInitialization());
135 
136  // Initialize G4 kernel
137  //
138  runManager->Initialize();
139 
140  // Initialize visualization
141  //
142  G4VisManager* visManager = new G4VisExecutive;
143  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
144  // G4VisManager* visManager = new G4VisExecutive("Quiet");
145  visManager->Initialize();
146 
147  // Get the pointer to the User Interface manager
148  //
149  G4UImanager* UImanager = G4UImanager::GetUIpointer();
150 
151  if ( macro.size() ) {
152  // batch mode
153  G4String command = "/control/execute ";
154  UImanager->ApplyCommand(command+macro);
155  }
156  else
157  { // interactive mode : define UI session
158  UImanager->ApplyCommand("/control/execute vis.mac");
159  if (ui->IsGUI())
160  UImanager->ApplyCommand("/control/execute gui.mac");
161  ui->SessionStart();
162  delete ui;
163  }
164 
165  // Job termination
166  // Free the store: user actions, physics_list and detector_description are
167  // owned and deleted by the run manager, so they should not
168  // be deleted in the main() program !
169 
170  delete visManager;
171  delete runManager;
172 
173  return 0;
174 }
static G4UIterminal * session
void PrintUsage()