Geant4  10.02.p02
OpNovice.cc
Go to the documentation of this file.
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 //
31 // Description: Test of Continuous Process G4Cerenkov
32 // and RestDiscrete Process G4Scintillation
33 // -- Generation Cerenkov Photons --
34 // -- Generation Scintillation Photons --
35 // -- Transport of optical Photons --
36 // Version: 5.0
37 // Created: 1996-04-30
38 // Author: Juliet Armstrong
39 // mail: gum@triumf.ca
40 //
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
43 #ifdef G4MULTITHREADED
44 #include "G4MTRunManager.hh"
45 #else
46 #include "G4RunManager.hh"
47 #endif
48 
49 #include "G4UImanager.hh"
50 
51 #include "OpNovicePhysicsList.hh"
53 
55 
56 #ifdef G4VIS_USE
57 #include "G4VisExecutive.hh"
58 #endif
59 
60 #ifdef G4UI_USE
61 #include "G4UIExecutive.hh"
62 #endif
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 namespace {
66  void PrintUsage() {
67  G4cerr << " Usage: " << G4endl;
68  G4cerr << " OpNovice [-m macro ] [-u UIsession] [-t nThreads] [-r seed] "
69  << G4endl;
70  G4cerr << " note: -t option is available only for multi-threaded mode."
71  << G4endl;
72  }
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
77 int main(int argc,char** argv)
78 {
79  // Evaluate arguments
80  //
81  if ( argc > 9 ) {
82  PrintUsage();
83  return 1;
84  }
85 
86  G4String macro;
88 #ifdef G4MULTITHREADED
89  G4int nThreads = 0;
90 #endif
91 
92  G4long myseed = 345354;
93  for ( G4int i=1; i<argc; i=i+2 ) {
94  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
95  else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
96  else if ( G4String(argv[i]) == "-r" ) myseed = atoi(argv[i+1]);
97 #ifdef G4MULTITHREADED
98  else if ( G4String(argv[i]) == "-t" ) {
99  nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
100  }
101 #endif
102  else {
103  PrintUsage();
104  return 1;
105  }
106  }
107 
108  // Choose the Random engine
109  //
110  G4Random::setTheEngine(new CLHEP::RanecuEngine);
111 
112  // Construct the default run manager
113  //
114 #ifdef G4MULTITHREADED
115  G4MTRunManager * runManager = new G4MTRunManager;
116  if ( nThreads > 0 ) runManager->SetNumberOfThreads(nThreads);
117 #else
118  G4RunManager * runManager = new G4RunManager;
119 #endif
120 
121  // Seed the random number generator manually
122  G4Random::setTheSeed(myseed);
123 
124  // Set mandatory initialization classes
125  //
126  // Detector construction
127  runManager-> SetUserInitialization(new OpNoviceDetectorConstruction());
128  // Physics list
129  runManager-> SetUserInitialization(new OpNovicePhysicsList());
130  // User action initialization
132 
133  // Initialize G4 kernel
134  //
135  runManager->Initialize();
136 
137 #ifdef G4VIS_USE
138  // Initialize visualization
139  //
140  G4VisManager* visManager = new G4VisExecutive;
141  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
142  // G4VisManager* visManager = new G4VisExecutive("Quiet");
143  visManager->Initialize();
144 #endif
145 
146  // Get the pointer to the User Interface manager
147  //
148  G4UImanager* UImanager = G4UImanager::GetUIpointer();
149 
150  if ( macro.size() ) {
151  // Batch mode
152  G4String command = "/control/execute ";
153  UImanager->ApplyCommand(command+macro);
154  }
155  else // Define UI session for interactive mode
156  {
157 #ifdef G4UI_USE
158  G4UIExecutive * ui = new G4UIExecutive(argc,argv,session);
159 #ifdef G4VIS_USE
160  UImanager->ApplyCommand("/control/execute vis.mac");
161 #else
162  UImanager->ApplyCommand("/control/execute OpNovice.in");
163 #endif
164  if (ui->IsGUI())
165  UImanager->ApplyCommand("/control/execute gui.mac");
166  ui->SessionStart();
167  delete ui;
168 #endif
169  }
170 
171  // Job termination
172  // Free the store: user actions, physics_list and detector_description are
173  // owned and deleted by the run manager, so they should not
174  // be deleted in the main() program !
175 
176 #ifdef G4VIS_USE
177  delete visManager;
178 #endif
179  delete runManager;
180 
181  return 0;
182 }
183 
184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
long G4long
Definition: G4Types.hh:80
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
static G4UIterminal * session
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:435
void Initialize()
Definition of the OpNoviceActionInitialization class.
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
int main(int argc, char **argv)
Definition: OpNovice.cc:77
G4bool IsGUI() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
G4GLOB_DLL std::ostream G4cerr