CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
lowptgsfeleseed::HeavyObjectCache Class Reference

#include <LowPtGsfElectronSeedHeavyObjectCache.h>

Public Member Functions

bool eval (const std::string &name, reco::PreId &ecal, reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools) const
 
 HeavyObjectCache (const edm::ParameterSet &)
 
std::vector< std::string > modelNames () const
 

Private Attributes

std::vector< std::unique_ptr< const GBRForest > > models_
 
std::vector< std::string > names_
 
std::vector< double > thresholds_
 

Detailed Description

Definition at line 52 of file LowPtGsfElectronSeedHeavyObjectCache.h.

Constructor & Destructor Documentation

lowptgsfeleseed::HeavyObjectCache::HeavyObjectCache ( const edm::ParameterSet conf)

Definition at line 111 of file LowPtGsfElectronSeedHeavyObjectCache.cc.

References createGBRForest(), Exception, edm::ParameterSet::getParameter(), Skims_PA_cff::name, GOODCOLL_filter_cfg::thresh, and HGCalRecHit_cfi::weights.

111  {
112  for (auto& name : conf.getParameter<std::vector<std::string> >("ModelNames")) {
113  names_.push_back(name);
114  }
115  for (auto& weights : conf.getParameter<std::vector<std::string> >("ModelWeights")) {
117  }
118  for (auto& thresh : conf.getParameter<std::vector<double> >("ModelThresholds")) {
119  thresholds_.push_back(thresh);
120  }
121  if (names_.size() != models_.size()) {
122  throw cms::Exception("Incorrect configuration")
123  << "'ModelNames' size (" << names_.size() << ") != 'ModelWeights' size (" << models_.size() << ").\n";
124  }
125  if (models_.size() != thresholds_.size()) {
126  throw cms::Exception("Incorrect configuration")
127  << "'ModelWeights' size (" << models_.size() << ") != 'ModelThresholds' size (" << thresholds_.size()
128  << ").\n";
129  }
130  }
T getParameter(std::string const &) const
std::vector< std::unique_ptr< const GBRForest > > models_
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)

Member Function Documentation

bool lowptgsfeleseed::HeavyObjectCache::eval ( const std::string &  name,
reco::PreId ecal,
reco::PreId hcal,
double  rho,
const reco::BeamSpot spot,
noZS::EcalClusterLazyTools ecalTools 
) const

Definition at line 134 of file LowPtGsfElectronSeedHeavyObjectCache.cc.

References HLT_2018_cff::distance, Exception, postprocess-scan-build::features, spr::find(), PixelMapPlotter::inputs, Skims_PA_cff::name, convertSQLitetoXML_cfg::output, and reco::PreId::setMVA().

139  {
140  std::vector<std::string>::const_iterator iter = std::find(names_.begin(), names_.end(), name);
141  if (iter != names_.end()) {
142  int index = std::distance(names_.begin(), iter);
143  Features features;
144  features.set(ecal, hcal, rho, spot, ecalTools);
145  std::vector<float> inputs = features.get();
146  float output = models_.at(index)->GetResponse(inputs.data());
147  bool pass = output > thresholds_.at(index);
148  ecal.setMVA(pass, output, index);
149  return pass;
150  } else {
151  throw cms::Exception("Unknown model name")
152  << "'Name given: '" << name << "'. Check against configuration file.\n";
153  }
154  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void setMVA(bool accepted, float mva, unsigned n=0)
Definition: PreId.h:63
std::vector< std::unique_ptr< const GBRForest > > models_
std::vector<std::string> lowptgsfeleseed::HeavyObjectCache::modelNames ( ) const
inline

Member Data Documentation

std::vector<std::unique_ptr<const GBRForest> > lowptgsfeleseed::HeavyObjectCache::models_
private

Definition at line 67 of file LowPtGsfElectronSeedHeavyObjectCache.h.

std::vector<std::string> lowptgsfeleseed::HeavyObjectCache::names_
private

Definition at line 66 of file LowPtGsfElectronSeedHeavyObjectCache.h.

std::vector<double> lowptgsfeleseed::HeavyObjectCache::thresholds_
private

Definition at line 68 of file LowPtGsfElectronSeedHeavyObjectCache.h.