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

Main program of the eventgenerator/HepMC/HepMCEx01 example. More...

#include "G4Types.hh"
#include "FTFP_BERT.hh"
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "ExN04DetectorConstruction.hh"
#include "ExN04EventAction.hh"
#include "ExN04PrimaryGeneratorAction.hh"
#include "ExN04RunAction.hh"
#include "ExN04StackingAction.hh"
#include "ExN04SteppingAction.hh"
#include "ExN04SteppingVerbose.hh"
#include "ExN04TrackingAction.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 eventgenerator/HepMC/HepMCEx01 example.

Definition in file HepMCEx01.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 52 of file HepMCEx01.cc.

53{
54 // Instantiate G4UIExecutive if there are no arguments (interactive mode)
55 G4UIExecutive* ui = nullptr;
56 if ( argc == 1 ) {
57 ui = new G4UIExecutive(argc, argv);
58 }
59
60 // User Verbose output class
61 //
63 G4VSteppingVerbose::SetInstance(verbosity);
64
65 // Serial only Run manager
66 //
67 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly);
68
69 // User Initialization classes (mandatory)
70 //
72 runManager->SetUserInitialization(detector);
73 //
74 G4VUserPhysicsList* physics = new FTFP_BERT;
75 runManager->SetUserInitialization(physics);
76
77 runManager->Initialize();
78
79 // User Action classes
80 //
82 runManager->SetUserAction(gen_action);
83 //
84 G4UserRunAction* run_action = new ExN04RunAction;
85 runManager->SetUserAction(run_action);
86 //
87 G4UserEventAction* event_action = new ExN04EventAction;
88 runManager->SetUserAction(event_action);
89 //
90 G4UserStackingAction* stacking_action = new ExN04StackingAction;
91 runManager->SetUserAction(stacking_action);
92 //
93 G4UserTrackingAction* tracking_action = new ExN04TrackingAction;
94 runManager->SetUserAction(tracking_action);
95 //
96 G4UserSteppingAction* stepping_action = new ExN04SteppingAction;
97 runManager->SetUserAction(stepping_action);
98
99 G4VisManager* visManager = new G4VisExecutive;
100 visManager->Initialize();
101
102 //get the pointer to the User Interface manager
103 G4UImanager* UImanager = G4UImanager::GetUIpointer();
104
105 if (!ui) // batch mode
106 {
107 visManager->SetVerboseLevel("quiet");
108 G4String command = "/control/execute ";
109 G4String fileName = argv[1];
110 UImanager->ApplyCommand(command+fileName);
111 }
112 else
113 { // interactive mode : define UI session
114 ui->SessionStart();
115 delete ui;
116 }
117
118 // Free the store: user actions, physics_list and detector_description are
119 // owned and deleted by the run manager, so they should not
120 // be deleted in the main() program !
121
122 delete visManager;
123 delete runManager;
124 delete verbosity;
125}

Applications | User Support | Publications | Collaboration