Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:21

0001 /* Copyright 2008-2010, Technische Universitaet Muenchen,
0002    Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
0003 
0004    This file is part of GENFIT.
0005 
0006    GENFIT is free software: you can redistribute it and/or modify
0007    it under the terms of the GNU Lesser General Public License as published
0008    by the Free Software Foundation, either version 3 of the License, or
0009    (at your option) any later version.
0010 
0011    GENFIT is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014    GNU Lesser General Public License for more details.
0015 
0016    You should have received a copy of the GNU Lesser General Public License
0017    along with GENFIT.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 /** @addtogroup genfit
0021  * @{
0022  */
0023 
0024 #ifndef genfit_Tools_h
0025 #define genfit_Tools_h
0026 
0027 #include <TVectorD.h>
0028 #include <TMatrixD.h>
0029 #include <TMatrixDSym.h>
0030 
0031 /**
0032  * @brief Matrix inversion tools.
0033  */
0034 namespace genfit {
0035 
0036 class AbsHMatrix;
0037 
0038 namespace tools {
0039 
0040 /** @brief Invert a matrix, throwing an Exception when inversion fails.
0041  * Optional calculation of determinant.
0042  */
0043 void invertMatrix(const TMatrixDSym& mat, TMatrixDSym& inv, double* determinant = nullptr);
0044 /** @brief Same, replacing its argument.
0045  */
0046 void invertMatrix(TMatrixDSym& mat, double* determinant = nullptr);
0047 
0048 /** @brief Solves R^t x = b, replacing b with the solution for x.  R is
0049  *  assumed to be upper diagonal.
0050  */
0051 bool transposedForwardSubstitution(const TMatrixD& R, TVectorD& b);
0052 /** @brief Same, for a column of the matrix b.  */
0053 bool transposedForwardSubstitution(const TMatrixD& R, TMatrixD& b, int nCol);
0054 /** @brief Inverts the transpose of the upper right matrix R into inv.  */
0055 bool transposedInvert(const TMatrixD& R, TMatrixD& inv);
0056 
0057 /** @brief Replaces A with an upper right matrix connected to A by
0058  *  an orthongonal transformation.  I.e., it computes R from a QR
0059  *  decomposition of A = QR, replacing A.
0060  */
0061 void QR(TMatrixD& A);
0062 
0063 /** @brief Replaces A with an upper right matrix connected to A by
0064  *  an orthongonal transformation.  I.e., it computes R from a QR
0065  *  decomposition of A = QR, replacing A.  Also replaces b by Q'b
0066  *  where Q' is the transposed of Q.
0067  */
0068 void QR(TMatrixD& A, TVectorD& b);
0069 
0070 /** @brief Calculate a sqrt for the positive semidefinite noise
0071  *  matrix.  Rows corresponding to zero eigenvalues are omitted.
0072  *  This gives the transposed of the square root, i.e.
0073  *    noise = noiseSqrt * noiseSqrt'
0074  */    
0075 void
0076 noiseMatrixSqrt(const TMatrixDSym& noise,
0077         TMatrixD& noiseSqrt);
0078 
0079 /** @brief Calculates the square root of the covariance matrix after
0080  *  the Kalman prediction (i.e. extrapolation) with transport matrix F
0081  *  and the noise square root Q.  Gives the new covariance square
0082  *  root.  */
0083 void
0084 kalmanPredictionCovSqrt(const TMatrixD& S,
0085             const TMatrixD& F, const TMatrixD& Q,
0086             TMatrixD& Snew);
0087 
0088 /** @brief Calculate the Kalman measurement update with no transport.
0089  *  x, S : state prediction, covariance square root
0090  *  res, R, H : residual, measurement covariance square root, H matrix of the measurement
0091  */
0092 void
0093 kalmanUpdateSqrt(const TMatrixD& S,
0094          const TVectorD& res, const TMatrixD& R, const AbsHMatrix* H,
0095          TVectorD& update, TMatrixD& SNew);
0096 
0097 } /* End of namespace tools */
0098 } /* End of namespace genfit */
0099 /** @} */
0100 
0101 #endif // genfit_Tools_h