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