DD4hep  1.35.0
Detector Description Toolkit for High Energy Physics
Geant4VolumeManager.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DDG4_GEANT4VOLUMEMANAGER_H
14 #define DDG4_GEANT4VOLUMEMANAGER_H
15 
16 // Framework include files
17 #include <DD4hep/Detector.h>
18 #include <DD4hep/IDDescriptor.h>
19 #include <DDG4/Geant4Primitives.h>
20 
21 // Geant4 include files
22 #include <G4VTouchable.hh>
23 
24 #include <utility>
25 #include <vector>
26 
27 // Geant4 forward declarations
28 class G4VPhysicalVolume;
29 
30 
32 namespace dd4hep {
33 
35  namespace sim {
36 
37  // Forward declarations
38  class Geant4VolumeManager;
39  class Geant4GeometryInfo;
40 
42 
47  class Geant4VolumeManager : public Handle<Geant4GeometryInfo> {
48  protected:
50  bool checkValidity() const;
51  protected:
52  friend class Geant4Mapping;
53 
55  Geant4VolumeManager() = default;
58  : Handle<Geant4GeometryInfo>(e) { }
62  template <typename Q> Geant4VolumeManager(const Handle<Q>& e)
64  }
67 
68  public:
69  constexpr static const VolumeID InvalidPath = VolumeID(-1LL);
70  constexpr static const VolumeID Insensitive = VolumeID(-2LL);
71  constexpr static const VolumeID NonExisting = 0ULL;
72  enum debug_flags {
73  PRINT_LEVEL = 1<<0,
74  PRINT_ACTION = 1<<1,
75  PRINT_CHAIN = 1<<2,
76  PRINT_RESULT = 1<<3,
77  PRINT_NODES = 1<<4,
78  PRINT_VOLIDS = 1<<5,
79  PRINT_ENTRIES = 1<<6,
80  };
81 
82  public:
84  Geant4VolumeManager(const Detector& description, Geant4GeometryInfo* info, long debug);
85 
87  std::vector<const G4VPhysicalVolume*>
88  placementPath(const G4VTouchable* touchable, bool exception = true) const;
90  VolumeID volumeID(const G4VTouchable* touchable) const;
92  void volumeDescriptor(const std::vector<const G4VPhysicalVolume*>& path,
93  std::pair<VolumeID,std::vector<std::pair<const BitFieldElement*, VolumeID> > >& volume_desc) const;
95  void volumeDescriptor(const G4VTouchable* touchable,
96  std::pair<VolumeID,std::vector<std::pair<const BitFieldElement*, VolumeID> > >& volume_desc) const;
97  };
98  } // End namespace sim
99 } // End namespace dd4hep
100 #endif // DDG4_GEANT4VOLUMEMANAGER_H
dd4hep::sim::Geant4VolumeManager::Geant4VolumeManager
Geant4VolumeManager()=default
Default constructor.
dd4hep::sim::Geant4VolumeManager::PRINT_VOLIDS
@ PRINT_VOLIDS
Definition: Geant4VolumeManager.h:78
dd4hep::sim::Geant4VolumeManager::PRINT_CHAIN
@ PRINT_CHAIN
Definition: Geant4VolumeManager.h:75
Geant4Primitives.h
dd4hep::sim::Geant4VolumeManager::Insensitive
constexpr static const VolumeID Insensitive
Definition: Geant4VolumeManager.h:70
dd4hep::sim::Geant4VolumeManager::PRINT_ACTION
@ PRINT_ACTION
Definition: Geant4VolumeManager.h:74
dd4hep::sim::Geant4VolumeManager::NonExisting
constexpr static const VolumeID NonExisting
Definition: Geant4VolumeManager.h:71
Detector.h
dd4hep::info
std::size_t info(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:65
dd4hep::exception
void exception(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:69
dd4hep::sim::Geant4VolumeManager::InvalidPath
constexpr static const VolumeID InvalidPath
Definition: Geant4VolumeManager.h:69
dd4hep::debug
std::size_t debug(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:64
dd4hep::sim::Geant4VolumeManager::PRINT_NODES
@ PRINT_NODES
Definition: Geant4VolumeManager.h:77
dd4hep::Handle
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:82
dd4hep::sim::Geant4VolumeManager::Geant4VolumeManager
Geant4VolumeManager(const Geant4VolumeManager &e)=default
Constructor to be used when reading the already parsed object.
dd4hep::sim::Geant4VolumeManager::PRINT_ENTRIES
@ PRINT_ENTRIES
Definition: Geant4VolumeManager.h:79
dd4hep::sim::Geant4VolumeManager::PRINT_RESULT
@ PRINT_RESULT
Definition: Geant4VolumeManager.h:76
dd4hep::sim::Geant4VolumeManager::volumeID
VolumeID volumeID(const G4VTouchable *touchable) const
Access CELLID by Geant4 touchable object.
Definition: Geant4VolumeManager.cpp:383
dd4hep::sim::Geant4VolumeManager::operator=
Geant4VolumeManager & operator=(const Geant4VolumeManager &c)=default
Assignment operator.
dd4hep::sim::Geant4Mapping
Geometry mapping from dd4hep to Geant 4.
Definition: Geant4Mapping.h:35
dd4hep::sim::Geant4VolumeManager::PRINT_LEVEL
@ PRINT_LEVEL
Definition: Geant4VolumeManager.h:73
dd4hep::sim::Geant4VolumeManager
The Geant4VolumeManager to facilitate optimized lookups of cell IDs from touchables.
Definition: Geant4VolumeManager.h:47
dd4hep::sim::Geant4VolumeManager::placementPath
std::vector< const G4VPhysicalVolume * > placementPath(const G4VTouchable *touchable, bool exception=true) const
Helper: Generate placement path from touchable object.
Definition: Geant4VolumeManager.cpp:353
dd4hep::sim::Geant4VolumeManager::debug_flags
debug_flags
Definition: Geant4VolumeManager.h:72
dd4hep::sim::Geant4VolumeManager::Geant4VolumeManager
Geant4VolumeManager(const Handle< Q > &e)
Constructor to be used when reading the already parsed object.
Definition: Geant4VolumeManager.h:62
VolumeID
dd4hep::DDSegmentation::VolumeID VolumeID
Definition: SegmentationDictionary.h:50
IDDescriptor.h
dd4hep::sim::Geant4GeometryInfo
Concreate class holding the relation information between geant4 objects and dd4hep objects.
Definition: Geant4GeometryInfo.h:91
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4VolumeManager::Geant4VolumeManager
Geant4VolumeManager(const Handle< Geant4GeometryInfo > &e)
Constructor to be used when reading the already parsed object.
Definition: Geant4VolumeManager.h:57
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::sim::Geant4VolumeManager::volumeDescriptor
void volumeDescriptor(const std::vector< const G4VPhysicalVolume * > &path, std::pair< VolumeID, std::vector< std::pair< const BitFieldElement *, VolumeID > > > &volume_desc) const
Access fully decoded volume fields by placement path.
dd4hep::sim::Geant4VolumeManager::volumeDescriptor
void volumeDescriptor(const G4VTouchable *touchable, std::pair< VolumeID, std::vector< std::pair< const BitFieldElement *, VolumeID > > > &volume_desc) const
Access fully decoded volume fields by Geant4 touchable object.
dd4hep::sim::Geant4VolumeManager::checkValidity
bool checkValidity() const
Check the validity of the information before accessing it.
Definition: Geant4VolumeManager.cpp:359