DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
VolumeManager.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 
14 #ifndef DD4HEP_VOLUMEMANAGER_H
15 #define DD4HEP_VOLUMEMANAGER_H
16 
17 // Framework include files
18 #include <DD4hep/Volumes.h>
19 #include <DD4hep/DetElement.h>
20 #include <DD4hep/NamedObject.h>
21 #include <DD4hep/IDDescriptor.h>
22 #include <DD4hep/ConditionsMap.h>
23 
24 // ROOT include files
25 #include <TGeoMatrix.h>
26 
28 namespace dd4hep {
29 
31  namespace detail {
32  class VolumeManagerObject;
33  }
34 
36 
51  public:
57  VolumeID mask = ~0x0ULL;
59  long flag = 0;
60  public:
62  VolumeManagerContext() = default;
72  virtual ~VolumeManagerContext();
78  const TGeoHMatrix& toElement() const;
80  Position localToElement(const double local[3]) const;
82  Position localToElement(const Position& local) const;
84  Position localToWorld(const double local[3]) const;
86  Position localToWorld(const Position& local) const;
87 
89  Position worldToElement(const Position& world) const;
91  Position worldToElement(const double world[3]) const;
93  void worldToElement(const double world[3], double element[3]) const;
94 
96  Position worldToLocal(const Position& world) const;
98  Position worldToLocal(const double world[3]) const;
100  void worldToLocal(const double world[3], double local[3]) const;
101  };
102 
104 
135  class VolumeManager: public Handle<detail::VolumeManagerObject> {
136  public:
137  // Creation flags
139  NONE = 0,
140  TREE = 1 << 1, // Build 1 level DetElement hierarchy while populating
141  ONE = 1 << 2, // Populate all daughter volumes into one big lookup-container
142  // This flag may be in parallel with 'TREE'
143  LAST
144  };
145 
146  protected:
148  Object& _data() const {
149  return *(Object*) ptr();
150  }
151 
152  public:
154  VolumeManager() = default;
155 
157  VolumeManager(const VolumeManager& e) = default;
158 #ifndef __CINT__
161  : Handle<detail::VolumeManagerObject>(e) {
162  }
163 #endif
164  template <typename Q>
166  VolumeManager(const Handle<Q>& e) : Handle<detail::VolumeManagerObject>(e) { }
171  VolumeManager(const Detector& description,
172  const std::string& name,
173  DetElement world = DetElement(),
174  Readout ro = Readout(),
175  int flags = NONE);
178 
180  static VolumeManager getVolumeManager(const Detector& description);
181 
183  VolumeManager& operator=(const VolumeManager& m) = default;
184 
189 
191  DetElement detector() const;
193  IDDescriptor idSpec() const;
194 
196  bool adoptPlacement(VolumeManagerContext* context);
198  bool adoptPlacement(VolumeID volume_id, VolumeManagerContext* context);
199 
203  VolumeManagerContext* lookupContext(VolumeID volume_id) const;
210  DetElement lookupDetector(VolumeID volume_id) const;
212  DetElement lookupDetElement(VolumeID volume_id) const;
214  const TGeoMatrix& worldTransformation(const ConditionsMap& map,
215  VolumeID volume_id) const;
216  };
217 
219  std::ostream& operator<<(std::ostream& os, const VolumeManager& m);
220 } /* End namespace dd4hep */
221 #endif // DD4HEP_VOLUMEMANAGER_H
dd4hep::VolumeManagerContext::worldToElement
Position worldToElement(const Position &world) const
Transform world coordinates to the DetElement coordinates.
Definition: VolumeManager.cpp:363
dd4hep::VolumeManager::lookupDetElement
DetElement lookupDetElement(VolumeID volume_id) const
Convenience routine: Lookup the closest subdetector detector element in the hierarchy according to a ...
Definition: VolumeManager.cpp:672
dd4hep::VolumeManager::lookupContext
VolumeManagerContext * lookupContext(VolumeID volume_id) const
Lookup the context, which belongs to a registered physical volume.
Definition: VolumeManager.cpp:605
Volumes.h
dd4hep::VolumeManagerContext::operator=
VolumeManagerContext & operator=(const VolumeManagerContext &copy)=delete
Inhibit assignment.
dd4hep::VolumeManager::adoptPlacement
bool adoptPlacement(VolumeManagerContext *context)
Register physical volume with the manager (normally: section manager)
Definition: VolumeManager.cpp:568
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:173
dd4hep::VolumeManager::LAST
@ LAST
Definition: VolumeManager.h:143
dd4hep::VolumeManagerContext::VolumeManagerContext
VolumeManagerContext(VolumeManagerContext &&copy)=delete
Inhibit move constructor.
dd4hep::IDDescriptor
Class implementing the ID encoding of the detector response.
Definition: IDDescriptor.h:37
dd4hep::VolumeManagerContext::element
DetElement element
Handle to the closest Detector element.
Definition: VolumeManager.h:53
dd4hep::VolumeManager::NONE
@ NONE
Definition: VolumeManager.h:139
dd4hep::VolumeManager::worldTransformation
const TGeoMatrix & worldTransformation(const ConditionsMap &map, VolumeID volume_id) const
Convenience routine: Access the transformation of a physical volume to the world coordinate system.
Definition: VolumeManager.cpp:679
dd4hep::Handle
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:84
dd4hep::VolumeManager::detector
DetElement detector() const
Access the top level detector element.
Definition: VolumeManager.cpp:497
dd4hep::VolumeManagerContext::volumePlacement
PlacedVolume volumePlacement() const
Acces the sensitive volume placement.
Definition: VolumeManager.cpp:314
dd4hep::VolumeManager::ONE
@ ONE
Definition: VolumeManager.h:141
dd4hep::Handle< detail::VolumeManagerObject >::name
const char * name() const
Access the object name (or "" if not supported by the object)
dd4hep::detail::VolumeManagerObject
This structure describes the internal data of the volume manager object.
Definition: VolumeManagerInterna.h:65
dd4hep::operator<<
std::ostream & operator<<(std::ostream &os, const DetType &t)
Definition: DetType.h:99
dd4hep::VolumeManager::VolumeManager
VolumeManager()=default
Default constructor.
dd4hep::VolumeManagerContext::mask
VolumeID mask
Ignore mask of the placement identifier.
Definition: VolumeManager.h:57
dd4hep::VolumeManagerContext::~VolumeManagerContext
virtual ~VolumeManagerContext()
Default destructor.
Definition: VolumeManager.cpp:304
dd4hep::VolumeManager::lookupVolumePlacement
PlacedVolume lookupVolumePlacement(VolumeID volume_id) const
Lookup a physical (placed) volume identified by its 64 bit hit ID.
Definition: VolumeManager.cpp:639
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::VolumeManager::PopulateFlags
PopulateFlags
Definition: VolumeManager.h:138
dd4hep::VolumeManager
Class to support the retrieval of detector elements and volumes given a valid identifier.
Definition: VolumeManager.h:135
dd4hep::VolumeManager::lookupDetector
DetElement lookupDetector(VolumeID volume_id) const
Convenience routine: Lookup a top level subdetector detector element according to a contained 64 bit ...
Definition: VolumeManager.cpp:645
dd4hep::VolumeManager::getVolumeManager
static VolumeManager getVolumeManager(const Detector &description)
static accessor calling DD4hepVolumeManagerPlugin if necessary
Definition: VolumeManager.cpp:420
dd4hep::VolumeManager::subdetector
VolumeManager subdetector(VolumeID id) const
Access the volume manager by cell id.
Definition: VolumeManager.cpp:479
dd4hep::VolumeManager::VolumeManager
VolumeManager(const Handle< Q > &e)
Constructor to be used when reading the already parsed object.
Definition: VolumeManager.h:166
NamedObject.h
dd4hep::VolumeManagerContext::localToElement
Position localToElement(const double local[3]) const
Transform local coordinates to the DetElement coordinates.
Definition: VolumeManager.cpp:330
dd4hep::VolumeManagerContext::toElement
const TGeoHMatrix & toElement() const
Access the transformation to the closest detector element.
Definition: VolumeManager.cpp:322
dd4hep::VolumeManager::addSubdetector
VolumeManager addSubdetector(DetElement detector, Readout ro)
Add a new Volume manager section according to a new subdetector.
Definition: VolumeManager.cpp:428
dd4hep::VolumeManager::lookupDetElementPlacement
PlacedVolume lookupDetElementPlacement(VolumeID volume_id) const
Lookup a physical (placed) volume of the detector element containing a volume identified by its 64 bi...
Definition: VolumeManager.cpp:633
dd4hep::VolumeManagerContext::operator=
VolumeManagerContext & operator=(VolumeManagerContext &&copy)=delete
Inhibit move assignment.
dd4hep::VolumeManagerContext::flag
long flag
Flag to indicate optional information.
Definition: VolumeManager.h:59
ConditionsMap.h
dd4hep::Position
ROOT::Math::XYZVector Position
Definition: Objects.h:81
dd4hep::VolumeManager::operator=
VolumeManager & operator=(const VolumeManager &m)=default
Assignment operator.
dd4hep::VolumeManager::TREE
@ TREE
Definition: VolumeManager.h:140
VolumeID
dd4hep::DDSegmentation::VolumeID VolumeID
Definition: SegmentationDictionary.h:49
IDDescriptor.h
dd4hep::VolumeManager::idSpec
IDDescriptor idSpec() const
Access IDDescription structure.
Definition: VolumeManager.cpp:505
dd4hep::Handle< detail::VolumeManagerObject >::ptr
detail::VolumeManagerObject * ptr() const
Access to the held object.
Definition: Handle.h:153
DetElement.h
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::VolumeManagerContext::identifier
VolumeID identifier
Placement identifier.
Definition: VolumeManager.h:55
dd4hep::VolumeManager::_data
Object & _data() const
Additional data accessor.
Definition: VolumeManager.h:148
dd4hep::VolumeManagerContext
This structure describes the cached data for one placement held by the volume manager.
Definition: VolumeManager.h:50
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::Readout
Handle to the implementation of the readout structure of a subdetector.
Definition: Readout.h:38
dd4hep::VolumeManagerContext::worldToLocal
Position worldToLocal(const Position &world) const
Transform world coordinates to the local coordinates.
Definition: VolumeManager.cpp:381
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::VolumeManagerContext::VolumeManagerContext
VolumeManagerContext(const VolumeManagerContext &copy)=delete
Inhibit copy constructor.
dd4hep::VolumeManagerContext::VolumeManagerContext
VolumeManagerContext()=default
Default constructor.
dd4hep::VolumeManager::VolumeManager
VolumeManager(const VolumeManager &e)=default
Constructor to be used when reading the already parsed object.
dd4hep::VolumeManagerContext::localToWorld
Position localToWorld(const double local[3]) const
Transform local coordinates to the world coordinates.
Definition: VolumeManager.cpp:344
dd4hep::ConditionsMap
ConditionsMap class.
Definition: ConditionsMap.h:59
dd4hep::VolumeManagerContext::elementPlacement
PlacedVolume elementPlacement() const
Acces the detector element volume placement.
Definition: VolumeManager.cpp:309