CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::HGCalMulticluster
preselection_
 
std::unique_ptr< TMVA::Reader > reader_
 
edm::EDGetTokenT
< l1t::HGCalMulticlusterBxCollection
src_
 
std::vector< Varvariables_
 
std::string weightsFile_
 
StringObjectFunction
< l1t::HGCalMulticluster
wp_
 

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

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, isotrackApplyRegressor::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 }
std::unique_ptr< TMVA::Reader > reader_
StringCutObjectSelector< l1t::HGCalMulticluster > preselection_
list var
if using global norm cols_to_minmax = [&#39;t_delta&#39;, &#39;t_hmaxNearP&#39;,&#39;t_emaxNearP&#39;, &#39;t_hAnnular&#39;, &#39;t_eAnnular&#39;,&#39;t_pt&#39;,&#39;t_nVtx&#39;,&#39;t_ieta&#39;,&#39;t_eHcal10&#39;, &#39;t_eHcal30&#39;,&#39;t_rhoh&#39;,&#39;t_eHcal&#39;] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() &gt; 0) else 1.0/200.0)
StringObjectFunction< l1t::HGCalMulticluster > wp_
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollection > src_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
std::string fullPath() const
Definition: FileInPath.cc:161
l1t::HGC3DClusterTMVASelector::~HGC3DClusterTMVASelector ( )
inlineoverride

Definition at line 19 of file HGC3DClusterTMVASelector.cc.

19 {}

Member Function Documentation

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

Definition at line 70 of file HGC3DClusterTMVASelector.cc.

References makePileupJSON::bx, c, edm::Event::getByToken(), eostools::move(), submitPVResolutionJobs::out, edm::Event::put(), and isotrackApplyRegressor::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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EventSetup & c
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::unique_ptr< TMVA::Reader > reader_
StringCutObjectSelector< l1t::HGCalMulticluster > preselection_
list var
if using global norm cols_to_minmax = [&#39;t_delta&#39;, &#39;t_hmaxNearP&#39;,&#39;t_emaxNearP&#39;, &#39;t_hAnnular&#39;, &#39;t_eAnnular&#39;,&#39;t_pt&#39;,&#39;t_nVtx&#39;,&#39;t_ieta&#39;,&#39;t_eHcal10&#39;, &#39;t_eHcal30&#39;,&#39;t_rhoh&#39;,&#39;t_eHcal&#39;] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() &gt; 0) else 1.0/200.0)
def move
Definition: eostools.py:511
StringObjectFunction< l1t::HGCalMulticluster > wp_
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollection > src_

Member Data Documentation

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

Definition at line 37 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector().

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

Definition at line 35 of file HGC3DClusterTMVASelector.cc.

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

Definition at line 38 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector().

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

Definition at line 34 of file HGC3DClusterTMVASelector.cc.

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

Definition at line 36 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector().

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

Definition at line 37 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector().

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

Definition at line 39 of file HGC3DClusterTMVASelector.cc.