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

Main program of the medical/electronScattering2 example. More...

#include "G4RunManager.hh"
#include "Randomize.hh"
#include "G4ScoringManager.hh"
#include "G4UImanager.hh"
#include "ElectronBenchmarkDetector.hh"
#include "PhysicsList.hh"
#include "ElectronActionInitialization.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the medical/electronScattering2 example.

Definition in file electronScattering2.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 55 of file electronScattering2.cc.

References G4UImanager::ApplyCommand(), G4cout, G4endl, G4ScoringManager::GetScoringManager(), G4UImanager::GetUIpointer(), G4VisManager::Initialize(), G4UIExecutive::SessionStart(), and G4RunManager::SetUserInitialization().

55  {
56 
57  // Parse the arguments
58  G4String outputFile = "output.csv";
59  G4String startingSeed = "1";
60  G4String macroFile = "None";
61  if (argc > 1) macroFile = argv[1];
62  if (argc > 2) startingSeed = argv[2];
63  if (argc > 3) outputFile = argv[3];
64  G4cout << "Starting run with" << G4endl;
65  G4cout << "Macro File : " << macroFile << G4endl;
66  G4cout << "Starting Seed : " << startingSeed << G4endl;
67  G4cout << "Output File : " << outputFile << G4endl;
68 
69  // Instantiate the run manager
70 #ifdef G4MULTITHREADED
71  G4MTRunManager* runManager = new G4MTRunManager;
72 #else
73  G4RunManager* runManager = new G4RunManager;
74 #endif
75 
76  // Instantiate the random engine
77  G4Random::setTheEngine(new CLHEP::MTwistEngine);
78 
79  // Convert the starting seed to integer and feed it to the random engine
80  unsigned startingSeedInt;
81  std::istringstream is(startingSeed);
82  is >> startingSeedInt;
83  G4Random::setTheSeed(startingSeedInt);
84 
85  // Instantiate the scoring manager
87 
88  // Instantiate the geometry
90 
91  // Instantiate the physics list (in turn calls one of four choices of physics list)
92  runManager->SetUserInitialization(new PhysicsList);
93 
94  // set user action classes
95  runManager->SetUserInitialization(new ElectronActionInitialization(outputFile));
96 
97  // Instantiate the visualization System
98 #ifdef G4VIS_USE
99  G4VisManager* visManager = new G4VisExecutive;
100  visManager->Initialize();
101 #endif
102 
103  if (argc == 1)
104  {
105  // Since no macro was specified, instantiate an interactive session (exact
106  // (session type depends on user preference expressed in environment variables).
107 #ifdef G4UI_USE
108  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
109  ui->SessionStart();
110  delete ui;
111 #endif
112  }
113  else
114  {
115  // A macro was specified. Execute it.
116  G4UImanager* UImanager = G4UImanager::GetUIpointer();
117  G4String command = "/control/execute ";
118  UImanager->ApplyCommand(command+macroFile);
119  }
120 
121 #ifdef G4VIS_USE
122  delete visManager;
123 #endif
124  delete runManager;
125 
126  return 0;
127 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
void Initialize()
#define G4endl
Definition: G4ios.hh:61
static G4ScoringManager * GetScoringManager()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419