Skip to content

Commit e7954c1

Browse files
authored
Merge pull request cms-sw#36243 from valsdav/pfid_egamma_v2
PFID with DNNs - updated model trained on Run3Summer21
2 parents b517fae + 2325db7 commit e7954c1

File tree

10 files changed

+138
-68
lines changed

10 files changed

+138
-68
lines changed

RecoEgamma/EgammaElectronProducers/plugins/GsfElectronProducer.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,14 @@ void GsfElectronProducer::fillDescriptions(edm::ConfigurationDescriptions& descr
294294
psd1.add<uint>("outputDim", 5); // Number of output nodes of DNN
295295
psd1.add<std::vector<std::string>>(
296296
"modelsFiles",
297-
{"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/lowpT/lowpT_modelDNN.pb",
298-
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/highpTEB/highpTEB_modelDNN.pb",
299-
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/highpTEE/highpTEE_modelDNN.pb"});
297+
{"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/lowpT/lowpT_modelDNN.pb",
298+
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/highpTEB/highpTEB_modelDNN.pb",
299+
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/highpTEE/highpTEE_modelDNN.pb"});
300300
psd1.add<std::vector<std::string>>(
301301
"scalersFiles",
302-
{"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/lowpT/lowpT_scaler.txt",
303-
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/highpTEB/highpTEB_scaler.txt",
304-
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/highpTEE/highpTEE_scaler.txt"});
302+
{"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/lowpT/lowpT_scaler.txt",
303+
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/highpTEB/highpTEB_scaler.txt",
304+
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/v1/highpTEE/highpTEE_scaler.txt"});
305305
psd1.add<bool>("useEBModelInGap", true);
306306
// preselection parameters
307307
desc.add<edm::ParameterSetDescription>("EleDNNPFid", psd1);

RecoEgamma/EgammaElectronProducers/python/gedGsfElectrons_cfi.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@
2020
"gedelectron_EEUncertainty_offline_v1"],
2121
combinationRegressionWeightLabels = ["gedelectron_p4combination_offline"],
2222

23-
#Activate the evaluation of Egamma PFID DNN
23+
#Egamma PFID DNN model configuration
2424
EleDNNPFid= dict(
25+
outputTensorName = "sequential_1/FinalLayer/Softmax",
2526
modelsFiles = [
26-
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/lowpT/lowpT_modelDNN.pb",
27-
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/highpTEB/highpTEB_modelDNN.pb",
28-
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/highpTEE/highpTEE_modelDNN.pb"
27+
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/Run3Summer21_120X/lowpT/lowpT_modelDNN.pb",
28+
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/Run3Summer21_120X/EB_highpT/barrel_highpT_modelDNN.pb",
29+
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/Run3Summer21_120X/EE_highpT/endcap_highpT_modelDNN.pb"
2930
],
3031
scalersFiles = [
31-
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/lowpT/lowpT_scaler.txt",
32-
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/highpTEB/highpTEB_scaler.txt",
33-
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/highpTEE/highpTEE_scaler.txt"
32+
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/Run3Summer21_120X/lowpT/lowpT_scaler.txt",
33+
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/Run3Summer21_120X/EB_highpT/barrel_highpT_scaler.txt",
34+
"RecoEgamma/ElectronIdentification/data/Ele_PFID_dnn/Run3Summer21_120X/EE_highpT/endcap_highpT_scaler.txt"
3435
]
3536
)
3637
)

RecoEgamma/EgammaPhotonProducers/python/gedPhotonSequence_cff.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
candidateP4type = "fromEcalEnergy",
1515
outputPhotonCollection = "",
1616
reconstructionStep = "tmp",
17+
#Photon PFID DNN model configuration
1718
PhotonDNNPFid = dict(
18-
modelsFiles = [ "RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/EB/EB_modelDNN.pb",
19-
"RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/EE/EE_modelDNN.pb"],
19+
modelsFiles = [ "RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/Run3Summer21_120X/EB/barrel_modelDNN.pb",
20+
"RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/Run3Summer21_120X/EE/endcap_modelDNN.pb"],
2021
scalersFiles = [
21-
"RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/EB/EB_scaler.txt",
22-
"RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/EE/EE_scaler.txt"]
22+
"RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/Run3Summer21_120X/EB/barrel_scaler.txt",
23+
"RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/Run3Summer21_120X/EE/endcap_scaler.txt"]
2324
)
2425
)
2526
del gedPhotonsTmp.regressionConfig

RecoEgamma/EgammaPhotonProducers/python/gedPhotons_cfi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@
104104
inputTensorName = cms.string("FirstLayer_input"),
105105
outputTensorName = cms.string("sequential/FinalLayer/Sigmoid"),
106106
modelsFiles = cms.vstring(
107-
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/EB/EB_modelDNN.pb',
108-
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/EE/EE_modelDNN.pb'),
107+
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/v1/EB/EB_modelDNN.pb',
108+
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/v1/EE/EE_modelDNN.pb'),
109109
scalersFiles = cms.vstring(
110-
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/EB/EB_scaler.txt',
111-
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/EE/EE_scaler.txt'
110+
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/v1/EB/EB_scaler.txt',
111+
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/v1/EE/EE_scaler.txt'
112112
),
113113
outputDim = cms.uint32(1),
114114
useEBModelInGap = cms.bool(True)

RecoEgamma/EgammaPhotonProducers/python/photons_cfi.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@
9393
PhotonDNNPFid = cms.PSet(
9494
enabled = cms.bool(False),
9595
inputTensorName = cms.string("FirstLayer_input"),
96-
outputTensorName = cms.string("sequential/LastLayer/Softmax"),
96+
outputTensorName = cms.string("sequential/FinalLayer/Sigmoid"),
9797
modelsFiles = cms.vstring(
98-
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/model_barrel.pb',
99-
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/model_endcap.pb'),
98+
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/v1/EB/EB_modelDNN.pb',
99+
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/v1/EE/EE_modelDNN.pb'),
100100
scalersFiles = cms.vstring(
101-
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/PhotonDNNScaler.txt',
102-
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/PhotonDNNScaler.txt'
101+
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/v1/EB/EB_scaler.txt',
102+
'RecoEgamma/PhotonIdentification/data/Photon_PFID_dnn/v1/EE/EE_scaler.txt'
103103
),
104104
outputDim = cms.uint32(1),
105105
useEBModelInGap = cms.bool(True)

RecoEgamma/ElectronIdentification/src/ElectronDNNEstimator.cc

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "RecoEgamma/ElectronIdentification/interface/ElectronDNNEstimator.h"
22
#include "FWCore/MessageLogger/interface/MessageLogger.h"
33
#include "FWCore/Utilities/interface/FileInPath.h"
4+
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
45

56
#include <iostream>
67
#include <fstream>
@@ -37,37 +38,55 @@ ElectronDNNEstimator::ElectronDNNEstimator(const egammaTools::DNNConfiguration&
3738

3839
std::vector<tensorflow::Session*> ElectronDNNEstimator::getSessions() const { return dnnHelper_.getSessions(); };
3940

40-
const std::vector<std::string> ElectronDNNEstimator::dnnAvaibleInputs = {{"pt",
41-
"eta",
42-
"fbrem",
43-
"abs(deltaEtaSuperClusterTrackAtVtx)",
44-
"abs(deltaPhiSuperClusterTrackAtVtx)",
45-
"full5x5_sigmaIetaIeta",
46-
"full5x5_hcalOverEcal",
47-
"eSuperClusterOverP",
48-
"full5x5_e1x5",
49-
"eEleClusterOverPout",
50-
"closestCtfTrackNormChi2",
51-
"closestCtfTrackNLayers",
52-
"gsfTrack.missing_inner_hits",
53-
"dr03TkSumPt",
54-
"dr03EcalRecHitSumEt",
55-
"dr03HcalTowerSumEt",
56-
"gsfTrack.normalizedChi2",
57-
"superCluster.eta",
58-
"ecalPFClusterIso",
59-
"hcalPFClusterIso",
60-
"numberOfBrems",
61-
"abs(deltaEtaSeedClusterTrackAtCalo)",
62-
"hadronicOverEm",
63-
"full5x5_e2x5Max",
64-
"full5x5_e5x5"}};
41+
const std::vector<std::string> ElectronDNNEstimator::dnnAvaibleInputs = {
42+
{"pt",
43+
"eta",
44+
"fbrem",
45+
"abs(deltaEtaSuperClusterTrackAtVtx)",
46+
"abs(deltaPhiSuperClusterTrackAtVtx)",
47+
"full5x5_sigmaIetaIeta",
48+
"full5x5_hcalOverEcal",
49+
"eSuperClusterOverP",
50+
"full5x5_e1x5",
51+
"eEleClusterOverPout",
52+
"closestCtfTrackNormChi2",
53+
"closestCtfTrackNLayers",
54+
"gsfTrack.missing_inner_hits",
55+
"dr03TkSumPt",
56+
"dr03EcalRecHitSumEt",
57+
"dr03HcalTowerSumEt",
58+
"gsfTrack.normalizedChi2",
59+
"superCluster.eta",
60+
"ecalPFClusterIso",
61+
"hcalPFClusterIso",
62+
"numberOfBrems",
63+
"abs(deltaEtaSeedClusterTrackAtCalo)",
64+
"hadronicOverEm",
65+
"full5x5_e2x5Max",
66+
"full5x5_e5x5",
67+
"full5x5_sigmaIphiIphi",
68+
"1_minus_full5x5_e1x5_ratio_full5x5_e5x5",
69+
"full5x5_e1x5_ratio_full5x5_e5x5",
70+
"full5x5_r9",
71+
"gsfTrack.trackerLayersWithMeasurement",
72+
"superCluster.energy",
73+
"superCluster.rawEnergy",
74+
"superClusterFbrem",
75+
"1_ratio_ecalEnergy_minus_1_ratio_trackMomentumAtVtx.R",
76+
"superCluster.preshowerEnergy_ratio_superCluster.rawEnergy",
77+
"convVtxFitProb",
78+
"superCluster.clustersSize",
79+
"ecalEnergyError_ratio_ecalEnergy",
80+
"superClusterFbrem_plus_superCluster.energy",
81+
"superClusterFbrem_plus_superCluster.rawEnergy",
82+
"trackMomentumError",
83+
"trackMomentumError_ratio_pt",
84+
"full5x5_e5x5_ratio_superCluster.rawEnergy",
85+
"full5x5_e5x5_ratio_superCluster.energy"}};
6586

6687
std::map<std::string, float> ElectronDNNEstimator::getInputsVars(const reco::GsfElectron& ele) const {
6788
// Prepare a map with all the defined variables
6889
std::map<std::string, float> variables;
69-
reco::TrackRef myTrackRef = ele.closestCtfTrackRef();
70-
bool validKF = (myTrackRef.isNonnull() && myTrackRef.isAvailable());
7190
variables["pt"] = ele.pt();
7291
variables["eta"] = ele.eta();
7392
variables["fbrem"] = ele.fbrem();
@@ -81,11 +100,11 @@ std::map<std::string, float> ElectronDNNEstimator::getInputsVars(const reco::Gsf
81100
variables["closestCtfTrackNormChi2"] = ele.closestCtfTrackNormChi2();
82101
variables["closestCtfTrackNLayers"] = ele.closestCtfTrackNLayers();
83102
variables["gsfTrack.missing_inner_hits"] =
84-
(validKF) ? myTrackRef->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) : -1.;
103+
ele.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
85104
variables["dr03TkSumPt"] = ele.dr03TkSumPt();
86105
variables["dr03EcalRecHitSumEt"] = ele.dr03EcalRecHitSumEt();
87106
variables["dr03HcalTowerSumEt"] = ele.dr03HcalTowerSumEt();
88-
variables["gsfTrack.normalizedChi2"] = (validKF) ? myTrackRef->normalizedChi2() : 0;
107+
variables["gsfTrack.normalizedChi2"] = ele.gsfTrack()->normalizedChi2();
89108
variables["superCluster.eta"] = ele.superCluster()->eta();
90109
variables["ecalPFClusterIso"] = ele.ecalPFClusterIso();
91110
variables["hcalPFClusterIso"] = ele.hcalPFClusterIso();
@@ -94,6 +113,30 @@ std::map<std::string, float> ElectronDNNEstimator::getInputsVars(const reco::Gsf
94113
variables["hadronicOverEm"] = ele.hcalOverEcalValid() ? ele.hadronicOverEm() : 0;
95114
variables["full5x5_e2x5Max"] = ele.full5x5_e2x5Max();
96115
variables["full5x5_e5x5"] = ele.full5x5_e5x5();
116+
117+
variables["full5x5_sigmaIphiIphi"] = ele.full5x5_sigmaIphiIphi();
118+
variables["1_minus_full5x5_e1x5_ratio_full5x5_e5x5"] = 1 - ele.full5x5_e1x5() / ele.full5x5_e5x5();
119+
variables["full5x5_e1x5_ratio_full5x5_e5x5"] = ele.full5x5_e1x5() / ele.full5x5_e5x5();
120+
variables["full5x5_r9"] = ele.full5x5_r9();
121+
variables["gsfTrack.trackerLayersWithMeasurement"] = ele.gsfTrack()->hitPattern().trackerLayersWithMeasurement();
122+
variables["superCluster.energy"] = ele.superCluster()->energy();
123+
variables["superCluster.rawEnergy"] = ele.superCluster()->rawEnergy();
124+
variables["superClusterFbrem"] = ele.superClusterFbrem();
125+
variables["1_ratio_ecalEnergy_minus_1_ratio_trackMomentumAtVtx.R"] =
126+
1 / ele.ecalEnergy() - 1 / ele.trackMomentumAtVtx().R();
127+
variables["superCluster.preshowerEnergy_ratio_superCluster.rawEnergy"] =
128+
ele.superCluster()->preshowerEnergy() / ele.superCluster()->rawEnergy();
129+
variables["convVtxFitProb"] = ele.convVtxFitProb();
130+
variables["superCluster.clustersSize"] = ele.superCluster()->clustersSize();
131+
variables["ecalEnergyError_ratio_ecalEnergy"] = ele.ecalEnergyError() / ele.ecalEnergy();
132+
variables["superClusterFbrem_plus_superCluster.energy"] = ele.superClusterFbrem() + ele.superCluster()->energy();
133+
variables["superClusterFbrem_plus_superCluster.rawEnergy"] =
134+
ele.superClusterFbrem() + ele.superCluster()->rawEnergy();
135+
variables["trackMomentumError"] = ele.trackMomentumError();
136+
variables["trackMomentumError_ratio_pt"] = ele.trackMomentumError() / ele.pt();
137+
variables["full5x5_e5x5_ratio_superCluster.rawEnergy"] = ele.full5x5_e5x5() / ele.superCluster()->rawEnergy();
138+
variables["full5x5_e5x5_ratio_superCluster.energy"] = ele.full5x5_e5x5() / ele.superCluster()->energy();
139+
97140
// Define more variables here and use them directly in the model config!
98141
return variables;
99142
}

RecoEgamma/PhotonIdentification/src/PhotonDNNEstimator.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ std::vector<tensorflow::Session*> PhotonDNNEstimator::getSessions() const { retu
3434
const std::vector<std::string> PhotonDNNEstimator::dnnAvaibleInputs = {{"pt",
3535
"eta",
3636
"hadTowOverEm",
37-
"TrkSumPtHollow",
37+
"trkSumPtHollowConeDR03",
3838
"EcalRecHit",
3939
"SigmaIetaIeta",
40-
"SigmaIEtaIEtaFull5x5",
40+
"SigmaIetaIetaFull5x5",
4141
"SigmaIEtaIPhiFull5x5",
4242
"EcalPFClusterIso",
4343
"HcalPFClusterIso",
@@ -51,10 +51,10 @@ std::map<std::string, float> PhotonDNNEstimator::getInputsVars(const reco::Photo
5151
variables["pt"] = photon.pt();
5252
variables["eta"] = photon.eta();
5353
variables["hadTowOverEm"] = photon.hadTowOverEmValid() ? photon.hadTowOverEm() : 0;
54-
variables["TrkSumPtHollow"] = photon.trkSumPtHollowConeDR03();
54+
variables["trkSumPtHollowConeDR03"] = photon.trkSumPtHollowConeDR03();
5555
variables["EcalRecHit"] = photon.ecalRecHitSumEtConeDR03();
5656
variables["SigmaIetaIeta"] = photon.sigmaIetaIeta();
57-
variables["SigmaIEtaIEtaFull5x5"] = photon.full5x5_sigmaIetaIeta();
57+
variables["SigmaIetaIetaFull5x5"] = photon.full5x5_sigmaIetaIeta();
5858
variables["SigmaIEtaIPhiFull5x5"] = photon.full5x5_showerShapeVariables().sigmaIetaIphi;
5959
variables["EcalPFClusterIso"] = photon.ecalPFClusterIso();
6060
variables["HcalPFClusterIso"] = photon.hcalPFClusterIso();

RecoParticleFlow/PFProducer/interface/PFEGammaFilters.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ class PFEGammaFilters {
5757
float ele_dnnLowPtThr_;
5858
float ele_dnnHighPtBarrelThr_;
5959
float ele_dnnHighPtEndcapThr_;
60+
// Thresholds for DNN Bkg ele pfid
61+
float ele_dnnBkgLowPtThr_;
62+
float ele_dnnBkgHighPtBarrelThr_;
63+
float ele_dnnBkgHighPtEndcapThr_;
6064
// Threshold for DNN photon pfid
6165
float photon_dnnBarrelThr_;
6266
float photon_dnnEndcapThr_;

RecoParticleFlow/PFProducer/python/particleFlow_cff.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@
1515
particleFlowTmp.PFEGammaFiltersParameters.allowEEEinPF = cms.bool(False)
1616

1717
# Thresholds for e/gamma PFID DNN
18+
# Thresholds for electron: Sig_isolated+Sig_nonIsolated
1819
particleFlowTmp.PFEGammaFiltersParameters.electronDnnThresholds = cms.PSet(
19-
electronDnnHighPtBarrelThr = cms.double(0.122),
20-
electronDnnHighPtEndcapThr = cms.double(0.072),
21-
electronDnnLowPtThr = cms.double(0.081)
20+
electronDnnHighPtBarrelThr = cms.double(0.068),
21+
electronDnnHighPtEndcapThr = cms.double(0.056),
22+
electronDnnLowPtThr = cms.double(0.075)
2223
)
24+
# Thresholds for electron: Bkg_nonIsolated
25+
particleFlowTmp.PFEGammaFiltersParameters.electronDnnBkgThresholds = cms.PSet(
26+
electronDnnBkgHighPtBarrelThr = cms.double(0.8),
27+
electronDnnBkgHighPtEndcapThr = cms.double(0.75),
28+
electronDnnBkgLowPtThr = cms.double(0.75)
29+
)
30+
# Thresholds for photons
2331
particleFlowTmp.PFEGammaFiltersParameters.photonDnnThresholds = cms.PSet(
24-
photonDnnBarrelThr = cms.double(0.70),
25-
photonDnnEndcapThr = cms.double(0.79)
32+
photonDnnBarrelThr = cms.double(0.22),
33+
photonDnnEndcapThr = cms.double(0.35)
2634
)
2735

2836
from Configuration.Eras.Modifier_pf_badHcalMitigationOff_cff import pf_badHcalMitigationOff

0 commit comments

Comments
 (0)