// AddFitter.h #ifndef AddFitter_H #define AddFitter_H // Adds a hit prediction to a track, refit the track and use the // new track parameters to update the hit prediction. // // Two type methods are provided: one updates an ETrack and it chi-square // and the other updates an HTrack. For each type there are two methods: // one with a hit record and one without. Default impementations are // provided for all methods. Subclasses must implement at least one. // // If a subclass implements either HTrack method, then calls to the other // will appropriately call the implemented method. // // If a subclass implements either ETrack method, then calls to the other // will appropriately call the implemented method. If neither HTrack method // is implemented, then the implemented ETrack method is used. // // Typically, the original call is HTrack with record. This invokes the // first implemented subclass method in the following order of precedence: // 1. HTrack without record // 2. ETrack with record // 3. ETrack without record // // If neither ETrack method is overridedn, then ETrack fits throw an // assertion or fail if assertions are disabled. // #include "trfbase/Algorithm.h" #include "trfbase/Hit.h" namespace trf { class HTrack; class CutRecord; class AddFitter : public Algorithm { private: // Data. // Flags to find the appropriate subclass method. mutable bool _base_add_hit; mutable bool _base_add_hit_fit; public: // Static methods. // Return the type name. static TypeName get_type_name() { return "AddFitter"; } // Return the creator. static ObjCreator get_creator(); // Return the type. static Type get_static_type() { return get_creator(); } public: // methods // constructor AddFitter(); // destructor virtual ~AddFitter(); // Return the generic type. // This is only needed at this level. Type get_generic_type() const { return get_static_type(); } // Add a hit and fit with the new hit. // Return status 0 if fit is successful, negative value for a local // error and positive for an error in add_hit_fit. // The default method calls add_hit_fit and return its status. // If the fit is successful, then the track fit is updated and the hit // is added to the end of its list. virtual int add_hit(HTrack& trh, const HitPtr& phit) const; // Same as above with the addition of a cut record. virtual int add_hit_with_record(HTrack& trh, const HitPtr& phit, CutRecord* prec) const; // Refit a track and update its chi-square by adding the specified hit. // Return status 0 if fit is successful, positive value for error. // This is the method implemented by subclasses. // If the fit fails, the track and chi-square may return any value // and the hit may be updated with any track. // If the fit is successful, the fit track and chi-square are // returned and the hit is updated with the fit track. // Normally this is not invoked directly but is called by add_hit. // The default method here returns an error. virtual int add_hit_fit(ETrack& tre, double& chisq, const HitPtr& phit) const; // Same as the above with the addition of a cut record. virtual int add_hit_fit_with_record(ETrack& tre, double& chisq, const HitPtr& phit, CutRecord* prec) const; }; } // end namespace trf #endif