QwGeant4
Hadr00.cc File Reference
#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 dependency graph for Hadr00.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 69 of file Hadr00.cc.

69  {
70 
71  //choose the Random engine
72  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
73 
74  //Construct the default run manager
75  G4RunManager * runManager = new G4RunManager();
76 
77  //set mandatory initialization classes
78  runManager->SetUserInitialization(new DetectorConstruction());
79 
80  G4PhysListFactory factory;
81  G4VModularPhysicsList* phys = 0;
82  G4String physName = "";
83 
84  // Physics List name defined via 3nd argument
85  if (argc==3) { physName = argv[2]; }
86 
87  // Physics List is defined via environment variable PHYSLIST
88  if("" == physName) {
89  char* path = getenv("PHYSLIST");
90  if (path) { physName = G4String(path); }
91  }
92 
93  // if name is not known to the factory use FTFP_BERT
94  if("" == physName || !factory.IsReferencePhysList(physName)) {
95  physName = "QGSP_BERT";
96  }
97 
98  // reference PhysicsList via its name
99  phys = factory.GetReferencePhysList(physName);
100 
101  runManager->SetUserInitialization(phys);
102 
103  runManager->SetUserAction(new PrimaryGeneratorAction());
104 
105  //set user action classes
106  runManager->SetUserAction(new RunAction());
107  runManager->SetUserAction(new EventAction());
108 
109  //get the pointer to the User Interface manager
110  G4UImanager* UImanager = G4UImanager::GetUIpointer();
111 #ifdef G4VIS_USE
112  G4VisManager* visManager = 0;
113 #endif
114 
115  if (argc==1) // Define UI terminal for interactive mode
116  {
117 #ifdef G4VIS_USE
118  //visualization manager
119  visManager = new G4VisExecutive;
120  visManager->Initialize();
121 #endif
122 #ifdef G4UI_USE
123  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
124  ui->SessionStart();
125  delete ui;
126 #endif
127  }
128  else // Batch mode
129  {
130  G4String command = "/control/execute ";
131  G4String fileName = argv[1];
132  UImanager->ApplyCommand(command+fileName);
133  }
134 
135  //job termination
136 #ifdef G4VIS_USE
137  delete visManager;
138 #endif
139  delete runManager;
140 
141  return 0;
142 }