File indexing completed on 2025-07-14 08:25:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Detector/ProtoBinning.hpp"
0013 #include "Acts/Geometry/Extent.hpp"
0014 #include "Acts/Plugins/DD4hep/DD4hepConversionHelpers.hpp"
0015 #include "Acts/Utilities/AxisFwd.hpp"
0016 #include "Acts/Utilities/BinningData.hpp"
0017
0018 #include <optional>
0019 #include <sstream>
0020 #include <string>
0021 #include <tuple>
0022 #include <vector>
0023
0024 #include <DDRec/DetectorData.h>
0025
0026 namespace Acts {
0027
0028 static std::vector<std::tuple<std::string, BinningValue>> allowedBinnings = {
0029 {"x", BinningValue::binX},
0030 {"y", BinningValue::binY},
0031 {"z", BinningValue::binZ},
0032 {"phi", BinningValue::binPhi},
0033 {"r", BinningValue::binR}};
0034
0035
0036
0037
0038
0039
0040 inline BinningValue stringToBinningValue(const std::string &binningString) {
0041 if (binningString == "x") {
0042 return BinningValue::binX;
0043 } else if (binningString == "y") {
0044 return BinningValue::binY;
0045 } else if (binningString == "z") {
0046 return BinningValue::binZ;
0047 } else if (binningString == "phi") {
0048 return BinningValue::binPhi;
0049 } else if (binningString == "r") {
0050 return BinningValue::binR;
0051 } else {
0052 throw std::invalid_argument("DD4hepBinningHelpers: Binning value " +
0053 binningString + " not allowed.");
0054 }
0055 }
0056
0057
0058
0059
0060
0061
0062
0063
0064 inline std::vector<BinningValue> stringToBinningValues(
0065 const std::string &binningString, const char &del = ',') {
0066 if (binningString.empty()) {
0067 return {};
0068 }
0069 std::vector<BinningValue> bBinning;
0070 std::stringstream s(binningString);
0071 std::string b = "";
0072 while (getline(s, b, del)) {
0073 bBinning.push_back(stringToBinningValue(b));
0074 }
0075 return bBinning;
0076 }
0077
0078 namespace DD4hepBinningHelpers {
0079
0080
0081
0082
0083
0084
0085
0086 std::vector<Acts::Experimental::ProtoBinning> convertBinning(
0087 const dd4hep::DetElement &dd4hepElement, const std::string &bname);
0088
0089 }
0090 }