Belle II Software  release-08-01-10
CLHEPToROOT.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 <Math/Vector3D.h>
16 #include <Math/Vector4D.h>
17 #include <TMatrixFSym.h>
18 
19 namespace Belle2 {
25  namespace CLHEPToROOT {
26 
31  inline ROOT::Math::PxPyPzEVector
32  getLorentzVector(const CLHEP::HepLorentzVector& vector)
33  {
34  return ROOT::Math::PxPyPzEVector(vector.x(), vector.y(), vector.z(), vector.t());
35  }
36 
41  inline ROOT::Math::XYZVector getXYZVector(const HepGeom::Point3D<double>& point)
42  {
43  return ROOT::Math::XYZVector(point.x(), point.y(), point.z());
44  }
45 
50  inline TMatrixFSym getTMatrixFSym(const CLHEP::HepSymMatrix& matrix)
51  {
52  int n = matrix.num_row();
53  TMatrixFSym m(n);
54  /*
55  * TMatrixFSym is stored as a full matrix, thus all elements must be set.
56  */
57  for (int i = 0; i < n; ++i) {
58  for (int j = 0; j < n; ++j)
59  m[i][j] = matrix[i][j];
60  }
61  return m;
62  }
63 
68  inline TMatrixDSym getTMatrixDSym(const CLHEP::HepSymMatrix& matrix)
69  {
70  int n = matrix.num_row();
71  TMatrixDSym m(n);
72  /*
73  * TMatrixFSym is stored as a full matrix, thus all elements must be set.
74  */
75  for (int i = 0; i < n; ++i) {
76  for (int j = 0; j < n; ++j)
77  m[i][j] = matrix[i][j];
78  }
79  return m;
80  }
81 
82  }
83 
85 }
Abstract base class for different kinds of events.