DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
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 #include <vector>
26 
27 // Forward declarations
28 class TGeoVolume;
29 class TGeoElement;
30 class TGeoShape;
31 class TGeoMedium;
32 class TGeoNode;
33 class TGeoMatrix;
34 
36 namespace dd4hep {
37 
39  namespace detail {
40 
41  // Forward declarations
42  class SensitiveDetectorObject;
43 
45 
50  class LCDDConverter: public GeoHandler {
51  public:
52  typedef xml::XmlElement XmlElement;
53  typedef std::map<Atom, XmlElement*> ElementMap;
54  typedef std::map<Material, XmlElement*> MaterialMap;
55  typedef std::map<LimitSet, XmlElement*> LimitMap;
56  typedef std::map<PlacedVolume, XmlElement*> PlacementMap;
57  typedef std::map<Region, XmlElement*> RegionMap;
58  typedef std::map<SensitiveDetector, XmlElement*> SensDetMap;
59  typedef std::map<Volume, XmlElement*> VolumeMap;
60  typedef std::map<IDDescriptor, XmlElement*> IdSpecMap;
61  typedef std::map<VisAttr, XmlElement*> VisMap;
62  typedef std::map<const TGeoShape*, XmlElement*> SolidMap;
63  typedef std::map<OverlayedField, XmlElement*> FieldMap;
64  typedef std::map<const TGeoMatrix*, XmlElement*> TrafoMap;
66 
72  public:
86  std::set<SensitiveDetector> sensitives;
87  std::set<Region> regions;
88  std::set<LimitSet> limits;
89  // These we need for redundancy and checking the data integrity
90  typedef std::map<std::string, const TNamed*> CheckIter;
91  struct _checks {
92  std::map<std::string, const TNamed*> positions, rotations, volumes, solids, materials;
93  };
94  mutable _checks checks;
95  void check(const std::string& name, const TNamed* n, std::map<std::string, const TNamed*>& array) const;
96  void checkPosition(const std::string& name, const TNamed* n) const {
97  check(name, n, checks.positions);
98  }
99  void checkRotation(const std::string& name, const TNamed* n) const {
100  check(name, n, checks.rotations);
101  }
102  void checkVolume(const std::string& name, const TNamed* n) const {
103  check(name, n, checks.volumes);
104  }
105  void checkShape(const std::string& name, const TNamed* n) const {
106  check(name, n, checks.solids);
107  }
108  void checkMaterial(const std::string& name, Material n) const {
109  check(name, n.ptr(), checks.materials);
110  }
111 
116  GeometryInfo();
117  };
118  typedef std::set<std::string> NameSet;
119 
124 
125  GeometryInfo& data() const {
126  return *m_dataPtr;
127  }
128 
130  void checkVolumes(const std::string& name, Volume volume) const;
131 
133  LCDDConverter(Detector& description);
134 
136  virtual ~LCDDConverter();
137 
140 
143 
146 
148  virtual void handleHeader() const;
149 
151  virtual xml_h handleMaterial(const std::string& name, Material medium) const;
152 
154  virtual xml_h handleElement(const std::string& name, Atom element) const;
155 
157  virtual xml_h handleSolid(const std::string& name, const TGeoShape* volume) const;
158 
160  virtual xml_h handleVolume(const std::string& name, Volume volume) const;
161  virtual xml_h handleVolumeVis(const std::string& name, const TGeoVolume* volume) const;
162  virtual void collectVolume(const std::string& name, const TGeoVolume* volume) const;
163 
165  virtual xml_h handlePlacement(const std::string& name, PlacedVolume node) const;
166 
169 
171  virtual xml_h handleRegion(const std::string& name, Region region) const;
172 
174  virtual xml_h handleVis(const std::string& name, VisAttr vis) const;
175 
177  virtual xml_h handleIdSpec(const std::string& name, IDDescriptor idspec) const;
178 
180  virtual xml_h handleLimitSet(const std::string& name, LimitSet limitset) const;
181 
183  virtual xml_h handleSensitive(const std::string& name, SensitiveDetector sens_det) const;
184 
186  virtual xml_h handleSegmentation(Segmentation seg) const;
187 
189  virtual xml_h handlePosition(const std::string& name, const TGeoMatrix* trafo) const;
190 
192  virtual xml_h handleRotation(const std::string& name, const TGeoMatrix* trafo) const;
193 
195  virtual xml_h handleField(const std::string& name, OverlayedField field) const;
196 
198  void handleProperties(Detector::Properties& prp) const;
199  };
200  } // End namespace xml
201 } // End namespace dd4hep
202 #endif // DDCORE_SRC_PLUGINS_LCDDCONVERTER_H
dd4hep::detail::LCDDConverter::VolumeMap
std::map< Volume, XmlElement * > VolumeMap
Definition: LCDDConverter.h:59
dd4hep::detail::LCDDConverter::PlacementMap
std::map< PlacedVolume, XmlElement * > PlacementMap
Definition: LCDDConverter.h:56
dd4hep::Atom
Handle class describing an element in the periodic table.
Definition: Objects.h:242
dd4hep::detail::LCDDConverter::GeometryInfo::doc_regions
xml_elt_t doc_regions
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::m_detDesc
Detector & m_detDesc
Reference to detector description.
Definition: LCDDConverter.h:121
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:44
Detector.h
dd4hep::detail::LCDDConverter::m_checkNames
NameSet m_checkNames
Definition: LCDDConverter.h:122
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:58
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:173
dd4hep::VisAttr
Handle class describing visualization attributes.
Definition: Objects.h:324
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:91
dd4hep::detail::LCDDConverter::GeometryInfo::checks
_checks checks
Definition: LCDDConverter.h:94
dd4hep::detail::LCDDConverter::GeometryInfo::doc_gdml
xml_elt_t doc_gdml
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::GeometryInfo::xmlSensDets
SensDetMap xmlSensDets
Definition: LCDDConverter.h:82
dd4hep::IDDescriptor
Class implementing the ID encoding of the detector response.
Definition: IDDescriptor.h:37
dd4hep::detail::LCDDConverter::RegionMap
std::map< Region, XmlElement * > RegionMap
Definition: LCDDConverter.h:57
dd4hep::detail::LCDDConverter::createDetector
xml_doc_t createDetector(DetElement top)
Create geometry conversion in Detector format.
Definition: LCDDConverter.cpp:1203
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:1010
dd4hep::detail::LCDDConverter::GeometryInfo::_checks::positions
std::map< std::string, const TNamed * > positions
Definition: LCDDConverter.h:92
dd4hep::detail::LCDDConverter::GeometryInfo::doc_solids
xml_elt_t doc_solids
Definition: LCDDConverter.h:115
dd4hep::detail::LCDDConverter::GeometryInfo::limits
std::set< LimitSet > limits
Definition: LCDDConverter.h:88
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:638
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:85
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:137
dd4hep::detail::LCDDConverter::data
GeometryInfo & data() const
Definition: LCDDConverter.h:125
dd4hep::detail::LCDDConverter
Geometry converter from dd4hep to Geant 4 in Detector format.
Definition: LCDDConverter.h:50
dd4hep::detail::LCDDConverter::GeometryInfo::doc_display
xml_elt_t doc_display
Definition: LCDDConverter.h:114
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:221
dd4hep::detail::LCDDConverter::GeometryInfo::xmlRegions
RegionMap xmlRegions
Definition: LCDDConverter.h:78
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:160
dd4hep::detail::LCDDConverter::GeometryInfo::_checks::solids
std::map< std::string, const TNamed * > solids
Definition: LCDDConverter.h:92
dd4hep::detail::LCDDConverter::GeometryInfo::doc_fields
xml_elt_t doc_fields
Definition: LCDDConverter.h:114
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:803
dd4hep::detail::LCDDConverter::XmlElement
xml::XmlElement XmlElement
Definition: LCDDConverter.h:52
dd4hep::detail::LCDDConverter::createVis
xml_doc_t createVis(DetElement top)
Create geometry conversion in Vis format.
Definition: LCDDConverter.cpp:1179
dd4hep::detail::LCDDConverter::GeometryInfo::doc_idDict
xml_elt_t doc_idDict
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::GeometryInfo::checkPosition
void checkPosition(const std::string &name, const TNamed *n) const
Definition: LCDDConverter.h:96
dd4hep::Material
Handle class describing a material.
Definition: Objects.h:272
dd4hep::detail::LCDDConverter::GeometryInfo::xmlSolids
SolidMap xmlSolids
Definition: LCDDConverter.h:75
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:760
dd4hep::detail::LCDDConverter::GeometryInfo::identity_pos
xml_h identity_pos
Definition: LCDDConverter.h:113
dd4hep::detail::LCDDConverter::GeometryInfo::xmlLimits
LimitMap xmlLimits
Definition: LCDDConverter.h:80
dd4hep::detail::LCDDConverter::GeometryInfo::checkMaterial
void checkMaterial(const std::string &name, Material n) const
Definition: LCDDConverter.h:108
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::detail::LCDDConverter::GeometryInfo::doc_define
xml_elt_t doc_define
Definition: LCDDConverter.h:115
dd4hep::detail::LCDDConverter::createGDML
xml_doc_t createGDML(DetElement top)
Create geometry conversion in GDML format.
Definition: LCDDConverter.cpp:1123
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:378
dd4hep::detail::LCDDConverter::FieldMap
std::map< OverlayedField, XmlElement * > FieldMap
Definition: LCDDConverter.h:63
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:62
dd4hep::detail::LCDDConverter::GeometryInfo::xmlVis
VisMap xmlVis
Definition: LCDDConverter.h:79
dd4hep::LimitSet
Handle class describing a set of limits as they are used for simulation.
Definition: Objects.h:425
dd4hep::detail::LCDDConverter::GeometryInfo::doc_header
xml_elt_t doc_header
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::GeometryInfo
Data structure of the geometry converter from dd4hep to Geant 4 in Detector format.
Definition: LCDDConverter.h:71
dd4hep::detail::LCDDConverter::GeometryInfo::checkVolume
void checkVolume(const std::string &name, const TNamed *n) const
Definition: LCDDConverter.h:102
dd4hep::detail::LCDDConverter::checkVolumes
void checkVolumes(const std::string &name, Volume volume) const
Data integrity checker.
Definition: LCDDConverter.cpp:779
dd4hep::detail::LCDDConverter::GeometryInfo::_checks::volumes
std::map< std::string, const TNamed * > volumes
Definition: LCDDConverter.h:92
dd4hep::detail::LCDDConverter::GeometryInfo::doc_detectors
xml_elt_t doc_detectors
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::GeometryInfo::regions
std::set< Region > regions
Definition: LCDDConverter.h:87
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:672
dd4hep::detail::LCDDConverter::GeometryInfo::identity_rot
xml_h identity_rot
Definition: LCDDConverter.h:113
dd4hep::detail::LCDDConverter::m_dataPtr
GeometryInfo * m_dataPtr
Definition: LCDDConverter.h:123
dd4hep::detail::LCDDConverter::VisMap
std::map< VisAttr, XmlElement * > VisMap
Definition: LCDDConverter.h:61
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:53
dd4hep::Region
Handle class describing a region as used in simulation.
Definition: Objects.h:462
dd4hep::detail::LCDDConverter::LimitMap
std::map< LimitSet, XmlElement * > LimitMap
Definition: LCDDConverter.h:55
dd4hep::detail::LCDDConverter::GeometryInfo::xmlVolumes
VolumeMap xmlVolumes
Definition: LCDDConverter.h:76
dd4hep::detail::LCDDConverter::~LCDDConverter
virtual ~LCDDConverter()
Standard destructor.
Definition: LCDDConverter.cpp:130
dd4hep::detail::LCDDConverter::GeometryInfo::_checks::materials
std::map< std::string, const TNamed * > materials
Definition: LCDDConverter.h:92
dd4hep::detail::LCDDConverter::GeometryInfo::doc
xml_doc_t doc
Definition: LCDDConverter.h:112
dd4hep::detail::LCDDConverter::handleProperties
void handleProperties(Detector::Properties &prp) const
Handle the geant 4 specific properties.
Definition: LCDDConverter.cpp:1034
dd4hep::detail::LCDDConverter::GeometryInfo::xmlElements
ElementMap xmlElements
Definition: LCDDConverter.h:73
dd4hep::detail::LCDDConverter::GeometryInfo::doc_limits
xml_elt_t doc_limits
Definition: LCDDConverter.h:114
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:845
dd4hep::detail::LCDDConverter::TrafoMap
std::map< const TGeoMatrix *, XmlElement * > TrafoMap
Definition: LCDDConverter.h:64
dd4hep::detail::LCDDConverter::GeometryInfo::sensitives
std::set< SensitiveDetector > sensitives
Definition: LCDDConverter.h:86
dd4hep::detail::LCDDConverter::GeometryInfo::xmlPositions
TrafoMap xmlPositions
Definition: LCDDConverter.h:83
dd4hep::detail::LCDDConverter::GeometryInfo::checkShape
void checkShape(const std::string &name, const TNamed *n) const
Definition: LCDDConverter.h:105
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:941
dd4hep::detail::LCDDConverter::GeometryInfo::doc_setup
xml_elt_t doc_setup
Definition: LCDDConverter.h:115
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:861
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:739
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:153
dd4hep::detail::LCDDConverter::handleHeader
virtual void handleHeader() const
Add header information in Detector format.
Definition: LCDDConverter.cpp:1084
dd4hep::detail::LCDDConverter::GeometryInfo::xmlIdSpecs
IdSpecMap xmlIdSpecs
Definition: LCDDConverter.h:81
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:116
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::detail::LCDDConverter::GeometryInfo::xmlPlacements
PlacementMap xmlPlacements
Definition: LCDDConverter.h:77
dd4hep::detail::LCDDConverter::LCDDConverter
LCDDConverter(Detector &description)
Initializing Constructor.
Definition: LCDDConverter.cpp:126
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:915
dd4hep::detail::LCDDConverter::GeometryInfo::_checks::rotations
std::map< std::string, const TNamed * > rotations
Definition: LCDDConverter.h:92
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:60
dd4hep::detail::LCDDConverter::GeometryInfo::xmlMaterials
MaterialMap xmlMaterials
Definition: LCDDConverter.h:74
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:883
dd4hep::detail::LCDDConverter::GeometryInfo::doc_root
xml_elt_t doc_root
Definition: LCDDConverter.h:114
dd4hep::detail::LCDDConverter::GeometryInfo::doc_structure
xml_elt_t doc_structure
Definition: LCDDConverter.h:115
dd4hep::detail::LCDDConverter::NameSet
std::set< std::string > NameSet
Definition: LCDDConverter.h:118
dd4hep::detail::LCDDConverter::GeometryInfo::GeometryInfo
GeometryInfo()
Helper constructor.
Definition: LCDDConverter.cpp:1285
dd4hep::detail::LCDDConverter::GeometryInfo::xmlRotations
TrafoMap xmlRotations
Definition: LCDDConverter.h:84
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:604
dd4hep::detail::LCDDConverter::GeometryInfo::doc_materials
xml_elt_t doc_materials
Definition: LCDDConverter.h:115
dd4hep::detail::LCDDConverter::MaterialMap
std::map< Material, XmlElement * > MaterialMap
Definition: LCDDConverter.h:54
dd4hep::detail::LCDDConverter::GeometryInfo::CheckIter
std::map< std::string, const TNamed * > CheckIter
Definition: LCDDConverter.h:90
dd4hep::detail::LCDDConverter::GeometryInfo::checkRotation
void checkRotation(const std::string &name, const TNamed *n) const
Definition: LCDDConverter.h:99
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:976
GeoHandler.h