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