ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wls.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file wls.cc
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 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 
32 #ifndef WIN32
33 #include <unistd.h>
34 #endif
35 
36 #include "G4Types.hh"
37 
38 #ifdef G4MULTITHREADED
39 #include "G4MTRunManager.hh"
40 #else
41 #include "G4RunManager.hh"
42 #endif
43 
44 #include "G4UImanager.hh"
45 
46 #include "FTFP_BERT.hh"
47 #include "G4OpticalPhysics.hh"
49 
51 
53 
54 #include "G4VisExecutive.hh"
55 #include "G4UIExecutive.hh"
56 
57 // argc holds the number of arguments (including the name) on the command line
58 // -> it is ONE when only the name is given !!!
59 // argv[0] is always the name of the program
60 // argv[1] points to the first argument, and so on
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
64 int main(int argc,char** argv)
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
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 }
147 
148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......