LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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.

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
86  G4ScoringManager::GetScoringManager();
87 
88  // Instantiate the geometry
89  runManager->SetUserInitialization(new ElectronBenchmarkDetector);
90 
91  // Instantiate the physics list (in turn calls one of the choices of
92  // physics list)
93  runManager->SetUserInitialization(new PhysicsList);
94 
95  // set user action classes
96  runManager->SetUserInitialization(
97  new ElectronActionInitialization(outputFile));
98 
99  if (argc == 1)
100  {
101  // Since no macro was specified, instantiate an interactive session
102  // (exact session type depends on user preference expressed in
103  // environment variables).
104  //
105  // Instantiate the visualization System
106 #ifdef G4VIS_USE
107  G4VisManager* visManager = new G4VisExecutive;
108  visManager->Initialize();
109 #endif
110 
111 #ifdef G4UI_USE
112  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
113  ui->SessionStart();
114  delete ui;
115 #endif
116 
117 #ifdef G4VIS_USE
118  delete visManager;
119 #endif
120  }
121  else
122  {
123  // A macro was specified. Execute it.
124  G4UImanager* UImanager = G4UImanager::GetUIpointer();
125  G4String command = "/control/execute ";
126  UImanager->ApplyCommand(command+macroFile);
127  }
128 
129  delete runManager;
130 
131  return 0;
132 }