Loading...
Searching...
No Matches
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//
27/// \file optical/wls/wls.cc
28/// \brief Main program of the optical/wls example
29//
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31
34
35#include "FTFP_BERT.hh"
36#include "G4EmStandardPhysics_option4.hh"
37#include "G4OpticalPhysics.hh"
38#include "G4RunManagerFactory.hh"
39#include "G4Types.hh"
40#include "G4UIExecutive.hh"
41#include "G4UImanager.hh"
42#include "G4VisExecutive.hh"
43
44//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45
46int main(int argc, char** argv)
47{
48 // Instantiate G4UIExecutive if interactive mode
49 G4UIExecutive* ui = nullptr;
50 if(argc == 1)
51 {
52 ui = new G4UIExecutive(argc, argv);
53 }
54
55 auto runManager = G4RunManagerFactory::CreateRunManager();
56 G4int seed = 123;
57 if(argc > 2)
58 seed = atoi(argv[argc - 1]);
59
60 // Choose the Random engine and set the seed
61 // G4Random::setTheEngine(new CLHEP::RanecuEngine);
62 G4Random::setTheSeed(seed);
63
64 // Detector construction
65 auto detector = new WLSDetectorConstruction();
66 runManager->SetUserInitialization(detector);
67
68 // Physics list
69 G4VModularPhysicsList* physicsList = new FTFP_BERT;
70 physicsList->ReplacePhysics(new G4EmStandardPhysics_option4());
71 auto opticalPhysics = new G4OpticalPhysics();
72
73 auto opticalParams = G4OpticalParameters::Instance();
74 opticalParams->SetBoundaryInvokeSD(true);
75
76 physicsList->RegisterPhysics(opticalPhysics);
77 runManager->SetUserInitialization(physicsList);
78
79 // User action initialization
80 runManager->SetUserInitialization(new WLSActionInitialization(detector));
81
82 // Initialize visualization
83 G4VisManager* visManager = new G4VisExecutive;
84 visManager->Initialize();
85
86 // Get the pointer to the User Interface manager
87 G4UImanager* UImanager = G4UImanager::GetUIpointer();
88
89 if(ui)
90 {
91 // Define (G)UI terminal for interactive mode
92 if(ui->IsGUI())
93 UImanager->ApplyCommand("/control/execute gui.mac");
94 ui->SessionStart();
95 delete ui;
96 }
97 else
98 {
99 G4String command = "/control/execute ";
100 G4String fileName = argv[1];
101 UImanager->ApplyCommand(command + fileName);
102 }
103
104 // job termination
105 delete visManager;
106 delete runManager;
107 return 0;
108}
109
110//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Definition of the WLSActionInitialization class.
Definition of the WLSDetectorConstruction class.
int main()
Definition testCommon.cc:47

Applications | User Support | Publications | Collaboration