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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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

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, JetChargeProducer_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
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)
std::string fullPath() const
Definition: FileInPath.cc:163
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 EnergyCorrector::c, DEFINE_FWK_MODULE, cmsPerfPublish::fail(), edm::Event::getByToken(), method_, eostools::move(), MillePedeFileConverter_cfg::out, preselection_, edm::Event::put(), reader_, src_, JetChargeProducer_cfi::var, variables_, and wp_.

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:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::unique_ptr< TMVA::Reader > reader_
StringCutObjectSelector< l1t::HGCalMulticluster > preselection_
StringObjectFunction< l1t::HGCalMulticluster > wp_
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollection > src_
def fail(errstr="")
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 37 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector(), and produce().

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

Definition at line 35 of file HGC3DClusterTMVASelector.cc.

Referenced by produce().

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

Definition at line 38 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector(), and produce().

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

Definition at line 34 of file HGC3DClusterTMVASelector.cc.

Referenced by produce().

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

Definition at line 36 of file HGC3DClusterTMVASelector.cc.

Referenced by HGC3DClusterTMVASelector(), and produce().

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.

Referenced by produce().