Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/include/Acts/Utilities/Axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class Axis<AxisType::Equidistant, bdt> : public IAxis {
/// bounds, that is \f$l <= x < u\f$ if the value @c x lies within a
/// bin with lower bound @c l and upper bound @c u.
/// @note Bin indices start at @c 1. The underflow bin has the index @c 0
/// while the index <tt>nBins + 1</tt> indicates the overflow bin .
/// while the index <tt>nBins + 1</tt> indicates the overflow bin.
std::size_t getBin(double x) const final {
return wrapBin(
static_cast<int>(std::floor((x - getMin()) / getBinWidth()) + 1));
Expand Down
14 changes: 6 additions & 8 deletions Core/include/Acts/Utilities/AxisDefinitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,15 @@ std::string axesDirectionName(const std::vector<AxisDirection>& manyDir);
std::ostream& operator<<(std::ostream& os,
const std::vector<AxisDirection>& manyDir);

/// Enum which determines how the axis handle its outer boundaries
/// possible values values
/// Enum which determines how the axis handle its outer boundaries possible
/// values values
enum class AxisBoundaryType {
/// Default behaviour: out of bounds
/// positions are filled into the over or underflow bins
/// Default behaviour: out of bounds positions are filled into the over or
/// underflow bins
Open,
/// Out-of-bounds positions resolve to first/last bin
/// respectively
/// Out-of-bounds positions resolve to first/last bin respectively
Bound,
/// Out-of-bounds positions resolve to the outermost
/// bin on the opposite side
/// Out-of-bounds positions resolve to the outermost bin on the opposite side
Closed,
};

Expand Down
61 changes: 54 additions & 7 deletions Core/include/Acts/Utilities/ProtoAxis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#pragma once

#include "Acts/Utilities/Axis.hpp"
#include "Acts/Utilities/AxisDefinitions.hpp"
#include "Acts/Utilities/Grid.hpp"
#include "Acts/Utilities/IAxis.hpp"
Expand All @@ -17,6 +16,7 @@
#include <vector>

namespace Acts {

/// This class is a pure run-time placeholder for the axis definition
///
/// The IAxis allows via the visitor pattern to access the actual axis type
Expand All @@ -31,7 +31,7 @@ class ProtoAxis {
///
/// @param abType the axis boundary type
/// @param edges the bin edges (variable binning)
ProtoAxis(Acts::AxisBoundaryType abType, const std::vector<double>& edges);
ProtoAxis(AxisBoundaryType abType, const std::vector<double>& edges);

/// Convenience constructors - for equidistant binning
///
Expand Down Expand Up @@ -65,8 +65,6 @@ class ProtoAxis {
/// @return Reference to this ProtoAxis for assignment chaining
ProtoAxis& operator=(ProtoAxis&&) = default;

~ProtoAxis() = default;

/// @brief Return the IAxis representation
///
/// @return @c AxisType of this axis
Expand Down Expand Up @@ -96,6 +94,46 @@ class ProtoAxis {
/// @return the string representation
std::string toString() const;

/// Get the minimum edge of the axis
/// @return the minimum edge of the axis
double min() const;

/// Get the maximum edge of the axis
/// @return the maximum edge of the axis
double max() const;

/// Get the number of bins
/// @return the number of bins
std::size_t nBins() const;

/// Compute the center of a given bin
/// @param bin the bin number for which to compute the center
/// @return the center of the given bin
double binCenter(std::size_t bin) const;

/// Compute the width of a given bin
/// @param bin the bin number for which to compute the width
/// @return the width of the given bin
double binWidth(std::size_t bin) const;

/// Compute the bin number for a given value
/// @param value the value for which to compute the bin number
/// @return the bin number for the given value
std::size_t bin(double value) const;

/// Get the bin edges
/// @return the bin edges
std::vector<double> binEdges() const;

/// Check if two axes are equal
/// @param lhs first axis
/// @param rhs second axis
/// @return true if the axes are equal
friend bool operator==(const ProtoAxis& lhs, const ProtoAxis& rhs) {
return lhs.getAxis() == rhs.getAxis() &&
lhs.isAutorange() == rhs.isAutorange();
}

private:
/// @brief Hidden friend ostream operator
/// @param os the output stream
Expand Down Expand Up @@ -167,7 +205,7 @@ std::unique_ptr<IGrid> makeGrid(const ProtoAxis& a, const ProtoAxis& b) {
}

/// A Directed proto axis
struct DirectedProtoAxis : public ProtoAxis {
struct DirectedProtoAxis final : public ProtoAxis {
public:
/// Convenience constructors - for variable binning
///
Expand Down Expand Up @@ -197,8 +235,6 @@ struct DirectedProtoAxis : public ProtoAxis {
DirectedProtoAxis(AxisDirection axisDir, AxisBoundaryType abType,
std::size_t nbins);

virtual ~DirectedProtoAxis() = default;

/// Access to the AxisDirection
/// @return the axis direction
AxisDirection getAxisDirection() const;
Expand All @@ -207,6 +243,17 @@ struct DirectedProtoAxis : public ProtoAxis {
/// @return the string representation
std::string toString() const;

/// Check if two axes are equal
/// @param lhs first axis
/// @param rhs second axis
/// @return true if the axes are equal
friend bool operator==(const DirectedProtoAxis& lhs,
const DirectedProtoAxis& rhs) {
return operator==(static_cast<const ProtoAxis&>(lhs),
static_cast<const ProtoAxis&>(rhs)) &&
lhs.getAxisDirection() == rhs.getAxisDirection();
}

private:
/// @brief Hidden friend ostream operator
/// @param os the output stream
Expand Down
29 changes: 29 additions & 0 deletions Core/src/Utilities/ProtoAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,35 @@ void ProtoAxis::toStream(std::ostream& os) const {
os << toString();
}

double ProtoAxis::min() const {
return getAxis().getMin();
}

double ProtoAxis::max() const {
return getAxis().getMax();
}

std::size_t ProtoAxis::nBins() const {
return getAxis().getNBins();
}

double ProtoAxis::binCenter(const std::size_t bin) const {
return 0.5 * (getAxis().getBinEdges().at(bin) +
getAxis().getBinEdges().at(bin + 1));
}

double ProtoAxis::binWidth(const std::size_t bin) const {
return getAxis().getBinEdges().at(bin + 1) - getAxis().getBinEdges().at(bin);
}

std::size_t ProtoAxis::bin(const double value) const {
return getAxis().getBin(value);
}

std::vector<double> ProtoAxis::binEdges() const {
return getAxis().getBinEdges();
}

std::string ProtoAxis::toString() const {
std::stringstream ss;
const auto& axis = getAxis();
Expand Down
2 changes: 1 addition & 1 deletion Examples/Algorithms/Digitization/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
acts_add_library(
ExamplesDigitization
src/DigitizationAlgorithm.cpp
src/DigitizationConfig.cpp
src/GeometricConfig.cpp
src/DigitizationCoordinatesConverter.cpp
src/MeasurementCreation.cpp
src/DigitizationConfigurator.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Utilities/BinUtility.hpp"
#include "Acts/Utilities/ProtoAxis.hpp"
#include "Acts/Utilities/Result.hpp"
#include "ActsExamples/Digitization/Smearers.hpp"
#include "ActsExamples/Framework/RandomNumbers.hpp"
Expand All @@ -28,18 +28,16 @@ namespace ActsExamples {

/// Configuration struct for geometric digitization
///
/// If this is defined, then the geometric digitization
/// will create clusters with cells.
/// The BinUtility defines the segmentation and which parameters
/// are defined by this.
///
/// If this is defined, then the geometric digitization will create clusters
/// with cells. The DirectedProtoAxis defines the segmentation and which
/// parameters are defined by this.
struct GeometricConfig {
// The dimensions of the measurement
std::vector<Acts::BoundIndices> indices = {};
std::vector<Acts::BoundIndices> indices;

/// The (multidimensional) binning definition for the segmentation of the
/// sensor
Acts::BinUtility segmentation;
std::vector<Acts::DirectedProtoAxis> segmentation;

/// The thickness of the sensor
double thickness = 0.;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "Acts/Clusterization/Clusterization.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Utilities/BinUtility.hpp"
#include "ActsExamples/Digitization/MeasurementCreation.hpp"
#include "ActsExamples/EventData/Cluster.hpp"
#include "ActsExamples/EventData/SimHit.hpp"
Expand All @@ -35,7 +34,7 @@ struct ModuleValue {

class ModuleClusters {
public:
ModuleClusters(Acts::BinUtility segmentation,
ModuleClusters(std::vector<Acts::DirectedProtoAxis> segmentation,
std::vector<Acts::BoundIndices> geoIndices, bool merge,
double nsigma, bool commonCorner)
: m_segmentation(std::move(segmentation)),
Expand All @@ -49,7 +48,7 @@ class ModuleClusters {
digitizedParameters();

private:
Acts::BinUtility m_segmentation;
std::vector<Acts::DirectedProtoAxis> m_segmentation;
std::vector<Acts::BoundIndices> m_geoIndices;
std::vector<ModuleValue> m_moduleValues;
bool m_merge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/Utilities/BinUtility.hpp"
#include "ActsExamples/Digitization/ModuleClusters.hpp"
#include "ActsExamples/EventData/GeometryContainers.hpp"
#include "ActsExamples/EventData/Index.hpp"
Expand Down Expand Up @@ -359,8 +358,6 @@ DigitizedParameters DigitizationAlgorithm::localParameters(
RandomEngine& rng) const {
DigitizedParameters dParameters;

const auto& binningData = geoCfg.segmentation.binningData();

// For digital readout, the weight needs to be split in x and y
std::array<double, 2u> pos = {0., 0.};
std::array<double, 2u> totalWeight = {0., 0.};
Expand All @@ -383,12 +380,12 @@ DigitizedParameters DigitizationAlgorithm::localParameters(
// only fill component of this row/column if not yet filled
if (!componentChannels[ib].contains(bin[ib])) {
totalWeight[ib] += weight;
pos[ib] += weight * binningData[ib].center(bin[ib]);
pos[ib] += weight * geoCfg.segmentation.at(ib).binCenter(bin[ib]);
componentChannels[ib].insert(bin[ib]);
}
} else {
totalWeight[ib] += weight;
pos[ib] += weight * binningData[ib].center(bin[ib]);
pos[ib] += weight * geoCfg.segmentation.at(ib).binCenter(bin[ib]);
}
// min max channels
bmin[ib] = std::min(bmin[ib], static_cast<std::size_t>(bin[ib]));
Expand Down
Loading
Loading