Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
AnaEx02.cc File Reference

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

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "SteppingAction.hh"
#include "HistoManager.hh"

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 57 of file AnaEx02.cc.

References G4UImanager::ApplyCommand(), G4UImanager::GetUIpointer(), G4RunManager::Initialize(), G4VisManager::Initialize(), G4UIExecutive::SessionStart(), G4RunManager::SetUserAction(), and G4RunManager::SetUserInitialization().

58 {
59  // Construct the default run manager
60  //
61  G4RunManager * runManager = new G4RunManager;
62 
63  // Set mandatory initialization classes
64  //
66  runManager->SetUserInitialization(detector);
67  //
68  PhysicsList* physics = new PhysicsList;
69  runManager->SetUserInitialization(physics);
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  // Get the pointer to the User Interface manager
96  //
98 
99  if (argc!=1) // batch mode
100  {
101  G4String command = "/control/execute ";
102  G4String fileName = argv[1];
103  UImanager->ApplyCommand(command+fileName);
104  }
105  else
106  { // interactive mode : define visualization and UI terminal
107 #ifdef G4VIS_USE
108  G4VisManager* visManager = new G4VisExecutive;
109  visManager->Initialize();
110 #ifdef G4UI_USE
111  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
112 #endif
113  UImanager->ApplyCommand("/control/execute vis.mac");
114 #endif
115 
116 #ifdef G4UI_USE
117  ui->SessionStart();
118  delete ui;
119 #endif
120 
121 #ifdef G4VIS_USE
122  delete visManager;
123 #endif
124  }
125 
126  // Job termination
127  delete histo;
128  delete runManager;
129 
130  return 0;
131 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
void Initialize()
virtual void Initialize()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
virtual void SetUserAction(G4UserRunAction *userAction)