| 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 | //
|
|---|
| 27 | // $Id: G4Region.hh,v 1.21 2009/11/27 16:34:37 gcosmo Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-03 $
|
|---|
| 29 | //
|
|---|
| 30 | // class G4Region
|
|---|
| 31 | //
|
|---|
| 32 | // Class description:
|
|---|
| 33 | //
|
|---|
| 34 | // Defines a region or a group of regions in the detector geometry
|
|---|
| 35 | // setup, sharing properties associated to materials or production
|
|---|
| 36 | // cuts which may affect or bias specific physics processes.
|
|---|
| 37 |
|
|---|
| 38 | // History:
|
|---|
| 39 | // 18.09.02 G.Cosmo Initial version
|
|---|
| 40 | // --------------------------------------------------------------------
|
|---|
| 41 | #ifndef G4REGION_HH
|
|---|
| 42 | #define G4REGION_HH
|
|---|
| 43 |
|
|---|
| 44 | class G4ProductionCuts;
|
|---|
| 45 | class G4LogicalVolume;
|
|---|
| 46 | class G4Material;
|
|---|
| 47 | class G4VUserRegionInformation;
|
|---|
| 48 | class G4MaterialCutsCouple;
|
|---|
| 49 | class G4UserLimits;
|
|---|
| 50 | class G4FieldManager;
|
|---|
| 51 | class G4FastSimulationManager;
|
|---|
| 52 | class G4VPhysicalVolume;
|
|---|
| 53 | class G4UserSteppingAction;
|
|---|
| 54 |
|
|---|
| 55 | #include <vector>
|
|---|
| 56 | #include <map>
|
|---|
| 57 | #include <algorithm>
|
|---|
| 58 |
|
|---|
| 59 | #include "G4Types.hh"
|
|---|
| 60 | #include "G4String.hh"
|
|---|
| 61 |
|
|---|
| 62 | class G4Region
|
|---|
| 63 | {
|
|---|
| 64 | typedef std::vector<G4LogicalVolume*> G4RootLVList;
|
|---|
| 65 | typedef std::vector<G4Material*> G4MaterialList;
|
|---|
| 66 | typedef std::pair<G4Material*,G4MaterialCutsCouple*> G4MaterialCouplePair;
|
|---|
| 67 | typedef std::map<G4Material*,G4MaterialCutsCouple*> G4MaterialCoupleMap;
|
|---|
| 68 |
|
|---|
| 69 | public: // with description
|
|---|
| 70 |
|
|---|
| 71 | G4Region(const G4String& name);
|
|---|
| 72 | virtual ~G4Region();
|
|---|
| 73 |
|
|---|
| 74 | inline G4bool operator==(const G4Region& rg) const;
|
|---|
| 75 | // Equality defined by address only.
|
|---|
| 76 |
|
|---|
| 77 | void AddRootLogicalVolume(G4LogicalVolume* lv);
|
|---|
| 78 | void RemoveRootLogicalVolume(G4LogicalVolume* lv, G4bool scan=true);
|
|---|
| 79 | // Add/remove root logical volumes and set/reset their
|
|---|
| 80 | // daughters flags as regions. They also recompute the
|
|---|
| 81 | // materials list for the region.
|
|---|
| 82 |
|
|---|
| 83 | inline void SetName(const G4String& name);
|
|---|
| 84 | inline const G4String& GetName() const;
|
|---|
| 85 | // Set/get region's name.
|
|---|
| 86 |
|
|---|
| 87 | inline void RegionModified(G4bool flag);
|
|---|
| 88 | inline G4bool IsModified() const;
|
|---|
| 89 | // Accessors to flag identifying if a region has been modified
|
|---|
| 90 | // (and still cuts needs to be computed) or not.
|
|---|
| 91 |
|
|---|
| 92 | inline void SetProductionCuts(G4ProductionCuts* cut);
|
|---|
| 93 | inline G4ProductionCuts* GetProductionCuts() const;
|
|---|
| 94 |
|
|---|
| 95 | inline std::vector<G4LogicalVolume*>::iterator
|
|---|
| 96 | GetRootLogicalVolumeIterator();
|
|---|
| 97 | inline std::vector<G4Material*>::const_iterator
|
|---|
| 98 | GetMaterialIterator() const;
|
|---|
| 99 | // Return iterators to lists of root logical volumes and materials.
|
|---|
| 100 |
|
|---|
| 101 | inline size_t GetNumberOfMaterials() const;
|
|---|
| 102 | inline size_t GetNumberOfRootVolumes() const;
|
|---|
| 103 | // Return the number of elements in the lists of materials and
|
|---|
| 104 | // root logical volumes.
|
|---|
| 105 |
|
|---|
| 106 | void UpdateMaterialList();
|
|---|
| 107 | // Clears material list and recomputes it looping through
|
|---|
| 108 | // each root logical volume in the region.
|
|---|
| 109 |
|
|---|
| 110 | void ClearMaterialList();
|
|---|
| 111 | // Clears the material list.
|
|---|
| 112 |
|
|---|
| 113 | void ScanVolumeTree(G4LogicalVolume* lv, G4bool region);
|
|---|
| 114 | // Scans recursively the 'lv' logical volume tree, retrieves
|
|---|
| 115 | // and places all materials in the list if becoming a region.
|
|---|
| 116 |
|
|---|
| 117 | inline void SetUserInformation(G4VUserRegionInformation* ui);
|
|---|
| 118 | inline G4VUserRegionInformation* GetUserInformation() const;
|
|---|
| 119 | // Set and Get methods for user information.
|
|---|
| 120 |
|
|---|
| 121 | inline void SetUserLimits(G4UserLimits* ul);
|
|---|
| 122 | inline G4UserLimits* GetUserLimits() const;
|
|---|
| 123 | // Set and Get methods for userL-limits associated to a region.
|
|---|
| 124 | // Once user-limits are set, it will propagate to daughter volumes.
|
|---|
| 125 |
|
|---|
| 126 | inline void ClearMap();
|
|---|
| 127 | // Reset G4MaterialCoupleMap
|
|---|
| 128 |
|
|---|
| 129 | inline void RegisterMaterialCouplePair(G4Material* mat,
|
|---|
| 130 | G4MaterialCutsCouple* couple);
|
|---|
| 131 | // Method invoked by G4ProductionCutsTable to register the pair.
|
|---|
| 132 |
|
|---|
| 133 | inline G4MaterialCutsCouple* FindCouple(G4Material* mat);
|
|---|
| 134 | // Find a G4MaterialCutsCouple which corresponds to the material
|
|---|
| 135 | // in this region.
|
|---|
| 136 |
|
|---|
| 137 | inline void SetFastSimulationManager(G4FastSimulationManager* fsm);
|
|---|
| 138 | inline G4FastSimulationManager* GetFastSimulationManager() const;
|
|---|
| 139 | // Set and Get methods for G4FastSimulationManager.
|
|---|
| 140 | // The root logical volume that has the region with G4FastSimulationManager
|
|---|
| 141 | // becomes an envelope of fast simulation.
|
|---|
| 142 |
|
|---|
| 143 | void ClearFastSimulationManager();
|
|---|
| 144 | // Set G4FastSimulationManager pointer to the one for the parent region
|
|---|
| 145 | // if it exists. Otherwise set to null.
|
|---|
| 146 |
|
|---|
| 147 | inline void SetFieldManager(G4FieldManager* fm);
|
|---|
| 148 | inline G4FieldManager* GetFieldManager() const;
|
|---|
| 149 | // Set and Get methods for G4FieldManager.
|
|---|
| 150 | // The region with assigned field-manager sets the field to the
|
|---|
| 151 | // geometrical area associated with it; priority is anyhow given
|
|---|
| 152 | // to local fields eventually set to logical volumes.
|
|---|
| 153 |
|
|---|
| 154 | inline G4VPhysicalVolume* GetWorldPhysical() const;
|
|---|
| 155 | // Get method for the world physical volume which this region
|
|---|
| 156 | // belongs to. A valid pointer will be assigned by G4RunManagerKernel
|
|---|
| 157 | // through G4RegionStore when the geometry is to be closed. Thus, this
|
|---|
| 158 | // pointer may be incorrect at PreInit and Idle state. If the pointer
|
|---|
| 159 | // is null at the proper state, this particular region does not belong
|
|---|
| 160 | // to any world (maybe not assigned to any volume, etc.).
|
|---|
| 161 |
|
|---|
| 162 | void SetWorld(G4VPhysicalVolume* wp);
|
|---|
| 163 | // Set the world physical volume if this region belongs to this world.
|
|---|
| 164 | // If wp is null, reset the pointer.
|
|---|
| 165 |
|
|---|
| 166 | G4bool BelongsTo(G4VPhysicalVolume* thePhys) const;
|
|---|
| 167 | // Returns whether this region belongs to the given physical volume
|
|---|
| 168 | // (recursively scanned to the bottom of the hierarchy).
|
|---|
| 169 |
|
|---|
| 170 | G4Region* GetParentRegion(G4bool& unique) const;
|
|---|
| 171 | // Returns a region that contains this region. Otherwise null returned.
|
|---|
| 172 | // Flag 'unique' is true if there is only one parent region containing
|
|---|
| 173 | // the current region.
|
|---|
| 174 |
|
|---|
| 175 | inline void SetRegionalSteppingAction(G4UserSteppingAction* rusa);
|
|---|
| 176 | inline G4UserSteppingAction* GetRegionalSteppingAction() const;
|
|---|
| 177 | // Set/Get method of the regional user stepping action
|
|---|
| 178 |
|
|---|
| 179 | public: // without description
|
|---|
| 180 |
|
|---|
| 181 | G4Region(__void__&);
|
|---|
| 182 | // Fake default constructor for usage restricted to direct object
|
|---|
| 183 | // persistency for clients requiring preallocation of memory for
|
|---|
| 184 | // persistifiable objects.
|
|---|
| 185 |
|
|---|
| 186 | private:
|
|---|
| 187 |
|
|---|
| 188 | G4Region(const G4Region&);
|
|---|
| 189 | G4Region& operator=(const G4Region&);
|
|---|
| 190 | // Private copy constructor and assignment operator.
|
|---|
| 191 |
|
|---|
| 192 | inline void AddMaterial (G4Material* aMaterial);
|
|---|
| 193 | // Searchs the specified material in the material table and
|
|---|
| 194 | // if not present adds it.
|
|---|
| 195 |
|
|---|
| 196 | private:
|
|---|
| 197 |
|
|---|
| 198 | G4String fName;
|
|---|
| 199 |
|
|---|
| 200 | G4RootLVList fRootVolumes;
|
|---|
| 201 | G4MaterialList fMaterials;
|
|---|
| 202 | G4MaterialCoupleMap fMaterialCoupleMap;
|
|---|
| 203 |
|
|---|
| 204 | G4bool fRegionMod;
|
|---|
| 205 | G4ProductionCuts* fCut;
|
|---|
| 206 |
|
|---|
| 207 | G4VUserRegionInformation* fUserInfo;
|
|---|
| 208 | G4UserLimits* fUserLimits;
|
|---|
| 209 | G4FieldManager* fFieldManager;
|
|---|
| 210 |
|
|---|
| 211 | G4FastSimulationManager* fFastSimulationManager;
|
|---|
| 212 |
|
|---|
| 213 | G4VPhysicalVolume* fWorldPhys;
|
|---|
| 214 |
|
|---|
| 215 | G4UserSteppingAction* fRegionalSteppingAction;
|
|---|
| 216 | };
|
|---|
| 217 |
|
|---|
| 218 | #include "G4Region.icc"
|
|---|
| 219 |
|
|---|
| 220 | #endif
|
|---|