File indexing completed on 2026-03-28 07:45:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Utilities/Histogram.hpp"
0010
0011 #include <cassert>
0012 #include <vector>
0013
0014 namespace Acts::Experimental {
0015
0016
0017 Histogram1 projectionX(const Histogram2& hist2d) {
0018 auto projectedHist = boost::histogram::algorithm::project(
0019 hist2d.histogram(), std::integral_constant<unsigned, 0>{});
0020
0021
0022 std::array<AxisVariant, 1> axes = {projectedHist.axis(0)};
0023
0024 return Histogram1(hist2d.name() + "_projX", hist2d.title() + " projection X",
0025 axes);
0026 }
0027
0028 Histogram1 projectionY(const Histogram2& hist2d) {
0029 auto projectedHist = boost::histogram::algorithm::project(
0030 hist2d.histogram(), std::integral_constant<unsigned, 1>{});
0031
0032
0033 std::array<AxisVariant, 1> axes = {projectedHist.axis(0)};
0034
0035 return Histogram1(hist2d.name() + "_projY", hist2d.title() + " projection Y",
0036 axes);
0037 }
0038
0039 std::vector<double> extractBinEdges(const AxisVariant& axis) {
0040 assert(axis.size() > 0 && "Axis must have at least one bin");
0041 std::vector<double> edges(axis.size() + 1);
0042 for (int i = 0; i < axis.size(); ++i) {
0043 edges.at(i) = axis.bin(i).lower();
0044 }
0045 edges.back() = axis.bin(axis.size() - 1).upper();
0046
0047 return edges;
0048 }
0049
0050 }