source: trunk/examples/novice/N07/exampleN07.cc@ 1248

Last change on this file since 1248 was 1230, checked in by garnier, 16 years ago

update to geant4.9.3

File size: 4.1 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: exampleN07.cc,v 1.12 2009/10/30 15:29:55 allison Exp $
28// GEANT4 tag $Name: geant4-09-03-cand-01 $
29//
30//
31// --------------------------------------------------------------
32// GEANT 4 - exampleN07
33// --------------------------------------------------------------
34
35#include "G4RunManager.hh"
36#include "G4UImanager.hh"
37
38#ifdef G4VIS_USE
39#include "G4VisExecutive.hh"
40#endif
41
42#ifdef G4UI_USE
43#include "G4UIExecutive.hh"
44#endif
45
46#include "ExN07DetectorConstruction.hh"
47#include "ExN07ParallelWorld.hh"
48#include "ExN07PhysicsList.hh"
49#include "ExN07PrimaryGeneratorAction.hh"
50#include "ExN07RunAction.hh"
51#include "ExN07SteppingVerbose.hh"
52
53int main(int argc,char** argv)
54{
55 // Construct the stepping verbose class
56 ExN07SteppingVerbose* verbosity = new ExN07SteppingVerbose;
57 G4VSteppingVerbose::SetInstance(verbosity);
58
59 // Construct the run manager
60 //
61 G4RunManager * runManager = new G4RunManager;
62
63 // Set mandatory initialization classes
64 //
65 G4VUserDetectorConstruction* detector = new ExN07DetectorConstruction;
66 detector->RegisterParallelWorld(new ExN07ParallelWorld("ParallelScoringWorld"));
67 runManager->SetUserInitialization(detector);
68 //
69 G4VUserPhysicsList* physics = new ExN07PhysicsList;
70 runManager->SetUserInitialization(physics);
71
72 // Set user action classes
73 //
74 G4VUserPrimaryGeneratorAction* gen_action = new ExN07PrimaryGeneratorAction;
75 runManager->SetUserAction(gen_action);
76 //
77 G4UserRunAction* run_action = new ExN07RunAction;
78 runManager->SetUserAction(run_action);
79
80#ifdef G4VIS_USE
81 // Visualization manager
82 //
83 G4VisManager* visManager = new G4VisExecutive;
84 visManager->Initialize();
85#endif
86
87 // Initialize G4 kernel
88 //
89 runManager->Initialize();
90
91 // Get the pointer to the User Interface manager
92 //
93 G4UImanager* UImanager = G4UImanager::GetUIpointer();
94
95 if (argc==1) // Define UI session for interactive mode
96 {
97#ifdef G4UI_USE
98 G4UIExecutive * ui = new G4UIExecutive(argc,argv);
99#ifdef G4VIS_USE
100 UImanager->ApplyCommand("/control/execute vis.mac");
101#endif
102 ui->SessionStart();
103 delete ui;
104#endif
105 }
106 else // Batch mode
107 {
108 G4String command = "/control/execute ";
109 G4String fileName = argv[1];
110 UImanager->ApplyCommand(command+fileName);
111 }
112
113 // Job termination
114 // Free the store: user actions, physics_list and detector_description are
115 // owned and deleted by the run manager, so they should not
116 // be deleted in the main() program !
117
118#ifdef G4VIS_USE
119 delete visManager;
120#endif
121 delete runManager;
122
123 return 0;
124}
Note: See TracBrowser for help on using the repository browser.