CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/DataFormats/CLHEP/interface/Migration.h

Go to the documentation of this file.
00001 #ifndef _CLEHP_2_SMATRIX_MIGRATION_H_
00002 #define _CLEHP_2_SMATRIX_MIGRATION_H_
00003 
00004 #include "DataFormats/Math/interface/AlgebraicROOTObjects.h"
00005 #include <cstring>
00006 
00007 /*
00008 template <unsigned int N1, unsigned int N2> 
00009     ROOT::Math::SMatrix<double,N1,N2,ROOT::Math::RepStd<double,N1,N2> > clhep2smatrix(const CLHEP::HepMatrix &mt) {
00010         typedef ROOT::Math::SMatrix<double,N1,N2,ROOT::Math::RepStd<double,N1,N2> > RM;
00011         RM rm;
00012         memcpy(rm.Array(), &matmt(1,1), (N1*N2)*sizeof(double));
00013         return rm;
00014     }
00015 template <unsigned int N1> 
00016     ROOT::Math::SMatrix<double,N1,N1,ROOT::Math::RepSym<double,N1> > clhep2smatrix(const CLHEP::HepSymMatrix &mt) {
00017         typedef ROOT::Math::SMatrix<double,N1,N1,ROOT::Math::RepSym<double,N1> > RM;
00018         RM rm;
00019         memcpy(rm.Array(), &matmt(1,1), (D1*D2)*sizeof(double));
00020         return rm;
00021     }
00022 */
00023 
00024 template<unsigned int N1, unsigned int N2> 
00025     ROOT::Math::SMatrix<double,N1,N2, typename ROOT::Math::MatRepStd<double,N1,N2> > asSMatrix(const CLHEP::HepMatrix &m) {
00026         typedef typename ROOT::Math::MatRepStd<double,N1,N2>  REP;
00027         assert(m.num_row() == N1); assert(m.num_col() == N2);
00028         return  ROOT::Math::SMatrix<double,N1,N2,REP> (&m(1,1), REP::kSize);
00029     }
00030 
00031 template<unsigned int N1> 
00032     ROOT::Math::SMatrix<double,N1,N1, typename ROOT::Math::MatRepSym<double,N1> > asSMatrix(const CLHEP::HepSymMatrix &m) {
00033         typedef typename ROOT::Math::MatRepSym<double,N1>  REP;
00034         assert(m.num_row() == N1);
00035         return  ROOT::Math::SMatrix<double,N1,N1,REP> (&m(1,1), REP::kSize);
00036     }
00037 
00038 template<unsigned int N1> 
00039     ROOT::Math::SVector<double,N1> asSVector(const CLHEP::HepVector &m) {
00040         return  ROOT::Math::SVector<double,N1> (&m[0], N1);
00041     }
00042 
00043 template<unsigned int N> CLHEP::HepVector asHepVector(const ROOT::Math::SVector<double,N> &v) {
00044     CLHEP::HepVector hv(N);
00045     memcpy(&hv[0], &v[0], N*sizeof(double));
00046     return hv;
00047     }
00048 
00049 template<unsigned int N1, unsigned int N2> CLHEP::HepMatrix asHepMatrix (
00050      const ROOT::Math::SMatrix<double,N1,N2, typename ROOT::Math::MatRepStd<double,N1,N2> > &rm) {
00051         CLHEP::HepMatrix am(N1,N2);
00052         memcpy(&am(1,1), rm.Array(), N1*N2*sizeof(double));
00053         return am;
00054     }
00055 
00056 template<unsigned int N1> CLHEP::HepSymMatrix asHepMatrix (
00057      const ROOT::Math::SMatrix<double,N1,N1, typename ROOT::Math::MatRepSym<double,N1> > &rm) {
00058         CLHEP::HepSymMatrix am(N1);
00059         memcpy(&am(1,1), rm.Array(), (N1*(N1+1))/2*sizeof(double));
00060         return am;
00061     }
00062 
00063 
00064 #endif