53#ifndef IClassifierReader__def
54#define IClassifierReader__def
56class IClassifierReader {
61 IClassifierReader() : fStatusIsClean(
true ) {}
62 virtual ~IClassifierReader() {}
65 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
68 bool IsStatusClean()
const {
return fStatusIsClean; }
77class ReadLD :
public IClassifierReader {
82 ReadLD( std::vector<std::string>& theInputVars )
83 : IClassifierReader(),
84 fClassName(
"ReadLD" ),
88 const char* inputVars[] = {
"var1+var2",
"var1-var2",
"var3",
"var4" };
91 if (theInputVars.size() <= 0) {
92 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
93 fStatusIsClean =
false;
96 if (theInputVars.size() != fNvars) {
97 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: "
98 << theInputVars.size() <<
" != " << fNvars << std::endl;
99 fStatusIsClean =
false;
103 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
104 if (theInputVars[ivar] != inputVars[ivar]) {
105 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
106 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
107 fStatusIsClean =
false;
140 double GetMvaValue(
const std::vector<double>& inputValues )
const override;
148 const char* fClassName;
151 size_t GetNvar()
const {
return fNvars; }
157 double NormVariable(
double x,
double xmin,
double xmax )
const {
167 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
170 std::vector<double> fLDCoefficients;
175 fLDCoefficients.push_back( -0.0548834585145 );
176 fLDCoefficients.push_back( -0.309417182502 );
177 fLDCoefficients.push_back( -0.101898689979 );
178 fLDCoefficients.push_back( -0.142337150119 );
179 fLDCoefficients.push_back( 0.705328504943 );
182 if (fLDCoefficients.size() != fNvars+1) {
183 std::cout <<
"Problem in class \"" << fClassName <<
"\"::Initialize: mismatch in number of input values"
184 << fLDCoefficients.size() <<
" != " << fNvars+1 << std::endl;
185 fStatusIsClean =
false;
189inline double ReadLD::GetMvaValue__(
const std::vector<double>& inputValues )
const
191 double retval = fLDCoefficients[0];
192 for (
size_t ivar = 1; ivar < fNvars+1; ivar++) {
193 retval += fLDCoefficients[ivar]*inputValues[ivar-1];
200inline void ReadLD::Clear()
203 fLDCoefficients.clear();
205 inline double ReadLD::GetMvaValue(
const std::vector<double>& inputValues )
const
211 if (!IsStatusClean()) {
212 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response"
213 <<
" because status is dirty" << std::endl;
217 retval = GetMvaValue__( inputValues );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)