source: trunk/examples/extended/eventgenerator/HepMC/HepMCEx01/hepmcEx01.cc @ 1292

Last change on this file since 1292 was 1230, checked in by garnier, 14 years ago

update to geant4.9.3

File size: 4.6 KB
Line 
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: hepmcEx01.cc,v 1.5 2006/07/05 11:06:36 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-03-cand-01 $
29//
30//
31// --------------------------------------------------------------
32//      GEANT 4 - example derived from novice exampleN04
33// --------------------------------------------------------------
34
35#include "G4RunManager.hh"
36#include "G4UImanager.hh"
37#include "G4UIterminal.hh"
38#include "G4UItcsh.hh"
39
40#include "ExN04DetectorConstruction.hh"
41#include "QGSP.hh"
42#include "ExN04PrimaryGeneratorAction.hh"
43#include "ExN04RunAction.hh"
44#include "ExN04EventAction.hh"
45#include "ExN04StackingAction.hh"
46#include "ExN04TrackingAction.hh"
47#include "ExN04SteppingAction.hh"
48#include "ExN04SteppingVerbose.hh"
49
50#ifdef G4VIS_USE
51#include "G4VisExecutive.hh"
52#endif
53
54int main(int argc,char** argv)
55{
56  // User Verbose output class
57  //
58  G4VSteppingVerbose* verbosity = new ExN04SteppingVerbose;
59  G4VSteppingVerbose::SetInstance(verbosity);
60 
61  // Run manager
62  //
63  G4RunManager* runManager = new G4RunManager;
64
65  // User Initialization classes (mandatory)
66  //
67  G4VUserDetectorConstruction* detector = new ExN04DetectorConstruction;
68  runManager->SetUserInitialization(detector);
69  //
70  G4VUserPhysicsList* physics = new QGSP;
71  runManager->SetUserInitialization(physics);
72 
73#ifdef G4VIS_USE
74  // Visualization, if you choose to have it!
75  G4VisManager* visManager = new G4VisExecutive;
76  visManager->Initialize();
77#endif
78
79  runManager->Initialize();
80
81  // User Action classes
82  //
83  G4VUserPrimaryGeneratorAction* gen_action = new ExN04PrimaryGeneratorAction;
84  runManager->SetUserAction(gen_action);
85  //
86  G4UserRunAction* run_action = new ExN04RunAction;
87  runManager->SetUserAction(run_action); 
88  //
89  G4UserEventAction* event_action = new ExN04EventAction;
90  runManager->SetUserAction(event_action);
91  //
92  G4UserStackingAction* stacking_action = new ExN04StackingAction;
93  runManager->SetUserAction(stacking_action);
94  //
95  G4UserTrackingAction* tracking_action = new ExN04TrackingAction;
96  runManager->SetUserAction(tracking_action);
97  //
98  G4UserSteppingAction* stepping_action = new ExN04SteppingAction;
99  runManager->SetUserAction(stepping_action);
100 
101  //get the pointer to the User Interface manager   
102  G4UImanager* UImanager = G4UImanager::GetUIpointer(); 
103
104  if(argc==1)
105  {
106    // G4UIterminal is a (dumb) terminal
107    //
108#ifdef G4UI_USE_TCSH
109    G4UIsession* session = new G4UIterminal(new G4UItcsh);     
110#else
111    G4UIsession* session = new G4UIterminal();
112#endif   
113    UImanager->ApplyCommand("/control/execute vis.mac");
114    session->SessionStart();
115    delete session;
116  }
117  else   // Batch mode
118  {
119    G4String command = "/control/execute ";
120    G4String fileName = argv[1];
121    UImanager->ApplyCommand(command+fileName);
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}
136
Note: See TracBrowser for help on using the repository browser.