LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::LArEigenHelper Class Reference

LArEigenHelper class. More...

#include "LArEigenHelper.h"

Static Public Member Functions

template<class T >
static void Vectorize (const T &caloHitContainer, Eigen::MatrixXf &hitMatrix)
 Convert a container of calo hits into an Eigen matrix. More...
 
template<class T >
static void Vectorize (const T &caloHitContainer, Eigen::MatrixXf &centre, Eigen::MatrixXf &low, Eigen::MatrixXf &high)
 Convert a container of calo hits into a collection of Eigen matrices representing the centre, low and high coordinates of hits. More...
 
static void GetAngles (const Eigen::MatrixXf &hitMatrix, const Eigen::RowVectorXf &origin, Eigen::RowVectorXf &phis)
 Retrieve the angle, coutner-clockwise relative to the x axis, between all hits in a matrix and a specified origin. More...
 

Detailed Description

LArEigenHelper class.

Definition at line 23 of file LArEigenHelper.h.

Member Function Documentation

void lar_content::LArEigenHelper::GetAngles ( const Eigen::MatrixXf &  hitMatrix,
const Eigen::RowVectorXf &  origin,
Eigen::RowVectorXf &  phis 
)
static

Retrieve the angle, coutner-clockwise relative to the x axis, between all hits in a matrix and a specified origin.

Parameters
hitMatrixthe input collection of hits
originthe origin from which to measure hits
phisthe output vector of angles in the range [0, 2pi]

Definition at line 58 of file LArEigenHelper.cc.

References geo::origin(), and util::pi().

59 {
60  const float pi{static_cast<float>(M_PI)};
61  Eigen::RowVectorXf piVec{Eigen::RowVectorXf::Constant(hitMatrix.rows(), pi)};
62  Eigen::RowVectorXf zeroVec{Eigen::RowVectorXf::Zero(hitMatrix.rows())};
63  Eigen::MatrixXf deltas(hitMatrix.rowwise() - origin);
64  for (int i = 0; i < deltas.rows(); ++i)
65  phis(i) = std::atan2(deltas(i, 1), deltas(i, 0));
66  // Move from [-pi, +pi] to [0, 2pi)
67  phis = (phis.array() < 0).select(piVec * 2 + phis, phis);
68  phis = (phis.array() < 2 * pi).select(phis, zeroVec);
69 }
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
template<class T >
void lar_content::LArEigenHelper::Vectorize ( const T &  caloHitContainer,
Eigen::MatrixXf &  hitMatrix 
)
static

Convert a container of calo hits into an Eigen matrix.

Parameters
caloHitContainerthe calo hit list containing the hits from which to construct a maxtrix
hitMatrixthe output Eigen matrix

Definition at line 26 of file LArEigenHelper.cc.

27 {
28  int i{0};
29  for (const CaloHit *const pCaloHit : caloHitContainer)
30  {
31  const CartesianVector &pos{pCaloHit->GetPositionVector()};
32  hitMatrix(i, 0) = pos.GetX();
33  hitMatrix(i, 1) = pos.GetZ();
34  ++i;
35  }
36 }
template<class T >
void lar_content::LArEigenHelper::Vectorize ( const T &  caloHitContainer,
Eigen::MatrixXf &  centre,
Eigen::MatrixXf &  low,
Eigen::MatrixXf &  high 
)
static

Convert a container of calo hits into a collection of Eigen matrices representing the centre, low and high coordinates of hits.

Parameters
caloHitContainerthe calo hit list containing the hits from which to construct matrices
centrethe output Eigen matrix of hit centres
lowthe output Eigen matrix of hit low edges (centre - width / 2)
highthe output Eigen matrix of hit high edges (centre + width / 2)

Definition at line 41 of file LArEigenHelper.cc.

42 {
43  LArEigenHelper::Vectorize(caloHitContainer, centre);
44  int i{0};
45  for (const CaloHit *const pCaloHit : caloHitContainer)
46  {
47  const CartesianVector &pos{pCaloHit->GetPositionVector()};
48  low(i, 0) = pos.GetX() - pCaloHit->GetCellSize1() * 0.5f;
49  low(i, 1) = pos.GetZ();
50  high(i, 0) = pos.GetX() + pCaloHit->GetCellSize1() * 0.5f;
51  high(i, 1) = pos.GetZ();
52  ++i;
53  }
54 }
static void Vectorize(const T &caloHitContainer, Eigen::MatrixXf &hitMatrix)
Convert a container of calo hits into an Eigen matrix.

The documentation for this class was generated from the following files: