Skip to content

Commit

Permalink
Merge pull request #36274 from kdlong/backportParticleLevel
Browse files Browse the repository at this point in the history
Backport particle level runtime improvements for Nano 106X
  • Loading branch information
cmsbuild authored Dec 23, 2021
2 parents 62d0e56 + ca42d89 commit 5d82080
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 36 deletions.
8 changes: 6 additions & 2 deletions GeneratorInterface/RivetInterface/interface/RivetAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Rivet {
bool _usePromptFinalStates;
bool _excludePromptLeptonsFromJetClustering;
bool _excludeNeutrinosFromJetClustering;
bool _doJetClustering;

double _particleMinPt, _particleMaxEta;
double _lepConeSize, _lepMinPt, _lepMaxEta;
Expand All @@ -51,6 +52,7 @@ namespace Rivet {
_usePromptFinalStates(pset.getParameter<bool>("usePromptFinalStates")),
_excludePromptLeptonsFromJetClustering(pset.getParameter<bool>("excludePromptLeptonsFromJetClustering")),
_excludeNeutrinosFromJetClustering(pset.getParameter<bool>("excludeNeutrinosFromJetClustering")),
_doJetClustering(pset.getParameter<bool>("doJetClustering")),

_particleMinPt (pset.getParameter<double>("particleMinPt")),
_particleMaxEta (pset.getParameter<double>("particleMaxEta")),
Expand Down Expand Up @@ -201,8 +203,10 @@ namespace Rivet {

}

_jets = applyProjection<FastJets>(event, "Jets").jetsByPt(jet_cut);
_fatjets = applyProjection<FastJets>(event, "FatJets").jetsByPt(fatjet_cut);
if (_doJetClustering) {
_jets = apply<FastJets>(event, "Jets").jetsByPt(jet_cut);
_fatjets = apply<FastJets>(event, "FatJets").jetsByPt(fatjet_cut);
}
_neutrinos = applyProjection<FinalState>(event, "Neutrinos").particlesByPt();
_met = applyProjection<MissingMomentum>(event, "MET").missingMomentum().p3();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
usePromptFinalStates = cms.bool(True), # for leptons, photons, neutrinos
excludePromptLeptonsFromJetClustering = cms.bool(True),
excludeNeutrinosFromJetClustering = cms.bool(True),
doJetClustering = cms.bool(True),

particleMinPt = cms.double(0.),
particleMaxEta = cms.double(5.), # HF range. Maximum 6.0 on MiniAOD
Expand Down
12 changes: 9 additions & 3 deletions PhysicsTools/NanoAOD/plugins/GenJetGenPartMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"

#include "DataFormats/Common/interface/ValueMap.h"
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
#include "CommonTools/Utils/interface/StringObjectFunction.h"

//
// class declaration
Expand All @@ -33,6 +35,7 @@ class GenJetGenPartMerger : public edm::stream::EDProducer<> {

const edm::EDGetTokenT<reco::GenJetCollection> jetToken_;
const edm::EDGetTokenT<reco::GenParticleCollection> partToken_;
const StringCutObjectSelector<reco::Candidate> cut_;
const edm::EDGetTokenT<edm::ValueMap<bool>> tauAncToken_;
};

Expand All @@ -50,6 +53,7 @@ class GenJetGenPartMerger : public edm::stream::EDProducer<> {
GenJetGenPartMerger::GenJetGenPartMerger(const edm::ParameterSet& iConfig)
: jetToken_(consumes<reco::GenJetCollection>(iConfig.getParameter<edm::InputTag>("srcJet"))),
partToken_(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("srcPart"))),
cut_(iConfig.getParameter<std::string>("cut")),
tauAncToken_(consumes<edm::ValueMap<bool>>(iConfig.getParameter<edm::InputTag>("hasTauAnc"))) {
produces<reco::GenJetCollection>("merged");
produces<edm::ValueMap<bool>>("hasTauAnc");
Expand Down Expand Up @@ -79,9 +83,11 @@ void GenJetGenPartMerger::produce(edm::Event& iEvent, const edm::EventSetup& iSe

for (unsigned int ijet = 0; ijet < jetHandle->size(); ++ijet) {
auto jet = jetHandle->at(ijet);
merged->push_back(reco::GenJet(jet));
reco::GenJetRef jetRef(jetHandle, ijet);
hasTauAncValues.push_back((*tauAncHandle)[jetRef]);
if (cut_(jet)) {
merged->push_back(reco::GenJet(jet));
reco::GenJetRef jetRef(jetHandle, ijet);
hasTauAncValues.push_back((*tauAncHandle)[jetRef]);
}
}

for (auto& part : *partHandle) {
Expand Down
17 changes: 7 additions & 10 deletions PhysicsTools/NanoAOD/python/electrons_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,19 +469,16 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
vidNestedWPBitmapSum16 = Var("userInt('VIDNestedWPBitmapSum16')",int,doc=_bitmapVIDForEleSum16_docstring),

)

from PhysicsTools.NanoAOD.particlelevel_cff import particleLevel
particleLevelForMatching = particleLevel.clone(
lepMinPt = cms.double(3.),
phoMinPt = cms.double(3),
)
#############electron Table END#####################
# Depends on particlelevel producer run in particlelevel_cff
tautaggerForMatching = cms.EDProducer("GenJetTauTaggerProducer",
src = cms.InputTag('particleLevelForMatching:leptons')
src = cms.InputTag('particleLevel:leptons')
)

matchingElecPhoton = cms.EDProducer("GenJetGenPartMerger",
srcJet =cms.InputTag("particleLevelForMatching:leptons"),
srcPart=cms.InputTag("particleLevelForMatching:photons"),
srcJet =cms.InputTag("particleLevel:leptons"),
srcPart=cms.InputTag("particleLevel:photons"),
cut = cms.string("pt > 3"),
hasTauAnc=cms.InputTag("tautaggerForMatching"),
)

Expand Down Expand Up @@ -536,7 +533,7 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
electronSequence = cms.Sequence(bitmapVIDForEle + bitmapVIDForEleHEEP + isoForEle + ptRatioRelForEle + seedGainEle + slimmedElectronsWithUserData + finalElectrons)
electronTables = cms.Sequence (electronMVATTH + electronTable)
electronMCold = cms.Sequence(electronsMCMatchForTable + electronMCTable)
electronMC = cms.Sequence(particleLevelForMatching + tautaggerForMatching + matchingElecPhoton + electronsMCMatchForTable + electronsMCMatchForTableAlt + electronMCTable)
electronMC = cms.Sequence(tautaggerForMatching + matchingElecPhoton + electronsMCMatchForTable + electronsMCMatchForTableAlt + electronMCTable)
( run2_nanoAOD_106Xv1 & ~run2_nanoAOD_devel).toModify( electronMCTable,
mcMapDressedLep=None,
mcMap = cms.InputTag("electronsMCMatchForTable"),
Expand Down
23 changes: 6 additions & 17 deletions PhysicsTools/NanoAOD/python/lowPtElectrons_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,13 @@
# electronTable (MC)
################################################################################

from PhysicsTools.NanoAOD.particlelevel_cff import particleLevel
particleLevelForMatchingLowPt = particleLevel.clone(
lepMinPt = cms.double(1.),
phoMinPt = cms.double(1),
)

tautaggerForMatchingLowPt = cms.EDProducer(
"GenJetTauTaggerProducer",
src = cms.InputTag('particleLevelForMatchingLowPt:leptons')
)

# Depends on tautaggerForMatching being run in electrons_cff
matchingLowPtElecPhoton = cms.EDProducer(
"GenJetGenPartMerger",
srcJet =cms.InputTag("particleLevelForMatchingLowPt:leptons"),
srcPart=cms.InputTag("particleLevelForMatchingLowPt:photons"),
hasTauAnc=cms.InputTag("tautaggerForMatchingLowPt"),
srcJet =cms.InputTag("particleLevel:leptons"),
srcPart=cms.InputTag("particleLevel:photons"),
cut = cms.string(""),
hasTauAnc=cms.InputTag("tautaggerForMatching"),
)

lowPtElectronsMCMatchForTableAlt = cms.EDProducer(
Expand Down Expand Up @@ -194,9 +185,7 @@
+finalLowPtElectrons)
lowPtElectronTables = cms.Sequence(lowPtElectronTable)
lowPtElectronMC = cms.Sequence(
particleLevelForMatchingLowPt
+tautaggerForMatchingLowPt
+matchingLowPtElecPhoton
matchingLowPtElecPhoton
+lowPtElectronsMCMatchForTable
+lowPtElectronsMCMatchForTableAlt
+lowPtElectronMCTable)
Expand Down
9 changes: 5 additions & 4 deletions PhysicsTools/NanoAOD/python/particlelevel_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
particleLevel = cms.EDProducer("ParticleLevelProducer",
src = cms.InputTag("genParticles2HepMC:unsmeared"),

doJetClustering = cms.bool(False), # Not needed as Rivet jets aren't used currently
usePromptFinalStates = cms.bool(True), # for leptons, photons, neutrinos
excludePromptLeptonsFromJetClustering = cms.bool(False),
excludeNeutrinosFromJetClustering = cms.bool(True),
Expand All @@ -34,7 +35,7 @@
particleMaxEta = cms.double(5.), # HF range. Maximum 6.0 on MiniAOD

lepConeSize = cms.double(0.1), # for photon dressing
lepMinPt = cms.double(15.),
lepMinPt = cms.double(1.),
lepMaxEta = cms.double(2.5),

jetConeSize = cms.double(0.4),
Expand All @@ -47,7 +48,7 @@

phoIsoConeSize = cms.double(0.4),
phoMaxRelIso = cms.double(0.5),
phoMinPt = cms.double(10),
phoMinPt = cms.double(1.),
phoMaxEta = cms.double(2.5),
)

Expand All @@ -61,7 +62,7 @@
##################### Tables for final output and docs ##########################
rivetLeptonTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
src = cms.InputTag("particleLevel:leptons"),
cut = cms.string(""),
cut = cms.string("pt > 15"),
name= cms.string("GenDressedLepton"),
doc = cms.string("Dressed leptons from Rivet-based ParticleLevelProducer"),
singleton = cms.bool(False), # the number of entries is variable
Expand All @@ -77,7 +78,7 @@

rivetPhotonTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
src = cms.InputTag("particleLevel:photons"),
cut = cms.string(""),
cut = cms.string("pt > 10"),
name= cms.string("GenIsolatedPhoton"),
doc = cms.string("Isolated photons from Rivet-based ParticleLevelProducer"),
singleton = cms.bool(False), # the number of entries is variable
Expand Down

0 comments on commit 5d82080

Please sign in to comment.