LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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 93734 2015-10-30 10:59:21Z 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 
49 #include "ElectronBenchmarkDetector.hh"
50 #include "PhysicsList.hh"
51 #include "ElectronActionInitialization.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
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 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc, char **argv)