Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4Region << 23 // >> 24 // $Id: G4Region.hh,v 1.14 2005/11/09 14:54:03 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-08-00-patch-01 $ >> 26 // >> 27 // class G4Region 27 // 28 // 28 // Class description: 29 // Class description: 29 // 30 // 30 // Defines a region or a group of regions in t 31 // Defines a region or a group of regions in the detector geometry 31 // setup, sharing properties associated to mat 32 // setup, sharing properties associated to materials or production 32 // cuts which may affect or bias specific phys 33 // cuts which may affect or bias specific physics processes. 33 34 34 // 18.09.02, G.Cosmo - Initial version << 35 // History: >> 36 // 18.09.02 G.Cosmo Initial version 35 // ------------------------------------------- 37 // -------------------------------------------------------------------- 36 #ifndef G4REGION_HH 38 #ifndef G4REGION_HH 37 #define G4REGION_HH 1 << 39 #define G4REGION_HH 38 << 39 #include <vector> << 40 #include <map> << 41 #include <algorithm> << 42 << 43 #include "G4Types.hh" << 44 #include "G4String.hh" << 45 #include "G4GeomSplitter.hh" << 46 40 47 class G4ProductionCuts; 41 class G4ProductionCuts; 48 class G4LogicalVolume; 42 class G4LogicalVolume; 49 class G4Material; 43 class G4Material; 50 class G4VUserRegionInformation; 44 class G4VUserRegionInformation; 51 class G4MaterialCutsCouple; 45 class G4MaterialCutsCouple; 52 class G4UserLimits; 46 class G4UserLimits; 53 class G4FieldManager; << 54 class G4FastSimulationManager; 47 class G4FastSimulationManager; 55 class G4VPhysicalVolume; 48 class G4VPhysicalVolume; 56 class G4UserSteppingAction; << 57 49 58 class G4RegionData << 50 #include <vector> 59 { << 51 #include <map> 60 // Encapsulates the fields associated to the << 61 // G4Region that may not be read-only. << 62 << 63 public: << 64 << 65 void initialize() << 66 { << 67 fFastSimulationManager = nullptr; << 68 fRegionalSteppingAction = nullptr; << 69 } << 70 << 71 G4FastSimulationManager* fFastSimulationMa << 72 G4UserSteppingAction* fRegionalSteppingAct << 73 }; << 74 52 75 // The type G4RegionManager is introduced to e << 53 #include "G4Types.hh" 76 // both the master thread and worker threads t << 54 #include "G4String.hh" 77 // the fields encapsulated by the class G4Regi << 78 // initializes the value for these fields, it << 79 // definition defined below. For every G4Regio << 80 // corresponding G4RegionData instance. All G4 << 81 // organized by the class G4RegionManager as a << 82 // The field "int instanceID" is added to the << 83 // The value of this field in each G4Region in << 84 // of the corresponding G4RegionData instance. << 85 // In order to use the class G4RegionManager, << 86 // the class G4Region as follows: "static G4Re << 87 // For the master thread, the array for G4Regi << 88 // dynamically along with G4Region instances a << 89 // thread, it copies the array of G4RegionData << 90 // In addition, it invokes a method similiar t << 91 // to achieve the partial effect for each inst << 92 // << 93 using G4RegionManager = G4GeomSplitter<G4Regio << 94 55 95 class G4Region 56 class G4Region 96 { 57 { 97 public: << 58 typedef std::vector<G4LogicalVolume*> G4RootLVList; >> 59 typedef std::vector<G4Material*> G4MaterialList; >> 60 typedef std::pair<G4Material*,G4MaterialCutsCouple*> G4MaterialCouplePair; >> 61 typedef std::map<G4Material*,G4MaterialCutsCouple*> G4MaterialCoupleMap; >> 62 >> 63 public: // with description 98 64 99 G4Region(const G4String& name); 65 G4Region(const G4String& name); 100 virtual ~G4Region(); 66 virtual ~G4Region(); 101 67 102 G4Region(const G4Region&) = delete; << 103 G4Region& operator=(const G4Region&) = del << 104 // Copy constructor and assignment opera << 105 << 106 inline G4bool operator==(const G4Region& r 68 inline G4bool operator==(const G4Region& rg) const; 107 // Equality defined by address only. 69 // Equality defined by address only. 108 70 109 void AddRootLogicalVolume(G4LogicalVolume* << 71 void AddRootLogicalVolume(G4LogicalVolume* lv); 110 void RemoveRootLogicalVolume(G4LogicalVolu << 72 void RemoveRootLogicalVolume(G4LogicalVolume* lv); 111 // Add/remove root logical volumes and s 73 // Add/remove root logical volumes and set/reset their 112 // daughters flags as regions. They also 74 // daughters flags as regions. They also recompute the 113 // materials list for the region. Flag f << 75 // materials list for the region. 114 // always enabled by default. Search in << 115 // when adding, assuming the user guaran << 116 // NOT already inserted, in which case s << 117 // achieved in very complex flat geometr << 118 76 119 void SetName(const G4String& name); << 77 inline void SetName(const G4String& name); 120 inline const G4String& GetName() const; 78 inline const G4String& GetName() const; 121 // Set/get region's name. 79 // Set/get region's name. 122 80 123 inline void RegionModified(G4bool flag); 81 inline void RegionModified(G4bool flag); 124 inline G4bool IsModified() const; 82 inline G4bool IsModified() const; 125 // Accessors to flag identifying if a re 83 // Accessors to flag identifying if a region has been modified 126 // (and still cuts needs to be computed) 84 // (and still cuts needs to be computed) or not. 127 85 128 inline void SetProductionCuts(G4Production 86 inline void SetProductionCuts(G4ProductionCuts* cut); 129 inline G4ProductionCuts* GetProductionCuts 87 inline G4ProductionCuts* GetProductionCuts() const; 130 88 131 inline std::vector<G4LogicalVolume*>::iter 89 inline std::vector<G4LogicalVolume*>::iterator 132 GetRootLogicalVolumeIterator(); 90 GetRootLogicalVolumeIterator(); 133 inline std::vector<G4Material*>::const_ite 91 inline std::vector<G4Material*>::const_iterator 134 GetMaterialIterator() const; 92 GetMaterialIterator() const; 135 // Return iterators to lists of root log 93 // Return iterators to lists of root logical volumes and materials. 136 94 137 inline std::size_t GetNumberOfMaterials() << 95 inline size_t GetNumberOfMaterials() const; 138 inline std::size_t GetNumberOfRootVolumes( << 96 inline size_t GetNumberOfRootVolumes() const; 139 // Return the number of elements in the 97 // Return the number of elements in the lists of materials and 140 // root logical volumes. 98 // root logical volumes. 141 99 142 void UpdateMaterialList(); 100 void UpdateMaterialList(); 143 // Clears material list and recomputes i 101 // Clears material list and recomputes it looping through 144 // each root logical volume in the regio 102 // each root logical volume in the region. 145 103 146 void ClearMaterialList(); 104 void ClearMaterialList(); 147 // Clears the material list. 105 // Clears the material list. 148 106 149 void ScanVolumeTree(G4LogicalVolume* lv, G 107 void ScanVolumeTree(G4LogicalVolume* lv, G4bool region); 150 // Scans recursively the 'lv' logical vo 108 // Scans recursively the 'lv' logical volume tree, retrieves 151 // and places all materials in the list 109 // and places all materials in the list if becoming a region. 152 110 153 inline void SetUserInformation(G4VUserRegi 111 inline void SetUserInformation(G4VUserRegionInformation* ui); 154 inline G4VUserRegionInformation* GetUserIn 112 inline G4VUserRegionInformation* GetUserInformation() const; 155 // Set and Get methods for user informat 113 // Set and Get methods for user information. 156 114 157 inline void SetUserLimits(G4UserLimits* ul 115 inline void SetUserLimits(G4UserLimits* ul); 158 inline G4UserLimits* GetUserLimits() const 116 inline G4UserLimits* GetUserLimits() const; 159 // Set and Get methods for userL-limits 117 // Set and Get methods for userL-limits associated to a region. 160 // Once user-limits are set, it will pro 118 // Once user-limits are set, it will propagate to daughter volumes. 161 119 162 inline void ClearMap(); 120 inline void ClearMap(); 163 // Reset G4MaterialCoupleMap 121 // Reset G4MaterialCoupleMap 164 122 165 inline void RegisterMaterialCouplePair(G4M 123 inline void RegisterMaterialCouplePair(G4Material* mat, 166 G4M 124 G4MaterialCutsCouple* couple); 167 // Method invoked by G4ProductionCutsTab 125 // Method invoked by G4ProductionCutsTable to register the pair. 168 126 169 inline G4MaterialCutsCouple* FindCouple(G4 127 inline G4MaterialCutsCouple* FindCouple(G4Material* mat); 170 // Find a G4MaterialCutsCouple which cor 128 // Find a G4MaterialCutsCouple which corresponds to the material 171 // in this region. 129 // in this region. 172 130 173 void SetFastSimulationManager(G4FastSimula << 131 inline void SetFastSimulationManager(G4FastSimulationManager* fsm); 174 G4FastSimulationManager* GetFastSimulation << 132 inline G4FastSimulationManager* GetFastSimulationManager() const; 175 // Set and Get methods for G4FastSimulat 133 // Set and Get methods for G4FastSimulationManager. 176 // The root logical volume that has the 134 // The root logical volume that has the region with G4FastSimulationManager 177 // becomes an envelope of fast simulatio 135 // becomes an envelope of fast simulation. 178 136 179 void ClearFastSimulationManager(); 137 void ClearFastSimulationManager(); 180 // Set G4FastSimulationManager pointer t 138 // Set G4FastSimulationManager pointer to the one for the parent region 181 // if it exists. Otherwise set to null. 139 // if it exists. Otherwise set to null. 182 140 183 inline void SetFieldManager(G4FieldManager << 184 inline G4FieldManager* GetFieldManager() c << 185 // Set and Get methods for G4FieldManage << 186 // The region with assigned field-manage << 187 // geometrical area associated with it; << 188 // to local fields eventually set to log << 189 << 190 inline G4VPhysicalVolume* GetWorldPhysical 141 inline G4VPhysicalVolume* GetWorldPhysical() const; 191 // Get method for the world physical vol 142 // Get method for the world physical volume which this region 192 // belongs to. A valid pointer will be a 143 // belongs to. A valid pointer will be assigned by G4RunManagerKernel 193 // through G4RegionStore when the geomet 144 // through G4RegionStore when the geometry is to be closed. Thus, this 194 // pointer may be incorrect at PreInit a 145 // pointer may be incorrect at PreInit and Idle state. If the pointer 195 // is null at the proper state, this par 146 // is null at the proper state, this particular region does not belong 196 // to any world (maybe not assigned to a 147 // to any world (maybe not assigned to any volume, etc.). 197 148 198 void SetWorld(G4VPhysicalVolume* wp); 149 void SetWorld(G4VPhysicalVolume* wp); 199 // Set the world physical volume if this 150 // Set the world physical volume if this region belongs to this world. 200 // If wp is null, reset the pointer. 151 // If wp is null, reset the pointer. 201 152 202 G4bool BelongsTo(G4VPhysicalVolume* thePhy 153 G4bool BelongsTo(G4VPhysicalVolume* thePhys) const; 203 // Returns whether this region belongs t 154 // Returns whether this region belongs to the given physical volume 204 // (recursively scanned to the bottom of << 155 // (recursively scanned to the bottom of the hierarchy) 205 156 206 G4Region* GetParentRegion(G4bool& unique) << 157 G4Region* GetParentRegion() const; 207 // Returns a region that contains this r 158 // Returns a region that contains this region. Otherwise null returned. 208 // Flag 'unique' is true if there is onl << 209 // the current region. << 210 159 211 void SetRegionalSteppingAction(G4UserStepp << 160 public: // without description 212 G4UserSteppingAction* GetRegionalSteppingA << 213 // Set/Get method of the regional user s << 214 << 215 public: << 216 161 217 G4Region(__void__&); 162 G4Region(__void__&); 218 // Fake default constructor for usage re 163 // Fake default constructor for usage restricted to direct object 219 // persistency for clients requiring pre 164 // persistency for clients requiring preallocation of memory for 220 // persistifiable objects. 165 // persistifiable objects. 221 166 222 inline G4int GetInstanceID() const; << 223 // Returns the instance ID. << 224 << 225 static const G4RegionManager& GetSubInstan << 226 // Returns the private data instance man << 227 << 228 static void Clean(); << 229 // Clear memory allocated by sub-instanc << 230 << 231 inline void UsedInMassGeometry(G4bool val << 232 inline void UsedInParallelGeometry(G4bool << 233 inline G4bool IsInMassGeometry() const; << 234 inline G4bool IsInParallelGeometry() const << 235 // Utility methods to identify if region << 236 // geometry for tracking or a parallel g << 237 << 238 private: 167 private: 239 168 240 inline void AddMaterial (G4Material* aMate << 169 G4Region(const G4Region&); 241 // Searchs the specified material in the << 170 G4Region& operator=(const G4Region&); 242 // if not present adds it. << 171 // Private copy constructor and assignment operator. 243 172 244 private: 173 private: 245 174 246 using G4RootLVList = std::vector<G4Logical << 247 using G4MaterialList = std::vector<G4Mater << 248 using G4MaterialCouplePair = std::pair<G4M << 249 using G4MaterialCoupleMap = std::map<G4Mat << 250 << 251 G4String fName; 175 G4String fName; 252 176 253 G4RootLVList fRootVolumes; 177 G4RootLVList fRootVolumes; 254 G4MaterialList fMaterials; 178 G4MaterialList fMaterials; 255 G4MaterialCoupleMap fMaterialCoupleMap; 179 G4MaterialCoupleMap fMaterialCoupleMap; 256 180 257 G4bool fRegionMod = true; << 181 G4bool fRegionMod; 258 G4ProductionCuts* fCut = nullptr; << 182 G4ProductionCuts* fCut; >> 183 >> 184 G4VUserRegionInformation* fUserInfo; >> 185 G4UserLimits* fUserLimits; >> 186 >> 187 G4FastSimulationManager* fFastSimulationManager; 259 188 260 G4VUserRegionInformation* fUserInfo = null << 189 G4VPhysicalVolume* fWorldPhys; 261 G4UserLimits* fUserLimits = nullptr; << 262 G4FieldManager* fFieldManager = nullptr; << 263 << 264 G4VPhysicalVolume* fWorldPhys = nullptr; << 265 << 266 G4bool fInMassGeometry = false; << 267 G4bool fInParallelGeometry = false; << 268 << 269 G4int instanceID; << 270 // This field is used as instance ID. << 271 G4GEOM_DLL static G4RegionManager subInsta << 272 // This field helps to use the class G4R << 273 }; 190 }; 274 191 275 #include "G4Region.icc" 192 #include "G4Region.icc" 276 193 277 #endif 194 #endif 278 195