File indexing completed on 2025-08-05 08:10:16
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Plugins/DD4hep/DD4hepBinningHelpers.hpp"
0010
0011 std::vector<Acts::Experimental::ProtoBinning>
0012 Acts::DD4hepBinningHelpers::convertBinning(
0013 const dd4hep::DetElement &dd4hepElement, const std::string &bname) {
0014
0015 std::vector<Experimental::ProtoBinning> protoBinnings;
0016
0017 for (const auto &[ab, bVal] : allowedBinnings) {
0018 auto type =
0019 getParamOr<std::string>(bname + "_" + ab + "_type", dd4hepElement, "");
0020 if (!type.empty()) {
0021
0022 auto bType = Acts::detail::AxisBoundaryType::Bound;
0023
0024 detail::AxisType aType = type == "equidistant"
0025 ? detail::AxisType::Equidistant
0026 : detail::AxisType::Variable;
0027 int nBins = getParamOr<int>(bname + "_" + ab + "_n", dd4hepElement, 0);
0028 int nExpansion =
0029 getParamOr<int>(bname + "_" + ab + "_exp", dd4hepElement, 0);
0030
0031 bool autoRange = getParamOr<bool>(bname + "_" + ab + "_autorange",
0032 dd4hepElement, false);
0033
0034 if (aType == detail::AxisType::Equidistant) {
0035 if (autoRange) {
0036 protoBinnings.push_back(
0037 Experimental::ProtoBinning(bVal, bType, nBins, nExpansion));
0038 } else {
0039
0040 ActsScalar minDefault = bVal == binPhi ? -M_PI : 0.;
0041 ActsScalar maxDefault = bVal == binPhi ? M_PI : 0.;
0042 auto min = getParamOr<ActsScalar>(bname + "_" + ab + "_min",
0043 dd4hepElement, minDefault);
0044 auto max = getParamOr<ActsScalar>(bname + "_" + ab + "_max",
0045 dd4hepElement, maxDefault);
0046
0047 if (bVal == binPhi && (max - min) > 1.9 * M_PI) {
0048 bType = Acts::detail::AxisBoundaryType::Closed;
0049 }
0050 protoBinnings.push_back(Experimental::ProtoBinning(
0051 bVal, bType, min, max, nBins, nExpansion));
0052 }
0053 } else {
0054
0055 std::vector<ActsScalar> edges;
0056 for (int ib = 0; ib <= nBins; ++ib) {
0057 edges.push_back(getParamOr<ActsScalar>(
0058 bname + "_" + ab + "_b" + std::to_string(ib), dd4hepElement, 0.));
0059 }
0060
0061 if (bVal == binPhi && (edges.back() - edges.front()) > 1.9 * M_PI) {
0062 bType = Acts::detail::AxisBoundaryType::Closed;
0063 }
0064 protoBinnings.push_back(
0065 Experimental::ProtoBinning(bVal, bType, edges, nExpansion));
0066 }
0067 }
0068 }
0069 return protoBinnings;
0070 }