Skip to content

Commit

Permalink
Merge pull request cms-sw#26 from gpetruc/L1PF_10_6_1p2_X-fastHisto
Browse files Browse the repository at this point in the history
Switch to L1PF to FastHisto
  • Loading branch information
gpetruc authored Oct 25, 2019
2 parents 5fa3ec0 + 2ca42ee commit 556e171
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
34 changes: 26 additions & 8 deletions L1Trigger/Phase2L1ParticleFlow/plugins/L1TPFProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -47,6 +48,7 @@ class L1TPFProducer : public edm::stream::EDProducer<> {
unsigned trkMinStubs_;
l1tpf_impl::PUAlgoBase::VertexAlgo vtxAlgo_;
edm::EDGetTokenT<std::vector<l1t::Vertex>> extVtx_;
edm::EDGetTokenT<std::vector<l1t::L1TkPrimaryVertex>> extTkVtx_;

edm::EDGetTokenT<l1t::MuonBxCollection> muCands_; // standalone muons
edm::EDGetTokenT<l1t::L1TkMuonParticleCollection> tkMuCands_; // tk muons
Expand Down Expand Up @@ -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<std::vector<l1t::Vertex>>(iConfig.getParameter<edm::InputTag>("vtxCollection"));
const std::string & vtxFormat = iConfig.getParameter<std::string>("vtxFormat");
if (vtxFormat == "Vertex") {
extVtx_ = consumes<std::vector<l1t::Vertex>>(iConfig.getParameter<edm::InputTag>("vtxCollection"));
} else if (vtxFormat == "L1TkPrimaryVertex") {
extTkVtx_ = consumes<std::vector<l1t::L1TkPrimaryVertex>>(iConfig.getParameter<edm::InputTag>("vtxCollection"));
} else throw cms::Exception("Configuration") << "Unsupported vtxFormat " << vtxFormat << "\n";
} else throw cms::Exception("Configuration") << "Unsupported vtxAlgo " << vtxAlgo << "\n";


Expand Down Expand Up @@ -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<std::vector<l1t::Vertex>> 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<std::vector<l1t::Vertex>> 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<std::vector<l1t::L1TkPrimaryVertex>> 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<float>(z0), "z0");
Expand Down
9 changes: 6 additions & 3 deletions L1Trigger/Phase2L1ParticleFlow/python/l1ParticleFlow_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 556e171

Please sign in to comment.