Warning, file /DD4hep/DDCore/src/plugins/LCDDConverter.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef DDCORE_SRC_PLUGINS_LCDDCONVERTER_H
0015 #define DDCORE_SRC_PLUGINS_LCDDCONVERTER_H
0016
0017
0018 #include <DD4hep/Detector.h>
0019 #include <DD4hep/GeoHandler.h>
0020 #include <DD4hep/DetFactoryHelper.h>
0021
0022
0023 #include <set>
0024 #include <map>
0025 #include <vector>
0026
0027
0028 class TGeoVolume;
0029 class TGeoElement;
0030 class TGeoShape;
0031 class TGeoMedium;
0032 class TGeoNode;
0033 class TGeoMatrix;
0034
0035
0036 namespace dd4hep {
0037
0038
0039 namespace detail {
0040
0041
0042 class SensitiveDetectorObject;
0043
0044
0045
0046
0047
0048
0049
0050 class LCDDConverter: public GeoHandler {
0051 public:
0052 typedef xml::XmlElement XmlElement;
0053 typedef std::map<Atom, XmlElement*> ElementMap;
0054 typedef std::map<Material, XmlElement*> MaterialMap;
0055 typedef std::map<LimitSet, XmlElement*> LimitMap;
0056 typedef std::map<PlacedVolume, XmlElement*> PlacementMap;
0057 typedef std::map<Region, XmlElement*> RegionMap;
0058 typedef std::map<SensitiveDetector, XmlElement*> SensDetMap;
0059 typedef std::map<Volume, XmlElement*> VolumeMap;
0060 typedef std::map<IDDescriptor, XmlElement*> IdSpecMap;
0061 typedef std::map<VisAttr, XmlElement*> VisMap;
0062 typedef std::map<const TGeoShape*, XmlElement*> SolidMap;
0063 typedef std::map<OverlayedField, XmlElement*> FieldMap;
0064 typedef std::map<const TGeoMatrix*, XmlElement*> TrafoMap;
0065
0066
0067
0068
0069
0070
0071 class GeometryInfo: public GeoHandler::GeometryInfo {
0072 public:
0073 ElementMap xmlElements;
0074 MaterialMap xmlMaterials;
0075 SolidMap xmlSolids;
0076 VolumeMap xmlVolumes;
0077 PlacementMap xmlPlacements;
0078 RegionMap xmlRegions;
0079 VisMap xmlVis;
0080 LimitMap xmlLimits;
0081 IdSpecMap xmlIdSpecs;
0082 SensDetMap xmlSensDets;
0083 TrafoMap xmlPositions;
0084 TrafoMap xmlRotations;
0085 FieldMap xmlFields;
0086 std::set<SensitiveDetector> sensitives;
0087 std::set<Region> regions;
0088 std::set<LimitSet> limits;
0089
0090 typedef std::map<std::string, const TNamed*> CheckIter;
0091 struct _checks {
0092 std::map<std::string, const TNamed*> positions, rotations, volumes, solids, materials;
0093 };
0094 mutable _checks checks;
0095 void check(const std::string& name, const TNamed* n, std::map<std::string, const TNamed*>& array) const;
0096 void checkPosition(const std::string& name, const TNamed* n) const {
0097 check(name, n, checks.positions);
0098 }
0099 void checkRotation(const std::string& name, const TNamed* n) const {
0100 check(name, n, checks.rotations);
0101 }
0102 void checkVolume(const std::string& name, const TNamed* n) const {
0103 check(name, n, checks.volumes);
0104 }
0105 void checkShape(const std::string& name, const TNamed* n) const {
0106 check(name, n, checks.solids);
0107 }
0108 void checkMaterial(const std::string& name, Material n) const {
0109 check(name, n.ptr(), checks.materials);
0110 }
0111
0112 xml_doc_t doc;
0113 xml_h identity_rot, identity_pos;
0114 xml_elt_t doc_root, doc_header, doc_idDict, doc_detectors, doc_limits, doc_regions, doc_display, doc_gdml, doc_fields,
0115 doc_define, doc_materials, doc_solids, doc_structure, doc_setup;
0116 GeometryInfo();
0117 };
0118 typedef std::set<std::string> NameSet;
0119
0120
0121 Detector& m_detDesc;
0122 mutable NameSet m_checkNames;
0123 GeometryInfo* m_dataPtr;
0124
0125 GeometryInfo& data() const {
0126 return *m_dataPtr;
0127 }
0128
0129
0130 void checkVolumes(const std::string& name, Volume volume) const;
0131
0132
0133 LCDDConverter(Detector& description);
0134
0135
0136 virtual ~LCDDConverter();
0137
0138
0139 xml_doc_t createGDML(DetElement top);
0140
0141
0142 xml_doc_t createDetector(DetElement top);
0143
0144
0145 xml_doc_t createVis(DetElement top);
0146
0147
0148 virtual void handleHeader() const;
0149
0150
0151 virtual xml_h handleMaterial(const std::string& name, Material medium) const;
0152
0153
0154 virtual xml_h handleElement(const std::string& name, Atom element) const;
0155
0156
0157 virtual xml_h handleSolid(const std::string& name, const TGeoShape* volume) const;
0158
0159
0160 virtual xml_h handleVolume(const std::string& name, Volume volume) const;
0161 virtual xml_h handleVolumeVis(const std::string& name, const TGeoVolume* volume) const;
0162 virtual void collectVolume(const std::string& name, const TGeoVolume* volume) const;
0163
0164
0165 virtual xml_h handlePlacement(const std::string& name, PlacedVolume node) const;
0166
0167
0168
0169
0170
0171 virtual xml_h handleRegion(const std::string& name, Region region) const;
0172
0173
0174 virtual xml_h handleVis(const std::string& name, VisAttr vis) const;
0175
0176
0177 virtual xml_h handleIdSpec(const std::string& name, IDDescriptor idspec) const;
0178
0179
0180 virtual xml_h handleLimitSet(const std::string& name, LimitSet limitset) const;
0181
0182
0183 virtual xml_h handleSensitive(const std::string& name, SensitiveDetector sens_det) const;
0184
0185
0186 virtual xml_h handleSegmentation(Segmentation seg) const;
0187
0188
0189 virtual xml_h handlePosition(const std::string& name, const TGeoMatrix* trafo) const;
0190
0191
0192 virtual xml_h handleRotation(const std::string& name, const TGeoMatrix* trafo) const;
0193
0194
0195 virtual xml_h handleField(const std::string& name, OverlayedField field) const;
0196
0197
0198 void handleProperties(Detector::Properties& prp) const;
0199 };
0200 }
0201 }
0202 #endif