56 #ifndef IClassifierReader__def 57 #define IClassifierReader__def 59 class IClassifierReader {
64 IClassifierReader() : fStatusIsClean(
true ) {}
65 virtual ~IClassifierReader() {}
68 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
71 bool IsStatusClean()
const {
return fStatusIsClean; }
80 class ReadFDA_GA :
public IClassifierReader {
85 ReadFDA_GA( std::vector<std::string>& theInputVars )
86 : IClassifierReader(),
87 fClassName(
"ReadFDA_GA" ),
89 fIsNormalised(
false )
92 const char* inputVars[] = {
"var1+var2",
"var1-var2",
"var3",
"var4" };
95 if (theInputVars.size() <= 0) {
96 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
97 fStatusIsClean =
false;
100 if (theInputVars.size() != fNvars) {
101 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: " 102 << theInputVars.size() <<
" != " << fNvars << std::endl;
103 fStatusIsClean =
false;
107 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
108 if (theInputVars[ivar] != inputVars[ivar]) {
109 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
110 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
111 fStatusIsClean =
false;
137 virtual ~ReadFDA_GA() {
144 double GetMvaValue(
const std::vector<double>& inputValues )
const;
152 const char* fClassName;
155 size_t GetNvar()
const {
return fNvars; }
159 const bool fIsNormalised;
160 bool IsNormalised()
const {
return fIsNormalised; }
163 double NormVariable(
double x,
double xmin,
double xmax )
const {
165 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
173 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
176 double fParameter[5];
181 fParameter[0] = 0.388369514970016;
182 fParameter[1] = -0.325754963750384;
183 fParameter[2] = -0.0794257398582496;
184 fParameter[3] = -0.195619674556562;
185 fParameter[4] = 0.758560461256256;
188 inline double ReadFDA_GA::GetMvaValue__(
const std::vector<double>& inputValues )
const 191 double retval = fParameter[0]+fParameter[1]*inputValues[0]+fParameter[2]*inputValues[1]+fParameter[3]*inputValues[2]+fParameter[4]*inputValues[3];
197 inline void ReadFDA_GA::Clear()
201 inline double ReadFDA_GA::GetMvaValue(
const std::vector<double>& inputValues )
const 207 if (!IsStatusClean()) {
208 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response" 209 <<
" because status is dirty" << std::endl;
213 if (IsNormalised()) {
215 std::vector<double> iV;
216 iV.reserve(inputValues.size());
218 for (std::vector<double>::const_iterator varIt = inputValues.begin();
219 varIt != inputValues.end(); varIt++, ivar++) {
220 iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
222 retval = GetMvaValue__( iV );
225 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)