DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
DetectorData.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_DETECTORDATA_H
15 #define DD4HEP_DETECTORDATA_H
16 
17 // Framework includes
18 #include <DD4hep/Printout.h>
19 #include <DD4hep/Detector.h>
22 
23 // C/C++ include files
24 #include <stdexcept>
25 
27 namespace dd4hep {
28 
29  // Foward declarations
30  class NamedObject;
31 
33 
38  class DetectorData {
39 
40  public:
42 
47  struct InvalidObjectError: public std::runtime_error {
48  InvalidObjectError(const std::string& msg)
49  : std::runtime_error("dd4hep: " + msg) {
50  }
51  };
52 
54 
60  public:
62  std::string name;
63  public:
65  ObjectHandleMap() = default;
67  ObjectHandleMap(const std::string& name);
69  void append(const Handle<NamedObject>& e, bool throw_on_doubles = true) {
70  if (e.isValid()) {
71  std::string n = e.name();
72  std::pair<iterator, bool> r = this->emplace(n, e.ptr());
73  if (!throw_on_doubles || r.second) {
74  if (not r.second) {
75  printout(WARNING,"Detector",
76  "+++ Object '%s' is already defined. New value will be ignored",
77  n.c_str());
78  }
79  return;
80  }
81  throw InvalidObjectError("Attempt to add an already existing object:" + std::string(e.name()) + ".");
82  }
83  throw InvalidObjectError("Attempt to add an invalid object.");
84  }
86  template <typename T> void append(const Handle<NamedObject>& e, bool throw_on_doubles = true) {
87  T* obj = dynamic_cast<T*>(e.ptr());
88  if (obj) {
89  this->append(e, throw_on_doubles);
90  return;
91  }
92  throw InvalidObjectError("Attempt to add an object, which is of the wrong type.");
93  }
94  };
95 
96  protected:
97  public:
99  TGeoManager* m_manager;
117  // GDML fields
119 
120  std::map<std::string,DetElement> m_detectorParents;
121 
127 
135 
140 
143 
146 
147  protected:
148  public:
150  DetectorData();
152  virtual ~DetectorData();
156  DetectorData(const DetectorData& copy) = delete;
158  //DetectorData& operator=(const DetectorData& copy) = delete;
159  public:
161  static void patchRootStreamer(TClass* cl);
163  static void unpatchRootStreamer(TClass* cl);
164 
166  void destroyData(bool destroy_mgr=true);
168  void clearData();
170  void adoptData(DetectorData& source, bool CLR=true);
171 
173  TGeoManager& manager() const { return *m_manager; }
175  dd4hep::Material air() const { return m_materialAir; }
181  dd4hep::DetElement world() const { return m_world; }
195  dd4hep::Header header() const { return m_header; }
197  const Detector::HandleMap& constants() const { return m_define; }
199  const Detector::HandleMap& visAttributes() const { return m_display; }
201  const Detector::HandleMap& limitsets() const { return m_limits; }
203  const Detector::HandleMap& regions() const { return m_regions; }
205  const Detector::HandleMap& readouts() const { return m_readouts; }
207  const Detector::HandleMap& detectors() const { return m_detectors; }
211  const Detector::HandleMap& fields() const { return m_fields; }
213  const Detector::HandleMap& idSpecifications() const { return m_idDict; }
214  };
215 
217  inline DetectorData::ObjectHandleMap::ObjectHandleMap(const std::string& nam)
218  : name(nam)
219  {
220  }
221 } /* End namespace dd4hep */
222 #endif // DD4HEP_DETECTORDATA_H
dd4hep::Detector::State
State
The detector description states.
Definition: Detector.h:98
dd4hep::DetectorData::m_sensitive
ObjectHandleMap m_sensitive
The map of top level sub-detector sensitive detector objects indexed by the detector name.
Definition: DetectorData.h:110
dd4hep::DetectorData::m_detectorParents
std::map< std::string, DetElement > m_detectorParents
Definition: DetectorData.h:120
dd4hep::DetectorData::m_display
ObjectHandleMap m_display
The map of display attributes in use.
Definition: DetectorData.h:114
dd4hep::DetectorData::volumeManager
dd4hep::VolumeManager volumeManager() const
Return handle to the VolumeManager.
Definition: DetectorData.h:191
dd4hep::DetectorData::clearData
void clearData()
Clear data content: DOES NOT RELEASEW ALLOCATED RESOURCES!
Definition: DetectorData.cpp:255
dd4hep::DetectorData::manager
TGeoManager & manager() const
Access the geometry manager of this instance.
Definition: DetectorData.h:173
dd4hep::ObjectExtensions
Implementation of an object supporting arbitrary user extensions.
Definition: ObjectExtensions.h:33
Detector.h
dd4hep::DetectorData::ObjectHandleMap::append
void append(const Handle< NamedObject > &e, bool throw_on_doubles=true)
Append entry to map.
Definition: DetectorData.h:69
dd4hep::DetectorData::m_trackingVol
Volume m_trackingVol
Definition: DetectorData.h:126
ObjectExtensions.h
dd4hep::Detector::Properties
std::map< std::string, PropertyValues > Properties
Definition: Detector.h:95
dd4hep::VisAttr
Handle class describing visualization attributes.
Definition: Objects.h:324
dd4hep::DetectorData::trackingVolume
dd4hep::Volume trackingVolume() const
Return handle to the world volume containing the volume with the tracking devices.
Definition: DetectorData.h:189
VolumeManagerInterna.h
dd4hep::DetectorData::m_world
DetElement m_world
Definition: DetectorData.h:122
dd4hep::Handle::isValid
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:128
dd4hep::Handle< NamedObject >
dd4hep::DetectorData::m_header
Header m_header
Definition: DetectorData.h:132
dd4hep::DetectorData::m_field
OverlayedField m_field
Definition: DetectorData.h:131
dd4hep::DetectorData::vacuum
dd4hep::Material vacuum() const
Return handle to material describing vacuum.
Definition: DetectorData.h:177
dd4hep::Handle::name
const char * name() const
Access the object name (or "" if not supported by the object)
dd4hep::DetectorData::m_idDict
ObjectHandleMap m_idDict
Map of readout IDDescriptors indexed by hit collection name.
Definition: DetectorData.h:102
dd4hep::DetectorData::DetectorData
DetectorData()
Default constructor.
Definition: DetectorData.cpp:159
dd4hep::DetectorData::patchRootStreamer
static void patchRootStreamer(TClass *cl)
Assignment operator.
Definition: DetectorData.cpp:187
dd4hep::DetectorData::m_inhibitConstants
bool m_inhibitConstants
Flag to inhibit the access to global constants. Value set by constants section 'Detector_InhibitConst...
Definition: DetectorData.h:145
dd4hep::DetectorData::air
dd4hep::Material air() const
Return handle to material describing air.
Definition: DetectorData.h:175
dd4hep::DetectorData::InvalidObjectError
Specialized exception class.
Definition: DetectorData.h:47
dd4hep::DetectorData::m_worldVol
Volume m_worldVol
Definition: DetectorData.h:124
dd4hep::OverlayedField
Class describing a field overlay with several sources.
Definition: Fields.h:138
dd4hep::DetectorData::fields
const Detector::HandleMap & fields() const
Accessor to the map of field entries, which together form the global field.
Definition: DetectorData.h:211
dd4hep::DetectorData::m_define
ObjectHandleMap m_define
Definition: DetectorData.h:118
dd4hep::Material
Handle class describing a material.
Definition: Objects.h:272
dd4hep::DetectorData::m_regions
ObjectHandleMap m_regions
Map of regions settings for the simulation.
Definition: DetectorData.h:106
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::DetectorData::visAttributes
const Detector::HandleMap & visAttributes() const
Accessor to the map of visualisation attributes.
Definition: DetectorData.h:199
dd4hep::DetectorData::idSpecifications
const Detector::HandleMap & idSpecifications() const
Accessor to the map of ID specifications.
Definition: DetectorData.h:213
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:370
dd4hep::DetectorData::DetectorData
DetectorData(const DetectorData &copy)=delete
Copy constructor.
dd4hep::VolumeManager
Class to support the retrieval of detector elements and volumes given a valid identifier.
Definition: VolumeManager.h:135
dd4hep::DetectorData::constants
const Detector::HandleMap & constants() const
Accessor to the map of constants.
Definition: DetectorData.h:197
dd4hep::DetectorData::m_buildType
DetectorBuildType m_buildType
Definition: DetectorData.h:134
dd4hep::DetectorData::m_state
Detector::State m_state
Detector description state.
Definition: DetectorData.h:142
dd4hep::DetectorData::m_volManager
VolumeManager m_volManager
Volume manager reference.
Definition: DetectorData.h:139
dd4hep::DetectorData::m_readouts
ObjectHandleMap m_readouts
Map of readout descriptors indexed by subdetector name.
Definition: DetectorData.h:108
dd4hep::DetectorData::trackers
dd4hep::DetElement trackers() const
Return reference to detector element with all tracker devices.
Definition: DetectorData.h:183
dd4hep::DetectorData::m_detectors
ObjectHandleMap m_detectors
The map of top level sub-detector objects indexed by name.
Definition: DetectorData.h:112
dd4hep::DetectorData::field
dd4hep::OverlayedField field() const
Return handle to the combined electromagentic field description.
Definition: DetectorData.h:193
dd4hep::DetectorData::m_materialAir
Material m_materialAir
Definition: DetectorData.h:128
dd4hep::DetectorData::destroyData
void destroyData(bool destroy_mgr=true)
Clear data content: releases all allocated resources.
Definition: DetectorData.cpp:209
dd4hep::Header
Handle class describing the basic information about geometry objects as it is defined in Detector.
Definition: Objects.h:158
dd4hep::DetectorData::DetectorData
DetectorData(DetectorData &&copy)=delete
Move constructor.
dd4hep::DetectorData::ObjectHandleMap::ObjectHandleMap
ObjectHandleMap()=default
Default constructor.
dd4hep::DetectorData::m_properties
Detector::Properties m_properties
Definition: DetectorData.h:133
dd4hep::DetectorData::m_fields
ObjectHandleMap m_fields
The map of electro magnet field components for the global overlay field.
Definition: DetectorData.h:116
dd4hep::DetectorData::~DetectorData
virtual ~DetectorData()
Default destructor.
Definition: DetectorData.cpp:181
dd4hep::DetectorData::worldVolume
dd4hep::Volume worldVolume() const
Return handle to the world volume containing everything.
Definition: DetectorData.h:185
dd4hep::Detector::HandleMap
std::map< std::string, Handle< NamedObject > > HandleMap
Type definition of a map of named handles.
Definition: Detector.h:93
dd4hep::Detector::NOT_READY
@ NOT_READY
The detector description object is freshly created. No geometry nothing.
Definition: Detector.h:100
dd4hep::DetectorData::ObjectHandleMap
Implementation of a map of named dd4hep Handles.
Definition: DetectorData.h:59
dd4hep::DetectorData::InvalidObjectError::InvalidObjectError
InvalidObjectError(const std::string &msg)
Definition: DetectorData.h:48
dd4hep::DetectorData::m_trackers
DetElement m_trackers
Definition: DetectorData.h:123
std
Definition: Plugins.h:30
dd4hep::DetectorData::m_parallelWorldVol
Volume m_parallelWorldVol
Definition: DetectorData.h:125
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:153
dd4hep::DetectorData::m_materialVacuum
Material m_materialVacuum
Definition: DetectorData.h:129
dd4hep::DetectorData::adoptData
void adoptData(DetectorData &source, bool CLR=true)
Adopt all data from source structure.
Definition: DetectorData.cpp:283
dd4hep::DetectorData::m_extensions
ObjectExtensions m_extensions
Definition of the extension type.
Definition: DetectorData.h:137
dd4hep::DetectorBuildType
DetectorBuildType
Detector description build types.
Definition: BuildType.h:34
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::DetectorData
Data implementation class of the Detector interface.
Definition: DetectorData.h:38
dd4hep::DetectorData::invisible
dd4hep::VisAttr invisible() const
Return handle to "invisible" visualization attributes.
Definition: DetectorData.h:179
dd4hep::DetectorData::header
dd4hep::Header header() const
Accessor to the header entry.
Definition: DetectorData.h:195
dd4hep::DetectorData::m_manager
TGeoManager * m_manager
Reference to the geometry manager object from ROOT.
Definition: DetectorData.h:100
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::DetectorData::m_invisibleVis
VisAttr m_invisibleVis
Definition: DetectorData.h:130
dd4hep::DetectorData::parallelWorldVolume
dd4hep::Volume parallelWorldVolume() const
Return handle to the world volume containing the volume with the tracking devices.
Definition: DetectorData.h:187
dd4hep::DetectorData::limitsets
const Detector::HandleMap & limitsets() const
Accessor to the map of limit settings.
Definition: DetectorData.h:201
dd4hep::DetectorData::ObjectHandleMap::name
std::string name
Name the map.
Definition: DetectorData.h:62
Printout.h
dd4hep::DetectorData::unpatchRootStreamer
static void unpatchRootStreamer(TClass *cl)
UNPatch the ROOT streamers to adapt for DD4hep (set fUserExtension transient)
Definition: DetectorData.cpp:198
dd4hep::DetectorData::m_limits
ObjectHandleMap m_limits
Map of limit sets.
Definition: DetectorData.h:104
dd4hep::DetectorData::regions
const Detector::HandleMap & regions() const
Accessor to the map of region settings.
Definition: DetectorData.h:203
dd4hep::DetectorData::detectors
const Detector::HandleMap & detectors() const
Accessor to the map of sub-detectors.
Definition: DetectorData.h:207
dd4hep::DetectorData::ObjectHandleMap::append
void append(const Handle< NamedObject > &e, bool throw_on_doubles=true)
Append entry to map.
Definition: DetectorData.h:86
dd4hep::DetectorData::world
dd4hep::DetElement world() const
Return reference to the top-most (world) detector element.
Definition: DetectorData.h:181
dd4hep::DetectorData::sensitiveDetectors
const Detector::HandleMap & sensitiveDetectors() const
Retrieve a sensitive detector by its name from the detector description.
Definition: DetectorData.h:209
dd4hep::DetectorData::readouts
const Detector::HandleMap & readouts() const
Accessor to the map of readout structures.
Definition: DetectorData.h:205