CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
12 
17 
18 //Geant4
19 #include "G4ErrorFreeTrajState.hh"
20 
24 namespace TrackPropagation {
31  HepGeom::Point3D<double> globalPointToHepPoint3D(const GlobalPoint& r) {
32  return HepGeom::Point3D<double> (r.x()*cm, r.y()*cm, r.z()*cm);
33  }
34 
35 
36 
41  GlobalPoint hepPoint3DToGlobalPoint(const HepGeom::Point3D<double> & r) {
42  return GlobalPoint(r.x()/cm, r.y()/cm, r.z()/cm);
43  }
44 
45 
49  HepGeom::Normal3D<double> globalVectorToHepNormal3D(const GlobalVector& p) {
50  return HepGeom::Normal3D<double> (p.x(), p.y(), p.z());
51  }
52 
56  GlobalVector hepNormal3DToGlobalVector(const HepGeom::Normal3D<double> & p) {
57  return GlobalVector(p.x(), p.y(), p.z());
58  }
59 
60 
61 
62 
65  CLHEP::Hep3Vector globalVectorToHep3Vector(const GlobalVector& p) {
66  return CLHEP::Hep3Vector(p.x(), p.y(), p.z());
67  }
68 
71  GlobalVector hep3VectorToGlobalVector(const CLHEP::Hep3Vector& p) {
72  return GlobalVector(p.x(), p.y(), p.z());
73  }
74 
75 
76 
77 
82  CLHEP::Hep3Vector globalPointToHep3Vector(const GlobalPoint& r) {
83  return CLHEP::Hep3Vector(r.x()*cm, r.y()*cm, r.z()*cm);
84  }
85 
90  GlobalPoint hep3VectorToGlobalPoint(const CLHEP::Hep3Vector& v) {
91  return GlobalPoint(v.x()/cm, v.y()/cm, v.z()/cm);
92  }
93 
94 
95 
96 
97 
98 
99 
100 
101 
104  CLHEP::HepRotation tkRotationFToHepRotation(const TkRotation<float>& tkr) {
105  return CLHEP::HepRotation(CLHEP::Hep3Vector(tkr.xx(),tkr.yx(), tkr.zx()),
106  CLHEP::Hep3Vector(tkr.xy(),tkr.yy(), tkr.zy()),
107  CLHEP::Hep3Vector(tkr.xz(),tkr.yz(), tkr.zz()));
108  }
109 
112  TkRotation<float> hepRotationToTkRotationF(const CLHEP::HepRotation& r) {
113  return TkRotation<float>(r.xx(), r.xy(), r.xz(),
114  r.yx(), r.yy(), r.yz(),
115  r.zx(), r.zy(), r.zz());
116  }
117 
125  g4ErrorTrajErrToAlgebraicSymMatrix55(const G4ErrorTrajErr& e, const int q) {
126  //From DataFormats/CLHEP/interface/Migration.h
127  //typedef ROOT::Math::SMatrix<double,5,5,ROOT::Math::MatRepSym<double,5> > AlgebraicSymMatrix55;
129  for (unsigned int i = 0; i < 5; i++)
130  for (unsigned int j = 0; j < 5; j++) {
131  m55(i, j) = e(i+1,j+1);
132  if(i==0) m55(i,j) = q*m55(i,j);
133  if(j==0) m55(i,j) = q*m55(i,j);
134  }
135  return m55;
136  }
137 
140  G4ErrorTrajErr
142  G4ErrorTrajErr g4err(5,1);
143  for (unsigned int i = 0; i < 5; i++)
144  for (unsigned int j = 0; j < 5; j++) {
145  g4err(i+1, j+1) = e(i,j);
146  if(i==0) g4err(i+1,j+1) = q*g4err(i+1,j+1);
147  if(j==0) g4err(i+1,j+1) = q*g4err(i+1,j+1);
148  }
149  return g4err;
150  }
151 
152 }
153 
154 
155 
156 #endif
T xx() const
int i
Definition: DBlmapReader.cc:9
HepGeom::Normal3D< double > globalVectorToHepNormal3D(const GlobalVector &p)
TkRotation< float > hepRotationToTkRotationF(const CLHEP::HepRotation &r)
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
int j
Definition: DBlmapReader.cc:9
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