00001
00002
00003 #ifndef __TRESULT__
00004 #define __TRESULT__
00005
00015 #include <TString.h>
00016 #include <map>
00017 #include <vector>
00018
00019
00020
00021
00022 namespace Root {
00023 class TResult
00024 {
00025
00026 public:
00028 TResult(const char* name="TResult");
00029
00031 TResult( const TResult& parent );
00032
00034 TResult& operator= ( const TResult& rhs );
00035
00037 virtual ~TResult();
00038
00039 public:
00042 inline operator double() const
00043 {
00044 return getNResults() >= 1 ? m_result[0] : m_defaultResult;
00045 }
00046
00047
00050 inline operator std::pair<double,double>() const
00051 {
00052 return getNResults() >= 2 ? std::make_pair( m_result[0], m_result[1] ) : std::make_pair( m_defaultResult, m_defaultResult );
00053 }
00054
00055
00057 inline double getEfficiency() const { return double(*this); };
00058
00060 inline double getScaleFactor() const { return double(*this); };
00061
00063 inline double getMVAResponse() const { return double(*this); };
00064
00066 inline double getTotalUncertainty() const
00067 {
00068 return getNResults() >= 2 ? m_result[1] : m_defaultResult;
00069 }
00070
00071
00072
00074 inline const char* getName() const { return m_name; }
00075
00076
00078 inline void clear()
00079 {
00080 for ( unsigned int i=0; i < m_result.size(); i++ )
00081 {
00082 m_result[i] = m_defaultResult;
00083 }
00084 }
00085
00086
00087
00089 inline unsigned int getNResults() const { return m_resultMap.size(); }
00090
00091
00093 int addResult( const TString& resultName, const TString& resultDescription );
00094
00095
00097 inline unsigned int getResultPosition( const TString& resultName ) const
00098 {
00099 std::map< TString, std::pair< TString, unsigned int > >::const_iterator it = m_resultMap.find(resultName);
00100 return (it != m_resultMap.end()) ? (it->second).second : 999999;
00101 }
00102
00103
00105 const TString& getResultName( unsigned int resultPosition ) const;
00106
00107
00109 inline const TString& getResultDescription( const TString& resultName ) const
00110 {
00111 std::map< TString, std::pair< TString, unsigned int > >::const_iterator it = m_resultMap.find(resultName);
00112 return (it != m_resultMap.end()) ? (it->second).first : m_emptyString;
00113 }
00114
00116 const TString& getResultDescription( unsigned int resultPosition ) const;
00117
00118
00120 inline double getResult( const TString& resultName ) const
00121 {
00122 unsigned int resultPosition = getResultPosition(resultName);
00123 return getResult(resultPosition);
00124 }
00125
00127 inline double getResult( unsigned int resultPosition ) const
00128 {
00129 return m_result[resultPosition];
00130 }
00131
00132
00134 inline std::vector<double> getResults() const
00135 {
00136 return m_result;
00137 }
00138
00139
00141 inline void setResult( const TString& resultName, double resultResult )
00142 {
00143 unsigned int resultPosition = getResultPosition(resultName);
00144 return setResult( resultPosition, resultResult );
00145 }
00146
00148 inline void setResult( unsigned int resultPosition, double resultResult )
00149 {
00150 m_result[resultPosition] = resultResult;
00151 return;
00152 }
00153
00154
00156 inline void setResultDescription( const TString& resultName, const TString& resultDescription )
00157 {
00158 unsigned int resultPosition = getResultPosition(resultName);
00159 return setResultDescription( resultPosition, resultDescription );
00160 }
00161
00163 void setResultDescription( unsigned int resultPosition, const TString& resultDescription );
00164
00165
00166 #ifdef ROOTCORE
00167
00168 ClassDef(TResult,1);
00169 #endif
00170
00171
00172
00173 protected:
00175 TString m_name;
00176
00177
00178
00179 private:
00181 double m_defaultResult;
00182
00184 std::vector<double> m_result;
00185
00187 std::map< TString, std::pair< TString, unsigned int > > m_resultMap;
00188
00190 TString m_emptyString;
00191
00192
00193 };
00194
00195 }
00196
00197
00198 #endif