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

Main program of the persistency/gdml/G04 example. More...

#include <vector>
#include "G04ActionInitialization.hh"
#include "G04DetectorConstruction.hh"
#include "G04SensitiveDetector.hh"
#include "G4RunManagerFactory.hh"
#include "FTFP_BERT.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4GDMLParser.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the persistency/gdml/G04 example.

Definition in file gdml_det.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 51 of file gdml_det.cc.

52{
53 G4cout << G4endl;
54 G4cout << "Usage: gdml_det <intput_gdml_file:mandatory>"
55 << G4endl;
56 G4cout << G4endl;
57
58 if (argc<2)
59 {
60 G4cout << "Error! Mandatory input file is not specified!" << G4endl;
61 G4cout << G4endl;
62 return -1;
63 }
64
65 // Detect interactive mode (if only one argument) and define UI session
66 //
67 G4UIExecutive* ui = 0;
68 if ( argc == 2 ) {
69 ui = new G4UIExecutive(argc, argv);
70 }
71
72 G4GDMLParser parser;
73 parser.Read(argv[1]);
74
75 auto* runManager = G4RunManagerFactory::CreateRunManager();
76
77 runManager->SetUserInitialization(new G04DetectorConstruction(parser));
78 runManager->SetUserInitialization(new FTFP_BERT);
79
80 // User action initialization
81 runManager->SetUserInitialization(new G04ActionInitialization());
82 runManager->Initialize();
83
84 // Initialize visualization
85 G4VisManager* visManager = new G4VisExecutive;
86 visManager->Initialize();
87
88 // Get the pointer to the User Interface manager
89 G4UImanager* UImanager = G4UImanager::GetUIpointer();
90
91 // Process macro or start UI session
92 if ( ! ui ) // batch mode
93 {
94 G4String command = "/control/execute ";
95 G4String fileName = argv[2];
96 UImanager->ApplyCommand(command+fileName);
97 }
98 else // interactive mode
99 {
100 UImanager->ApplyCommand("/control/execute vis.mac");
101 ui->SessionStart();
102 delete ui;
103 }
104
105 delete visManager;
106 delete runManager;
107}
Action initialization class.
Detector construction for laoding GDML geometry.

Applications | User Support | Publications | Collaboration