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
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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