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

Main program of the field/field03 example. More...

#include "G4Types.hh"
#include "F03SteppingVerbose.hh"
#include "G4RunManager.hh"
#include "F03DetectorConstruction.hh"
#include "F03ActionInitialization.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.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 field/field03 example.

Definition in file field03.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 58 of file field03.cc.

59 {
60  // Instantiate G4UIExecutive if there are no arguments (interactive mode)
61  G4UIExecutive* ui = nullptr;
62  if ( argc == 1 ) {
63  ui = new G4UIExecutive(argc, argv);
64  }
65 
66  // Choose the Random engine
67  //
68  G4Random::setTheEngine(new CLHEP::RanecuEngine);
69 
70  // Construct the default run manager
71  //
72 #ifdef G4MULTITHREADED
73  G4MTRunManager * runManager = new G4MTRunManager;
74 #else
75  G4VSteppingVerbose::SetInstance(new F03SteppingVerbose);
76  G4RunManager * runManager = new G4RunManager;
77 #endif
78 
79  // Set mandatory initialization classes
80  //
81  // Detector construction
82  F03DetectorConstruction* detector = new F03DetectorConstruction();
83  runManager->SetUserInitialization(detector);
84  // Physics list
85  G4VModularPhysicsList* physicsList = new FTFP_BERT;
86  physicsList->RegisterPhysics(new G4StepLimiterPhysics());
87  runManager->SetUserInitialization(physicsList);
88  // User action initialization
89  runManager->SetUserInitialization(new F03ActionInitialization(detector));
90 
91  // Initialize G4 kernel
92  //
93  runManager->Initialize();
94 
95  // Initialize visualization
96  //
97  G4VisManager* visManager = new G4VisExecutive;
98  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
99  // G4VisManager* visManager = new G4VisExecutive("Quiet");
100  visManager->Initialize();
101 
102  // Get the pointer to the User Interface manager
103  //
104  G4UImanager* UImanager = G4UImanager::GetUIpointer();
105 
106  if (!ui) // batch mode
107  {
108  G4String command = "/control/execute ";
109  G4String fileName = argv[1];
110  UImanager->ApplyCommand(command+fileName);
111  }
112  else
113  {
114  UImanager->ApplyCommand("/control/execute init_vis.mac");
115  if (ui->IsGUI())
116  UImanager->ApplyCommand("/control/execute gui.mac");
117  ui->SessionStart();
118  delete ui;
119  }
120 
121  // Job termination
122  // Free the store: user actions, physics_list and detector_description are
123  // owned and deleted by the run manager, so they should not
124  // be deleted in the main() program !
125 
126  delete visManager;
127  delete runManager;
128 
129  return 0;
130 }