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>();
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)) {
85 out->push_back(
bx,
c);
87 fail->push_back(
bx,
c);
Var(const std::string &name, const std::string &expr)
void produce(edm::Event &, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::EventSetup & c
std::vector< Var > variables_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
std::unique_ptr< TMVA::Reader > reader_
StringCutObjectSelector< l1t::HGCalMulticluster > preselection_
StringObjectFunction< l1t::HGCalMulticluster > expr_
list var
if using global norm cols_to_minmax = ['t_delta', 't_hmaxNearP','t_emaxNearP', 't_hAnnular', 't_eAnnular','t_pt','t_nVtx','t_ieta','t_eHcal10', 't_eHcal30','t_rhoh','t_eHcal'] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() > 0) else 1.0/200.0)
StringObjectFunction< l1t::HGCalMulticluster > wp_
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollection > src_
T getParameter(std::string const &) const
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
void declare(TMVA::Reader &r)
std::string fullPath() const
~HGC3DClusterTMVASelector() override
HGC3DClusterTMVASelector(const edm::ParameterSet &)
void fill(const l1t::HGCalMulticluster &c)