source: trunk/examples/novice/N04/exampleN04.cc @ 1288

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

update to geant4.9.3

File size: 4.7 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: exampleN04.cc,v 1.18 2009/10/30 15:08:39 allison Exp $
28// GEANT4 tag $Name: geant4-09-03-cand-01 $
29//
30//
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33
34#include "G4RunManager.hh"
35#include "G4UImanager.hh"
36
37#include "ExN04DetectorConstruction.hh"
38#include "QGSP.hh"
39#include "ExN04PrimaryGeneratorAction.hh"
40#include "ExN04RunAction.hh"
41#include "ExN04EventAction.hh"
42#include "ExN04StackingAction.hh"
43#include "ExN04TrackingAction.hh"
44#include "ExN04SteppingAction.hh"
45#include "ExN04SteppingVerbose.hh"
46
47#ifdef G4VIS_USE
48#include "G4VisExecutive.hh"
49#endif
50
51#ifdef G4UI_USE
52#include "G4UIExecutive.hh"
53#endif
54
55int main(int argc,char** argv)
56{
57  // User Verbose output class
58  //
59  G4VSteppingVerbose* verbosity = new ExN04SteppingVerbose;
60  G4VSteppingVerbose::SetInstance(verbosity);
61 
62  // Run manager
63  //
64  G4RunManager* runManager = new G4RunManager;
65
66  // User Initialization classes (mandatory)
67  //
68  G4VUserDetectorConstruction* detector = new ExN04DetectorConstruction;
69  runManager->SetUserInitialization(detector);
70  //
71  G4VUserPhysicsList* physics = new QGSP;
72  runManager->SetUserInitialization(physics);
73
74  runManager->Initialize();
75
76  // User Action classes
77  //
78  G4VUserPrimaryGeneratorAction* gen_action = new ExN04PrimaryGeneratorAction;
79  runManager->SetUserAction(gen_action);
80  //
81  G4UserRunAction* run_action = new ExN04RunAction;
82  runManager->SetUserAction(run_action);
83  //
84  G4UserEventAction* event_action = new ExN04EventAction;
85  runManager->SetUserAction(event_action);
86  //
87  G4UserStackingAction* stacking_action = new ExN04StackingAction;
88  runManager->SetUserAction(stacking_action);
89  //
90  G4UserTrackingAction* tracking_action = new ExN04TrackingAction;
91  runManager->SetUserAction(tracking_action);
92  //
93  G4UserSteppingAction* stepping_action = new ExN04SteppingAction;
94  runManager->SetUserAction(stepping_action);
95 
96#ifdef G4VIS_USE
97      G4VisManager* visManager = new G4VisExecutive;
98      visManager->Initialize();
99#endif   
100     
101  //get the pointer to the User Interface manager   
102  G4UImanager* UImanager = G4UImanager::GetUIpointer(); 
103
104  if (argc!=1)   // batch mode 
105    {
106      G4String command = "/control/execute ";
107      G4String fileName = argv[1];
108      UImanager->ApplyCommand(command+fileName);
109    }
110  else           // interactive mode : define UI session
111    { 
112#ifdef G4UI_USE
113      G4UIExecutive * ui = new G4UIExecutive(argc,argv);
114#ifdef G4VIS_USE
115      UImanager->ApplyCommand("/control/execute vis.mac");     
116#endif
117      ui->SessionStart();
118      delete ui;
119#endif
120     
121#ifdef G4VIS_USE
122      delete visManager;
123#endif     
124    }
125   
126  // Job termination
127  // Free the store: user actions, physics_list and detector_description are
128  //                 owned and deleted by the run manager, so they should not
129  //                 be deleted in the main() program !
130  delete runManager;
131  delete verbosity;
132
133  return 0;
134}
135
136//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.