Geant4_10
wls.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 // $Id: wls.cc 78066 2013-12-03 11:08:36Z gcosmo $
27 //
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #ifndef WIN32
34 #include <unistd.h>
35 #endif
36 
37 #ifdef G4MULTITHREADED
38 #include "G4MTRunManager.hh"
39 #else
40 #include "G4RunManager.hh"
41 #endif
42 
43 #include "G4UImanager.hh"
44 
45 #include "Randomize.hh"
46 
47 #include "WLSPhysicsList.hh"
49 
51 
52 #ifdef G4VIS_USE
53 #include "G4VisExecutive.hh"
54 #endif
55 
56 #ifdef G4UI_USE
57 #include "G4UIExecutive.hh"
58 #endif
59 
60 // argc holds the number of arguments (including the name) on the command line
61 // -> it is ONE when only the name is given !!!
62 // argv[0] is always the name of the program
63 // argv[1] points to the first argument, and so on
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
67 int main(int argc,char** argv)
68 {
69 #ifdef G4MULTITHREADED
70  G4MTRunManager * runManager = new G4MTRunManager;
71 #else
72  G4int seed = 123;
73  if (argc > 2) seed = atoi(argv[argc-1]);
74 
75  // Choose the Random engine and set the seed
76 
77  G4Random::setTheEngine(new CLHEP::RanecuEngine);
78  G4Random::setTheSeed(seed);
79 
80  G4RunManager * runManager = new G4RunManager;
81 #endif
82 
83  G4String physName = "QGSP_BERT_HP";
84 
85 #ifndef WIN32
86  G4int c = 0;
87  while ((c=getopt(argc,argv,"p")) != -1)
88  {
89  switch (c)
90  {
91  case 'p':
92  physName = optarg;
93  G4cout << "Physics List used is " << physName << G4endl;
94  break;
95  case ':': /* -p without operand */
96  fprintf(stderr,
97  "Option -%c requires an operand\n", optopt);
98  break;
99  case '?':
100  fprintf(stderr,
101  "Unrecognised option: -%c\n", optopt);
102  }
103  }
104 #endif
105 
106  // Set mandatory initialization classes
107  //
108  // Detector construction
110  runManager->SetUserInitialization(detector);
111  // Physics list
112  runManager->SetUserInitialization(new WLSPhysicsList(physName));
113  // User action initialization
114  runManager->SetUserInitialization(new WLSActionInitialization(detector));
115 
116 #ifdef G4VIS_USE
117  // Initialize visualization
118  //
119  G4VisManager* visManager = new G4VisExecutive;
120  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
121  // G4VisManager* visManager = new G4VisExecutive("Quiet");
122  visManager->Initialize();
123 #endif
124 
125  // Get the pointer to the User Interface manager
126 
127  G4UImanager * UImanager = G4UImanager::GetUIpointer();
128 
129 #ifndef WIN32
130  G4int optmax = argc;
131  if (argc > 2) { optmax = optmax-1; }
132 
133  if (optind < optmax)
134  {
135  G4String command = "/control/execute ";
136  for ( ; optind < optmax; optind++)
137  {
138  G4String macroFilename = argv[optind];
139  UImanager->ApplyCommand(command+macroFilename);
140  }
141  }
142 #else // Simple UI for Windows runs, no possibility of additional arguments
143  if (argc!=1)
144  {
145  G4String command = "/control/execute ";
146  G4String fileName = argv[1];
147  UImanager->ApplyCommand(command+fileName);
148  }
149 #endif
150  else {
151  // Define (G)UI terminal for interactive mode
152 #ifdef G4UI_USE
153  G4UIExecutive * ui = new G4UIExecutive(argc,argv);
154 #ifdef G4VIS_USE
155  UImanager->ApplyCommand("/control/execute init.in");
156 #endif
157  if (ui->IsGUI())
158  UImanager->ApplyCommand("/control/execute gui.mac");
159  ui->SessionStart();
160  delete ui;
161 #endif
162  }
163 
164  // job termination
165 
166 #ifdef G4VIS_USE
167  delete visManager;
168 #endif
169  delete runManager;
170 
171  return 0;
172 }
173 
174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int optind
int main(int argc, char **argv)
Definition: genwindef.cpp:30
int G4int
Definition: G4Types.hh:78
Definition of the WLSDetectorConstruction class.
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
void Initialize()
int optopt
Definition of the WLSPhysicsList class.
#define G4endl
Definition: G4ios.hh:61
char * optarg
G4bool IsGUI() const
tuple c
Definition: test.py:13
Definition of the WLSActionInitialization class.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419