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 16 of file LowPtGsfElectronSeedHeavyObjectCache.h.

Constructor & Destructor Documentation

◆ HeavyObjectCache()

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

Definition at line 18 of file LowPtGsfElectronSeedHeavyObjectCache.cc.

References createGBRForest(), Exception, edm::ParameterSet::getParameter(), models_, Skims_PA_cff::name, names_, DMR_cfg::thresh, thresholds_, and hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights.

18  {
19  for (auto& name : conf.getParameter<std::vector<std::string> >("ModelNames")) {
20  names_.push_back(name);
21  }
22  for (auto& weights : conf.getParameter<std::vector<std::string> >("ModelWeights")) {
24  }
25  for (auto& thresh : conf.getParameter<std::vector<double> >("ModelThresholds")) {
26  thresholds_.push_back(thresh);
27  }
28  if (names_.size() != models_.size()) {
29  throw cms::Exception("Incorrect configuration")
30  << "'ModelNames' size (" << names_.size() << ") != 'ModelWeights' size (" << models_.size() << ").\n";
31  }
32  if (models_.size() != thresholds_.size()) {
33  throw cms::Exception("Incorrect configuration")
34  << "'ModelWeights' size (" << models_.size() << ") != 'ModelThresholds' size (" << thresholds_.size()
35  << ").\n";
36  }
37  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< std::unique_ptr< const GBRForest > > models_
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)

Member Function Documentation

◆ eval()

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 41 of file LowPtGsfElectronSeedHeavyObjectCache.cc.

References HLT_2022v15_cff::distance, Exception, lowptgsfeleseed::features(), spr::find(), PixelMapPlotter::inputs, models_, Skims_PA_cff::name, names_, convertSQLitetoXML_cfg::output, and thresholds_.

46  {
47  std::vector<std::string>::const_iterator iter = std::find(names_.begin(), names_.end(), name);
48  if (iter != names_.end()) {
49  int index = std::distance(names_.begin(), iter);
50  std::vector<float> inputs = features(ecal, hcal, rho, spot, ecalTools);
51  float output = models_.at(index)->GetResponse(inputs.data());
52  bool pass = output > thresholds_.at(index);
53  ecal.setMVA(pass, output, index);
54  return pass;
55  } else {
56  throw cms::Exception("Unknown model name")
57  << "'Name given: '" << name << "'. Check against configuration file.\n";
58  }
59  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< float > features(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
std::vector< std::unique_ptr< const GBRForest > > models_

◆ modelNames()

std::vector<std::string> lowptgsfeleseed::HeavyObjectCache::modelNames ( ) const
inline

Definition at line 20 of file LowPtGsfElectronSeedHeavyObjectCache.h.

References names_.

20 { return names_; }

Member Data Documentation

◆ models_

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

Definition at line 31 of file LowPtGsfElectronSeedHeavyObjectCache.h.

Referenced by eval(), and HeavyObjectCache().

◆ names_

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

Definition at line 30 of file LowPtGsfElectronSeedHeavyObjectCache.h.

Referenced by eval(), HeavyObjectCache(), and modelNames().

◆ thresholds_

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

Definition at line 32 of file LowPtGsfElectronSeedHeavyObjectCache.h.

Referenced by eval(), and HeavyObjectCache().