Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Hadr01.cc File Reference

Main program of the hadronic/Hadr01 example. More...

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "G4PhysListFactory.hh"
#include "G4VModularPhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "PhysicsListMessenger.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "StackingAction.hh"
Include dependency graph for Hadr01.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the hadronic/Hadr01 example.

Definition in file Hadr01.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 74 of file Hadr01.cc.

74  {
75 
76  //choose the Random engine
78 
79  //Construct the default run manager
80  G4RunManager * runManager = new G4RunManager();
81 
82  //set mandatory initialization classes
84 
85  G4PhysListFactory factory;
86  G4VModularPhysicsList* phys = nullptr;
87  PhysicsListMessenger* mess = nullptr;
88  G4String physName = "";
89 
90  // Physics List name defined via 3nd argument
91  if (argc==3) { physName = argv[2]; }
92 
93  // Physics List name defined via environment variable
94  if("" == physName) {
95  char* path = getenv("PHYSLIST");
96  if (path) { physName = G4String(path); }
97  }
98 
99  // reference PhysicsList via its name
100  if("" != physName && factory.IsReferencePhysList(physName)) {
101  phys = factory.GetReferencePhysList(physName);
102 
103  // instantiated messenger
104  mess = new PhysicsListMessenger();
105  }
106 
107  // local Physics List
108  if(!phys) { phys = new PhysicsList(); }
109 
110  // define physics
111  runManager->SetUserInitialization(phys);
112  runManager->SetUserAction(new PrimaryGeneratorAction());
113 
114  //set user action classes
115  runManager->SetUserAction(new RunAction());
116  runManager->SetUserAction(new EventAction());
117  runManager->SetUserAction(new StackingAction());
118 
119  //get the pointer to the User Interface manager
120  G4UImanager* UImanager = G4UImanager::GetUIpointer();
121 #ifdef G4VIS_USE
122  G4VisManager* visManager = nullptr;
123 #endif
124 
125  if (argc==1) // Define UI terminal for interactive mode
126  {
127 #ifdef G4VIS_USE
128  //visualization manager
129  visManager = new G4VisExecutive;
130  visManager->Initialize();
131 #endif
132 #ifdef G4UI_USE
133  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
134  ui->SessionStart();
135  delete ui;
136 #endif
137  }
138  else // Batch mode
139  {
140  G4String command = "/control/execute ";
141  G4String fileName = argv[1];
142  UImanager->ApplyCommand(command+fileName);
143  }
144 
145  //job termination
146 #ifdef G4VIS_USE
147  delete visManager;
148 #endif
149  delete runManager;
150  delete mess;
151 
152  return 0;
153 }
The primary generator action class with particle gun.
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
Event action class.
Definition: EventAction.hh:45
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
G4bool IsReferencePhysList(const G4String &)
void Initialize()
Detector construction class to define materials and geometry.
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:270
Run action class.
Definition: RunAction.hh:45
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447
virtual void SetUserAction(G4UserRunAction *userAction)
Physics list class.
Definition: PhysicsList.hh:47

Here is the call graph for this function: