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

Main program of the electromagnetic/TestEm18 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 "TrackingAction.hh"
#include "SteppingAction.hh"
#include "SteppingVerbose.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/TestEm18 example.

Definition in file TestEm18.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 53 of file TestEm18.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  //choose the Random engine
60  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
61 
62  //my Verbose output class
63  G4VSteppingVerbose::SetInstance(new SteppingVerbose);
64 
65  // Construct the default run manager
66  G4RunManager * runManager = new G4RunManager;
67 
68  // set mandatory initialization classes
69  DetectorConstruction* detector;
70  detector = new DetectorConstruction;
71  runManager->SetUserInitialization(detector);
72  runManager->SetUserInitialization(new PhysicsList());
73 
74  // set user action classes
75  //
76  //primaryGenerator
77  PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(detector);
78  runManager->SetUserAction(primary);
79 
80  //runAction
81  RunAction* runaction = new RunAction(detector,primary);
82  runManager->SetUserAction(runaction);
83 
84  //eventAction
85  EventAction* eventaction = new EventAction(runaction);
86  runManager->SetUserAction(eventaction);
87 
88  //TrackingAction
89  TrackingAction* trackingaction = new TrackingAction(runaction);
90  runManager->SetUserAction(trackingaction);
91 
92  //stepAction
93  SteppingAction* steppingaction = new SteppingAction(runaction, eventaction);
94  runManager->SetUserAction(steppingaction);
95 
96  //stackAction
97  StackingAction* stackingaction = new StackingAction();
98  runManager->SetUserAction(stackingaction);
99 
100  //initialize visualization
101  G4VisManager* visManager = nullptr;
102 
103  //get the pointer to the User Interface manager
104  G4UImanager* UImanager = G4UImanager::GetUIpointer();
105 
106  if (ui) {
107  //interactive mode
108  visManager = new G4VisExecutive;
109  visManager->Initialize();
110  ui->SessionStart();
111  delete ui;
112  }
113  else {
114  //batch mode
115  G4String command = "/control/execute ";
116  G4String fileName = argv[1];
117  UImanager->ApplyCommand(command+fileName);
118  }
119 
120  //job termination
121  delete visManager;
122  delete runManager;
123 }
TConfigurablePhysicsList< ModularPhysicsList > PhysicsList
Definition: PhysicsList.h:83