From 2ca42eedcb324c4b26914a78065ece74df707edc Mon Sep 17 00:00:00 2001 From: Giovanni Date: Wed, 23 Oct 2019 17:16:38 +0200 Subject: [PATCH] Switch to FastHisto --- .../plugins/L1TPFProducer.cc | 34 ++++++++++++++----- .../python/l1ParticleFlow_cff.py | 9 +++-- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TPFProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TPFProducer.cc index ba70fdae7988a..da304a9878cfb 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TPFProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TPFProducer.cc @@ -14,6 +14,7 @@ #include "DataFormats/Common/interface/View.h" #include "DataFormats/Phase2L1ParticleFlow/interface/PFCandidate.h" #include "DataFormats/L1TVertex/interface/Vertex.h" +#include "DataFormats/L1TrackTrigger/interface/L1TkPrimaryVertex.h" #include "DataFormats/Math/interface/deltaR.h" @@ -47,6 +48,7 @@ class L1TPFProducer : public edm::stream::EDProducer<> { unsigned trkMinStubs_; l1tpf_impl::PUAlgoBase::VertexAlgo vtxAlgo_; edm::EDGetTokenT> extVtx_; + edm::EDGetTokenT> extTkVtx_; edm::EDGetTokenT muCands_; // standalone muons edm::EDGetTokenT tkMuCands_; // tk muons @@ -140,7 +142,12 @@ L1TPFProducer::L1TPFProducer(const edm::ParameterSet& iConfig): else if (vtxAlgo == "old") vtxAlgo_ = l1tpf_impl::PUAlgoBase::OldVtxAlgo; else if (vtxAlgo == "external") { vtxAlgo_ = l1tpf_impl::PUAlgoBase::ExternalVtxAlgo; - extVtx_ = consumes>(iConfig.getParameter("vtxCollection")); + const std::string & vtxFormat = iConfig.getParameter("vtxFormat"); + if (vtxFormat == "Vertex") { + extVtx_ = consumes>(iConfig.getParameter("vtxCollection")); + } else if (vtxFormat == "L1TkPrimaryVertex") { + extTkVtx_ = consumes>(iConfig.getParameter("vtxCollection")); + } else throw cms::Exception("Configuration") << "Unsupported vtxFormat " << vtxFormat << "\n"; } else throw cms::Exception("Configuration") << "Unsupported vtxAlgo " << vtxAlgo << "\n"; @@ -275,15 +282,26 @@ L1TPFProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // Then do the vertexing, and save it out float z0; if (vtxAlgo_ == l1tpf_impl::PUAlgoBase::ExternalVtxAlgo) { - edm::Handle> vtxHandle; - iEvent.getByToken(extVtx_, vtxHandle); z0 = 0; double ptsum = 0; - for (const l1t::Vertex & vtx : *vtxHandle) { - double myptsum = 0; - for (const auto & tkptr : vtx.tracks()) { myptsum += std::min(tkptr->getMomentum(4).perp(), 50.f); } - if (myptsum > ptsum) { z0 = vtx.z0(); ptsum = myptsum; } - } + if (!extVtx_.isUninitialized()) { + edm::Handle> vtxHandle; + iEvent.getByToken(extVtx_, vtxHandle); + for (const l1t::Vertex & vtx : *vtxHandle) { + double myptsum = 0; + for (const auto & tkptr : vtx.tracks()) { myptsum += std::min(tkptr->getMomentum(4).perp(), 50.f); } + if (myptsum > ptsum) { z0 = vtx.z0(); ptsum = myptsum; } + } + } else if (!extTkVtx_.isUninitialized()) { + edm::Handle> vtxHandle; + iEvent.getByToken(extTkVtx_, vtxHandle); + for (const l1t::L1TkPrimaryVertex & vtx : *vtxHandle) { + if (ptsum == 0 || vtx.getSum() > ptsum) { + z0 = vtx.getZvertex(); + ptsum = vtx.getSum(); + } + } + } else throw cms::Exception("LogicError", "Inconsistent vertex configuration"); } l1pualgo_->doVertexing(l1regions_.regions(), vtxAlgo_, z0); iEvent.put(std::make_unique(z0), "z0"); diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ParticleFlow_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ParticleFlow_cff.py index a73a42f2147e9..4b201bbc3ff1d 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ParticleFlow_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ParticleFlow_cff.py @@ -75,7 +75,8 @@ puppiDrMin = 0.07, puppiPtMax = 50., vtxAlgo = "external", - vtxCollection = cms.InputTag("VertexProducer","l1vertices"), + vtxFormat = cms.string("L1TkPrimaryVertex"), + vtxCollection = cms.InputTag("L1TkPrimaryVertex",""), # puppi tuning puAlgo = "LinearizedPuppi", puppiEtaCuts = cms.vdouble( 1.6 ), # just one bin @@ -128,7 +129,8 @@ puppiPtMax = 50., puppiUsingBareTracks = True, vtxAlgo = "external", - vtxCollection = cms.InputTag("VertexProducer","l1vertices"), + vtxFormat = cms.string("L1TkPrimaryVertex"), + vtxCollection = cms.InputTag("L1TkPrimaryVertex",""), # puppi tuning puAlgo = "LinearizedPuppi", puppiEtaCuts = cms.vdouble( 2.0, 2.4, 3.1 ), # two bins in the tracker (different pT), one outside @@ -199,7 +201,8 @@ puppiDrMin = 0.1, puppiPtMax = 100., vtxAlgo = "external", - vtxCollection = cms.InputTag("VertexProducer","l1vertices"), + vtxFormat = cms.string("L1TkPrimaryVertex"), + vtxCollection = cms.InputTag("L1TkPrimaryVertex",""), # puppi tuning puAlgo = "LinearizedPuppi", puppiEtaCuts = cms.vdouble( 5.5 ), # one bin