From 16ea729e6fd56161b7d445dd689a691878e6c7f3 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Thu, 28 Mar 2024 15:58:15 -0500 Subject: [PATCH 1/3] Explicit setting of lazy parsing in SimpleFlatTableProducer The T0 had a failure from the string parser which we have previously attributed to using the lazy option of the string parser. Added option to turn on lazy parsing from the configuration. This is an 'opt' in since lazy parsing can be problematic so best to explicitly state it must be used. --- .../interface/SimpleFlatTableProducer.h | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h b/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h index a544f4b484d56..b93ace3c45387 100644 --- a/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h +++ b/PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h @@ -47,9 +47,9 @@ class FuncVariable : public Variable { public: FuncVariable(const std::string &aname, const edm::ParameterSet &cfg) : Variable(aname, cfg), - func_(cfg.getParameter("expr"), true), + func_(cfg.getParameter("expr"), cfg.getUntrackedParameter("lazyEval")), precisionFunc_(cfg.existsAs("precision") ? cfg.getParameter("precision") : "23", - true) {} + cfg.getUntrackedParameter("lazyEval")) {} ~FuncVariable() override {} void fill(std::vector &selobjs, nanoaod::FlatTable &out) const override { @@ -212,6 +212,8 @@ class SimpleFlatTableProducerBase : public edm::stream::EDProducer<> { edm::ParameterSetDescription variable; variable.add("expr")->setComment("a function to define the content of the branch in the flat table"); variable.add("doc")->setComment("few words description of the branch content"); + variable.addUntracked("lazyEval", false) + ->setComment("if true, can use methods of inheriting classes in `expr`. Can cause problems with threading."); variable.ifValue( edm::ParameterDescription( "type", "int", true, edm::Comment("the c++ type of the branch in the flat table")), @@ -271,7 +273,8 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase("singleton")), maxLen_(params.existsAs("maxLen") ? params.getParameter("maxLen") : std::numeric_limits::max()), - cut_(!singleton_ ? params.getParameter("cut") : "", true) { + cut_(!singleton_ ? params.getParameter("cut") : "", + !singleton_ ? params.getUntrackedParameter("lazyEval") : false) { if (params.existsAs("externalVariables")) { edm::ParameterSet const &extvarsPSet = params.getParameter("externalVariables"); for (const std::string &vname : extvarsPSet.getParameterNamesForType()) { @@ -312,11 +315,17 @@ class SimpleFlatTableProducer : public SimpleFlatTableProducerBase>::baseDescriptions(); - desc.ifValue(edm::ParameterDescription( - "singleton", false, true, edm::Comment("whether or not the input collection is single-element")), - false >> edm::ParameterDescription( - "cut", "", true, edm::Comment("selection on the main input collection")) or - true >> edm::EmptyGroupDescription()); + desc.ifValue( + edm::ParameterDescription( + "singleton", false, true, edm::Comment("whether or not the input collection is single-element")), + false >> (edm::ParameterDescription( + "cut", "", true, edm::Comment("selection on the main input collection")) and + edm::ParameterDescription("lazyEval", + false, + false, + edm::Comment("if true, can use methods of inheriting classes. Can " + "cause problems when multi-threading."))) or + true >> edm::EmptyGroupDescription()); desc.addOptional("maxLen")->setComment( "define the maximum length of the input collection to put in the branch"); @@ -442,6 +451,8 @@ class SimpleTypedExternalFlatTableProducer : public SimpleFlatTableProducer { extvariable.add("expr")->setComment( "a function to define the content of the branch in the flat table"); extvariable.add("doc")->setComment("few words description of the branch content"); + extvariable.addUntracked("lazyEval", false) + ->setComment("if true, can use methods of inheriting classes in `expr`. Can cause problems with threading."); extvariable.ifValue( edm::ParameterDescription( "type", "int", true, edm::Comment("the c++ type of the branch in the flat table")), @@ -482,7 +493,7 @@ class BXVectorSimpleFlatTableProducer : public SimpleFlatTableProducerBase>(params), maxLen_(params.existsAs("maxLen") ? params.getParameter("maxLen") : std::numeric_limits::max()), - cut_(params.getParameter("cut"), true), + cut_(params.getParameter("cut"), false), minBX_(params.getParameter("minBX")), maxBX_(params.getParameter("maxBX")), alwaysWriteBXValue_(params.getParameter("alwaysWriteBXValue")), From 7e564e8312b6fa998dc306e87b584019ff2568f6 Mon Sep 17 00:00:00 2001 From: Huilin Qu Date: Fri, 19 Apr 2024 02:19:59 +0200 Subject: [PATCH 2/3] Use explicit types for SimpleFlatTableProducer. --- .../SiStripCommon/plugins/SealModules.cc | 4 -- .../MuonTools/interface/MuDigiBaseProducer.h | 1 + .../interface/MuLocalRecoBaseProducer.h | 1 + DPGAnalysis/MuonTools/python/common_cff.py | 10 +-- .../MuonTools/python/nano_mu_reco_cff.py | 4 +- DataFormats/Candidate/src/classes_def.xml | 2 + .../plugins/SimpleFlatTableProducerPlugins.cc | 61 +++++++++++++++++++ .../NanoAOD/plugins/VertexTableProducer.cc | 7 +-- .../NanoAOD/python/boostedTaus_cff.py | 4 +- PhysicsTools/NanoAOD/python/btvMC_cff.py | 6 +- PhysicsTools/NanoAOD/python/common_cff.py | 9 +-- PhysicsTools/NanoAOD/python/custom_btv_cff.py | 8 +-- PhysicsTools/NanoAOD/python/custom_jme_cff.py | 6 +- .../NanoAOD/python/custom_muon_cff.py | 12 ++-- PhysicsTools/NanoAOD/python/electrons_cff.py | 4 +- PhysicsTools/NanoAOD/python/fsrPhotons_cff.py | 4 +- .../NanoAOD/python/genparticles_cff.py | 4 +- PhysicsTools/NanoAOD/python/isotracks_cff.py | 4 +- PhysicsTools/NanoAOD/python/jetMC_cff.py | 7 ++- .../NanoAOD/python/jetsAK4_CHS_cff.py | 6 +- .../NanoAOD/python/jetsAK4_Puppi_cff.py | 6 +- PhysicsTools/NanoAOD/python/jetsAK8_cff.py | 6 +- .../python/leptonTimeLifeInfo_common_cff.py | 14 +++-- .../NanoAOD/python/lowPtElectrons_cff.py | 4 +- PhysicsTools/NanoAOD/python/met_cff.py | 30 ++++----- PhysicsTools/NanoAOD/python/muons_cff.py | 4 +- PhysicsTools/NanoAOD/python/photons_cff.py | 4 +- .../NanoAOD/python/run3scouting_cff.py | 4 +- ...SingletonCandidateFlatTableProducer_cfi.py | 4 +- PhysicsTools/NanoAOD/python/taus_cff.py | 10 +-- PhysicsTools/NanoAOD/python/vertices_cff.py | 4 +- 31 files changed, 162 insertions(+), 92 deletions(-) diff --git a/CalibTracker/SiStripCommon/plugins/SealModules.cc b/CalibTracker/SiStripCommon/plugins/SealModules.cc index 1bafc65ef6f88..275fd4b1ba83c 100644 --- a/CalibTracker/SiStripCommon/plugins/SealModules.cc +++ b/CalibTracker/SiStripCommon/plugins/SealModules.cc @@ -20,7 +20,3 @@ DEFINE_FWK_MODULE(ShallowSimhitClustersProducer); DEFINE_FWK_MODULE(ShallowTracksProducer); DEFINE_FWK_MODULE(ShallowSimTracksProducer); DEFINE_FWK_MODULE(ShallowGainCalibration); - -#include "PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h" -typedef SimpleFlatTableProducer SimpleTrackFlatTableProducer; -DEFINE_FWK_MODULE(SimpleTrackFlatTableProducer); diff --git a/DPGAnalysis/MuonTools/interface/MuDigiBaseProducer.h b/DPGAnalysis/MuonTools/interface/MuDigiBaseProducer.h index d29c71c61700c..a48de726a40b7 100644 --- a/DPGAnalysis/MuonTools/interface/MuDigiBaseProducer.h +++ b/DPGAnalysis/MuonTools/interface/MuDigiBaseProducer.h @@ -67,6 +67,7 @@ class MuDigiBaseProducer : public SimpleFlatTableProducerBase("expr")->setComment("a function to define the content of the branch in the flat table"); variable.add("doc")->setComment("few words description of the branch content"); + variable.addUntracked("lazyEval")->setComment("set to True if the type read from the Event is unknown"); variable.ifValue(edm::ParameterDescription("type", "int", true, comType), edm::allowedValues("int", "uint", "int16", "uint8")); diff --git a/DPGAnalysis/MuonTools/interface/MuLocalRecoBaseProducer.h b/DPGAnalysis/MuonTools/interface/MuLocalRecoBaseProducer.h index ba27733fc8e1f..178763252ad94 100644 --- a/DPGAnalysis/MuonTools/interface/MuLocalRecoBaseProducer.h +++ b/DPGAnalysis/MuonTools/interface/MuLocalRecoBaseProducer.h @@ -105,6 +105,7 @@ class MuRecObjBaseProducer varBase.add("expr")->setComment("a function to define the content of the branch in the flat table"); varBase.add("doc")->setComment("few words description of the branch content"); + varBase.addUntracked("lazyEval")->setComment("if True, check object type during Event processing."); return varBase; }; diff --git a/DPGAnalysis/MuonTools/python/common_cff.py b/DPGAnalysis/MuonTools/python/common_cff.py index b217515add89c..56634c4e8fd07 100644 --- a/DPGAnalysis/MuonTools/python/common_cff.py +++ b/DPGAnalysis/MuonTools/python/common_cff.py @@ -10,7 +10,7 @@ class DEFAULT_VAL(NamedTuple): defaults = DEFAULT_VAL() -def DetIdVar(expr, type, doc=None): +def DetIdVar(expr, type, doc=None, lazyEval=False): """ Create a PSet for a DetId variable in the tree: - expr is the expression to evaluate to compute the variable, - type of the value (int, bool, or a string that the table producer understands), @@ -22,10 +22,11 @@ def DetIdVar(expr, type, doc=None): return cms.PSet( type = cms.string(type), expr = cms.string(expr), - doc = cms.string(doc if doc else expr) + doc = cms.string(doc if doc else expr), + lazyEval = cms.untracked.bool(lazyEval) ) -def GlobGeomVar(expr, doc=None, precision=-1): +def GlobGeomVar(expr, doc=None, precision=-1, lazyEval=False): """ Create a PSet for a Global position/direction variable in the tree , - expr is the expression to evaluate to compute the variable, - doc is a docstring, that will be passed to the table producer, @@ -34,7 +35,8 @@ def GlobGeomVar(expr, doc=None, precision=-1): return cms.PSet( expr = cms.string(expr), doc = cms.string(doc if doc else expr), - precision=cms.string(precision) if type(precision)==str else cms.int32(precision) + precision = cms.string(precision) if type(precision)==str else cms.int32(precision), + lazyEval = cms.untracked.bool(lazyEval) ) diff --git a/DPGAnalysis/MuonTools/python/nano_mu_reco_cff.py b/DPGAnalysis/MuonTools/python/nano_mu_reco_cff.py index d32ab9dcf79fc..ecae5844bd050 100644 --- a/DPGAnalysis/MuonTools/python/nano_mu_reco_cff.py +++ b/DPGAnalysis/MuonTools/python/nano_mu_reco_cff.py @@ -3,11 +3,11 @@ from PhysicsTools.NanoAOD.common_cff import * from DPGAnalysis.MuonTools.common_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATMuonFlatTableProducer_cfi import simplePATMuonFlatTableProducer from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi import * -muonFlatTableProducer = simpleCandidateFlatTableProducer.clone( +muonFlatTableProducer = simplePATMuonFlatTableProducer.clone( src = cms.InputTag("patMuons"), name = cms.string("muon"), doc = cms.string("RECO muon information"), diff --git a/DataFormats/Candidate/src/classes_def.xml b/DataFormats/Candidate/src/classes_def.xml index 707dd454ff758..8b40654e3589f 100644 --- a/DataFormats/Candidate/src/classes_def.xml +++ b/DataFormats/Candidate/src/classes_def.xml @@ -254,6 +254,8 @@ + + diff --git a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc index 8217d13f32bab..10ffe15e96956 100644 --- a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc +++ b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc @@ -3,6 +3,45 @@ #include "DataFormats/Candidate/interface/Candidate.h" typedef SimpleFlatTableProducer SimpleCandidateFlatTableProducer; +#include "DataFormats/TrackReco/interface/Track.h" +typedef SimpleFlatTableProducer SimpleTrackFlatTableProducer; + +#include "DataFormats/JetReco/interface/PFJet.h" +typedef SimpleFlatTableProducer SimplePFJetFlatTableProducer; + +#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h" +typedef SimpleFlatTableProducer SimpleSecondaryVertexFlatTableProducer; + +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" +typedef SimpleFlatTableProducer SimpleGenParticleFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/Electron.h" +typedef SimpleFlatTableProducer SimplePATElectronFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/Muon.h" +typedef SimpleFlatTableProducer SimplePATMuonFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/Tau.h" +typedef SimpleFlatTableProducer SimplePATTauFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/Photon.h" +typedef SimpleFlatTableProducer SimplePATPhotonFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/Jet.h" +typedef SimpleFlatTableProducer SimplePATJetFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/IsolatedTrack.h" +typedef SimpleFlatTableProducer SimplePATIsolatedTrackFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/GenericParticle.h" +typedef SimpleFlatTableProducer SimplePATGenericParticleFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" +typedef SimpleFlatTableProducer SimplePATCandidateFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/MET.h" +typedef SimpleFlatTableProducer SimplePATMETFlatTableProducer; + typedef SimpleTypedExternalFlatTableProducer SimpleCandidate2CandidateFlatTableProducer; @@ -66,9 +105,28 @@ typedef SimpleFlatTableProducer SimpleVertexFlatTableProducer; #include "DataFormats/VertexReco/interface/TrackTimeLifeInfo.h" typedef SimpleTypedExternalFlatTableProducer SimpleCandidate2TrackTimeLifeInfoFlatTableProducer; +typedef SimpleTypedExternalFlatTableProducer + SimplePATElectron2TrackTimeLifeInfoFlatTableProducer; +typedef SimpleTypedExternalFlatTableProducer + SimplePATMuon2TrackTimeLifeInfoFlatTableProducer; +typedef SimpleTypedExternalFlatTableProducer + SimplePATTau2TrackTimeLifeInfoFlatTableProducer; #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(SimpleCandidateFlatTableProducer); +DEFINE_FWK_MODULE(SimpleTrackFlatTableProducer); +DEFINE_FWK_MODULE(SimplePFJetFlatTableProducer); +DEFINE_FWK_MODULE(SimpleSecondaryVertexFlatTableProducer); +DEFINE_FWK_MODULE(SimpleGenParticleFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATElectronFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATMuonFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATTauFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATPhotonFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATJetFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATIsolatedTrackFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATGenericParticleFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATCandidateFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATMETFlatTableProducer); DEFINE_FWK_MODULE(SimpleCandidate2CandidateFlatTableProducer); DEFINE_FWK_MODULE(SimpleGenEventFlatTableProducer); DEFINE_FWK_MODULE(SimpleGenFilterFlatTableProducerLumi); @@ -90,3 +148,6 @@ DEFINE_FWK_MODULE(SimpleRun3ScoutingElectronFlatTableProducer); DEFINE_FWK_MODULE(SimpleRun3ScoutingTrackFlatTableProducer); DEFINE_FWK_MODULE(SimpleVertexFlatTableProducer); DEFINE_FWK_MODULE(SimpleCandidate2TrackTimeLifeInfoFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATElectron2TrackTimeLifeInfoFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATMuon2TrackTimeLifeInfoFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATTau2TrackTimeLifeInfoFlatTableProducer); diff --git a/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc b/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc index 224c21d828b55..c72846d83cc96 100644 --- a/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc +++ b/PhysicsTools/NanoAOD/plugins/VertexTableProducer.cc @@ -93,7 +93,7 @@ VertexTableProducer::VertexTableProducer(const edm::ParameterSet& params) produces("pv"); produces("otherPVs"); produces("svs"); - produces>(); + produces>(); } // @@ -167,7 +167,7 @@ void VertexTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe otherPVsTable->addColumn("score", pvscores, "scores of other primary vertices, excluding the main PV", 8); const auto& svsProd = iEvent.get(svs_); - auto selCandSv = std::make_unique>(); + auto selCandSv = std::make_unique>(); std::vector dlen, dlenSig, pAngle, dxy, dxySig; std::vector charge; VertexDistance3D vdist; @@ -182,8 +182,7 @@ void VertexTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe if (dl.value() > dlenMin_ and dl.significance() > dlenSigMin_) { dlen.push_back(dl.value()); dlenSig.push_back(dl.significance()); - edm::Ptr c = svsProd.ptrAt(i); - selCandSv->push_back(c); + selCandSv->push_back(svsProd.ptrAt(i)); double dx = (PV0.x() - sv.vx()), dy = (PV0.y() - sv.vy()), dz = (PV0.z() - sv.vz()); double pdotv = (dx * sv.px() + dy * sv.py() + dz * sv.pz()) / sv.p() / sqrt(dx * dx + dy * dy + dz * dz); pAngle.push_back(std::acos(pdotv)); diff --git a/PhysicsTools/NanoAOD/python/boostedTaus_cff.py b/PhysicsTools/NanoAOD/python/boostedTaus_cff.py index a620e6265ac08..10c382ac13855 100644 --- a/PhysicsTools/NanoAOD/python/boostedTaus_cff.py +++ b/PhysicsTools/NanoAOD/python/boostedTaus_cff.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * from PhysicsTools.NanoAOD.nano_eras_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATTauFlatTableProducer_cfi import simplePATTauFlatTableProducer ##################### Import reusable funtions and objects from std taus ######## from PhysicsTools.NanoAOD.taus_cff import _tauIdWPMask, tausMCMatchLepTauForTable, tausMCMatchHadTauForTable,tauMCTable @@ -18,7 +18,7 @@ cut = "pt > 40 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2DBoldDMdR0p3wLT') || tauID('byVVLooseIsolationMVArun2DBnewDMwLT'))" ) -boostedTauTable = simpleCandidateFlatTableProducer.clone( +boostedTauTable = simplePATTauFlatTableProducer.clone( src = cms.InputTag("linkedObjects", "boostedTaus"), name= cms.string("boostedTau"), doc = cms.string("slimmedBoostedTaus after basic selection (" + finalBoostedTaus.cut.value()+")"), diff --git a/PhysicsTools/NanoAOD/python/btvMC_cff.py b/PhysicsTools/NanoAOD/python/btvMC_cff.py index 0a72694f96112..a45b213daa199 100644 --- a/PhysicsTools/NanoAOD/python/btvMC_cff.py +++ b/PhysicsTools/NanoAOD/python/btvMC_cff.py @@ -14,7 +14,7 @@ ] btvGenTable = cms.EDProducer( - "SimpleCandidateFlatTableProducer", + "SimpleGenParticleFlatTableProducer", src=finalGenParticles.src, name= cms.string("GenPart"), doc = cms.string("interesting gen particles "), @@ -31,7 +31,7 @@ btvMCTable = cms.EDProducer("BTVMCFlavourTableProducer",name=jetPuppiTable.name,src=cms.InputTag("linkedObjects","jets"),genparticles=cms.InputTag("prunedGenParticles")) btvAK4JetExtTable = cms.EDProducer( - "SimpleCandidateFlatTableProducer", + "SimplePATJetFlatTableProducer", src=jetPuppiTable.src, cut=jetPuppiTable.cut, name=jetPuppiTable.name, @@ -48,7 +48,7 @@ )) btvSubJetMCExtTable = cms.EDProducer( - "SimpleCandidateFlatTableProducer", + "SimplePATJetFlatTableProducer", src = subJetTable.src, cut = subJetTable.cut, name = subJetTable.name, diff --git a/PhysicsTools/NanoAOD/python/common_cff.py b/PhysicsTools/NanoAOD/python/common_cff.py index 54f09cfb15d24..9eb34ff556e2a 100644 --- a/PhysicsTools/NanoAOD/python/common_cff.py +++ b/PhysicsTools/NanoAOD/python/common_cff.py @@ -11,9 +11,10 @@ def OVar(valtype, doc=None, precision=-1): return cms.PSet( type = cms.string(valtype), doc = cms.string(doc if doc else expr), - precision=cms.optional.allowed(cms.string, cms.int32, default = (cms.string(precision) if type(precision)==str else cms.int32(precision) - ))) -def Var(expr, valtype, doc=None, precision=-1): + precision=cms.optional.allowed(cms.string, cms.int32, default = (cms.string(precision) if type(precision)==str else cms.int32(precision))) + ) + +def Var(expr, valtype, doc=None, precision=-1, lazyEval=False): """Create a PSet for a variable computed with the string parser expr is the expression to evaluate to compute the variable @@ -22,7 +23,7 @@ def Var(expr, valtype, doc=None, precision=-1): see OVar above for all the other arguments """ return OVar(valtype, doc=(doc if doc else expr), precision=precision).clone( - expr = cms.string(expr)) + expr = cms.string(expr), lazyEval=cms.untracked.bool(lazyEval)) def ExtVar(tag, valtype, doc=None, precision=-1): """Create a PSet for a variable read from the event diff --git a/PhysicsTools/NanoAOD/python/custom_btv_cff.py b/PhysicsTools/NanoAOD/python/custom_btv_cff.py index e446c6d5492c2..2b74d70fffd2c 100644 --- a/PhysicsTools/NanoAOD/python/custom_btv_cff.py +++ b/PhysicsTools/NanoAOD/python/custom_btv_cff.py @@ -483,7 +483,7 @@ def add_BTV(process, addAK4=False, addAK8=False, scheme="btvSF"): process = update_jets_AK4(process) process.customJetExtTable = cms.EDProducer( - "SimpleCandidateFlatTableProducer", + "SimplePATJetFlatTableProducer", src=jetPuppiTable.src, cut=jetPuppiTable.cut, name=jetPuppiTable.name, @@ -523,7 +523,7 @@ def add_BTV(process, addAK4=False, addAK8=False, scheme="btvSF"): process = update_jets_AK8(process) process = update_jets_AK8_subjet(process) process.customFatJetExtTable = cms.EDProducer( - "SimpleCandidateFlatTableProducer", + "SimplePATJetFlatTableProducer", src=fatJetTable.src, cut=fatJetTable.cut, name=fatJetTable.name, @@ -539,7 +539,7 @@ def add_BTV(process, addAK4=False, addAK8=False, scheme="btvSF"): # Subjets process.customSubJetExtTable = cms.EDProducer( - "SimpleCandidateFlatTableProducer", + "SimplePATJetFlatTableProducer", src=subJetTable.src, cut=subJetTable.cut, name=subJetTable.name, @@ -588,7 +588,7 @@ def addPFCands(process, allPF = False, addAK4=False, addAK8=False): process.finalJetsConstituentsTable = cms.EDProducer("PackedCandidatePtrMerger", src = candList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True)) candInput = cms.InputTag("finalJetsConstituentsTable") - process.customConstituentsExtTable = cms.EDProducer("SimpleCandidateFlatTableProducer", + process.customConstituentsExtTable = cms.EDProducer("SimplePATCandidateFlatTableProducer", src = candInput, cut = cms.string(""), #we should not filter after pruning name = cms.string("PFCands"), diff --git a/PhysicsTools/NanoAOD/python/custom_jme_cff.py b/PhysicsTools/NanoAOD/python/custom_jme_cff.py index 5c5b3422d698e..765b58a848a1a 100644 --- a/PhysicsTools/NanoAOD/python/custom_jme_cff.py +++ b/PhysicsTools/NanoAOD/python/custom_jme_cff.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.nano_eras_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATJetFlatTableProducer_cfi import simplePATJetFlatTableProducer from RecoJets.JetProducers.hfJetShowerShape_cfi import hfJetShowerShape from RecoJets.JetProducers.PileupJetID_cfi import pileupJetIdCalculator, pileupJetId @@ -570,7 +570,7 @@ def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTabl jetTableDocDefault = jetTableDoc jetTableName = "jet{}Table".format(jetName) - setattr(proc,jetTableName, simpleCandidateFlatTableProducer.clone( + setattr(proc,jetTableName, simplePATJetFlatTableProducer.clone( src = cms.InputTag(finalJetsForTable), cut = cms.string(jetTableCutDefault), name = cms.string(jetTablePrefix), @@ -585,7 +585,7 @@ def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTabl # Save MC-only jet variables in table # jetMCTableName = "jet{}MCTable".format(jetName) - setattr(proc, jetMCTableName, simpleCandidateFlatTableProducer.clone( + setattr(proc, jetMCTableName, simplePATJetFlatTableProducer.clone( src = cms.InputTag(finalJetsForTable), cut = getattr(proc,jetTableName).cut, name = cms.string(jetTablePrefix), diff --git a/PhysicsTools/NanoAOD/python/custom_muon_cff.py b/PhysicsTools/NanoAOD/python/custom_muon_cff.py index 71959b9799d18..0e8817be105b8 100644 --- a/PhysicsTools/NanoAOD/python/custom_muon_cff.py +++ b/PhysicsTools/NanoAOD/python/custom_muon_cff.py @@ -1,11 +1,9 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.nano_eras_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer -from PhysicsTools.NanoAOD.common_cff import Var, P3Vars, P4Vars -from PhysicsTools.NanoAOD.muons_cff import muonTable, finalMuons -from PhysicsTools.NanoAOD.triggerObjects_cff import triggerObjectTable, mksel +from PhysicsTools.NanoAOD.common_cff import Var, P3Vars +from PhysicsTools.NanoAOD.triggerObjects_cff import mksel def Custom_Muon_Task(process): process.nanoTableTaskCommon.remove(process.electronTablesTask) @@ -258,9 +256,9 @@ def AddVariablesForMuon(proc): proc.muonTable.variables.innerTrackExtraIdx = Var('? innerTrack().isNonnull() ? innerTrack().extra().key() : -99', 'int', precision=-1, doc='Index of the innerTrack TrackExtra in the original collection') #Jet Related Variables - proc.muonTable.variables.jetPtRatio = Var("?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1.0/(1.0+(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))/pt)", float, doc="ptRatio using the LepAware JEC approach, for muon MVA") - proc.muonTable.variables.jetDF = Var("?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probbb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:problepb'),0.0):0.0",float,doc="b-tagging discriminator of the jet matched to the lepton, for muon MVA") - proc.muonTable.variables.jetCSVv2 = Var("?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfCombinedSecondaryVertexV2BJetTags'),0.0):0.0",float,doc="CSVv2 b-tagging discriminator of the jet matched to the lepton, for muon MVA") + proc.muonTable.variables.jetPtRatio = Var("?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1.0/(1.0+(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))/pt)", float, doc="ptRatio using the LepAware JEC approach, for muon MVA", lazyEval=True) + proc.muonTable.variables.jetDF = Var("?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probbb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:problepb'),0.0):0.0",float,doc="b-tagging discriminator of the jet matched to the lepton, for muon MVA", lazyEval=True) + proc.muonTable.variables.jetCSVv2 = Var("?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfCombinedSecondaryVertexV2BJetTags'),0.0):0.0",float,doc="CSVv2 b-tagging discriminator of the jet matched to the lepton, for muon MVA", lazyEval=True) #nSegments diff --git a/PhysicsTools/NanoAOD/python/electrons_cff.py b/PhysicsTools/NanoAOD/python/electrons_cff.py index 66c090d1e7ef5..84e8f9251f961 100644 --- a/PhysicsTools/NanoAOD/python/electrons_cff.py +++ b/PhysicsTools/NanoAOD/python/electrons_cff.py @@ -1,5 +1,5 @@ import FWCore.ParameterSet.Config as cms -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATElectronFlatTableProducer_cfi import simplePATElectronFlatTableProducer from PhysicsTools.NanoAOD.nano_eras_cff import * from PhysicsTools.NanoAOD.common_cff import * from math import ceil,log @@ -292,7 +292,7 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints): ################################################electronPROMPTMVA end##################### ################################################electronTable defn ##################### -electronTable = simpleCandidateFlatTableProducer.clone( +electronTable = simplePATElectronFlatTableProducer.clone( src = cms.InputTag("linkedObjects","electrons"), name= cms.string("Electron"), doc = cms.string("slimmedElectrons after basic selection (" + finalElectrons.cut.value()+")"), diff --git a/PhysicsTools/NanoAOD/python/fsrPhotons_cff.py b/PhysicsTools/NanoAOD/python/fsrPhotons_cff.py index dc30306db1dbd..f3f4425548478 100644 --- a/PhysicsTools/NanoAOD/python/fsrPhotons_cff.py +++ b/PhysicsTools/NanoAOD/python/fsrPhotons_cff.py @@ -1,6 +1,6 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATGenericParticleFlatTableProducer_cfi import simplePATGenericParticleFlatTableProducer from CommonTools.RecoUtils.leptonFSRProducer_cfi import leptonFSRProducer leptonFSRphotons = leptonFSRProducer.clone( @@ -10,7 +10,7 @@ electrons = "linkedObjects:electrons", ) -fsrTable = simpleCandidateFlatTableProducer.clone( +fsrTable = simplePATGenericParticleFlatTableProducer.clone( src = cms.InputTag("leptonFSRphotons"), name = cms.string("FsrPhoton"), doc = cms.string("Final state radiation photons emitted by muons or electrons"), diff --git a/PhysicsTools/NanoAOD/python/genparticles_cff.py b/PhysicsTools/NanoAOD/python/genparticles_cff.py index 33e09275d7c97..747bf2d542250 100644 --- a/PhysicsTools/NanoAOD/python/genparticles_cff.py +++ b/PhysicsTools/NanoAOD/python/genparticles_cff.py @@ -1,6 +1,6 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simpleGenParticleFlatTableProducer_cfi import simpleGenParticleFlatTableProducer ##################### User floats producers, selectors ########################## @@ -29,7 +29,7 @@ ##################### Tables for final output and docs ########################## -genParticleTable = simpleCandidateFlatTableProducer.clone( +genParticleTable = simpleGenParticleFlatTableProducer.clone( src = cms.InputTag("finalGenParticles"), name= cms.string("GenPart"), doc = cms.string("interesting gen particles "), diff --git a/PhysicsTools/NanoAOD/python/isotracks_cff.py b/PhysicsTools/NanoAOD/python/isotracks_cff.py index f043527fcca76..ac6a10e79e962 100644 --- a/PhysicsTools/NanoAOD/python/isotracks_cff.py +++ b/PhysicsTools/NanoAOD/python/isotracks_cff.py @@ -1,6 +1,6 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATIsolatedTrackFlatTableProducer_cfi import simplePATIsolatedTrackFlatTableProducer finalIsolatedTracks = cms.EDProducer("IsolatedTrackCleaner", tracks = cms.InputTag("isolatedTracks"), @@ -23,7 +23,7 @@ lostTracks = cms.InputTag("lostTracks"), ) -isoTrackTable = simpleCandidateFlatTableProducer.clone( +isoTrackTable = simplePATIsolatedTrackFlatTableProducer.clone( src = cms.InputTag("finalIsolatedTracks"), name = cms.string("IsoTrack"), doc = cms.string("isolated tracks after basic selection (" + finalIsolatedTracks.cut.value() + ") and lepton veto"), diff --git a/PhysicsTools/NanoAOD/python/jetMC_cff.py b/PhysicsTools/NanoAOD/python/jetMC_cff.py index 2c2cc3d1ac253..4e57a5e7c176d 100644 --- a/PhysicsTools/NanoAOD/python/jetMC_cff.py +++ b/PhysicsTools/NanoAOD/python/jetMC_cff.py @@ -2,10 +2,11 @@ from PhysicsTools.NanoAOD.common_cff import * from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATJetFlatTableProducer_cfi import simplePATJetFlatTableProducer from PhysicsTools.NanoAOD.jetsAK8_cff import fatJetTable as _fatJetTable from PhysicsTools.NanoAOD.jetsAK8_cff import subJetTable as _subJetTable -jetMCTable = simpleCandidateFlatTableProducer.clone( +jetMCTable = simplePATJetFlatTableProducer.clone( src = cms.InputTag("linkedObjects","jets"), name = cms.string("Jet"), extension = cms.bool(True), # this is an extension table for the jets @@ -82,7 +83,7 @@ deltaR = cms.double(0.1), jetFlavourInfos = cms.InputTag("genJetAK8FlavourAssociation"), ) -fatJetMCTable = simpleCandidateFlatTableProducer.clone( +fatJetMCTable = simplePATJetFlatTableProducer.clone( src = _fatJetTable.src, cut = _fatJetTable.cut, name = _fatJetTable.name, @@ -102,7 +103,7 @@ #anything else? ) ) -subjetMCTable = simpleCandidateFlatTableProducer.clone( +subjetMCTable = simplePATJetFlatTableProducer.clone( src = _subJetTable.src, cut = _subJetTable.cut, name = _subJetTable.name, diff --git a/PhysicsTools/NanoAOD/python/jetsAK4_CHS_cff.py b/PhysicsTools/NanoAOD/python/jetsAK4_CHS_cff.py index bf5ddf48e5cfc..bb463da41b6ef 100644 --- a/PhysicsTools/NanoAOD/python/jetsAK4_CHS_cff.py +++ b/PhysicsTools/NanoAOD/python/jetsAK4_CHS_cff.py @@ -2,7 +2,7 @@ from PhysicsTools.NanoAOD.nano_eras_cff import * from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATJetFlatTableProducer_cfi import simplePATJetFlatTableProducer ##################### User floats producers, selectors ########################## @@ -113,7 +113,7 @@ ##################### Tables for final output and docs ########################## -jetTable = simpleCandidateFlatTableProducer.clone( +jetTable = simplePATJetFlatTableProducer.clone( src = cms.InputTag("linkedObjects","jets"), name = cms.string("Jet"), doc = cms.string("slimmedJets, i.e. ak4 PFJets CHS with JECs applied, after basic selection (" + finalJets.cut.value()+")"), @@ -522,7 +522,7 @@ def nanoAOD_refineFastSim_bTagDeepFlav(process): updatedJetsWithUserData.userFloats.muonSubtrRawPt = cms.InputTag("basicJetsForMetForT1METNano:MuonSubtrRawPt") -corrT1METJetTable = simpleCandidateFlatTableProducer.clone( +corrT1METJetTable = simplePATJetFlatTableProducer.clone( src = finalJets.src, cut = cms.string("pt<15 && abs(eta)<9.9"), name = cms.string("CorrT1METJet"), diff --git a/PhysicsTools/NanoAOD/python/jetsAK4_Puppi_cff.py b/PhysicsTools/NanoAOD/python/jetsAK4_Puppi_cff.py index 0cdccb02a2d85..2c7dcdae72b31 100644 --- a/PhysicsTools/NanoAOD/python/jetsAK4_Puppi_cff.py +++ b/PhysicsTools/NanoAOD/python/jetsAK4_Puppi_cff.py @@ -2,7 +2,7 @@ from PhysicsTools.NanoAOD.common_cff import * from PhysicsTools.NanoAOD.nano_eras_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATJetFlatTableProducer_cfi import simplePATJetFlatTableProducer ##################### User floats producers, selectors ########################## @@ -83,7 +83,7 @@ ) ##################### Tables for final output and docs ########################## -jetPuppiTable = simpleCandidateFlatTableProducer.clone( +jetPuppiTable = simplePATJetFlatTableProducer.clone( src = cms.InputTag("linkedObjects","jets"), name = cms.string("Jet"), doc = cms.string("slimmedJetsPuppi, i.e. ak4 PFJets Puppi with JECs applied, after basic selection (" + finalJetsPuppi.cut.value()+")"), @@ -233,7 +233,7 @@ def nanoAOD_addDeepInfoAK4(process,addParticleNet,addRobustParTAK4=False,addUnif updatedJetsPuppiWithUserData.userFloats.muonSubtrRawPt = cms.InputTag("basicJetsPuppiForMetForT1METNano:MuonSubtrRawPt") -corrT1METJetPuppiTable = simpleCandidateFlatTableProducer.clone( +corrT1METJetPuppiTable = simplePATJetFlatTableProducer.clone( src = finalJetsPuppi.src, cut = cms.string("pt<15 && abs(eta)<9.9"), name = cms.string("CorrT1METJet"), diff --git a/PhysicsTools/NanoAOD/python/jetsAK8_cff.py b/PhysicsTools/NanoAOD/python/jetsAK8_cff.py index f0dffc1ddcdf8..33a68208d9e3d 100644 --- a/PhysicsTools/NanoAOD/python/jetsAK8_cff.py +++ b/PhysicsTools/NanoAOD/python/jetsAK8_cff.py @@ -2,7 +2,7 @@ from PhysicsTools.NanoAOD.nano_eras_cff import * from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATJetFlatTableProducer_cfi import simplePATJetFlatTableProducer from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import * # Note: Safe to always add 'L2L3Residual' as MC contains dummy L2L3Residual corrections (always set to 1) @@ -87,7 +87,7 @@ srcMu = cms.InputTag("finalMuons") ) -fatJetTable = simpleCandidateFlatTableProducer.clone( +fatJetTable = simplePATJetFlatTableProducer.clone( src = cms.InputTag("finalJetsAK8"), cut = cms.string(" pt > 170"), #probably already applied in miniaod name = cms.string("FatJet"), @@ -284,7 +284,7 @@ def nanoAOD_addDeepInfoAK8(process, addDeepBTag, addDeepBoostedJet, addDeepDoubl ## DeepInfoAK8:End ################################################# -subJetTable = simpleCandidateFlatTableProducer.clone( +subJetTable = simplePATJetFlatTableProducer.clone( src = cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked","SubJets"), name = cms.string("SubJet"), doc = cms.string("slimmedJetsAK8PFPuppiSoftDropPacked::SubJets, i.e. soft-drop subjets for ak8 fat jets for boosted analysis"), diff --git a/PhysicsTools/NanoAOD/python/leptonTimeLifeInfo_common_cff.py b/PhysicsTools/NanoAOD/python/leptonTimeLifeInfo_common_cff.py index 1c9c6aa3dbd29..e73f6e2750d9d 100644 --- a/PhysicsTools/NanoAOD/python/leptonTimeLifeInfo_common_cff.py +++ b/PhysicsTools/NanoAOD/python/leptonTimeLifeInfo_common_cff.py @@ -10,7 +10,9 @@ from PhysicsTools.PatAlgos.patElectronTimeLifeInfoProducer_cfi import patElectronTimeLifeInfoProducer from PhysicsTools.PatAlgos.patMuonTimeLifeInfoProducer_cfi import patMuonTimeLifeInfoProducer from PhysicsTools.PatAlgos.patTauTimeLifeInfoProducer_cfi import patTauTimeLifeInfoProducer -from PhysicsTools.NanoAOD.simpleCandidate2TrackTimeLifeInfoFlatTableProducer_cfi import simpleCandidate2TrackTimeLifeInfoFlatTableProducer +from PhysicsTools.NanoAOD.simplePATElectron2TrackTimeLifeInfoFlatTableProducer_cfi import simplePATElectron2TrackTimeLifeInfoFlatTableProducer +from PhysicsTools.NanoAOD.simplePATMuon2TrackTimeLifeInfoFlatTableProducer_cfi import simplePATMuon2TrackTimeLifeInfoFlatTableProducer +from PhysicsTools.NanoAOD.simplePATTau2TrackTimeLifeInfoFlatTableProducer_cfi import simplePATTau2TrackTimeLifeInfoFlatTableProducer from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import * from PhysicsTools.NanoAOD.nanoDQM_tools_cff import * @@ -22,7 +24,7 @@ # impact parameter ipVars = cms.PSet( - #ipLength = Var("ipLength().value()", float, doc="lenght of impact parameter (3d)", precision=10),#MB: redundant + #ipLength = Var("ipLength().value()", float, doc="lenght of impact parameter (3d)", precision=10), ipLengthSig = Var("ipLength().significance()", float, doc="significance of impact parameter", precision=10), IPx = Var("ipVector().x()", float, doc="x coordinate of impact parameter vector", precision=10), IPy = Var("ipVector().y()", float, doc="y coordinate of impact parameter vector", precision=10), @@ -53,7 +55,7 @@ refitSVy = Var("?hasSV()?sv().y():0", float, doc="y coordinate of SV", precision=10), refitSVz = Var("?hasSV()?sv().z():0", float, doc="z coordinate of SV", precision=10), refitSVchi2 = Var("?hasSV()?sv().normalizedChi2():0", float, doc="reduced chi2, i.e. chi2/ndof, of SV fit", precision=8), - #refitSVndof = Var("?hasSV()?sv().ndof():0", float, doc="ndof of SV fit", precision=8),#MB: not important + #refitSVndof = Var("?hasSV()?sv().ndof():0", float, doc="ndof of SV fit", precision=8), # flight-length #refitFlightLength = Var("?hasSV()?flightLength().value():0", float, doc="flight-length,i.e. the PV to SV distance", precision=10), #refitFlightLengthSig = Var("?hasSV()?flightLength().significance():0", float, doc="Significance of flight-length", precision=10) @@ -122,7 +124,7 @@ def addElectronTimeLifeInfoTask(process): pvSource = prod_common.pvSource, pvChoice = prod_common.pvChoice ) - process.electronTimeLifeInfoTable = simpleCandidate2TrackTimeLifeInfoFlatTableProducer.clone( + process.electronTimeLifeInfoTable = simplePATElectron2TrackTimeLifeInfoFlatTableProducer.clone( name = process.electronTable.name, src = process.electronTable.src, doc = cms.string("Additional time-life info for non-prompt electrons"), @@ -187,7 +189,7 @@ def addMuonTimeLifeInfoTask(process): pvSource = prod_common.pvSource, pvChoice = prod_common.pvChoice ) - process.muonTimeLifeInfoTable = simpleCandidate2TrackTimeLifeInfoFlatTableProducer.clone( + process.muonTimeLifeInfoTable = simplePATMuon2TrackTimeLifeInfoFlatTableProducer.clone( name = process.muonTable.name, src = process.muonTable.src, doc = cms.string("Additional time-life info for non-prompt muon"), @@ -251,7 +253,7 @@ def addTauTimeLifeInfoTask(process): pvSource = prod_common.pvSource, pvChoice = prod_common.pvChoice ) - process.tauTimeLifeInfoTable = simpleCandidate2TrackTimeLifeInfoFlatTableProducer.clone( + process.tauTimeLifeInfoTable = simplePATTau2TrackTimeLifeInfoFlatTableProducer.clone( name = process.tauTable.name, src = process.tauTable.src, doc = cms.string("Additional tau time-life info"), diff --git a/PhysicsTools/NanoAOD/python/lowPtElectrons_cff.py b/PhysicsTools/NanoAOD/python/lowPtElectrons_cff.py index 76d72f5e8410d..f7bb17b29e6f7 100644 --- a/PhysicsTools/NanoAOD/python/lowPtElectrons_cff.py +++ b/PhysicsTools/NanoAOD/python/lowPtElectrons_cff.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.nano_eras_cff import * from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATElectronFlatTableProducer_cfi import simplePATElectronFlatTableProducer ################################################################################ # Modules @@ -60,7 +60,7 @@ # electronTable ################################################################################ -lowPtElectronTable = simpleCandidateFlatTableProducer.clone( +lowPtElectronTable = simplePATElectronFlatTableProducer.clone( src = cms.InputTag("linkedObjects","lowPtElectrons"), name= cms.string("LowPtElectron"), doc = cms.string("slimmedLowPtElectrons after basic selection (" + finalLowPtElectrons.cut.value()+")"), diff --git a/PhysicsTools/NanoAOD/python/met_cff.py b/PhysicsTools/NanoAOD/python/met_cff.py index c93ebbbf24214..65aa36807fe9d 100644 --- a/PhysicsTools/NanoAOD/python/met_cff.py +++ b/PhysicsTools/NanoAOD/python/met_cff.py @@ -1,14 +1,19 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.simpleSingletonCandidateFlatTableProducer_cfi import simpleSingletonCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATMETFlatTableProducer_cfi import simplePATMETFlatTableProducer + +simpleSingletonPATMETFlatTableProducer = simplePATMETFlatTableProducer.clone( + singleton = cms.bool(True), + cut = None, + lazyEval = None +) ##################### Tables for final output and docs ########################## -pfmetTable = simpleSingletonCandidateFlatTableProducer.clone( +pfmetTable = simpleSingletonPATMETFlatTableProducer.clone( src = cms.InputTag("slimmedMETs"), name = cms.string("PFMET"), doc = cms.string("slimmedMET, type-1 corrected PF MET"), variables = cms.PSet(PTVars, - covXX = Var("getSignificanceMatrix().At(0,0)",float,doc="xx element of met covariance matrix", precision=8), covXY = Var("getSignificanceMatrix().At(0,1)",float,doc="xy element of met covariance matrix", precision=8), covYY = Var("getSignificanceMatrix().At(1,1)",float,doc="yy element of met covariance matrix", precision=8), @@ -19,12 +24,11 @@ ptUnclusteredDown = Var("shiftedPt('UnclusteredEnDown')", float, doc="Unclustered down pt",precision=10), phiUnclusteredUp = Var("shiftedPhi('UnclusteredEnUp')", float, doc="Unclustered up phi",precision=10), phiUnclusteredDown = Var("shiftedPhi('UnclusteredEnDown')", float, doc="Unclustered down phi",precision=10), - ), ) -rawMetTable = simpleSingletonCandidateFlatTableProducer.clone( +rawMetTable = simpleSingletonPATMETFlatTableProducer.clone( src = pfmetTable.src, name = cms.string("RawPFMET"), doc = cms.string("raw PF MET"), @@ -36,7 +40,7 @@ ) -caloMetTable = simpleSingletonCandidateFlatTableProducer.clone( +caloMetTable = simpleSingletonPATMETFlatTableProducer.clone( src = pfmetTable.src, name = cms.string("CaloMET"), doc = cms.string("Offline CaloMET (muon corrected)"), @@ -47,7 +51,7 @@ ), ) -puppiMetTable = simpleSingletonCandidateFlatTableProducer.clone( +puppiMetTable = simpleSingletonPATMETFlatTableProducer.clone( src = cms.InputTag("slimmedMETsPuppi"), name = cms.string("PuppiMET"), doc = cms.string("PUPPI MET"), @@ -62,11 +66,10 @@ ptUnclusteredDown = Var("shiftedPt('UnclusteredEnDown')", float, doc="Unclustered down pt",precision=10), phiUnclusteredUp = Var("shiftedPhi('UnclusteredEnUp')", float, doc="Unclustered up phi",precision=10), phiUnclusteredDown = Var("shiftedPhi('UnclusteredEnDown')", float, doc="Unclustered down phi",precision=10), - ), ) -rawPuppiMetTable = simpleSingletonCandidateFlatTableProducer.clone( +rawPuppiMetTable = simpleSingletonPATMETFlatTableProducer.clone( src = puppiMetTable.src, name = cms.string("RawPuppiMET"), doc = cms.string("raw Puppi MET"), @@ -77,7 +80,7 @@ ),) -trkMetTable = simpleSingletonCandidateFlatTableProducer.clone( +trkMetTable = simpleSingletonPATMETFlatTableProducer.clone( src = pfmetTable.src, name = cms.string("TrkMET"), doc = cms.string("Track MET computed with tracks from PV0 ( pvAssociationQuality()>=4 ) "), @@ -88,8 +91,7 @@ ), ) - -deepMetResolutionTuneTable = simpleSingletonCandidateFlatTableProducer.clone( +deepMetResolutionTuneTable = simpleSingletonPATMETFlatTableProducer.clone( # current deepMets are saved in slimmedMETs in MiniAOD, # in the same way as chsMet/TrkMET src = pfmetTable.src, @@ -101,7 +103,7 @@ ), ) -deepMetResponseTuneTable = simpleSingletonCandidateFlatTableProducer.clone( +deepMetResponseTuneTable = simpleSingletonPATMETFlatTableProducer.clone( src = pfmetTable.src, name = cms.string("DeepMETResponseTune"), doc = cms.string("Deep MET trained with extra response tune"), @@ -111,7 +113,7 @@ ), ) -metMCTable = simpleSingletonCandidateFlatTableProducer.clone( +metMCTable = simpleSingletonPATMETFlatTableProducer.clone( src = pfmetTable.src, name = cms.string("GenMET"), doc = cms.string("Gen MET"), diff --git a/PhysicsTools/NanoAOD/python/muons_cff.py b/PhysicsTools/NanoAOD/python/muons_cff.py index daaef7d6ba0ff..cc393da93fcbe 100644 --- a/PhysicsTools/NanoAOD/python/muons_cff.py +++ b/PhysicsTools/NanoAOD/python/muons_cff.py @@ -2,7 +2,7 @@ from PhysicsTools.NanoAOD.nano_eras_cff import * from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATMuonFlatTableProducer_cfi import simplePATMuonFlatTableProducer import PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi @@ -150,7 +150,7 @@ src = cms.InputTag("linkedObjects","muons"), ) -muonTable = simpleCandidateFlatTableProducer.clone( +muonTable = simplePATMuonFlatTableProducer.clone( src = cms.InputTag("linkedObjects","muons"), name = cms.string("Muon"), doc = cms.string("slimmedMuons after basic selection (" + finalMuons.cut.value()+")"), diff --git a/PhysicsTools/NanoAOD/python/photons_cff.py b/PhysicsTools/NanoAOD/python/photons_cff.py index 1ef45717476fd..bd5235ff08056 100644 --- a/PhysicsTools/NanoAOD/python/photons_cff.py +++ b/PhysicsTools/NanoAOD/python/photons_cff.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.nano_eras_cff import * from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simplePATPhotonFlatTableProducer_cfi import simplePATPhotonFlatTableProducer from math import ceil,log @@ -184,7 +184,7 @@ def make_bitmapVID_docstring(id_modules_working_points_pset): cut = cms.string("pt > 5 ") ) -photonTable = simpleCandidateFlatTableProducer.clone( +photonTable = simplePATPhotonFlatTableProducer.clone( src = cms.InputTag("linkedObjects","photons"), name= cms.string("Photon"), doc = cms.string("slimmedPhotons after basic selection (" + finalPhotons.cut.value()+")"), diff --git a/PhysicsTools/NanoAOD/python/run3scouting_cff.py b/PhysicsTools/NanoAOD/python/run3scouting_cff.py index dc3ae77147bf0..2f3ec743c9e69 100644 --- a/PhysicsTools/NanoAOD/python/run3scouting_cff.py +++ b/PhysicsTools/NanoAOD/python/run3scouting_cff.py @@ -306,7 +306,7 @@ debugMode = cms.untracked.bool(False), ) -ak4ScoutingJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer", +ak4ScoutingJetTable = cms.EDProducer("SimplePFJetFlatTableProducer", src = cms.InputTag("ak4ScoutingJets"), name = cms.string("ScoutingJet"), cut = cms.string(""), @@ -443,7 +443,7 @@ debugMode = cms.untracked.bool(False), ) -ak8ScoutingJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer", +ak8ScoutingJetTable = cms.EDProducer("SimplePFJetFlatTableProducer", src = cms.InputTag("ak8ScoutingJets"), name = cms.string("ScoutingFatJet"), cut = cms.string(""), diff --git a/PhysicsTools/NanoAOD/python/simpleSingletonCandidateFlatTableProducer_cfi.py b/PhysicsTools/NanoAOD/python/simpleSingletonCandidateFlatTableProducer_cfi.py index 831646f936793..7cc0ce30f1146 100644 --- a/PhysicsTools/NanoAOD/python/simpleSingletonCandidateFlatTableProducer_cfi.py +++ b/PhysicsTools/NanoAOD/python/simpleSingletonCandidateFlatTableProducer_cfi.py @@ -4,5 +4,7 @@ simpleSingletonCandidateFlatTableProducer = default.clone( singleton = cms.bool(True), + cut = None, + lazyEval = None ) -del simpleSingletonCandidateFlatTableProducer.cut + diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index d5073f244c34e..93c04305c89bc 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -2,6 +2,8 @@ from PhysicsTools.NanoAOD.common_cff import * from PhysicsTools.NanoAOD.nano_eras_cff import run3_nanoAOD_124 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simpleGenParticleFlatTableProducer_cfi import simpleGenParticleFlatTableProducer +from PhysicsTools.NanoAOD.simplePATTauFlatTableProducer_cfi import simplePATTauFlatTableProducer from PhysicsTools.JetMCAlgos.TauGenJets_cfi import tauGenJets from PhysicsTools.JetMCAlgos.TauGenJetsDecayModeSelectorAllHadrons_cfi import tauGenJetsSelectorAllHadrons @@ -45,7 +47,7 @@ def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None): return Var(var_definition, "uint8", doc=doc) -tauTable = simpleCandidateFlatTableProducer.clone( +tauTable = simplePATTauFlatTableProducer.clone( src = cms.InputTag("linkedObjects","taus"), name= cms.string("Tau"), doc = cms.string("slimmedTaus after basic selection (" + finalTaus.cut.value()+")") @@ -66,8 +68,8 @@ def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None): leadTkDeltaEta = Var("?leadChargedHadrCand.isNonnull()?(leadChargedHadrCand.eta - eta):0",float, doc="eta of the leading track, minus tau eta",precision=8), leadTkDeltaPhi = Var("?leadChargedHadrCand.isNonnull()?deltaPhi(leadChargedHadrCand.phi, phi):0",float, doc="phi of the leading track, minus tau phi",precision=8), - dxy = Var("?leadChargedHadrCand.isNonnull()?leadChargedHadrCand().dxy():0",float, doc="d_{xy} of lead track with respect to PV, in cm (with sign)",precision=10), - dz = Var("?leadChargedHadrCand.isNonnull()?leadChargedHadrCand().dz():0",float, doc="d_{z} of lead track with respect to PV, in cm (with sign)",precision=14), + dxy = Var("?leadChargedHadrCand.isNonnull()?leadChargedHadrCand().dxy():0",float, doc="d_{xy} of lead track with respect to PV, in cm (with sign)",precision=10, lazyEval=True), + dz = Var("?leadChargedHadrCand.isNonnull()?leadChargedHadrCand().dz():0",float, doc="d_{z} of lead track with respect to PV, in cm (with sign)",precision=14, lazyEval=True), # these are too many, we may have to suppress some rawIso = Var("?isTauIDAvailable('byCombinedIsolationDeltaBetaCorrRaw3Hits')?tauID('byCombinedIsolationDeltaBetaCorrRaw3Hits'):-1", float, doc = "combined isolation (deltaBeta corrections)", precision=10), @@ -197,7 +199,7 @@ def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None): srcGenParticles = cms.InputTag("finalGenParticles") ) -genVisTauTable = simpleCandidateFlatTableProducer.clone( +genVisTauTable = simpleGenParticleFlatTableProducer.clone( src = cms.InputTag("genVisTaus"), cut = cms.string("pt > 10."), name = cms.string("GenVisTau"), diff --git a/PhysicsTools/NanoAOD/python/vertices_cff.py b/PhysicsTools/NanoAOD/python/vertices_cff.py index 69d105795d25d..536ec1ea04fb5 100644 --- a/PhysicsTools/NanoAOD/python/vertices_cff.py +++ b/PhysicsTools/NanoAOD/python/vertices_cff.py @@ -1,6 +1,6 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * -from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer +from PhysicsTools.NanoAOD.simpleSecondaryVertexFlatTableProducer_cfi import simpleSecondaryVertexFlatTableProducer ##################### User floats producers, selectors ########################## @@ -20,7 +20,7 @@ svDoc = cms.string("secondary vertices from IVF algorithm"), ) -svCandidateTable = simpleCandidateFlatTableProducer.clone( +svCandidateTable = simpleSecondaryVertexFlatTableProducer.clone( src = cms.InputTag("vertexTable"), name = cms.string("SV"), extension = cms.bool(True), From e4328e708aee8c36d5b0426f45906b9b1b91f52e Mon Sep 17 00:00:00 2001 From: Huilin Qu Date: Tue, 23 Apr 2024 00:09:59 +0200 Subject: [PATCH 3/3] Split plugins into multiple files. --- .../plugins/SimpleFlatTableProducerPlugins.cc | 98 +------------------ .../SimpleL1TFlatTableProducerPlugins.cc | 24 +++++ .../SimplePATFlatTableProducerPlugins.cc | 50 ++++++++++ .../SimpleScoutingFlatTableProducerPlugins.cc | 23 +++++ .../NanoAOD/python/custom_muon_cff.py | 2 +- PhysicsTools/NanoAOD/python/taus_cff.py | 1 + 6 files changed, 103 insertions(+), 95 deletions(-) create mode 100644 PhysicsTools/NanoAOD/plugins/SimpleL1TFlatTableProducerPlugins.cc create mode 100644 PhysicsTools/NanoAOD/plugins/SimplePATFlatTableProducerPlugins.cc create mode 100644 PhysicsTools/NanoAOD/plugins/SimpleScoutingFlatTableProducerPlugins.cc diff --git a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc index 10ffe15e96956..53fc6f16ee47e 100644 --- a/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc +++ b/PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc @@ -9,39 +9,15 @@ typedef SimpleFlatTableProducer SimpleTrackFlatTableProducer; #include "DataFormats/JetReco/interface/PFJet.h" typedef SimpleFlatTableProducer SimplePFJetFlatTableProducer; +#include "DataFormats/VertexReco/interface/Vertex.h" +typedef SimpleFlatTableProducer SimpleVertexFlatTableProducer; + #include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h" typedef SimpleFlatTableProducer SimpleSecondaryVertexFlatTableProducer; #include "DataFormats/HepMCCandidate/interface/GenParticle.h" typedef SimpleFlatTableProducer SimpleGenParticleFlatTableProducer; -#include "DataFormats/PatCandidates/interface/Electron.h" -typedef SimpleFlatTableProducer SimplePATElectronFlatTableProducer; - -#include "DataFormats/PatCandidates/interface/Muon.h" -typedef SimpleFlatTableProducer SimplePATMuonFlatTableProducer; - -#include "DataFormats/PatCandidates/interface/Tau.h" -typedef SimpleFlatTableProducer SimplePATTauFlatTableProducer; - -#include "DataFormats/PatCandidates/interface/Photon.h" -typedef SimpleFlatTableProducer SimplePATPhotonFlatTableProducer; - -#include "DataFormats/PatCandidates/interface/Jet.h" -typedef SimpleFlatTableProducer SimplePATJetFlatTableProducer; - -#include "DataFormats/PatCandidates/interface/IsolatedTrack.h" -typedef SimpleFlatTableProducer SimplePATIsolatedTrackFlatTableProducer; - -#include "DataFormats/PatCandidates/interface/GenericParticle.h" -typedef SimpleFlatTableProducer SimplePATGenericParticleFlatTableProducer; - -#include "DataFormats/PatCandidates/interface/PackedCandidate.h" -typedef SimpleFlatTableProducer SimplePATCandidateFlatTableProducer; - -#include "DataFormats/PatCandidates/interface/MET.h" -typedef SimpleFlatTableProducer SimplePATMETFlatTableProducer; - typedef SimpleTypedExternalFlatTableProducer SimpleCandidate2CandidateFlatTableProducer; @@ -69,64 +45,13 @@ typedef EventSingletonSimpleFlatTableProducer SimpleOnli #include "DataFormats/BeamSpot/interface/BeamSpot.h" typedef EventSingletonSimpleFlatTableProducer SimpleBeamspotFlatTableProducer; -#include "DataFormats/L1Trigger/interface/EGamma.h" -typedef BXVectorSimpleFlatTableProducer SimpleTriggerL1EGFlatTableProducer; - -#include "DataFormats/L1Trigger/interface/Jet.h" -typedef BXVectorSimpleFlatTableProducer SimpleTriggerL1JetFlatTableProducer; - -#include "DataFormats/L1Trigger/interface/Tau.h" -typedef BXVectorSimpleFlatTableProducer SimpleTriggerL1TauFlatTableProducer; - -#include "DataFormats/L1Trigger/interface/Muon.h" -typedef BXVectorSimpleFlatTableProducer SimpleTriggerL1MuonFlatTableProducer; - -#include "DataFormats/L1Trigger/interface/EtSum.h" -typedef BXVectorSimpleFlatTableProducer SimpleTriggerL1EtSumFlatTableProducer; - -#include "DataFormats/Scouting/interface/Run3ScoutingVertex.h" -typedef SimpleFlatTableProducer SimpleRun3ScoutingVertexFlatTableProducer; - -#include "DataFormats/Scouting/interface/Run3ScoutingPhoton.h" -typedef SimpleFlatTableProducer SimpleRun3ScoutingPhotonFlatTableProducer; - -#include "DataFormats/Scouting/interface/Run3ScoutingMuon.h" -typedef SimpleFlatTableProducer SimpleRun3ScoutingMuonFlatTableProducer; - -#include "DataFormats/Scouting/interface/Run3ScoutingElectron.h" -typedef SimpleFlatTableProducer SimpleRun3ScoutingElectronFlatTableProducer; - -#include "DataFormats/Scouting/interface/Run3ScoutingTrack.h" -typedef SimpleFlatTableProducer SimpleRun3ScoutingTrackFlatTableProducer; - -#include "DataFormats/VertexReco/interface/Vertex.h" -typedef SimpleFlatTableProducer SimpleVertexFlatTableProducer; - -#include "DataFormats/VertexReco/interface/TrackTimeLifeInfo.h" -typedef SimpleTypedExternalFlatTableProducer - SimpleCandidate2TrackTimeLifeInfoFlatTableProducer; -typedef SimpleTypedExternalFlatTableProducer - SimplePATElectron2TrackTimeLifeInfoFlatTableProducer; -typedef SimpleTypedExternalFlatTableProducer - SimplePATMuon2TrackTimeLifeInfoFlatTableProducer; -typedef SimpleTypedExternalFlatTableProducer - SimplePATTau2TrackTimeLifeInfoFlatTableProducer; - #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(SimpleCandidateFlatTableProducer); DEFINE_FWK_MODULE(SimpleTrackFlatTableProducer); DEFINE_FWK_MODULE(SimplePFJetFlatTableProducer); +DEFINE_FWK_MODULE(SimpleVertexFlatTableProducer); DEFINE_FWK_MODULE(SimpleSecondaryVertexFlatTableProducer); DEFINE_FWK_MODULE(SimpleGenParticleFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATElectronFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATMuonFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATTauFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATPhotonFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATJetFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATIsolatedTrackFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATGenericParticleFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATCandidateFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATMETFlatTableProducer); DEFINE_FWK_MODULE(SimpleCandidate2CandidateFlatTableProducer); DEFINE_FWK_MODULE(SimpleGenEventFlatTableProducer); DEFINE_FWK_MODULE(SimpleGenFilterFlatTableProducerLumi); @@ -136,18 +61,3 @@ DEFINE_FWK_MODULE(SimpleLocalTrackFlatTableProducer); DEFINE_FWK_MODULE(SimpleXYZPointFlatTableProducer); DEFINE_FWK_MODULE(SimpleOnlineLuminosityFlatTableProducer); DEFINE_FWK_MODULE(SimpleBeamspotFlatTableProducer); -DEFINE_FWK_MODULE(SimpleTriggerL1EGFlatTableProducer); -DEFINE_FWK_MODULE(SimpleTriggerL1JetFlatTableProducer); -DEFINE_FWK_MODULE(SimpleTriggerL1MuonFlatTableProducer); -DEFINE_FWK_MODULE(SimpleTriggerL1TauFlatTableProducer); -DEFINE_FWK_MODULE(SimpleTriggerL1EtSumFlatTableProducer); -DEFINE_FWK_MODULE(SimpleRun3ScoutingVertexFlatTableProducer); -DEFINE_FWK_MODULE(SimpleRun3ScoutingPhotonFlatTableProducer); -DEFINE_FWK_MODULE(SimpleRun3ScoutingMuonFlatTableProducer); -DEFINE_FWK_MODULE(SimpleRun3ScoutingElectronFlatTableProducer); -DEFINE_FWK_MODULE(SimpleRun3ScoutingTrackFlatTableProducer); -DEFINE_FWK_MODULE(SimpleVertexFlatTableProducer); -DEFINE_FWK_MODULE(SimpleCandidate2TrackTimeLifeInfoFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATElectron2TrackTimeLifeInfoFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATMuon2TrackTimeLifeInfoFlatTableProducer); -DEFINE_FWK_MODULE(SimplePATTau2TrackTimeLifeInfoFlatTableProducer); diff --git a/PhysicsTools/NanoAOD/plugins/SimpleL1TFlatTableProducerPlugins.cc b/PhysicsTools/NanoAOD/plugins/SimpleL1TFlatTableProducerPlugins.cc new file mode 100644 index 0000000000000..75009161f6e6c --- /dev/null +++ b/PhysicsTools/NanoAOD/plugins/SimpleL1TFlatTableProducerPlugins.cc @@ -0,0 +1,24 @@ +#include "PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h" + +#include "DataFormats/L1Trigger/interface/EGamma.h" +typedef BXVectorSimpleFlatTableProducer SimpleTriggerL1EGFlatTableProducer; + +#include "DataFormats/L1Trigger/interface/Jet.h" +typedef BXVectorSimpleFlatTableProducer SimpleTriggerL1JetFlatTableProducer; + +#include "DataFormats/L1Trigger/interface/Tau.h" +typedef BXVectorSimpleFlatTableProducer SimpleTriggerL1TauFlatTableProducer; + +#include "DataFormats/L1Trigger/interface/Muon.h" +typedef BXVectorSimpleFlatTableProducer SimpleTriggerL1MuonFlatTableProducer; + +#include "DataFormats/L1Trigger/interface/EtSum.h" +typedef BXVectorSimpleFlatTableProducer SimpleTriggerL1EtSumFlatTableProducer; + +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_FWK_MODULE(SimpleTriggerL1EGFlatTableProducer); +DEFINE_FWK_MODULE(SimpleTriggerL1JetFlatTableProducer); +DEFINE_FWK_MODULE(SimpleTriggerL1MuonFlatTableProducer); +DEFINE_FWK_MODULE(SimpleTriggerL1TauFlatTableProducer); +DEFINE_FWK_MODULE(SimpleTriggerL1EtSumFlatTableProducer); diff --git a/PhysicsTools/NanoAOD/plugins/SimplePATFlatTableProducerPlugins.cc b/PhysicsTools/NanoAOD/plugins/SimplePATFlatTableProducerPlugins.cc new file mode 100644 index 0000000000000..921163486de77 --- /dev/null +++ b/PhysicsTools/NanoAOD/plugins/SimplePATFlatTableProducerPlugins.cc @@ -0,0 +1,50 @@ +#include "PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h" + +#include "DataFormats/PatCandidates/interface/Electron.h" +typedef SimpleFlatTableProducer SimplePATElectronFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/Muon.h" +typedef SimpleFlatTableProducer SimplePATMuonFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/Tau.h" +typedef SimpleFlatTableProducer SimplePATTauFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/Photon.h" +typedef SimpleFlatTableProducer SimplePATPhotonFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/Jet.h" +typedef SimpleFlatTableProducer SimplePATJetFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/IsolatedTrack.h" +typedef SimpleFlatTableProducer SimplePATIsolatedTrackFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/GenericParticle.h" +typedef SimpleFlatTableProducer SimplePATGenericParticleFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" +typedef SimpleFlatTableProducer SimplePATCandidateFlatTableProducer; + +#include "DataFormats/PatCandidates/interface/MET.h" +typedef SimpleFlatTableProducer SimplePATMETFlatTableProducer; + +#include "DataFormats/VertexReco/interface/TrackTimeLifeInfo.h" +typedef SimpleTypedExternalFlatTableProducer + SimplePATElectron2TrackTimeLifeInfoFlatTableProducer; +typedef SimpleTypedExternalFlatTableProducer + SimplePATMuon2TrackTimeLifeInfoFlatTableProducer; +typedef SimpleTypedExternalFlatTableProducer + SimplePATTau2TrackTimeLifeInfoFlatTableProducer; + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SimplePATElectronFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATMuonFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATTauFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATPhotonFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATJetFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATIsolatedTrackFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATGenericParticleFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATCandidateFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATMETFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATElectron2TrackTimeLifeInfoFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATMuon2TrackTimeLifeInfoFlatTableProducer); +DEFINE_FWK_MODULE(SimplePATTau2TrackTimeLifeInfoFlatTableProducer); diff --git a/PhysicsTools/NanoAOD/plugins/SimpleScoutingFlatTableProducerPlugins.cc b/PhysicsTools/NanoAOD/plugins/SimpleScoutingFlatTableProducerPlugins.cc new file mode 100644 index 0000000000000..9f586eda01ed9 --- /dev/null +++ b/PhysicsTools/NanoAOD/plugins/SimpleScoutingFlatTableProducerPlugins.cc @@ -0,0 +1,23 @@ +#include "PhysicsTools/NanoAOD/interface/SimpleFlatTableProducer.h" + +#include "DataFormats/Scouting/interface/Run3ScoutingVertex.h" +typedef SimpleFlatTableProducer SimpleRun3ScoutingVertexFlatTableProducer; + +#include "DataFormats/Scouting/interface/Run3ScoutingPhoton.h" +typedef SimpleFlatTableProducer SimpleRun3ScoutingPhotonFlatTableProducer; + +#include "DataFormats/Scouting/interface/Run3ScoutingMuon.h" +typedef SimpleFlatTableProducer SimpleRun3ScoutingMuonFlatTableProducer; + +#include "DataFormats/Scouting/interface/Run3ScoutingElectron.h" +typedef SimpleFlatTableProducer SimpleRun3ScoutingElectronFlatTableProducer; + +#include "DataFormats/Scouting/interface/Run3ScoutingTrack.h" +typedef SimpleFlatTableProducer SimpleRun3ScoutingTrackFlatTableProducer; + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SimpleRun3ScoutingVertexFlatTableProducer); +DEFINE_FWK_MODULE(SimpleRun3ScoutingPhotonFlatTableProducer); +DEFINE_FWK_MODULE(SimpleRun3ScoutingMuonFlatTableProducer); +DEFINE_FWK_MODULE(SimpleRun3ScoutingElectronFlatTableProducer); +DEFINE_FWK_MODULE(SimpleRun3ScoutingTrackFlatTableProducer); diff --git a/PhysicsTools/NanoAOD/python/custom_muon_cff.py b/PhysicsTools/NanoAOD/python/custom_muon_cff.py index 0e8817be105b8..cf4f5d82a5a42 100644 --- a/PhysicsTools/NanoAOD/python/custom_muon_cff.py +++ b/PhysicsTools/NanoAOD/python/custom_muon_cff.py @@ -256,10 +256,10 @@ def AddVariablesForMuon(proc): proc.muonTable.variables.innerTrackExtraIdx = Var('? innerTrack().isNonnull() ? innerTrack().extra().key() : -99', 'int', precision=-1, doc='Index of the innerTrack TrackExtra in the original collection') #Jet Related Variables + # lazyEval=True: userCand() returns the base type `reco::CandidatePtr`, needs to be dynamically casted to pat::Jet to call the userFloat() / bDiscriminator() methods proc.muonTable.variables.jetPtRatio = Var("?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1.0/(1.0+(pfIsolationR04().sumChargedHadronPt + max(pfIsolationR04().sumNeutralHadronEt + pfIsolationR04().sumPhotonEt - pfIsolationR04().sumPUPt/2,0.0))/pt)", float, doc="ptRatio using the LepAware JEC approach, for muon MVA", lazyEval=True) proc.muonTable.variables.jetDF = Var("?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probbb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:problepb'),0.0):0.0",float,doc="b-tagging discriminator of the jet matched to the lepton, for muon MVA", lazyEval=True) proc.muonTable.variables.jetCSVv2 = Var("?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfCombinedSecondaryVertexV2BJetTags'),0.0):0.0",float,doc="CSVv2 b-tagging discriminator of the jet matched to the lepton, for muon MVA", lazyEval=True) - #nSegments proc.muonTable.variables.nsegments = Var("userInt('nsegments')", int, doc = "nsegments as of Spark-tool") diff --git a/PhysicsTools/NanoAOD/python/taus_cff.py b/PhysicsTools/NanoAOD/python/taus_cff.py index 93c04305c89bc..bfd2349f5e360 100644 --- a/PhysicsTools/NanoAOD/python/taus_cff.py +++ b/PhysicsTools/NanoAOD/python/taus_cff.py @@ -68,6 +68,7 @@ def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None): leadTkDeltaEta = Var("?leadChargedHadrCand.isNonnull()?(leadChargedHadrCand.eta - eta):0",float, doc="eta of the leading track, minus tau eta",precision=8), leadTkDeltaPhi = Var("?leadChargedHadrCand.isNonnull()?deltaPhi(leadChargedHadrCand.phi, phi):0",float, doc="phi of the leading track, minus tau phi",precision=8), + # lazyEval=True: leadChargedHadrCand() returns the base type `reco::CandidatePtr`, needs to be dynamically casted to PackedCandidate to call dxy() / dz() dxy = Var("?leadChargedHadrCand.isNonnull()?leadChargedHadrCand().dxy():0",float, doc="d_{xy} of lead track with respect to PV, in cm (with sign)",precision=10, lazyEval=True), dz = Var("?leadChargedHadrCand.isNonnull()?leadChargedHadrCand().dz():0",float, doc="d_{z} of lead track with respect to PV, in cm (with sign)",precision=14, lazyEval=True),