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

59  {
60 
61  //detect interactive mode (if no arguments) and define UI session
62  G4UIExecutive* ui = nullptr;
63  if (argc == 1) ui = new G4UIExecutive(argc,argv);
64 
65  //choose the Random engine
66  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
67 
68  //Construct the default run manager
69  G4RunManager * runManager = new G4RunManager();
70 
71  //set mandatory initialization classes
72  runManager->SetUserInitialization(new DetectorConstruction());
73 
74  G4PhysListFactory factory;
75  G4VModularPhysicsList* phys = 0;
76 
77  // default Physics List for this example
78  G4String physName = "QBBC";
79 
80  // Physics List name defined via 2nd argument
81  if (argc==3) { physName = argv[2]; }
82  else {
83  char* path = std::getenv("PHYSLIST");
84  if (path) { physName = G4String(path); }
85  }
86  if ( physName == "UrQMD" ) {
87  phys = new UrQMD;
88  } else if ( physName == "CRMC_FTFP_BERT" ) {
89  phys = new CRMC_FTFP_BERT;
90  } else {
91  phys = factory.GetReferencePhysList( physName );
92  }
93 
94  // Physics List is defined via environment variable PHYSLIST
95  if(!phys) {
96  G4cout << "Hadr02 FATAL ERROR: Physics List is not defined"
97  << G4endl;
98  return 1;
99  }
100  runManager->SetUserInitialization(phys);
101  HistoManager::GetPointer()->SetPhysicsList(phys);
102 
103  runManager->SetUserAction(new PrimaryGeneratorAction());
104 
105  //set user action classes
106  runManager->SetUserAction(new RunAction());
107  runManager->SetUserAction(new EventAction());
108  runManager->SetUserAction(new StackingAction());
109 
110  //initialize visualization
111  G4VisManager* visManager = new G4VisExecutive;
112  visManager->Initialize();
113 
114  //get the pointer to the User Interface manager
115  G4UImanager* UImanager = G4UImanager::GetUIpointer();
116 
117  if (ui) {
118  //interactive mode
119  ui->SessionStart();
120  delete ui;
121  }
122  else {
123  //batch mode
124  G4String command = "/control/execute ";
125  G4String fileName = argv[1];
126  UImanager->ApplyCommand(command+fileName);
127  }
128 
129  //job termination
130  delete visManager;
131  delete runManager;
132 }