Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
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 // $Id: wls.cc 110278 2018-05-17 14:48:26Z gcosmo $
27 //
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #ifndef WIN32
34 #include <unistd.h>
35 #endif
36 
37 #include "G4Types.hh"
38 
39 #ifdef G4MULTITHREADED
40 #include "G4MTRunManager.hh"
41 #else
42 #include "G4RunManager.hh"
43 #endif
44 
45 #include "G4UImanager.hh"
46 
47 #include "Randomize.hh"
48 
49 #include "WLSPhysicsList.hh"
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  G4String physName = "QGSP_BERT_HP";
87 
88 #ifndef WIN32
89  G4int c = 0;
90  while ((c=getopt(argc,argv,"p")) != -1)
91  {
92  switch (c)
93  {
94  case 'p':
95  physName = optarg;
96  G4cout << "Physics List used is " << physName << G4endl;
97  break;
98  case ':': /* -p without operand */
99  fprintf(stderr,
100  "Option -%c requires an operand\n", optopt);
101  break;
102  case '?':
103  fprintf(stderr,
104  "Unrecognised option: -%c\n", optopt);
105  }
106  }
107 #endif
108 
109  // Set mandatory initialization classes
110  //
111  // Detector construction
113  runManager->SetUserInitialization(detector);
114  // Physics list
115  runManager->SetUserInitialization(new WLSPhysicsList(physName));
116  // User action initialization
117  runManager->SetUserInitialization(new WLSActionInitialization(detector));
118 
119  // Initialize visualization
120  //
121  G4VisManager* visManager = new G4VisExecutive;
122  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
123  // G4VisManager* visManager = new G4VisExecutive("Quiet");
124  visManager->Initialize();
125 
126  // Get the pointer to the User Interface manager
127 
128  G4UImanager * UImanager = G4UImanager::GetUIpointer();
129 
130 #ifndef WIN32
131  G4int optmax = argc;
132  if (argc > 2) { optmax = optmax-1; }
133 
134  if (optind < optmax)
135  {
136  G4String command = "/control/execute ";
137  for ( ; optind < optmax; optind++)
138  {
139  G4String macroFilename = argv[optind];
140  UImanager->ApplyCommand(command+macroFilename);
141  }
142  }
143 #else // Simple UI for Windows runs, no possibility of additional arguments
144  if (argc!=1)
145  {
146  G4String command = "/control/execute ";
147  G4String fileName = argv[1];
148  UImanager->ApplyCommand(command+fileName);
149  }
150 #endif
151  else {
152  // Define (G)UI terminal for interactive mode
153  UImanager->ApplyCommand("/control/execute init.in");
154  if (ui->IsGUI())
155  UImanager->ApplyCommand("/control/execute gui.mac");
156  ui->SessionStart();
157  delete ui;
158  }
159 
160  // job termination
161 
162  delete visManager;
163  delete runManager;
164 
165  return 0;
166 }
167 
168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
Definition of the WLSDetectorConstruction class.
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
long seed
Definition: chem4.cc:68
int main(int argc, char **argv)
Definition: genwindef.cc:359
int G4int
Definition: G4Types.hh:78
Definition of the WLSActionInitialization class.
G4GLOB_DLL std::ostream G4cout
void Initialize()
G4bool IsGUI() const
Definition of the WLSPhysicsList class.