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

Add GloParT inference facility #46523

Merged
merged 4 commits into from
Nov 4, 2024
Merged
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
2 changes: 2 additions & 0 deletions PhysicsTools/NanoAOD/python/custom_jme_cff.py
Original file line number Diff line number Diff line change
@@ -1298,9 +1298,11 @@ def RecomputePuppiWeightsMETAK8(proc):
from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetMassRegressionOutputs as pfParticleNetMassRegressionOutputs
from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetMassCorrelatedJetTagsAll as pfParticleNetMassCorrelatedJetTagsAll
from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK8_cff import _pfParticleNetFromMiniAODAK8JetTagsAll as pfParticleNetFromMiniAODAK8JetTagsAll
from RecoBTag.ONNXRuntime.pfGlobalParticleTransformerAK8_cff import _pfGlobalParticleTransformerAK8JetTagsAll as pfGlobalParticleTransformerAK8JetTagsAll

btagDiscriminatorsAK8 = cms.PSet(names = cms.vstring(
pfParticleNetMassCorrelatedJetTagsAll+
pfGlobalParticleTransformerAK8JetTagsAll+
pfParticleNetFromMiniAODAK8JetTagsAll+
pfParticleNetJetTagsAll+
pfParticleNetMassRegressionOutputs
32 changes: 30 additions & 2 deletions PhysicsTools/NanoAOD/python/jetsAK8_cff.py
Original file line number Diff line number Diff line change
@@ -56,6 +56,28 @@
n2b1 = Var("?hasUserFloat('nb1AK8PuppiSoftDrop:ecfN2')?userFloat('nb1AK8PuppiSoftDrop:ecfN2'):-99999.", float, doc="N2 with beta=1 (for jets with raw pT>250 GeV)", precision=10),
n3b1 = Var("?hasUserFloat('nb1AK8PuppiSoftDrop:ecfN3')?userFloat('nb1AK8PuppiSoftDrop:ecfN3'):-99999.", float, doc="N3 with beta=1 (for jets with raw pT>250 GeV)", precision=10),
msoftdrop = Var("groomedMass('SoftDropPuppi')",float, doc="Corrected soft drop mass with PUPPI",precision=10),
globalParT3_Xbb = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXbb')",float,doc="Mass-decorrelated GlobalParT-3 X->bb score. Note: For sig vs bkg (e.g. bkg=QCD) tagging, use sig/(sig+bkg) to construct the discriminator",precision=10),
globalParT3_Xcc = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXcc')",float,doc="Mass-decorrelated GlobalParT-3 X->cc score",precision=10),
globalParT3_Xcs = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXcs')",float,doc="Mass-decorrelated GlobalParT-3 X->cs score",precision=10),
globalParT3_Xqq = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXqq')",float,doc="Mass-decorrelated GlobalParT-3 X->qq (ss/dd/uu) score",precision=10),
globalParT3_Xtauhtaue = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXtauhtaue')",float,doc="Mass-decorrelated GlobalParT-3 X->tauhtaue score",precision=10),
globalParT3_Xtauhtaum = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXtauhtaum')",float,doc="Mass-decorrelated GlobalParT-3 X->tauhtaum score",precision=10),
globalParT3_Xtauhtauh = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXtauhtauh')",float,doc="Mass-decorrelated GlobalParT-3 X->tauhtauh score",precision=10),
globalParT3_XWW4q = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXWW4q')",float,doc="Mass-decorrelated GlobalParT-3 X->WW4q score",precision=10),
globalParT3_XWW3q = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXWW3q')",float,doc="Mass-decorrelated GlobalParT-3 X->WW3q score",precision=10),
globalParT3_XWWqqev = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXWWqqev')",float,doc="Mass-decorrelated GlobalParT-3 X->WWqqev score",precision=10),
globalParT3_XWWqqmv = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probXWWqqmv')",float,doc="Mass-decorrelated GlobalParT-3 X->WWqqmv score",precision=10),
globalParT3_TopbWqq = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probTopbWqq')",float,doc="Mass-decorrelated GlobalParT-3 Top->bWqq score",precision=10),
globalParT3_TopbWq = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probTopbWq')",float,doc="Mass-decorrelated GlobalParT-3 Top->bWq score",precision=10),
globalParT3_TopbWev = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probTopbWev')",float,doc="Mass-decorrelated GlobalParT-3 Top->bWev score",precision=10),
globalParT3_TopbWmv = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probTopbWmv')",float,doc="Mass-decorrelated GlobalParT-3 Top->bWmv score",precision=10),
globalParT3_TopbWtauhv = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probTopbWtauhv')",float,doc="Mass-decorrelated GlobalParT-3 Top->bWtauhv score",precision=10),
globalParT3_QCD = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probQCD')",float,doc="Mass-decorrelated GlobalParT-3 QCD score.",precision=10),
globalParT3_massCorrX2p = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:massCorrX2p')",float,doc="GlobalParT-3 mass regression corrector with respect to the original jet mass, optimised for resonance 2-prong (bb/cc/cs/ss/qq) jets. Use (massCorrX2p * mass * (1 - rawFactor)) to get the regressed mass",precision=10),
globalParT3_massCorrGeneric = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:massCorrGeneric')",float,doc="GlobalParT-3 mass regression corrector with respect to the original jet mass, optimised for generic jet cases. Use (massCorrGeneric * mass * (1 - rawFactor)) to get the regressed mass",precision=10),
globalParT3_withMassTopvsQCD = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probWithMassTopvsQCD')",float,doc="GlobalParT-3 tagger (w/mass) Top vs QCD discriminator",precision=10),
globalParT3_withMassWvsQCD = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probWithMassWvsQCD')",float,doc="GlobalParT-3 tagger (w/mass) W vs QCD discriminator",precision=10),
globalParT3_withMassZvsQCD = Var("bDiscriminator('pfGlobalParticleTransformerAK8JetTags:probWithMassZvsQCD')",float,doc="GlobalParT-3 tagger (w/mass) Z vs QCD discriminator",precision=10),
particleNetWithMass_QCD = Var("bDiscriminator('pfParticleNetJetTags:probQCDbb')+bDiscriminator('pfParticleNetJetTags:probQCDcc')+bDiscriminator('pfParticleNetJetTags:probQCDb')+bDiscriminator('pfParticleNetJetTags:probQCDc')+bDiscriminator('pfParticleNetJetTags:probQCDothers')",float,doc="ParticleNet tagger (w/ mass) QCD(bb,cc,b,c,others) sum",precision=10),
particleNetWithMass_TvsQCD = Var("bDiscriminator('pfParticleNetDiscriminatorsJetTags:TvsQCD')",float,doc="ParticleNet tagger (w/ mass) top vs QCD discriminator",precision=10),
particleNetWithMass_WvsQCD = Var("bDiscriminator('pfParticleNetDiscriminatorsJetTags:WvsQCD')",float,doc="ParticleNet tagger (w/ mass) W vs QCD discriminator",precision=10),
@@ -147,7 +169,7 @@
## - To be used in nanoAOD_customizeCommon() in nano_cff.py
###############################################################
from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubleX, addDeepDoubleXV2, addParticleNetMassLegacy, addParticleNet, jecPayload):
def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubleX, addDeepDoubleXV2, addParticleNetMassLegacy, addParticleNet, addGlobalParT, jecPayload):
_btagDiscriminators=[]
if addDeepBTag:
print("Updating process to run DeepCSV btag to AK8 jets")
@@ -156,6 +178,10 @@ def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubl
print("Updating process to run DeepBoostedJet on datasets before 103X")
from RecoBTag.ONNXRuntime.pfDeepBoostedJet_cff import _pfDeepBoostedJetTagsAll as pfDeepBoostedJetTagsAll
_btagDiscriminators += pfDeepBoostedJetTagsAll
if addGlobalParT:
print("Updating process to run GlobalParT")
from RecoBTag.ONNXRuntime.pfGlobalParticleTransformerAK8_cff import _pfGlobalParticleTransformerAK8JetTagsAll as pfGlobalParticleTransformerAK8JetTagsAll
_btagDiscriminators += pfGlobalParticleTransformerAK8JetTagsAll
if addParticleNet:
print("Updating process to run ParticleNet joint classification and mass regression")
from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK8_cff import _pfParticleNetFromMiniAODAK8JetTagsAll as pfParticleNetFromMiniAODAK8JetTagsAll
@@ -200,16 +226,18 @@ def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubl
nanoAOD_addDeepDoubleXV2_switch = cms.untracked.bool(False),
nanoAOD_addParticleNetMassLegacy_switch = cms.untracked.bool(False),
nanoAOD_addParticleNet_switch = cms.untracked.bool(False),
nanoAOD_addGlobalParT_switch = cms.untracked.bool(False),
jecPayload = cms.untracked.string('AK8PFPuppi')
)


# ParticleNet legacy jet tagger is already in 106Xv2 MINIAOD,
# add ParticleNet legacy mass regression and new combined tagger + mass regression
# add ParticleNet legacy mass regression, new combined tagger + mass regression, and GlobalParT
run2_nanoAOD_106Xv2.toModify(
nanoAOD_addDeepInfoAK8_switch,
nanoAOD_addParticleNetMassLegacy_switch = True,
nanoAOD_addParticleNet_switch = True,
nanoAOD_addGlobalParT_switch = True,
)

################################################
22 changes: 22 additions & 0 deletions PhysicsTools/NanoAOD/python/nanoDQM_cfi.py
Original file line number Diff line number Diff line change
@@ -179,6 +179,28 @@
plots = cms.VPSet(
Count1D('_size', 6, -0.5, 5.5, 'slimmedJetsAK8, i.e. ak8 fat jets for boosted analysis'),
Plot1D('area', 'area', 20, 2, 4, 'jet catchment area, for JECs'),
Plot1D('globalParT3_Xbb', 'globalParT3_Xbb', 20, -1, 1, 'GlobalParT-3 X->bb score'),
Plot1D('globalParT3_Xcc', 'globalParT3_Xcc', 20, -1, 1, 'GlobalParT-3 X->cc score'),
Plot1D('globalParT3_Xcs', 'globalParT3_Xcs', 20, -1, 1, 'GlobalParT-3 X->cs score'),
Plot1D('globalParT3_Xqq', 'globalParT3_Xqq', 20, -1, 1, 'GlobalParT-3 X->qq (ss/dd/uu) score'),
Plot1D('globalParT3_Xtauhtaue', 'globalParT3_Xtauhtaue', 20, -1, 1, 'GlobalParT-3 X->tauhtaue score'),
Plot1D('globalParT3_Xtauhtaum', 'globalParT3_Xtauhtaum', 20, -1, 1, 'GlobalParT-3 X->tauhtaum score'),
Plot1D('globalParT3_Xtauhtauh', 'globalParT3_Xtauhtauh', 20, -1, 1, 'GlobalParT-3 X->tauhtauh score'),
Plot1D('globalParT3_XWW4q', 'globalParT3_XWW4q', 20, -1, 1, 'GlobalParT-3 X->WW4q score'),
Plot1D('globalParT3_XWW3q', 'globalParT3_XWW3q', 20, -1, 1, 'GlobalParT-3 X->WW3q score'),
Plot1D('globalParT3_XWWqqev', 'globalParT3_XWWqqev', 20, -1, 1, 'GlobalParT-3 X->WWqqev score'),
Plot1D('globalParT3_XWWqqmv', 'globalParT3_XWWqqmv', 20, -1, 1, 'GlobalParT-3 X->WWqqmv score'),
Plot1D('globalParT3_TopbWqq', 'globalParT3_TopbWqq', 20, -1, 1, 'GlobalParT-3 Top->bWqq score'),
Plot1D('globalParT3_TopbWq', 'globalParT3_TopbWq', 20, -1, 1, 'GlobalParT-3 Top->bWq score'),
Plot1D('globalParT3_TopbWev', 'globalParT3_TopbWev', 20, -1, 1, 'GlobalParT-3 Top->bWev score'),
Plot1D('globalParT3_TopbWmv', 'globalParT3_TopbWmv', 20, -1, 1, 'GlobalParT-3 Top->bWmv score'),
Plot1D('globalParT3_TopbWtauhv', 'globalParT3_TopbWtauhv', 20, -1, 1, 'GlobalParT-3 Top->bWtauhv score'),
Plot1D('globalParT3_QCD', 'globalParT3_QCD', 20, -1, 1, 'GlobalParT-3 QCD score'),
Plot1D('globalParT3_massCorrX2p', 'globalParT3_massCorrX2p', 20, -1, 2, 'GlobalParT-3 mass regression corrector (for X->2-prong jets)'),
Plot1D('globalParT3_massCorrGeneric', 'globalParT3_massCorrGeneric', 20, -1, 2, 'GlobalParT-3 mass regression corrector (for generic cases)'),
Plot1D('globalParT3_withMassTopvsQCD', 'globalParT3_withMassTopvsQCD', 20, -1, 1, 'GlobalParT-3 tagger (mass-correlated) Top vs QCD discriminator'),
Plot1D('globalParT3_withMassWvsQCD', 'globalParT3_withMassWvsQCD', 20, -1, 1, 'GlobalParT-3 tagger (mass-correlated) W vs QCD discriminator'),
Plot1D('globalParT3_withMassZvsQCD', 'globalParT3_withMassZvsQCD', 20, -1, 1, 'GlobalParT-3 tagger (mass-correlated) Z vs QCD discriminator'),
Plot1D('particleNetWithMass_QCD', 'particleNetWithMass_QCD', 20, -1, 1, 'ParticleNet (mass-correlated) QCD score'),
Plot1D('particleNetWithMass_TvsQCD', 'particleNetWithMass_TvsQCD', 20, 0, 1, 'ParticleNet (mass-correlated) top vs. QCD score'),
Plot1D('particleNetWithMass_WvsQCD', 'particleNetWithMass_WvsQCD', 20, 0, 1, 'ParticleNet (mass-correlated) W vs. QCD score'),
1 change: 1 addition & 0 deletions PhysicsTools/NanoAOD/python/nano_cff.py
Original file line number Diff line number Diff line change
@@ -233,6 +233,7 @@ def nanoAOD_customizeCommon(process):
addDeepDoubleXV2=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepDoubleXV2_switch,
addParticleNetMassLegacy=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNetMassLegacy_switch,
addParticleNet=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addParticleNet_switch,
addGlobalParT=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addGlobalParT_switch,
jecPayload=nanoAOD_addDeepInfoAK8_switch.jecPayload
)

14 changes: 13 additions & 1 deletion PhysicsTools/PatAlgos/python/recoLayer0/bTagging_cff.py
Original file line number Diff line number Diff line change
@@ -45,6 +45,8 @@
, 'pfParticleTransformerAK4TagInfos'
# UnifiedParticleTransformerAK4 tag infos
, 'pfUnifiedParticleTransformerAK4TagInfos'
# GlobalParticleTransformerAK8 tag infos
, 'pfGlobalParticleTransformerAK8TagInfos'
# DeepDoubleB/C tag infos
, 'pfDeepDoubleXTagInfos'
# DeepBoostedJet tag infos
@@ -379,5 +381,15 @@
# update supportedBtagDiscr
for disc in _pfNegativeUnifiedParticleTransformerAK4JetTagsProbs:
supportedBtagDiscr[disc] = [["pfNegativeUnifiedParticleTransformerAK4TagInfos"]]
# -----------------------------------


# -----------------------------------
# setup GlobalParticleTransformer AK8
from RecoBTag.ONNXRuntime.pfGlobalParticleTransformerAK8_cff import _pfGlobalParticleTransformerAK8JetTagsProbs, _pfGlobalParticleTransformerAK8JetTagsMetaDiscrs
# update supportedBtagDiscr
for disc in _pfGlobalParticleTransformerAK8JetTagsProbs:
supportedBtagDiscr[disc] = [["pfGlobalParticleTransformerAK8TagInfos"]]
# update supportedMetaDiscr
for disc in _pfGlobalParticleTransformerAK8JetTagsMetaDiscrs:
supportedMetaDiscr[disc] = _pfGlobalParticleTransformerAK8JetTagsProbs
# -----------------------------------
Original file line number Diff line number Diff line change
@@ -80,11 +80,12 @@ def applyDeepBtagging(process, postfix=""):
from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetMassRegressionOutputs as pfParticleNetMassRegressionOutputs
from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetMassCorrelatedJetTagsAll as pfParticleNetMassCorrelatedJetTagsAll
from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK8_cff import _pfParticleNetFromMiniAODAK8JetTagsAll as pfParticleNetFromMiniAODAK8JetTagsAll
from RecoBTag.ONNXRuntime.pfGlobalParticleTransformerAK8_cff import _pfGlobalParticleTransformerAK8JetTagsAll as pfGlobalParticleTransformerAK8JetTagsAll

# update slimmed jets to include particle-based deep taggers (keep same name)
# make clone for DeepTags-less slimmed AK8 jets, so output name is preserved
addToProcessAndTask('slimmedJetsAK8NoDeepTags', slimmedJetsAK8.clone(), process, task)
_btagDiscriminatorsAK8 = cms.PSet(names = cms.vstring(pfParticleNetMassCorrelatedJetTagsAll+pfParticleNetFromMiniAODAK8JetTagsAll+pfParticleNetJetTagsAll+pfParticleNetMassRegressionOutputs))
_btagDiscriminatorsAK8 = cms.PSet(names = cms.vstring(pfParticleNetMassCorrelatedJetTagsAll+pfGlobalParticleTransformerAK8JetTagsAll+pfParticleNetFromMiniAODAK8JetTagsAll+pfParticleNetJetTagsAll+pfParticleNetMassRegressionOutputs))
updateJetCollection(
process,
jetSource = cms.InputTag('slimmedJetsAK8NoDeepTags'),
4 changes: 2 additions & 2 deletions PhysicsTools/PatAlgos/python/tools/jetTools.py
Original file line number Diff line number Diff line change
@@ -786,7 +786,7 @@ def setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSou
),
process, task)

if btagInfo == 'pfParticleNetTagInfos':
if btagInfo == 'pfParticleNetTagInfos' or btagInfo == 'pfGlobalParticleTransformerAK8TagInfos':
if pfCandidates.value() == 'packedPFCandidates':
# case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
vertex_associator = ""
@@ -797,7 +797,7 @@ def setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSou
else:
raise ValueError("Invalid pfCandidates collection: %s." % pfCandidates.value())
addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
btag.pfParticleNetTagInfos.clone(
getattr(btag, btagInfo).clone(
jets = jetSource,
vertices = pvSource,
secondary_vertices = svSource,
Original file line number Diff line number Diff line change
@@ -44,8 +44,10 @@ def puppiJetMETReclusterFromMiniAOD(process, runOnMC, useExistingWeights=False,
from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetMassRegressionOutputs as pfParticleNetMassRegressionOutputs
from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetMassCorrelatedJetTagsAll as pfParticleNetMassCorrelatedJetTagsAll
from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK8_cff import _pfParticleNetFromMiniAODAK8JetTagsAll as pfParticleNetFromMiniAODAK8JetTagsAll
from RecoBTag.ONNXRuntime.pfGlobalParticleTransformerAK8_cff import _pfGlobalParticleTransformerAK8JetTagsAll as pfGlobalParticleTransformerAK8JetTagsAll
btagDiscriminatorsAK8 = cms.PSet(names = cms.vstring(
pfParticleNetMassCorrelatedJetTagsAll+
pfGlobalParticleTransformerAK8JetTagsAll+
pfParticleNetFromMiniAODAK8JetTagsAll+
pfParticleNetJetTagsAll+
pfParticleNetMassRegressionOutputs
1 change: 1 addition & 0 deletions RecoBTag/Configuration/python/RecoBTag_cff.py
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
from RecoBTag.ONNXRuntime.pfParticleNetAK4_cff import *
from RecoBTag.ONNXRuntime.pfParticleTransformerAK4_cff import *
from RecoBTag.ONNXRuntime.pfUnifiedParticleTransformerAK4_cff import *
from RecoBTag.ONNXRuntime.pfGlobalParticleTransformerAK8_cff import *
from RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff import *
from RecoBTag.PixelCluster.pixelClusterTagInfos_cfi import *

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions RecoBTag/ONNXRuntime/python/pfGlobalParticleTransformerAK8_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import FWCore.ParameterSet.Config as cms

from RecoBTag.FeatureTools.pfGlobalParticleTransformerAK8TagInfos_cfi import pfGlobalParticleTransformerAK8TagInfos as _pfGlobalParticleTransformerAK8TagInfos
from RecoBTag.ONNXRuntime.boostedJetONNXJetTagsProducer_cfi import boostedJetONNXJetTagsProducer

pfGlobalParticleTransformerAK8TagInfos = _pfGlobalParticleTransformerAK8TagInfos.clone(
use_puppiP4 = False
)

pfGlobalParticleTransformerAK8JetTags = boostedJetONNXJetTagsProducer.clone(
src = 'pfGlobalParticleTransformerAK8TagInfos',
preprocess_json = 'RecoBTag/Combined/data/GlobalParticleTransformerAK8/PUPPI/V03/preprocess.json',
model_path = 'RecoBTag/Combined/data/GlobalParticleTransformerAK8/PUPPI/V03/model.onnx',
flav_names = [
'probXbb', 'probXcc', 'probXcs', 'probXqq', 'probXtauhtaue', 'probXtauhtaum', 'probXtauhtauh', 'probXWW4q', 'probXWW3q', 'probXWWqqev', 'probXWWqqmv', 'probTopbWqq', 'probTopbWq', 'probTopbWev', 'probTopbWmv', 'probTopbWtauhv', 'probQCD', 'massCorrX2p', 'massCorrGeneric', 'probWithMassTopvsQCD', 'probWithMassWvsQCD', 'probWithMassZvsQCD'
] + ['hidNeuron' + str(i).zfill(3) for i in range(256)],
debugMode = False,
)

from CommonTools.PileupAlgos.Puppi_cff import puppi
from CommonTools.RecoAlgos.primaryVertexAssociation_cfi import primaryVertexAssociation

# This task is not used, useful only if we run it from RECO jets (RECO/AOD)
pfGlobalParticleTransformerAK8Task = cms.Task(puppi, primaryVertexAssociation, pfGlobalParticleTransformerAK8TagInfos, pfGlobalParticleTransformerAK8JetTags)

# declare all the discriminators

# probs
_pfGlobalParticleTransformerAK8JetTagsProbs = ['pfGlobalParticleTransformerAK8JetTags:' + flav_name for flav_name in pfGlobalParticleTransformerAK8JetTags.flav_names]

# meta-taggers
_pfGlobalParticleTransformerAK8JetTagsMetaDiscrs = []

_pfGlobalParticleTransformerAK8JetTagsAll = _pfGlobalParticleTransformerAK8JetTagsProbs + _pfGlobalParticleTransformerAK8JetTagsMetaDiscrs
70 changes: 70 additions & 0 deletions RecoBTag/ONNXRuntime/test/test_globalpart_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import FWCore.ParameterSet.Config as cms
from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask

from FWCore.ParameterSet.VarParsing import VarParsing
options = VarParsing('analysis')
options.inputFiles = '/store/mc/Run3Summer23BPixMiniAODv4/TTtoLNu2Q_TuneCP5_13p6TeV_powheg-pythia8/MINIAODSIM/130X_mcRun3_2023_realistic_postBPix_v2-v3/2520000/00488681-4f49-4bdc-89e6-198da9e42a17.root'
options.maxEvents = 10
options.parseArguments()

process = cms.Process('PATtest')

## MessageLogger
process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 1


## Options and Output Report
process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) )

## Source
process.source = cms.Source("PoolSource",
fileNames=cms.untracked.vstring(options.inputFiles)
)
## Maximal Number of Events
process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(options.maxEvents))

## Geometry and Detector Conditions (needed for a few patTuple production steps)
process.load("Configuration.Geometry.GeometryRecoDB_cff")
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2023_realistic')
process.load("Configuration.StandardSequences.MagneticField_cff")

## Output Module Configuration (expects a path 'p')
from PhysicsTools.PatAlgos.patEventContent_cff import patEventContentNoCleaning
process.out = cms.OutputModule("PoolOutputModule",
fileName = cms.untracked.string('patTuple.root'),
## save only events passing the full path
#SelectEvents = cms.untracked.PSet( SelectEvents = cms.vstring('p') ),
## save PAT output; you need a '*' to unpack the list of commands
## 'patEventContent'
outputCommands = cms.untracked.vstring('drop *', *patEventContentNoCleaning )
)

patAlgosToolsTask = getPatAlgosToolsTask(process)
process.outpath = cms.EndPath(process.out, patAlgosToolsTask)

## and add them to the event content
from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
from RecoBTag.ONNXRuntime.pfGlobalParticleTransformerAK8_cff import _pfGlobalParticleTransformerAK8JetTagsProbs as pfGlobalParticleTransformerAK8JetTagsProbs

updateJetCollection(
process,
jetSource = cms.InputTag('slimmedJetsAK8'),
pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'),
svSource = cms.InputTag('slimmedSecondaryVertices'),
rParam = 0.8,
jetCorrections = ('AK8PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'),
btagDiscriminators = pfGlobalParticleTransformerAK8JetTagsProbs
)

from Configuration.EventContent.EventContent_cff import MINIAODSIMEventContent
process.out.outputCommands.append('keep *_slimmedJetsAK8*_*_*')
process.out.outputCommands.append('keep *_offlineSlimmedPrimaryVertices*_*_*')
process.out.outputCommands.append('keep *_slimmedSecondaryVertices*_*_*')
process.out.outputCommands.append('keep *_selectedPatJets*_*_*')
process.out.outputCommands.append('keep *_selectedUpdatedPatJets*_*_*')
process.out.outputCommands.append('keep *_updatedPatJets*_*_*')

process.out.fileName = 'test_globalpart_MINIAODSIM_noragged.root'