Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hgg photons variables in nanoAODs #36526

Merged
merged 8 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions PhysicsTools/NanoAOD/python/nanoDQM_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@
NoPlot('electronIdx'),
Plot1D('electronVeto', 'electronVeto', 2, -0.5, 1.5, 'pass electron veto'),
Plot1D('energyErr', 'energyErr', 20, 0, 300, 'energy error of the cluster from regression'),
Plot1D('energyRaw', 'energyRaw', 100, 0, 300, 'raw energy of photon supercluster'),
Plot1D('eta', 'eta', 20, -3, 3, 'eta'),
Plot1D('genPartFlav', 'genPartFlav', 14, -0.5, 13.5, 'Flavour of genParticle for MC matching to status==1 photons or electrons: 1 = prompt photon, 13 = prompt electron, 0 = unknown or unmatched'),
NoPlot('genPartIdx'),
Expand All @@ -608,9 +609,11 @@
NoPlot('jetIdx'),
NoPlot('mass'),
Plot1D('mvaID', 'mvaID', 20, -1, 1, 'MVA ID score'),
Plot1D('mvaID_Fall17V1p1', 'mvaID_Fall17V1p1', 20, -1, 1, 'MVA ID score, Fall17V1p1'),
Plot1D('mvaID_WP80', 'mvaID_WP80', 2, -0.5, 1.5, 'MVA ID WP80'),
Plot1D('mvaID_WP90', 'mvaID_WP90', 2, -0.5, 1.5, 'MVA ID WP90'),
Plot1D('pfPhoIso03', 'pfPhoIso03', 100, 0, 1, 'PF absolute isolation dR=0.3, photon component (uncorrected)'),
Plot1D('pfChargedIsoPFPV', 'pfChargedIsoPFPV', 100, 0, 5, 'PF absolute isolation dR=0.3, charged component (PF PV only)'),
Plot1D('pfChargedIsoWorstVtx', 'pfChargedIsoWorstVtx', 100, 0, 10,'PF absolute isolation dR=0.3, charged component (Vertex with largest isolation)'),
Plot1D('pdgId', 'pdgId', 1, 21.5, 22.5, 'PDG code assigned by the event reconstruction (not by MC truth)'),
Plot1D('pfRelIso03_all', 'pfRelIso03_all', 20, 0, 2, 'PF relative isolation dR=0.3, total (with rho*EA PU corrections)'),
Plot1D('pfRelIso03_chg', 'pfRelIso03_chg', 20, 0, 2, 'PF relative isolation dR=0.3, charged component (with rho*EA PU corrections)'),
Expand All @@ -619,11 +622,21 @@
Plot1D('pt', 'pt', 20, 0, 200, 'pt (corrected)'),
Plot1D('r9', 'r9', 20, 0, 1.1, 'R9 of the supercluster, calculated with full 5x5 region'),
Plot1D('seedGain', 'seedGain', 12, 0.5, 12.5, 'Gain of the seed crystal'),
Plot1D('sieie', 'sieie', 20, 0, 0.05, 'sigma_IetaIeta of the supercluster, calculated with full 5x5 region'),
Plot1D('sieie', 'sieie', 100, 0, 0.05, 'sigma_IetaIeta of the supercluster, calculated with full 5x5 region'),
Plot1D('sipip', 'sipip', 100, 0, 0.05, 'sigmaIphiIphi of the supercluster'),
Plot1D('sieip', 'sieip', 100, -0.0002, 0.0002, 'sigma_IetaIphi of the supercluster, calculated with full 5x5 region'),
Plot1D('s4', 's4', 100, 0.4, 1, 'e2x2/e5x5 of the supercluster, calculated with full 5x5 region'),
Plot1D('etaWidth', 'etaWidth', 100, 0, 0.03, 'Width of the photon supercluster in eta'),
Plot1D('phiWidth', 'phiWidth', 100, 0, 0.1, 'Width of the photon supercluster in phi'),
Plot1D('dEscaleUp', 'dEscaleUp', 100, -0.01, 0.01, '#Delta E scaleUp'),
Plot1D('dEscaleDown', 'dEscaleDown', 100, -0.01, 0.01, '#Delta E scaleDown'),
Plot1D('dEsigmaUp', 'dEsigmaUp', 100, -0.1, 0.1, '#Delta E sigmaUp'),
Plot1D('dEsigmaDown', 'dEsigmaDown', 100, -0.1, 0.1, '#Delta E sigmaDown'),
Plot1D('x_calo', 'x_calo', 100, -150, 150, 'photon supercluster position on calorimeter, x coordinate (cm)'),
Plot1D('y_calo', 'y_calo', 100, -150, 150, 'photon supercluster position on calorimeter, y coordinate (cm)'),
Plot1D('z_calo', 'z_calo', 100, -330, 330, 'photon supercluster position on calorimeter, y coordinate (cm)'),
Plot1D('esEffSigmaRR', 'esEffSigmaRR', 100, 0, 10, 'preshower sigmaRR'),
Plot1D('esEnergyOverRawE', 'esEnergyOverRawE', 100, 0, 0.2, 'ratio of preshower energy to raw supercluster energy'),
NoPlot('vidNestedWPBitmap'),
)
),
Expand Down
29 changes: 21 additions & 8 deletions PhysicsTools/NanoAOD/python/photons_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def make_bitmapVID_docstring(id_modules_working_points_pset):
src = cms.InputTag("slimmedPhotons"),
userFloats = cms.PSet(
mvaID = cms.InputTag("photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v2Values"),
mvaID_Fall17V1p1 = cms.InputTag("photonMVAValueMapProducer:PhotonMVAEstimatorRunIIFall17v1p1Values"),
PFIsoChg = cms.InputTag("isoForPho:PFIsoChg"),
PFIsoAll = cms.InputTag("isoForPho:PFIsoAll"),
),
Expand Down Expand Up @@ -174,12 +173,18 @@ def make_bitmapVID_docstring(id_modules_working_points_pset):
doc = cms.string("slimmedPhotons after basic selection (" + finalPhotons.cut.value()+")"),
singleton = cms.bool(False), # the number of entries is variable
extension = cms.bool(False), # this is the main table for the photons
variables = cms.PSet(CandVars,
variables = cms.PSet(P3Vars,
jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to save little more space: CandVars can be moved to P3vars

  • int charge (is undefined for photons)
  • float mass (is trivially zero)
  • pdgId from RECO code should be always 22 and not sure is of any use

electronIdx = Var("?hasUserCand('electron')?userCand('electron').key():-1", int, doc="index of the associated electron (-1 if none)"),
energyErr = Var("getCorrectedEnergyError('regression2')",float,doc="energy error of the cluster from regression",precision=6),
r9 = Var("full5x5_r9()",float,doc="R9 of the supercluster, calculated with full 5x5 region",precision=10),
sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
energyRaw = Var("superCluster().rawEnergy()",float,doc="raw energy of photon supercluster", precision=10),
r9 = Var("full5x5_r9()",float,doc="R9 of the supercluster, calculated with full 5x5 region",precision=8),
sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=8),
sipip = Var("showerShapeVariables().sigmaIphiIphi", float, doc="sigmaIphiIphi of the supercluster", precision=8),
sieip = Var("full5x5_showerShapeVariables().sigmaIetaIphi",float,doc="sigma_IetaIphi of the supercluster, calculated with full 5x5 region",precision=8),
s4 = Var("full5x5_showerShapeVariables().e2x2/full5x5_showerShapeVariables().e5x5",float,doc="e2x2/e5x5 of the supercluster, calculated with full 5x5 region",precision=8),
etaWidth = Var("superCluster().etaWidth()",float,doc="Width of the photon supercluster in eta", precision=8),
phiWidth = Var("superCluster().phiWidth()",float,doc="Width of the photon supercluster in phi", precision=8),
cutBased = Var(
"userInt('cutbasedID_loose')+userInt('cutbasedID_medium')+userInt('cutbasedID_tight')",
int,
Expand All @@ -198,15 +203,24 @@ def make_bitmapVID_docstring(id_modules_working_points_pset):
electronVeto = Var("passElectronVeto()",bool,doc="pass electron veto"),
pixelSeed = Var("hasPixelSeed()",bool,doc="has pixel seed"),
Comment on lines 203 to 204
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we improve the self documentation ? i.e. the doc string

electronVeto : to add "analysis not sensitive to electron -> photon fake rate"
pixelSeed: to add "analysis sensitive to electron -> photon fake rate"

see information in the wiki https://twiki.cern.ch/twiki/bin/viewauth/CMS/CutBasedPhotonIdentificationRun2

mvaID = Var("userFloat('mvaID')",float,doc="MVA ID score, Fall17V2",precision=10),
mvaID_Fall17V1p1 = Var("userFloat('mvaID_Fall17V1p1')",float,doc="MVA ID score, Fall17V1p1",precision=10),
mvaID_WP90 = Var("userInt('mvaID_WP90')",bool,doc="MVA ID WP90, Fall17V2"),
mvaID_WP80 = Var("userInt('mvaID_WP80')",bool,doc="MVA ID WP80, Fall17V2"),
pfPhoIso03 = Var("photonIso()",float,doc="PF absolute isolation dR=0.3, photon component (uncorrected)"),
pfChargedIsoPFPV = Var("chargedHadronPFPVIso()",float,doc="PF absolute isolation dR=0.3, charged component (PF PV only)"),
pfChargedIsoWorstVtx = Var("chargedHadronWorstVtxIso()",float,doc="PF absolute isolation dR=0.3, charged component (Vertex with largest isolation)"),
pfRelIso03_chg = Var("userFloat('PFIsoChg')/pt",float,doc="PF relative isolation dR=0.3, charged component (with rho*EA PU corrections)"),
pfRelIso03_all = Var("userFloat('PFIsoAll')/pt",float,doc="PF relative isolation dR=0.3, total (with rho*EA PU corrections)"),
hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8),
based on the discussion at the xPOG this is neither the run2 definition (i.e. what goes in the ID is another one) nor the one planned for Run3.

We should update with the right one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In run 2 the H/E variable used in IDs is indeed hadTowOverEm() (tower based H/E), while for Run 3 we are planning to move to the cone based H/E, ie hadronicOverEm() (the one you are talking about), so probably we should keep it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can have both Run2 and Run3 right

(run2_egamma_2016 || run2_egamma_2017 || run2_egamma_2018) .toModify(photonTable,
    hoe = Var("hadTowOverEm()",float,doc="H over E (Run2)",precision=8),
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this duality hadTowOverEm() vs hadronicOverEm() exist also for the electrons ?
https://github.com/cms-sw/cmssw/blob/master/PhysicsTools/NanoAOD/python/electrons_cff.py#L388

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, for electrons we do not need hadTowOverEm(): the ID cuts on hadronicOverEm(), which is the one included

isScEtaEB = Var("abs(superCluster().eta()) < 1.4442",bool,doc="is supercluster eta within barrel acceptance"),
isScEtaEE = Var("abs(superCluster().eta()) > 1.566 && abs(superCluster().eta()) < 2.5",bool,doc="is supercluster eta within endcap acceptance"),
seedGain = Var("userInt('seedGain')","uint8",doc="Gain of the seed crystal"),
# position of photon is best approximated by position of seed cluster, not the SC centroid
x_calo = Var("superCluster().seed().position().x()",float,doc="photon supercluster position on calorimeter, x coordinate (cm)",precision=10),
y_calo = Var("superCluster().seed().position().y()",float,doc="photon supercluster position on calorimeter, y coordinate (cm)",precision=10),
z_calo = Var("superCluster().seed().position().z()",float,doc="photon supercluster position on calorimeter, z coordinate (cm)",precision=10),
# ES variables
esEffSigmaRR = Var("full5x5_showerShapeVariables().effSigmaRR()", float, doc="preshower sigmaRR"),
esEnergyOverRawE = Var("superCluster().preshowerEnergy()/superCluster().rawEnergy()", float, doc="ratio of preshower energy to raw supercluster energy"),
)
)

Expand All @@ -217,6 +231,7 @@ def make_bitmapVID_docstring(id_modules_working_points_pset):
pt = Var("pt*userFloat('ecalEnergyPostCorrNew')/userFloat('ecalEnergyPreCorrNew')", float, precision=-1, doc="p_{T}"),
energyErr = Var("userFloat('ecalEnergyErrPostCorrNew')",float,doc="energy error of the cluster from regression",precision=6),
eCorr = Var("userFloat('ecalEnergyPostCorrNew')/userFloat('ecalEnergyPreCorrNew')",float,doc="ratio of the calibrated energy/miniaod energy"),
hoe = Var("hadTowOverEm()",float,doc="H over E (Run2)",precision=8),
)

#these eras have the energy correction in the mini
Expand Down Expand Up @@ -331,14 +346,12 @@ def make_bitmapVID_docstring(id_modules_working_points_pset):
(run3_nanoAOD_devel).toModify(slimmedPhotonsWithUserData.userInts,
VIDNestedWPBitmap = None,)
(run3_nanoAOD_devel).toModify(slimmedPhotonsWithUserData.userFloats,
mvaID = None,
mvaID_Fall17V1p1 = None)
mvaID = None)
(run3_nanoAOD_devel).toModify(photonTable.variables,
cutBased = None,
cutBased_Fall17V1Bitmap = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the cutBased_Fall17V1 can be removed, no ?
Fall17V2 should be the recommended for the Run2 legacy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I missed it while rebasing, pushing now

vidNestedWPBitmap = None,
mvaID = None,
mvaID_Fall17V1p1 = None,
mvaID_WP90 = None,
mvaID_WP80 = None,
)
Expand Down