CMS 3D CMS Logo

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

#include <LowPtGsfElectronIDHeavyObjectCache.h>

Public Member Functions

double eval (const std::string &name, const reco::GsfElectronRef &, double rho) 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 51 of file LowPtGsfElectronIDHeavyObjectCache.h.

Constructor & Destructor Documentation

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

Definition at line 108 of file LowPtGsfElectronIDHeavyObjectCache.cc.

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

108  {
109  for ( auto& name : conf.getParameter< std::vector<std::string> >("ModelNames") )
110  {
111  names_.push_back(name);
112  }
113  for ( auto& weights : conf.getParameter< std::vector<std::string> >("ModelWeights") )
114  {
116  }
117  for ( auto& thresh : conf.getParameter< std::vector<double> >("ModelThresholds") )
118  {
119  thresholds_.push_back(thresh);
120  }
121  if ( names_.size() != models_.size() ) {
122  throw cms::Exception("Incorrect configuration")
123  << "'ModelNames' size (" << names_.size()
124  << ") != 'ModelWeights' size (" << models_.size()
125  << ").\n";
126  }
127  if ( models_.size() != thresholds_.size() ) {
128  throw cms::Exception("Incorrect configuration")
129  << "'ModelWeights' size (" << models_.size()
130  << ") != 'ModelThresholds' size (" << thresholds_.size()
131  << ").\n";
132  }
133 
134  }
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

double lowptgsfeleid::HeavyObjectCache::eval ( const std::string &  name,
const reco::GsfElectronRef ele,
double  rho 
) const

Definition at line 138 of file LowPtGsfElectronIDHeavyObjectCache.cc.

References SoftLeptonByDistance_cfi::distance, Exception, postprocess-scan-build::features, spr::find(), PatBasicFWLiteJetAnalyzer_Selector_cfg::inputs, and dataset::name.

141  {
142  std::vector<std::string>::const_iterator iter = std::find( names_.begin(),
143  names_.end(),
144  name );
145  if ( iter != names_.end() ) {
146  int index = std::distance(names_.begin(),iter);
147  Features features;
148  features.set(ele,rho);
149  std::vector<float> inputs = features.get();
150  return models_.at(index)->GetResponse( inputs.data() );
151  } else {
152  throw cms::Exception("Unknown model name")
153  << "'Name given: '" << name
154  << "'. Check against configuration file.\n";
155  }
156  return 0.;
157  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< std::unique_ptr< const GBRForest > > models_
std::vector<std::string> lowptgsfeleid::HeavyObjectCache::modelNames ( ) const
inline

Member Data Documentation

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

Definition at line 64 of file LowPtGsfElectronIDHeavyObjectCache.h.

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

Definition at line 63 of file LowPtGsfElectronIDHeavyObjectCache.h.

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

Definition at line 65 of file LowPtGsfElectronIDHeavyObjectCache.h.