DD4hep  1.37.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  delete e.ptr();
79  }
80  return;
81  }
82  throw InvalidObjectError("Attempt to add an already existing object:" + std::string(e.name()) + ".");
83  }
84  throw InvalidObjectError("Attempt to add an invalid object.");
85  }
87  template <typename T> void append(const Handle<NamedObject>& e, bool throw_on_doubles = true) {
88  T* obj = dynamic_cast<T*>(e.ptr());
89  if (obj) {
90  this->append(e, throw_on_doubles);
91  return;
92  }
93  throw InvalidObjectError("Attempt to add an object, which is of the wrong type.");
94  }
95  };
96 
97  protected:
98  public:
100  TGeoManager* m_manager;
118  // GDML fields
120 
121  std::map<std::string,DetElement> m_detectorParents;
122 
128 
136 
141 
144 
147 
148  protected:
149  public:
151  DetectorData();
153  virtual ~DetectorData();
157  DetectorData(const DetectorData& copy) = delete;
159  //DetectorData& operator=(const DetectorData& copy) = delete;
160  public:
162  static void patchRootStreamer(TClass* cl);
164  static void unpatchRootStreamer(TClass* cl);
165 
167  void destroyData(bool destroy_mgr=true);
169  void clearData();
171  void adoptData(DetectorData& source, bool CLR=true);
172 
174  TGeoManager& manager() const { return *m_manager; }
176  dd4hep::Material air() const { return m_materialAir; }
182  dd4hep::DetElement world() const { return m_world; }
196  dd4hep::Header header() const { return m_header; }
198  const Detector::HandleMap& constants() const { return m_define; }
200  const Detector::HandleMap& visAttributes() const { return m_display; }
202  const Detector::HandleMap& limitsets() const { return m_limits; }
204  const Detector::HandleMap& regions() const { return m_regions; }
206  const Detector::HandleMap& readouts() const { return m_readouts; }
208  const Detector::HandleMap& detectors() const { return m_detectors; }
212  const Detector::HandleMap& fields() const { return m_fields; }
214  const Detector::HandleMap& idSpecifications() const { return m_idDict; }
215  };
216 
218  inline DetectorData::ObjectHandleMap::ObjectHandleMap(const std::string& nam)
219  : name(nam)
220  {
221  }
222 } /* End namespace dd4hep */
223 #endif // DD4HEP_DETECTORDATA_H
dd4hep::Detector::State
State
The detector description states.
Definition: Detector.h:97
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:111
dd4hep::DetectorData::m_detectorParents
std::map< std::string, DetElement > m_detectorParents
Definition: DetectorData.h:121
dd4hep::DetectorData::m_display
ObjectHandleMap m_display
The map of display attributes in use.
Definition: DetectorData.h:115
dd4hep::DetectorData::volumeManager
dd4hep::VolumeManager volumeManager() const
Return handle to the VolumeManager.
Definition: DetectorData.h:192
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:174
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:127
ObjectExtensions.h
dd4hep::Detector::Properties
std::map< std::string, PropertyValues > Properties
Definition: Detector.h:94
dd4hep::VisAttr
Handle class describing visualization attributes.
Definition: Objects.h:331
dd4hep::DetectorData::trackingVolume
dd4hep::Volume trackingVolume() const
Return handle to the world volume containing the volume with the tracking devices.
Definition: DetectorData.h:190
VolumeManagerInterna.h
dd4hep::DetectorData::m_world
DetElement m_world
Definition: DetectorData.h:123
dd4hep::Handle::isValid
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:126
dd4hep::Handle< NamedObject >
dd4hep::DetectorData::m_header
Header m_header
Definition: DetectorData.h:133
dd4hep::DetectorData::m_field
OverlayedField m_field
Definition: DetectorData.h:132
dd4hep::DetectorData::vacuum
dd4hep::Material vacuum() const
Return handle to material describing vacuum.
Definition: DetectorData.h:178
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:103
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:146
dd4hep::DetectorData::air
dd4hep::Material air() const
Return handle to material describing air.
Definition: DetectorData.h:176
dd4hep::DetectorData::InvalidObjectError
Specialized exception class.
Definition: DetectorData.h:47
dd4hep::DetectorData::m_worldVol
Volume m_worldVol
Definition: DetectorData.h:125
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:212
dd4hep::DetectorData::m_define
ObjectHandleMap m_define
Definition: DetectorData.h:119
dd4hep::Material
Handle class describing a material.
Definition: Objects.h:271
dd4hep::DetectorData::m_regions
ObjectHandleMap m_regions
Map of regions settings for the simulation.
Definition: DetectorData.h:107
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:187
dd4hep::DetectorData::visAttributes
const Detector::HandleMap & visAttributes() const
Accessor to the map of visualisation attributes.
Definition: DetectorData.h:200
dd4hep::DetectorData::idSpecifications
const Detector::HandleMap & idSpecifications() const
Accessor to the map of ID specifications.
Definition: DetectorData.h:214
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:371
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:198
dd4hep::DetectorData::m_buildType
DetectorBuildType m_buildType
Definition: DetectorData.h:135
dd4hep::DetectorData::m_state
Detector::State m_state
Detector description state.
Definition: DetectorData.h:143
dd4hep::DetectorData::m_volManager
VolumeManager m_volManager
Volume manager reference.
Definition: DetectorData.h:140
dd4hep::DetectorData::m_readouts
ObjectHandleMap m_readouts
Map of readout descriptors indexed by subdetector name.
Definition: DetectorData.h:109
dd4hep::DetectorData::trackers
dd4hep::DetElement trackers() const
Return reference to detector element with all tracker devices.
Definition: DetectorData.h:184
dd4hep::DetectorData::m_detectors
ObjectHandleMap m_detectors
The map of top level sub-detector objects indexed by name.
Definition: DetectorData.h:113
dd4hep::DetectorData::field
dd4hep::OverlayedField field() const
Return handle to the combined electromagentic field description.
Definition: DetectorData.h:194
dd4hep::DetectorData::m_materialAir
Material m_materialAir
Definition: DetectorData.h:129
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:157
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:134
dd4hep::DetectorData::m_fields
ObjectHandleMap m_fields
The map of electro magnet field components for the global overlay field.
Definition: DetectorData.h:117
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:186
dd4hep::Detector::HandleMap
std::map< std::string, Handle< NamedObject > > HandleMap
Type definition of a map of named handles.
Definition: Detector.h:92
dd4hep::Detector::NOT_READY
@ NOT_READY
The detector description object is freshly created. No geometry nothing.
Definition: Detector.h:99
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:124
dd4hep::DetectorData::m_parallelWorldVol
Volume m_parallelWorldVol
Definition: DetectorData.h:126
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:151
dd4hep::DetectorData::m_materialVacuum
Material m_materialVacuum
Definition: DetectorData.h:130
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:138
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:180
dd4hep::DetectorData::header
dd4hep::Header header() const
Accessor to the header entry.
Definition: DetectorData.h:196
dd4hep::DetectorData::m_manager
TGeoManager * m_manager
Reference to the geometry manager object from ROOT.
Definition: DetectorData.h:101
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:131
dd4hep::DetectorData::parallelWorldVolume
dd4hep::Volume parallelWorldVolume() const
Return handle to the world volume containing the volume with the tracking devices.
Definition: DetectorData.h:188
dd4hep::DetectorData::limitsets
const Detector::HandleMap & limitsets() const
Accessor to the map of limit settings.
Definition: DetectorData.h:202
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:105
dd4hep::DetectorData::regions
const Detector::HandleMap & regions() const
Accessor to the map of region settings.
Definition: DetectorData.h:204
dd4hep::DetectorData::detectors
const Detector::HandleMap & detectors() const
Accessor to the map of sub-detectors.
Definition: DetectorData.h:208
dd4hep::DetectorData::ObjectHandleMap::append
void append(const Handle< NamedObject > &e, bool throw_on_doubles=true)
Append entry to map.
Definition: DetectorData.h:87
dd4hep::DetectorData::world
dd4hep::DetElement world() const
Return reference to the top-most (world) detector element.
Definition: DetectorData.h:182
dd4hep::DetectorData::sensitiveDetectors
const Detector::HandleMap & sensitiveDetectors() const
Retrieve a sensitive detector by its name from the detector description.
Definition: DetectorData.h:210
dd4hep::DetectorData::readouts
const Detector::HandleMap & readouts() const
Accessor to the map of readout structures.
Definition: DetectorData.h:206