source: trunk/examples/extended/runAndEvent/RE03/RE03.cc @ 1309

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

update to geant4.9.3

File size: 4.3 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: RE03.cc,v 1.4 2007/11/17 01:26:01 asaim Exp $
28// GEANT4 tag $Name: geant4-09-03-cand-01 $
29//
30//
31
32#include "G4RunManager.hh"
33#include "G4UImanager.hh"
34#include "G4UIterminal.hh"
35#include "G4UItcsh.hh"
36#include "G4ScoringManager.hh"
37
38#ifdef G4VIS_USE
39#include "G4VisExecutive.hh"
40#endif
41#include "RE03DetectorConstruction.hh"
42#include "RE03PhysicsList.hh"
43#include "RE03PrimaryGeneratorAction.hh"
44
45//====================================================================
46// Un-comment this line for user defined score writer
47//    #include "RE03UserScoreWriter.hh"
48//====================================================================
49
50int main(int argc,char** argv)
51{
52 // Construct the run manager
53 //
54 G4RunManager * runManager = new G4RunManager;
55
56 // Activate UI-command base scorer
57 G4ScoringManager * scManager = G4ScoringManager::GetScoringManager();
58 scManager->SetVerboseLevel(1);
59
60//====================================================================
61// Un-comment this line for user defined score writer
62//    scManager->SetScoreWriter(new RE03UserScoreWriter());
63//====================================================================
64
65 // Set mandatory initialization classes
66 //
67 G4VUserDetectorConstruction* detector = new RE03DetectorConstruction;
68 runManager->SetUserInitialization(detector);
69 //
70 G4VUserPhysicsList* physics = new RE03PhysicsList;
71 runManager->SetUserInitialization(physics);
72   
73 // Set user action classes
74 //
75 G4VUserPrimaryGeneratorAction* gen_action = new RE03PrimaryGeneratorAction;
76 runManager->SetUserAction(gen_action);
77 //
78 
79#ifdef G4VIS_USE
80 // Visualization manager
81 //
82 G4VisManager* visManager = new G4VisExecutive;
83 visManager->Initialize();
84#endif
85   
86 // Initialize G4 kernel
87 //
88 runManager->Initialize();
89 
90 // Get the pointer to the User Interface manager
91 //
92 G4UImanager* UI = G4UImanager::GetUIpointer(); 
93 UI->ApplyCommand("/control/execute vis.mac");   
94
95 if (argc==1)   // Define UI session for interactive mode
96 {
97   G4UIsession* session=0;
98 
99   // G4UIterminal is a (dumb) terminal
100   //
101#ifdef G4UI_USE_TCSH
102   session = new G4UIterminal(new G4UItcsh);     
103#else
104   session = new G4UIterminal();
105#endif   
106     
107   session->SessionStart();
108
109   delete session;
110 }
111 else           // Batch mode
112 { 
113   G4String command = "/control/execute ";
114   G4String fileName = argv[1];
115   UI->ApplyCommand(command+fileName);
116 }
117
118  // Job termination
119  // Free the store: user actions, physics_list and detector_description are
120  //                 owned and deleted by the run manager, so they should not
121  //                 be deleted in the main() program !
122
123#ifdef G4VIS_USE
124 delete visManager;
125#endif
126 delete runManager;
127
128 return 0;
129}
Note: See TracBrowser for help on using the repository browser.