source: trunk/source/processes/electromagnetic/lowenergy/test/hTest/hTest.cc @ 1199

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

nvx fichiers dans CVS

File size: 5.4 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// -------------------------------------------------------------
28//      GEANT4 hTest
29//
30//      History: based on object model of
31//      2nd December 1995, G.Cosmo
32//      ---------- hTest ----------------------------
33//             
34//  Modified: 05.04.01 Vladimir Ivanchenko new design of hTest
35//
36// -------------------------------------------------------------
37
38//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
39//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
40
41#include "G4RunManager.hh"
42#include "G4UImanager.hh"
43#include "G4UIterminal.hh"
44#include "Randomize.hh"
45
46#ifdef G4VIS_USE
47#include "hTestVisManager.hh"
48#endif
49
50#include "hTestDetectorConstruction.hh"
51#include "hTestPhysicsList.hh"
52#include "hTestPrimaryGeneratorAction.hh"
53#include "hTestEventAction.hh"
54#include "hTestTrackingAction.hh"
55#include "hTestRunAction.hh"
56
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
58//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59
60int main(int argc,char** argv) {
61
62  G4int verbose = 1;
63  //choose the Random engine
64  //  HepRandom::setTheEngine(new RanecuEngine);
65 
66  // Construct the default run manager
67  G4RunManager * runManager = new G4RunManager();
68
69  // set mandatory initialization classes
70  hTestDetectorConstruction* det = new hTestDetectorConstruction();
71  runManager->SetUserInitialization(det);
72  det->SetVerbose(verbose);
73  if(verbose >0) G4cout << "Detector Construction is defined" << G4endl;
74 
75  runManager->SetUserInitialization(new hTestPhysicsList(det));
76  if(verbose >0) G4cout << "Physics List is defined" << G4endl;
77
78#ifdef G4VIS_USE
79  G4cout << "VisManager will be inicialized" << G4endl;
80  // visualization manager
81  G4VisManager* visManager = new hTestVisManager;
82  visManager->Initialize();
83#endif
84
85  G4cout << "User actions will be initialized" << G4endl;
86 
87  // set user action classes
88  runManager->SetUserAction(new hTestPrimaryGeneratorAction(det));
89  if(verbose >0) G4cout << "hTestPrimaryGeneratorAction is defined" << G4endl;
90
91  runManager->SetUserAction(new hTestRunAction());
92  if(verbose >0) G4cout << "hTestRunAction is defined" << G4endl;
93
94  hTestEventAction* event = new hTestEventAction(det);
95  runManager->SetUserAction(event);
96  if(verbose >0) G4cout << "EventAction is defined" << G4endl;
97
98  runManager->SetUserAction(new hTestTrackingAction());
99  if(verbose >0) G4cout << "TrackingAction is defined" << G4endl;
100 
101  // get the pointer to the User Interface manager
102  G4UImanager* UI = G4UImanager::GetUIpointer(); 
103  if(1 < verbose) UI->ListCommands("/hTest/");
104
105  if (argc==1)   // Define UI terminal for interactive mode 
106    { 
107     // Initialize G4 kernel
108     runManager->Initialize();
109
110     G4UIsession * session = new G4UIterminal;
111     UI->ApplyCommand("/control/execute init.mac");   
112     session->SessionStart();
113     delete session;
114    }
115  else if (argc>1) // Batch mode with 1 or more files
116    { 
117     if(verbose >0) G4cout << "UI interface is started" << G4endl;
118     G4String command = "/control/execute ";
119     G4String fileName = argv[1];
120     UI->ApplyCommand(command+fileName);
121
122     // Initialize G4 kernel
123     G4int nev = det->GetNumberOfEvents();
124     if(nev > 0) {
125       G4cout << "Start initialisation for hTest" << G4endl;
126       runManager->Initialize();
127
128       if(verbose >0) {
129         G4cout << "Start event loop for " << nev 
130                << " events" << G4endl;
131       }
132
133       runManager->BeamOn(nev);
134     }
135
136     // next file
137     if(argc==3) {
138       if(verbose >0) G4cout << "Second mac file is applied" << G4endl; 
139       UI->ApplyCommand(command+argv[2]);
140     }
141    }
142   
143  // job termination
144 
145#ifdef G4VIS_USE
146  delete visManager;
147#endif
148
149  G4cout << "runManager will be deleted" << G4endl; 
150  delete runManager;
151  G4cout << "runManager is deleted" << G4endl; 
152
153  return 0;
154}
155
Note: See TracBrowser for help on using the repository browser.