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

Main program of the physicslists/genericPL example. More...

#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "PrimaryGeneratorAction.hh"
#include "G4RunManager.hh"
#include "G4GenericPhysicsList.hh"
#include "G4VModularPhysicsList.hh"
#include "G4UImanager.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 physicslists/genericPL example.

Definition in file genericPL.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 76 of file genericPL.cc.

References PrintUsage(), and session.

77 {
78  // Evaluate arguments
79  //
80  if ( argc > 9 ) {
81  PrintUsage();
82  return 1;
83  }
84 
85  G4String macro;
87  G4String physListMacro;
88  G4String gdmlFileName;
89 #ifdef G4MULTITHREADED
90  G4int nofThreads = 0;
91 #endif
92  for ( G4int i=1; i<argc; i=i+2 ) {
93  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
94  else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
95  else if ( G4String(argv[i]) == "-p" ) physListMacro = argv[i+1];
96 #ifdef G4MULTITHREADED
97  else if ( G4String(argv[i]) == "-t" ) {
98  nofThreads = G4UIcommand::ConvertToInt(argv[i+1]);
99  }
100 #endif
101  else {
102  PrintUsage();
103  return 1;
104  }
105  }
106 
107  // Detect interactive mode (if no arguments) and define UI session
108  //
109  G4UIExecutive* ui = 0;
110  if ( ! macro.size() ) {
111  ui = new G4UIExecutive(argc, argv, session);
112  }
113 
114  // Choose the Random engine //choose the Random engine
115  G4Random::setTheEngine(new CLHEP::RanecuEngine());
116 
117  // Construct the run manager
118 #ifdef G4MULTITHREADED
119  G4MTRunManager * runManager = new G4MTRunManager();
120  if ( nofThreads > 0 ) {
121  runManager->SetNumberOfThreads(nofThreads);
122  }
123 #else
124  G4RunManager * runManager = new G4RunManager();
125 #endif
126 
127  // Get the pointer to the User Interface manager
128  G4UImanager* UImanager = G4UImanager::GetUIpointer();
129 
130  // Physics List
131  G4VModularPhysicsList* physList = nullptr;
132  if ( physListMacro.size() ) {
133  // via macro
134  physList = new G4GenericPhysicsList();
135  UImanager->ApplyCommand("/control/execute "+physListMacro);
136  }
137  else {
138  // from vector of physics cobstructor names
139  std::vector<G4String>* myConstructors = new std::vector<G4String>;
140 
141  myConstructors->push_back("G4EmStandardPhysics");
142  myConstructors->push_back("G4EmExtraPhysics");
143  myConstructors->push_back("G4DecayPhysics");
144  myConstructors->push_back("G4HadronElasticPhysics");
145  myConstructors->push_back("G4HadronPhysicsFTFP_BERT");
146  myConstructors->push_back("G4StoppingPhysics");
147  myConstructors->push_back("G4IonPhysics");
148  myConstructors->push_back("G4NeutronTrackingCut");
149 
150  physList = new G4GenericPhysicsList(myConstructors);
151  }
152 
153  // Set mandatory initialization classes
154  runManager->SetUserInitialization(new DetectorConstruction());
155  runManager->SetUserInitialization(physList);
156 
157  // set user action classes
158  runManager->SetUserInitialization(new ActionInitialization("genericPL"));
159 
160  // Initialize visualization
161  G4VisManager* visManager = new G4VisExecutive;
162  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
163  // G4VisManager* visManager = new G4VisExecutive("Quiet");
164  visManager->Initialize();
165 
166  if ( macro.size() ) {
167  // batch mode
168  G4String command = "/control/execute ";
169  UImanager->ApplyCommand(command+macro);
170  }
171  else {
172  // interactive mode : define UI session
173  UImanager->ApplyCommand("/control/execute init_vis.mac");
174  ui->SessionStart();
175  delete ui;
176  }
177 
178  // Job termination
179  // Free the store: user actions, physics_list and detector_description are
180  // owned and deleted by the run manager, so they should not be deleted
181  // in the main() program !
182 
183  delete visManager;
184  delete runManager;
185 }
static G4UIterminal * session
void PrintUsage()