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

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

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "DetectorConstruction.hh"
#include "G4PhysListFactory.hh"
#include "G4VModularPhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "StackingAction.hh"
#include "HistoManager.hh"
#include "UrQMD.hh"
Include dependency graph for Hadr02.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the hadronic/Hadr02 example.

Definition in file Hadr02.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 71 of file Hadr02.cc.

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

Here is the call graph for this function: