// HTrackGenerator.cpp #include "HTrackGenerator.h" #include "trfbase/VTrackGenerator.h" #include "trfbase/HitGenerator.h" #include #include "trfbase/ETrack.h" #include "trffit/HTrack.h" #include "trfbase/Hit.h" #include "trfbase/PropStat.h" #include "trfbase/Propagator.h" #include "trfbase/Surface.h" using trf::Surface; using trf::TrackError; using trf::VTrack; using trf::PropStat; using trf::Propagator; using trf::HitList; using trf::HTrack; using trf::HTrackGenerator; //********************************************************************** // Constructor. HTrackGenerator::HTrackGenerator( const HitGeneratorList& hgens, const Propagator& prop, const Surface& srf, const TrackError& terr ) : _hgens(hgens), _terr(terr) { _pprop = prop.new_propagator(); _psrf = srf.new_pure_surface(); } //********************************************************************** // Destructor. // Members use reference-counting pointers so there is little to do // here. HTrackGenerator::~HTrackGenerator() { } //********************************************************************** // generate a new track HTrack* HTrackGenerator::new_track(const VTrack& trv) { HTrack* ptrh = 0; VTrack newtrv(trv); // Create new list of hits. HitList track_hits; // Loop over hit surfaces. HitGeneratorList::iterator ihgen; for ( ihgen=_hgens.begin(); ihgen!=_hgens.end(); ++ihgen ) { HitGenerator& hgen = **ihgen; // Propagate to the surface. PropStat pstat = _pprop->vec_prop(newtrv,hgen.get_surface()); if ( ! pstat.success() ) break; // Generate a cluster. ClusterPtr pclu = hgen.new_cluster(newtrv); if ( ! pclu ) break; // Generate a hit. HitList hits = pclu->predict( ETrack(newtrv,_terr) ); if ( ! hits.size() ) break; track_hits.push_back( hits.front() ); } // If the number of assigned does not equal the number of hit // generators, all hits were not found. Exit with error. if ( track_hits.size() != _hgens.size() ) return ptrh; // Propagate to the surface. VTrack starttrv(trv); PropStat pstat = _pprop->vec_prop(starttrv,*_psrf); if ( ! pstat.success() ) return ptrh; const ETrack tre(starttrv,_terr); ptrh = new HTrack(tre); HitList::iterator ihit; for ( ihit=track_hits.begin(); ihit!=track_hits.end(); ++ihit ) ptrh->add_hit(*ihit); return ptrh; } //**********************************************************************