Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleN04.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 "ExN04DetectorConstruction.hh"
37 #include "QGSP_BERT.hh"
38 #include "ExN04PrimaryGeneratorAction.hh"
39 #include "ExN04RunAction.hh"
40 #include "ExN04EventAction.hh"
41 #include "ExN04StackingAction.hh"
42 #include "ExN04TrackingAction.hh"
43 #include "ExN04SteppingAction.hh"
44 #include "ExN04SteppingVerbose.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 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 QGSP_BERT();
71  runManager->SetUserInitialization(physics);
72 
73  runManager->Initialize();
74 
75  // User Action classes
76  //
78  runManager->SetUserAction(gen_action);
79  //
80  G4UserRunAction* run_action = new ExN04RunAction;
81  runManager->SetUserAction(run_action);
82  //
83  G4UserEventAction* event_action = new ExN04EventAction;
84  runManager->SetUserAction(event_action);
85  //
86  G4UserStackingAction* stacking_action = new ExN04StackingAction;
87  runManager->SetUserAction(stacking_action);
88  //
89  G4UserTrackingAction* tracking_action = new ExN04TrackingAction;
90  runManager->SetUserAction(tracking_action);
91  //
92  G4UserSteppingAction* stepping_action = new ExN04SteppingAction;
93  runManager->SetUserAction(stepping_action);
94 
95 #ifdef G4VIS_USE
96  G4VisManager* visManager = new G4VisExecutive;
97  visManager->Initialize();
98 #endif
99 
100  //get the pointer to the User Interface manager
101  G4UImanager* UImanager = G4UImanager::GetUIpointer();
102 
103  if (argc!=1) // batch mode
104  {
105  G4String command = "/control/execute ";
106  G4String fileName = argv[1];
107  UImanager->ApplyCommand(command+fileName);
108  }
109  else // interactive mode : define UI session
110  {
111 #ifdef G4UI_USE
112  G4UIExecutive * ui = new G4UIExecutive(argc,argv);
113 #ifdef G4VIS_USE
114  UImanager->ApplyCommand("/control/execute vis.mac");
115 #endif
116  ui->SessionStart();
117  delete ui;
118 #endif
119 
120 #ifdef G4VIS_USE
121  delete visManager;
122 #endif
123  }
124 
125  // Job termination
126  // Free the store: user actions, physics_list and detector_description are
127  // owned and deleted by the run manager, so they should not
128  // be deleted in the main() program !
129  delete runManager;
130  delete verbosity;
131 
132  return 0;
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......