source: trunk/examples/novice/N02/exampleN02.cc @ 1189

Last change on this file since 1189 was 1189, checked in by garnier, 15 years ago

update par rapport a CVS

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