LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
Hadr00.cc File Reference

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

#include "G4RunManager.hh"
#include "G4MTRunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "DetectorConstruction.hh"
#include "G4PhysListFactory.hh"
#include "G4VModularPhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "ActionInitialization.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the hadronic/Hadr00 example.

Definition in file Hadr00.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 68 of file Hadr00.cc.

68  {
69 
70  //choose the Random engine
71  G4Random::setTheEngine(new CLHEP::RanecuEngine());
72 
73 #ifdef G4MULTITHREADED
74  G4MTRunManager * runManager = new G4MTRunManager();
75 
76  // Number of threads can be defined via 3rd argument
77  if (argc==4) {
78  G4int nThreads = G4UIcommand::ConvertToInt(argv[3]);
79  runManager->SetNumberOfThreads(nThreads);
80  }
81  G4cout << "##### Hadr00 started for " << runManager->GetNumberOfThreads()
82  << " threads" << " #####" << G4endl;
83 #else
84  G4RunManager * runManager = new G4RunManager();
85  G4cout << "##### Hadr00 started in sequential mode"
86  << " #####" << G4endl;
87 #endif
88 
89  //set mandatory initialization classes
91  runManager->SetUserInitialization(det);
92 
93  G4PhysListFactory factory;
94  G4VModularPhysicsList* phys = 0;
95  G4String physName = "";
96 
97  // Physics List name defined via 3nd argument
98  if (argc>=3) { physName = argv[2]; }
99 
100  // Physics List is defined via environment variable PHYSLIST
101  if("" == physName) {
102  char* path = getenv("PHYSLIST");
103  if (path) { physName = G4String(path); }
104  }
105 
106  // if name is not known to the factory use FTFP_BERT
107  if("" == physName || !factory.IsReferencePhysList(physName)) {
108  physName = "FTFP_BERT";
109  }
110 
111  // reference PhysicsList via its name
112  phys = factory.GetReferencePhysList(physName);
113 
114  runManager->SetUserInitialization(phys);
115 
116  //set user action classes
117  runManager->SetUserInitialization(new ActionInitialization(det));
118 
119  //get the pointer to the User Interface manager
120  G4UImanager* UImanager = G4UImanager::GetUIpointer();
121 #ifdef G4VIS_USE
122  G4VisManager* visManager = 0;
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 
151  return 0;
152 }