CMS 3D CMS Logo

ErrorMatrixPropagator.cc
Go to the documentation of this file.
1 /* From SimpleFits Package
2  * Designed an written by
3  * author: Ian M. Nugent
4  * Humboldt Foundations
5  */
7 #include <cmath>
8 #include <iostream>
9 
10 using namespace tauImpactParameter;
11 
12 TMatrixTSym<double> ErrorMatrixPropagator::propagateError(std::function<TVectorT<double>(const TVectorT<double>&)> f,
13  const TVectorT<double>& inPar,
14  TMatrixTSym<double>& inCov,
15  double epsilon,
16  double errorEpsilonRatio) {
17  TVectorT<double> v = f(inPar);
18  TMatrixT<double> Jacobian(inPar.GetNrows(), v.GetNrows());
19  for (int i = 0; i < inPar.GetNrows(); i++) {
20  TVectorT<double> ParPlusEpsilon = inPar;
21  double error = sqrt(fabs(inCov(i, i)));
22  double delta = epsilon;
23  if (delta * errorEpsilonRatio < error)
24  delta = error / errorEpsilonRatio;
25  ParPlusEpsilon(i) += delta;
26  TVectorT<double> vp = f(ParPlusEpsilon);
27  for (int j = 0; j < v.GetNrows(); j++) {
28  Jacobian(i, j) = (vp(j) - v(j)) / delta;
29  } // Newtons approx.
30  }
31  TMatrixTSym<double> newCov = inCov.SimilarityT(Jacobian);
32  return newCov;
33 }
T sqrt(T t)
Definition: SSEVec.h:19
double f[11][100]
static TMatrixTSym< double > propagateError(std::function< TVectorT< double >(const TVectorT< double > &)> f, const TVectorT< double > &inPar, TMatrixTSym< double > &inCov, double epsilon=0.001, double errorEpsilonRatio=1000)