19 const std::vector<std::string> &
variables,
const std::vector<std::string> & spectators)
22 mReader.reset(
new TMVA::Reader(options.c_str()));
27 for(std::vector<std::string>::const_iterator it = variables.begin(); it!=variables.end(); ++it)
29 mVariables.insert( std::pair<std::string,float>(*it,0.) );
34 for(std::vector<std::string>::const_iterator it = spectators.begin(); it!=spectators.end(); ++it)
36 mSpectators.insert( std::pair<std::string,float>(*it,0.) );
51 edm::LogError(
"InitializationError") <<
"TMVAEvaluator not properly initialized.";
57 edm::LogError(
"MissingInputs") <<
"Too few inputs provided (" << inputs.size() <<
" provided but " <<
mVariables.size() <<
" input and " <<
mSpectators.size() <<
" spectator variables expected).";
62 edm::LogError(
"MissingInputVariable(s)") <<
"Too few input variables provided (" << inputs.size() <<
" provided but " <<
mVariables.size() <<
" expected).";
69 if (inputs.count(it->first)>0)
70 it->second = inputs.at(it->first);
72 edm::LogError(
"MissingInputVariable") <<
"Input variable " << it->first <<
" is missing from the list of inputs. The returned discriminator value might not be sensible.";
81 if (inputs.count(it->first)>0)
82 it->second = inputs.at(it->first);
84 edm::LogError(
"MissingSpectatorVariable") <<
"Spectator variable " << it->first <<
" is missing from the list of inputs. The returned discriminator value might not be sensible.";
std::map< std::string, float > mVariables
float evaluate(const std::map< std::string, float > &inputs, const bool useSpectators=false)
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)
std::unique_ptr< TMVA::Reader > mReader
volatile std::atomic< bool > shutdown_flag false
void loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
std::map< std::string, float > mSpectators