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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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.

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 }

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

◆ ~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.

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 }

References BXVector< T >::begin(), l1GtPatternGenerator_cfi::bx, HltBtagPostValidation_cff::c, BXVector< T >::end(), BXVector< T >::getFirstBX(), BXVector< T >::getLastBX(), iEvent, eostools::move(), MillePedeFileConverter_cfg::out, and trigObjTnPSource_cfi::var.

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.

l1t::HGC3DClusterTMVASelector::variables_
std::vector< Var > variables_
Definition: HGC3DClusterTMVASelector.cc:36
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
l1t::HGC3DClusterTMVASelector::src_
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollection > src_
Definition: HGC3DClusterTMVASelector.cc:34
edm::Handle
Definition: AssociativeIterator.h:50
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
BXVector::getFirstBX
int getFirstBX() const
edm::FileInPath
Definition: FileInPath.h:64
l1t::HGC3DClusterTMVASelector::reader_
std::unique_ptr< TMVA::Reader > reader_
Definition: HGC3DClusterTMVASelector.cc:38
l1t::HGC3DClusterTMVASelector::preselection_
StringCutObjectSelector< l1t::HGCalMulticluster > preselection_
Definition: HGC3DClusterTMVASelector.cc:35
BXVector::begin
const_iterator begin(int bx) const
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BXVector::end
const_iterator end(int bx) const
iEvent
int iEvent
Definition: GenABIO.cc:224
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
l1t::HGC3DClusterTMVASelector::wp_
StringObjectFunction< l1t::HGCalMulticluster > wp_
Definition: HGC3DClusterTMVASelector.cc:39
l1t::HGC3DClusterTMVASelector::weightsFile_
std::string weightsFile_
Definition: HGC3DClusterTMVASelector.cc:37
eostools.move
def move(src, dest)
Definition: eostools.py:511
l1t::HGC3DClusterTMVASelector::method_
std::string method_
Definition: HGC3DClusterTMVASelector.cc:37
reco::details::loadTMVAWeights
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
Definition: TMVAZipReader.cc:52
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
BXVector::getLastBX
int getLastBX() const
edm::InputTag
Definition: InputTag.h:15
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163