62 #ifndef IClassifierReader__def 63 #define IClassifierReader__def 65 class IClassifierReader {
70 IClassifierReader() : fStatusIsClean(
true ) {}
71 virtual ~IClassifierReader() {}
74 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
77 bool IsStatusClean()
const {
return fStatusIsClean; }
86 class ReadPDERS :
public IClassifierReader {
91 ReadPDERS( std::vector<std::string>& theInputVars )
92 : IClassifierReader(),
93 fClassName(
"ReadPDERS" ),
95 fIsNormalised(
false )
98 const char* inputVars[] = {
"var1+var2",
"var1-var2",
"var3",
"var4" };
101 if (theInputVars.size() <= 0) {
102 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
103 fStatusIsClean =
false;
106 if (theInputVars.size() != fNvars) {
107 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: " 108 << theInputVars.size() <<
" != " << fNvars << std::endl;
109 fStatusIsClean =
false;
113 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
114 if (theInputVars[ivar] != inputVars[ivar]) {
115 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
116 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
117 fStatusIsClean =
false;
143 virtual ~ReadPDERS() {
150 double GetMvaValue(
const std::vector<double>& inputValues )
const;
158 const char* fClassName;
161 size_t GetNvar()
const {
return fNvars; }
165 const bool fIsNormalised;
166 bool IsNormalised()
const {
return fIsNormalised; }
169 double NormVariable(
double x,
double xmin,
double xmax )
const {
171 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
179 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
184 inline double ReadPDERS::GetMvaValue(
const std::vector<double>& inputValues )
const 190 if (!IsStatusClean()) {
191 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response" 192 <<
" because status is dirty" << std::endl;
196 if (IsNormalised()) {
198 std::vector<double> iV;
199 iV.reserve(inputValues.size());
201 for (std::vector<double>::const_iterator varIt = inputValues.begin();
202 varIt != inputValues.end(); varIt++, ivar++) {
203 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
205 retval = GetMvaValue__( iV );
208 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)