Loading...
Searching...
No Matches
Functions
OpNovice.cc File Reference

Main program of the OpNovice example. More...

#include "OpNoviceDetectorConstruction.hh"
#include "OpNoviceActionInitialization.hh"
#include "FTFP_BERT.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "G4OpticalPhysics.hh"
#include "G4RunManagerFactory.hh"
#include "G4Types.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the OpNovice example.

Definition in file OpNovice.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 80 of file OpNovice.cc.

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}
void PrintUsage()

Applications | User Support | Publications | Collaboration