Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
gar::geo::LocalTransformation< StoredMatrix > Class Template Reference

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

#include <LocalTransformation.h>

Public Types

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

Public Member Functions

 LocalTransformation ()
 Constructor. More...
 
 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...
 
void SetPath (std::vector< TGeoNode const * > const &path, size_t depth)
 
void SetMatrix (TransformationMatrix_t matrix)
 
std::vector< TGeoNode const * > GetNodes () const
 
TransformationMatrix_t GetMatrix () const
 
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)
 

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 Attributes

TransformationMatrix_t fGeoMatrix
 local to world transform More...
 
std::vector< TGeoNode const * > fNodeVec
 

Detailed Description

template<typename StoredMatrix>
class gar::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 41 of file LocalTransformation.h.

Member Typedef Documentation

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

Type of transformation matrix.

Definition at line 45 of file LocalTransformation.h.

Constructor & Destructor Documentation

template<typename StoredMatrix>
gar::geo::LocalTransformation< StoredMatrix >::LocalTransformation ( )
inline

Constructor.

Definition at line 50 of file LocalTransformation.h.

51  : fGeoMatrix(nullptr) {}
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
gar::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 60 of file LocalTransformation.h.

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

Definition at line 62 of file LocalTransformation.h.

63  : fGeoMatrix(std::move(matrix)) {}
TransformationMatrix_t fGeoMatrix
local to world transform
def move(depos, offset)
Definition: depos.py:107
template<typename StoredMatrix>
gar::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 73 of file LocalTransformation.h.

74  : fGeoMatrix(transformationFromPath(path, depth)) {}
TransformationMatrix_t fGeoMatrix
local to world transform
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.

Member Function Documentation

template<typename StoredMatrix>
TransformationMatrix_t gar::geo::LocalTransformation< StoredMatrix >::GetMatrix ( ) const
inline

Definition at line 162 of file LocalTransformation.h.

162 {return fGeoMatrix;}
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
std::vector<TGeoNode const*> gar::geo::LocalTransformation< StoredMatrix >::GetNodes ( ) const
inline

Definition at line 160 of file LocalTransformation.h.

160 {return fNodeVec;}
std::vector< TGeoNode const * > fNodeVec
template<typename StoredMatrix>
void gar::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.

template<typename StoredMatrix>
void gar::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.

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

Direct access to the transformation matrix.

Definition at line 143 of file LocalTransformation.h.

143 { return fGeoMatrix; }
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
void gar::geo::LocalTransformation< StoredMatrix >::SetMatrix ( TransformationMatrix_t  matrix)
inline

Definition at line 156 of file LocalTransformation.h.

156  {
157  fGeoMatrix = matrix;
158  }
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
void gar::geo::LocalTransformation< StoredMatrix >::SetPath ( std::vector< TGeoNode const * > const &  path,
size_t  depth 
)
inline

Definition at line 150 of file LocalTransformation.h.

150  {
151  fGeoMatrix = transformationFromPath(path, depth);
152  for(size_t i = 0; i <= depth; i++) fNodeVec.push_back(path[i]);
153  }
TransformationMatrix_t fGeoMatrix
local to world transform
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.
std::vector< TGeoNode const * > fNodeVec
template<>
TGeoHMatrix gar::geo::LocalTransformation< TGeoHMatrix >::transformationFromPath ( std::vector< TGeoNode const * > const &  path,
size_t  depth 
)

Definition at line 30 of file LocalTransformation.cxx.

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

Definition at line 44 of file LocalTransformation.cxx.

45  {
46 
47  auto const mat =
49  (path, depth);
50  const Double_t* translation = mat.GetTranslation();
51  return HepGeom::Transform3D(
52  CLHEP::HepRotation(CLHEP::HepRep3x3(mat.GetRotationMatrix())),
53  CLHEP::Hep3Vector(translation[0], translation[1], translation[2])
54  );
55 
56  } // gar::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.
template<typename StoredMatrix>
static TransformationMatrix_t gar::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.

template<typename StoredMatrix>
void gar::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.

template<typename StoredMatrix>
void gar::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.

Member Data Documentation

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

local to world transform

Definition at line 166 of file LocalTransformation.h.

template<typename StoredMatrix>
std::vector<TGeoNode const*> gar::geo::LocalTransformation< StoredMatrix >::fNodeVec
protected

Definition at line 167 of file LocalTransformation.h.


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