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5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/management/include/G4Region.hh (Version 11.3.0) and /geometry/management/include/G4Region.hh (Version 10.3)


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