Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
field01.cc File Reference

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

#include "F01SteppingVerbose.hh"
#include "G4RunManager.hh"
#include "F01PhysicsList.hh"
#include "F01DetectorConstruction.hh"
#include "F01ActionInitialization.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the field/field01 example.

Definition in file field01.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 63 of file field01.cc.

References G4UImanager::ApplyCommand(), G4UImanager::GetUIpointer(), G4RunManager::Initialize(), G4VisManager::Initialize(), G4UIExecutive::IsGUI(), G4UIExecutive::SessionStart(), G4VSteppingVerbose::SetInstance(), and G4RunManager::SetUserInitialization().

64 {
65  // Choose the Random engine
66  //
67  G4Random::setTheEngine(new CLHEP::RanecuEngine);
68 
69  // Construct the default run manager
70  //
71 #ifdef G4MULTITHREADED
72  G4MTRunManager * runManager = new G4MTRunManager;
73 #else
75  G4RunManager * runManager = new G4RunManager;
76 #endif
77 
78  // Set mandatory initialization classes
79  //
80  // Detector construction
82  runManager->SetUserInitialization(detector);
83  // Physics list
84  runManager->SetUserInitialization(new F01PhysicsList(detector));
85  // User action initialization
86  runManager->SetUserInitialization(new F01ActionInitialization(detector));
87 
88  // Initialize G4 kernel
89  //
90  runManager->Initialize();
91 
92 #ifdef G4VIS_USE
93  // Initialize visualization
94  //
95  G4VisManager* visManager = new G4VisExecutive;
96  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
97  // G4VisManager* visManager = new G4VisExecutive("Quiet");
98  visManager->Initialize();
99 #endif
100 
101  // Get the pointer to the User Interface manager
102  //
103  G4UImanager* UImanager = G4UImanager::GetUIpointer();
104 
105  if (argc!=1) // batch mode
106  {
107  G4String command = "/control/execute ";
108  G4String fileName = argv[1];
109  UImanager->ApplyCommand(command+fileName);
110  }
111  else
112  { // interactive mode : define UI session
113 #ifdef G4UI_USE
114  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
115  if (ui->IsGUI())
116  UImanager->ApplyCommand("/control/execute gui.mac");
117  ui->SessionStart();
118  delete ui;
119 #endif
120  }
121 
122  // Job termination
123  // Free the store: user actions, physics_list and detector_description are
124  // owned and deleted by the run manager, so they should not
125  // be deleted in the main() program !
126 
127 #ifdef G4VIS_USE
128  delete visManager;
129 #endif
130  delete runManager;
131 
132  return 0;
133 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
Action initialization class.
void Initialize()
static void SetInstance(G4VSteppingVerbose *Instance)
virtual void Initialize()
G4bool IsGUI() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419