Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AnaEx02.cc File Reference

Main program of the analysis/AnaEx02 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"
Include dependency graph for AnaEx02.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the analysis/AnaEx02 example.

Definition in file AnaEx02.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 52 of file AnaEx02.cc.

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

Here is the call graph for this function: