CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/TrackPropagation/Geant4e/interface/ConvertFromToCLHEP.h

Go to the documentation of this file.
00001 #ifndef TrackPropagation_ConvertFromToCLHEP_h
00002 #define TrackPropagation_ConvertFromToCLHEP_h
00003 
00004 //CLHEP
00005 #include "CLHEP/Geometry/Point3D.h"
00006 #include "CLHEP/Geometry/Normal3D.h" 
00007 #include "CLHEP/Vector/ThreeVector.h"
00008 #include "CLHEP/Vector/Rotation.h"
00009 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00010 
00011 //CMS
00012 
00013 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00014 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00015 #include "DataFormats/GeometrySurface/interface/TkRotation.h"
00016 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
00017 
00018 //Geant4
00019 #include "G4ErrorFreeTrajState.hh"
00020 
00024 namespace TrackPropagation {
00031   HepGeom::Point3D<double>  globalPointToHepPoint3D(const GlobalPoint& r) {
00032     return HepGeom::Point3D<double> (r.x()*cm, r.y()*cm, r.z()*cm);
00033   }
00034   
00035    
00036 
00041   GlobalPoint hepPoint3DToGlobalPoint(const HepGeom::Point3D<double> & r) {
00042     return GlobalPoint(r.x()/cm, r.y()/cm, r.z()/cm);
00043   }
00044 
00045 
00049   HepGeom::Normal3D<double>  globalVectorToHepNormal3D(const GlobalVector& p) {
00050     return HepGeom::Normal3D<double> (p.x(), p.y(), p.z());
00051   }
00052 
00056   GlobalVector hepNormal3DToGlobalVector(const HepGeom::Normal3D<double> & p) {
00057     return GlobalVector(p.x(), p.y(), p.z());
00058   }
00059 
00060 
00061 
00062 
00065   CLHEP::Hep3Vector globalVectorToHep3Vector(const GlobalVector& p) {
00066     return CLHEP::Hep3Vector(p.x(), p.y(), p.z());
00067   }
00068 
00071   GlobalVector hep3VectorToGlobalVector(const CLHEP::Hep3Vector& p) {
00072     return GlobalVector(p.x(), p.y(), p.z());
00073   }
00074 
00075 
00076 
00077 
00082   CLHEP::Hep3Vector globalPointToHep3Vector(const GlobalPoint& r) {
00083      return CLHEP::Hep3Vector(r.x()*cm, r.y()*cm, r.z()*cm);
00084   }
00085 
00090   GlobalPoint hep3VectorToGlobalPoint(const CLHEP::Hep3Vector& v) {
00091     return GlobalPoint(v.x()/cm, v.y()/cm, v.z()/cm);
00092   }
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00104   CLHEP::HepRotation tkRotationFToHepRotation(const TkRotation<float>& tkr) {
00105     return CLHEP::HepRotation(CLHEP::Hep3Vector(tkr.xx(),tkr.yx(), tkr.zx()),
00106                        CLHEP::Hep3Vector(tkr.xy(),tkr.yy(), tkr.zy()),
00107                        CLHEP::Hep3Vector(tkr.xz(),tkr.yz(), tkr.zz()));
00108   }
00109 
00112   TkRotation<float> hepRotationToTkRotationF(const CLHEP::HepRotation& r) {
00113     return TkRotation<float>(r.xx(), r.xy(), r.xz(),
00114                              r.yx(), r.yy(), r.yz(),
00115                              r.zx(), r.zy(), r.zz());
00116   }
00117 
00124   AlgebraicSymMatrix55
00125    g4ErrorTrajErrToAlgebraicSymMatrix55(const G4ErrorTrajErr& e, const int q) {
00126     //From DataFormats/CLHEP/interface/Migration.h
00127     //typedef ROOT::Math::SMatrix<double,5,5,ROOT::Math::MatRepSym<double,5> > AlgebraicSymMatrix55;
00128     AlgebraicSymMatrix55 m55;
00129     for (unsigned int i = 0; i < 5; i++)
00130       for (unsigned int j = 0; j < 5; j++) {
00131         m55(i, j) = e(i+1,j+1);
00132         if(i==0) m55(i,j) = q*m55(i,j);
00133         if(j==0) m55(i,j) = q*m55(i,j);
00134       }
00135     return m55;
00136   }
00137 
00140   G4ErrorTrajErr
00141     algebraicSymMatrix55ToG4ErrorTrajErr(const AlgebraicSymMatrix55& e, const int q) {
00142     G4ErrorTrajErr g4err(5,1);
00143     for (unsigned int i = 0; i < 5; i++)
00144       for (unsigned int j = 0; j < 5; j++) {
00145         g4err(i+1, j+1) = e(i,j);
00146         if(i==0) g4err(i+1,j+1) = q*g4err(i+1,j+1);
00147         if(j==0) g4err(i+1,j+1) = q*g4err(i+1,j+1);
00148       }
00149     return g4err;
00150   }
00151 
00152 }
00153 
00154 
00155 
00156 #endif