Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleP02.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 //
26 /// \file persistency/P02/exampleP02.cc
27 /// \brief Main program of the persistency/P02 example
28 //
29 //
30 // $Id: exampleP02.cc 68025 2013-03-13 13:43:46Z gcosmo $
31 //
32 //
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
37 #include "ExP02DetConstrReader.hh"
38 #include "ExP02PhysicsList.hh"
40 
41 #include "G4RunManager.hh"
42 #include "G4UImanager.hh"
43 
44 #ifdef G4VIS_USE
45 #include "G4VisExecutive.hh"
46 #endif
47 
48 #ifdef G4UI_USE
49 #include "G4UIExecutive.hh"
50 #endif
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
54 int main(int argc, char** argv)
55 {
56 
57  if(argc==1)
58  {
59  std::cout << "Please give 'write' or 'read' as argument " << std::endl;
60  return 0;
61  }
62 
64 
65  if(std::string(argv[1]) == "read")
66  {
67  det = new ExP02DetConstrReader;
68  }
69  else if(std::string(argv[1]) == "write")
70  {
71  det = new ExP02DetectorConstruction;
72  }
73  else
74  {
75  std::cout << "Wrong argument!" << std::endl;
76  return 0;
77  }
78 
79  // Run manager
80  G4RunManager * runManager = new G4RunManager;
81 
82  // UserInitialization classes (mandatory)
83  runManager->SetUserInitialization(det);
84  runManager->SetUserInitialization(new ExP02PhysicsList);
85 
86 #ifdef G4VIS_USE
87  // Visualization, if you choose to have it!
88  G4VisManager* visManager = new G4VisExecutive;
89  visManager->Initialize();
90 #endif
91 
92  // UserAction classes
93  runManager->SetUserAction(new ExP02PrimaryGeneratorAction());
94 
95  //Initialize G4 kernel
96  runManager->Initialize();
97 
98  //get the pointer to the User Interface manager
99  G4UImanager * UImanager = G4UImanager::GetUIpointer();
100 
101 #ifdef G4UI_USE
102  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
103 #ifdef G4VIS_USE
104  UImanager->ApplyCommand("/control/execute vis.mac");
105 #endif
106  ui->SessionStart();
107  delete ui;
108 #endif
109 
110 #ifdef G4VIS_USE
111  delete visManager;
112 #endif
113  delete runManager;
114 
115  return 0;
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int main(int argc, char **argv)
Definition: exampleP02.cc:54
Definition of the ExP02PhysicsList class.
Definition of the ExP02DetectorConstruction class.
Detector construction reader using ROOT I/O.
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
void Initialize()
Definition of the ExP02DetConstrReader class.
Definition of the ExP02PrimaryGeneratorAction class.
virtual void Initialize()
Physics list.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
virtual void SetUserAction(G4UserRunAction *userAction)