Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HepMCEx01.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 // $Id: HepMCEx01.cc 77801 2013-11-28 13:33:20Z gcosmo $
30 //
31 // --------------------------------------------------------------
32 // GEANT 4 - example derived from novice exampleN04
33 // --------------------------------------------------------------
34 
35 #include "FTFP_BERT.hh"
36 #include "G4RunManager.hh"
37 #include "G4UImanager.hh"
38 
39 #include "ExN04DetectorConstruction.hh"
40 #include "ExN04EventAction.hh"
41 #include "ExN04PrimaryGeneratorAction.hh"
42 #include "ExN04RunAction.hh"
43 #include "ExN04StackingAction.hh"
44 #include "ExN04SteppingAction.hh"
45 #include "ExN04SteppingVerbose.hh"
46 #include "ExN04TrackingAction.hh"
47 
48 #ifdef G4VIS_USE
49 #include "G4VisExecutive.hh"
50 #endif
51 
52 #ifdef G4UI_USE
53 #include "G4UIExecutive.hh"
54 #endif
55 
56 int main(int argc,char** argv)
57 {
58  // User Verbose output class
59  //
62 
63  // Run manager
64  //
65  G4RunManager* runManager = new G4RunManager;
66 
67  // User Initialization classes (mandatory)
68  //
70  runManager->SetUserInitialization(detector);
71  //
72  G4VUserPhysicsList* physics = new FTFP_BERT;
73  runManager->SetUserInitialization(physics);
74 
75  runManager->Initialize();
76 
77  // User Action classes
78  //
80  runManager->SetUserAction(gen_action);
81  //
82  G4UserRunAction* run_action = new ExN04RunAction;
83  runManager->SetUserAction(run_action);
84  //
85  G4UserEventAction* event_action = new ExN04EventAction;
86  runManager->SetUserAction(event_action);
87  //
88  G4UserStackingAction* stacking_action = new ExN04StackingAction;
89  runManager->SetUserAction(stacking_action);
90  //
91  G4UserTrackingAction* tracking_action = new ExN04TrackingAction;
92  runManager->SetUserAction(tracking_action);
93  //
94  G4UserSteppingAction* stepping_action = new ExN04SteppingAction;
95  runManager->SetUserAction(stepping_action);
96 
97 #ifdef G4VIS_USE
98  // Visualization, if you choose to have it!
99  G4VisManager* visManager = new G4VisExecutive;
100  visManager->Initialize();
101 #endif
102 
103  //get the pointer to the User Interface manager
104  G4UImanager* UImanager = G4UImanager::GetUIpointer();
105 
106  if (argc!=1) // batch mode
107  {
108 #ifdef G4VIS_USE
109  visManager->SetVerboseLevel("quiet");
110 #endif
111  G4String command = "/control/execute ";
112  G4String fileName = argv[1];
113  UImanager->ApplyCommand(command+fileName);
114  }
115  else
116  { // interactive mode : define UI session
117 #ifdef G4UI_USE
118  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
119  ui->SessionStart();
120  delete ui;
121 #endif
122  }
123 
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  delete verbosity;
133 
134  return 0;
135 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetVerboseLevel(G4int)
int main(int argc, char **argv)
Definition: genwindef.cpp:30
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
void Initialize()
TFTFP_BERT< G4VModularPhysicsList > FTFP_BERT
Definition: FTFP_BERT.hh:63
static void SetInstance(G4VSteppingVerbose *Instance)
virtual void Initialize()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447
virtual void SetUserAction(G4UserRunAction *userAction)