2 * @file larcorealg/Geometry/GeoVectorLocalTransformation.tcc
3 * @brief Specialization of local-to-world transformations for ROOT GenVector
4 * (template implementation).
5 * @see `GeoVectorLocalTransformation.h`
7 * This file is expected to be included directly in the header.
11 #ifndef LARCOREALG_GEOMETRY_GEOVECTORLOCALTRANSFORMATION_TCC
12 #define LARCOREALG_GEOMETRY_GEOVECTORLOCALTRANSFORMATION_TCC
15 #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect::fillCoords()...
17 // framework libraries
18 #include "cetlib_except/exception.h"
21 #include "TGeoMatrix.h"
25 #include "CLHEP/Geometry/Transform3D.h"
26 #include "CLHEP/Vector/Rotation.h" // CLHEP::HepRotation
27 #include "CLHEP/Vector/RotationInterfaces.h" // CLHEP::HepRep3x3
28 #include "CLHEP/Vector/ThreeVector.h" // CLHEP::Hep3Vector
33 //------------------------------------------------------------------------------
35 struct geo::details::TransformationMatrixConverter<ROOT::Math::Transform3D, TGeoMatrix> {
36 static ROOT::Math::Transform3D convert(TGeoMatrix const& trans);
39 //------------------------------------------------------------------------------
41 template <typename DestPoint, typename SrcPoint>
42 DestPoint geo::LocalTransformation<ROOT::Math::Transform3D>::WorldToLocalImpl(
43 SrcPoint const& world) const
45 // need inverse transformation
46 using geo::vect::convertTo;
47 return convertTo<DestPoint>(
48 fGeoMatrix.ApplyInverse(convertTo<typename TransformationMatrix_t::Point>(world)));
51 //......................................................................
53 template <typename DestVector, typename SrcVector>
54 DestVector geo::LocalTransformation<ROOT::Math::Transform3D>::WorldToLocalVectImpl(
55 SrcVector const& world) const
57 // need inverse transformation
58 using geo::vect::convertTo;
59 return convertTo<DestVector>(
60 fGeoMatrix.ApplyInverse(convertTo<typename TransformationMatrix_t::Vector>(world)));
63 //......................................................................
65 template <typename DestPoint, typename SrcPoint>
66 DestPoint geo::LocalTransformation<ROOT::Math::Transform3D>::LocalToWorldImpl(
67 SrcPoint const& local) const
69 // need direct transformation
70 using geo::vect::convertTo;
71 return convertTo<DestPoint>(fGeoMatrix(convertTo<typename TransformationMatrix_t::Point>(local)));
74 //......................................................................
76 template <typename DestVector, typename SrcVector>
77 DestVector geo::LocalTransformation<ROOT::Math::Transform3D>::LocalToWorldVectImpl(
78 SrcVector const& local) const
80 // need direct transformation
81 using geo::vect::convertTo;
82 return convertTo<DestVector>(
83 fGeoMatrix(convertTo<typename TransformationMatrix_t::Vector>(local)));
86 //------------------------------------------------------------------------------
88 inline ROOT::Math::Transform3D geo::transformationFromPath<ROOT::Math::Transform3D>(
89 GeoNodeIterator_t begin,
90 GeoNodeIterator_t end)
92 if (begin == end) return {}; // identity by default construction
94 ROOT::Math::Transform3D matrix =
95 convertTransformationMatrix<ROOT::Math::Transform3D>(*iNode->node->GetMatrix());
96 while (++iNode != end) {
97 matrix *= convertTransformationMatrix<ROOT::Math::Transform3D>(*iNode->node->GetMatrix());
102 //------------------------------------------------------------------------------
104 inline ROOT::Math::Transform3D geo::transformationFromPath<ROOT::Math::Transform3D>(
105 std::vector<GeoNodePathEntry> const& path,
108 return transformationFromPath<ROOT::Math::Transform3D>(path.begin(), path.begin() + depth + 1);
111 //------------------------------------------------------------------------------
113 #endif // LARCOREALG_GEOMETRY_GEOVECTORLOCALTRANSFORMATION_TCC