CMS 3D CMS Logo

LowPtGsfElectronIDHeavyObjectCache.cc
Go to the documentation of this file.
11 #include <string>
12 
13 namespace lowptgsfeleid {
14 
16  //
17  std::vector<float> Features::get() {
18  std::vector<float> output = {
19  rho_,
20  ele_pt_,
21  sc_eta_,
29  trk_nhits_,
32  brem_frac_,
33  gsf_nhits_,
39  sc_E_,
40  trk_p_,
41  };
42  return output;
43  }
44 
46  //
47  void Features::set( const reco::GsfElectron& ele, double rho ) {
48 
49  // KF tracks
50  if ( ele.core().isNonnull() ) {
51  reco::TrackRef trk = ele.core()->ctfTrack(); //@@ is this what we want?!
52  if ( trk.isNonnull() ) {
53  trk_p_ = float(trk->p());
54  trk_nhits_ = float(trk->found());
55  trk_chi2red_ = float(trk->normalizedChi2());
56  }
57  }
58 
59  // GSF tracks
60  if ( ele.core().isNonnull() ) {
61  reco::GsfTrackRef gsf = ele.core()->gsfTrack();
62  if ( gsf.isNonnull() ) {
63  gsf_nhits_ = gsf->found();
64  gsf_chi2red_ = gsf->normalizedChi2();
65  }
66  }
67 
68  // Super clusters
69  if ( ele.core().isNonnull() ) {
70  reco::SuperClusterRef sc = ele.core()->superCluster();
71  if ( sc.isNonnull() ) {
72  sc_E_ = sc->energy();
73  sc_eta_ = sc->eta();
74  sc_etaWidth_ = sc->etaWidth();
75  sc_phiWidth_ = sc->phiWidth();
76  }
77  }
78 
79  // Track-cluster matching
81  match_eclu_EoverP_ = (1./ele.ecalEnergy()) - (1./ele.p());
85 
86  // Shower shape vars
92 
93  // Misc
94  rho_ = rho;
95  brem_frac_ = ele.fbrem();
96  ele_pt_ = ele.pt();
97 
98  };
99 
101  //
103  for ( auto& name : conf.getParameter< std::vector<std::string> >("ModelNames") )
104  {
105  names_.push_back(name);
106  }
107  for ( auto& weights : conf.getParameter< std::vector<std::string> >("ModelWeights") )
108  {
109  models_.push_back(createGBRForest(edm::FileInPath(weights)));
110  }
111  for ( auto& thresh : conf.getParameter< std::vector<double> >("ModelThresholds") )
112  {
113  thresholds_.push_back(thresh);
114  }
115  if ( names_.size() != models_.size() ) {
116  throw cms::Exception("Incorrect configuration")
117  << "'ModelNames' size (" << names_.size()
118  << ") != 'ModelWeights' size (" << models_.size()
119  << ").\n";
120  }
121  if ( models_.size() != thresholds_.size() ) {
122  throw cms::Exception("Incorrect configuration")
123  << "'ModelWeights' size (" << models_.size()
124  << ") != 'ModelThresholds' size (" << thresholds_.size()
125  << ").\n";
126  }
127 
128  }
129 
131  //
133  const reco::GsfElectronRef& ele,
134  double rho ) const
135  {
136  std::vector<std::string>::const_iterator iter = std::find( names_.begin(),
137  names_.end(),
138  name );
139  if ( iter != names_.end() ) {
140  int index = std::distance(names_.begin(),iter);
142  features.set(ele,rho);
143  std::vector<float> inputs = features.get();
144  return models_.at(index)->GetResponse( inputs.data() );
145  } else {
146  throw cms::Exception("Unknown model name")
147  << "'Name given: '" << name
148  << "'. Check against configuration file.\n";
149  }
150  return 0.;
151  }
152 
153 } // namespace lowptgsfeleid
T getParameter(std::string const &) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
float eSuperClusterOverP() const
Definition: GsfElectron.h:249
float full5x5_e5x5() const
Definition: GsfElectron.h:466
float full5x5_e1x5() const
Definition: GsfElectron.h:464
float full5x5_sigmaIphiIphi() const
Definition: GsfElectron.h:463
double pt() const final
transverse momentum
float fbrem() const
Definition: GsfElectron.h:772
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
float full5x5_sigmaIetaIeta() const
Definition: GsfElectron.h:462
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:253
double eval(const std::string &name, const reco::GsfElectronRef &, double rho) const
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:256
double p() const final
magnitude of momentum vector
float full5x5_hcalOverEcal() const
Definition: GsfElectron.h:470
float ecalEnergy() const
Definition: GsfElectron.h:860
virtual GsfElectronCoreRef core() const
Definition: GsfElectron.cc:8
float full5x5_r9() const
Definition: GsfElectron.h:467
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:254
void set(const reco::GsfElectronRef &ele, double rho)
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)