28 #include "TDecompChol.h"
33 printOut <<
"genfit::MeasuredStateOnPlane ";
42 printOut <<
" 3D position: "; pos.Print();
43 printOut <<
" 3D momentum: "; mom.Print();
50 unsigned int dim =
cov_.GetNcols();
52 if (resetOffDiagonals) {
53 for (
unsigned int i=0; i<
dim; ++i) {
54 for (
unsigned int j=0; j<
dim; ++j) {
58 cov_(i,j) *= blowUpFac;
67 for (
unsigned int i=0; i<
dim; ++i) {
68 for (
unsigned int j=0; j<
dim; ++j) {
79 Exception e(
"KalmanFitterInfo::calcAverageState: forwardState and backwardState are not defined in the same plane.", __LINE__,__FILE__);
89 TMatrixDSym fCovInv, bCovInv, smoothed_cov;
97 retVal.
setCov(smoothed_cov);
143 TDecompChol d1(forwardState.
getCov());
144 bool success = d1.Decompose();
145 TDecompChol d2(backwardState.
getCov());
146 success &= d2.Decompose();
149 Exception e(
"KalmanFitterInfo::calcAverageState: ill-conditioned covariance matrix.", __LINE__,__FILE__);
153 int nRows = d1.GetU().GetNrows();
154 assert(nRows == d2.GetU().GetNrows());
155 TMatrixD S1inv, S2inv;
159 TMatrixD A(2*nRows, nRows);
160 TVectorD b(2 * nRows);
161 double *
const bk = b.GetMatrixArray();
162 double *
const Ak = A.GetMatrixArray();
163 const double* S1invk = S1inv.GetMatrixArray();
164 const double* S2invk = S2inv.GetMatrixArray();
166 for (
int i = 0; i < nRows; ++i) {
169 for (
int j = 0; j <= i; ++j) {
170 Ak[i*nRows + j] = S1invk[i*nRows + j];
171 Ak[(i + nRows)*nRows + j] = S2invk[i*nRows + j];
172 sum1 += S1invk[i*nRows + j]*forwardState.
getState().GetMatrixArray()[j];
173 sum2 += S2invk[i*nRows + j]*backwardState.
getState().GetMatrixArray()[j];
176 bk[i + nRows] = sum2;
180 A.ResizeTo(nRows, nRows);
185 for (
int i = 0; i < nRows; ++i) {
187 for (
int j = i; j < nRows; ++j) {
188 sum += inv.GetMatrixArray()[j*nRows+i] * b[j];
190 b.GetMatrixArray()[i] = sum;
193 TMatrixDSym(TMatrixDSym::kAtA, inv),