Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HepMCEx02.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 //
28 //
29 //
30 // $Id$
31 // GEANT4 tag $Name: not supported by cvs2svn $
32 //
33 //
34 // --------------------------------------------------------------
35 // GEANT 4 - example of HepMC-interface
36 // --------------------------------------------------------------
37 
38 #include "G4RunManager.hh"
39 #include "G4UImanager.hh"
40 
42 #include "FTFP_BERT.hh"
44 #include "H02EventAction.hh"
45 #include "H02SteppingAction.hh"
46 
47 #ifdef G4VIS_USE
48 #include "G4VisExecutive.hh"
49 #endif
50 
51 #ifdef G4UI_USE
52 #include "G4UIExecutive.hh"
53 #endif
54 
55 int main(int argc, char** argv)
56 {
57  G4RunManager* runManager= new G4RunManager;
58 
59  // User Initialization classes (mandatory)
60  //
62  runManager-> SetUserInitialization(detector);
63  //
64  G4VUserPhysicsList* physics = new FTFP_BERT;
65  runManager-> SetUserInitialization(physics);
66 
67  runManager-> Initialize();
68 
69  // User Action classes
70  //
72  runManager-> SetUserAction(gen_action);
73  //
74  G4UserEventAction* event_action = new H02EventAction;
75  runManager-> SetUserAction(event_action);
76  //
77  G4UserSteppingAction* stepping_action = new H02SteppingAction;
78  runManager-> SetUserAction(stepping_action);
79 
80 #ifdef G4VIS_USE
81  // Initialize visualization package
82  //
83  G4VisManager* visManager= new G4VisExecutive;
84  visManager-> Initialize();
85  G4cout << G4endl;
86 #endif
87 
88  //get the pointer to the User Interface manager
89  G4UImanager* UImanager = G4UImanager::GetUIpointer();
90 
91  if (argc!=1) { // batch mode
92 #ifdef G4VIS_USE
93  visManager-> SetVerboseLevel("quiet");
94 #endif
95  G4String command = "/control/execute ";
96  G4String fileName = argv[1];
97  UImanager-> ApplyCommand(command+fileName);
98  } else { // interactive mode : define UI session
99 #ifdef G4UI_USE
100  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
101  ui-> SessionStart();
102  delete ui;
103 #endif
104  }
105 
106  // Free the store: user actions, physics_list and detector_description are
107  // owned and deleted by the run manager, so they should not
108  // be deleted in the main() program !
109 
110 #ifdef G4VIS_USE
111  delete visManager;
112 #endif
113 
114  delete runManager;
115 
116  return 0;
117 }
118