Geant4  10.03
field05.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: field05.cc 78053 2013-12-03 08:25:13Z gcosmo $
27 //
30 //
31 //
32 //
33 //
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
36 
37 #ifndef WIN32
38 #include <unistd.h>
39 #endif
40 
41 #ifdef G4MULTITHREADED
42 #include "G4MTRunManager.hh"
43 #else
44 #include "F05SteppingVerbose.hh"
45 #include "G4RunManager.hh"
46 #endif
47 
48 #include "F05PhysicsList.hh"
50 
52 
53 #include "G4UImanager.hh"
54 
55 #include "Randomize.hh"
56 
57 #ifdef G4VIS_USE
58 #include "G4VisExecutive.hh"
59 #endif
60 
61 #ifdef G4UI_USE
62 #include "G4UIExecutive.hh"
63 #endif
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
67 int main(int argc,char** argv)
68 {
69  // Choose the Random engine
70  //
71  G4Random::setTheEngine(new CLHEP::RanecuEngine);
72 
73  G4int myseed = 1234;
74  if (argc > 2) myseed = atoi(argv[argc-1]);
75 
76  // Construct the default run manager
77  //
78 #ifdef G4MULTITHREADED
79  G4MTRunManager * runManager = new G4MTRunManager;
80 #else
82  G4RunManager * runManager = new G4RunManager;
83 #endif
84 
85  G4Random::setTheSeed(myseed);
86 
87  // Set mandatory initialization classes
88  //
89  // Detector construction
91  // Physics list
92  runManager->SetUserInitialization(new F05PhysicsList());
93  // User action initialization
95 
96  // Initialize G4 kernel
97  //
98  runManager->Initialize();
99 
100 #ifdef G4VIS_USE
101  // Initialize visualization
102  //
103  G4VisManager* visManager = new G4VisExecutive;
104  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
105  // G4VisManager* visManager = new G4VisExecutive("Quiet");
106  visManager->Initialize();
107 #endif
108 
109  // Get the pointer to the User Interface manager
110  //
111  G4UImanager* UImanager = G4UImanager::GetUIpointer();
112 
113  if (argc!=1) // batch mode
114  {
115  G4String command = "/control/execute ";
116  G4String fileName = argv[1];
117  UImanager->ApplyCommand(command+fileName);
118  }
119  else
120  { // interactive mode : define UI session
121 #ifdef G4UI_USE
122  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
123 #ifdef G4VIS_USE
124  UImanager->ApplyCommand("/control/execute vis.mac");
125 #else
126  UImanager->ApplyCommand("/control/execute field05.in");
127 #endif
128  if (ui->IsGUI())
129  UImanager->ApplyCommand("/control/execute gui.mac");
130  ui->SessionStart();
131  delete ui;
132 #endif
133  }
134 
135  // Job termination
136  // Free the store: user actions, physics_list and detector_description are
137  // owned and deleted by the run manager, so they should not
138  // be deleted in the main() program !
139 
140 #ifdef G4VIS_USE
141  delete visManager;
142 #endif
143  delete runManager;
144 
145  return 0;
146 }
147 
148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
Action initialization class.
int main(int argc, char **argv)
Definition: field05.cc:67
Definition of the F05PhysicsList class.
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
Definition of the F05DetectorConstruction class.
Definition of the F05SteppingVerbose class.
void Initialize()
static void SetInstance(G4VSteppingVerbose *Instance)
Definition of the F05ActionInitialization class.
virtual void Initialize()
G4bool IsGUI() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446