LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
wls.cc File Reference

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

#include <unistd.h>
#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4OpticalPhysics.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "WLSDetectorConstruction.hh"
#include "WLSActionInitialization.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

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 64 of file wls.cc.

References seed.

65 {
66  // Instantiate G4UIExecutive if interactive mode
67  G4UIExecutive* ui = nullptr;
68  if ( argc == 1 ) {
69  ui = new G4UIExecutive(argc, argv);
70  }
71 
72 #ifdef G4MULTITHREADED
73  G4MTRunManager * runManager = new G4MTRunManager;
74 #else
75  G4int seed = 123;
76  if (argc > 2) seed = atoi(argv[argc-1]);
77 
78  // Choose the Random engine and set the seed
79 
80  G4Random::setTheEngine(new CLHEP::RanecuEngine);
81  G4Random::setTheSeed(seed);
82 
83  G4RunManager * runManager = new G4RunManager;
84 #endif
85 
86  // Set mandatory initialization classes
87  //
88  // Detector construction
89  WLSDetectorConstruction* detector = new WLSDetectorConstruction();
90  runManager->SetUserInitialization(detector);
91  // Physics list
92 
93  G4VModularPhysicsList* physicsList = new FTFP_BERT;
94  physicsList->ReplacePhysics(new G4EmStandardPhysics_option4());
95  G4OpticalPhysics* opticalPhysics = new G4OpticalPhysics();
96  physicsList->RegisterPhysics(opticalPhysics);
97  runManager->SetUserInitialization(physicsList);
98 
99  // User action initialization
100  runManager->SetUserInitialization(new WLSActionInitialization(detector));
101 
102  // Initialize visualization
103  G4VisManager* visManager = new G4VisExecutive;
104  visManager->Initialize();
105 
106  // Get the pointer to the User Interface manager
107 
108  G4UImanager * UImanager = G4UImanager::GetUIpointer();
109 
110 #ifndef WIN32
111  G4int optmax = argc;
112  if (argc > 2) { optmax = optmax-1; }
113 
114  if (optind < optmax)
115  {
116  G4String command = "/control/execute ";
117  for ( ; optind < optmax; optind++)
118  {
119  G4String macroFilename = argv[optind];
120  UImanager->ApplyCommand(command+macroFilename);
121  }
122  }
123 #else // Simple UI for Windows runs, no possibility of additional arguments
124  if (argc!=1)
125  {
126  G4String command = "/control/execute ";
127  G4String fileName = argv[1];
128  UImanager->ApplyCommand(command+fileName);
129  }
130 #endif
131  else {
132  // Define (G)UI terminal for interactive mode
133  UImanager->ApplyCommand("/control/execute init.in");
134  if (ui->IsGUI())
135  UImanager->ApplyCommand("/control/execute gui.mac");
136  ui->SessionStart();
137  delete ui;
138  }
139 
140  // job termination
141 
142  delete visManager;
143  delete runManager;
144 
145  return 0;
146 }
long seed
Definition: chem4.cc:67