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