Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
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 "G4EmUserPhysics.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "StackingAction.hh"

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 75 of file Hadr01.cc.

References G4UImanager::ApplyCommand(), G4PhysListFactory::GetReferencePhysList(), G4UImanager::GetUIpointer(), G4VisManager::Initialize(), G4PhysListFactory::IsReferencePhysList(), G4VModularPhysicsList::RegisterPhysics(), G4UIExecutive::SessionStart(), CLHEP::HepRandom::setTheEngine(), G4RunManager::SetUserAction(), and G4RunManager::SetUserInitialization().

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