//////////////////////////////////////////////////////////////////////// /// \class RAT::DS::FitClassiferCollection /// /// \brief Collection of FitResults or ClassifierResults /// /// \author M Mottram /// /// REVISION HISTORY:\n /// 2014/07/01 : M Mottram - New file \n /// /// \details Template class /// //////////////////////////////////////////////////////////////////////// #ifndef __RAT_DS_FitClassifierCollection__ #define __RAT_DS_FitClassifierCollection__ #include #include #include #include #include #include namespace RAT { namespace DS { template class FitClassifierCollection : public TObject { public: class NoResultError : public DataNotFound { public: /// Construct the error naming the variable that is problematic /// /// @param[in] className of class the variable is a member of /// @param[in] fieldName of the variable NoResultError( const std::string className, const std::string fieldName ) : DataNotFound(className, fieldName) { } }; /// Constructs the fit collection, do nothing FitClassifierCollection() : TObject() { } /// Get names of results /// /// @return vector result names std::vector GetNames() const { return keys_in_map( results ); } /// Get result /// /// @return result of classifier or fitter const T& GetResult( const std::string& name ) const { if( results.count( name ) == 0 ) throw NoResultError( "FitClassifierCollection", name ); return results.at( name ); }; /// Check if a result exists /// /// @param[in] name of result Bool_t ResultExists( const std::string& name ) const { return results.count( name ) > 0; } /// Set a named result /// /// @param[in] name of result /// @param[in] result of fitter or classifier void SetResult( const std::string& name, const T& result ) { results[name] = result; } /// Prune named result /// /// @param[in] name of result void PruneResult( const std::string& name ) { results.erase( name ); } protected: std::map results; ///< map results, indexed by name ClassDefNV( FitClassifierCollection, 1 ); }; typedef FitClassifierCollection FitCollection; ///< typedef for collection of FitResults typedef FitClassifierCollection ClassifierCollection; ///< typedef for collection of ClassifierResults } // namespace DS } // namespace RAT #endif