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
VolumeManager.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation for LCD
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_GEOMETRY_VOLUMEMANAGER_H
15 #define DD4hep_GEOMETRY_VOLUMEMANAGER_H
16 
17 // Framework include files
18 #include "DD4hep/Volumes.h"
19 #include "DD4hep/Detector.h"
20 #include "DD4hep/NamedObject.h"
21 #include "DD4hep/IDDescriptor.h"
22 
23 // ROOT include files
24 #include "TGeoMatrix.h"
25 
26 
28 namespace DD4hep {
29 
31  namespace Geometry {
32 
33  // Forward declarations
34  class LCDD;
35  class VolumeManagerContext;
36  class VolumeManagerObject;
37 
39 
70  class VolumeManager: public Handle<VolumeManagerObject> {
71  public:
74  // Creation flags
76  NONE = 0,
77  TREE = 1 << 1, // Build 1 level DetElement hierarchy while populating
78  ONE = 1 << 2, // Populate all daughter volumes into one big lookup-container
79  // This flag may be in parallel with 'TREE'
81  };
82 
86  typedef std::map<VolumeID, VolumeManager> Managers;
87  typedef std::map<DetElement, VolumeManager> Detectors;
88  typedef std::map<VolumeID, VolumeManagerContext*> Volumes;
90  typedef std::map<TGeoNode*, Context*> PhysVolumes;
91 
92  protected:
94  Object& _data() const {
95  return *(Object*) ptr();
96  }
97 
98  public:
102  }
106  }
107 #ifndef __CINT__
111  }
112 #endif
113  template <typename Q> VolumeManager(const Handle<Q>& e)
116  }
121  VolumeManager(LCDD& lcdd, const std::string& name, DetElement world = DetElement(), Readout ro = Readout(), int flags =
122  NONE);
124  VolumeManager(DetElement subdetector, Readout ro);
125 
128  if ( this != &m ) m_element = m.m_element;
129  return *this;
130  }
135 
137  DetElement detector() const;
139  IDDescriptor idSpec() const;
140 
142  bool adoptPlacement(Context* context);
144  bool adoptPlacement(VolumeID volume_id, Context* context);
145 
149  Context* lookupContext(VolumeID volume_id) const;
152  PlacedVolume lookupPlacement(VolumeID volume_id) const;
154  DetElement lookupDetector(VolumeID volume_id) const;
156  DetElement lookupDetElement(VolumeID volume_id) const;
158  const TGeoMatrix& worldTransformation(VolumeID volume_id) const;
159  };
160 
162  std::ostream& operator<<(std::ostream& os, const VolumeManager& m);
163 
164  } /* End namespace Geometry */
165 } /* End namespace DD4hep */
166 #endif /* DD4hep_GEOMETRY_READOUT_H */
VolumeManager addSubdetector(DetElement detector, Readout ro)
Add a new Volume manager section according to a new subdetector.
bool adoptPlacement(Context *context)
Register physical volume with the manager (normally: section manager)
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:135
const char * name() const
Access the object name (or "" if not supported by the object)
Definition: Handle.inl:36
VolumeManagerObject Object
Some useful Container abbreviations used by the VolumeManager.
Definition: VolumeManager.h:84
PlacedVolume lookupPlacement(VolumeID volume_id) const
Lookup a physical (placed) volume identified by its 64 bit hit ID.
Object & _data() const
Additional data accessor.
Definition: VolumeManager.h:94
VolumeManager & operator=(const VolumeManager &m)
Assignment operator.
This structure describes the cached data for one placement held by the volume manager.
IDDescriptor idSpec() const
Access IDDescription structure.
return e
Definition: Volumes.cpp:297
Handle to the implementation of the readout structure of a subdetector.
Definition: Readout.h:46
T * ptr() const
Access to the held object.
Definition: Handle.h:149
std::ostream & operator<<(std::ostream &os, const VolumeManager &m)
Enable printouts for debugging.
DD4hep::Geometry::DetElement DetElement
PlacedVolume::VolIDs VolIDs
Definition: VolumeManager.h:89
This structure describes the internal data of the volume manager object.
VolumeManager(const VolumeManager &e)
Constructor to be used when reading the already parsed object.
VolumeManager()
Default constructor.
VolumeManagerContext Context
Definition: VolumeManager.h:85
VolumeManager subdetector(VolumeID id) const
Access the volume manager by cell id.
std::map< VolumeID, VolumeManager > Managers
Definition: VolumeManager.h:86
DetElement lookupDetElement(VolumeID volume_id) const
Lookup the closest subdetector detector element in the hierarchy according to a contained 64 bit hit ...
DetElement lookupDetector(VolumeID volume_id) const
Lookup a top level subdetector detector element according to a contained 64 bit hit ID...
Context * lookupContext(VolumeID volume_id) const
Lookup the context, which belongs to a registered physical volume.
Handle class describing a detector element.
Definition: Detector.h:172
Class to support the retrieval of detector elements and volumes given a valid identifier.
Definition: VolumeManager.h:70
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:87
const TGeoMatrix & worldTransformation(VolumeID volume_id) const
Access the transformation of a physical volume to the world coordinate system.
long long int VolumeID
Definition: Primitives.h:35
std::map< DetElement, VolumeManager > Detectors
Definition: VolumeManager.h:87
T * m_element
Single and only data member: Reference to the actual element.
Definition: Handle.h:96
DetElement detector() const
Access the top level detector element.
Class implementing the ID encoding of detector response.
Definition: IDDescriptor.h:40
std::map< VolumeID, VolumeManagerContext * > Volumes
Definition: VolumeManager.h:88
TGeoShape TGeoMedium * m
Definition: Volumes.cpp:294
std::map< TGeoNode *, Context * > PhysVolumes
Definition: VolumeManager.h:90