CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Attributes
ElectronDNNEstimator Class Reference

#include <ElectronDNNEstimator.h>

Public Member Functions

 ElectronDNNEstimator (const egammaTools::DNNConfiguration &, const bool useEBModelInGap)
 
std::vector< std::pair< uint, std::vector< float > > > evaluate (const reco::GsfElectronCollection &ele, const std::vector< tensorflow::Session *> &sessions) const
 
std::map< std::string, float > getInputsVars (const reco::GsfElectron &ele) const
 
std::vector< tensorflow::Session * > getSessions () const
 

Static Public Attributes

static const std::vector< std::string > dnnAvaibleInputs
 
static constexpr float ecalBarrelMaxEtaNoGap = 1.485
 
static constexpr float ecalBarrelMaxEtaWithGap = 1.566
 
static constexpr float endcapBoundary = 2.5
 
static constexpr float extEtaBoundary = 2.65
 
static constexpr float ptThreshold = 10.
 

Private Attributes

const egammaTools::EgammaDNNHelper dnnHelper_
 
const bool useEBModelInGap_
 

Detailed Description

Definition at line 12 of file ElectronDNNEstimator.h.

Constructor & Destructor Documentation

◆ ElectronDNNEstimator()

ElectronDNNEstimator::ElectronDNNEstimator ( const egammaTools::DNNConfiguration cfg,
const bool  useEBModelInGap 
)

Definition at line 38 of file ElectronDNNEstimator.cc.

39  : dnnHelper_(cfg,
40  std::bind(electronModelSelector,
41  _1,
static const std::vector< std::string > dnnAvaibleInputs
static constexpr float ptThreshold
static constexpr float ecalBarrelMaxEtaWithGap
static constexpr float extEtaBoundary
const egammaTools::EgammaDNNHelper dnnHelper_
static constexpr float endcapBoundary
uint electronModelSelector(const std::map< std::string, float > &vars, float ptThr, float etaThr, float endcapBoundary, float extEtaBoundary)
static constexpr float ecalBarrelMaxEtaNoGap

Member Function Documentation

◆ evaluate()

std::vector< std::pair< uint, std::vector< float > > > ElectronDNNEstimator::evaluate ( const reco::GsfElectronCollection ele,
const std::vector< tensorflow::Session *> &  sessions 
) const

Definition at line 159 of file ElectronDNNEstimator.cc.

References dnnHelper_, pwdgSkimBPark_cfi::electrons, egammaTools::EgammaDNNHelper::evaluate(), getInputsVars(), and PixelMapPlotter::inputs.

160  {
161  // Collect the map of variables for each candidate and call the dnnHelper
162  // Scaling, model selection and running is performed in the helper
163  std::vector<std::map<std::string, float>> inputs;
164  for (const auto& ele : electrons) {
165  inputs.push_back(getInputsVars(ele));
166  }
167  return dnnHelper_.evaluate(inputs, sessions);
168 }
std::map< std::string, float > getInputsVars(const reco::GsfElectron &ele) const
std::vector< std::pair< uint, std::vector< float > > > evaluate(const std::vector< std::map< std::string, float >> &candidates, const std::vector< tensorflow::Session *> &sessions) const
const egammaTools::EgammaDNNHelper dnnHelper_

◆ getInputsVars()

std::map< std::string, float > ElectronDNNEstimator::getInputsVars ( const reco::GsfElectron ele) const

Definition at line 100 of file ElectronDNNEstimator.cc.

References funct::abs(), reco::GsfElectron::closestCtfTrackNLayers(), reco::GsfElectron::closestCtfTrackNormChi2(), reco::GsfElectron::convVtxFitProb(), reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), reco::GsfElectron::dr03EcalRecHitSumEt(), reco::GsfElectron::dr03HcalTowerSumEt(), reco::GsfElectron::dr03TkSumPt(), reco::GsfElectron::ecalEnergy(), reco::GsfElectron::ecalEnergyError(), reco::GsfElectron::ecalPFClusterIso(), reco::GsfElectron::eEleClusterOverPout(), reco::GsfElectron::eSuperClusterOverP(), reco::LeafCandidate::eta(), reco::GsfElectron::fbrem(), reco::GsfElectron::full5x5_e1x5(), reco::GsfElectron::full5x5_e2x5Max(), reco::GsfElectron::full5x5_e5x5(), reco::GsfElectron::full5x5_hcalOverEcal(), reco::GsfElectron::full5x5_hcalOverEcalValid(), reco::GsfElectron::full5x5_r9(), reco::GsfElectron::full5x5_sigmaIetaIeta(), reco::GsfElectron::full5x5_sigmaIphiIphi(), reco::GsfElectron::gsfTrack(), reco::GsfElectron::hadronicOverEm(), reco::GsfElectron::hcalOverEcalValid(), reco::GsfElectron::hcalPFClusterIso(), reco::HitPattern::MISSING_INNER_HITS, reco::GsfElectron::numberOfBrems(), reco::LeafCandidate::pt(), reco::GsfElectron::superCluster(), reco::GsfElectron::superClusterFbrem(), reco::GsfElectron::trackMomentumAtVtx(), reco::GsfElectron::trackMomentumError(), and hcalRecHitTable_cff::variables.

Referenced by evaluate().

100  {
101  // Prepare a map with all the defined variables
102  std::map<std::string, float> variables;
103  variables["pt"] = ele.pt();
104  variables["eta"] = ele.eta();
105  variables["fbrem"] = ele.fbrem();
106  variables["abs(deltaEtaSuperClusterTrackAtVtx)"] = std::abs(ele.deltaEtaSuperClusterTrackAtVtx());
107  variables["abs(deltaPhiSuperClusterTrackAtVtx)"] = std::abs(ele.deltaPhiSuperClusterTrackAtVtx());
108  variables["full5x5_sigmaIetaIeta"] = ele.full5x5_sigmaIetaIeta();
109  variables["full5x5_hcalOverEcal"] = ele.full5x5_hcalOverEcalValid() ? ele.full5x5_hcalOverEcal() : 0;
110  variables["eSuperClusterOverP"] = ele.eSuperClusterOverP();
111  variables["full5x5_e1x5"] = ele.full5x5_e1x5();
112  variables["eEleClusterOverPout"] = ele.eEleClusterOverPout();
113  variables["closestCtfTrackNormChi2"] = ele.closestCtfTrackNormChi2();
114  variables["closestCtfTrackNLayers"] = ele.closestCtfTrackNLayers();
115  variables["gsfTrack.missing_inner_hits"] =
116  ele.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
117  variables["dr03TkSumPt"] = ele.dr03TkSumPt();
118  variables["dr03EcalRecHitSumEt"] = ele.dr03EcalRecHitSumEt();
119  variables["dr03HcalTowerSumEt"] = ele.dr03HcalTowerSumEt();
120  variables["gsfTrack.normalizedChi2"] = ele.gsfTrack()->normalizedChi2();
121  variables["superCluster.eta"] = ele.superCluster()->eta();
122  variables["ecalPFClusterIso"] = ele.ecalPFClusterIso();
123  variables["hcalPFClusterIso"] = ele.hcalPFClusterIso();
124  variables["numberOfBrems"] = ele.numberOfBrems();
125  variables["abs(deltaEtaSeedClusterTrackAtCalo)"] = std::abs(ele.deltaEtaSeedClusterTrackAtCalo());
126  variables["hadronicOverEm"] = ele.hcalOverEcalValid() ? ele.hadronicOverEm() : 0;
127  variables["full5x5_e2x5Max"] = ele.full5x5_e2x5Max();
128  variables["full5x5_e5x5"] = ele.full5x5_e5x5();
129 
130  variables["full5x5_sigmaIphiIphi"] = ele.full5x5_sigmaIphiIphi();
131  variables["1_minus_full5x5_e1x5_ratio_full5x5_e5x5"] = 1 - ele.full5x5_e1x5() / ele.full5x5_e5x5();
132  variables["full5x5_e1x5_ratio_full5x5_e5x5"] = ele.full5x5_e1x5() / ele.full5x5_e5x5();
133  variables["full5x5_r9"] = ele.full5x5_r9();
134  variables["gsfTrack.trackerLayersWithMeasurement"] = ele.gsfTrack()->hitPattern().trackerLayersWithMeasurement();
135  variables["gsfTrack.numberOfValidPixelBarrelHits"] = ele.gsfTrack()->hitPattern().numberOfValidPixelBarrelHits();
136  variables["gsfTrack.numberOfValidPixelEndcapHits"] = ele.gsfTrack()->hitPattern().numberOfValidPixelEndcapHits();
137  variables["superCluster.energy"] = ele.superCluster()->energy();
138  variables["superCluster.rawEnergy"] = ele.superCluster()->rawEnergy();
139  variables["superClusterFbrem"] = ele.superClusterFbrem();
140  variables["1_ratio_ecalEnergy_minus_1_ratio_trackMomentumAtVtx.R"] =
141  1 / ele.ecalEnergy() - 1 / ele.trackMomentumAtVtx().R();
142  variables["superCluster.preshowerEnergy_ratio_superCluster.rawEnergy"] =
143  ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
144  variables["convVtxFitProb"] = ele.convVtxFitProb();
145  variables["superCluster.clustersSize"] = ele.superCluster()->clustersSize();
146  variables["ecalEnergyError_ratio_ecalEnergy"] = ele.ecalEnergyError() / ele.ecalEnergy();
147  variables["superClusterFbrem_plus_superCluster.energy"] = ele.superClusterFbrem() + ele.superCluster()->energy();
148  variables["superClusterFbrem_plus_superCluster.rawEnergy"] =
149  ele.superClusterFbrem() + ele.superCluster()->rawEnergy();
150  variables["trackMomentumError"] = ele.trackMomentumError();
151  variables["trackMomentumError_ratio_pt"] = ele.trackMomentumError() / ele.pt();
152  variables["full5x5_e5x5_ratio_superCluster.rawEnergy"] = ele.full5x5_e5x5() / ele.superCluster()->rawEnergy();
153  variables["full5x5_e5x5_ratio_superCluster.energy"] = ele.full5x5_e5x5() / ele.superCluster()->energy();
154 
155  // Define more variables here and use them directly in the model config!
156  return variables;
157 }
bool full5x5_hcalOverEcalValid() const
Definition: GsfElectron.h:479
float full5x5_e2x5Max() const
Definition: GsfElectron.h:474
double pt() const final
transverse momentum
float full5x5_e1x5() const
Definition: GsfElectron.h:473
float trackMomentumError() const
Definition: GsfElectron.h:884
float full5x5_sigmaIphiIphi() const
Definition: GsfElectron.h:472
float eSuperClusterOverP() const
Definition: GsfElectron.h:221
float full5x5_e5x5() const
Definition: GsfElectron.h:475
float eEleClusterOverPout() const
Definition: GsfElectron.h:224
float dr03TkSumPt() const
Definition: GsfElectron.h:557
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
float ecalPFClusterIso() const
Definition: GsfElectron.h:731
float closestCtfTrackNormChi2() const
Definition: GsfElectron.h:165
int numberOfBrems() const
Definition: GsfElectron.h:808
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:268
float convVtxFitProb() const
Definition: GsfElectron.h:648
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:228
float superClusterFbrem() const
Definition: GsfElectron.h:803
int closestCtfTrackNLayers() const
Definition: GsfElectron.h:168
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:225
float ecalEnergy() const
Definition: GsfElectron.h:896
float ecalEnergyError() const
Definition: GsfElectron.h:897
float hcalPFClusterIso() const
Definition: GsfElectron.h:732
float fbrem() const
Definition: GsfElectron.h:809
float full5x5_hcalOverEcal(int depth=0) const
Definition: GsfElectron.h:477
float dr03EcalRecHitSumEt() const
Definition: GsfElectron.h:559
float full5x5_r9() const
Definition: GsfElectron.h:476
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:226
float full5x5_sigmaIetaIeta() const
Definition: GsfElectron.h:471
float dr03HcalTowerSumEt(int depth=0) const
Definition: GsfElectron.h:576
float hadronicOverEm() const
Definition: GsfElectron.h:500
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
bool hcalOverEcalValid() const
Definition: GsfElectron.h:462
double eta() const final
momentum pseudorapidity

◆ getSessions()

std::vector< tensorflow::Session * > ElectronDNNEstimator::getSessions ( ) const

Definition at line 50 of file ElectronDNNEstimator.cc.

References dnnHelper_, and egammaTools::EgammaDNNHelper::getSessions().

50 { return dnnHelper_.getSessions(); };
std::vector< tensorflow::Session * > getSessions() const
const egammaTools::EgammaDNNHelper dnnHelper_

Member Data Documentation

◆ dnnAvaibleInputs

const std::vector< std::string > ElectronDNNEstimator::dnnAvaibleInputs
static

Definition at line 29 of file ElectronDNNEstimator.h.

◆ dnnHelper_

const egammaTools::EgammaDNNHelper ElectronDNNEstimator::dnnHelper_
private

Definition at line 38 of file ElectronDNNEstimator.h.

Referenced by evaluate(), and getSessions().

◆ ecalBarrelMaxEtaNoGap

constexpr float ElectronDNNEstimator::ecalBarrelMaxEtaNoGap = 1.485
static

Definition at line 33 of file ElectronDNNEstimator.h.

◆ ecalBarrelMaxEtaWithGap

constexpr float ElectronDNNEstimator::ecalBarrelMaxEtaWithGap = 1.566
static

Definition at line 32 of file ElectronDNNEstimator.h.

◆ endcapBoundary

constexpr float ElectronDNNEstimator::endcapBoundary = 2.5
static

Definition at line 34 of file ElectronDNNEstimator.h.

◆ extEtaBoundary

constexpr float ElectronDNNEstimator::extEtaBoundary = 2.65
static

Definition at line 35 of file ElectronDNNEstimator.h.

◆ ptThreshold

constexpr float ElectronDNNEstimator::ptThreshold = 10.
static

Definition at line 31 of file ElectronDNNEstimator.h.

◆ useEBModelInGap_

const bool ElectronDNNEstimator::useEBModelInGap_
private

Definition at line 40 of file ElectronDNNEstimator.h.