Belle II Software  release-05-01-25
ROOTToCLHEP.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Kirill Chilikin *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 /* External headers. */
14 #include <CLHEP/Geometry/Point3D.h>
15 #include <CLHEP/Matrix/SymMatrix.h>
16 #include <CLHEP/Vector/LorentzVector.h>
17 #include <TLorentzVector.h>
18 #include <TMatrixFSym.h>
19 #include <TMatrixDSym.h>
20 #include <TVector3.h>
21 
22 namespace Belle2 {
28  namespace ROOTToCLHEP {
29 
34  inline CLHEP::HepLorentzVector
35  getHepLorentzVector(const TLorentzVector& vector)
36  {
37  return CLHEP::HepLorentzVector(vector.X(), vector.Y(), vector.Z(),
38  vector.T());
39  }
40 
45  inline HepGeom::Point3D<double> getPoint3D(const TVector3& vector)
46  {
47  return HepGeom::Point3D<double>(vector.X(), vector.Y(), vector.Z());
48  }
49 
54  inline CLHEP::HepSymMatrix getHepSymMatrix(const TMatrixFSym& matrix)
55  {
56  int n = matrix.GetNrows();
57  CLHEP::HepSymMatrix m(n);
58  /*
59  * CLHEP::HepSymMatrix is stored as a lower triangular matrix,
60  * thus it is sufficient to set only the corresponding elements.
61  */
62  for (int i = 0; i < n; ++i) {
63  for (int j = 0; j <= i; ++j)
64  m[i][j] = matrix[i][j];
65  }
66  return m;
67  }
68 
73  inline CLHEP::HepSymMatrix getHepSymMatrix(const TMatrixDSym& matrix)
74  {
75  int n = matrix.GetNrows();
76  CLHEP::HepSymMatrix m(n);
77  /*
78  * CLHEP::HepSymMatrix is stored as a lower triangular matrix,
79  * thus it is sufficient to set only the corresponding elements.
80  */
81  for (int i = 0; i < n; ++i) {
82  for (int j = 0; j <= i; ++j)
83  m[i][j] = matrix[i][j];
84  }
85  return m;
86  }
87 
88  }
89 
91 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
HepGeom::Point3D< double >