LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TestEm9.cc File Reference

Main program of the electromagnetic/TestEm9 example. More...

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "SteppingAction.hh"
#include "TrackingAction.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 electromagnetic/TestEm9 example.

Definition in file TestEm9.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 52 of file TestEm9.cc.

52  {
53 
54  //detect interactive mode (if no arguments) and define UI session
55  G4UIExecutive* ui = nullptr;
56  if (argc == 1) { ui = new G4UIExecutive(argc,argv); }
57 
58  //construct the default run manager
59  G4RunManager * runManager = new G4RunManager;
60 
61  //set mandatory initialization classes
63  PhysicsList* phys;
65  runManager->SetUserInitialization(det);
66  runManager->SetUserInitialization(phys = new PhysicsList);
67  runManager->SetUserAction(kin = new PrimaryGeneratorAction(det));
68 
69  //set user action classes
70  runManager->SetUserAction(new RunAction());
71  runManager->SetUserAction(new EventAction());
72  runManager->SetUserAction(new TrackingAction());
73  runManager->SetUserAction(new SteppingAction());
74 
75  //initialize visualization
76  G4VisManager* visManager = nullptr;
77 
78  //get the pointer to the User Interface manager
79  G4UImanager* UImanager = G4UImanager::GetUIpointer();
80 
81  if (ui) {
82  //interactive mode
83  visManager = new G4VisExecutive;
84  visManager->Initialize();
85  ui->SessionStart();
86  delete ui;
87  } else {
88  //batch mode
89  G4String command = "/control/execute ";
90  G4String fileName = argv[1];
91  UImanager->ApplyCommand(command+fileName);
92  }
93 
94  //job termination
95  delete visManager;
96  delete runManager;
97 }