14 const std::vector<std::string>&
variables,
19 mReader.reset(
new TMVA::Reader(options.c_str()));
24 for (std::vector<std::string>::const_iterator it = variables.begin(); it != variables.end(); ++it) {
25 mVariables.insert(std::make_pair(*it, std::make_pair(it - variables.begin(), 0.)));
30 for (std::vector<std::string>::const_iterator it = spectators.begin(); it != spectators.end(); ++it) {
31 mSpectators.insert(std::make_pair(*it, std::make_pair(it - spectators.begin(), 0.)));
52 const std::vector<std::string>&
variables,
56 for (std::vector<std::string>::const_iterator it = variables.begin(); it != variables.end(); ++it)
57 mVariables.insert(std::make_pair(*it, std::make_pair(it - variables.begin(), 0.)));
60 for (std::vector<std::string>::const_iterator it = spectators.begin(); it != spectators.end(); ++it)
61 mSpectators.insert(std::make_pair(*it, std::make_pair(it - spectators.begin(), 0.)));
73 const std::vector<std::string>&
variables,
92 if (inputs.count(it->first) > 0)
93 it->second.second = inputs.at(it->first);
96 <<
"Input variable " << it->first
97 <<
" is missing from the list of inputs. The returned discriminator value might not be sensible.";
104 if (inputs.count(it->first) > 0)
105 it->second.second = inputs.at(it->first);
108 <<
"Spectator variable " << it->first
109 <<
" is missing from the list of inputs. The returned discriminator value might not be sensible.";
127 if (inputs.count(it->first) > 0)
128 vars[it->second.first] = inputs.at(it->first);
131 <<
"Input variable " << it->first
132 <<
" is missing from the list of inputs. The returned discriminator value might not be sensible.";
149 edm::LogError(
"InitializationError") <<
"TMVAEvaluator not properly initialized.";
154 edm::LogError(
"MissingInputs") <<
"Too few inputs provided (" << inputs.size() <<
" provided but " 156 <<
" spectator variables expected).";
158 }
else if (inputs.size() <
mVariables.size()) {
159 edm::LogError(
"MissingInputVariable(s)") <<
"Too few input variables provided (" << inputs.size()
160 <<
" provided but " <<
mVariables.size() <<
" expected).";
167 <<
"Use of spectator variables with GBRForest is not supported. Spectator variables will be ignored.";
void initializeGBRForest(const GBRForest *gbrForest, const std::vector< std::string > &variables, const std::vector< std::string > &spectators, bool useAdaBoost=false)
std::map< std::string, std::pair< size_t, float > > mVariables
void initialize(const std::string &options, const std::string &method, const std::string &weightFile, const std::vector< std::string > &variables, const std::vector< std::string > &spectators, bool useGBRForest=false, bool useAdaBoost=false)
float evaluateTMVA(const std::map< std::string, float > &inputs, bool useSpectators) const
std::shared_ptr< const GBRForest > mGBRForest
std::map< std::string, std::pair< size_t, float > > mSpectators
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
std::unique_ptr< TMVA::Reader > mReader
float evaluate(const std::map< std::string, float > &inputs, bool useSpectators=false) const
float evaluateGBRForest(const std::map< std::string, float > &inputs) const
T const * product() const