G4LogicalVolume.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 // 
00030 // class G4LogicalVolume
00031 //
00032 // Class description:
00033 //
00034 // Represents a leaf node or unpositioned subtree in the geometry hierarchy.
00035 // Logical volumes are named, and may have daughters ascribed to them.
00036 // They are responsible for retrieval of the physical and tracking attributes
00037 // of the physical volume that it represents: solid, material, magnetic field,
00038 // and optionally, user limits, sensitive detectors, regions, biasing weights.
00039 //
00040 // Get and Set functionality is provided for all attributes, but note that
00041 // most set functions should not be used  when the geometry is `closed'.
00042 // As a  further development, `Guard' checks can be added to ensure
00043 // only legal operations at tracking time.
00044 //
00045 // On construction, solid, material and name must be specified.
00046 //
00047 // Daughters are ascribed and managed by means of a simple
00048 // GetNoDaughters,Get/SetDaughter(n),AddDaughter interface.
00049 //
00050 // Smart voxels as used for tracking optimisation. They're also an attribute.
00051 //
00052 // Logical volumes self register to the logical volume Store on construction,
00053 // and deregister on destruction.
00054 //
00055 // NOTE: This class is currently *NOT* subclassed, since not meant to
00056 //       act as a base class. Therefore, the destructor is NOT virtual.
00057 //
00058 // Data members:
00059 //
00060 //    std::vector<G4VPhysicalVolume*> fDaughters
00061 //    - Vector of daughters. Given initial size of 0.
00062 //    G4FieldManager* fFieldManager
00063 //    - Pointer (possibly 0) to (magnetic or other) field manager object.
00064 //    G4Material* fMaterial
00065 //    - Pointer to material at this node.
00066 //    G4String fName
00067 //    - Name of logical volume.
00068 //    G4VSensitiveDetector *fSensitiveDetector
00069 //    - Pointer (possibly 0) to `Hit' object.
00070 //    G4VSolid* fSolid
00071 //    - Pointer to solid.
00072 //    G4UserLimits* fUserLimits
00073 //    - Pointer (possibly 0) to user Step limit object for this node.
00074 //    G4SmartVoxelHeader* fVoxel
00075 //    - Pointer (possibly 0) to optimisation info objects.
00076 //    G4bool fOptimise
00077 //    - Flag to identify if optimisation should be applied or not.
00078 //    G4bool fRootRegion
00079 //    - Flag to identify if the logical volume is a root region.
00080 //    G4double fSmartless
00081 //    - Quality for optimisation, average number of voxels to be spent
00082 //      per content.
00083 //    const G4VisAttributes* fVisAttributes
00084 //    - Pointer (possibly 0) to visualization attributes.
00085 //    G4Region* fRegion
00086 //    - Pointer to the cuts region (if any)
00087 //    G4MaterialCutsCouple* fCutsCouple
00088 //    - Pointer (possibly 0) to associated production cuts.
00089 //    G4double fBiasWeight
00090 //    - Weight used in the event biasing technique.
00091 //
00092 // Following data members has been moved to G4Region - M.Asai (Aug/18/2005)
00093 //    G4FastSimulationManager* fFastSimulationManager
00094 //    - Pointer (possibly 0) to G4FastSimulationManager object.
00095 //    G4bool fIsEnvelope
00096 //    - Flags if the Logical Volume is an envelope for a FastSimulationManager.
00097 
00098 // History:
00099 // 12.11.04 G.Cosmo: Added GetMass() method for computing mass of the tree
00100 // 24.09.02 G.Cosmo: Added flags and accessors for region cuts handling
00101 // 17.05.02 G.Cosmo: Added IsToOptimise() method and related flag
00102 // 18.04.01 G.Cosmo: Migrated to STL vector
00103 // 12.02.99 S.Giani: Added user defined optimisation quality
00104 // 09.11.98 J.Apostolakis:  Changed G4MagneticField to G4FieldManager
00105 // 09.11.98 M.Verderi, J.Apostolakis: Added BiasWeight member and accessors
00106 // 10.20.97 P.M.DeFreitas: Added pointer to a FastSimulation
00107 //          J.Apostolakis: & flag to indicate if it is an Envelope for it
00108 // 19.11.96 J.Allison: Replaced G4Visible with explicit const G4VisAttributes*
00109 // 19.08.96 P.Kent: Split -> hh/icc/cc files; G4VSensitiveDetector change
00110 // 11.07.95 P.Kent: Initial version.
00111 // ------------------------------------------------------------------------
00112 #ifndef G4LOGICALVOLUME_HH
00113 #define G4LOGICALVOLUME_HH
00114 
00115 #include "G4Types.hh"
00116 #include "G4Region.hh"           // Required by inline methods
00117 #include "G4VPhysicalVolume.hh"  // Need operator == for vector fdaughters
00118 #include <vector>
00119 #include <assert.h>
00120 
00121 // Forward declarations
00122 //
00123 class G4FieldManager;
00124 class G4Material;
00125 class G4VSensitiveDetector;
00126 class G4VSolid;
00127 class G4UserLimits;
00128 class G4SmartVoxelHeader;
00129 class G4VisAttributes;
00130 class G4FastSimulationManager;
00131 class G4MaterialCutsCouple;
00132 
00133 class G4LogicalVolume
00134 {
00135   typedef std::vector<G4VPhysicalVolume*> G4PhysicalVolumeList;
00136 
00137   public:  // with description
00138   
00139     G4LogicalVolume(G4VSolid* pSolid,
00140                     G4Material* pMaterial,
00141               const G4String& name,
00142                     G4FieldManager* pFieldMgr=0,
00143                     G4VSensitiveDetector* pSDetector=0,
00144                     G4UserLimits* pULimits=0,
00145                     G4bool optimise=true);
00146       // Constructor. The solid and material pointer must be non null.
00147       // The parameters for field, detector and user limits are optional.
00148       // The volume also enters itself into the logical volume Store.
00149       // Optimisation of the geometry (voxelisation) for the volume
00150       // hierarchy is applied by default. For parameterised volumes in
00151       // the hierarchy, optimisation is -always- applied.
00152 
00153     ~G4LogicalVolume();
00154       // Destructor. Removes the logical volume from the logical volume Store.
00155       // NOT virtual, since not meant to act as base class.
00156 
00157     inline G4String GetName() const;
00158     inline void SetName(const G4String& pName);
00159       // Returns and sets the name of the logical volume.
00160 
00161     inline G4int GetNoDaughters() const;
00162       // Returns the number of daughters (0 to n).
00163     inline G4VPhysicalVolume* GetDaughter(const G4int i) const;
00164       // Returns the ith daughter. Note numbering starts from 0,
00165       // and no bounds checking is performed.
00166     inline void AddDaughter(G4VPhysicalVolume* p);
00167       // Adds the volume p as a daughter of the current logical volume.
00168     inline G4bool IsDaughter(const G4VPhysicalVolume* p) const;
00169       // Returns true if the volume p is a daughter of the current
00170       // logical volume.
00171     G4bool IsAncestor(const G4VPhysicalVolume* p) const;
00172       // Returns true if the volume p is part of the hierarchy of
00173       // volumes established by the current logical volume. Scans
00174       // recursively the volume tree.
00175     inline void RemoveDaughter(const G4VPhysicalVolume* p);
00176       // Removes the volume p from the List of daughter of the current
00177       // logical volume.
00178     inline void ClearDaughters();
00179       // Clears the list of daughters. Used by the phys-volume store when
00180       // the geometry tree is cleared, since modified at run-time.
00181     G4int TotalVolumeEntities() const;
00182       // Returns the total number of physical volumes (replicated or placed)
00183       // in the tree represented by the current logical volume.
00184 
00185 
00186     inline G4VSolid* GetSolid() const;
00187     inline void SetSolid(G4VSolid *pSolid);
00188       // Gets and sets the current solid.
00189 
00190     inline G4Material* GetMaterial() const;
00191     inline void SetMaterial(G4Material *pMaterial);
00192       // Gets and sets the current material.
00193     inline void UpdateMaterial(G4Material *pMaterial);
00194       // Sets material and corresponding MaterialCutsCouple.
00195       // This method is invoked by G4Navigator while it is navigating through 
00196       // material parameterization.
00197     G4double GetMass(G4bool forced=false, G4bool propagate=true,
00198                      G4Material* parMaterial=0);
00199       // Returns the mass of the logical volume tree computed from the
00200       // estimated geometrical volume of each solid and material associated
00201       // to the logical volume and (by default) to its daughters.
00202       // NOTE: the computation may require a considerable amount of time,
00203       //       depending from the complexity of the geometry tree.
00204       //       The returned value is cached and can be used for successive
00205       //       calls (default), unless recomputation is forced by providing
00206       //       'true' for the boolean argument in input. Computation should
00207       //       be forced if the geometry setup has changed after the previous
00208       //       call. By setting the 'propagate' boolean flag to 'false' the 
00209       //       method returns the mass of the present logical volume only 
00210       //       (subtracted for the volume occupied by the daughter volumes).
00211       //       An optional argument to specify a material is also provided.
00212 
00213     inline G4FieldManager* GetFieldManager() const;
00214       // Gets current FieldManager.
00215     void SetFieldManager(G4FieldManager *pFieldMgr, G4bool forceToAllDaughters); 
00216       // Sets FieldManager and propagates it:
00217       //  i) only to daughters with G4FieldManager = 0
00218       //     if forceToAllDaughters=false
00219       // ii) to all daughters
00220       //     if forceToAllDaughters=true
00221 
00222     inline G4VSensitiveDetector* GetSensitiveDetector() const;
00223       // Gets current SensitiveDetector.
00224     inline void SetSensitiveDetector(G4VSensitiveDetector *pSDetector);
00225       // Sets SensitiveDetector (can be 0).
00226 
00227     inline G4UserLimits* GetUserLimits() const;
00228     inline void SetUserLimits(G4UserLimits *pULimits);
00229       // Gets and sets current UserLimits.
00230 
00231     inline G4SmartVoxelHeader* GetVoxelHeader() const;
00232     inline void SetVoxelHeader(G4SmartVoxelHeader *pVoxel);
00233       // Gets and sets current VoxelHeader.
00234     
00235     inline G4double GetSmartless() const;
00236     inline void SetSmartless(G4double s);
00237       // Gets and sets user defined optimisation quality.
00238 
00239     inline G4bool IsToOptimise() const;
00240       // Replies if geometry optimisation (voxelisation) is to be
00241       // applied for this volume hierarchy.
00242     inline void SetOptimisation(G4bool optim);
00243       // Specifies if to apply or not geometry optimisation to this
00244       // volume hierarchy. Note that for parameterised volumes in the
00245       // hierarchy, optimisation is always applied. 
00246 
00247     inline G4bool IsRootRegion() const;
00248       // Replies if the logical volume represents a root region or not.
00249     inline void SetRegionRootFlag(G4bool rreg);
00250       // Sets/unsets the volume as a root region for cuts.
00251     inline G4bool IsRegion() const;
00252       // Replies if the logical volume is part of a cuts region or not.
00253     inline void SetRegion(G4Region* reg);
00254       // Sets/unsets the volume as cuts region.
00255     inline G4Region* GetRegion() const;
00256       // Return the region to which the volume belongs, if any.
00257     inline void PropagateRegion();
00258       // Propagates region pointer to daughters.
00259 
00260     inline const G4MaterialCutsCouple* GetMaterialCutsCouple() const;
00261     inline void SetMaterialCutsCouple(G4MaterialCutsCouple* cuts);
00262       // Accessors for production cuts.
00263 
00264     G4bool operator == (const G4LogicalVolume& lv) const;
00265       // Equality defined by address only.
00266       // Returns true if objects are at same address, else false.
00267 
00268     inline const G4VisAttributes* GetVisAttributes () const;
00269     inline void  SetVisAttributes (const G4VisAttributes* pVA);
00270     void  SetVisAttributes (const G4VisAttributes& VA);
00271       // Gets and sets visualization attributes. A copy of 'VA' on the heap
00272       // will be made in the case the call with a const reference is used.
00273 
00274     inline G4FastSimulationManager* GetFastSimulationManager () const;
00275       // Gets current FastSimulationManager pointer if exists, otherwise null.
00276 
00277     inline void SetBiasWeight (G4double w);
00278     inline G4double GetBiasWeight() const;
00279       // Sets and gets bias weight.
00280 
00281   public:  // without description
00282 
00283     G4LogicalVolume(__void__&);
00284       // Fake default constructor for usage restricted to direct object
00285       // persistency for clients requiring preallocation of memory for
00286       // persistifiable objects.
00287 
00288     inline void Lock();
00289       // Set lock identifier for final deletion of entity.
00290 
00291   private:
00292 
00293     G4LogicalVolume(const G4LogicalVolume&);
00294     G4LogicalVolume& operator=(const G4LogicalVolume&);
00295       // Private copy-constructor and assignment operator.
00296 
00297   private:
00298 
00299     // Data members:   
00300 
00301     G4PhysicalVolumeList fDaughters;
00302       // Vector of daughters. Given initial size of 0.
00303     G4FieldManager* fFieldManager;
00304       // Pointer (possibly 0) to (magnetic or other) field manager object.
00305     G4Material* fMaterial;
00306       // Pointer to material at this node.
00307     G4String fName;
00308       // Name of logical volume.
00309     G4VSensitiveDetector* fSensitiveDetector;
00310       // Pointer (possibly 0) to `Hit' object.
00311     G4VSolid* fSolid;
00312       // Pointer to solid.
00313     G4UserLimits* fUserLimits;
00314       // Pointer (possibly 0) to user Step limit object for this node.
00315     G4SmartVoxelHeader* fVoxel;
00316       // Pointer (possibly 0) to optimisation info objects.
00317     G4bool fOptimise;
00318       // Flag to identify if optimisation should be applied or not.
00319     G4bool fRootRegion;
00320       // Flag to identify if the logical volume is a root region.
00321     G4bool fLock;
00322       // Flag to identify if entity is locked for final deletion.
00323     G4double fSmartless;
00324       // Quality for optimisation, average number of voxels to be spent
00325       // per content.
00326     G4double fMass;
00327       // Mass of the logical volume tree.
00328     const G4VisAttributes* fVisAttributes;
00329       // Pointer (possibly 0) to visualization attributes.
00330     G4Region* fRegion;
00331       // Pointer to the cuts region (if any)
00332     G4MaterialCutsCouple* fCutsCouple;
00333       // Pointer (possibly 0) to associated production cuts.
00334     G4double fBiasWeight;
00335       // Weight used in the event biasing technique.
00336 };
00337 
00338 #include "G4LogicalVolume.icc"
00339 
00340 #endif

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