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

[8.0.X] Prevent negative jet smearing factor #15250

Merged
Changes from all 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
13 changes: 13 additions & 0 deletions PhysicsTools/PatUtils/interface/SmearedJetProducerT.h
Expand Up @@ -252,6 +252,17 @@ class SmearedJetProducerT : public edm::stream::EDProducer<> {
std::cout << "Impossible to smear this jet" << std::endl;
}

if (jet.energy() * smearFactor < MIN_JET_ENERGY) {
// Negative or too small smearFactor. We would change direction of the jet
// and this is not what we want.
// Recompute the smearing factor in order to have jet.energy() == MIN_JET_ENERGY
double newSmearFactor = MIN_JET_ENERGY / jet.energy();
if (m_debug) {
std::cout << "The smearing factor (" << smearFactor << ") is either negative or too small. Fixing it to " << newSmearFactor << " to avoid change of direction." << std::endl;
}
smearFactor = newSmearFactor;
}

T smearedJet = jet;
smearedJet.scaleEnergy(smearFactor);

Expand All @@ -269,6 +280,8 @@ class SmearedJetProducerT : public edm::stream::EDProducer<> {
}

private:
static constexpr const double MIN_JET_ENERGY = 1e-2;

edm::EDGetTokenT<JetCollection> m_jets_token;
edm::EDGetTokenT<double> m_rho_token;
bool m_enabled;
Expand Down