CMS 3D CMS Logo

ConvertFromToCLHEP.h
Go to the documentation of this file.
1 #ifndef TrackPropagation_ConvertFromToCLHEP_h
2 #define TrackPropagation_ConvertFromToCLHEP_h
3 
4 //CLHEP
5 #include "CLHEP/Geometry/Point3D.h"
6 #include "CLHEP/Geometry/Normal3D.h"
7 #include "CLHEP/Vector/ThreeVector.h"
8 #include "CLHEP/Vector/Rotation.h"
9 #include "CLHEP/Units/GlobalSystemOfUnits.h"
10 
11 //CMS
16 
17 //Geant4
18 #include "G4ErrorFreeTrajState.hh"
19 
24 {
31 inline HepGeom::Point3D<double> globalPointToHepPoint3D(const GlobalPoint& r)
32 {
33  return HepGeom::Point3D<double>(r.x() * cm, r.y() * cm, r.z() * cm);
34 }
35 
40 inline GlobalPoint hepPoint3DToGlobalPoint(const HepGeom::Point3D<double> & r)
41 {
42  return GlobalPoint(r.x() / cm, r.y() / cm, r.z() / cm);
43 }
44 
48 inline double g4doubleToCmsDouble(const G4double & d)
49 {
50  return d / cm;
51 }
52 
56 inline HepGeom::Normal3D<double> globalVectorToHepNormal3D(
57  const GlobalVector& p)
58 {
59  return HepGeom::Normal3D<double>(p.x(), p.y(), p.z());
60 }
61 
66  const HepGeom::Normal3D<double> & p)
67 {
68  return GlobalVector(p.x(), p.y(), p.z());
69 }
70 
73 inline CLHEP::Hep3Vector globalVectorToHep3Vector(const GlobalVector& p)
74 {
75  return CLHEP::Hep3Vector(p.x(), p.y(), p.z());
76 }
77 
80 inline GlobalVector hep3VectorToGlobalVector(const CLHEP::Hep3Vector& p)
81 {
82  return GlobalVector(p.x(), p.y(), p.z());
83 }
84 
89 inline CLHEP::Hep3Vector globalPointToHep3Vector(const GlobalPoint& r)
90 {
91  return CLHEP::Hep3Vector(r.x() * cm, r.y() * cm, r.z() * cm);
92 }
93 
98 inline GlobalPoint hep3VectorToGlobalPoint(const CLHEP::Hep3Vector& v)
99 {
100  return GlobalPoint(v.x() / cm, v.y() / cm, v.z() / cm);
101 }
102 
105 inline CLHEP::HepRotation tkRotationFToHepRotation(const TkRotation<float>& tkr)
106 {
107  return CLHEP::HepRotation(CLHEP::Hep3Vector(tkr.xx(), tkr.yx(), tkr.zx()),
108  CLHEP::Hep3Vector(tkr.xy(), tkr.yy(), tkr.zy()),
109  CLHEP::Hep3Vector(tkr.xz(), tkr.yz(), tkr.zz()));
110 }
111 
114 inline TkRotation<float> hepRotationToTkRotationF(const CLHEP::HepRotation& r)
115 {
116  return TkRotation<float>(r.xx(), r.xy(), r.xz(), r.yx(), r.yy(), r.yz(),
117  r.zx(), r.zy(), r.zz());
118 }
119 
125  const G4ErrorTrajErr& e, const int q)
126 {
127  assert(q != 0);
128  //From DataFormats/CLHEP/interface/Migration.h
129  //typedef ROOT::Math::SMatrix<double,5,5,ROOT::Math::MatRepSym<double,5> > AlgebraicSymMatrix55;
131  for (unsigned int i = 0; i < 5; i++)
132  for (unsigned int j = 0; j < 5; j++)
133  {
134  m55(i, j) = e(i + 1, j + 1);
135  if (i == 0)
136  m55(i, j) = double(q) * m55(i, j);
137  if (j == 0)
138  m55(i, j) = double(q) * m55(i, j);
139 
140  }
141  return m55;
142 }
143 
147  const AlgebraicSymMatrix55& e, const int q)
148 {
149  assert(q != 0);
150  G4ErrorTrajErr g4err(5, 1);
151  for (unsigned int i = 0; i < 5; i++)
152  for (unsigned int j = 0; j < 5; j++)
153  {
154  g4err(i + 1, j + 1) = e(i, j);
155 
156  if (i == 0)
157  g4err(i + 1, j + 1) = g4err(i + 1, j + 1) * double(q);
158  if (j == 0)
159  g4err(i + 1, j + 1) = g4err(i + 1, j + 1) * double(q);
160 
161  }
162  return g4err;
163 }
164 
165 }
166 
167 #endif
T xx() const
HepGeom::Normal3D< double > globalVectorToHepNormal3D(const GlobalVector &p)
TkRotation< float > hepRotationToTkRotationF(const CLHEP::HepRotation &r)
double g4doubleToCmsDouble(const G4double &d)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalVector hepNormal3DToGlobalVector(const HepGeom::Normal3D< double > &p)
T y() const
Definition: PV3DBase.h:63
T yx() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
CLHEP::Hep3Vector globalVectorToHep3Vector(const GlobalVector &p)
CLHEP::HepRotation tkRotationFToHepRotation(const TkRotation< float > &tkr)
T zx() const
T xy() const
T zz() const
AlgebraicSymMatrix55 g4ErrorTrajErrToAlgebraicSymMatrix55(const G4ErrorTrajErr &e, const int q)
T z() const
Definition: PV3DBase.h:64
GlobalPoint hepPoint3DToGlobalPoint(const HepGeom::Point3D< double > &r)
T zy() const
T yy() const
HepGeom::Point3D< double > globalPointToHepPoint3D(const GlobalPoint &r)
GlobalVector hep3VectorToGlobalVector(const CLHEP::Hep3Vector &p)
T xz() const
G4ErrorTrajErr algebraicSymMatrix55ToG4ErrorTrajErr(const AlgebraicSymMatrix55 &e, const int q)
T x() const
Definition: PV3DBase.h:62
CLHEP::Hep3Vector globalPointToHep3Vector(const GlobalPoint &r)
GlobalPoint hep3VectorToGlobalPoint(const CLHEP::Hep3Vector &v)
T yz() const
Global3DVector GlobalVector
Definition: GlobalVector.h:10