67 #ifndef IClassifierReader__def 68 #define IClassifierReader__def 70 class IClassifierReader {
75 IClassifierReader() : fStatusIsClean(
true ) {}
76 virtual ~IClassifierReader() {}
79 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
82 bool IsStatusClean()
const {
return fStatusIsClean; }
91 class ReadPDEFoam :
public IClassifierReader {
96 ReadPDEFoam( std::vector<std::string>& theInputVars )
97 : IClassifierReader(),
98 fClassName(
"ReadPDEFoam" ),
100 fIsNormalised(
false )
103 const char* inputVars[] = {
"var1+var2",
"var1-var2",
"var3",
"var4" };
106 if (theInputVars.size() <= 0) {
107 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
108 fStatusIsClean =
false;
111 if (theInputVars.size() != fNvars) {
112 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: " 113 << theInputVars.size() <<
" != " << fNvars << std::endl;
114 fStatusIsClean =
false;
118 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
119 if (theInputVars[ivar] != inputVars[ivar]) {
120 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
121 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
122 fStatusIsClean =
false;
148 virtual ~ReadPDEFoam() {
155 double GetMvaValue(
const std::vector<double>& inputValues )
const;
163 const char* fClassName;
166 size_t GetNvar()
const {
return fNvars; }
170 const bool fIsNormalised;
171 bool IsNormalised()
const {
return fIsNormalised; }
174 double NormVariable(
double x,
double xmin,
double xmax )
const {
176 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
184 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
187 inline double ReadPDEFoam::GetMvaValue(
const std::vector<double>& inputValues )
const 193 if (!IsStatusClean()) {
194 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response" 195 <<
" because status is dirty" << std::endl;
199 if (IsNormalised()) {
201 std::vector<double> iV;
202 iV.reserve(inputValues.size());
204 for (std::vector<double>::const_iterator varIt = inputValues.begin();
205 varIt != inputValues.end(); varIt++, ivar++) {
206 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
208 retval = GetMvaValue__( iV );
211 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)