LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
LocalTransformation.cxx
Go to the documentation of this file.
1 
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 //------------------------------------------------------------------------------
24 // specialisations
25 //
26 namespace geo {
27 
28  template <>
30  (std::vector<TGeoNode const*> const& path, size_t depth)
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()
39 
40 
41  //----------------------------------------------------------------------------
42  template <>
43  HepGeom::Transform3D
45  (std::vector<TGeoNode const*> const& path, size_t depth)
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()
58 
59 } // namespace geo
60 
61 
62 //------------------------------------------------------------------------------
63 
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.
Class containing local-to-world transformations.
Float_t mat
Definition: plot.C:40
Namespace collecting geometry-related classes utilities.