From 501e2d9e8221f8111efd53a87418a55838a36a62 Mon Sep 17 00:00:00 2001 From: Andrej Saibel Date: Tue, 8 May 2018 14:06:12 +0200 Subject: [PATCH] backport of ttHfgenfilter to 94X --- PhysicsTools/JetMCAlgos/plugins/ttHFGenFilter.cc | 10 ++++++++-- PhysicsTools/JetMCAlgos/python/ttHFGenFilter_cfi.py | 3 ++- PhysicsTools/JetMCAlgos/test/testttHFGenFilter.py | 10 +++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/PhysicsTools/JetMCAlgos/plugins/ttHFGenFilter.cc b/PhysicsTools/JetMCAlgos/plugins/ttHFGenFilter.cc index e923f54703485..339e146a0dce1 100644 --- a/PhysicsTools/JetMCAlgos/plugins/ttHFGenFilter.cc +++ b/PhysicsTools/JetMCAlgos/plugins/ttHFGenFilter.cc @@ -67,6 +67,7 @@ class ttHFGenFilter : public edm::stream::EDFilter<> { const edm::EDGetTokenT > > genBHadPlusMothersIndicesToken_; const edm::EDGetTokenT > genBHadIndexToken_; bool OnlyHardProcessBHadrons_; + bool taggingMode_; // ----------member data --------------------------- @@ -93,6 +94,9 @@ genBHadIndexToken_(consumes >(iConfig.getParameter ( "OnlyHardProcessBHadrons" ); + taggingMode_ = iConfig.getParameter("taggingMode"); + + produces(); } @@ -142,9 +146,11 @@ ttHFGenFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) std::vector AllTopMothers; std::vector Tops = GetTops(*genParticles,AllTopMothers); - // std::cout << "Size of AllTopMothers = " << AllTopMothers.size() << std::endl; - return HasAdditionalBHadron(*genBHadIndex,*genBHadFlavour,*genBHadPlusMothers,AllTopMothers); + bool pass = HasAdditionalBHadron(*genBHadIndex,*genBHadFlavour,*genBHadPlusMothers,AllTopMothers); + + iEvent.put(std::make_unique(pass)); + return taggingMode_ || pass; } bool ttHFGenFilter::HasAdditionalBHadron(const std::vector& genBHadIndex, const std::vector& genBHadFlavour,const std::vector& genBHadPlusMothers,std::vector& AllTopMothers){ diff --git a/PhysicsTools/JetMCAlgos/python/ttHFGenFilter_cfi.py b/PhysicsTools/JetMCAlgos/python/ttHFGenFilter_cfi.py index 3bd9e1848ee1b..cfda861ffaaf2 100644 --- a/PhysicsTools/JetMCAlgos/python/ttHFGenFilter_cfi.py +++ b/PhysicsTools/JetMCAlgos/python/ttHFGenFilter_cfi.py @@ -9,6 +9,7 @@ genBHadPlusMothersIndices = cms.InputTag("matchGenBHadron", "genBHadPlusMothersIndices"), genBHadIndex = cms.InputTag("matchGenBHadron", "genBHadIndex"), - OnlyHardProcessBHadrons = cms.bool(False) + OnlyHardProcessBHadrons = cms.bool(False), + taggingMode = cms.bool(False) ) diff --git a/PhysicsTools/JetMCAlgos/test/testttHFGenFilter.py b/PhysicsTools/JetMCAlgos/test/testttHFGenFilter.py index 98a431054f4dc..d889fe82dc83c 100644 --- a/PhysicsTools/JetMCAlgos/test/testttHFGenFilter.py +++ b/PhysicsTools/JetMCAlgos/test/testttHFGenFilter.py @@ -13,7 +13,7 @@ ) ## Set up command line options options = VarParsing ('analysis') -options.register('runOnGenOrAODsim', True, VarParsing.multiplicity.singleton, VarParsing.varType.bool, "GEN SIM") +options.register('runOnGenOrAODsim', False, VarParsing.multiplicity.singleton, VarParsing.varType.bool, "GEN SIM") options.register( "skipEvents", 0, VarParsing.multiplicity.singleton, VarParsing.varType.int, "Number of events to skip" ) options.parseArguments() @@ -28,7 +28,7 @@ if options.runOnGenOrAODsim: options.inputFiles=['/store/mc/RunIISummer15GS/TTToSemiLeptonic_TuneCUETP8M1_alphaS01273_13TeV-powheg-scaledown-pythia8/GEN-SIM/MCRUN2_71_V1-v2/40000/DE7952A2-6E2F-E611-A803-001E673D1B21.root'] else: - options.inputFiles=['/store/mc/RunIISpring15MiniAODv2/ttbb_4FS_ckm_amcatnlo_madspin_pythia8/MINIAODSIM/74X_mcRun2_asymptotic_v2-v1/40000/06D46D97-C66D-E511-9ABF-00266CFAE20C.root'] + options.inputFiles=['/store/mc/RunIIFall17MiniAOD/TTToSemiLeptonic_TuneCP5_PSweights_13TeV-powheg-pythia8/MINIAODSIM/94X_mc2017_realistic_v10-v1/50000/DC5D3109-F2E1-E711-A26E-A0369FC5FC9C.root'] ## Define maximum number of events to loop over if options.maxEvents is -1: # maxEvents is set in VarParsing class by default to -1 @@ -108,9 +108,13 @@ process.load("PhysicsTools/JetMCAlgos/ttHFGenFilter_cfi") from PhysicsTools.JetMCAlgos.ttHFGenFilter_cfi import ttHFGenFilter process.ttHFGenFilter = ttHFGenFilter.clone( - genParticles = genParticleCollection + genParticles = genParticleCollection, + taggingMode = cms.bool(True), ) +print "If taggingMode is set to true, the filter will write a branch into the tree instead of filtering the events" +print "taggingMode is set to ", process.ttHFGenFilter.taggingMode + ## configuring the testing analyzer that produces output tree #process.matchGenHFHadrons = cms.EDAnalyzer("matchGenHFHadrons",