Skip to content

Commit

Permalink
[DijetAnalysis] Add Ntuple branch 'randomUniform' for doing subsampling.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsavoiu committed Mar 21, 2020
1 parent e034621 commit b927e9d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DijetAnalysis/interface/NtupleProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/StreamID.h"

// for random number generator service
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"
#include "CLHEP/Random/RandomEngine.h"
#include "CLHEP/Random/RandFlat.h"

#include <boost/regex.hpp>

#include "Karma/Common/interface/EDMTools/Caches.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,10 @@ def configure(process, options):
"smearedCorrectedJets{}{}{}".format(jet_collection, jec_shift, jer_variation) : cms.PSet(
initialSeed=cms.untracked.uint32(83),
engineName=cms.untracked.string('TRandom3')
),
"ntuple{}{}".format(jet_collection, _pipeline_suffix) : cms.PSet(
initialSeed=cms.untracked.uint32(497931),
engineName=cms.untracked.string('TRandom3')
)
})

Expand All @@ -696,6 +700,12 @@ def configure(process, options):
jet_algo_name=jet_collection,
jec_shift=None
)
_rng_engines.update({
"ntuple{}{}".format(jet_collection, 'Raw') : cms.PSet(
initialSeed=cms.untracked.uint32(497931),
engineName=cms.untracked.string('TRandom3')
)
})

# random number generator service (for JER smearing)
if _rng_engines:
Expand Down
1 change: 1 addition & 0 deletions DijetAnalysis/src/NtupleFlatOutput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void dijet::NtupleFlatOutput::setUpTTree(TTree* tree, dijet::NtupleEntry* produc
ADD_BRANCH(tree, productForFill, lumi, I);
ADD_BRANCH(tree, productForFill, event, L);
ADD_BRANCH(tree, productForFill, bx, I);
ADD_BRANCH(tree, productForFill, randomUniform, D);
ADD_BRANCH(tree, productForFill, rho, D);
ADD_BRANCH(tree, productForFill, npv, I);
ADD_BRANCH(tree, productForFill, npvGood, I);
Expand Down
5 changes: 5 additions & 0 deletions DijetAnalysis/src/NtupleProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,18 @@ void dijet::NtupleProducer::produce(edm::Event& event, const edm::EventSetup& se

assert(this->karmaMETCollectionHandle->size() == 1); // only allow MET collections containing a single MET object

// get random number generator engine
edm::Service<edm::RandomNumberGenerator> rng;
CLHEP::HepRandomEngine& rngEngine = rng->getEngine(event.streamID());

// -- populate outputs

// event metadata
outputNtupleEntry->run = event.id().run();
outputNtupleEntry->lumi = event.id().luminosityBlock();
outputNtupleEntry->event = event.id().event();
outputNtupleEntry->bx = event.bunchCrossing();
outputNtupleEntry->randomUniform = CLHEP::RandFlat::shoot(&rngEngine, 0, 1);

// -- copy event content to ntuple
outputNtupleEntry->rho = this->karmaEventHandle->rho;
Expand Down
1 change: 1 addition & 0 deletions DijetAnalysisFormats/interface/Ntuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace dijet {
int lumi = -1;
long event = -1;
int bx = -1;
double randomUniform = UNDEFINED_DOUBLE;
// pileup-related
double rho = UNDEFINED_DOUBLE; // PU density
double nPUMean = UNDEFINED_DOUBLE; // true (MC) or estimated (DATA) mean of Poisson distribution of `nPU`
Expand Down

0 comments on commit b927e9d

Please sign in to comment.