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/Normal3D.h"
6 #include "CLHEP/Geometry/Point3D.h"
7 #include "CLHEP/Units/GlobalSystemOfUnits.h"
8 #include "CLHEP/Vector/Rotation.h"
9 #include "CLHEP/Vector/ThreeVector.h"
10 
11 // CMS
16 
17 // Geant4
18 #include "G4ErrorFreeTrajState.hh"
19 
23 namespace TrackPropagation {
30  inline HepGeom::Point3D<double> globalPointToHepPoint3D(const GlobalPoint &r) {
31  return HepGeom::Point3D<double>(r.x() * cm, r.y() * cm, r.z() * cm);
32  }
33 
38  inline GlobalPoint hepPoint3DToGlobalPoint(const HepGeom::Point3D<double> &r) {
39  return GlobalPoint(r.x() / cm, r.y() / cm, r.z() / cm);
40  }
41 
45  inline double g4doubleToCmsDouble(const G4double &d) { return d / cm; }
46 
50  inline HepGeom::Normal3D<double> globalVectorToHepNormal3D(const GlobalVector &p) {
51  return HepGeom::Normal3D<double>(p.x(), p.y(), p.z());
52  }
53 
57  inline GlobalVector hepNormal3DToGlobalVector(const HepGeom::Normal3D<double> &p) {
58  return GlobalVector(p.x(), p.y(), p.z());
59  }
60 
63  inline CLHEP::Hep3Vector globalVectorToHep3Vector(const GlobalVector &p) {
64  return CLHEP::Hep3Vector(p.x(), p.y(), p.z());
65  }
66 
69  inline GlobalVector hep3VectorToGlobalVector(const CLHEP::Hep3Vector &p) { return GlobalVector(p.x(), p.y(), p.z()); }
70 
75  inline CLHEP::Hep3Vector globalPointToHep3Vector(const GlobalPoint &r) {
76  return CLHEP::Hep3Vector(r.x() * cm, r.y() * cm, r.z() * cm);
77  }
78 
83  inline GlobalPoint hep3VectorToGlobalPoint(const CLHEP::Hep3Vector &v) {
84  return GlobalPoint(v.x() / cm, v.y() / cm, v.z() / cm);
85  }
86 
90  inline CLHEP::HepRotation tkRotationFToHepRotation(const TkRotation<float> &tkr) {
91  return CLHEP::HepRotation(CLHEP::Hep3Vector(tkr.xx(), tkr.yx(), tkr.zx()),
92  CLHEP::Hep3Vector(tkr.xy(), tkr.yy(), tkr.zy()),
93  CLHEP::Hep3Vector(tkr.xz(), tkr.yz(), tkr.zz()));
94  }
95 
98  inline TkRotation<float> hepRotationToTkRotationF(const CLHEP::HepRotation &r) {
99  return TkRotation<float>(r.xx(), r.xy(), r.xz(), r.yx(), r.yy(), r.yz(), r.zx(), r.zy(), r.zz());
100  }
101 
106  inline AlgebraicSymMatrix55 g4ErrorTrajErrToAlgebraicSymMatrix55(const G4ErrorTrajErr &e, const int q) {
107  assert(q != 0);
108  // From DataFormats/CLHEP/interface/Migration.h
109  // typedef ROOT::Math::SMatrix<double,5,5,ROOT::Math::MatRepSym<double,5> >
110  // AlgebraicSymMatrix55;
112  for (unsigned int i = 0; i < 5; i++)
113  for (unsigned int j = 0; j < 5; j++) {
114  m55(i, j) = e(i + 1, j + 1);
115  if (i == 0)
116  m55(i, j) = double(q) * m55(i, j);
117  if (j == 0)
118  m55(i, j) = double(q) * m55(i, j);
119  }
120  return m55;
121  }
122 
126  inline G4ErrorTrajErr algebraicSymMatrix55ToG4ErrorTrajErr(const AlgebraicSymMatrix55 &e, const int q) {
127  assert(q != 0);
128  G4ErrorTrajErr g4err(5, 1);
129  for (unsigned int i = 0; i < 5; i++)
130  for (unsigned int j = 0; j < 5; j++) {
131  g4err(i + 1, j + 1) = e(i, j);
132 
133  if (i == 0)
134  g4err(i + 1, j + 1) = g4err(i + 1, j + 1) * double(q);
135  if (j == 0)
136  g4err(i + 1, j + 1) = g4err(i + 1, j + 1) * double(q);
137  }
138  return g4err;
139  }
140 
141 } // namespace TrackPropagation
142 
143 #endif
Vector3DBase
Definition: Vector3DBase.h:8
TkRotation< float >
TrackPropagation::hep3VectorToGlobalVector
GlobalVector hep3VectorToGlobalVector(const CLHEP::Hep3Vector &p)
Definition: ConvertFromToCLHEP.h:69
mps_fire.i
i
Definition: mps_fire.py:428
TkRotation::zy
T zy() const
Definition: extTkRotation.h:258
AlgebraicObjects.h
TrackPropagation::hepPoint3DToGlobalPoint
GlobalPoint hepPoint3DToGlobalPoint(const HepGeom::Point3D< double > &r)
Definition: ConvertFromToCLHEP.h:38
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
cms::cuda::assert
assert(be >=bs)
TrackPropagation::hep3VectorToGlobalPoint
GlobalPoint hep3VectorToGlobalPoint(const CLHEP::Hep3Vector &v)
Definition: ConvertFromToCLHEP.h:83
TrackPropagation::g4ErrorTrajErrToAlgebraicSymMatrix55
AlgebraicSymMatrix55 g4ErrorTrajErrToAlgebraicSymMatrix55(const G4ErrorTrajErr &e, const int q)
Definition: ConvertFromToCLHEP.h:106
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
findQualityFiles.v
v
Definition: findQualityFiles.py:179
TkRotation::xz
T xz() const
Definition: extTkRotation.h:253
TrackPropagation::g4doubleToCmsDouble
double g4doubleToCmsDouble(const G4double &d)
Definition: ConvertFromToCLHEP.h:45
TrackPropagation::globalVectorToHepNormal3D
HepGeom::Normal3D< double > globalVectorToHepNormal3D(const GlobalVector &p)
Definition: ConvertFromToCLHEP.h:50
TrackPropagation::globalPointToHepPoint3D
HepGeom::Point3D< double > globalPointToHepPoint3D(const GlobalPoint &r)
Definition: ConvertFromToCLHEP.h:30
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
TkRotation.h
Point3DBase< float, GlobalTag >
TrackPropagation::hepRotationToTkRotationF
TkRotation< float > hepRotationToTkRotationF(const CLHEP::HepRotation &r)
Definition: ConvertFromToCLHEP.h:98
TkRotation::yx
T yx() const
Definition: extTkRotation.h:254
TrackPropagation::globalPointToHep3Vector
CLHEP::Hep3Vector globalPointToHep3Vector(const GlobalPoint &r)
Definition: ConvertFromToCLHEP.h:75
TkRotation::xx
T xx() const
Definition: extTkRotation.h:251
TrackPropagation::globalVectorToHep3Vector
CLHEP::Hep3Vector globalVectorToHep3Vector(const GlobalVector &p)
Definition: ConvertFromToCLHEP.h:63
TkRotation::xy
T xy() const
Definition: extTkRotation.h:252
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
TkRotation::zz
T zz() const
Definition: extTkRotation.h:259
TrackPropagation::hepNormal3DToGlobalVector
GlobalVector hepNormal3DToGlobalVector(const HepGeom::Normal3D< double > &p)
Definition: ConvertFromToCLHEP.h:57
alignCSCRings.r
r
Definition: alignCSCRings.py:93
TkRotation::yz
T yz() const
Definition: extTkRotation.h:256
TrackPropagation::tkRotationFToHepRotation
CLHEP::HepRotation tkRotationFToHepRotation(const TkRotation< float > &tkr)
Definition: ConvertFromToCLHEP.h:90
TkRotation::yy
T yy() const
Definition: extTkRotation.h:255
GlobalVector.h
TrackPropagation::algebraicSymMatrix55ToG4ErrorTrajErr
G4ErrorTrajErr algebraicSymMatrix55ToG4ErrorTrajErr(const AlgebraicSymMatrix55 &e, const int q)
Definition: ConvertFromToCLHEP.h:126
TrackPropagation
Definition: ConvertFromToCLHEP.h:23
ztail.d
d
Definition: ztail.py:151
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
TkRotation::zx
T zx() const
Definition: extTkRotation.h:257
GlobalPoint.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37