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

Main program of the Common example. More...

#include "DetectorConstruction.hh"
#include "GeantinoPhysicsList.hh"
#include "GpsPrimaryGeneratorAction.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the Common example.

Definition in file exampleCommon.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 41 of file exampleCommon.cc.

42{
43 // Detect interactive mode (if no arguments) and define UI session
44 //
45 G4UIExecutive* ui = nullptr;
46 if ( argc == 1 ) { ui = new G4UIExecutive(argc, argv); }
47
48 // Construct the default run manager
49 G4RunManager* runManager = new G4RunManager;
50
51 // Set mandatory initialization classes
52 runManager->SetUserInitialization(new DetectorConstruction);
53 runManager->SetUserInitialization(new GeantinoPhysicsList);
54
55 // Set mandatory user action class
56 runManager->SetUserAction(new GpsPrimaryGeneratorAction);
57
58 // Initialize visualization
59 //
60 G4VisManager* visManager = new G4VisExecutive;
61 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
62 // G4VisManager* visManager = new G4VisExecutive("Quiet");
63 visManager->Initialize();
64
65 // Get the pointer to the User Interface manager
66 G4UImanager* UImanager = G4UImanager::GetUIpointer();
67
68 // Process macro or start UI session
69 //
70 if ( ! ui ) {
71 // batch mode
72 G4String command = "/control/execute ";
73 G4String fileName = argv[1];
74 UImanager->ApplyCommand(command+fileName);
75 }
76 else {
77 // interactive mode
78 UImanager->ApplyCommand("/control/execute init_vis.mac");
79 ui->SessionStart();
80 delete ui;
81 }
82
83 // Job termination
84 // Free the store: user actions, physics_list and detector_description are
85 // owned and deleted by the run manager, so they should not be deleted
86 // in the main() program !
87 delete visManager;
88 delete runManager;
89}
Simple detector construction with a box volume placed in a world.
Physics list with geantino and charged geantino only.
The primary generator class with general particle source.

Applications | User Support | Publications | Collaboration