LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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"

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
74  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
75 
76  //Construct the default run manager
77  G4RunManager * runManager = new G4RunManager();
78 
79  //set mandatory initialization classes
80  runManager->SetUserInitialization(new DetectorConstruction());
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);
104  HistoManager::GetPointer()->SetPhysicsList(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 }