Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-14 00:30:37

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask
0004 
0005 
0006 def applyDeepBtagging(process, postfix=""):
0007     task = getPatAlgosToolsTask(process)
0008 
0009     from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
0010 
0011     from PhysicsTools.PatAlgos.slimming.slimmedJets_cfi import slimmedJets, slimmedJetsAK8
0012     from RecoBTag.ONNXRuntime.pfParticleNetAK4_cff import _pfParticleNetAK4JetTagsAll as pfParticleNetAK4JetTagsAll
0013 
0014     # update slimmed jets to include DeepFlavour (keep same name)
0015     # make clone for DeepFlavour-less slimmed jets, so output name is preserved
0016     addToProcessAndTask('slimmedJetsNoDeepFlavour', slimmedJets.clone(), process, task)
0017     _btagDiscriminatorsAK4CHS = cms.PSet(
0018         names=cms.vstring(
0019             'pfDeepFlavourJetTags:probb',
0020             'pfDeepFlavourJetTags:probbb',
0021             'pfDeepFlavourJetTags:problepb',
0022             'pfDeepFlavourJetTags:probc',
0023             'pfDeepFlavourJetTags:probuds',
0024             'pfDeepFlavourJetTags:probg')
0025     )
0026     updateJetCollection(
0027         process,
0028         jetSource = cms.InputTag('slimmedJetsNoDeepFlavour'),
0029         # updateJetCollection defaults to MiniAOD inputs but
0030         # here it is made explicit (as in training or MINIAOD redoing)
0031         pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'),
0032         pfCandidates = cms.InputTag('packedPFCandidates'),
0033         svSource = cms.InputTag('slimmedSecondaryVertices'),
0034         muSource = cms.InputTag('slimmedMuons'),
0035         elSource = cms.InputTag('slimmedElectrons'),
0036         jetCorrections = ('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'),
0037         btagDiscriminators = _btagDiscriminatorsAK4CHS.names.value(),
0038         postfix = 'SlimmedDeepFlavour' + postfix,
0039         printWarning = False
0040     )
0041 
0042     # slimmedJets with DeepFlavour (remove DeepFlavour-less)
0043     addToProcessAndTask('slimmedJets', getattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour' + postfix).clone(), process, task)
0044     # delete module not used anymore (slimmedJets substitutes)
0045     delattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour' + postfix)
0046 
0047     # update slimmedJetsPuppi to include deep taggers
0048     addToProcessAndTask('slimmedJetsPuppiNoDeepTags', slimmedJets.clone(
0049         src = "selectedPatJetsPuppi", packedPFCandidates = "packedPFCandidates"
0050     ), process, task)
0051     _btagDiscriminatorsAK4Puppi = cms.PSet(
0052         names=cms.vstring(
0053             'pfDeepFlavourJetTags:probb',
0054             'pfDeepFlavourJetTags:probbb',
0055             'pfDeepFlavourJetTags:problepb',
0056             'pfDeepFlavourJetTags:probc',
0057             'pfDeepFlavourJetTags:probuds',
0058             'pfDeepFlavourJetTags:probg') + pfParticleNetAK4JetTagsAll
0059     )
0060     updateJetCollection(
0061         process,
0062         jetSource = cms.InputTag('slimmedJetsPuppiNoDeepTags'),
0063         pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'),
0064         pfCandidates = cms.InputTag('packedPFCandidates'),
0065         svSource = cms.InputTag('slimmedSecondaryVertices'),
0066         muSource = cms.InputTag('slimmedMuons'),
0067         elSource = cms.InputTag('slimmedElectrons'),
0068         jetCorrections = ('AK4PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'),
0069         btagDiscriminators = _btagDiscriminatorsAK4Puppi.names.value(),
0070         postfix = 'SlimmedPuppiWithDeepTags' + postfix,
0071         printWarning = False
0072     )
0073 
0074     addToProcessAndTask('slimmedJetsPuppi', getattr(process, 'selectedUpdatedPatJetsSlimmedPuppiWithDeepTags' + postfix).clone(), process, task)
0075     # delete module not used anymore (slimmedJetsPuppi substitutes)
0076     delattr(process, 'selectedUpdatedPatJetsSlimmedPuppiWithDeepTags' + postfix)
0077 
0078 
0079     from RecoBTag.ONNXRuntime.pfDeepBoostedJet_cff import _pfDeepBoostedJetTagsAll as pfDeepBoostedJetTagsAll
0080     from RecoBTag.ONNXRuntime.pfHiggsInteractionNet_cff import _pfHiggsInteractionNetTagsProbs as pfHiggsInteractionNetTagsProbs
0081     from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetJetTagsAll as pfParticleNetJetTagsAll
0082     from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetMassRegressionOutputs
0083 
0084     # update slimmed jets to include particle-based deep taggers (keep same name)
0085     # make clone for DeepTags-less slimmed AK8 jets, so output name is preserved
0086     addToProcessAndTask('slimmedJetsAK8NoDeepTags', slimmedJetsAK8.clone(), process, task)
0087     _btagDiscriminatorsAK8 = cms.PSet(names = cms.vstring(
0088         'pfMassIndependentDeepDoubleBvLV2JetTags:probQCD',
0089         'pfMassIndependentDeepDoubleBvLV2JetTags:probHbb',
0090         'pfMassIndependentDeepDoubleCvLV2JetTags:probQCD',
0091         'pfMassIndependentDeepDoubleCvLV2JetTags:probHcc',
0092         'pfMassIndependentDeepDoubleCvBV2JetTags:probHbb',
0093         'pfMassIndependentDeepDoubleCvBV2JetTags:probHcc',
0094     ) + pfDeepBoostedJetTagsAll + pfParticleNetJetTagsAll + pfHiggsInteractionNetTagsProbs + _pfParticleNetMassRegressionOutputs)
0095     updateJetCollection(
0096         process,
0097         jetSource = cms.InputTag('slimmedJetsAK8NoDeepTags'),
0098         # updateJetCollection defaults to MiniAOD inputs but
0099         # here it is made explicit (as in training or MINIAOD redoing)
0100         pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'),
0101         pfCandidates = cms.InputTag('packedPFCandidates'),
0102         svSource = cms.InputTag('slimmedSecondaryVertices'),
0103         muSource = cms.InputTag('slimmedMuons'),
0104         elSource = cms.InputTag('slimmedElectrons'),
0105         rParam = 0.8,
0106         jetCorrections = ('AK8PFPuppi', cms.vstring(['L2Relative', 'L3Absolute']), 'None'),
0107         btagDiscriminators = _btagDiscriminatorsAK8.names.value(),
0108         postfix = 'SlimmedAK8DeepTags' + postfix,
0109         printWarning = False
0110     )
0111 
0112     # slimmedJetsAK8 with DeepTags (remove DeepTags-less)
0113     addToProcessAndTask('slimmedJetsAK8', getattr(process, 'selectedUpdatedPatJetsSlimmedAK8DeepTags' + postfix).clone(), process, task)
0114     # delete module not used anymore (slimmedJetsAK8 substitutes)
0115     delattr(process, 'selectedUpdatedPatJetsSlimmedAK8DeepTags' + postfix)