LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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 //
28 //
29 //
30 // $Id: exampleP02.cc 82291 2014-06-13 15:20:32Z gcosmo $
31 //
32 //
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
36 #include "ExP02DetectorConstruction.hh"
37 #include "ExP02DetConstrReader.hh"
38 #include "ExP02PrimaryGeneratorAction.hh"
39 
40 #include "FTFP_BERT.hh"
41 
42 
43 #include "G4RunManager.hh"
44 #include "G4UImanager.hh"
45 
46 #ifdef G4VIS_USE
47 #include "G4VisExecutive.hh"
48 #endif
49 
50 #ifdef G4UI_USE
51 #include "G4UIExecutive.hh"
52 #endif
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
56 int main(int argc, char** argv)
57 {
58 
59  if(argc==1)
60  {
61  G4cout << "Please give 'write' or 'read' as argument " << G4endl;
62  return 0;
63  }
64 
65  G4VUserDetectorConstruction* det;
66 
67  if(std::string(argv[1]) == "read")
68  {
69  det = new ExP02DetConstrReader;
70  }
71  else if(std::string(argv[1]) == "write")
72  {
73  det = new ExP02DetectorConstruction;
74  }
75  else
76  {
77  G4cout << "Wrong argument!" << G4endl;
78  return 0;
79  }
80 
81  // Run manager
82  G4RunManager * runManager = new G4RunManager;
83 
84  // UserInitialization classes (mandatory)
85  runManager->SetUserInitialization(det);
86 
87  G4VModularPhysicsList* physicsList = new FTFP_BERT;
88  runManager->SetUserInitialization(physicsList);
89 
90 #ifdef G4VIS_USE
91  // Visualization, if you choose to have it!
92  G4VisManager* visManager = new G4VisExecutive;
93  visManager->Initialize();
94 #endif
95 
96  // UserAction classes
97  runManager->SetUserAction(new ExP02PrimaryGeneratorAction());
98 
99  //Initialize G4 kernel
100  runManager->Initialize();
101 
102  //get the pointer to the User Interface manager
103  G4UImanager * UImanager = G4UImanager::GetUIpointer();
104 
105 #ifdef G4UI_USE
106  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
107 #ifdef G4VIS_USE
108  UImanager->ApplyCommand("/control/execute vis.mac");
109 #endif
110  ui->SessionStart();
111  delete ui;
112 #endif
113 
114 #ifdef G4VIS_USE
115  delete visManager;
116 #endif
117  delete runManager;
118 
119  return 0;
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
int main(int argc, char **argv)
Definition: exampleP02.cc:56