27 #include <TMVA/Types.h> 28 #include <TMVA/MethodBase.h> 29 #include "TMVA/Reader.h" 39 #include <boost/filesystem.hpp> 50 ProcTMVA(
const char *
name,
53 virtual ~ProcTMVA() {}
55 virtual void configure(ConfIterator iter,
unsigned int n)
override;
56 virtual void eval(ValueIterator iter,
unsigned int n)
const override;
59 std::unique_ptr<TMVA::Reader>
reader;
70 ProcTMVA::ProcTMVA(
const char *
name,
76 reader = std::unique_ptr<TMVA::Reader>(
new TMVA::Reader(
"!Color:Silent" ));
79 reinterpret_cast<const char*>(&calib->
store.front()),
83 std::getline(izs, methodName);
86 std::getline(izs, tmp);
87 std::istringstream iss(tmp);
89 for(
unsigned int i = 0;
i < nVars;
i++) {
90 std::getline(izs, tmp);
91 reader->DataInfo().AddVariable(tmp.c_str());
97 while (std::getline(izs, line)) {
104 TMVA::Types::EMVA methodType =
105 TMVA::Types::Instance().GetMethodType(methodName);
107 if (weight_text.find(
"<?xml") != std::string::npos) {
108 method =
dynamic_cast<TMVA::MethodBase*
>(
reader->BookMVA( methodType, weight_text.c_str() ) );
111 TString weight_file_name(boost::filesystem::unique_path().c_str());
112 std::ofstream weight_file;
113 weight_file.open(weight_file_name.Data());
114 weight_file << weight_text;
116 edm::LogInfo(
"LegacyMVA") <<
"Building legacy TMVA plugin - " 117 <<
"the weights are being stored in " << weight_file_name << std::endl;
118 methodName_t.Append(methodName.c_str());
119 method =
dynamic_cast<TMVA::MethodBase*
>(
reader->BookMVA( methodName_t, weight_file_name ) );
120 remove(weight_file_name.Data());
188 void ProcTMVA::configure(ConfIterator iter,
unsigned int n)
193 for(
unsigned int i = 0;
i <
n;
i++)
194 iter++(Variable::FLAG_NONE);
196 iter << Variable::FLAG_NONE;
199 void ProcTMVA::eval(ValueIterator iter,
unsigned int n)
const 201 std::vector<Float_t>
inputs;
203 for(
unsigned int i = 0;
i <
n;
i++)
204 inputs.push_back(*iter++);
205 std::unique_ptr<TMVA::Event> evt(
new TMVA::Event(inputs, 2));
#define MVA_COMPUTER_DEFINE_PLUGIN(T)
std::vector< std::vector< double > > tmp