// AddFitKalman.cpp #include "AddFitKalman.h" #include #include "objstream/ObjData.hpp" #include "objstream/ObjTable.hpp" #include "trfutil/trfstream.h" #include "trfbase/Hit.h" #include "trfbase/Surface.h" #include "HTrack.h" using std::ostream; using std::cout; using std::endl; using trf::TrfVector; using trf::TrfMatrix; using trf::TrfSMatrix; using trf::HitPtr; using trf::ETrack; using trf::AddFitKalman; //********************************************************************** // Free functions. //********************************************************************** namespace { // Creator ObjPtr create(const ObjData& data) { assert( data.get_object_type() == "AddFitKalman" ); if ( data.get_object_type() != "AddFitKalman" ) return ObjPtr(0); AddFitKalman* pobj = new AddFitKalman; if ( data.has("debug") ) { bool flag = data.get_bool("debug"); pobj->set_debug(flag); } return ObjPtr(pobj); } } //********************************************************************** // Nested class methods. //********************************************************************** // Constructor. // Allocate the space required for hit vectors, hit errors, derivatives // and gains for hits of dimension size. AddFitKalman::Box::Box(int size) : _size(size) { int icnt; for ( icnt=0; icnt= eii*ejj ) ++nbad; } } if ( nbad > 0 ) return 5; } // Create track vector with new values. tre.set_vector_and_keep_direction(TrackVector(new_vec)); tre.set_error(TrackError(new_err)); // Calculate residual vector. // Update the hit with the new track. hit.update(tre); hit_res = hit.difference_vector().get_vector(); new_dhit_dtrk = hit.dhit_dtrack().get_matrix(); // Calculate residual covariance and invert. hit_res_err = hit_err - dhit_dtrk%new_err; if ( invert( hit_res_err ) ) return 4; // Update chi-square. double dchsq = hit_res_err % hit_res; chsq = chsq + dchsq; if ( get_debug() ) { cout << endl; cout << "gain: " << endl << gain << endl; cout << endl; cout << "new_vec: " << endl <