CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
l1t::HGC3DClusterTMVASelector Class Reference
Inheritance diagram for l1t::HGC3DClusterTMVASelector:
edm::stream::EDProducer<>

Classes

class  Var
 

Public Member Functions

 HGC3DClusterTMVASelector (const edm::ParameterSet &)
 
 ~HGC3DClusterTMVASelector () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::string method_
 
StringCutObjectSelector< l1t::HGCalMulticlusterpreselection_
 
std::unique_ptr< TMVA::Reader > reader_
 
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollectionsrc_
 
std::vector< Varvariables_
 
std::string weightsFile_
 
StringObjectFunction< l1t::HGCalMulticlusterwp_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 16 of file HGC3DClusterTMVASelector.cc.

Constructor & Destructor Documentation

◆ HGC3DClusterTMVASelector()

l1t::HGC3DClusterTMVASelector::HGC3DClusterTMVASelector ( const edm::ParameterSet iConfig)
explicit

Definition at line 46 of file HGC3DClusterTMVASelector.cc.

References edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), reco::details::loadTMVAWeights(), method_, reader_, AlCaHLTBitMon_QueryRunRegistry::string, trigObjTnPSource_cfi::var, variables_, and weightsFile_.

47  : src_(consumes<l1t::HGCalMulticlusterBxCollection>(iConfig.getParameter<edm::InputTag>("src"))),
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")) {
53  // first create all the variables
54  for (const auto &psvar : iConfig.getParameter<std::vector<edm::ParameterSet>>("variables")) {
55  variables_.emplace_back(psvar.getParameter<std::string>("name"), psvar.getParameter<std::string>("value"));
56  }
57  // then declare them
58  for (auto &var : variables_)
59  var.declare(*reader_);
60  // then read the weights
61  if (weightsFile_[0] != '/' && weightsFile_[0] != '.') {
63  }
65  // finally, declare outputs
66  produces<l1t::HGCalMulticlusterBxCollection>();
67  produces<l1t::HGCalMulticlusterBxCollection>("fail");
68 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string fullPath() const
Definition: FileInPath.cc:161
std::unique_ptr< TMVA::Reader > reader_
StringCutObjectSelector< l1t::HGCalMulticluster > preselection_
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)

◆ ~HGC3DClusterTMVASelector()

l1t::HGC3DClusterTMVASelector::~HGC3DClusterTMVASelector ( )
inlineoverride

Definition at line 19 of file HGC3DClusterTMVASelector.cc.

19 {}

Member Function Documentation

◆ produce()

void l1t::HGC3DClusterTMVASelector::produce ( edm::Event iEvent,
const edm::EventSetup  
)
overrideprivate

Definition at line 70 of file HGC3DClusterTMVASelector.cc.

References nano_mu_digi_cff::bx, HltBtagPostValidation_cff::c, iEvent, eostools::move(), MillePedeFileConverter_cfg::out, and trigObjTnPSource_cfi::var.

70  {
71  std::unique_ptr<l1t::HGCalMulticlusterBxCollection> out = std::make_unique<l1t::HGCalMulticlusterBxCollection>();
72  std::unique_ptr<l1t::HGCalMulticlusterBxCollection> fail = std::make_unique<l1t::HGCalMulticlusterBxCollection>();
73 
75  iEvent.getByToken(src_, multiclusters);
76 
77  for (int bx = multiclusters->getFirstBX(); bx <= multiclusters->getLastBX(); ++bx) {
78  for (auto it = multiclusters->begin(bx), ed = multiclusters->end(bx); it != ed; ++it) {
79  const auto &c = *it;
80  if (preselection_(c)) {
81  for (auto &var : variables_)
82  var.fill(c);
83  float mvaOut = reader_->EvaluateMVA(method_);
84  if (mvaOut > wp_(c)) {
85  out->push_back(bx, c);
86  } else {
87  fail->push_back(bx, c);
88  }
89  }
90  }
91  }
92 
93  iEvent.put(std::move(out));
94  iEvent.put(std::move(fail), "fail");
95 }
std::unique_ptr< TMVA::Reader > reader_
StringCutObjectSelector< l1t::HGCalMulticluster > preselection_
int iEvent
Definition: GenABIO.cc:224
StringObjectFunction< l1t::HGCalMulticluster > wp_
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollection > src_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ method_

std::string l1t::HGC3DClusterTMVASelector::method_
private

Definition at line 37 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector().

◆ preselection_

StringCutObjectSelector<l1t::HGCalMulticluster> l1t::HGC3DClusterTMVASelector::preselection_
private

Definition at line 35 of file HGC3DClusterTMVASelector.cc.

◆ reader_

std::unique_ptr<TMVA::Reader> l1t::HGC3DClusterTMVASelector::reader_
private

Definition at line 38 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector().

◆ src_

edm::EDGetTokenT<l1t::HGCalMulticlusterBxCollection> l1t::HGC3DClusterTMVASelector::src_
private

Definition at line 34 of file HGC3DClusterTMVASelector.cc.

◆ variables_

std::vector<Var> l1t::HGC3DClusterTMVASelector::variables_
private

Definition at line 36 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector().

◆ weightsFile_

std::string l1t::HGC3DClusterTMVASelector::weightsFile_
private

Definition at line 37 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector().

◆ wp_

StringObjectFunction<l1t::HGCalMulticluster> l1t::HGC3DClusterTMVASelector::wp_
private

Definition at line 39 of file HGC3DClusterTMVASelector.cc.