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