CMS 3D CMS Logo

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 
6 #include "CLHEP/Matrix/Matrix.h"
7 #include "CLHEP/Matrix/Vector.h"
8 #include "CLHEP/Matrix/SymMatrix.h"
9 
10 #include <cstring>
11 
12 /*
13 template <unsigned int N1, unsigned int N2>
14  ROOT::Math::SMatrix<double,N1,N2,ROOT::Math::RepStd<double,N1,N2> > clhep2smatrix(const CLHEP::HepMatrix &mt) {
15  typedef ROOT::Math::SMatrix<double,N1,N2,ROOT::Math::RepStd<double,N1,N2> > RM;
16  RM rm;
17  memcpy(rm.Array(), &matmt(1,1), (N1*N2)*sizeof(double));
18  return rm;
19  }
20 template <unsigned int N1>
21  ROOT::Math::SMatrix<double,N1,N1,ROOT::Math::RepSym<double,N1> > clhep2smatrix(const CLHEP::HepSymMatrix &mt) {
22  typedef ROOT::Math::SMatrix<double,N1,N1,ROOT::Math::RepSym<double,N1> > RM;
23  RM rm;
24  memcpy(rm.Array(), &matmt(1,1), (D1*D2)*sizeof(double));
25  return rm;
26  }
27 */
28 
29 template<unsigned int N1, unsigned int N2>
30  ROOT::Math::SMatrix<double,N1,N2, typename ROOT::Math::MatRepStd<double,N1,N2> > asSMatrix(const CLHEP::HepMatrix &m) {
31  typedef typename ROOT::Math::MatRepStd<double,N1,N2> REP;
32  assert(m.num_row() == N1); assert(m.num_col() == N2);
33  return ROOT::Math::SMatrix<double,N1,N2,REP> (&m(1,1), REP::kSize);
34  }
35 
36 template<unsigned int N1>
37  ROOT::Math::SMatrix<double,N1,N1, typename ROOT::Math::MatRepSym<double,N1> > asSMatrix(const CLHEP::HepSymMatrix &m) {
38  typedef typename ROOT::Math::MatRepSym<double,N1> REP;
39  assert(m.num_row() == N1);
40  return ROOT::Math::SMatrix<double,N1,N1,REP> (&m(1,1), REP::kSize);
41  }
42 
43 template<unsigned int N1>
44  ROOT::Math::SVector<double,N1> asSVector(const CLHEP::HepVector &m) {
45  return ROOT::Math::SVector<double,N1> (&m[0], N1);
46  }
47 
48 template<unsigned int N> CLHEP::HepVector asHepVector(const ROOT::Math::SVector<double,N> &v) {
49  CLHEP::HepVector hv(N);
50  memcpy(&hv[0], &v[0], N*sizeof(double));
51  return hv;
52  }
53 
54 template<unsigned int N1, unsigned int N2> CLHEP::HepMatrix asHepMatrix (
55  const ROOT::Math::SMatrix<double,N1,N2, typename ROOT::Math::MatRepStd<double,N1,N2> > &rm) {
56  CLHEP::HepMatrix am(N1,N2);
57  memcpy(&am(1,1), rm.Array(), N1*N2*sizeof(double));
58  return am;
59  }
60 
61 template<unsigned int N1> CLHEP::HepSymMatrix asHepMatrix (
62  const ROOT::Math::SMatrix<double,N1,N1, typename ROOT::Math::MatRepSym<double,N1> > &rm) {
63  CLHEP::HepSymMatrix am(N1);
64  memcpy(&am(1,1), rm.Array(), (N1*(N1+1))/2*sizeof(double));
65  return am;
66  }
67 
68 
69 #endif
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:54
susybsm::HSCParticleRefVector hv
Definition: classes.h:28
#define N
Definition: blowfish.cc:9
ROOT::Math::SVector< double, N1 > asSVector(const CLHEP::HepVector &m)
Definition: Migration.h:44
rm
Definition: submit.py:77
ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > asSMatrix(const CLHEP::HepMatrix &m)
Definition: Migration.h:30
CLHEP::HepVector asHepVector(const ROOT::Math::SVector< double, N > &v)
Definition: Migration.h:48