DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4VolumeManager.h
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 #ifndef DD4HEP_DDG4_GEANT4VOLUMEMANAGER_H
15 #define DD4HEP_DDG4_GEANT4VOLUMEMANAGER_H
16 
17 // Framework include files
18 #include "DD4hep/LCDD.h"
19 #include "DD4hep/IDDescriptor.h"
20 #include "DDG4/Geant4Primitives.h"
22 
23 // Geant4 forward declarations
24 class G4VTouchable;
25 
27 namespace DD4hep {
28 
30  namespace Simulation {
31 
32  // Forward declarations
33  class Geant4VolumeManager;
34  class Geant4GeometryInfo;
35 
37 
42  class Geant4VolumeManager: public Geometry::Handle<Geant4GeometryInfo> {
43  public:
44  // Forward declarations
49  typedef std::pair<VolumeID, VolIDFields> VolIDDescriptor;
52 
53  protected:
55  mutable bool m_isValid;
56 
58  bool checkValidity() const;
59 
60  public:
61  static const VolumeID InvalidPath = VolumeID(-1LL);
62  static const VolumeID Insensitive = VolumeID(-2LL);
63  static const VolumeID NonExisting = 0ULL;
64 
69  : Base(), m_isValid(false) {
70  }
73  : Base(e), m_isValid(false) {
74  }
77  : Base(e), m_isValid(false) {
78  }
80  template <typename Q> Geant4VolumeManager(const Geometry::Handle<Q>& e)
81  : Base(e), m_isValid(false) {
82  }
85  if ( this != &c ) {
86  m_element = c.m_element;
87  m_isValid = c.m_isValid;
88  }
89  return *this;
90  }
91 
93  PlacementPath placementPath(const G4VTouchable* touchable, bool exception = true) const;
95  VolumeID volumeID(const PlacementPath& path) const;
97  VolumeID volumeID(const G4VTouchable* touchable) const;
99  void volumeDescriptor(const PlacementPath& path, VolIDDescriptor& volume_desc) const;
101  void volumeDescriptor(const G4VTouchable* touchable, VolIDDescriptor& volume_desc) const;
102  };
103 
104  } // End namespace Simulation
105 } // End namespace DD4hep
106 #endif // DD4HEP_DDG4_GEANT4VOLUMEMANAGER_H
bool checkValidity() const
Check the validity of the information before accessing it.
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:135
Geant4VolumeManager(const Geometry::Handle< Q > &e)
Constructor to be used when reading the already parsed object.
The Geant4VolumeManager to facilitate optimized lookups of cell IDs from touchables.
DetectorTools::PlacementPath PlacementPath
VolumeID volumeID(const PlacementPath &path) const
Access CELLID by placement path.
bool m_isValid
Optimization flag to shortcut object checks.
std::vector< const G4VPhysicalVolume * > Geant4PlacementPath
return e
Definition: Volumes.cpp:297
void volumeDescriptor(const PlacementPath &path, VolIDDescriptor &volume_desc) const
Accessfully decoded volume fields by placement path.
Geant4GeometryMaps::Geant4PlacementPath PlacementPath
Geant4VolumeManager(const Geant4VolumeManager &e)
Constructor to be used when reading the already parsed object.
Geant4VolumeManager & operator=(const Geant4VolumeManager &c)
Assignment operator.
std::pair< VolumeID, VolIDFields > VolIDDescriptor
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:87
long long int VolumeID
Definition: Primitives.h:35
Geant4VolumeManager(const Base &e)
Constructor to be used when reading the already parsed object.
The main interface to the DD4hep detector description package.
Definition: LCDD.h:82
Concreate class holding the relation information between geant4 objects and dd4hep objects...
PlacementPath placementPath(const G4VTouchable *touchable, bool exception=true) const
Helper: Generate placement path from touchable object.
T * m_element
Single and only data member: Reference to the actual element.
Definition: Handle.h:96
std::vector< VolIDField > VolIDFields
Definition: IDDescriptor.h:47
Class implementing the ID encoding of detector response.
Definition: IDDescriptor.h:40
Geometry::Handle< Geant4GeometryInfo > Base