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

Main program of the B1 example. More...

#include "B1DetectorConstruction.hh"
#include "B1ActionInitialization.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "QBBC.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "Randomize.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the B1 example.

Definition in file exampleB1.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 49 of file exampleB1.cc.

50 {
51  // Detect interactive mode (if no arguments) and define UI session
52  //
53  G4UIExecutive* ui = 0;
54  if ( argc == 1 ) {
55  ui = new G4UIExecutive(argc, argv);
56  }
57 
58  // Optionally: choose a different Random engine...
59  // G4Random::setTheEngine(new CLHEP::MTwistEngine);
60 
61  // Construct the default run manager
62  //
63 #ifdef G4MULTITHREADED
64  G4MTRunManager* runManager = new G4MTRunManager;
65 #else
66  G4RunManager* runManager = new G4RunManager;
67 #endif
68 
69  // Set mandatory initialization classes
70  //
71  // Detector construction
72  runManager->SetUserInitialization(new B1DetectorConstruction());
73 
74  // Physics list
75  G4VModularPhysicsList* physicsList = new QBBC;
76  physicsList->SetVerboseLevel(1);
77  runManager->SetUserInitialization(physicsList);
78 
79  // User action initialization
80  runManager->SetUserInitialization(new B1ActionInitialization());
81 
82  // Initialize visualization
83  //
84  G4VisManager* visManager = new G4VisExecutive;
85  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
86  // G4VisManager* visManager = new G4VisExecutive("Quiet");
87  visManager->Initialize();
88 
89  // Get the pointer to the User Interface manager
90  G4UImanager* UImanager = G4UImanager::GetUIpointer();
91 
92  // Process macro or start UI session
93  //
94  if ( ! ui ) {
95  // batch mode
96  G4String command = "/control/execute ";
97  G4String fileName = argv[1];
98  UImanager->ApplyCommand(command+fileName);
99  }
100  else {
101  // interactive mode
102  UImanager->ApplyCommand("/control/execute init_vis.mac");
103  ui->SessionStart();
104  delete ui;
105  }
106 
107  // Job termination
108  // Free the store: user actions, physics_list and detector_description are
109  // owned and deleted by the run manager, so they should not be deleted
110  // in the main() program !
111 
112  delete visManager;
113  delete runManager;
114 }