Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
olapex.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$
31 //
32 //
33 // --------------------------------------------------------------
34 // GEANT 4 - OLAP, Debugging Tool for Ovelapping Geometries
35 //
36 // Author: Martin Liendl - Martin.Liendl@cern.ch
37 //
38 // --------------------------------------------------------------
39 //
40 // the detector-construction
41 #include "RandomDetector.hh"
42 
43 // Geant4
44 #include "G4RunManager.hh"
45 #include "G4UImanager.hh"
46 
47 // this module
48 #include "OlapGenerator.hh"
49 #include "OlapDetConstr.hh"
50 #include "OlapPhysicsList.hh"
51 #include "OlapManager.hh"
52 #include "OlapRunAction.hh"
53 #include "OlapEventAction.hh"
54 #include "OlapSteppingAction.hh"
55 #include "G4GeoNav.hh"
56 
57 #ifdef G4VIS_USE
58  #include "G4VisExecutive.hh"
59 #endif
60 
61 #ifdef G4UI_USE
62 #include "G4UIExecutive.hh"
63 #endif
64 
65 #ifdef debug
66  #include "G4LogicalVolumeStore.hh"
67  #include "G4PhysicalVolumeStore.hh"
68 #endif
69 
70 
71 int main(int argc,char** argv) {
72 
73 
74  G4RunManager * runManager = new G4RunManager;
75 
76  // put the user-geometry here
77  G4VUserDetectorConstruction * origGeom = new RandomDetector(0);
78  OlapDetConstr * olapGeom = new OlapDetConstr(origGeom);
79  runManager->SetUserInitialization(olapGeom);
80 
81  runManager->SetUserInitialization(new OlapPhysicsList);
82  runManager->SetUserAction(new OlapGenerator);
83 
84  // initialize G4
85  runManager->Initialize();
86 
87  // initialize overlap-detection
89  olap->GotoLV(olap->GetFullWorld()->GetLogicalVolume()->GetName());
90 
91  //User action classes.
92  OlapRunAction * olapRunAction = new OlapRunAction;
93  OlapEventAction * olapEventAction = new OlapEventAction(olapRunAction);
94  OlapSteppingAction * olapSteppingAction = new OlapSteppingAction(olapEventAction);
95  runManager->SetUserAction(olapRunAction);
96  runManager->SetUserAction(olapEventAction);
97  runManager->SetUserAction(olapSteppingAction);
98 
99 #ifdef debug
100  //Get number of logical and physical volumes
103  G4cout << endl
104  << "Number of Logical volumes " << logstore->entries() << endl
105  << "====================================" << endl
106  << "Number of Physical volumes " << phystore->entries() << endl
107  << "====================================" << endl << endl;
108 #endif
109 
110 #ifdef G4VIS_USE
111  //Instantiating VisManager
112  G4VisManager *visManager = new G4VisExecutive;
113  visManager -> Initialize();
114 #endif
115 
116  //Get the pointer for the User Interface maager
117  G4UImanager* UImanager = G4UImanager::GetUIpointer();
118 
119  if (argc!=1) // batch mode
120  {
121 #ifdef G4VIS_USE
122  visManager->SetVerboseLevel("quiet");
123 #endif
124  G4String command = "/control/execute ";
125  G4String fileName = argv[1];
126  UImanager->ApplyCommand(command+fileName);
127  }
128  else
129  { // interactive mode : define UI session
130 #ifdef G4UI_USE
131  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
132  ui->SessionStart();
133  delete ui;
134 #endif
135  }
136 
137 #ifdef G4VIS_USE
138  delete visManager;
139 #endif
140  delete runManager;
141 
142  return 0;
143 }