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

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

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4String.hh"
#include "FTFP_BERT.hh"
#include "G4OpticalPhysics.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "DetectorConstruction.hh"
#include "ActionInitialization.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/OpNovice2 example.

Definition in file OpNovice2.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 56 of file OpNovice2.cc.

57 {
58 
59  //detect interactive mode (if no arguments) and define UI session
60  G4UIExecutive* ui = nullptr;
61  if (argc == 1) ui = new G4UIExecutive(argc,argv);
62 
63 #ifdef G4MULTITHREADED
64  G4MTRunManager * runManager = new G4MTRunManager;
65  G4int nThreads = std::min(G4Threading::G4GetNumberOfCores(), 4);
66  runManager->SetNumberOfThreads(nThreads);
67  G4cout << "===== OpNovice2 is started with "
68  << runManager->GetNumberOfThreads() << " threads =====" << G4endl;
69 #else
70  G4RunManager * runManager = new G4RunManager;
71 #endif
72 
74  runManager->SetUserInitialization(detector);
75 
76  G4VModularPhysicsList* physicsList = new FTFP_BERT;
77  physicsList->ReplacePhysics(new G4EmStandardPhysics_option4());
78  G4OpticalPhysics* opticalPhysics = new G4OpticalPhysics();
79 
80  physicsList->RegisterPhysics(opticalPhysics);
81  runManager->SetUserInitialization(physicsList);
82 
83  runManager->SetUserInitialization(new ActionInitialization());
84 
85  //initialize visualization
86  G4VisManager* visManager = new G4VisExecutive;
87  visManager->Initialize();
88 
89  //get the pointer to the User Interface manager
90  G4UImanager* UImanager = G4UImanager::GetUIpointer();
91 
92  if (ui) {
93  //interactive mode
94  UImanager->ApplyCommand("/control/execute vis.mac");
95  ui->SessionStart();
96  delete ui;
97  }
98  else {
99  //batch mode
100  G4String command = "/control/execute ";
101  G4String fileName = argv[1];
102  UImanager->ApplyCommand(command+fileName);
103  }
104 
105  // job termination
106  delete visManager;
107  delete runManager;
108  return 0;
109 }