Loading...
Searching...
No Matches
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/// \file OpNovice/OpNovice.cc
27/// \brief Main program of the OpNovice example
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//
43//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
46#ifdef GEANT4_USE_GDML
48#endif
50#include "FTFP_BERT.hh"
51#include "G4EmStandardPhysics_option4.hh"
52#include "G4OpticalPhysics.hh"
53#include "G4RunManagerFactory.hh"
54#include "G4Types.hh"
55#include "G4UIExecutive.hh"
56#include "G4UImanager.hh"
57#include "G4VisExecutive.hh"
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60namespace
61{
62 void PrintUsage()
63 {
64 G4cerr << " Usage: " << G4endl;
65#ifdef GEANT4_USE_GDML
66 G4cerr << " OpNovice [-g gdmlfile] [-m macro ] [-u UIsession] [-t "
67 "nThreads] [-r seed] "
68 << G4endl;
69#else
70 G4cerr << " OpNovice [-m macro ] [-u UIsession] [-t nThreads] [-r seed] "
71 << G4endl;
72#endif
73 G4cerr << " note: -t option is available only for multi-threaded mode."
74 << G4endl;
75 }
76} // namespace
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79
80int main(int argc, char** argv)
81{
82 // Evaluate arguments
83 //
84 if(argc > 9)
85 {
86 PrintUsage();
87 return 1;
88 }
89 G4String gdmlfile;
90 G4String macro;
91 G4String session;
92#ifdef G4MULTITHREADED
93 G4int nThreads = 0;
94#endif
95
96 G4long myseed = 345354;
97 for(G4int i = 1; i < argc; i = i + 2)
98 {
99 if(G4String(argv[i]) == "-g")
100 gdmlfile = argv[i + 1];
101 else if(G4String(argv[i]) == "-m")
102 macro = argv[i + 1];
103 else if(G4String(argv[i]) == "-u")
104 session = argv[i + 1];
105 else if(G4String(argv[i]) == "-r")
106 myseed = atoi(argv[i + 1]);
107#ifdef G4MULTITHREADED
108 else if(G4String(argv[i]) == "-t")
109 {
110 nThreads = G4UIcommand::ConvertToInt(argv[i + 1]);
111 }
112#endif
113 else
114 {
115 PrintUsage();
116 return 1;
117 }
118 }
119
120 // Instantiate G4UIExecutive if interactive mode
121 G4UIExecutive* ui = nullptr;
122 if(macro.size() == 0)
123 {
124 ui = new G4UIExecutive(argc, argv);
125 }
126
127 // Construct the default run manager
128 auto runManager = G4RunManagerFactory::CreateRunManager();
129#ifdef G4MULTITHREADED
130 if(nThreads > 0)
131 runManager->SetNumberOfThreads(nThreads);
132#endif
133
134 // Seed the random number generator manually
135 G4Random::setTheSeed(myseed);
136
137 // Set mandatory initialization classes
138 //
139 // Detector construction
140 if(gdmlfile != "")
141 {
142#ifdef GEANT4_USE_GDML
143 runManager->SetUserInitialization(
145#else
146 G4cout << "Error! Input gdml file specified, but Geant4 wasn't" << G4endl
147 << "built with gdml support." << G4endl;
148 return 1;
149#endif
150 }
151 else
152 {
153 runManager->SetUserInitialization(new OpNoviceDetectorConstruction());
154 }
155 // Physics list
156 G4VModularPhysicsList* physicsList = new FTFP_BERT;
157 physicsList->ReplacePhysics(new G4EmStandardPhysics_option4());
158 auto opticalPhysics = new G4OpticalPhysics();
159 physicsList->RegisterPhysics(opticalPhysics);
160 runManager->SetUserInitialization(physicsList);
161
162 runManager->SetUserInitialization(new OpNoviceActionInitialization());
163
164 G4VisManager* visManager = new G4VisExecutive("Quiet");
165 visManager->Initialize();
166
167 G4UImanager* UImanager = G4UImanager::GetUIpointer();
168
169 if(macro.size())
170 {
171 G4String command = "/control/execute ";
172 UImanager->ApplyCommand(command + macro);
173 }
174 else // Define UI session for interactive mode
175 {
176 UImanager->ApplyCommand("/control/execute vis.mac");
177 if(ui->IsGUI())
178 UImanager->ApplyCommand("/control/execute gui.mac");
179 ui->SessionStart();
180 delete ui;
181 }
182
183 delete visManager;
184 delete runManager;
185
186 return 0;
187}
188
189//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Definition of the OpNoviceActionInitialization class.
Definition of the OpNoviceDetectorConstruction class.
void PrintUsage()
int main()
Definition testCommon.cc:47

Applications | User Support | Publications | Collaboration