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