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

Main program of the runAndEvent/RE03 example. More...

#include "G4Types.hh"
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "G4ScoringManager.hh"
#include "RE03DetectorConstruction.hh"
#include "FTFP_BERT.hh"
#include "RE03ActionInitialization.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 runAndEvent/RE03 example.

Definition in file RE03.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 50 of file RE03.cc.

51{
52 // Instantiate G4UIExecutive if there are no arguments (interactive mode)
53 G4UIExecutive* ui = nullptr;
54 if ( argc == 1 ) {
55 ui = new G4UIExecutive(argc, argv);
56 }
57
58 // Construct the run manager
59 //
60 auto* runManager = G4RunManagerFactory::CreateRunManager();
61 runManager->SetNumberOfThreads(4);
62
63 // Activate UI-command base scorer
64 G4ScoringManager * scManager = G4ScoringManager::GetScoringManager();
65 scManager->SetVerboseLevel(1);
66
67//====================================================================
68// Un-comment this line for user defined score writer
69// scManager->SetScoreWriter(new RE03UserScoreWriter());
70//====================================================================
71
72 // Set mandatory initialization classes
73 //
75 runManager->SetUserInitialization(detector);
76 //
77 G4VUserPhysicsList* physics = new FTFP_BERT;
78 runManager->SetUserInitialization(physics);
79
80 // Set user action classes through Worker Initialization
81 //
83 runManager->SetUserInitialization(actions);
84
85 // Visualization manager
86 G4VisManager* visManager = new G4VisExecutive;
87 visManager->Initialize();
88
89 // Initialize G4 kernel
90 //
91 runManager->Initialize();
92
93 // Get the pointer to the User Interface manager
94 //
95 G4UImanager* UImanager = G4UImanager::GetUIpointer();
96
97 if (ui) // Define UI session for interactive mode
98 {
99 UImanager->ApplyCommand("/control/execute vis.mac");
100 ui->SessionStart();
101 delete ui;
102 }
103 else // Batch mode
104 {
105 G4String command = "/control/execute ";
106 G4String fileName = argv[1];
107 UImanager->ApplyCommand(command+fileName);
108 }
109
110 // Job termination
111 // Free the store: user actions, physics_list and detector_description are
112 // owned and deleted by the run manager, so they should not
113 // be deleted in the main() program !
114
115 delete visManager;
116 delete runManager;
117
118 return 0;
119}

Applications | User Support | Publications | Collaboration