Belle II Software development
EigenHelper.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#pragma once
9
10#include <Eigen/Dense>
11#include <TVectorD.h>
12#include <framework/logging/Logger.h>
13
14namespace Belle2 {
20 template <unsigned int NRows, unsigned int NCols, class AMatrix>
21 Eigen::Matrix<double, NRows, NCols, Eigen::RowMajor> convertToEigen(const AMatrix& matrix)
22 {
23 B2ASSERT("Matrix should be in the form " << NRows << "x" << NCols << ", not " << matrix.GetNrows() << "x" << matrix.GetNcols(),
24 matrix.GetNcols() == NCols and matrix.GetNrows() == NRows);
25 return Eigen::Matrix<double, NRows, NCols, Eigen::RowMajor>(matrix.GetMatrixArray());
26 };
27
29 template <unsigned int NRows>
30 Eigen::Matrix<double, NRows, 1> convertToEigen(const TVectorD& matrix)
31 {
32 B2ASSERT("Matrix should be in the form " << NRows << "x" << 1 << ", not " << matrix.GetNrows() << "x" << 1,
33 matrix.GetNrows() == NRows);
34 return Eigen::Matrix<double, NRows, 1>(matrix.GetMatrixArray());
35 };
37}
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:21
Abstract base class for different kinds of events.