LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
geo::LocalTransformation< StoredMatrix > Class Template Reference

Class to transform between world and local coordinates. More...

#include "LocalTransformation.h"

Inheritance diagram for geo::LocalTransformation< StoredMatrix >:
geo::LocalTransformationGeo< StoredMatrix, LocalPoint, LocalVector >

Public Types

using TransformationMatrix_t = StoredMatrix
 Type of transformation matrix. More...
 

Public Member Functions

 LocalTransformation (std::vector< TGeoNode const * > const &path, size_t depth)
 Constructor: uses the specified transformation matrix. More...
 
void LocalToWorld (double const *local, double *world) const
 Transforms a point from local frame to world frame. More...
 
void LocalToWorldVect (double const *local, double *world) const
 Transforms a vector from local frame to world frame. More...
 
void WorldToLocal (double const *world, double *local) const
 Transforms a point from world frame to local frame. More...
 
void WorldToLocalVect (const double *world, double *local) const
 Transforms a vector from world frame to local frame. More...
 
TransformationMatrix_t const & Matrix () const
 Direct access to the transformation matrix. More...
 
template<>
TGeoHMatrix transformationFromPath (std::vector< TGeoNode const * > const &path, size_t depth)
 
template<>
HepGeom::Transform3D transformationFromPath (std::vector< TGeoNode const * > const &path, size_t depth)
 
 LocalTransformation (TransformationMatrix_t const &matrix)
 Constructor: uses the specified transformation matrix. More...
 
 LocalTransformation (TransformationMatrix_t &&matrix)
 Constructor: uses the specified transformation matrix. More...
 
template<typename DestPoint , typename SrcPoint , typename = std::enable_if_t<!std::is_same<SrcPoint, DestPoint>::value>>
DestPoint LocalToWorld (SrcPoint const &local) const
 Transforms a point from local frame to world frame. More...
 
template<typename Point >
Point LocalToWorld (Point const &local) const
 Transforms a point from local frame to world frame. More...
 
template<typename DestVector , typename SrcVector , typename = std::enable_if_t<!std::is_same<SrcVector, DestVector>::value>>
DestVector LocalToWorldVect (SrcVector const &local) const
 Transforms a vector from local frame to world frame. More...
 
template<typename Vector >
Vector LocalToWorldVect (Vector const &local) const
 Transforms a vector from local frame to world frame. More...
 
template<typename DestPoint , typename SrcPoint , typename = std::enable_if_t<!std::is_same<SrcPoint, DestPoint>::value>>
DestPoint WorldToLocal (SrcPoint const &world) const
 Transforms a point from world frame to local frame. More...
 
template<typename Point >
Point WorldToLocal (Point const &world) const
 Transforms a point from world frame to local frame. More...
 
template<typename DestVector , typename SrcVector , typename = std::enable_if_t<!std::is_same<SrcVector, DestVector>::value>>
DestVector WorldToLocalVect (SrcVector const &world) const
 Transforms a vector from world frame to local frame. More...
 
template<typename Vector >
Vector WorldToLocalVect (Vector const &world) const
 Transforms a vector from world frame to local frame. More...
 

Static Public Member Functions

static TransformationMatrix_t transformationFromPath (std::vector< TGeoNode const * > const &path, size_t depth)
 Builds a matrix to go from local to world coordinates in one step. More...
 

Protected Member Functions

template<typename DestPoint , typename SrcPoint >
DestPoint LocalToWorldImpl (SrcPoint const &local) const
 
template<typename DestVector , typename SrcVector >
DestVector LocalToWorldVectImpl (SrcVector const &local) const
 
template<typename DestPoint , typename SrcPoint >
DestPoint WorldToLocalImpl (SrcPoint const &world) const
 
template<typename DestVector , typename SrcVector >
DestVector WorldToLocalVectImpl (SrcVector const &world) const
 

Protected Attributes

TransformationMatrix_t fGeoMatrix
 local to world transform More...
 

Detailed Description

template<typename StoredMatrix>
class geo::LocalTransformation< StoredMatrix >

Class to transform between world and local coordinates.

Template Parameters
StoredMatrixtype of transformation matrix internally stored

This class provides two directions of transformations (world to local and the other way around), for points and for vectors. The vector version of the transformation does not apply translation.

Note
In the class method examples, the following definition is assumed:
using LocalTransformation_t = geo::LocalTransformation<TGeoHMatrix>;

Definition at line 45 of file LocalTransformation.h.

Member Typedef Documentation

template<typename StoredMatrix>
using geo::LocalTransformation< StoredMatrix >::TransformationMatrix_t = StoredMatrix

Type of transformation matrix.

Definition at line 49 of file LocalTransformation.h.

Constructor & Destructor Documentation

template<typename StoredMatrix>
geo::LocalTransformation< StoredMatrix >::LocalTransformation ( TransformationMatrix_t const &  matrix)
inline

Constructor: uses the specified transformation matrix.

Parameters
matrixthe transformation matrix to be used

The specified matrix is copied into a local copy.

Definition at line 58 of file LocalTransformation.h.

59  : fGeoMatrix(matrix) {}
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
geo::LocalTransformation< StoredMatrix >::LocalTransformation ( TransformationMatrix_t &&  matrix)
inline

Constructor: uses the specified transformation matrix.

Parameters
matrixthe transformation matrix to be used

The specified matrix is copied into a local copy.

Definition at line 60 of file LocalTransformation.h.

61  : fGeoMatrix(std::move(matrix)) {}
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
geo::LocalTransformation< StoredMatrix >::LocalTransformation ( std::vector< TGeoNode const * > const &  path,
size_t  depth 
)
inline

Constructor: uses the specified transformation matrix.

Parameters
paththe path of ROOT geometry nodes
depththe index in the path of the last node to be considered

The specified matrix is copied into a local copy.

Definition at line 71 of file LocalTransformation.h.

72  : fGeoMatrix(transformationFromPath(path, depth)) {}
static TransformationMatrix_t transformationFromPath(std::vector< TGeoNode const * > const &path, size_t depth)
Builds a matrix to go from local to world coordinates in one step.
TransformationMatrix_t fGeoMatrix
local to world transform

Member Function Documentation

template<typename StoredMatrix>
void geo::LocalTransformation< StoredMatrix >::LocalToWorld ( double const *  local,
double *  world 
) const

Transforms a point from local frame to world frame.

Parameters
locallocal coordinates: [0] x, [1] y, [2] z [cm]
world(output) corresponding world coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
std::array<double, 3U> origin, center;
origin.fill(0.);
trans.LocalToWorld(origin.data(), center.data());

center will contain the world coordinates of the center of the volume, which is usually represented by the origin in the local coordinates.

In-place replacement is not supported: world and local buffers are assumed not to, and must not, overlap.

Referenced by geo::OpDetGeo::Length(), geo::AuxDetGeo::LocalToWorld(), geo::AuxDetSensitiveGeo::LocalToWorld(), geo::CryostatGeo::LocalToWorld(), geo::TPCGeo::LocalToWorld(), and geo::LocalTransformation< TGeoHMatrix >::LocalTransformation().

template<typename StoredMatrix>
template<typename DestPoint , typename SrcPoint , typename = std::enable_if_t<!std::is_same<SrcPoint, DestPoint>::value>>
DestPoint geo::LocalTransformation< StoredMatrix >::LocalToWorld ( SrcPoint const &  local) const
inline

Transforms a point from local frame to world frame.

Template Parameters
SrcPointtype of the input (local) vector
DestPointtype of the output (world) vector (default: as Point)
Parameters
locallocal coordinates [cm]
Returns
corresponding world coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
auto center = trans.LocalToWorld(TVector3());

center will be a TVector3 containing the world coordinates of the center of the volume, which is usually represented by the origin in the local coordinates (a TVector3 is by default constructed to point to the origin).

Definition at line 119 of file LocalTransformation.h.

120  { return LocalToWorldImpl<DestPoint>(local); }
template<typename StoredMatrix>
template<typename Point >
Point geo::LocalTransformation< StoredMatrix >::LocalToWorld ( Point const &  local) const
inline

Transforms a point from local frame to world frame.

Template Parameters
SrcPointtype of the input (local) vector
DestPointtype of the output (world) vector (default: as Point)
Parameters
locallocal coordinates [cm]
Returns
corresponding world coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
auto center = trans.LocalToWorld(TVector3());

center will be a TVector3 containing the world coordinates of the center of the volume, which is usually represented by the origin in the local coordinates (a TVector3 is by default constructed to point to the origin).

Definition at line 122 of file LocalTransformation.h.

123  { return LocalToWorldImpl<Point>(local); }
template<typename StoredMatrix>
template<typename DestPoint , typename SrcPoint >
DestPoint geo::LocalTransformation< StoredMatrix >::LocalToWorldImpl ( SrcPoint const &  local) const
protected
template<typename StoredMatrix>
void geo::LocalTransformation< StoredMatrix >::LocalToWorldVect ( double const *  local,
double *  world 
) const

Transforms a vector from local frame to world frame.

Parameters
locallocal coordinates: [0] x, [1] y, [2] z [cm]
world(output) corresponding world coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

In-place replacement is not supported: world and local buffers are assumed not to, and must not, overlap.

Referenced by geo::LocalTransformation< TGeoHMatrix >::LocalToWorld(), geo::OpDetGeo::LocalToWorldVect(), geo::AuxDetGeo::LocalToWorldVect(), geo::AuxDetSensitiveGeo::LocalToWorldVect(), geo::WireGeo::LocalToWorldVect(), geo::CryostatGeo::LocalToWorldVect(), and geo::TPCGeo::LocalToWorldVect().

template<typename StoredMatrix>
template<typename DestVector , typename SrcVector , typename = std::enable_if_t<!std::is_same<SrcVector, DestVector>::value>>
DestVector geo::LocalTransformation< StoredMatrix >::LocalToWorldVect ( SrcVector const &  local) const
inline

Transforms a vector from local frame to world frame.

Template Parameters
SrcVectortype of the input (local) vector
DestVectortype of output (world) vector (default: as Vector)
Parameters
locallocal coordinates [cm]
Returns
corresponding world coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

Definition at line 154 of file LocalTransformation.h.

155  { return LocalToWorldVectImpl<DestVector>(local); }
template<typename StoredMatrix>
template<typename Vector >
Vector geo::LocalTransformation< StoredMatrix >::LocalToWorldVect ( Vector const &  local) const
inline

Transforms a vector from local frame to world frame.

Template Parameters
SrcVectortype of the input (local) vector
DestVectortype of output (world) vector (default: as Vector)
Parameters
locallocal coordinates [cm]
Returns
corresponding world coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

Definition at line 157 of file LocalTransformation.h.

158  { return LocalToWorldVectImpl<Vector>(local); }
template<typename StoredMatrix>
template<typename DestVector , typename SrcVector >
DestVector geo::LocalTransformation< StoredMatrix >::LocalToWorldVectImpl ( SrcVector const &  local) const
protected
template<typename StoredMatrix>
TransformationMatrix_t const& geo::LocalTransformation< StoredMatrix >::Matrix ( ) const
inline

Direct access to the transformation matrix.

Definition at line 247 of file LocalTransformation.h.

Referenced by geo::AuxDetGeo::AuxDetGeo(), and geo::TPCGeo::TPCGeo().

247 { return fGeoMatrix; }
TransformationMatrix_t fGeoMatrix
local to world transform
template<>
TGeoHMatrix geo::LocalTransformation< TGeoHMatrix >::transformationFromPath ( std::vector< TGeoNode const * > const &  path,
size_t  depth 
)

Definition at line 30 of file LocalTransformation.cxx.

References geo::LocalTransformation< StoredMatrix >::transformationFromPath().

31  {
32 
33  TGeoHMatrix matrix = *(path[0]->GetMatrix());
34  for(size_t i = 1; i <= depth; ++i)
35  matrix.Multiply(path[i]->GetMatrix());
36  return matrix;
37 
38  } // geo::LocalTransformation::transformationFromPath()
template<>
HepGeom::Transform3D geo::LocalTransformation< HepGeom::Transform3D >::transformationFromPath ( std::vector< TGeoNode const * > const &  path,
size_t  depth 
)

Definition at line 45 of file LocalTransformation.cxx.

References mat, and geo::LocalTransformation< StoredMatrix >::transformationFromPath().

46  {
47 
48  auto const mat =
50  (path, depth);
51  const Double_t* translation = mat.GetTranslation();
52  return HepGeom::Transform3D(
53  CLHEP::HepRotation(CLHEP::HepRep3x3(mat.GetRotationMatrix())),
54  CLHEP::Hep3Vector(translation[0], translation[1], translation[2])
55  );
56 
57  } // geo::LocalTransformation::transformationFromPath()
static TransformationMatrix_t transformationFromPath(std::vector< TGeoNode const * > const &path, size_t depth)
Builds a matrix to go from local to world coordinates in one step.
Float_t mat
Definition: plot.C:40
template<typename StoredMatrix>
static TransformationMatrix_t geo::LocalTransformation< StoredMatrix >::transformationFromPath ( std::vector< TGeoNode const * > const &  path,
size_t  depth 
)
static

Builds a matrix to go from local to world coordinates in one step.

Referenced by geo::LocalTransformation< TGeoHMatrix >::Matrix(), and geo::LocalTransformation< StoredMatrix >::transformationFromPath().

template<typename StoredMatrix>
void geo::LocalTransformation< StoredMatrix >::WorldToLocal ( double const *  world,
double *  local 
) const

Transforms a point from world frame to local frame.

Parameters
worldworld coordinates: [0] x, [1] y, [2] z [cm]
local(output) corresponding local coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
std::array<double, 3U> world{ 4.0, 5.0, -2.5 }, local;
trans.WorldToLocal(world.data(), local.data());

local will contain the local coordinates of the specified point.

In-place replacement is not supported: world and local buffers are assumed not to, and must not, overlap.

Referenced by geo::LocalTransformation< TGeoHMatrix >::LocalToWorldVect(), geo::OpDetGeo::WorldToLocal(), geo::AuxDetGeo::WorldToLocal(), geo::AuxDetSensitiveGeo::WorldToLocal(), geo::WireGeo::WorldToLocal(), geo::CryostatGeo::WorldToLocal(), and geo::TPCGeo::WorldToLocal().

template<typename StoredMatrix>
template<typename DestPoint , typename SrcPoint , typename = std::enable_if_t<!std::is_same<SrcPoint, DestPoint>::value>>
DestPoint geo::LocalTransformation< StoredMatrix >::WorldToLocal ( SrcPoint const &  world) const
inline

Transforms a point from world frame to local frame.

Template Parameters
SrcPointtype of the input (local) vector
DestPointtype of the output (world) vector (default: as Point)
Parameters
worldworld coordinates [cm]
Returns
corresponding local coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
auto local = trans.WorldToLocal(TVector3(4.0, 5.0, -2.5));

local will be a TVector3 containing the local coordinates of the specified point.

Definition at line 202 of file LocalTransformation.h.

203  { return WorldToLocalImpl<DestPoint>(world); }
template<typename StoredMatrix>
template<typename Point >
Point geo::LocalTransformation< StoredMatrix >::WorldToLocal ( Point const &  world) const
inline

Transforms a point from world frame to local frame.

Template Parameters
SrcPointtype of the input (local) vector
DestPointtype of the output (world) vector (default: as Point)
Parameters
worldworld coordinates [cm]
Returns
corresponding local coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
auto local = trans.WorldToLocal(TVector3(4.0, 5.0, -2.5));

local will be a TVector3 containing the local coordinates of the specified point.

Definition at line 205 of file LocalTransformation.h.

206  { return WorldToLocalImpl<Point>(world); }
template<typename StoredMatrix>
template<typename DestPoint , typename SrcPoint >
DestPoint geo::LocalTransformation< StoredMatrix >::WorldToLocalImpl ( SrcPoint const &  world) const
protected
template<typename StoredMatrix>
void geo::LocalTransformation< StoredMatrix >::WorldToLocalVect ( const double *  world,
double *  local 
) const

Transforms a vector from world frame to local frame.

Parameters
worldworld coordinates: [0] x, [1] y, [2] z [cm]
local(output) corresponding local coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

In-place replacement is not supported: world and local buffers are assumed not to, and must not, overlap.

Referenced by geo::LocalTransformation< TGeoHMatrix >::WorldToLocal(), geo::OpDetGeo::WorldToLocalVect(), geo::AuxDetGeo::WorldToLocalVect(), geo::AuxDetSensitiveGeo::WorldToLocalVect(), geo::WireGeo::WorldToLocalVect(), geo::CryostatGeo::WorldToLocalVect(), and geo::TPCGeo::WorldToLocalVect().

template<typename StoredMatrix>
template<typename DestVector , typename SrcVector , typename = std::enable_if_t<!std::is_same<SrcVector, DestVector>::value>>
DestVector geo::LocalTransformation< StoredMatrix >::WorldToLocalVect ( SrcVector const &  world) const
inline

Transforms a vector from world frame to local frame.

Template Parameters
SrcVectortype of the input (local) vector
DestVectortype of output (world) vector (default: as Vector)
Parameters
worldcoordinates [cm]
Returns
corresponding world coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

Definition at line 238 of file LocalTransformation.h.

239  { return WorldToLocalVectImpl<DestVector>(world); }
template<typename StoredMatrix>
template<typename Vector >
Vector geo::LocalTransformation< StoredMatrix >::WorldToLocalVect ( Vector const &  world) const
inline

Transforms a vector from world frame to local frame.

Template Parameters
SrcVectortype of the input (local) vector
DestVectortype of output (world) vector (default: as Vector)
Parameters
worldcoordinates [cm]
Returns
corresponding world coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

Definition at line 241 of file LocalTransformation.h.

242  { return WorldToLocalVectImpl<Vector>(world); }
template<typename StoredMatrix>
template<typename DestVector , typename SrcVector >
DestVector geo::LocalTransformation< StoredMatrix >::WorldToLocalVectImpl ( SrcVector const &  world) const
protected

Member Data Documentation

template<typename StoredMatrix>
TransformationMatrix_t geo::LocalTransformation< StoredMatrix >::fGeoMatrix
protected

local to world transform

Definition at line 257 of file LocalTransformation.h.

Referenced by geo::LocalTransformation< TGeoHMatrix >::Matrix().


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