// FullFitKalman.cpp #include "FullFitKalman.h" #include "objstream/ObjData.hpp" #include "objstream/ObjTable.hpp" #include "trfutil/trfstream.h" #include "HTrack.h" #include "trfbase/Propagator.h" #include "trfbase/PropStat.h" using trf::PropStat; using trf::HitPtr; using trf::HitList; using trf::PropagatorPtr; using trf::FullFitKalman; //********************************************************************** // Free functions. //********************************************************************** namespace { // Creator // We need to add the list of registered fitters. ObjPtr create(const ObjData& data) { assert( data.get_object_type() == "FullFitKalman" ); if ( data.get_object_type() != "FullFitKalman" ) return ObjPtr(0); PropagatorPtr pprop; data.get_share_pointer("prop",pprop); return ObjPtr( new FullFitKalman(pprop) ); } } //********************************************************************** // Member functions. //********************************************************************** // constructor FullFitKalman::FullFitKalman(const PropagatorPtr& pprop) : _pprop(pprop) { } //********************************************************************** // destructor FullFitKalman::~FullFitKalman() { } //********************************************************************** // Return the creator. ObjCreator FullFitKalman::get_creator() { return create; } //********************************************************************** // Write object data. ObjData FullFitKalman::write_data() const { ObjData data("FullFitKalman"); data.add_share_pointer("prop",_pprop); return data; } //********************************************************************** // Fit. int FullFitKalman::fit(HTrack& trh) const { // Copy the hits from the track. HitList hits = trh.get_hits(); // Delete the list of hits from the track. while ( trh.get_hits().size() ) trh.drop_hit(); // Set direction to be nearest. Propagator::PropDir dir = Propagator::NEAREST; // Loop over hits and fit. int icount = 0; HitList::iterator ihit; for ( ihit=hits.begin(); ihit!=hits.end(); ++ihit ) { // Extract the next hit pointer. HitPtr& phit = *ihit; // propagate to the surface PropStat pstat = trh.propagate(*_pprop,phit->get_surface(),dir); if ( ! pstat.success() ) return icount; // fit track int fstat = _addfit.add_hit(trh,*ihit); if ( fstat ) return 10000 + 1000*fstat + icount; } return 0; } //********************************************************************** // output stream void FullFitKalman::ostr(ostream& stream) const { stream << begin_object; stream << "FullFitKalman"; stream << end_object; } //**********************************************************************