Geant4  10.00.p03
userVisAction.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: userVisAction.cc 66378 2012-12-18 09:45:21Z gcosmo $
31 //
32 //
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
36 #include "B1DetectorConstruction.hh"
37 #include "B1PrimaryGeneratorAction.hh"
38 #include "B1RunAction.hh"
39 #include "B1EventAction.hh"
40 #include "B1SteppingAction.hh"
41 
42 #include "G4RunManager.hh"
43 #include "G4UImanager.hh"
44 #include "FTFP_BERT.hh"
45 
46 #ifdef G4VIS_USE
47 #include "G4VisExecutive.hh"
48 #include "UVA_VisAction.hh"
49 #endif
50 
51 #ifdef G4UI_USE
52 #include "G4UIExecutive.hh"
53 #endif
54 
55 #include "G4SystemOfUnits.hh"
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
59 int main(int argc,char** argv) {
60 
61  // Run manager
62  G4RunManager * runManager = new G4RunManager;
63 
64  // UserInitialization classes (mandatory)
66  runManager->SetUserInitialization(new FTFP_BERT);
67 
68 #ifdef G4VIS_USE
69  // Visualization, if you choose to have it!
70  G4VisManager* visManager = new G4VisExecutive;
71  visManager->Initialize();
72  // Set User Vis Action...
73  visManager->SetUserAction
74  (new UVA_VisAction, G4VisExtent(-20*cm,-10*cm,-25*cm,-15*cm,20*cm,40*cm));
75 #endif
76 
77  // UserAction classes
78  runManager->SetUserAction(new B1PrimaryGeneratorAction);
79  runManager->SetUserAction(new B1RunAction);
80  runManager->SetUserAction(new B1EventAction);
81  runManager->SetUserAction(new B1SteppingAction);
82 
83  //Initialize G4 kernel
84  runManager->Initialize();
85 
86  //get the pointer to the User Interface manager
87  G4UImanager * UImanager = G4UImanager::GetUIpointer();
88 
89  if(argc==1)
90  // Define (G)UI terminal for interactive mode
91  {
92 #ifdef G4UI_USE
93  G4UIExecutive * ui = new G4UIExecutive(argc, argv);
94  UImanager->ApplyCommand("/control/execute vis.mac");
95  ui->SessionStart();
96  delete ui;
97 #endif
98  }
99  else
100  // Batch mode
101  {
102  G4String command = "/control/execute ";
103  G4String fileName = argv[1];
104  UImanager->ApplyCommand(command+fileName);
105  }
106 
107 #ifdef G4VIS_USE
108  delete visManager;
109 #endif
110  delete runManager;
111 
112  return 0;
113 }
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116 
static const double cm
Definition: G4SIunits.hh:106
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
Run action class.
Definition: B1RunAction.hh:46
int main(int argc, char **argv)
Stepping action class.
Detector construction class to define materials and geometry.
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
Definition of the UVA_VisAction class.
void Initialize()
The primary generator action class with particle gun.
void SetUserAction(G4VUserVisAction *pVisAction, const G4VisExtent &=G4VisExtent::NullExtent)
virtual void Initialize()
Event action class.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:432
virtual void SetUserAction(G4UserRunAction *userAction)