Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleN02.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: exampleN02.cc 69899 2013-05-17 10:05:33Z gcosmo $
28 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "ExN02DetectorConstruction.hh"
34 #include "ExN02PhysicsList.hh"
35 #include "ExN02PrimaryGeneratorAction.hh"
36 #include "ExN02RunAction.hh"
37 #include "ExN02EventAction.hh"
38 #include "ExN02SteppingAction.hh"
39 #include "ExN02SteppingVerbose.hh"
40 
41 #include "G4RunManager.hh"
42 #include "G4UImanager.hh"
43 
44 #ifdef G4VIS_USE
45 #include "G4VisExecutive.hh"
46 #endif
47 
48 #ifdef G4UI_USE
49 #include "G4UIExecutive.hh"
50 #endif
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
54 int main(int argc,char** argv)
55 {
56  // User Verbose output class
57  //
60 
61  // Run manager
62  //
63  G4RunManager * runManager = new G4RunManager;
64 
65  // User Initialization classes (mandatory)
66  //
68  runManager->SetUserInitialization(detector);
69  //
70  G4VUserPhysicsList* physics = new ExN02PhysicsList;
71  runManager->SetUserInitialization(physics);
72 
73  // User Action classes
74  //
76  runManager->SetUserAction(gen_action);
77  //
78  G4UserRunAction* run_action = new ExN02RunAction;
79  runManager->SetUserAction(run_action);
80  //
81  G4UserEventAction* event_action = new ExN02EventAction;
82  runManager->SetUserAction(event_action);
83  //
84  G4UserSteppingAction* stepping_action = new ExN02SteppingAction;
85  runManager->SetUserAction(stepping_action);
86 
87  // Initialize G4 kernel
88  //
89  runManager->Initialize();
90 
91 #ifdef G4VIS_USE
92  G4VisManager* visManager = new G4VisExecutive;
93  visManager->Initialize();
94 #endif
95 
96  // Get the pointer to the User Interface manager
97  //
98  G4UImanager * UImanager = G4UImanager::GetUIpointer();
99 
100  if (argc!=1) // batch mode
101  {
102  G4String command = "/control/execute ";
103  G4String fileName = argv[1];
104  UImanager->ApplyCommand(command+fileName);
105  }
106  else // interactive mode : define UI session
107  {
108 #ifdef G4UI_USE
109  G4UIExecutive * ui = new G4UIExecutive(argc,argv);
110 #ifdef G4VIS_USE
111  UImanager->ApplyCommand("/control/execute vis.mac");
112 #endif
113  ui->SessionStart();
114  delete ui;
115 #endif
116 
117 #ifdef G4VIS_USE
118  delete visManager;
119 #endif
120  }
121 
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 
126  delete runManager;
127  delete verbosity;
128 
129  return 0;
130 }
131 
132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
133