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

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

tag geant4.9.4 beta 1 + modifs locales

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.6 2010/05/12 12:58:17 allison Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30//
31// --------------------------------------------------------------
32//      GEANT 4 - example derived from novice exampleN04
33// --------------------------------------------------------------
34
35#include "G4RunManager.hh"
36#include "G4UImanager.hh"
37
38#include "ExN04DetectorConstruction.hh"
39#include "QGSP.hh"
40#include "ExN04PrimaryGeneratorAction.hh"
41#include "ExN04RunAction.hh"
42#include "ExN04EventAction.hh"
43#include "ExN04StackingAction.hh"
44#include "ExN04TrackingAction.hh"
45#include "ExN04SteppingAction.hh"
46#include "ExN04SteppingVerbose.hh"
47
48#ifdef G4VIS_USE
49#include "G4VisExecutive.hh"
50#endif
51
52#ifdef G4UI_USE
53#include "G4UIExecutive.hh"
54#endif
55
56int main(int argc,char** argv)
57{
58  // User Verbose output class
59  //
60  G4VSteppingVerbose* verbosity = new ExN04SteppingVerbose;
61  G4VSteppingVerbose::SetInstance(verbosity);
62 
63  // Run manager
64  //
65  G4RunManager* runManager = new G4RunManager;
66
67  // User Initialization classes (mandatory)
68  //
69  G4VUserDetectorConstruction* detector = new ExN04DetectorConstruction;
70  runManager->SetUserInitialization(detector);
71  //
72  G4VUserPhysicsList* physics = new QGSP;
73  runManager->SetUserInitialization(physics);
74 
75  runManager->Initialize();
76
77  // User Action classes
78  //
79  G4VUserPrimaryGeneratorAction* gen_action = new ExN04PrimaryGeneratorAction;
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}
136
Note: See TracBrowser for help on using the repository browser.