CMS 3D CMS Logo

LowPtGsfElectronSeedHeavyObjectCache.cc
Go to the documentation of this file.
11 
12 #include <string>
13 
14 namespace lowptgsfeleseed {
15 
17  //
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  }
38 
40  //
44  double rho,
45  const reco::BeamSpot& spot,
46  noZS::EcalClusterLazyTools& ecalTools) const {
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  }
60 
61 } // namespace lowptgsfeleseed
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool eval(const std::string &name, reco::PreId &ecal, reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools) const
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_
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)