57 #ifndef IClassifierReader__def 58 #define IClassifierReader__def 60 class IClassifierReader {
65 IClassifierReader() : fStatusIsClean(
true ) {}
66 virtual ~IClassifierReader() {}
69 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
72 bool IsStatusClean()
const {
return fStatusIsClean; }
81 class ReadFDA_GA :
public IClassifierReader {
86 ReadFDA_GA( std::vector<std::string>& theInputVars )
87 : IClassifierReader(),
88 fClassName(
"ReadFDA_GA" ),
90 fIsNormalised(
false )
93 const char* inputVars[] = {
"var1+var2",
"var1-var2",
"var3",
"var4" };
96 if (theInputVars.size() <= 0) {
97 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
98 fStatusIsClean =
false;
101 if (theInputVars.size() != fNvars) {
102 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: " 103 << theInputVars.size() <<
" != " << fNvars << std::endl;
104 fStatusIsClean =
false;
108 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
109 if (theInputVars[ivar] != inputVars[ivar]) {
110 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
111 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
112 fStatusIsClean =
false;
138 virtual ~ReadFDA_GA() {
145 double GetMvaValue(
const std::vector<double>& inputValues )
const;
153 const char* fClassName;
156 size_t GetNvar()
const {
return fNvars; }
160 const bool fIsNormalised;
161 bool IsNormalised()
const {
return fIsNormalised; }
164 double NormVariable(
double x,
double xmin,
double xmax )
const {
166 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
174 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
177 double fParameter[5];
182 fParameter[0] = 0.361717166844755;
185 fParameter[3] = 0.111212226929868;
189 inline double ReadFDA_GA::GetMvaValue__(
const std::vector<double>& inputValues )
const 192 double retval = fParameter[0]+fParameter[1]*inputValues[0]+fParameter[2]*inputValues[1]+fParameter[3]*inputValues[2]+fParameter[4]*inputValues[3];
198 inline void ReadFDA_GA::Clear()
202 inline double ReadFDA_GA::GetMvaValue(
const std::vector<double>& inputValues )
const 208 if (!IsStatusClean()) {
209 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response" 210 <<
" because status is dirty" << std::endl;
214 if (IsNormalised()) {
216 std::vector<double> iV;
217 iV.reserve(inputValues.size());
219 for (std::vector<double>::const_iterator varIt = inputValues.begin();
220 varIt != inputValues.end(); varIt++, ivar++) {
221 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
223 retval = GetMvaValue__( iV );
226 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)