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

Apply puppi weight in BoostedDoubleSV btaginfo for packedPFCandidates #29300

Merged
merged 5 commits into from Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions PhysicsTools/PatAlgos/python/tools/jetTools.py
Expand Up @@ -597,10 +597,18 @@ 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)
_btagInfo.weights = cms.InputTag("puppi")
if 'pfBoostedDouble' in btagInfo or 'SecondaryVertex' in btagInfo:
_btagInfo = getattr(process, btagPrefix+btagInfo+labelName+postfix)
if pfCandidates.value() == 'packedPFCandidates':
_btagInfo.weights = "packedpuppi"
if not hasattr(process,"packedpuppi"):
from CommonTools.PileupAlgos.Puppi_cff import puppi
addToProcessAndTask('packedpuppi', puppi.clone(
useExistingWeights = True,
candName = 'packedPFCandidates',
vertexName = 'offlineSlimmedPrimaryVertices') , process, task)
else:
_btagInfo.weights = "puppi"
Copy link
Contributor

Choose a reason for hiding this comment

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

apparently here weights does not already exist.
Is this some different module type or was it not created from the fillDescriptions file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, there are many SecondaryVertex config files not created from fillDescriptions:
https://github.com/ahinzmann/cmssw/tree/master/RecoBTag/SecondaryVertex/python

Copy link
Contributor Author

@ahinzmann ahinzmann Apr 8, 2020

Choose a reason for hiding this comment

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

the weights parameter is however protected against misspelling, if it misses the code in this PR will throw a error.


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