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

Main program of the B2b example. More...

#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "G4RunManagerFactory.hh"
#include "G4SteppingVerbose.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"
#include "Randomize.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 B2b example.

Definition in file exampleB2b.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 46 of file exampleB2b.cc.

47{
48 // Detect interactive mode (if no arguments) and define UI session
49 //
50 G4UIExecutive* ui = nullptr;
51 if ( argc == 1 ) { ui = new G4UIExecutive(argc, argv); }
52
53 // Optionally: choose a different Random engine...
54 // G4Random::setTheEngine(new CLHEP::MTwistEngine);
55
56 //use G4SteppingVerboseWithUnits
57 G4int precision = 4;
58 G4SteppingVerbose::UseBestUnit(precision);
59
60 // Construct the default run manager
61 //
62 auto runManager =
63 G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
64
65 // Set mandatory initialization classes
66 //
67 runManager->SetUserInitialization(new B2b::DetectorConstruction());
68
69 auto physicsList = new FTFP_BERT;
70 physicsList->RegisterPhysics(new G4StepLimiterPhysics());
71 runManager->SetUserInitialization(physicsList);
72
73 // Set user action classes
74 runManager->SetUserInitialization(new B2::ActionInitialization());
75
76 // Initialize visualization with the default graphics system
77 auto visManager = new G4VisExecutive(argc, argv);
78 // Constructors can also take optional arguments:
79 // - a graphics system of choice, eg. "OGL"
80 // - and a verbosity argument - see /vis/verbose guidance.
81 // auto visManager = new G4VisExecutive(argc, argv, "OGL", "Quiet");
82 // auto visManager = new G4VisExecutive("Quiet");
83 visManager->Initialize();
84
85 // Get the pointer to the User Interface manager
86 auto UImanager = G4UImanager::GetUIpointer();
87
88 // Process macro or start UI session
89 //
90 if ( ! ui ) {
91 // barch mode
92 G4String command = "/control/execute ";
93 G4String fileName = argv[1];
94 UImanager->ApplyCommand(command+fileName);
95 }
96 else {
97 // interactive mode
98 UImanager->ApplyCommand("/control/execute init_vis.mac");
99 if (ui->IsGUI()) {
100 UImanager->ApplyCommand("/control/execute gui.mac");
101 }
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, geometry and global uniform magnetic field.

Applications | User Support | Publications | Collaboration