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(
31  const CLHEP::HepMatrix &m) {
32  typedef typename ROOT::Math::MatRepStd<double, N1, N2> REP;
33  assert(m.num_row() == N1);
34  assert(m.num_col() == N2);
35  return ROOT::Math::SMatrix<double, N1, N2, REP>(&m(1, 1), REP::kSize);
36 }
37 
38 template <unsigned int N1>
39 ROOT::Math::SMatrix<double, N1, N1, typename ROOT::Math::MatRepSym<double, N1> > asSMatrix(
40  const CLHEP::HepSymMatrix &m) {
41  typedef typename ROOT::Math::MatRepSym<double, N1> REP;
42  assert(m.num_row() == N1);
43  return ROOT::Math::SMatrix<double, N1, N1, REP>(&m(1, 1), REP::kSize);
44 }
45 
46 template <unsigned int N1>
47 ROOT::Math::SVector<double, N1> asSVector(const CLHEP::HepVector &m) {
48  return ROOT::Math::SVector<double, N1>(&m[0], N1);
49 }
50 
51 template <unsigned int N>
52 CLHEP::HepVector asHepVector(const ROOT::Math::SVector<double, N> &v) {
53  CLHEP::HepVector hv(N);
54  memcpy(&hv[0], &v[0], N * sizeof(double));
55  return hv;
56 }
57 
58 template <unsigned int N1, unsigned int N2>
59 CLHEP::HepMatrix asHepMatrix(
60  const ROOT::Math::SMatrix<double, N1, N2, typename ROOT::Math::MatRepStd<double, N1, N2> > &rm) {
61  CLHEP::HepMatrix am(N1, N2);
62  memcpy(&am(1, 1), rm.Array(), N1 * N2 * sizeof(double));
63  return am;
64 }
65 
66 template <unsigned int N1>
67 CLHEP::HepSymMatrix asHepMatrix(
68  const ROOT::Math::SMatrix<double, N1, N1, typename ROOT::Math::MatRepSym<double, N1> > &rm) {
69  CLHEP::HepSymMatrix am(N1);
70  memcpy(&am(1, 1), rm.Array(), (N1 * (N1 + 1)) / 2 * sizeof(double));
71  return am;
72 }
73 
74 #endif
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:59
susybsm::HSCParticleRefVector hv
Definition: classes.h:28
ROOT::Math::SVector< double, N1 > asSVector(const CLHEP::HepVector &m)
Definition: Migration.h:47
#define N
Definition: blowfish.cc:9
ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > asSMatrix(const CLHEP::HepMatrix &m)
Definition: Migration.h:30
rm
Definition: submit.py:77
CLHEP::HepVector asHepVector(const ROOT::Math::SVector< double, N > &v)
Definition: Migration.h:52