Skip to content

Commit

Permalink
Merge pull request #20241 from kpedro88/SmearedJetDeterministicSeed8028
Browse files Browse the repository at this point in the history
option to use deterministic event-based seed in SmearedJetProducer (for MT) [80X]
  • Loading branch information
cmsbuild committed Sep 12, 2017
2 parents c8094c4 + a49df8e commit ba66d45
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions PhysicsTools/PatUtils/interface/SmearedJetProducerT.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class SmearedJetProducerT : public edm::stream::EDProducer<> {
public:
explicit SmearedJetProducerT(const edm::ParameterSet& cfg):
m_enabled(cfg.getParameter<bool>("enabled")),
m_useDeterministicSeed(cfg.getParameter<bool>("useDeterministicSeed")),
m_debug(cfg.getUntrackedParameter<bool>("debug", false)) {

m_jets_token = consumes<JetCollection>(cfg.getParameter<edm::InputTag>("src"));
Expand Down Expand Up @@ -153,6 +154,7 @@ class SmearedJetProducerT : public edm::stream::EDProducer<> {
desc.add<std::int32_t>("variation", 0);
desc.add<std::uint32_t>("seed", 37428479);
desc.add<bool>("skipGenMatching", false);
desc.add<bool>("useDeterministicSeed", true);
desc.addUntracked<bool>("debug", false);

auto source =
Expand Down Expand Up @@ -183,6 +185,8 @@ class SmearedJetProducerT : public edm::stream::EDProducer<> {
JME::JetResolution resolution;
JME::JetResolutionScaleFactor resolution_sf;

const JetCollection& jets = *jets_collection;

if (m_enabled) {
if (m_use_txt_files) {
resolution = *m_resolution_from_file;
Expand All @@ -191,9 +195,16 @@ class SmearedJetProducerT : public edm::stream::EDProducer<> {
resolution = JME::JetResolution::get(setup, m_jets_algo_pt);
resolution_sf = JME::JetResolutionScaleFactor::get(setup, m_jets_algo);
}
}

const JetCollection& jets = *jets_collection;
if(m_useDeterministicSeed) {
unsigned int runNum_uint = static_cast <unsigned int> (event.id().run());
unsigned int lumiNum_uint = static_cast <unsigned int> (event.id().luminosityBlock());
unsigned int evNum_uint = static_cast <unsigned int> (event.id().event());
unsigned int jet0eta = uint32_t(jets.empty() ? 0 : jets[0].eta()/0.01);
std::uint32_t seed = jet0eta + (lumiNum_uint<<10) + (runNum_uint<<20) + evNum_uint;
m_random_generator.seed(seed);
}
}

if (m_genJetMatcher)
m_genJetMatcher->getTokens(event);
Expand Down Expand Up @@ -288,6 +299,7 @@ class SmearedJetProducerT : public edm::stream::EDProducer<> {
std::string m_jets_algo_pt;
std::string m_jets_algo;
Variation m_systematic_variation;
bool m_useDeterministicSeed;
bool m_debug;
std::shared_ptr<pat::GenJetMatcher> m_genJetMatcher;

Expand Down
1 change: 1 addition & 0 deletions PhysicsTools/PatUtils/python/patPFMETCorrections_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
variation = cms.int32(0), # If not specified, default to 0

seed = cms.uint32(37428479), # If not specified, default to 37428479
useDeterministicSeed = cms.bool(True),

debug = cms.untracked.bool(False)
)
Expand Down

0 comments on commit ba66d45

Please sign in to comment.