Skip to content

Commit

Permalink
Apply puppi weight consistently in BoostedDoubleSV btaginfo for packe…
Browse files Browse the repository at this point in the history
…d and PF candidates
  • Loading branch information
ahinzmann committed Mar 25, 2020
1 parent 0884d51 commit 2d2f563
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Expand Up @@ -42,6 +42,12 @@ def applyDeepBtagging( process, postfix="" ) :
# delete module not used anymore (slimmedJets substitutes)
delattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour'+postfix)

from CommonTools.PileupAlgos.Puppi_cff import puppi
addToProcessAndTask('packedpuppi', puppi.clone(
useExistingWeights = True,
candName = 'packedPFCandidates',
vertexName = cms.InputTag('offlineSlimmedPrimaryVertices')) , process, task)

from RecoBTag.ONNXRuntime.pfDeepBoostedJet_cff import _pfDeepBoostedJetTagsAll as pfDeepBoostedJetTagsAll
from RecoBTag.MXNet.pfParticleNet_cff import _pfParticleNetJetTagsAll as pfParticleNetJetTagsAll

Expand Down
8 changes: 5 additions & 3 deletions PhysicsTools/PatAlgos/python/tools/jetTools.py
Expand Up @@ -597,10 +597,12 @@ def setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSou
btag.pixelClusterTagInfos.clone(jets = jetSource, vertices=pvSource),
process, task)

if 'Puppi' in jetSource.value() and pfCandidates.value() == 'particleFlow' and\
('pfBoostedDouble' in btagInfo or 'SecondaryVertex' in btagInfo):
_btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
if 'pfBoostedDouble' in btagInfo or 'SecondaryVertex' in btagInfo:
_btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
if 'Puppi' in jetSource.value() and pfCandidates.value() == 'particleFlow':
_btagInfo.weights = cms.InputTag("puppi")
if 'SlimmedAK8DeepTags' in jetSource.value() and pfCandidates.value() == 'packedPFCandidates':
_btagInfo.weights = cms.InputTag("packedpuppi")

if 'DeepFlavourTagInfos' in btagInfo:
svUsed = svSource
Expand Down
12 changes: 5 additions & 7 deletions RecoBTag/SecondaryVertex/plugins/BoostedDoubleSVProducer.cc
Expand Up @@ -672,10 +672,9 @@ void BoostedDoubleSVProducer::calcNsubjettiness(const reco::JetBaseRef& jet,
if (!weightsToken_.isUninitialized())
w = (*weightsHandle_)[constit];
else {
w = 1.0; // For backward compatibility PUPPI weight is not applied to PackedCandidates.
//throw cms::Exception("MissingConstituentWeight")
// << "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection"
// << std::endl;
throw cms::Exception("MissingConstituentWeight")
<< "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection"
<< std::endl;
}
fjParticles.push_back(
fastjet::PseudoJet(constit->px() * w, constit->py() * w, constit->pz() * w, constit->energy() * w));
Expand All @@ -698,9 +697,8 @@ void BoostedDoubleSVProducer::calcNsubjettiness(const reco::JetBaseRef& jet,
if (!weightsToken_.isUninitialized())
w = (*weightsHandle_)[daughter];
else {
w = 1.0; // For backward compatibility PUPPI weight is not applied to PackedCandidates.
//throw cms::Exception("MissingConstituentWeight")
// << "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
throw cms::Exception("MissingConstituentWeight")
<< "BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
}
fjParticles.push_back(
fastjet::PseudoJet(daughter->px() * w, daughter->py() * w, daughter->pz() * w, daughter->energy() * w));
Expand Down

0 comments on commit 2d2f563

Please sign in to comment.