Geant4  10.02.p01
AnaEx02.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 // $Id: AnaEx02.cc 81444 2014-05-28 14:28:20Z gcosmo $
31 //
32 //
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
36 #include "G4RunManager.hh"
37 #include "G4UImanager.hh"
38 #include "FTFP_BERT.hh"
39 
40 #include "DetectorConstruction.hh"
41 #include "PrimaryGeneratorAction.hh"
42 #include "RunAction.hh"
43 #include "EventAction.hh"
44 #include "SteppingAction.hh"
45 #include "HistoManager.hh"
46 
47 #ifdef G4VIS_USE
48 #include "G4VisExecutive.hh"
49 #endif
50 
51 #ifdef G4UI_USE
52 #include "G4UIExecutive.hh"
53 #endif
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
57 int main(int argc,char** argv)
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  runManager->SetUserInitialization(new FTFP_BERT);
69 
70  // set an HistoManager
71  //
72  HistoManager* histo = new HistoManager();
73 
74  // Set user action classes
75  //
76  PrimaryGeneratorAction* gen_action =
77  new PrimaryGeneratorAction(detector);
78  runManager->SetUserAction(gen_action);
79  //
80  RunAction* run_action = new RunAction(histo);
81  runManager->SetUserAction(run_action);
82  //
83  EventAction* event_action = new EventAction(run_action,histo);
84  runManager->SetUserAction(event_action);
85  //
86  SteppingAction* stepping_action =
87  new SteppingAction(detector, event_action);
88  runManager->SetUserAction(stepping_action);
89 
90  // Initialize G4 kernel
91  //
92  runManager->Initialize();
93 
94  // Get the pointer to the User Interface manager
95  //
97 
98  if (argc!=1) // batch mode
99  {
100  G4String command = "/control/execute ";
101  G4String fileName = argv[1];
102  UImanager->ApplyCommand(command+fileName);
103  }
104  else
105  { // interactive mode : define visualization and UI terminal
106 #ifdef G4VIS_USE
107  G4VisManager* visManager = new G4VisExecutive;
108  visManager->Initialize();
109 #ifdef G4UI_USE
110  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
111 #endif
112  UImanager->ApplyCommand("/control/execute vis.mac");
113 #endif
114 
115 #ifdef G4UI_USE
116  ui->SessionStart();
117  delete ui;
118 #endif
119 
120 #ifdef G4VIS_USE
121  delete visManager;
122 #endif
123  }
124 
125  // Job termination
126  delete histo;
127  delete runManager;
128 
129  return 0;
130 }
131 
132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction class.
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
Event action class.
Definition: EventAction.hh:45
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
int main(int argc, char **argv)
Definition: AnaEx02.cc:57
void Initialize()
virtual void Initialize()
Detector construction class to demonstrate various ways of placement.
Run action class.
Definition: RunAction.hh:45
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
virtual void SetUserAction(G4UserRunAction *userAction)