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