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

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

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "SteppingVerbose.hh"
#include "RunAction.hh"
#include "SteppingAction.hh"
#include "StackingAction.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/TestEm6 example.

Definition in file TestEm6.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 51 of file TestEm6.cc.

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