Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleN03.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 //
27 // $Id$
28 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "G4RunManager.hh"
34 #include "G4UImanager.hh"
35 
36 #include "Randomize.hh"
37 
38 #include "DetectorConstruction.hh"
39 #include "PhysicsList.hh"
40 #include "PrimaryGeneratorAction.hh"
41 #include "RunAction.hh"
42 #include "EventAction.hh"
43 #include "SteppingAction.hh"
44 #include "SteppingVerbose.hh"
45 
46 #ifdef G4VIS_USE
47 #include "G4VisExecutive.hh"
48 #endif
49 
50 #ifdef G4UI_USE
51 #include "G4UIExecutive.hh"
52 #endif
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
56 int main(int argc,char** argv)
57 {
58  // Choose the Random engine
59  //
61 
62  // User Verbose output class
63  //
65 
66  // Construct the default run manager
67  //
68  G4RunManager * runManager = new G4RunManager;
69 
70  // Set mandatory initialization classes
71  //
73  //
74  runManager->SetUserInitialization(new PhysicsList);
75 
76  // Set user action classes
77  //
78  runManager->SetUserAction(new PrimaryGeneratorAction);
79  //
80  runManager->SetUserAction(new RunAction);
81  //
82  runManager->SetUserAction(new EventAction);
83  //
84  runManager->SetUserAction(new SteppingAction);
85 
86  // Initialize G4 kernel
87  //
88  runManager->Initialize();
89 
90 #ifdef G4VIS_USE
91  // Initialize visualization
92  G4VisManager* visManager = new G4VisExecutive;
93  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
94  // G4VisManager* visManager = new G4VisExecutive("Quiet");
95  visManager->Initialize();
96 #endif
97 
98  // Get the pointer to the User Interface manager
100 
101  if (argc!=1) // batch mode
102  {
103  G4String command = "/control/execute ";
104  G4String fileName = argv[1];
105  UImanager->ApplyCommand(command+fileName);
106  }
107  else
108  { // interactive mode : define UI session
109 #ifdef G4UI_USE
110  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
111 #ifdef G4VIS_USE
112  UImanager->ApplyCommand("/control/execute vis.mac");
113 #endif
114  if (ui->IsGUI())
115  UImanager->ApplyCommand("/control/execute gui.mac");
116  ui->SessionStart();
117  delete ui;
118 #endif
119  }
120 
121  // Job termination
122  // Free the store: user actions, physics_list and detector_description are
123  // owned and deleted by the run manager, so they should not
124  // be deleted in the main() program !
125 #ifdef G4VIS_USE
126  delete visManager;
127 #endif
128  delete runManager;
129 
130  return 0;
131 }
132 
133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....