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

Main program of the B1 example. More...

#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "G4RunManagerFactory.hh"
#include "G4SteppingVerbose.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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 47 of file exampleB1.cc.

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

Applications | User Support | Publications | Collaboration