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

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

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "DetectorConstruction.hh"
#include "G4MonopolePhysics.hh"
#include "G4PhysListFactory.hh"
#include "G4VModularPhysicsList.hh"
#include "ActionInitialization.hh"
#include "globals.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the exoticphysics/monopole example.

Definition in file monopole.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 71 of file monopole.cc.

References PrintUsage().

72 {
73  // Evaluate arguments
74  //
75  if ( argc > 7 ) {
76  PrintUsage();
77  return 1;
78  }
79 
80  G4String macro;
81  G4String setupMonopole;
82 #ifdef G4MULTITHREADED
83  G4int nThreads = 0;
84 #endif
85  for ( G4int i=1; i<argc; i=i+2 ) {
86  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
87  else if ( G4String(argv[i]) == "-s" ) setupMonopole = argv[i+1];
88 #ifdef G4MULTITHREADED
89  else if ( G4String(argv[i]) == "-t" ) {
90  nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
91  }
92 #endif
93  else {
94  PrintUsage();
95  return 1;
96  }
97  }
98 
99  // Instantiate G4UIExecutive if interactive mode
100  G4UIExecutive* ui = nullptr;
101  if ( ! macro.size() ) {
102  ui = new G4UIExecutive(argc, argv);
103  }
104 
105  //choose the Random engine
106  CLHEP::HepRandom::setTheEngine(new CLHEP::MixMaxRng);
107 
108  // Construct the default run manager
109 #ifdef G4MULTITHREADED
110  G4MTRunManager* runManager = new G4MTRunManager;
111  if ( nThreads > 0 ) {
112  runManager->SetNumberOfThreads(nThreads);
113  }
114  G4cout << "===== Monopole is started with "
115  << runManager->GetNumberOfThreads() << " threads =====" << G4endl;
116 #else
117  G4RunManager* runManager = new G4RunManager();
118 #endif
119 
120  //create physicsList
121  // Physics List is defined via environment variable PHYSLIST
122  G4PhysListFactory factory;
123  G4VModularPhysicsList* phys = factory.GetReferencePhysList("FTFP_BERT");
124 
125  // monopole physics is added
126  G4MonopolePhysics * theMonopole = new G4MonopolePhysics();
127 
128  //get the pointer to the User Interface manager
129  G4UImanager* UImanager = G4UImanager::GetUIpointer();
130  // Setup monopole
131  if ( setupMonopole.size() ) {
132  UImanager->ApplyCommand("/control/verbose 1");
133  UImanager->ApplyCommand("/monopole/setup " + setupMonopole);
134  }
135 
136  // regsiter monopole physics
137  phys->RegisterPhysics(theMonopole);
138  runManager->SetUserInitialization(phys);
139 
140  // visualization manager
141  G4VisManager* visManager = new G4VisExecutive();
142  visManager->Initialize();
143 
144  // set detector construction
146  runManager->SetUserInitialization(det);
147 
148  // set user action classes
149  runManager->SetUserInitialization(new ActionInitialization(det));
150 
151  // Process macro or start UI session
152  //
153  if ( macro.size() ) {
154  // batch mode
155  G4String command = "/control/execute ";
156  UImanager->ApplyCommand(command+macro);
157  }
158  else {
159  // interactive mode : define UI session
160  UImanager->ApplyCommand("/control/execute init_vis.mac");
161  ui->SessionStart();
162  delete ui;
163  }
164 
165  delete visManager;
166 
167  // job termination
168  delete runManager;
169 
170  return 0;
171 }
void PrintUsage()