ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
Acts::AxisSpec Class Reference

Variant-like spec of an axis that builds IAxis objects. More...

#include <Acts/Utilities/AxisSpec.hpp>

Classes

struct  DeferredVariableParams
 Parameters for a variable axis whose bin edges are relative and scaled onto the range supplied by the consumer. More...
struct  EquidistantParams
 Parameters for an equidistant axis. More...
struct  VariableParams
 Parameters for a variable axis with absolute bin edges. More...

Public Types

using Options = AxisSpecOptions
 Axis properties supplied by the consumer at build time.

Public Member Functions

const DeferredVariableParamsasDeferredVariable () const
 Get the spec as deferred variable parameters.
const EquidistantParamsasEquidistant () const
 Get the spec as equidistant parameters.
const VariableParamsasVariable () const
 Get the spec as variable parameters.
std::optional< AxisBoundaryTypeboundaryType () const
 Get the boundary type of the axis.
std::unique_ptr< IAxisbuildAxis (const Options &options={}) const
 Build the axis, filling in the properties the spec leaves open and validating the ones it fixes.
std::optional< AxisDirectiondirection () const
 Get the direction of the axis.
bool isDeferred () const
 Check if the spec needs Options to build, i.e.
bool isDeferredVariable () const
 Check if the spec holds normalized instead of absolute bin edges.
bool isEquidistant () const
 Check if the spec produces an equidistant axis.
bool isVariable () const
 Check if the spec produces a variable axis.
std::size_t nBins () const
 Get the number of bins.
AxisSpec toDeferred () const
 Get the counterpart that leaves every property to the consumer: an equidistant spec keeps only its number of bins, a variable one its edges normalized to [0, 1].
std::string toString () const
 Get a string representation of this spec.
AxisSpec withDirection (AxisDirection direction) const
 Get a copy of this spec with the given direction attached.

Static Public Member Functions

static AxisSpec DeferredEquidistant (std::size_t nBins, std::optional< AxisDirection > direction=std::nullopt)
 Equidistant axis with only the number of bins fixed.
static AxisSpec DeferredVariable (std::vector< double > normalizedEdges, std::optional< AxisBoundaryType > boundaryType=std::nullopt, std::optional< AxisDirection > direction=std::nullopt)
 Variable axis whose normalized edges are scaled onto the range supplied by the consumer.
static AxisSpec Equidistant (std::size_t nBins, std::optional< double > min=std::nullopt, std::optional< double > max=std::nullopt, std::optional< AxisBoundaryType > boundaryType=std::nullopt, std::optional< AxisDirection > direction=std::nullopt)
 Equidistant axis; every property but the number of bins may be left to the consumer.
static AxisSpec FromAxis (const IAxis &axis)
 Capture an existing axis as a fully specified spec.
static AxisSpec Variable (std::vector< double > edges, std::optional< AxisBoundaryType > boundaryType=std::nullopt, std::optional< AxisDirection > direction=std::nullopt)
 Variable axis with absolute bin edges.

Detailed Description

Variant-like spec of an axis that builds IAxis objects.

Every property except the binning structure itself is optional. What the spec leaves open is supplied by the consumer as Options at build time, e.g. from the bounds of the surface the axis is attached to. This models proto material binning, where a configuration may fix the number of bins but not the range, or a range but not whether the axis wraps.

Per property the rule is the same: it has to be given by exactly one side, or by both with the same value. Supplying a property that the spec already fixes therefore validates it instead of overriding it, and a property that neither side gives is an error.

Member Function Documentation

◆ asDeferredVariable()

const DeferredVariableParams & Acts::AxisSpec::asDeferredVariable ( ) const

Get the spec as deferred variable parameters.

Exceptions
std::bad_variant_accessif another alternative is held
Returns
reference to the deferred variable parameters

◆ asEquidistant()

const EquidistantParams & Acts::AxisSpec::asEquidistant ( ) const

Get the spec as equidistant parameters.

Exceptions
std::bad_variant_accessif another alternative is held
Returns
reference to the equidistant parameters

◆ asVariable()

const VariableParams & Acts::AxisSpec::asVariable ( ) const

Get the spec as variable parameters.

Exceptions
std::bad_variant_accessif another alternative is held
Returns
reference to the variable parameters

◆ boundaryType()

std::optional< AxisBoundaryType > Acts::AxisSpec::boundaryType ( ) const

Get the boundary type of the axis.

Returns
the boundary type if the spec fixes it

◆ buildAxis()

std::unique_ptr< IAxis > Acts::AxisSpec::buildAxis ( const Options & options = {}) const

Build the axis, filling in the properties the spec leaves open and validating the ones it fixes.

Parameters
optionsthe properties supplied by the consumer
Exceptions
std::domain_errorif a property is given by neither side
std::invalid_argumentif a property is given by both sides with different values, or the resulting range is invalid
Returns
the created axis

◆ DeferredEquidistant()

AxisSpec Acts::AxisSpec::DeferredEquidistant ( std::size_t nBins,
std::optional< AxisDirection > direction = std::nullopt )
static

Equidistant axis with only the number of bins fixed.

Parameters
nBinsthe number of bins
directionthe optional direction of the axis
Exceptions
std::invalid_argumentif nBins == 0
Returns
the equidistant spec

◆ DeferredVariable()

AxisSpec Acts::AxisSpec::DeferredVariable ( std::vector< double > normalizedEdges,
std::optional< AxisBoundaryType > boundaryType = std::nullopt,
std::optional< AxisDirection > direction = std::nullopt )
static

Variable axis whose normalized edges are scaled onto the range supplied by the consumer.

Parameters
normalizedEdgesthe relative bin edges, strictly increasing, with first value 0 and last value 1
boundaryTypethe optional boundary type of the axis
directionthe optional direction of the axis
Exceptions
std::invalid_argumentif fewer than two values are given, the values are not strictly increasing, or the first and last values are not exactly 0 and 1
Returns
the deferred variable spec

◆ direction()

std::optional< AxisDirection > Acts::AxisSpec::direction ( ) const

Get the direction of the axis.

Returns
the direction if the spec fixes it

◆ Equidistant()

AxisSpec Acts::AxisSpec::Equidistant ( std::size_t nBins,
std::optional< double > min = std::nullopt,
std::optional< double > max = std::nullopt,
std::optional< AxisBoundaryType > boundaryType = std::nullopt,
std::optional< AxisDirection > direction = std::nullopt )
static

Equidistant axis; every property but the number of bins may be left to the consumer.

Parameters
nBinsthe number of bins
minthe optional minimum edge of the axis
maxthe optional maximum edge of the axis
boundaryTypethe optional boundary type of the axis
directionthe optional direction of the axis
Exceptions
std::invalid_argumentif min >= max or nBins == 0
Returns
the equidistant spec

◆ FromAxis()

AxisSpec Acts::AxisSpec::FromAxis ( const IAxis & axis)
static

Capture an existing axis as a fully specified spec.

Parameters
axisthe axis to decompose
Returns
the equidistant or variable spec of the given axis, including its direction if set

◆ isDeferred()

bool Acts::AxisSpec::isDeferred ( ) const

Check if the spec needs Options to build, i.e.

leaves at least one property to the consumer

Returns
true if the spec is deferred

◆ isDeferredVariable()

bool Acts::AxisSpec::isDeferredVariable ( ) const

Check if the spec holds normalized instead of absolute bin edges.

Returns
true for the deferred variable alternative

◆ isEquidistant()

bool Acts::AxisSpec::isEquidistant ( ) const

Check if the spec produces an equidistant axis.

Returns
true for the equidistant alternative

◆ isVariable()

bool Acts::AxisSpec::isVariable ( ) const

Check if the spec produces a variable axis.

Returns
true for the two variable alternatives

◆ nBins()

std::size_t Acts::AxisSpec::nBins ( ) const

Get the number of bins.

Returns
the number of bins, defined for all alternatives

◆ toDeferred()

AxisSpec Acts::AxisSpec::toDeferred ( ) const

Get the counterpart that leaves every property to the consumer: an equidistant spec keeps only its number of bins, a variable one its edges normalized to [0, 1].

Returns
the deferred spec

◆ toString()

std::string Acts::AxisSpec::toString ( ) const

Get a string representation of this spec.

Returns
the string representation

◆ Variable()

AxisSpec Acts::AxisSpec::Variable ( std::vector< double > edges,
std::optional< AxisBoundaryType > boundaryType = std::nullopt,
std::optional< AxisDirection > direction = std::nullopt )
static

Variable axis with absolute bin edges.

Parameters
edgesthe bin edges, strictly increasing
boundaryTypethe optional boundary type of the axis
directionthe optional direction of the axis
Exceptions
std::invalid_argumentif fewer than two edges are given or the edges are not strictly increasing
Returns
the variable spec

◆ withDirection()

AxisSpec Acts::AxisSpec::withDirection ( AxisDirection direction) const

Get a copy of this spec with the given direction attached.

Parameters
directionthe direction to attach
Returns
the spec with the direction set