Loading...
Searching...
No Matches
Functions
wls.cc File Reference

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

#include "WLSActionInitialization.hh"
#include "WLSDetectorConstruction.hh"
#include "FTFP_BERT.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "G4OpticalPhysics.hh"
#include "G4RunManagerFactory.hh"
#include "G4Types.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 46 of file wls.cc.

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}

Applications | User Support | Publications | Collaboration