Skip to content

Commit

Permalink
adding check for prior matrix inversion
Browse files Browse the repository at this point in the history
  • Loading branch information
nadrino committed Nov 19, 2024
1 parent 324eee4 commit 1deb689
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/ParametersManager/src/ParameterSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,26 @@ void ParameterSet::processCovarianceMatrix(){
<< _strippedCovarianceMatrix_->GetNcols() << "x"
<< _strippedCovarianceMatrix_->GetNrows() << std::endl;
_inverseStrippedCovarianceMatrix_ = std::shared_ptr<TMatrixD>((TMatrixD*)(_strippedCovarianceMatrix_->Clone()));
_inverseStrippedCovarianceMatrix_->Invert();

double det;
_inverseStrippedCovarianceMatrix_->Invert(&det);

bool failed{false};
if( det == 0 ){
LogError << "Determinant is null." << std::endl;
failed = true;
}

TVectorD eigenValues;
// https://root-forum.cern.ch/t/tmatrixt-get-eigenvalues/25924
_inverseStrippedCovarianceMatrix_->EigenVectors(eigenValues);
if( eigenValues.Min() < 0 ){
LogError << "Negative eigen values for prior cov matrix: " << eigenValues.Min() << std::endl;
failed = true;
}

LogThrowIf(failed, "Failed inverting prior covariance matrix of par set: " << getName() );

}
else {
LogWarning << "Decomposing the stripped covariance matrix..." << std::endl;
Expand Down

0 comments on commit 1deb689

Please # to comment.