Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:12:43

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef DDG4_GEANT4VOLUMEMANAGER_H
0014 #define DDG4_GEANT4VOLUMEMANAGER_H
0015 
0016 // Framework include files
0017 #include <DD4hep/Detector.h>
0018 #include <DD4hep/IDDescriptor.h>
0019 #include <DDG4/Geant4Primitives.h>
0020 
0021 // Geant4 include files
0022 #include <G4VTouchable.hh>
0023 
0024 #include <utility>
0025 #include <vector>
0026 
0027 // Geant4 forward declarations
0028 class G4VPhysicalVolume;
0029 
0030 
0031 /// Namespace for the AIDA detector description toolkit
0032 namespace dd4hep {
0033 
0034   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0035   namespace sim {
0036 
0037     // Forward declarations
0038     class Geant4VolumeManager;
0039     class Geant4GeometryInfo;
0040 
0041     /// The Geant4VolumeManager to facilitate optimized lookups of cell IDs from touchables.
0042     /** @class Geant4VolumeManager Geant4VolumeManager.h DDG4/Geant4VolumeManager.h
0043      *
0044      * @author  M.Frank
0045      * @version 1.0
0046      */
0047     class Geant4VolumeManager : public Handle<Geant4GeometryInfo>   {
0048     protected:
0049       /// Check the validity of the information before accessing it.
0050       bool checkValidity() const;
0051     protected:
0052       friend class Geant4Mapping;
0053       
0054       /// Default constructor
0055       Geant4VolumeManager() = default;
0056       /// Constructor to be used when reading the already parsed object
0057       Geant4VolumeManager(const Handle<Geant4GeometryInfo>& e)
0058         : Handle<Geant4GeometryInfo>(e) {  }
0059       /// Constructor to be used when reading the already parsed object
0060       Geant4VolumeManager(const Geant4VolumeManager& e) = default;
0061       /// Constructor to be used when reading the already parsed object
0062       template <typename Q> Geant4VolumeManager(const Handle<Q>& e)
0063         : Handle<Geant4GeometryInfo>(e) {
0064       }
0065       /// Assignment operator
0066       Geant4VolumeManager& operator=(const Geant4VolumeManager& c) = default;
0067       
0068     public:
0069       static const VolumeID InvalidPath = VolumeID(-1LL);
0070       static const VolumeID Insensitive = VolumeID(-2LL);
0071       static const VolumeID NonExisting = 0ULL;
0072 
0073       /// Initializing constructor. The tree will automatically be built if possible
0074       Geant4VolumeManager(const Detector& description, Geant4GeometryInfo* info);
0075 
0076       /// Helper: Generate placement path from touchable object
0077       std::vector<const G4VPhysicalVolume*>
0078       placementPath(const G4VTouchable* touchable, bool exception = true) const;
0079       /// Access CELLID by Geant4 touchable object
0080       VolumeID volumeID(const G4VTouchable* touchable) const;
0081       /// Access fully decoded volume fields  by placement path
0082       void volumeDescriptor(const std::vector<const G4VPhysicalVolume*>& path,
0083                             std::pair<VolumeID,std::vector<std::pair<const BitFieldElement*, VolumeID> > >& volume_desc) const;
0084       /// Access fully decoded volume fields by Geant4 touchable object
0085       void volumeDescriptor(const G4VTouchable* touchable,
0086                             std::pair<VolumeID,std::vector<std::pair<const BitFieldElement*, VolumeID> > >& volume_desc) const;
0087     };
0088   }    // End namespace sim
0089 }      // End namespace dd4hep
0090 #endif // DDG4_GEANT4VOLUMEMANAGER_H