33 #define COVEXC "cov_is_zero"
42 std::cout<<
"GFKalman::processTrack "<<std::endl;
49 for(
int i=0; i<nreps; i++) {
53 bool already_there =
false;
54 for(
unsigned int j=0; j<mat_keys.size(); j++) {
55 if(mat_keys.at(j) ==
"fUpSt") already_there =
true;
57 if(already_there)
continue;
80 assert(direction==1 || direction==-1);
87 for(
int ipass=0; ipass<2*
fNumIt; ipass++){
91 if(ipass==(2*fNumIt)-1) {
92 for(
int i=0; i<nreps; ++i) {
107 for(
int i=0; i<nreps; ++i){
117 for(
int i=0; i<nreps; ++i){
128 if(direction==1) direction=-1;
139 for(
int i=0; i<nreps; ++i){
155 int ihit=(int)starthit;
157 for(
int irep=0; irep<nreps; ++irep) {
161 if (direction == -1){
173 while((ihit<(
int)nhits && direction==1) || (ihit>-1 && direction==-1)){
176 for(
int irep=0; irep<nreps; ++irep){
181 std::cout<<
"++++++++++++++++++++++++++++++++++++++++\n";
182 std::cout<<
"GFKalman::fittingPass - process rep nr. "<<irep<<
" and hit nr. "<<ihit<<std::endl;
188 std::cerr << e.
what();
204 const TMatrixT<double>&
cov,
const TMatrixT<double>& V){
207 TMatrixT<double>
R(V);
208 TMatrixT<double> covsum1(cov,TMatrixT<double>::kMultTranspose,H);
209 TMatrixT<double> covsum(H,TMatrixT<double>::kMult,covsum1);
214 TMatrixT<double> Rinv;
218 TMatrixT<double> residTranspose(r);
220 TMatrixT<double> chisq=residTranspose*(Rinv*r);
221 assert(chisq.GetNoElements()==1);
223 if(TMath::IsNaN(chisq[0][0])){
226 std::vector< TMatrixT<double> > matrices;
227 matrices.push_back(r);
228 matrices.push_back(V);
229 matrices.push_back(R);
230 matrices.push_back(cov);
244 TMatrixT<double> state(repDim,1);
245 TMatrixT<double>
cov(repDim,repDim);;
251 TMatrixT<double>
m,V;
254 TMatrixT<double> res = m-(H*state);
255 assert(res.GetNrows()>0);
260 return chi2/res.GetNrows();
270 int repDim = rep->
getDim();
271 TMatrixT<double> state(repDim,1);
272 TMatrixT<double>
cov(repDim,repDim);;
294 if(cov[0][0]<1.E-50){
315 std::cerr<<
"GFKalman::processHit - state and cov prediction "<<std::endl;
321 TMatrixT<double>
m, V;
323 TMatrixT<double> res = m-(
H*state);
326 TMatrixT<double> Gain(
calcGain(cov,V,
H));
329 TMatrixT<double>
update=Gain*res;
332 std::cout<<
"Gain"; Gain.Print();
333 std::cout<<
"residual vector"; res.Print();
334 std::cout<<
"update = Gain*res"; update.Print();
360 int ndf = res.GetNrows();
361 if (direction == -1) {
364 if (direction == 1) {
394 std::cout<<
"GFKalman::processHit - updated state and cov "<<std::endl;
403 const TMatrixT<double>& HitCov,
404 const TMatrixT<double>& H){
407 TMatrixT<double> covsum1(cov,TMatrixT<double>::kMultTranspose,H);
408 TMatrixT<double> covsum(H,TMatrixT<double>::kMult,covsum1);
413 TMatrixT<double> covsumInv;
417 TMatrixT<double> gain1(H,TMatrixT<double>::kTransposeMult,covsumInv);
418 TMatrixT<double> gain(cov,TMatrixT<double>::kMult,gain1);