DD4hep  1.31.0
Detector Description Toolkit for High Energy Physics
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LCDDConverter.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 DDCORE_SRC_PLUGINS_LCDDCONVERTER_H
15 #define DDCORE_SRC_PLUGINS_LCDDCONVERTER_H
16 
17 // Framework include files
18 #include <DD4hep/Detector.h>
19 #include <DD4hep/GeoHandler.h>
21 
22 // C/C++ include files
23 #include <set>
24 #include <map>
25 
26 // Forward declarations
27 class TGeoVolume;
28 class TGeoElement;
29 class TGeoShape;
30 class TGeoMedium;
31 class TGeoNode;
32 class TGeoMatrix;
33 
35 namespace dd4hep {
36 
38  namespace detail {
39 
40  // Forward declarations
41  class SensitiveDetectorObject;
42 
44 
49  class LCDDConverter: public GeoHandler {
50  public:
51  typedef xml::XmlElement XmlElement;
52  typedef std::map<Atom, XmlElement*> ElementMap;
53  typedef std::map<Material, XmlElement*> MaterialMap;
54  typedef std::map<LimitSet, XmlElement*> LimitMap;
55  typedef std::map<PlacedVolume, XmlElement*> PlacementMap;
56  typedef std::map<Region, XmlElement*> RegionMap;
57  typedef std::map<SensitiveDetector, XmlElement*> SensDetMap;
58  typedef std::map<Volume, XmlElement*> VolumeMap;
59  typedef std::map<IDDescriptor, XmlElement*> IdSpecMap;
60  typedef std::map<VisAttr, XmlElement*> VisMap;
61  typedef std::map<const TGeoShape*, XmlElement*> SolidMap;
62  typedef std::map<OverlayedField, XmlElement*> FieldMap;
63  typedef std::map<const TGeoMatrix*, XmlElement*> TrafoMap;
65 
71  public:
85  std::set<SensitiveDetector> sensitives;
86  std::set<Region> regions;
87  std::set<LimitSet> limits;
88  // These we need for redundancy and checking the data integrity
89  typedef std::map<std::string, const TNamed*> CheckIter;
90  struct _checks {
91  std::map<std::string, const TNamed*> positions, rotations, volumes, solids, materials;
92  };
93  mutable _checks checks;
94  void check(const std::string& name, const TNamed* n, std::map<std::string, const TNamed*>& array) const;
95  void checkPosition(const std::string& name, const TNamed* n) const {
96  check(name, n, checks.positions);
97  }
98  void checkRotation(const std::string& name, const TNamed* n) const {
99  check(name, n, checks.rotations);
100  }
101  void checkVolume(const std::string& name, const TNamed* n) const {
102  check(name, n, checks.volumes);
103  }
104  void checkShape(const std::string& name, const TNamed* n) const {
105  check(name, n, checks.solids);
106  }
107  void checkMaterial(const std::string& name, Material n) const {
108  check(name, n.ptr(), checks.materials);
109  }
110 
115  GeometryInfo();
116  };
117  typedef std::set<std::string> NameSet;
118 
123 
124  GeometryInfo& data() const {
125  return *m_dataPtr;
126  }
127 
129  void checkVolumes(const std::string& name, Volume volume) const;
130 
132  LCDDConverter(Detector& description);
133 
135  virtual ~LCDDConverter();
136 
139 
142 
145 
147  virtual void handleHeader() const;
148 
150  virtual xml_h handleMaterial(const std::string& name, Material medium) const;
151 
153  virtual xml_h handleElement(const std::string& name, Atom element) const;
154 
156  virtual xml_h handleSolid(const std::string& name, const TGeoShape* volume) const;
157 
159  virtual xml_h handleVolume(const std::string& name, Volume volume) const;
160  virtual xml_h handleVolumeVis(const std::string& name, const TGeoVolume* volume) const;
161  virtual void collectVolume(const std::string& name, const TGeoVolume* volume) const;
162 
164  virtual xml_h handlePlacement(const std::string& name, PlacedVolume node) const;
165 
168 
170  virtual xml_h handleRegion(const std::string& name, Region region) const;
171 
173  virtual xml_h handleVis(const std::string& name, VisAttr vis) const;
174 
176  virtual xml_h handleIdSpec(const std::string& name, IDDescriptor idspec) const;
177 
179  virtual xml_h handleLimitSet(const std::string& name, LimitSet limitset) const;
180 
182  virtual xml_h handleSensitive(const std::string& name, SensitiveDetector sens_det) const;
183 
185  virtual xml_h handleSegmentation(Segmentation seg) const;
186 
188  virtual xml_h handlePosition(const std::string& name, const TGeoMatrix* trafo) const;
189 
191  virtual xml_h handleRotation(const std::string& name, const TGeoMatrix* trafo) const;
192 
194  virtual xml_h handleField(const std::string& name, OverlayedField field) const;
195 
197  void handleProperties(Detector::Properties& prp) const;
198  };
199  } // End namespace xml
200 } // End namespace dd4hep
201 #endif // DDCORE_SRC_PLUGINS_LCDDCONVERTER_H
dd4hep::detail::LCDDConverter::VolumeMap
std::map< Volume, XmlElement * > VolumeMap
Definition: LCDDConverter.h:58
dd4hep::detail::LCDDConverter::PlacementMap
std::map< PlacedVolume, XmlElement * > PlacementMap
Definition: LCDDConverter.h:55
dd4hep::Atom
Handle class describing an element in the periodic table.
Definition: Objects.h:241
dd4hep::detail::LCDDConverter::GeometryInfo::doc_regions
xml_elt_t doc_regions
Definition: LCDDConverter.h:113
dd4hep::detail::LCDDConverter::m_detDesc
Detector & m_detDesc
Reference to detector description.
Definition: LCDDConverter.h:120
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:43
Detector.h
dd4hep::detail::LCDDConverter::m_checkNames
NameSet m_checkNames
Definition: LCDDConverter.h:121
dd4hep::Detector::Properties
std::map< std::string, PropertyValues > Properties
Definition: Detector.h:95
dd4hep::detail::LCDDConverter::SensDetMap
std::map< SensitiveDetector, XmlElement * > SensDetMap
Definition: LCDDConverter.h:57
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:164
dd4hep::VisAttr
Handle class describing visualization attributes.
Definition: Objects.h:323
dd4hep::detail::GeoHandlerTypes::GeometryInfo
Data container to store information obtained during the geometry scan.
Definition: GeoHandler.h:60
dd4hep::detail::LCDDConverter::GeometryInfo::_checks
Definition: LCDDConverter.h:90
dd4hep::detail::LCDDConverter::GeometryInfo::checks
_checks checks
Definition: LCDDConverter.h:93
dd4hep::detail::LCDDConverter::GeometryInfo::doc_gdml
xml_elt_t doc_gdml
Definition: LCDDConverter.h:113
dd4hep::detail::LCDDConverter::GeometryInfo::xmlSensDets
SensDetMap xmlSensDets
Definition: LCDDConverter.h:81
dd4hep::IDDescriptor
Class implementing the ID encoding of the detector response.
Definition: IDDescriptor.h:36
dd4hep::detail::LCDDConverter::RegionMap
std::map< Region, XmlElement * > RegionMap
Definition: LCDDConverter.h:56
dd4hep::detail::LCDDConverter::createDetector
xml_doc_t createDetector(DetElement top)
Create geometry conversion in Detector format.
Definition: LCDDConverter.cpp:1202
dd4hep::detail::LCDDConverter::handleField
virtual xml_h handleField(const std::string &name, OverlayedField field) const
Convert the electric or magnetic fields into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:1009
dd4hep::detail::LCDDConverter::GeometryInfo::_checks::positions
std::map< std::string, const TNamed * > positions
Definition: LCDDConverter.h:91
dd4hep::detail::LCDDConverter::GeometryInfo::doc_solids
xml_elt_t doc_solids
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::GeometryInfo::limits
std::set< LimitSet > limits
Definition: LCDDConverter.h:87
dd4hep::detail::LCDDConverter::handleRotation
virtual xml_h handleRotation(const std::string &name, const TGeoMatrix *trafo) const
Convert the Rotation into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:637
dd4hep::xml::Handle_t
Class to easily access the properties of single XmlElements.
Definition: XMLElements.h:380
dd4hep::detail::LCDDConverter::GeometryInfo::xmlFields
FieldMap xmlFields
Definition: LCDDConverter.h:84
dd4hep::detail::LCDDConverter::handleElement
virtual xml_h handleElement(const std::string &name, Atom element) const
Convert the geometry type element into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:136
dd4hep::detail::LCDDConverter::data
GeometryInfo & data() const
Definition: LCDDConverter.h:124
dd4hep::detail::LCDDConverter
Geometry converter from dd4hep to Geant 4 in Detector format.
Definition: LCDDConverter.h:49
dd4hep::detail::LCDDConverter::GeometryInfo::doc_display
xml_elt_t doc_display
Definition: LCDDConverter.h:113
dd4hep::detail::LCDDConverter::handleSolid
virtual xml_h handleSolid(const std::string &name, const TGeoShape *volume) const
Convert the geometry type solid into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:220
dd4hep::detail::LCDDConverter::GeometryInfo::xmlRegions
RegionMap xmlRegions
Definition: LCDDConverter.h:77
dd4hep::OverlayedField
Class describing a field overlay with several sources.
Definition: Fields.h:138
dd4hep::detail::LCDDConverter::handleMaterial
virtual xml_h handleMaterial(const std::string &name, Material medium) const
Convert the geometry type material into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:159
dd4hep::detail::LCDDConverter::GeometryInfo::_checks::solids
std::map< std::string, const TNamed * > solids
Definition: LCDDConverter.h:91
dd4hep::detail::LCDDConverter::GeometryInfo::doc_fields
xml_elt_t doc_fields
Definition: LCDDConverter.h:113
dd4hep::detail::LCDDConverter::handlePlacement
virtual xml_h handlePlacement(const std::string &name, PlacedVolume node) const
Convert the geometry type volume placement into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:802
dd4hep::detail::LCDDConverter::XmlElement
xml::XmlElement XmlElement
Definition: LCDDConverter.h:51
dd4hep::detail::LCDDConverter::createVis
xml_doc_t createVis(DetElement top)
Create geometry conversion in Vis format.
Definition: LCDDConverter.cpp:1178
dd4hep::detail::LCDDConverter::GeometryInfo::doc_idDict
xml_elt_t doc_idDict
Definition: LCDDConverter.h:113
dd4hep::detail::LCDDConverter::GeometryInfo::checkPosition
void checkPosition(const std::string &name, const TNamed *n) const
Definition: LCDDConverter.h:95
dd4hep::Material
Handle class describing a material.
Definition: Objects.h:271
dd4hep::detail::LCDDConverter::GeometryInfo::xmlSolids
SolidMap xmlSolids
Definition: LCDDConverter.h:74
dd4hep::detail::LCDDConverter::collectVolume
virtual void collectVolume(const std::string &name, const TGeoVolume *volume) const
Dump logical volume in GDML format to output stream.
Definition: LCDDConverter.cpp:759
dd4hep::detail::LCDDConverter::GeometryInfo::identity_pos
xml_h identity_pos
Definition: LCDDConverter.h:112
dd4hep::detail::LCDDConverter::GeometryInfo::xmlLimits
LimitMap xmlLimits
Definition: LCDDConverter.h:79
dd4hep::detail::LCDDConverter::GeometryInfo::checkMaterial
void checkMaterial(const std::string &name, Material n) const
Definition: LCDDConverter.h:107
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:187
dd4hep::detail::LCDDConverter::GeometryInfo::doc_define
xml_elt_t doc_define
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::createGDML
xml_doc_t createGDML(DetElement top)
Create geometry conversion in GDML format.
Definition: LCDDConverter.cpp:1122
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:371
dd4hep::detail::LCDDConverter::FieldMap
std::map< OverlayedField, XmlElement * > FieldMap
Definition: LCDDConverter.h:62
dd4hep::detail::GeoHandler
The base class for all dd4hep geometry crawlers.
Definition: GeoHandler.h:87
dd4hep::detail::LCDDConverter::SolidMap
std::map< const TGeoShape *, XmlElement * > SolidMap
Definition: LCDDConverter.h:61
dd4hep::detail::LCDDConverter::GeometryInfo::xmlVis
VisMap xmlVis
Definition: LCDDConverter.h:78
dd4hep::LimitSet
Handle class describing a set of limits as they are used for simulation.
Definition: Objects.h:424
dd4hep::detail::LCDDConverter::GeometryInfo::doc_header
xml_elt_t doc_header
Definition: LCDDConverter.h:113
dd4hep::detail::LCDDConverter::GeometryInfo
Data structure of the geometry converter from dd4hep to Geant 4 in Detector format.
Definition: LCDDConverter.h:70
dd4hep::detail::LCDDConverter::GeometryInfo::checkVolume
void checkVolume(const std::string &name, const TNamed *n) const
Definition: LCDDConverter.h:101
dd4hep::detail::LCDDConverter::checkVolumes
void checkVolumes(const std::string &name, Volume volume) const
Data integrity checker.
Definition: LCDDConverter.cpp:778
dd4hep::detail::LCDDConverter::GeometryInfo::_checks::volumes
std::map< std::string, const TNamed * > volumes
Definition: LCDDConverter.h:91
dd4hep::detail::LCDDConverter::GeometryInfo::doc_detectors
xml_elt_t doc_detectors
Definition: LCDDConverter.h:113
dd4hep::detail::LCDDConverter::GeometryInfo::regions
std::set< Region > regions
Definition: LCDDConverter.h:86
dd4hep::detail::LCDDConverter::handleVolume
virtual xml_h handleVolume(const std::string &name, Volume volume) const
Convert the geometry type logical volume into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:671
dd4hep::detail::LCDDConverter::GeometryInfo::identity_rot
xml_h identity_rot
Definition: LCDDConverter.h:112
dd4hep::detail::LCDDConverter::m_dataPtr
GeometryInfo * m_dataPtr
Definition: LCDDConverter.h:122
dd4hep::detail::LCDDConverter::VisMap
std::map< VisAttr, XmlElement * > VisMap
Definition: LCDDConverter.h:60
TNamed
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:37
dd4hep::detail::LCDDConverter::ElementMap
std::map< Atom, XmlElement * > ElementMap
Definition: LCDDConverter.h:52
dd4hep::Region
Handle class describing a region as used in simulation.
Definition: Objects.h:461
dd4hep::detail::LCDDConverter::LimitMap
std::map< LimitSet, XmlElement * > LimitMap
Definition: LCDDConverter.h:54
dd4hep::detail::LCDDConverter::GeometryInfo::xmlVolumes
VolumeMap xmlVolumes
Definition: LCDDConverter.h:75
dd4hep::detail::LCDDConverter::~LCDDConverter
virtual ~LCDDConverter()
Standard destructor.
Definition: LCDDConverter.cpp:129
dd4hep::detail::LCDDConverter::GeometryInfo::_checks::materials
std::map< std::string, const TNamed * > materials
Definition: LCDDConverter.h:91
dd4hep::detail::LCDDConverter::GeometryInfo::doc
xml_doc_t doc
Definition: LCDDConverter.h:111
dd4hep::detail::LCDDConverter::handleProperties
void handleProperties(Detector::Properties &prp) const
Handle the geant 4 specific properties.
Definition: LCDDConverter.cpp:1033
dd4hep::detail::LCDDConverter::GeometryInfo::xmlElements
ElementMap xmlElements
Definition: LCDDConverter.h:72
dd4hep::detail::LCDDConverter::GeometryInfo::doc_limits
xml_elt_t doc_limits
Definition: LCDDConverter.h:113
dd4hep::xml::Document
Class supporting the basic functionality of an XML document.
Definition: XMLElements.h:697
dd4hep::detail::LCDDConverter::handleRegion
virtual xml_h handleRegion(const std::string &name, Region region) const
Convert the geometry type region into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:844
dd4hep::detail::LCDDConverter::TrafoMap
std::map< const TGeoMatrix *, XmlElement * > TrafoMap
Definition: LCDDConverter.h:63
dd4hep::detail::LCDDConverter::GeometryInfo::sensitives
std::set< SensitiveDetector > sensitives
Definition: LCDDConverter.h:85
dd4hep::detail::LCDDConverter::GeometryInfo::xmlPositions
TrafoMap xmlPositions
Definition: LCDDConverter.h:82
dd4hep::detail::LCDDConverter::GeometryInfo::checkShape
void checkShape(const std::string &name, const TNamed *n) const
Definition: LCDDConverter.h:104
DetFactoryHelper.h
dd4hep::detail::LCDDConverter::handleIdSpec
virtual xml_h handleIdSpec(const std::string &name, IDDescriptor idspec) const
Convert the geometry id dictionary entry to the corresponding Xml object(s).
Definition: LCDDConverter.cpp:940
dd4hep::detail::LCDDConverter::GeometryInfo::doc_setup
xml_elt_t doc_setup
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::handleLimitSet
virtual xml_h handleLimitSet(const std::string &name, LimitSet limitset) const
Convert the geometry type LimitSet into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:860
dd4hep::detail::LCDDConverter::handleVolumeVis
virtual xml_h handleVolumeVis(const std::string &name, const TGeoVolume *volume) const
Dump logical volume in GDML format to output stream.
Definition: LCDDConverter.cpp:738
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:151
dd4hep::detail::LCDDConverter::handleHeader
virtual void handleHeader() const
Add header information in Detector format.
Definition: LCDDConverter.cpp:1083
dd4hep::detail::LCDDConverter::GeometryInfo::xmlIdSpecs
IdSpecMap xmlIdSpecs
Definition: LCDDConverter.h:80
dd4hep::xml::Element
User abstraction class to manipulate XML elements within a document.
Definition: XMLElements.h:769
dd4hep::detail::LCDDConverter::GeometryInfo::check
void check(const std::string &name, const TNamed *n, std::map< std::string, const TNamed * > &array) const
Definition: LCDDConverter.cpp:115
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::detail::LCDDConverter::GeometryInfo::xmlPlacements
PlacementMap xmlPlacements
Definition: LCDDConverter.h:76
dd4hep::detail::LCDDConverter::LCDDConverter
LCDDConverter(Detector &description)
Initializing Constructor.
Definition: LCDDConverter.cpp:125
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::detail::LCDDConverter::handleSensitive
virtual xml_h handleSensitive(const std::string &name, SensitiveDetector sens_det) const
Convert the geometry type SensitiveDetector into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:914
dd4hep::detail::LCDDConverter::GeometryInfo::_checks::rotations
std::map< std::string, const TNamed * > rotations
Definition: LCDDConverter.h:91
dd4hep::Segmentation
Handle class supporting generic Segmentations of sensitive detectors.
Definition: Segmentations.h:41
dd4hep::detail::LCDDConverter::IdSpecMap
std::map< IDDescriptor, XmlElement * > IdSpecMap
Definition: LCDDConverter.h:59
dd4hep::detail::LCDDConverter::GeometryInfo::xmlMaterials
MaterialMap xmlMaterials
Definition: LCDDConverter.h:73
dd4hep::detail::LCDDConverter::handleSegmentation
virtual xml_h handleSegmentation(Segmentation seg) const
Convert the segmentation of a SensitiveDetector into the corresponding Detector object.
Definition: LCDDConverter.cpp:882
dd4hep::detail::LCDDConverter::GeometryInfo::doc_root
xml_elt_t doc_root
Definition: LCDDConverter.h:113
dd4hep::detail::LCDDConverter::GeometryInfo::doc_structure
xml_elt_t doc_structure
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::NameSet
std::set< std::string > NameSet
Definition: LCDDConverter.h:117
dd4hep::detail::LCDDConverter::GeometryInfo::GeometryInfo
GeometryInfo()
Helper constructor.
Definition: LCDDConverter.cpp:1284
dd4hep::detail::LCDDConverter::GeometryInfo::xmlRotations
TrafoMap xmlRotations
Definition: LCDDConverter.h:83
dd4hep::detail::LCDDConverter::handlePosition
virtual xml_h handlePosition(const std::string &name, const TGeoMatrix *trafo) const
Convert the Position into the corresponding Xml object(s).
Definition: LCDDConverter.cpp:603
dd4hep::detail::LCDDConverter::GeometryInfo::doc_materials
xml_elt_t doc_materials
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::MaterialMap
std::map< Material, XmlElement * > MaterialMap
Definition: LCDDConverter.h:53
dd4hep::detail::LCDDConverter::GeometryInfo::CheckIter
std::map< std::string, const TNamed * > CheckIter
Definition: LCDDConverter.h:89
dd4hep::detail::LCDDConverter::GeometryInfo::checkRotation
void checkRotation(const std::string &name, const TNamed *n) const
Definition: LCDDConverter.h:98
dd4hep::detail::LCDDConverter::handleVis
virtual xml_h handleVis(const std::string &name, VisAttr vis) const
Convert the geometry visualisation attributes to the corresponding Xml object(s).
Definition: LCDDConverter.cpp:975
GeoHandler.h