CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Migration.h
Go to the documentation of this file.
1 #ifndef _CLEHP_2_SMATRIX_MIGRATION_H_
2 #define _CLEHP_2_SMATRIX_MIGRATION_H_
3 
5 #include <cstring>
6 
7 /*
8 template <unsigned int N1, unsigned int N2>
9  ROOT::Math::SMatrix<double,N1,N2,ROOT::Math::RepStd<double,N1,N2> > clhep2smatrix(const CLHEP::HepMatrix &mt) {
10  typedef ROOT::Math::SMatrix<double,N1,N2,ROOT::Math::RepStd<double,N1,N2> > RM;
11  RM rm;
12  memcpy(rm.Array(), &matmt(1,1), (N1*N2)*sizeof(double));
13  return rm;
14  }
15 template <unsigned int N1>
16  ROOT::Math::SMatrix<double,N1,N1,ROOT::Math::RepSym<double,N1> > clhep2smatrix(const CLHEP::HepSymMatrix &mt) {
17  typedef ROOT::Math::SMatrix<double,N1,N1,ROOT::Math::RepSym<double,N1> > RM;
18  RM rm;
19  memcpy(rm.Array(), &matmt(1,1), (D1*D2)*sizeof(double));
20  return rm;
21  }
22 */
23 
24 template<unsigned int N1, unsigned int N2>
25  ROOT::Math::SMatrix<double,N1,N2, typename ROOT::Math::MatRepStd<double,N1,N2> > asSMatrix(const CLHEP::HepMatrix &m) {
26  typedef typename ROOT::Math::MatRepStd<double,N1,N2> REP;
27  assert(m.num_row() == N1); assert(m.num_col() == N2);
28  return ROOT::Math::SMatrix<double,N1,N2,REP> (&m(1,1), REP::kSize);
29  }
30 
31 template<unsigned int N1>
32  ROOT::Math::SMatrix<double,N1,N1, typename ROOT::Math::MatRepSym<double,N1> > asSMatrix(const CLHEP::HepSymMatrix &m) {
33  typedef typename ROOT::Math::MatRepSym<double,N1> REP;
34  assert(m.num_row() == N1);
35  return ROOT::Math::SMatrix<double,N1,N1,REP> (&m(1,1), REP::kSize);
36  }
37 
38 template<unsigned int N1>
39  ROOT::Math::SVector<double,N1> asSVector(const CLHEP::HepVector &m) {
40  return ROOT::Math::SVector<double,N1> (&m[0], N1);
41  }
42 
43 template<unsigned int N> CLHEP::HepVector asHepVector(const ROOT::Math::SVector<double,N> &v) {
44  CLHEP::HepVector hv(N);
45  memcpy(&hv[0], &v[0], N*sizeof(double));
46  return hv;
47  }
48 
49 template<unsigned int N1, unsigned int N2> CLHEP::HepMatrix asHepMatrix (
50  const ROOT::Math::SMatrix<double,N1,N2, typename ROOT::Math::MatRepStd<double,N1,N2> > &rm) {
51  CLHEP::HepMatrix am(N1,N2);
52  memcpy(&am(1,1), rm.Array(), N1*N2*sizeof(double));
53  return am;
54  }
55 
56 template<unsigned int N1> CLHEP::HepSymMatrix asHepMatrix (
57  const ROOT::Math::SMatrix<double,N1,N1, typename ROOT::Math::MatRepSym<double,N1> > &rm) {
58  CLHEP::HepSymMatrix am(N1);
59  memcpy(&am(1,1), rm.Array(), (N1*(N1+1))/2*sizeof(double));
60  return am;
61  }
62 
63 
64 #endif
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:49
string rm
Definition: submit.py:76
#define N
Definition: blowfish.cc:9
ROOT::Math::SVector< double, N1 > asSVector(const CLHEP::HepVector &m)
Definition: Migration.h:39
ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > asSMatrix(const CLHEP::HepMatrix &m)
Definition: Migration.h:25
CLHEP::HepVector asHepVector(const ROOT::Math::SVector< double, N > &v)
Definition: Migration.h:43
mathSSE::Vec4< T > v