2 * @file larcorealg/Geometry/GeoVectorLocalTransformation.tcc
3 * @brief Specialization of local-to-world transformations for ROOT GenVector
4 * (template implementation).
5 * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
6 * @date January 31, 2019
7 * @see `GeoVectorLocalTransformation.h`
9 * This file is expected to be included directly in the header.
13 #ifndef LARCOREALG_GEOMETRY_GEOVECTORLOCALTRANSFORMATION_TCC
14 #define LARCOREALG_GEOMETRY_GEOVECTORLOCALTRANSFORMATION_TCC
17 #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect::fillCoords()...
19 // framework libraries
20 #include "cetlib_except/exception.h"
23 #include "TGeoMatrix.h"
27 #include "CLHEP/Geometry/Transform3D.h"
28 #include "CLHEP/Vector/Rotation.h" // CLHEP::HepRotation
29 #include "CLHEP/Vector/RotationInterfaces.h" // CLHEP::HepRep3x3
30 #include "CLHEP/Vector/ThreeVector.h" // CLHEP::Hep3Vector
35 //------------------------------------------------------------------------------
37 struct geo::details::TransformationMatrixConverter<ROOT::Math::Transform3D, TGeoMatrix> {
38 static ROOT::Math::Transform3D convert(TGeoMatrix const& trans);
41 //------------------------------------------------------------------------------
43 template <typename DestPoint, typename SrcPoint>
44 DestPoint geo::LocalTransformation<ROOT::Math::Transform3D>::WorldToLocalImpl(
45 SrcPoint const& world) const
47 // need inverse transformation
48 using geo::vect::convertTo;
49 return geo::vect::convertTo<DestPoint>(
50 fGeoMatrix.ApplyInverse(convertTo<typename TransformationMatrix_t::Point>(world)));
51 } // geo::LocalTransformation::WorldToLocal()
53 //......................................................................
55 template <typename DestVector, typename SrcVector>
56 DestVector geo::LocalTransformation<ROOT::Math::Transform3D>::WorldToLocalVectImpl(
57 SrcVector const& world) const
59 // need inverse transformation
60 using geo::vect::convertTo;
61 return geo::vect::convertTo<DestVector>(
62 fGeoMatrix.ApplyInverse(convertTo<typename TransformationMatrix_t::Vector>(world)));
63 } // geo::LocalTransformation::WorldToLocalVect()
65 //......................................................................
67 template <typename DestPoint, typename SrcPoint>
68 DestPoint geo::LocalTransformation<ROOT::Math::Transform3D>::LocalToWorldImpl(
69 SrcPoint const& local) const
71 // need direct transformation
72 using geo::vect::convertTo;
73 return convertTo<DestPoint>(fGeoMatrix(convertTo<typename TransformationMatrix_t::Point>(local)));
75 } // geo::LocalTransformation::LocalToWorld()
77 //......................................................................
79 template <typename DestVector, typename SrcVector>
80 DestVector geo::LocalTransformation<ROOT::Math::Transform3D>::LocalToWorldVectImpl(
81 SrcVector const& local) const
83 // need direct transformation
84 using geo::vect::convertTo;
85 return convertTo<DestVector>(
86 fGeoMatrix(convertTo<typename TransformationMatrix_t::Vector>(local)));
87 } // geo::LocalTransformation::LocalToWorldVect()
89 //------------------------------------------------------------------------------
91 inline ROOT::Math::Transform3D geo::transformationFromPath<ROOT::Math::Transform3D>(
92 GeoNodeIterator_t begin,
93 GeoNodeIterator_t end)
95 if (begin == end) return {}; // identity by default construction
97 ROOT::Math::Transform3D matrix =
98 convertTransformationMatrix<ROOT::Math::Transform3D>(*((*iNode)->GetMatrix()));
99 while (++iNode != end) {
100 matrix *= convertTransformationMatrix<ROOT::Math::Transform3D>(*(*iNode)->GetMatrix());
103 } // geo::LocalTransformation<ROOT::Transform3D>::transformationFromPath()
105 //------------------------------------------------------------------------------
107 inline ROOT::Math::Transform3D geo::transformationFromPath<ROOT::Math::Transform3D>(
108 std::vector<TGeoNode const*> const& path,
111 return transformationFromPath<ROOT::Math::Transform3D>(path.begin(), path.begin() + depth + 1);
114 //------------------------------------------------------------------------------
116 #endif // LARCOREALG_GEOMETRY_GEOVECTORLOCALTRANSFORMATION_TCC