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

option to use deterministic event-based seed in SmearedJetProducer (for MT) #20240

Merged
merged 4 commits into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -162,6 +163,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 @@ -192,6 +194,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 @@ -200,9 +204,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 + m_nomVar + (lumiNum_uint<<10) + (runNum_uint<<20) + evNum_uint;
m_random_generator.seed(seed);
}
}

if (m_genJetMatcher)
m_genJetMatcher->getTokens(event);
Expand Down Expand Up @@ -297,6 +308,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 @@ -138,6 +138,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),
Copy link
Contributor

Choose a reason for hiding this comment

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

this does not match the PR description

Currently I have the useDeterministicSeed option disabled by default

I suppose, the description should be updated.


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