Skip to content

Commit

Permalink
Additional photon variables (cms-sw#1)
Browse files Browse the repository at this point in the history
- Added fixedGridRhoAll  & supercluster eta for photons and electrons
- add the rho variable "fixedGridRhoAll": rho from all PF Candidates, no foreground removal (for isolation of prompt photons)
  • Loading branch information
ram1123 committed Oct 20, 2023
1 parent 172a27f commit 3661e0b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
27 changes: 14 additions & 13 deletions PhysicsTools/NanoAOD/python/electrons_cff.py
Expand Up @@ -65,7 +65,7 @@
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Summer16_80X_V1_cff',
'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronHLTPreselecition_Summer16_V1_cff',
'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Spring15_25ns_V1_cff',
Expand All @@ -79,7 +79,7 @@
"egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight",
)
)


def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
docstring=''
Expand Down Expand Up @@ -133,7 +133,7 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
EAFile_MiniIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
EAFile_PFIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
)
run2_miniAOD_80XLegacy.toModify(isoForEle,
run2_miniAOD_80XLegacy.toModify(isoForEle,
EAFile_MiniIso = "RecoEgamma/ElectronIdentification/data/Spring15/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_25ns.txt",
EAFile_PFIso = "RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt")
run2_nanoAOD_94X2016.toModify(isoForEle,
Expand All @@ -158,7 +158,7 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
#the second part is introduced to protect v8 since (run2_nanoAOD_106Xv1 & ~run2_nanoAOD_devel) is the v8 condition
(run2_egamma_2016 & tracker_apv_vfp30_2016 & ~(run2_nanoAOD_106Xv1 & ~run2_nanoAOD_devel)).toModify(calibratedPatElectronsNano,
correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_preVFP_RunFineEtaR9Gain")
)
)

(run2_egamma_2016 & ~tracker_apv_vfp30_2016 & ~(run2_nanoAOD_106Xv1 & ~run2_nanoAOD_devel)).toModify(calibratedPatElectronsNano,
correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_postVFP_RunFineEtaR9Gain")
Expand All @@ -177,7 +177,7 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
)

for modifier in run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2:
modifier.toModify(calibratedPatElectronsNano,
modifier.toModify(calibratedPatElectronsNano,
correctionFile = cms.string("EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_17Nov2017_v1_ele_unc")
)

Expand Down Expand Up @@ -254,8 +254,8 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
energyScaleDownNew = None,
energySigmaUpNew = None,
energySigmaDownNew = None


)

run2_nanoAOD_94X2016.toModify(slimmedElectronsWithUserData.userIntFromBools,
Expand All @@ -268,12 +268,12 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
cutbasedID_Spring15_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-veto"),
cutbasedID_Spring15_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-loose"),
cutbasedID_Spring15_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-medium"),
cutbasedID_Spring15_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"),
cutbasedID_Spring15_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Spring15-25ns-V1-standalone-tight"),
cutbasedID_Fall17_V2_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto"),
cutbasedID_Fall17_V2_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose"),
cutbasedID_Fall17_V2_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
cutbasedID_Fall17_V2_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),

)

run2_miniAOD_80XLegacy.toModify(slimmedElectronsWithUserData.userFloats,
Expand Down Expand Up @@ -349,6 +349,7 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
dxyErr = Var("edB('PV2D')",float,doc="dxy uncertainty, in cm",precision=6),
ip3d = Var("abs(dB('PV3D'))",float,doc="3D impact parameter wrt first PV, in cm",precision=10),
sip3d = Var("abs(dB('PV3D')/edB('PV3D'))",float,doc="3D impact parameter significance wrt first PV, in cm",precision=10),
scEta = Var("superCluster().eta()",float,doc="eta of the supercluster",precision=10),
deltaEtaSC = Var("superCluster().eta()-eta()",float,doc="delta eta (SC,ele) with sign",precision=10),
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),
Expand Down Expand Up @@ -395,7 +396,7 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
#therefore we redo it but but we need use a new name for the userFloat as we cant override existing userfloats
#for technical reasons
for modifier in run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_miniAOD_80XLegacy,run2_nanoAOD_102Xv1,run2_nanoAOD_106Xv1,run2_nanoAOD_106Xv2:
modifier.toModify(electronTable.variables,
modifier.toModify(electronTable.variables,
pt = Var("pt*userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, precision=-1, doc="p_{T}"),
energyErr = Var("userFloat('ecalTrkEnergyErrPostCorrNew')", float, precision=6, doc="energy error of the cluster-track combination"),
eCorr = Var("userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, doc="ratio of the calibrated energy/miniaod energy"),
Expand Down Expand Up @@ -493,7 +494,7 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
)
)


electronsMCMatchForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
Expand Down Expand Up @@ -523,10 +524,10 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
mcMap = cms.InputTag("electronsMCMatchForTable"),
mapTauAnc = cms.InputTag("matchingElecPhoton:hasTauAnc"),
objName = electronTable.name,
objType = cms.string("ElectronDressed"),
objType = cms.string("ElectronDressed"),
branchName = cms.string("genPart"),
docString = cms.string("MC matching to status==1 electrons or photons"),
genparticles = cms.InputTag("finalGenParticles"),
genparticles = cms.InputTag("finalGenParticles"),
)


Expand Down
7 changes: 4 additions & 3 deletions PhysicsTools/NanoAOD/python/globals_cff.py
Expand Up @@ -3,6 +3,7 @@

rhoTable = cms.EDProducer("GlobalVariablesTableProducer",
variables = cms.PSet(
fixedGridRhoAll = ExtVar( cms.InputTag("fixedGridRhoAll"), "double", doc = "rho from all PF Candidates, no foreground removal (for isolation of prompt photons)" ),
fixedGridRhoFastjetAll = ExtVar( cms.InputTag("fixedGridRhoFastjetAll"), "double", doc = "rho from all PF Candidates, used e.g. for JECs" ),
fixedGridRhoFastjetCentralNeutral = ExtVar( cms.InputTag("fixedGridRhoFastjetCentralNeutral"), "double", doc = "rho from neutral PF Candidates with |eta| < 2.5, used e.g. for rho corrections of some lepton isolations" ),
fixedGridRhoFastjetCentralCalo = ExtVar( cms.InputTag("fixedGridRhoFastjetCentralCalo"), "double", doc = "rho from calo towers with |eta| < 2.5, used e.g. egamma PFCluster isolation" ),
Expand All @@ -15,15 +16,15 @@
src = cms.InputTag("slimmedAddPileupInfo"),
pvsrc = cms.InputTag("offlineSlimmedPrimaryVertices"),
zbins = cms.vdouble( [0.0,1.7,2.6,3.0,3.5,4.2,5.2,6.0,7.5,9.0,12.0] ),
savePtHatMax = cms.bool(False),
savePtHatMax = cms.bool(False),
)

genTable = cms.EDProducer("SimpleGenEventFlatTableProducer",
src = cms.InputTag("generator"),
cut = cms.string(""),
cut = cms.string(""),
name= cms.string("Generator"),
doc = cms.string("Generator information"),
singleton = cms.bool(True),
singleton = cms.bool(True),
extension = cms.bool(False),
variables = cms.PSet(
x1 = Var( "?hasPDF?pdf().x.first:-1", float, doc="x1 fraction of proton momentum carried by the first parton",precision=14 ),
Expand Down
2 changes: 2 additions & 0 deletions PhysicsTools/NanoAOD/python/nanoDQM_cfi.py
Expand Up @@ -57,6 +57,7 @@
Plot1D('convVeto', 'convVeto', 2, -0.5, 1.5, 'pass conversion veto'),
Plot1D('cutBased', 'cutBased', 5, -0.5, 4.5, 'cut-based ID (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)'),
Plot1D('cutBased_HEEP', 'cutBased_HEEP', 2, -0.5, 1.5, 'cut-based HEEP ID'),
Plot1D('scEta', 'scEta', 20, -3, 3, 'supercluster eta'),
Plot1D('deltaEtaSC', 'deltaEtaSC', 20, -0.2, 0.2, 'delta eta (SC,ele) with sign'),
Plot1D('dr03EcalRecHitSumEt', 'dr03EcalRecHitSumEt', 20, 0, 30, 'Non-PF Ecal isolation within a delta R cone of 0.3 with electron pt > 35 GeV'),
Plot1D('dr03HcalDepth1TowerSumEt', 'dr03HcalDepth1TowerSumEt', 20, 0, 20, 'Non-PF Hcal isolation within a delta R cone of 0.3 with electron pt > 35 GeV'),
Expand Down Expand Up @@ -600,6 +601,7 @@
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('scEta', 'scEta', 20, -3, 3, 'supercluster 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'),
Plot1D('hoe', 'hoe', 20, 0, 0.6, 'H over E'),
Expand Down
1 change: 1 addition & 0 deletions PhysicsTools/NanoAOD/python/photons_cff.py
Expand Up @@ -230,6 +230,7 @@ def make_bitmapVID_docstring(id_modules_working_points_pset):
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),
scEta = Var("superCluster().eta()",float,doc="supercluster eta",precision=10),
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"),
Expand Down

0 comments on commit 3661e0b

Please sign in to comment.