Loading...
Searching...
No Matches
movies.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/// \file movies.cc
28/// \brief Main program of the Movies example
29
32
33#include "G4RunManagerFactory.hh"
34
35#include "G4UImanager.hh"
36#include "G4UIcommand.hh"
37#include "FTFP_BERT.hh"
38
39#include "Randomize.hh"
40
41#include "G4VisExecutive.hh"
42#include "G4UIExecutive.hh"
43
44//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
46namespace {
47 void PrintUsage() {
48 G4cerr << " Usage: " << G4endl;
49 G4cerr << " exampleMovies [-m macro ] [-u UIsession] [-t nThreads]" << G4endl;
50 G4cerr << " note: -t option is available only for multi-threaded mode."
51 << G4endl;
52 }
53}
54
55//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56
57int main(int argc,char** argv)
58{
59 // Evaluate arguments
60 //
61 if ( argc > 7 ) {
62 PrintUsage();
63 return 1;
64 }
65
66 G4String macro;
67 G4String session;
68#ifdef G4MULTITHREADED
69 G4int nThreads = 0;
70#endif
71 for ( G4int i=1; i<argc; i=i+2 ) {
72 if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
73 else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
74#ifdef G4MULTITHREADED
75 else if ( G4String(argv[i]) == "-t" ) {
76 nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
77 }
78#endif
79 else {
80 PrintUsage();
81 return 1;
82 }
83 }
84
85 // Detect interactive mode (if no macro provided) and define UI session
86 //
87 G4UIExecutive* ui = nullptr;
88 if ( ! macro.size() ) {
89 ui = new G4UIExecutive(argc, argv, session);
90 }
91
92 // Optionally: choose a different Random engine...
93 //
94 // G4Random::setTheEngine(new CLHEP::MTwistEngine);
95
96 // Construct the default run manager
97 //
98 auto* runManager =
99 G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
100#ifdef G4MULTITHREADED
101 if ( nThreads > 0 ) {
102 runManager->SetNumberOfThreads(nThreads);
103 }
104#endif
105
106 // Set mandatory initialization classes
107 //
108 auto detConstruction = new MoviesDetectorConstruction();
109 runManager->SetUserInitialization(detConstruction);
110
111 auto physicsList = new FTFP_BERT;
112 runManager->SetUserInitialization(physicsList);
113
114 auto actionInitialization = new MoviesActionInitialization;
115 runManager->SetUserInitialization(actionInitialization);
116
117 // Initialize visualization
118 //
119 auto visManager = new G4VisExecutive;
120 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
121 // G4VisManager* visManager = new G4VisExecutive("Quiet");
122 visManager->Initialize();
123
124 // Get the pointer to the User Interface manager
125 auto UImanager = G4UImanager::GetUIpointer();
126
127 // Process macro or start UI session
128 //
129 if ( macro.size() ) {
130 // batch mode
131 G4String command = "/control/execute ";
132 UImanager->ApplyCommand(command+macro);
133 }
134 else {
135 // interactive mode : define UI session
136 UImanager->ApplyCommand("/control/execute init_vis.mac");
137 if (ui->IsGUI()) {
138 UImanager->ApplyCommand("/control/execute gui.mac");
139 }
140 ui->SessionStart();
141 delete ui;
142 }
143
144 // Job termination
145 // Free the store: user actions, physics_list and detector_description are
146 // owned and deleted by the run manager, so they should not be deleted
147 // in the main() program !
148
149 delete visManager;
150 delete runManager;
151}
152
153//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
Definition of the MoviesActionInitialization class.
Definition of the MoviesDetectorConstruction class.
void PrintUsage()
int main()
Definition testCommon.cc:47

Applications | User Support | Publications | Collaboration