CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 115 of file LowPtGsfElectronSeedHeavyObjectCache.cc.

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

115  {
116  for ( auto& name : conf.getParameter< std::vector<std::string> >("ModelNames") )
117  {
118  names_.push_back(name);
119  }
120  for ( auto& weights : conf.getParameter< std::vector<std::string> >("ModelWeights") )
121  {
123  }
124  for ( auto& thresh : conf.getParameter< std::vector<double> >("ModelThresholds") )
125  {
126  thresholds_.push_back(thresh);
127  }
128  if ( names_.size() != models_.size() ) {
129  throw cms::Exception("Incorrect configuration")
130  << "'ModelNames' size (" << names_.size()
131  << ") != 'ModelWeights' size (" << models_.size()
132  << ").\n";
133  }
134  if ( models_.size() != thresholds_.size() ) {
135  throw cms::Exception("Incorrect configuration")
136  << "'ModelWeights' size (" << models_.size()
137  << ") != 'ModelThresholds' size (" << thresholds_.size()
138  << ").\n";
139  }
140 
141  }
T getParameter(std::string const &) const
static std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightFile)
std::vector< std::unique_ptr< const GBRForest > > models_

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

References SoftLeptonByDistance_cfi::distance, Exception, spr::find(), PatBasicFWLiteJetAnalyzer_Selector_cfg::inputs, dataset::name, convertSQLitetoXML_cfg::output, lowptgsfeleseed::Features::set(), and reco::PreId::setMVA().

151  {
152  std::vector<std::string>::const_iterator iter = std::find( names_.begin(),
153  names_.end(),
154  name );
155  if ( iter != names_.end() ) {
156  int index = std::distance(names_.begin(),iter);
157  Features features;
158  features.set(ecal,hcal,rho,spot,ecalTools);
159  std::vector<float> inputs = features.get();
160  float output = models_.at(index)->GetResponse( inputs.data() );
161  bool pass = output > thresholds_.at(index);
162  ecal.setMVA(pass,output,index);
163  return pass;
164  } else {
165  throw cms::Exception("Unknown model name")
166  << "'Name given: '" << name
167  << "'. Check against configuration file.\n";
168  }
169  }
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.