14 #include <DD4hep/DetElement.h>
15 #include <DD4hep/DetFactoryHelper.h>
16 #include <DD4hep/Objects.h>
17 #include <DDRec/DetectorData.h>
29 auto* params = elt.extension<dd4hep::rec::VariantParameters>(
false);
30 if (params ==
nullptr) {
31 throw std::runtime_error{
"Detector Element has no VariantParameters"};
33 return params->get<
T>(key);
39 inline dd4hep::rec::VariantParameters&
getParams(dd4hep::DetElement& elt) {
40 auto* params = elt.extension<dd4hep::rec::VariantParameters>(
false);
41 if (params ==
nullptr) {
42 throw std::runtime_error{
"Detector Element has no VariantParameters"};
50 inline const dd4hep::rec::VariantParameters&
getParams(
51 const dd4hep::DetElement& elt) {
52 const auto* params = elt.extension<dd4hep::rec::VariantParameters>(
false);
53 if (params ==
nullptr) {
54 throw std::runtime_error{
"Detector Element has no VariantParameters"};
70 auto* params = elt.extension<dd4hep::rec::VariantParameters>(
false);
71 if (params ==
nullptr) {
74 return params->value_or<
T>(key, alternative);
83 auto* params = elt.extension<dd4hep::rec::VariantParameters>(
false);
84 if (params ==
nullptr) {
87 return params->contains(key);
94 return elt.extension<dd4hep::rec::VariantParameters>(
false) !=
nullptr;
108 template <
typename value_type>
112 if (node.hasAttr(dd4hep::xml::Strng_t(attrName.c_str()))) {
113 return node.attr<
value_type>(attrName.c_str());
115 return fallbackValue;
128 template <
typename value_type>
129 std::vector<value_type>
extractSeries(
const dd4hep::DetElement& dd4hepElement,
132 std::vector<value_type>
series = {};
135 int nVals = getParamOr<int>(bname +
"_n", dd4hepElement, fallBack);
136 series.reserve(nVals);
137 for (
auto ib = 0;
ib < nVals; ++
ib) {
138 auto val = unitConversion *
141 series.push_back(val);
158 unitConversion * getParamOr<ActsScalar>(bname +
"_x", dd4hepElement, 0.);
160 unitConversion * getParamOr<ActsScalar>(bname +
"_y", dd4hepElement, 0.);
162 unitConversion * getParamOr<ActsScalar>(bname +
"_z", dd4hepElement, 0.);
163 transform.pretranslate(
Vector3(x, y, z));