Geant4 Cross Reference |
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 // Gorad (Geant4 Open-source Radiation Analysis and Design) 27 // 28 // Author : Makoto Asai (SLAC National Accelerator Laboratory) 29 // 30 // Development of Gorad is funded by NASA Johnson Space Center (JSC) 31 // under the contract NNJ15HK11B. 32 // 33 // ******************************************************************** 34 // 35 // GRDetectorConstruction.hh 36 // Header file of the detector construction. It reads a GDML file. 37 // 38 // History 39 // September 8th, 2020 : first implementation 40 // 41 // ******************************************************************** 42 43 #ifndef GRDetectorConstruction_H 44 #define GRDetectorConstruction_H 1 45 46 #include "G4VUserDetectorConstruction.hh" 47 #include "globals.hh" 48 #include "G4ThreeVector.hh" 49 50 class G4GDMLParser; 51 class GRDetectorConstructionMessenger; 52 class GRGeomImpBiasWorld; 53 54 class GRDetectorConstruction : public G4VUserDetectorConstruction 55 { 56 friend class GRGeomImpBiasWorld; 57 58 public: 59 GRDetectorConstruction(); 60 virtual ~GRDetectorConstruction(); 61 virtual G4VPhysicalVolume* Construct(); 62 virtual void ConstructSDAndField(); 63 64 private: 65 GRDetectorConstructionMessenger* messenger; 66 G4GDMLParser* parser; 67 G4String gdmlFile; 68 G4VPhysicalVolume* fWorld; 69 G4bool initialized; 70 71 static G4double worldSize; 72 73 public: 74 G4bool SetGDMLFile(G4String&); 75 const G4String& GetGDMLFile() 76 { return gdmlFile; } 77 78 static G4double GetWorldSize() 79 { return worldSize; } 80 81 private: 82 void Read(); 83 84 public: 85 void ListSolids(G4int); 86 void ListLogVols(G4int); 87 void ListPhysVols(G4int); 88 void ListRegions(G4int); 89 G4bool CreateRegion(G4String&,G4String&); 90 G4bool CheckOverlap(G4String&,G4int,G4int,G4double); 91 92 public: 93 void ListAllMaterial(); 94 G4bool ListMaterial(G4String&); 95 void DumpNistMaterials(); 96 G4bool CreateMaterial(G4String&); 97 G4bool GetMaterial(G4String&); 98 G4int SetMaterial(G4String&,G4String&); 99 100 private: 101 G4bool applyGeomImpBias = false; 102 GRGeomImpBiasWorld* geomImpBiasWorld = nullptr; 103 struct GeomImpParameters 104 { 105 G4double radius = -1.; 106 G4ThreeVector pos0; 107 G4int nLayer = 0; 108 G4double radiusT = -1.; 109 G4ThreeVector posT; 110 G4int factor = 2; 111 G4double prob = 1.; 112 } geoImpP; 113 114 public: 115 void GeomImp(G4int n,G4double r) 116 { 117 applyGeomImpBias = true; 118 geoImpP.nLayer = n; 119 geoImpP.radius = r; 120 } 121 G4bool ApplyGeomImpBias() const 122 { return applyGeomImpBias; } 123 void GeomImpLocate(G4ThreeVector p0) 124 { geoImpP.pos0 = p0; } 125 G4double GeomImpInnerRadius(G4double rt) 126 { 127 if(rt>geoImpP.radius) 128 { return -rt; } 129 geoImpP.radiusT = rt; 130 return rt; 131 } 132 G4double GeomImpLocateTgt(G4ThreeVector pT) 133 { 134 G4ThreeVector dp = geoImpP.pos0 - pT; 135 G4double rt = geoImpP.radiusT; 136 if(rt<0.) 137 { rt = geoImpP.radius / geoImpP.nLayer; } 138 if(dp.mag() >= (geoImpP.radius - rt)) 139 { return (geoImpP.radius - rt); } 140 geoImpP.posT = pT; 141 return 0.; 142 } 143 void GeomImpFactor(G4int f) 144 { geoImpP.factor = f; } 145 void GeomImpProb(G4double p) 146 { geoImpP.prob = p; } 147 }; 148 149 #endif 150