Belle II Software  release-08-02-06
ROOTToCLHEP.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <framework/geometry/B2Vector3.h>
12 
13 /* External headers. */
14 #include <CLHEP/Geometry/Point3D.h>
15 #include <CLHEP/Matrix/SymMatrix.h>
16 #include <CLHEP/Vector/LorentzVector.h>
17 #include <Math/Vector3D.h>
18 #include <Math/Vector4D.h>
19 #include <TMatrixFSym.h>
20 #include <TMatrixDSym.h>
21 
22 namespace Belle2 {
28  namespace ROOTToCLHEP {
29 
34  inline CLHEP::HepLorentzVector
35  getHepLorentzVector(const ROOT::Math::PxPyPzEVector& vector)
36  {
37  return CLHEP::HepLorentzVector(vector.X(), vector.Y(), vector.Z(),
38  vector.T());
39  }
40 
45  inline HepGeom::Point3D<double> getPoint3DFromB2Vector(const B2Vector3D& vector)
46  {
47  return HepGeom::Point3D<double>(vector.X(), vector.Y(), vector.Z());
48  }
49 
54  inline HepGeom::Point3D<double> getPoint3D(const ROOT::Math::XYZVector& vector)
55  {
56  return HepGeom::Point3D<double>(vector.X(), vector.Y(), vector.Z());
57  }
58 
63  inline CLHEP::HepSymMatrix getHepSymMatrix(const TMatrixFSym& matrix)
64  {
65  int n = matrix.GetNrows();
66  CLHEP::HepSymMatrix m(n);
67  /*
68  * CLHEP::HepSymMatrix is stored as a lower triangular matrix,
69  * thus it is sufficient to set only the corresponding elements.
70  */
71  for (int i = 0; i < n; ++i) {
72  for (int j = 0; j <= i; ++j)
73  m[i][j] = matrix[i][j];
74  }
75  return m;
76  }
77 
82  inline CLHEP::HepSymMatrix getHepSymMatrix(const TMatrixDSym& matrix)
83  {
84  int n = matrix.GetNrows();
85  CLHEP::HepSymMatrix m(n);
86  /*
87  * CLHEP::HepSymMatrix is stored as a lower triangular matrix,
88  * thus it is sufficient to set only the corresponding elements.
89  */
90  for (int i = 0; i < n; ++i) {
91  for (int j = 0; j <= i; ++j)
92  m[i][j] = matrix[i][j];
93  }
94  return m;
95  }
96 
97  }
98 
100 }
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516
Abstract base class for different kinds of events.