Belle II Software  release-05-02-19
EigenHelper.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <Eigen/Dense>
13 #include <TVectorD.h>
14 #include <framework/logging/Logger.h>
15 
16 namespace Belle2 {
21  template <unsigned int NRows, unsigned int NCols, class AMatrix>
23  Eigen::Matrix<double, NRows, NCols, Eigen::RowMajor> convertToEigen(const AMatrix& matrix)
24  {
25  B2ASSERT("Matrix should be in the form " << NRows << "x" << NCols << ", not " << matrix.GetNrows() << "x" << matrix.GetNcols(),
26  matrix.GetNcols() == NCols and matrix.GetNrows() == NRows);
27  return Eigen::Matrix<double, NRows, NCols, Eigen::RowMajor>(matrix.GetMatrixArray());
28  };
29 
31  template <unsigned int NRows>
32  Eigen::Matrix<double, NRows, 1> convertToEigen(const TVectorD& matrix)
33  {
34  B2ASSERT("Matrix should be in the form " << NRows << "x" << 1 << ", not " << matrix.GetNrows() << "x" << 1,
35  matrix.GetNrows() == NRows);
36  return Eigen::Matrix<double, NRows, 1>(matrix.GetMatrixArray());
37  };
39 }
Belle2::convertToEigen
Eigen::Matrix< double, NRows, NCols, Eigen::RowMajor > convertToEigen(const AMatrix &matrix)
Convert a ROOT matrix to Eigen. Checks for the correct row and column number.
Definition: EigenHelper.h:31
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19