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

Main program of the analysis/AnaEx03 example. More...

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "SteppingAction.hh"
#include "HistoManager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the analysis/AnaEx03 example.

Definition in file AnaEx03.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 51 of file AnaEx03.cc.

52 {
53  // Detect interactive mode (if no arguments) and define UI session
54  //
55  G4UIExecutive* ui = 0;
56  if ( argc == 1 ) {
57  ui = new G4UIExecutive(argc, argv);
58  }
59 
60  // Construct the default run manager
61  //
62  G4RunManager * runManager = new G4RunManager;
63 
64  // Set mandatory initialization classes
65  //
67  runManager->SetUserInitialization(detector);
68  //
69  runManager->SetUserInitialization(new FTFP_BERT);
70 
71  // set an HistoManager
72  //
73  HistoManager* histo = new HistoManager();
74 
75  // Set user action classes
76  //
77  PrimaryGeneratorAction* gen_action =
78  new PrimaryGeneratorAction(detector);
79  runManager->SetUserAction(gen_action);
80  //
81  RunAction* run_action = new RunAction(histo);
82  runManager->SetUserAction(run_action);
83  //
84  EventAction* event_action = new EventAction(run_action,histo);
85  runManager->SetUserAction(event_action);
86  //
87  SteppingAction* stepping_action =
88  new SteppingAction(detector, event_action);
89  runManager->SetUserAction(stepping_action);
90 
91  // Initialize G4 kernel
92  //
93  runManager->Initialize();
94 
95  // Initialize visualization
96  //
97  G4VisManager* visManager = new G4VisExecutive;
98  visManager->Initialize();
99 
100  // Get the pointer to the User Interface manager
101  //
102  G4UImanager* UImanager = G4UImanager::GetUIpointer();
103 
104  if ( ! ui ) {
105  // batch mode
106  G4String command = "/control/execute ";
107  G4String fileName = argv[1];
108  UImanager->ApplyCommand(command+fileName);
109  }
110  else {
111  // interactive mode
112  UImanager->ApplyCommand("/control/execute init_vis.mac");
113  ui->SessionStart();
114  delete ui;
115  }
116 
117  // Job termination
118  delete visManager;
119  delete histo;
120  delete runManager;
121 
122  return 0;
123 }