LocalTransformation.cxx
Go to the documentation of this file.
1 /**
2 * @file larcorealg/Geometry/LocalTransformation.cxx
3 * @brief Class containing local-to-world transformations (implementation file)
4 * @author Gianluca Petrillo (petrillo@fnal.gov)
5 * @date November 30, 2016
6 * @see LocalTransformation.h
7 *
8 */
9 
10 // our header
11 #include "LocalTransformation.h"
12 
13 // ROOT
14 #include "TGeoMatrix.h" // TGeoHMatrix
15 
16 // CLHEP
17 #include "CLHEP/Geometry/Transform3D.h" // HepGeom::Transform3D
18 #include "CLHEP/Vector/Rotation.h" // CLHEP::HepRotation
19 #include "CLHEP/Vector/RotationInterfaces.h" // CLHEP::HepRep3x3
20 #include "CLHEP/Vector/ThreeVector.h" // CLHEP::Hep3Vector
21 
22 //------------------------------------------------------------------------------
23 // specialisations
24 //
25 namespace gar {
26  namespace geo {
27 
28  template <>
30  (std::vector<TGeoNode const*> const& path, size_t depth)
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()
39 
40  //----------------------------------------------------------------------------
41  template <>
42  HepGeom::Transform3D
44  (std::vector<TGeoNode const*> const& path, size_t depth)
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()
57  } // namespace geo
58 } // namespace gar
59 
60 //------------------------------------------------------------------------------
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.
General GArSoft Utilities.
LArSoft geometry interface.
Definition: ChannelGeo.h:16