66 #ifndef IClassifierReader__def 67 #define IClassifierReader__def 69 class IClassifierReader {
74 IClassifierReader() : fStatusIsClean(
true ) {}
75 virtual ~IClassifierReader() {}
78 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
81 bool IsStatusClean()
const {
return fStatusIsClean; }
90 class ReadCuts :
public IClassifierReader {
95 ReadCuts( std::vector<std::string>& theInputVars )
96 : IClassifierReader(),
97 fClassName(
"ReadCuts" ),
99 fIsNormalised(
false )
102 const char* inputVars[] = {
"var1+var2",
"var1-var2",
"var3",
"var4" };
105 if (theInputVars.size() <= 0) {
106 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
107 fStatusIsClean =
false;
110 if (theInputVars.size() != fNvars) {
111 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: " 112 << theInputVars.size() <<
" != " << fNvars << std::endl;
113 fStatusIsClean =
false;
117 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
118 if (theInputVars[ivar] != inputVars[ivar]) {
119 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
120 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
121 fStatusIsClean =
false;
147 virtual ~ReadCuts() {
154 double GetMvaValue(
const std::vector<double>& inputValues )
const;
162 const char* fClassName;
165 size_t GetNvar()
const {
return fNvars; }
169 const bool fIsNormalised;
170 bool IsNormalised()
const {
return fIsNormalised; }
173 double NormVariable(
double x,
double xmin,
double xmax )
const {
175 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
183 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
188 inline double ReadCuts::GetMvaValue(
const std::vector<double>& inputValues )
const 194 if (!IsStatusClean()) {
195 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response" 196 <<
" because status is dirty" << std::endl;
200 if (IsNormalised()) {
202 std::vector<double> iV;
203 iV.reserve(inputValues.size());
205 for (std::vector<double>::const_iterator varIt = inputValues.begin();
206 varIt != inputValues.end(); varIt++, ivar++) {
207 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
209 retval = GetMvaValue__( iV );
212 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)