CMS 3D CMS Logo

LowPtGsfElectronSeedHeavyObjectCache.cc
Go to the documentation of this file.
9 
11 
12 #include <string>
13 
14 namespace lowptgsfeleseed {
15 
17  //
18  std::vector<float> Features::get() {
19  std::vector<float> output = {trk_pt_,
20  trk_eta_,
21  trk_phi_,
22  trk_p_,
23  trk_nhits_,
26  rho_,
43  trk_dxy_sig_};
44  return output;
45  }
46 
48  //
50  const reco::PreId& hcal,
51  double rho,
52  const reco::BeamSpot& spot,
54  // Tracks
55  reco::TrackRef trk = ecal.trackRef();
56  if (trk.isNonnull()) {
57  trk_pt_ = trk->pt();
58  trk_eta_ = trk->eta();
59  trk_phi_ = trk->phi();
60  trk_p_ = trk->p();
61  trk_nhits_ = static_cast<float>(trk->found());
62  trk_high_quality_ = static_cast<float>(trk->quality(reco::TrackBase::qualityByName("highPurity")));
63  trk_chi2red_ = trk->normalizedChi2();
64  if (trk->dxy(spot) > 0.) {
65  trk_dxy_sig_ = trk->dxyError() / trk->dxy(spot); //@@ to be consistent with the training based on 94X MC
66  }
67  ktf_ecal_cluster_dphi_ *= trk->charge(); //@@ to be consistent with the training based on 94X MC
68  }
69 
70  // Rho
71  rho_ = static_cast<float>(rho);
72 
73  // ECAL clusters
74  reco::PFClusterRef ecal_clu = ecal.clusterRef();
75  if (ecal_clu.isNonnull()) {
76  ktf_ecal_cluster_e_ = ecal_clu->energy();
77  ktf_ecal_cluster_deta_ = ecal.geomMatching()[0];
78  ktf_ecal_cluster_dphi_ = ecal.geomMatching()[1];
79  ktf_ecal_cluster_e3x3_ = tools.e3x3(*ecal_clu);
80  ktf_ecal_cluster_e5x5_ = tools.e5x5(*ecal_clu);
81  auto covs = tools.localCovariances(*ecal_clu);
85  if (ktf_ecal_cluster_e_ > 0.) {
87  }
88  if (ktf_ecal_cluster_e5x5_ > 0.) {
90  } else {
92  }
93  }
94 
95  // HCAL clusters
96  reco::PFClusterRef hcal_clu = hcal.clusterRef();
97  if (hcal_clu.isNonnull()) {
98  ktf_hcal_cluster_e_ = hcal_clu->energy();
99  ktf_hcal_cluster_deta_ = hcal.geomMatching()[0];
100  ktf_hcal_cluster_dphi_ = hcal.geomMatching()[1];
101  }
102 
103  // PreId
104  preid_gsf_dpt_ = ecal.dpt();
105  preid_trk_gsf_chiratio_ = ecal.chi2Ratio();
106  preid_gsf_chi2red_ = ecal.gsfChi2();
107  };
108 
110  //
112  for (auto& name : conf.getParameter<std::vector<std::string> >("ModelNames")) {
113  names_.push_back(name);
114  }
115  for (auto& weights : conf.getParameter<std::vector<std::string> >("ModelWeights")) {
117  }
118  for (auto& thresh : conf.getParameter<std::vector<double> >("ModelThresholds")) {
119  thresholds_.push_back(thresh);
120  }
121  if (names_.size() != models_.size()) {
122  throw cms::Exception("Incorrect configuration")
123  << "'ModelNames' size (" << names_.size() << ") != 'ModelWeights' size (" << models_.size() << ").\n";
124  }
125  if (models_.size() != thresholds_.size()) {
126  throw cms::Exception("Incorrect configuration")
127  << "'ModelWeights' size (" << models_.size() << ") != 'ModelThresholds' size (" << thresholds_.size()
128  << ").\n";
129  }
130  }
131 
133  //
135  reco::PreId& ecal,
136  reco::PreId& hcal,
137  double rho,
138  const reco::BeamSpot& spot,
139  noZS::EcalClusterLazyTools& ecalTools) const {
140  std::vector<std::string>::const_iterator iter = std::find(names_.begin(), names_.end(), name);
141  if (iter != names_.end()) {
142  int index = std::distance(names_.begin(), iter);
144  features.set(ecal, hcal, rho, spot, ecalTools);
145  std::vector<float> inputs = features.get();
146  float output = models_.at(index)->GetResponse(inputs.data());
147  bool pass = output > thresholds_.at(index);
148  ecal.setMVA(pass, output, index);
149  return pass;
150  } else {
151  throw cms::Exception("Unknown model name")
152  << "'Name given: '" << name << "'. Check against configuration file.\n";
153  }
154  }
155 
156 } // namespace lowptgsfeleseed
lowptgsfeleseed::Features::trk_dxy_sig_
float trk_dxy_sig_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:42
lowptgsfeleseed::Features::ktf_hcal_cluster_dphi_
float ktf_hcal_cluster_dphi_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:38
lowptgsfeleseed::Features::rho_
float rho_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:25
HLT_2018_cff.weights
weights
Definition: HLT_2018_cff.py:87167
LowPtGsfElectronSeedHeavyObjectCache.h
lowptgsfeleseed::Features
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:16
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
postprocess-scan-build.features
features
Definition: postprocess-scan-build.py:8
hcal
Definition: ConfigurationDatabase.cc:13
GBRForestTools.h
lowptgsfeleseed::Features::ktf_ecal_cluster_deta_
float ktf_ecal_cluster_deta_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:27
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
createGBRForest
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
Definition: GBRForestTools.cc:244
lowptgsfeleseed::Features::ktf_ecal_cluster_covEtaPhi_
float ktf_ecal_cluster_covEtaPhi_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:32
lowptgsfeleseed::Features::preid_gsf_dpt_
float preid_gsf_dpt_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:39
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
reco::PreId
Definition: PreId.h:13
lowptgsfeleseed::Features::trk_p_
float trk_p_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:21
edm::Ref< TrackCollection >
FileInPath.h
PreId.h
lowptgsfeleseed::Features::ktf_ecal_cluster_r9_
float ktf_ecal_cluster_r9_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:34
lowptgsfeleseed::Features::ktf_hcal_cluster_deta_
float ktf_hcal_cluster_deta_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:37
lowptgsfeleseed::Features::preid_gsf_chi2red_
float preid_gsf_chi2red_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:41
lowptgsfeleseed::Features::trk_high_quality_
float trk_high_quality_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:23
edm::FileInPath
Definition: FileInPath.h:64
lowptgsfeleseed::Features::set
void set(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
Definition: LowPtGsfElectronSeedHeavyObjectCache.cc:49
Track.h
TrackFwd.h
BeamSpot.h
lowptgsfeleseed::HeavyObjectCache::names_
std::vector< std::string > names_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:66
reco::BeamSpot
Definition: BeamSpot.h:21
PFCluster.h
lowptgsfeleseed::Features::ktf_ecal_cluster_e5x5_
float ktf_ecal_cluster_e5x5_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:30
lowptgsfeleseed::HeavyObjectCache::eval
bool eval(const std::string &name, reco::PreId &ecal, reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools) const
Definition: LowPtGsfElectronSeedHeavyObjectCache.cc:134
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
lowptgsfeleseed::Features::ktf_ecal_cluster_covEtaEta_
float ktf_ecal_cluster_covEtaEta_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:31
EcalClusterLazyToolsT
Definition: EcalClusterLazyTools.h:105
edm::ParameterSet
Definition: ParameterSet.h:36
lowptgsfeleseed::Features::trk_nhits_
float trk_nhits_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:22
lowptgsfeleseed::Features::ktf_hcal_cluster_e_
float ktf_hcal_cluster_e_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:36
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
lowptgsfeleseed::Features::ktf_ecal_cluster_circularity_
float ktf_ecal_cluster_circularity_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:35
PFClusterFwd.h
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
tools
Definition: tools.py:1
lowptgsfeleseed::HeavyObjectCache::models_
std::vector< std::unique_ptr< const GBRForest > > models_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:67
lowptgsfeleseed::Features::trk_pt_
float trk_pt_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:18
lowptgsfeleseed::HeavyObjectCache::HeavyObjectCache
HeavyObjectCache(const edm::ParameterSet &)
Definition: LowPtGsfElectronSeedHeavyObjectCache.cc:111
GOODCOLL_filter_cfg.thresh
thresh
Definition: GOODCOLL_filter_cfg.py:74
reco::TrackBase::qualityByName
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
lowptgsfeleseed::Features::ktf_ecal_cluster_e_
float ktf_ecal_cluster_e_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:26
lowptgsfeleseed::Features::ktf_ecal_cluster_covPhiPhi_
float ktf_ecal_cluster_covPhiPhi_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:33
Exception
Definition: hltDiff.cc:246
lowptgsfeleseed::Features::preid_trk_gsf_chiratio_
float preid_trk_gsf_chiratio_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:40
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
bsc_activity_cfg.ecal
ecal
Definition: bsc_activity_cfg.py:25
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
lowptgsfeleseed::Features::ktf_ecal_cluster_e3x3_
float ktf_ecal_cluster_e3x3_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:29
lowptgsfeleseed::Features::trk_phi_
float trk_phi_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:20
lowptgsfeleseed::Features::trk_eta_
float trk_eta_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:19
lowptgsfeleseed
Definition: LowPtGsfElectronSeedHeavyObjectCache.cc:14
lowptgsfeleseed::Features::trk_chi2red_
float trk_chi2red_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:24
lowptgsfeleseed::HeavyObjectCache::thresholds_
std::vector< double > thresholds_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:68
lowptgsfeleseed::Features::get
std::vector< float > get()
Definition: LowPtGsfElectronSeedHeavyObjectCache.cc:18
lowptgsfeleseed::Features::ktf_ecal_cluster_dphi_
float ktf_ecal_cluster_dphi_
Definition: LowPtGsfElectronSeedHeavyObjectCache.h:28