Skip to content

Commit

Permalink
[Common] [SmearedJetsProducer] Prevent negative smearing factors.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsavoiu committed Mar 17, 2020
1 parent c5c541f commit e348e36
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Common/src/Producers/SmearedJetsProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ void karma::SmearedJetsProducer::produce(edm::Event& event, const edm::EventSetu
// (needed in order not to break replay)
// https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideEDMRandomNumberGeneratorService#Replay
CLHEP::RandGaussT::setFlag(false);
outputJetCollection->back().p4 *= (
1 + (
CLHEP::RandGaussT::shoot(&rngEngine, 0, resolution) *
std::sqrt(std::max(resolutionSF * resolutionSF - 1, 0.0))
)
double scaleFactor = 1 + (
CLHEP::RandGaussT::shoot(&rngEngine, 0, resolution) *
std::sqrt(std::max(resolutionSF * resolutionSF - 1, 0.0))
);

// prevent negative scale factors
if (scaleFactor < 0) scaleFactor = 0.0;

// apply scale factor
outputJetCollection->back().p4 *= scaleFactor;
}

}
Expand Down

0 comments on commit e348e36

Please sign in to comment.