Belle II Software  release-06-01-15
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 /* External headers. */
12 #include <CLHEP/Geometry/Point3D.h>
13 #include <CLHEP/Matrix/SymMatrix.h>
14 #include <CLHEP/Vector/LorentzVector.h>
15 #include <TLorentzVector.h>
16 #include <TMatrixFSym.h>
17 #include <TMatrixDSym.h>
18 #include <TVector3.h>
19 
20 namespace Belle2 {
26  namespace ROOTToCLHEP {
27 
32  inline CLHEP::HepLorentzVector
33  getHepLorentzVector(const TLorentzVector& vector)
34  {
35  return CLHEP::HepLorentzVector(vector.X(), vector.Y(), vector.Z(),
36  vector.T());
37  }
38 
43  inline HepGeom::Point3D<double> getPoint3D(const TVector3& vector)
44  {
45  return HepGeom::Point3D<double>(vector.X(), vector.Y(), vector.Z());
46  }
47 
52  inline CLHEP::HepSymMatrix getHepSymMatrix(const TMatrixFSym& matrix)
53  {
54  int n = matrix.GetNrows();
55  CLHEP::HepSymMatrix m(n);
56  /*
57  * CLHEP::HepSymMatrix is stored as a lower triangular matrix,
58  * thus it is sufficient to set only the corresponding elements.
59  */
60  for (int i = 0; i < n; ++i) {
61  for (int j = 0; j <= i; ++j)
62  m[i][j] = matrix[i][j];
63  }
64  return m;
65  }
66 
71  inline CLHEP::HepSymMatrix getHepSymMatrix(const TMatrixDSym& matrix)
72  {
73  int n = matrix.GetNrows();
74  CLHEP::HepSymMatrix m(n);
75  /*
76  * CLHEP::HepSymMatrix is stored as a lower triangular matrix,
77  * thus it is sufficient to set only the corresponding elements.
78  */
79  for (int i = 0; i < n; ++i) {
80  for (int j = 0; j <= i; ++j)
81  m[i][j] = matrix[i][j];
82  }
83  return m;
84  }
85 
86  }
87 
89 }
Abstract base class for different kinds of events.