diff --git a/Tracking/TrkEvent/TrkEventPrimitives/TrkEventPrimitives/ProjectionMatricesSet.h b/Tracking/TrkEvent/TrkEventPrimitives/TrkEventPrimitives/ProjectionMatricesSet.h index 18238deb0b71e1b52522d0e9ac662a02e642f1f6..88d00c27291be3be9f1c7f52d0d0a3ebec008ae0 100755 --- a/Tracking/TrkEvent/TrkEventPrimitives/TrkEventPrimitives/ProjectionMatricesSet.h +++ b/Tracking/TrkEvent/TrkEventPrimitives/TrkEventPrimitives/ProjectionMatricesSet.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -32,9 +32,6 @@ namespace Trk { /**Explicit constructor for 1-dimensional vector */ ProjectionMatricesSet(int maxdim); - /** Virtual destructor */ - virtual ~ProjectionMatricesSet(); - /**Expansion matrix return*/ const Amg::MatrixX& expansionMatrix(int mtx) const; @@ -45,16 +42,16 @@ namespace Trk { int accessor(int mtx, ParamDefs par) const; private: - int m_maxdim; - std::vector<const Amg::MatrixX*> m_expansions; - std::vector<const Amg::MatrixX*> m_reductions; - std::vector< std::vector<int> > m_accessors; + int m_maxdim; + std::vector<Amg::MatrixX> m_expansions; + std::vector<Amg::MatrixX> m_reductions; + std::vector<std::vector<int>> m_accessors; }; -inline const Amg::MatrixX& ProjectionMatricesSet::expansionMatrix(int mtx) const { return (*m_expansions[mtx]); } +inline const Amg::MatrixX& ProjectionMatricesSet::expansionMatrix(int mtx) const { return m_expansions[mtx]; } -inline const Amg::MatrixX& ProjectionMatricesSet::reductionMatrix(int mtx) const { return (*m_reductions[mtx]); } +inline const Amg::MatrixX& ProjectionMatricesSet::reductionMatrix(int mtx) const { return m_reductions[mtx]; } inline int ProjectionMatricesSet::accessor(int mtx, ParamDefs par) const { return (par-(m_accessors[mtx])[par]); } diff --git a/Tracking/TrkEvent/TrkEventPrimitives/src/ProjectionMatricesSet.cxx b/Tracking/TrkEvent/TrkEventPrimitives/src/ProjectionMatricesSet.cxx index d42ca6fa11085f16aea5a2b5e7ebf6f4bde18ed2..81ceacfe54abe8f59f7087e1136512528ab4c1b1 100755 --- a/Tracking/TrkEvent/TrkEventPrimitives/src/ProjectionMatricesSet.cxx +++ b/Tracking/TrkEvent/TrkEventPrimitives/src/ProjectionMatricesSet.cxx @@ -22,48 +22,42 @@ Trk::ProjectionMatricesSet::ProjectionMatricesSet(int maxdim) : std::vector<int> accessorInt(m_maxdim); std::vector<bool> parameterTag(m_maxdim); unsigned int cols = 0; - for (int itag = 0, ipos=1; itag<m_maxdim; ++itag, ipos*=2) - { bool bit = (imatx & ipos); - parameterTag[itag] = bit; - if (bit) { ++cols;} - } - - Amg::MatrixX* reduction = nullptr; - Amg::MatrixX* expansion = nullptr; - + for (int itag = 0, ipos = 1; itag < m_maxdim; ++itag, ipos *= 2) { + bool bit = (imatx & ipos); + parameterTag[itag] = bit; + if (bit) { + ++cols; + } + } + + //By default set zero + Amg::MatrixX reduction; + reduction.setZero(); + Amg::MatrixX expansion; + expansion.setZero(); if (cols){ // rows and cols - initialized to zero - reduction = new Amg::MatrixX(m_maxdim, cols); - (*reduction).setZero(); + reduction = Amg::MatrixX(m_maxdim, cols); + reduction.setZero(); // go through the rows and fill them int reduc = 0; for (int irow = 0; irow<m_maxdim; irow++) { - int icol = irow - reduc; // avoids couting to col 4 for int(0b01111) = 15 matrix icol = (icol < int(cols)) ? icol : cols-1; - (*reduction)(irow,icol) = parameterTag[irow] ? 1. : 0.; + reduction(irow,icol) = parameterTag[irow] ? 1. : 0.; if (!parameterTag[irow]) { accessorInt[irow] = -100; ++reduc; - } - else { - accessorInt[irow] = reduc;} + } else { + accessorInt[irow] = reduc; + } } - // the expansion matrix is the transposed reduction matrix - expansion = new Amg::MatrixX(reduction->transpose()); - - } else { - // only one single case - reduction = new Amg::MatrixX(m_maxdim, m_maxdim); - (*reduction).setZero(); - expansion = new Amg::MatrixX(m_maxdim, m_maxdim); - (*expansion).setZero(); - } - + expansion = Amg::MatrixX(reduction.transpose()); + } // store them m_reductions.push_back(reduction); m_expansions.push_back(expansion); @@ -71,16 +65,3 @@ Trk::ProjectionMatricesSet::ProjectionMatricesSet(int maxdim) : } } - -Trk::ProjectionMatricesSet::~ProjectionMatricesSet() -{ - std::vector<const Amg::MatrixX*>::const_iterator matrixIter = m_expansions.begin(); - std::vector<const Amg::MatrixX*>::const_iterator matrixIterEnd = m_expansions.end(); - for ( ; matrixIter != matrixIterEnd; delete (*matrixIter), ++matrixIter) { ;} - - matrixIter = m_reductions.begin(); - matrixIterEnd = m_reductions.end(); - for ( ; matrixIter != matrixIterEnd; delete (*matrixIter), ++matrixIter) { ;} - -} -