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

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

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

Definition in file TestEm17.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 53 of file TestEm17.cc.

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