Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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 @@ -335,7 +335,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 @@ -61,17 +61,15 @@ const std::string& axisDirectionName(AxisDirection aDir);
/// @return the output stream
std::ostream& operator<<(std::ostream& os, AxisDirection aDir);

/// 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
1 change: 0 additions & 1 deletion Core/include/Acts/Utilities/IAxis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Utilities/AxisDefinitions.hpp"

#include <iosfwd>
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
87 changes: 58 additions & 29 deletions Core/src/Utilities/ProtoAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@

#include <sstream>

Acts::ProtoAxis::ProtoAxis(Acts::AxisBoundaryType abType,
const std::vector<double>& edges)
namespace Acts {

ProtoAxis::ProtoAxis(AxisBoundaryType abType, const std::vector<double>& edges)
: m_axis(IAxis::createVariable(abType, edges)) {}

Acts::ProtoAxis::ProtoAxis(AxisBoundaryType abType, double minE, double maxE,
std::size_t nbins)
ProtoAxis::ProtoAxis(AxisBoundaryType abType, double minE, double maxE,
std::size_t nbins)
: m_axis(IAxis::createEquidistant(abType, minE, maxE, nbins)) {}

Acts::ProtoAxis::ProtoAxis(AxisBoundaryType abType, std::size_t nbins)
ProtoAxis::ProtoAxis(AxisBoundaryType abType, std::size_t nbins)
: m_axis(IAxis::createEquidistant(abType, 0., 1., nbins)),
m_autorange(true) {}

Acts::ProtoAxis::ProtoAxis(const ProtoAxis& other)
: m_autorange(other.m_autorange) {
ProtoAxis::ProtoAxis(const ProtoAxis& other) : m_autorange(other.m_autorange) {
const auto& axis = other.getAxis();
if (!m_autorange) {
const auto& edges = axis.getBinEdges();
Expand All @@ -39,7 +39,7 @@ Acts::ProtoAxis::ProtoAxis(const ProtoAxis& other)
}
}

Acts::ProtoAxis& Acts::ProtoAxis::operator=(const ProtoAxis& other) {
ProtoAxis& ProtoAxis::operator=(const ProtoAxis& other) {
if (this != &other) {
m_autorange = other.m_autorange;
const auto& axis = other.getAxis();
Expand All @@ -59,11 +59,11 @@ Acts::ProtoAxis& Acts::ProtoAxis::operator=(const ProtoAxis& other) {
return *this;
}

const Acts::IAxis& Acts::ProtoAxis::getAxis() const {
const IAxis& ProtoAxis::getAxis() const {
return *m_axis;
}

void Acts::ProtoAxis::setRange(double minE, double maxE) {
void ProtoAxis::setRange(double minE, double maxE) {
if (minE > maxE) {
throw std::invalid_argument(
"ProtoAxis::setRange: minE > maxE is not allowed.");
Expand All @@ -88,15 +88,44 @@ void Acts::ProtoAxis::setRange(double minE, double maxE) {
m_autorange = false;
}

bool Acts::ProtoAxis::isAutorange() const {
bool ProtoAxis::isAutorange() const {
return m_autorange;
}

void Acts::ProtoAxis::toStream(std::ostream& os) const {
void ProtoAxis::toStream(std::ostream& os) const {
os << toString();
}

std::string Acts::ProtoAxis::toString() const {
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();
ss << "ProtoAxis: " << axis.getNBins() << " bins";
Expand All @@ -112,38 +141,36 @@ std::string Acts::ProtoAxis::toString() const {
}

// Ostream operator implementation
std::ostream& Acts::operator<<(std::ostream& os,
const std::vector<ProtoAxis>& as) {
std::ostream& operator<<(std::ostream& os, const std::vector<ProtoAxis>& as) {
for (const auto& a : as) {
os << a.toString() << '\n';
}
return os;
}

Acts::DirectedProtoAxis::DirectedProtoAxis(AxisDirection axisDir,
AxisBoundaryType abType,
const std::vector<double>& edges)
DirectedProtoAxis::DirectedProtoAxis(AxisDirection axisDir,
AxisBoundaryType abType,
const std::vector<double>& edges)
: ProtoAxis(abType, edges), m_direction(axisDir) {}

Acts::DirectedProtoAxis::DirectedProtoAxis(AxisDirection axisDir,
AxisBoundaryType abType, double minE,
double maxE, std::size_t nbins)
DirectedProtoAxis::DirectedProtoAxis(AxisDirection axisDir,
AxisBoundaryType abType, double minE,
double maxE, std::size_t nbins)
: ProtoAxis(abType, minE, maxE, nbins), m_direction(axisDir) {}

Acts::DirectedProtoAxis::DirectedProtoAxis(AxisDirection axisDir,
AxisBoundaryType abType,
std::size_t nbins)
DirectedProtoAxis::DirectedProtoAxis(AxisDirection axisDir,
AxisBoundaryType abType, std::size_t nbins)
: ProtoAxis(abType, nbins), m_direction(axisDir) {}

Acts::AxisDirection Acts::DirectedProtoAxis::getAxisDirection() const {
AxisDirection DirectedProtoAxis::getAxisDirection() const {
return m_direction;
}

void Acts::DirectedProtoAxis::toStream(std::ostream& os) const {
void DirectedProtoAxis::toStream(std::ostream& os) const {
os << toString();
}

std::string Acts::DirectedProtoAxis::toString() const {
std::string DirectedProtoAxis::toString() const {
std::stringstream ss;
const auto& axis = getAxis();
ss << "DirectedProtoAxis: " << axis.getNBins() << " bins in "
Expand All @@ -160,10 +187,12 @@ std::string Acts::DirectedProtoAxis::toString() const {
}

// Ostream operator implementation vector of directed proto axes
std::ostream& Acts::operator<<(std::ostream& os,
const std::vector<DirectedProtoAxis>& as) {
std::ostream& operator<<(std::ostream& os,
const std::vector<DirectedProtoAxis>& as) {
for (const auto& a : as) {
os << a << '\n';
}
return os;
}

} // namespace Acts
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
Loading
Loading