From bcc70a308d6cd60b43146fabefdb109b372d9457 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Tue, 9 Feb 2016 14:16:14 +0000 Subject: [PATCH] - added utility DD4hep::XML::setDetectorTypeFlag() to set the TypeFlag from xml element <type_flag type="0x42"/> --- DDCore/include/XML/Utilities.h | 11 +++++++++++ DDCore/src/XML/Utilities.cpp | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/DDCore/include/XML/Utilities.h b/DDCore/include/XML/Utilities.h index 010e0c7fc..6fb9a2737 100644 --- a/DDCore/include/XML/Utilities.h +++ b/DDCore/include/XML/Utilities.h @@ -47,6 +47,17 @@ namespace DD4hep { Geometry::Volume createPlacedEnvelope( DD4hep::Geometry::LCDD& lcdd, DD4hep::XML::Handle_t e , DD4hep::Geometry::DetElement sdet ) ; + + + + /** Sets the type flag specified in the \<type_flags\> element for the given DetElement, example: <br> + @verbatim + <type_flags type=" DetType_TRACKER + DetType_PIXEL + DetType_VERTEX "/> + @endverbatim + * @author F.Gaede, DESY + */ + void setDetectorTypeFlag( DD4hep::XML::Handle_t e, DD4hep::Geometry::DetElement sdet ) ; + } /* End namespace XML */ } /* End namespace DD4hep */ #endif /* DD4hep_XML_XMLUTILITIES_H */ diff --git a/DDCore/src/XML/Utilities.cpp b/DDCore/src/XML/Utilities.cpp index df6cd5a88..f1d707b1b 100644 --- a/DDCore/src/XML/Utilities.cpp +++ b/DDCore/src/XML/Utilities.cpp @@ -122,3 +122,19 @@ Geometry::Volume DD4hep::XML::createPlacedEnvelope( DD4hep::Geometry::LCDD& lcdd return envelope ; } + + +void DD4hep::XML::setDetectorTypeFlag( DD4hep::XML::Handle_t e, DD4hep::Geometry::DetElement sdet ){ + + xml_det_t x_det = e; + string det_name = x_det.nameStr(); + + xml_comp_t x_dettype = x_det.child( DD4hep::XML::Strng_t("type_flags") ) ; + + unsigned int typeFlag = x_dettype.type() ; + + printout(DEBUG,"Utilities","+++ setDetectorTypeFlags for detector :%s set to 0x%x", det_name.c_str(), typeFlag ) ; + + sdet.setTypeFlag( typeFlag ) ; + +} -- GitLab