File Helpers.hpp

Defines

ACTS_CHECK_BIT(value, mask)
namespace Acts

Set the Geometry Context PLUGIN.

Set the Calibration Context PLUGIN.

Convenience functions to ease creation of and Acts::InterpolatedMaterialMap and to avoid code duplication.

Set the Mangetic Field Context PLUGIN.

Convenience functions to ease creation of and Acts::InterpolatedBFieldMap and to avoid code duplication.

Currently implemented for the two most common formats: rz and xyz.

Functions

template<typename MatrixType>
MatrixType bitsetToMatrix(const std::bitset<MatrixType::RowsAtCompileTime * MatrixType::ColsAtCompileTime> bs)

Convert a bitset to a matrix of integers, with each element set to the bit value.

Note

How the bits are assigned to matrix elements depends on the storage type of the matrix being converted (row-major or col-major)

Template Parameters

MatrixType – Matrix type that is produced

Parameters

bs – The bitset to convert

Returns

A matrix with the integer values of the bits from bs

template<typename Derived>
auto matrixToBitset(const Eigen::PlainObjectBase<Derived> &m)

Convert an integer matrix to a bitset.

Note

How the bits are ordered depends on the storage type of the matrix being converted (row-major or col-major)

Template Parameters

Derived – Eigen base concrete type

Parameters

m – Matrix that is converted

Returns

The converted bitset.

template<template<size_t> class Callable, size_t N, size_t NMAX, typename ...Args>
auto template_switch(size_t v, Args&&... args)

Dispatch a call based on a runtime value on a function taking the value at compile time.

This function allows to write a templated functor, which accepts a size_t like paramater at compile time. It is then possible to make a call to the corresponding instance of the functor based on a runtime value. To achieve this, the function essentially created a if cascade between N and NMAX, attempting to find the right instance. Because the cascade is visible to the compiler entirely, it should be able to optimize.

Note

Callable is expected to have a static member function invoke that is callable with Args

Template Parameters
  • Callable – Type which takes a size_t as a compile time param

  • N – Value from which to start the dispatch chain, i.e. 0 in most cases

  • NMAX – Maximum value up to which to attempt a dispatch

Parameters
  • v – The runtime value to dispatch on

  • args – Additional arguments passed to Callable::invoke().

template<typename derived_t>
inline std::string toString(const Eigen::MatrixBase<derived_t> &matrix, int precision = 4, const std::string &offset = "")

Print out a matrix in a structured way.

Template Parameters

derived_t – Type of the matrix

Parameters
  • matrix – The matrix to print

  • precision – Numeric output precision

  • offset – Offset in front of matrix lines

Returns

The printed string

inline std::string toString(const Acts::Translation3 &translation, int precision = 4)

Print out a translation in a structured way.

Parameters
  • translation – The translation to print

  • precision – Numeric output precision

Returns

The printed string

inline std::string toString(const Acts::Transform3 &transform, int precision = 4, const std::string &offset = "")

Print out a transform in a structured way.

Parameters
  • transform – The transform to print

  • precision – Numeric output precision

  • offset – Offset in front of matrix lines

Returns

The printed string

template<typename T>
std::vector<T*> unpack_shared_vector(const std::vector<std::shared_ptr<T>> &items)

Helper function to unpack a vector of shared_ptr into a vector of raw pointers.

Template Parameters

T – the stored type

Parameters

items – The vector of shared_ptr

Returns

The unpacked vector

template<typename T>
std::vector<const T*> unpack_shared_vector(const std::vector<std::shared_ptr<const T>> &items)

Helper function to unpack a vector of shared_ptr into a vector of raw pointers (const version)

Template Parameters

T – the stored type

Parameters

items – The vector of shared_ptr

Returns

The unpacked vector

namespace VectorHelpers

Functions

inline double cast(const Vector3 &position, BinningValue bval)

Helper method to extract the binning value from a 3D vector.

For this method a 3D vector is required to guarantee all potential binning values.

inline ActsMatrix<3, 3> cross(const ActsMatrix<3, 3> &m, const Vector3 &v)

Calculates column-wise cross products of a matrix and a vector and stores the result column-wise in a matrix.

Parameters
  • m[in] Matrix that will be used for cross products

  • v[in] Vector for cross products

Returns

Constructed matrix

template<typename Derived>
double eta(const Eigen::MatrixBase<Derived> &v) noexcept

Calculate the pseudorapidity for a vector.

Note

Will static assert that the number of rows of v is at least 3, or in case of dynamic size, will abort execution if that is not the case.

Template Parameters

Derived – Eigen derived concrete type

Parameters

v – Any vector like Eigen type, static or dynamic

Returns

The pseudorapidity value

static inline const std::array<ActsScalar, 5> evaluateTrigonomics(const Vector3 &direction)

Fast evaluation of trigonomic functions.

Parameters

direction – for this evaluatoin

Returns

cos(phi), sin(phi), cos(theta), sin(theta), 1/sin(theta)

template<typename vector3_t>
inline auto makeVector4(const Eigen::MatrixBase<vector3_t> &vec3, typename vector3_t::Scalar w) -> Eigen::Matrix<typename vector3_t::Scalar, 4, 1>

Construct a four-vector from a three-vector and scalar fourth component.

template<typename Derived>
double perp(const Eigen::MatrixBase<Derived> &v) noexcept

Calculate radius in the transverse (xy) plane of a vector.

Note

Will static assert that the number of rows of v is at least 2, or in case of dynamic size, will abort execution if that is not the case.

Template Parameters

Derived – Eigen derived concrete type

Parameters

v – Any vector like Eigen type, static or dynamic

Returns

The transverse radius value.

template<typename Derived>
double phi(const Eigen::MatrixBase<Derived> &v) noexcept

Calculate phi (transverse plane angle) from compatible Eigen types.

Note

Will static assert that the number of rows of v is at least 2, or in case of dynamic size, will abort execution if that is not the case.

Template Parameters

Derived – Eigen derived concrete type

Parameters

v – Any vector like Eigen type, static or dynamic

Returns

The value of the angle in the transverse plane.

template<typename T, std::enable_if_t<detail::has_phi_method<T>::value, int> = 0>
double phi(const T &v) noexcept

Calculate phi (transverse plane angle) from anything implementing a method like phi() returing anything convertible to double.

Template Parameters

T – anything that has a phi method

Parameters

v – Any type that implements a phi method

Returns

The phi value

inline auto position(const Vector4 &pos4)

Access the three-position components in a four-position vector.

inline auto position(const FreeVector &params)

Access the three-position components in a free parameters vector.

template<typename Derived>
double theta(const Eigen::MatrixBase<Derived> &v) noexcept

Calculate the theta angle (longitudinal w.r.t.

z axis) of a vector

Note

Will static assert that the number of rows of v is at least 3, or in case of dynamic size, will abort execution if that is not the case.

Template Parameters

Derived – Eigen derived concrete type

Parameters

v – Any vector like Eigen type, static or dynamic

Returns

The theta value