61 #ifndef IClassifierReader__def 62 #define IClassifierReader__def 64 class IClassifierReader {
69 IClassifierReader() : fStatusIsClean(
true ) {}
70 virtual ~IClassifierReader() {}
73 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
76 bool IsStatusClean()
const {
return fStatusIsClean; }
85 class ReadPDERS :
public IClassifierReader {
90 ReadPDERS( std::vector<std::string>& theInputVars )
91 : IClassifierReader(),
92 fClassName(
"ReadPDERS" ),
94 fIsNormalised(
false )
97 const char* inputVars[] = {
"var1+var2",
"var1-var2",
"var3",
"var4" };
100 if (theInputVars.size() <= 0) {
101 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
102 fStatusIsClean =
false;
105 if (theInputVars.size() != fNvars) {
106 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: " 107 << theInputVars.size() <<
" != " << fNvars << std::endl;
108 fStatusIsClean =
false;
112 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
113 if (theInputVars[ivar] != inputVars[ivar]) {
114 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
115 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
116 fStatusIsClean =
false;
142 virtual ~ReadPDERS() {
149 double GetMvaValue(
const std::vector<double>& inputValues )
const;
157 const char* fClassName;
160 size_t GetNvar()
const {
return fNvars; }
164 const bool fIsNormalised;
165 bool IsNormalised()
const {
return fIsNormalised; }
168 double NormVariable(
double x,
double xmin,
double xmax )
const {
170 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
178 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
183 inline double ReadPDERS::GetMvaValue(
const std::vector<double>& inputValues )
const 189 if (!IsStatusClean()) {
190 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response" 191 <<
" because status is dirty" << std::endl;
195 if (IsNormalised()) {
197 std::vector<double> iV;
198 iV.reserve(inputValues.size());
200 for (std::vector<double>::const_iterator varIt = inputValues.begin();
201 varIt != inputValues.end(); varIt++, ivar++) {
202 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
204 retval = GetMvaValue__( iV );
207 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)