G4Region.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // class G4Region
00030 //
00031 // Class description:
00032 //
00033 // Defines a region or a group of regions in the detector geometry
00034 // setup, sharing properties associated to materials or production
00035 // cuts which may affect or bias specific physics processes. 
00036 
00037 // History:
00038 // 18.09.02 G.Cosmo Initial version
00039 // --------------------------------------------------------------------
00040 #ifndef G4REGION_HH
00041 #define G4REGION_HH
00042 
00043 class G4ProductionCuts;
00044 class G4LogicalVolume;
00045 class G4Material;
00046 class G4VUserRegionInformation;
00047 class G4MaterialCutsCouple;
00048 class G4UserLimits;
00049 class G4FieldManager;
00050 class G4FastSimulationManager;
00051 class G4VPhysicalVolume;
00052 class G4UserSteppingAction;
00053 
00054 #include <vector>
00055 #include <map>
00056 #include <algorithm>
00057 
00058 #include "G4Types.hh"
00059 #include "G4String.hh"
00060 
00061 class G4Region
00062 {
00063     typedef std::vector<G4LogicalVolume*> G4RootLVList;
00064     typedef std::vector<G4Material*> G4MaterialList;
00065     typedef std::pair<G4Material*,G4MaterialCutsCouple*> G4MaterialCouplePair;
00066     typedef std::map<G4Material*,G4MaterialCutsCouple*> G4MaterialCoupleMap;
00067 
00068   public:  // with description
00069 
00070     G4Region(const G4String& name);
00071     virtual ~G4Region();
00072 
00073     inline G4bool operator==(const G4Region& rg) const;
00074       // Equality defined by address only.
00075 
00076     void AddRootLogicalVolume(G4LogicalVolume* lv);
00077     void RemoveRootLogicalVolume(G4LogicalVolume* lv, G4bool scan=true);
00078       // Add/remove root logical volumes and set/reset their
00079       // daughters flags as regions. They also recompute the
00080       // materials list for the region.
00081 
00082     inline void SetName(const G4String& name);
00083     inline const G4String& GetName() const;
00084       // Set/get region's name.
00085 
00086     inline void RegionModified(G4bool flag);
00087     inline G4bool IsModified() const;
00088       // Accessors to flag identifying if a region has been modified
00089       // (and still cuts needs to be computed) or not.
00090 
00091     inline void SetProductionCuts(G4ProductionCuts* cut);
00092     inline G4ProductionCuts* GetProductionCuts() const;
00093 
00094     inline std::vector<G4LogicalVolume*>::iterator
00095            GetRootLogicalVolumeIterator();
00096     inline std::vector<G4Material*>::const_iterator
00097            GetMaterialIterator() const;
00098       // Return iterators to lists of root logical volumes and materials.
00099 
00100     inline size_t GetNumberOfMaterials() const;
00101     inline size_t GetNumberOfRootVolumes() const;
00102       // Return the number of elements in the lists of materials and
00103       // root logical volumes.
00104 
00105     void UpdateMaterialList();
00106       // Clears material list and recomputes it looping through
00107       // each root logical volume in the region.
00108 
00109     void ClearMaterialList();
00110       // Clears the material list.
00111 
00112     void ScanVolumeTree(G4LogicalVolume* lv, G4bool region);
00113       // Scans recursively the 'lv' logical volume tree, retrieves
00114       // and places all materials in the list if becoming a region.
00115 
00116     inline void SetUserInformation(G4VUserRegionInformation* ui);
00117     inline G4VUserRegionInformation* GetUserInformation() const;
00118       // Set and Get methods for user information.
00119 
00120     inline void SetUserLimits(G4UserLimits* ul);
00121     inline G4UserLimits* GetUserLimits() const;
00122       // Set and Get methods for userL-limits associated to a region.
00123       // Once user-limits are set, it will propagate to daughter volumes.
00124 
00125     inline void ClearMap();
00126       // Reset G4MaterialCoupleMap
00127 
00128     inline void RegisterMaterialCouplePair(G4Material* mat,
00129                                            G4MaterialCutsCouple* couple);
00130       // Method invoked by G4ProductionCutsTable to register the pair.
00131 
00132     inline G4MaterialCutsCouple* FindCouple(G4Material* mat);
00133       // Find a G4MaterialCutsCouple which corresponds to the material
00134       // in this region.
00135 
00136     inline void SetFastSimulationManager(G4FastSimulationManager* fsm);
00137     inline G4FastSimulationManager* GetFastSimulationManager() const;
00138       // Set and Get methods for G4FastSimulationManager.
00139       // The root logical volume that has the region with G4FastSimulationManager
00140       // becomes an envelope of fast simulation.
00141     
00142     void ClearFastSimulationManager();
00143       // Set G4FastSimulationManager pointer to the one for the parent region
00144       // if it exists. Otherwise set to null.
00145 
00146     inline void SetFieldManager(G4FieldManager* fm);
00147     inline G4FieldManager* GetFieldManager() const;
00148       // Set and Get methods for G4FieldManager.
00149       // The region with assigned field-manager sets the field to the
00150       // geometrical area associated with it; priority is anyhow given
00151       // to local fields eventually set to logical volumes.
00152 
00153     inline G4VPhysicalVolume* GetWorldPhysical() const;
00154       // Get method for the world physical volume which this region
00155       // belongs to. A valid pointer will be assigned by G4RunManagerKernel
00156       // through G4RegionStore when the geometry is to be closed. Thus, this
00157       // pointer may be incorrect at PreInit and Idle state. If the pointer
00158       // is null at the proper state, this particular region does not belong
00159       // to any world (maybe not assigned to any volume, etc.).
00160 
00161     void SetWorld(G4VPhysicalVolume* wp);
00162       // Set the world physical volume if this region belongs to this world.
00163       // If wp is null, reset the pointer.
00164 
00165     G4bool BelongsTo(G4VPhysicalVolume* thePhys) const;
00166       // Returns whether this region belongs to the given physical volume
00167       // (recursively scanned to the bottom of the hierarchy).
00168 
00169     G4Region* GetParentRegion(G4bool& unique) const;
00170       // Returns a region that contains this region. Otherwise null returned.
00171       // Flag 'unique' is true if there is only one parent region containing
00172       // the current region.
00173 
00174     inline void SetRegionalSteppingAction(G4UserSteppingAction* rusa);
00175     inline G4UserSteppingAction* GetRegionalSteppingAction() const;
00176       // Set/Get method of the regional user stepping action
00177 
00178   public:  // without description
00179 
00180     G4Region(__void__&);
00181       // Fake default constructor for usage restricted to direct object
00182       // persistency for clients requiring preallocation of memory for
00183       // persistifiable objects.
00184 
00185     inline void UsedInMassGeometry(G4bool val=true);
00186     inline void UsedInParallelGeometry(G4bool val=true);
00187     inline G4bool IsInMassGeometry() const;
00188     inline G4bool IsInParallelGeometry() const;
00189       // Utility methods to identify if region is part of the main mass
00190       // geometry for tracking or a parallel geometry.
00191 
00192   private:
00193 
00194     G4Region(const G4Region&);
00195     G4Region& operator=(const G4Region&);
00196       // Private copy constructor and assignment operator.
00197 
00198     inline void AddMaterial (G4Material* aMaterial);
00199       // Searchs the specified material in the material table and
00200       // if not present adds it.
00201 
00202   private:
00203 
00204     G4String fName;
00205 
00206     G4RootLVList fRootVolumes;
00207     G4MaterialList fMaterials;
00208     G4MaterialCoupleMap fMaterialCoupleMap;
00209 
00210     G4bool fRegionMod;
00211     G4ProductionCuts* fCut;
00212 
00213     G4VUserRegionInformation* fUserInfo;
00214     G4UserLimits* fUserLimits;
00215     G4FieldManager* fFieldManager;
00216 
00217     G4FastSimulationManager* fFastSimulationManager;
00218 
00219     G4VPhysicalVolume* fWorldPhys;
00220 
00221     G4UserSteppingAction* fRegionalSteppingAction;
00222 
00223     G4bool fInMassGeometry;
00224     G4bool fInParallelGeometry;
00225   
00226 };
00227 
00228 #include "G4Region.icc"
00229 
00230 #endif

Generated on Mon May 27 17:49:43 2013 for Geant4 by  doxygen 1.4.7