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

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

114  {
115  for ( auto& name : conf.getParameter< std::vector<std::string> >("ModelNames") )
116  {
117  names_.push_back(name);
118  }
119  for ( auto& weights : conf.getParameter< std::vector<std::string> >("ModelWeights") )
120  {
122  }
123  for ( auto& thresh : conf.getParameter< std::vector<double> >("ModelThresholds") )
124  {
125  thresholds_.push_back(thresh);
126  }
127  if ( names_.size() != models_.size() ) {
128  throw cms::Exception("Incorrect configuration")
129  << "'ModelNames' size (" << names_.size()
130  << ") != 'ModelWeights' size (" << models_.size()
131  << ").\n";
132  }
133  if ( models_.size() != thresholds_.size() ) {
134  throw cms::Exception("Incorrect configuration")
135  << "'ModelWeights' size (" << models_.size()
136  << ") != 'ModelThresholds' size (" << thresholds_.size()
137  << ").\n";
138  }
139 
140  }
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 144 of file LowPtGsfElectronSeedHeavyObjectCache.cc.

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

150  {
151  std::vector<std::string>::const_iterator iter = std::find( names_.begin(),
152  names_.end(),
153  name );
154  if ( iter != names_.end() ) {
155  int index = std::distance(names_.begin(),iter);
156  Features features;
157  features.set(ecal,hcal,rho,spot,ecalTools);
158  std::vector<float> inputs = features.get();
159  float output = models_.at(index)->GetResponse( inputs.data() );
160  bool pass = output > thresholds_.at(index);
161  ecal.setMVA(pass,output,index);
162  return pass;
163  } else {
164  throw cms::Exception("Unknown model name")
165  << "'Name given: '" << name
166  << "'. Check against configuration file.\n";
167  }
168  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void setMVA(bool accepted, float mva, unsigned n=0)
Definition: PreId.h:72
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 70 of file LowPtGsfElectronSeedHeavyObjectCache.h.

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

Definition at line 69 of file LowPtGsfElectronSeedHeavyObjectCache.h.

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

Definition at line 71 of file LowPtGsfElectronSeedHeavyObjectCache.h.