LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.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 62 of file Hadr00.cc.

62  {
63 
64  //detect interactive mode (if no arguments) and define UI session
65  G4UIExecutive* ui = nullptr;
66  if (argc == 1) { ui = new G4UIExecutive(argc,argv); }
67 
68 #ifdef G4MULTITHREADED
69  G4MTRunManager * runManager = new G4MTRunManager();
70 
71  // Number of threads can be defined via 3rd argument
72  if (argc==4) {
73  G4int nThreads = G4UIcommand::ConvertToInt(argv[3]);
74  runManager->SetNumberOfThreads(nThreads);
75  }
76  G4cout << "##### Hadr00 started for " << runManager->GetNumberOfThreads()
77  << " threads" << " #####" << G4endl;
78 #else
79  G4RunManager * runManager = new G4RunManager();
80  G4cout << "##### Hadr00 started in sequential mode"
81  << " #####" << G4endl;
82 #endif
83 
84  //set mandatory initialization classes
86  runManager->SetUserInitialization(det);
87 
88  G4PhysListFactory factory;
89  G4VModularPhysicsList* phys = nullptr;
90  G4String physName = "";
91 
92  //Physics List name defined via 3nd argument
93  if (argc>=3) { physName = argv[2]; }
94 
95  //Physics List is defined via environment variable PHYSLIST
96  if ("" == physName) {
97  char* path = std::getenv("PHYSLIST");
98  if (path) { physName = G4String(path); }
99  }
100 
101  //if name is not known to the factory use FTFP_BERT
102  if("" == physName || !factory.IsReferencePhysList(physName)) {
103  physName = "FTFP_BERT";
104  }
105 
106  //reference PhysicsList via its name
107  phys = factory.GetReferencePhysList(physName);
108 
109  runManager->SetUserInitialization(phys);
110  det->SetPhysicsList(phys);
111 
112  //set user action classes
113  runManager->SetUserInitialization(new ActionInitialization(det));
114 
115  //initialize visualization
116  G4VisManager* visManager = nullptr;
117 
118  //get the pointer to the User Interface manager
119  G4UImanager* UImanager = G4UImanager::GetUIpointer();
120 
121  if (ui) {
122  //interactive mode
123  visManager = new G4VisExecutive;
124  visManager->Initialize();
125  ui->SessionStart();
126  delete ui;
127  } else {
128  //batch mode
129  G4String command = "/control/execute ";
130  G4String fileName = argv[1];
131  UImanager->ApplyCommand(command+fileName);
132  }
133 
134  //job termination
135  delete visManager;
136  delete runManager;
137 }