Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wls.cc File Reference

Main program of the optical/wls example. More...

#include <unistd.h>
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "WLSPhysicsList.hh"
#include "WLSDetectorConstruction.hh"
#include "WLSActionInitialization.hh"
Include dependency graph for wls.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the optical/wls example.

Definition in file wls.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 67 of file wls.cc.

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 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int optind
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4GLOB_DLL std::ostream G4cout
long seed
Definition: chem4.cc:68
void Initialize()
int optopt
#define G4endl
Definition: G4ios.hh:61
char * optarg
G4bool IsGUI() const
tuple c
Definition: test.py:13
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447

Here is the call graph for this function: