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

Integration of extended ParticleNet trainings for simultaneous jet flavor tagging, pT regression, and tau ID + reconstruction #40745

Merged
merged 25 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
17471e8
add ParticleNetFromMiniAOD
Feb 10, 2023
30c3043
a few fixes after runtime testing
Feb 10, 2023
419dc21
remove commented line
Feb 10, 2023
5c0afbd
reformat new code
Feb 14, 2023
0659445
add test cfgs for ParticleNetFromMiniAOD
Feb 16, 2023
17457a5
first implementation of new extended ParticleNet networks in miniAOD …
Mar 1, 2023
06e0181
clean up saved output nodes
Mar 2, 2023
da0325f
fix reference to PNet miniAOD tags
Mar 2, 2023
7e5767b
remove DeepAK8 from miniAOD and nanoAOD, include full ParticleNet mas…
Mar 2, 2023
8903fcd
enable evaluation of new ParticleNet trainings in nanoAOD step
Mar 6, 2023
ac075a6
fix printouts
Mar 6, 2023
3bca26d
add PNet regression neutrino correction
Mar 6, 2023
57484c4
fix jet and JEC reference in nanoAOD PNet reevaluation for PUPPI
Mar 7, 2023
5e7f771
remove puppi weight from PNet feature evaluator and fix nano AK4 PUPP…
Mar 8, 2023
69a2c39
fix CvsL definition
Mar 9, 2023
acbdc84
add PNet to NanoAOD DQM and change name of mass-correlated tagger nodes
Mar 9, 2023
1ecd5da
save decommissioned taggers for older Nano eras and infer new PNet no…
Mar 15, 2023
71d3b02
also remove new PNet AK4 nodes for PUPPI jets eras 12_2/4
Mar 15, 2023
4ceeb26
remove extra space
Mar 15, 2023
525aadc
update DQM plots
Mar 17, 2023
61e61f4
don't run PNet AK4 on PUPPI for Run-2
Mar 17, 2023
0075526
fix DQM variables with ParticleNet
Mar 23, 2023
d524a88
remove duplicate variable
Mar 23, 2023
3c15acd
add missing commas
Mar 23, 2023
55daf9d
Merge tag 'CMSSW_13_1_X_2023-03-27-1100' of https://github.com/cms-sw…
Mar 27, 2023
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: 16 additions & 1 deletion PhysicsTools/NanoAOD/python/jetsAK4_CHS_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@
btagDeepFlavCvL = Var("?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg')):-1",float,doc="DeepJet c vs uds+g discriminator",precision=10),
btagDeepFlavCvB = Var("?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')):-1",float,doc="DeepJet c vs b+bb+lepb discriminator",precision=10),
btagDeepFlavQG = Var("?(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfDeepFlavourJetTags:probg')/(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds')):-1",float,doc="DeepJet g vs uds discriminator",precision=10),
btagPNetB = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:BvsAll')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:BvsAll'):-1",float,precision=10,doc="ParticleNet b vs. udscg"),
btagPNetCvL = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsL')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsL'):-1",float,precision=10,doc="ParticleNet c vs. udsg"),
btagPNetCvB = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsB')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:CvsB'):-1",float,precision=10,doc="ParticleNet c vs. b"),
btagPNetQvG = Var("?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:QvsG'):bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardDiscriminatorsJetTags:QvsG')",float,precision=10,doc="ParticleNet q (udsbc) vs. g"),
btagPNetTauVJet = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:TauVsJet')>0?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralDiscriminatorsJetTags:TauVsJet'):-1",float,precision=10,doc="ParticleNet tau vs. jet"),
PNetRegPtRawCorr = Var("?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptcorr'):bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptcorr')",float,precision=10,doc="ParticleNet universal flavor-aware visible pT regression (no neutrinos), correction relative to raw jet pT"),
PNetRegPtRawCorrNeutrino = Var("?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptnu'):bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptnu')",float,precision=10,doc="ParticleNet universal flavor-aware pT regression neutrino correction, relative to visible. To apply full regression, multiply raw jet pT by both PNetRegPtRawCorr and PNetRegPtRawCorrNeutrino."),
PNetRegPtRawRes = Var("?abs(eta())<2.5?0.5*(bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptreshigh')-bDiscriminator('pfParticleNetFromMiniAODAK4CHSCentralJetTags:ptreslow')):0.5*(bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptreshigh')-bDiscriminator('pfParticleNetFromMiniAODAK4CHSForwardJetTags:ptreslow'))",float,precision=10,doc="ParticleNet universal flavor-aware jet pT resolution estimator, (q84 - q16)/2"),
puIdDisc = Var("userFloat('puIdNanoDisc')", float,doc="Pileup ID discriminant with 106X (2018) training",precision=10),
puId = Var("userInt('puIdNanoId')", "uint8", doc="Pileup ID flags with 106X (2018) training"),
jetId = Var("userInt('tightId')*2+4*userInt('tightIdLepVeto')", "uint8", doc="Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto"),
Expand Down Expand Up @@ -323,14 +331,20 @@
## - To be used in nanoAOD_customizeCommon() in nano_cff.py
###############################################################
from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
def nanoAOD_addDeepInfoAK4CHS(process,addDeepBTag,addDeepFlavour):
def nanoAOD_addDeepInfoAK4CHS(process,addDeepBTag,addDeepFlavour,addParticleNet):
_btagDiscriminators=[]
if addDeepBTag:
print("Updating process to run DeepCSV btag")
_btagDiscriminators += ['pfDeepCSVJetTags:probb','pfDeepCSVJetTags:probbb','pfDeepCSVJetTags:probc']
if addDeepFlavour:
print("Updating process to run DeepFlavour btag")
_btagDiscriminators += ['pfDeepFlavourJetTags:probb','pfDeepFlavourJetTags:probbb','pfDeepFlavourJetTags:problepb','pfDeepFlavourJetTags:probc']
if addParticleNet:
print("Updating process to run ParticleNetAK4")
from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import _pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll as pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import _pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll as pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
_btagDiscriminators += pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
_btagDiscriminators += pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
if len(_btagDiscriminators)==0: return process
print("Will recalculate the following discriminators: "+", ".join(_btagDiscriminators))
updateJetCollection(
Expand All @@ -348,6 +362,7 @@ def nanoAOD_addDeepInfoAK4CHS(process,addDeepBTag,addDeepFlavour):
nanoAOD_addDeepInfoAK4CHS_switch = cms.PSet(
nanoAOD_addDeepBTag_switch = cms.untracked.bool(False),
nanoAOD_addDeepFlavourTag_switch = cms.untracked.bool(False),
nanoAOD_addParticleNet_switch = cms.untracked.bool(False),
)

################################################
Expand Down
43 changes: 43 additions & 0 deletions PhysicsTools/NanoAOD/python/jetsAK4_Puppi_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
btagDeepFlavCvL = Var("?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg')):-1",float,doc="DeepJet c vs uds+g discriminator",precision=10),
btagDeepFlavCvB = Var("?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')):-1",float,doc="DeepJet c vs b+bb+lepb discriminator",precision=10),
btagDeepFlavQG = Var("?(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfDeepFlavourJetTags:probg')/(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds')):-1",float,doc="DeepJet g vs uds discriminator",precision=10),
btagPNetB = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:BvsAll')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:BvsAll'):-1",float,precision=10,doc="ParticleNet b vs. udscg"),
btagPNetCvL = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:CvsL')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:CvsL'):-1",float,precision=10,doc="ParticleNet c vs. udsg"),
btagPNetCvB = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:CvsB')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:CvsB'):-1",float,precision=10,doc="ParticleNet c vs. b"),
btagPNetQvG = Var("?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:QvsG'):bDiscriminator('pfParticleNetFromMiniAODAK4PuppiForwardDiscriminatorsJetTags:QvsG')",float,precision=10,doc="ParticleNet q (udsbc) vs. g"),
btagPNetTauVJet = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:TauVsJet')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralDiscriminatorsJetTags:TauVsJet'):-1",float,precision=10,doc="ParticleNet tau vs. jet"),
PNetRegPtRawCorr = Var("?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:ptcorr'):bDiscriminator('pfParticleNetFromMiniAODAK4PuppiForwardJetTags:ptcorr')",float,precision=10,doc="ParticleNet universal flavor-aware visible pT regression (no neutrinos), correction relative to raw jet pT"),
PNetRegPtRawCorrNeutrino = Var("?abs(eta())<2.5?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:ptnu'):bDiscriminator('pfParticleNetFromMiniAODAK4PuppiForwardJetTags:ptnu')",float,precision=10,doc="ParticleNet universal flavor-aware pT regression neutrino correction, relative to visible. To apply full regression, multiply raw jet pT by both PNetRegPtRawCorr and PNetRegPtRawCorrNeutrino."),
PNetRegPtRawRes = Var("?abs(eta())<2.5?0.5*(bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:ptreshigh')-bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:ptreslow')):0.5*(bDiscriminator('pfParticleNetFromMiniAODAK4PuppiForwardJetTags:ptreshigh')-bDiscriminator('pfParticleNetFromMiniAODAK4PuppiForwardJetTags:ptreslow'))",float,precision=10,doc="ParticleNet universal flavor-aware jet pT resolution estimator, (q84 - q16)/2"),
jetId = Var("userInt('tightId')*2+4*userInt('tightIdLepVeto')", "uint8",doc="Jet ID flag: bit2 is tight, bit3 is tightLepVeto"),
hfsigmaEtaEta = Var("userFloat('hfsigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10),
hfsigmaPhiPhi = Var("userFloat('hfsigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10),
Expand All @@ -111,6 +119,41 @@
#jets are not as precise as muons
jetPuppiTable.variables.pt.precision=10

##############################################################
## DeepInfoAK4:Start
## - To be used in nanoAOD_customizeCommon() in nano_cff.py
###############################################################
from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
def nanoAOD_addDeepInfoAK4(process,addParticleNet):
_btagDiscriminators=[]
if addParticleNet:
print("Updating process to run ParticleNetAK4")
from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import _pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll as pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import _pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll as pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
_btagDiscriminators += pfParticleNetFromMiniAODAK4CHSCentralJetTagsAll
_btagDiscriminators += pfParticleNetFromMiniAODAK4CHSForwardJetTagsAll
if len(_btagDiscriminators)==0: return process
print("Will recalculate the following discriminators: "+", ".join(_btagDiscriminators))
updateJetCollection(
process,
jetSource = cms.InputTag('slimmedJetsPuppi'),
jetCorrections = ('AK4PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

I thought that we no longer had L1 corrections for PUPPI jets? I borrowed the same logic as used here in the miniAOD step: https://github.com/cms-sw/cmssw/blob/master/PhysicsTools/PatAlgos/python/slimming/applyDeepBtagging_cff.py#L68. I agree though that it's strange to have two different lists of JEC corrections. Maybe JME can clarify the procedure? @abenecke @anmalara

Copy link

Choose a reason for hiding this comment

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

True, L1 is not needed for Puppi and L2L3Res is only for data.
I'd also add a warning here. The current corrections won't be valid for the regressed jets, so why do we need them in the first place? I didn't check the code, but this should be valid for the mini step.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @anmalara, the idea was to make the ParticleNet regression correction relative to the raw jet pT available in the MINIAOD and NANOAOD even if you're right that the current JEC won't apply to the regressed jets. The idea was that we embed the ParticleNet outputs in the jet collections including the raw pT regression correction as something that can be studied to assess the performance gain from the resolution improvement even if one cannot use the regression as-is for an analysis for the time being. Then on the longer term we either integrate the regression as part of the JERC, as you know well, or we deploy an updated training with the regression relative to the JEC-corrected pT.

Copy link

Choose a reason for hiding this comment

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

This makes sense to me. I wanted to make clear (this information should be propagated carefully in twikis and it will) that the pt-regression and the pt-corrected cannot be mixed and if one wants to use the regression, one would need to reapply JEC on the fly.

Copy link
Author

Choose a reason for hiding this comment

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

Since as you know the ParticleNet regression from the raw pT effectively approximates multiple aspects of the JEC corrections, I guess that if using the regression there is no good prescription for how to integrate that with the JEC other than having it as an input prior to the JERC derivation. I totally agree that we should make sure this is clear to the user - just saying that I don't think there is really much an on-the-fly solution available other than deploying a regression trained from the JEC-corrected pT. Since for now the priority is to provide the inputs for the POGs we figured this would be okay for the short term.

Copy link
Contributor

@swertz swertz Mar 10, 2023

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

do you have a specific reason to remove this correction? The JERC group would make sure that if L1 is not needed for Puppi, a dummy file is created. Should we decide that we need L1 for Puppi, we should revert these changes. Maybe, it's safer to include this correction even in this PR.
Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

No that's fine then, if JERC would rather keep the dummy L1, we can leave it in, it's up to you.

btagDiscriminators = _btagDiscriminators,
postfix = 'WithDeepInfo',
)
process.load("Configuration.StandardSequences.MagneticField_cff")
process.jetPuppiCorrFactorsNano.src="selectedUpdatedPatJetsWithDeepInfo"
process.updatedJets.jetSource="selectedUpdatedPatJetsWithDeepInfo"
return process

nanoAOD_addDeepInfoAK4_switch = cms.PSet(
nanoAOD_addParticleNet_switch = cms.untracked.bool(False),
)

################################################
## DeepInfoAK4CHS:End
#################################################

################################################################################
# JETS FOR MET type1
################################################################################
Expand Down
Loading