Geant4  10.00.p01
electronScattering2.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: electronScattering2.cc 75702 2013-11-05 13:08:48Z gcosmo $
27 //
30 
31 #ifdef G4MULTITHREADED
32 #include "G4MTRunManager.hh"
33 #else
34 #include "G4RunManager.hh"
35 #endif
36 
37 #include "Randomize.hh"
38 #include "G4ScoringManager.hh"
39 
40 #ifdef G4VIS_USE
41 #include "G4VisExecutive.hh"
42 #endif
43 
44 #include "G4UImanager.hh"
45 #ifdef G4UI_USE
46 #include "G4UIExecutive.hh"
47 #endif
48 
50 #include "PhysicsList.hh"
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
55 int main(int argc,char** argv) {
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 }
128 
129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int main(int argc, char **argv)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
static int outputFile
void Initialize()
Definition of the ElectronBenchmarkDetector class.
Definition of the ElectronActionInitialization class.
#define G4endl
Definition: G4ios.hh:61
static G4ScoringManager * GetScoringManager()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419