12 #include "TMVA/Factory.h" 13 #include "TMVA/Reader.h" 48 preselection_(iConfig.getParameter<
std::
string>(
"preselection")),
49 method_(iConfig.getParameter<
std::
string>(
"method")),
50 weightsFile_(iConfig.getParameter<
std::
string>(
"weightsFile")),
51 reader_(new TMVA::Reader()),
52 wp_(iConfig.getParameter<
std::
string>(
"wp")) {
54 for (
const auto &psvar : iConfig.
getParameter<std::vector<edm::ParameterSet>>(
"variables")) {
66 produces<l1t::HGCalMulticlusterBxCollection>();
67 produces<l1t::HGCalMulticlusterBxCollection>(
"fail");
71 std::unique_ptr<l1t::HGCalMulticlusterBxCollection>
out = std::make_unique<l1t::HGCalMulticlusterBxCollection>();
72 std::unique_ptr<l1t::HGCalMulticlusterBxCollection> fail = std::make_unique<l1t::HGCalMulticlusterBxCollection>();
75 iEvent.getByToken(src_, multiclusters);
77 for (
int bx = multiclusters->getFirstBX();
bx <= multiclusters->getLastBX(); ++
bx) {
78 for (
auto it = multiclusters->begin(
bx), ed = multiclusters->end(
bx); it != ed; ++it) {
80 if (preselection_(
c)) {
81 for (
auto &
var : variables_)
83 float mvaOut = reader_->EvaluateMVA(method_);
84 if (mvaOut > wp_(
c)) {
87 fail->push_back(
bx,
c);
Var(const std::string &name, const std::string &expr)
void produce(edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
std::vector< Var > variables_
std::string fullPath() const
#define DEFINE_FWK_MODULE(type)
std::unique_ptr< TMVA::Reader > reader_
StringCutObjectSelector< l1t::HGCalMulticluster > preselection_
StringObjectFunction< l1t::HGCalMulticluster > expr_
StringObjectFunction< l1t::HGCalMulticluster > wp_
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollection > src_
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
void declare(TMVA::Reader &r)
~HGC3DClusterTMVASelector() override
HGC3DClusterTMVASelector(const edm::ParameterSet &)
void fill(const l1t::HGCalMulticluster &c)