// AddFitStarter.h #ifndef AddFitStarter_H #define AddFitStarter_H // This class inherits from AddFitter. It maintains a map of // add fitters indexed by the number and types of hits on the // track. Tracks at or below a threshold number of hits are // fit using the fitter indicated by the map. If the map has // no matching fitter, the track is left unfit. If the number // of hits is above threshold, then a default fitter is called. // // Sample object stream: // // [ addfit AddFitStarter // max_hits=3 // default_fitter=@fit_kalman // hit_types = string( // "HitCylPhi" ":" // "HitCylPhi" "HitCylPhi" ":" // "HitCylPhi" "HitCylPhi" "HitCylPhi" ":" // ) // fitters=@( fitc fitcc fitccc ) // ] #include "trffit/AddFitter.h" #include "trffit/AddFitterPtr.h" #include "ptr/Ptr.h" #include "ptr/NullPolicy.h" #include #include namespace trf { class AddFitStarter : public AddFitter { public: // enum // return for missing default fitter enum { DEFAULT_NOT_REGISTERED = 101 }; // return for type list not found in registry enum { TYPES_NOT_FOUND = 102 }; // return for type list registered as zero enum { TYPES_NOT_REGISTERED = 103 }; public: // typedefs // list of hit types typedef std::list TypeList; private: // typedefs // type list comparator typedef std::less TypeListComparator; // map of fitters typedef std::map AddFitterMap; public: // static methods // Return the type name. static TypeName get_type_name() { return "AddFitStarter"; } // Return the creator. static ObjCreator get_creator(); // Return the type. static Type get_static_type() { return get_creator(); } private: // attributes // maximum number of hits for which map is used int _max_hits; // default fitter AddFitterPtr _pfitter0; // map of fitters AddFitterMap _fitters; private: // methods // output stream void ostr(std::ostream& stream) const; public: // methods // constructor AddFitStarter(int max_hits); // destructor ~AddFitStarter(); // Return the type. Type get_type() const { return get_static_type(); } // Write object data. ObjData write_data() const; // set the default fitter // return true if an old fitter has been replaced bool register_default_fitter(const AddFitterPtr fitter); // register a hitter for a list of types // return true if an old fitter has been replaced bool register_fitter(const AddFitterPtr fitter, TypeList types); // register a hitter for one hit // return true if an old fitter has been replaced bool register_fitter(const AddFitterPtr fitter, Type type1); // register a hitter for two hits bool register_fitter(const AddFitterPtr fitter, Type type1, Type type2); // register a hitter for three hits bool register_fitter(const AddFitterPtr fitter, Type type1, Type type2, Type type3); // register a hitter for four hits bool register_fitter(const AddFitterPtr fitter, Type type1, Type type2, Type type3, Type type4); // register a hitter for five hits bool register_fitter(const AddFitterPtr fitter, Type type1, Type type2, Type type3, Type type4, Type type5); // Return the appropriate fitter for a list of hit types. const AddFitterPtr& get_fitter(const TypeList& types) const; // add a hit int add_hit_with_record(HTrack& trh, const HitPtr& phit, CutRecord* prec) const; }; } // end namespace trf #endif