From 680cb1f40064b0938aaaa6c0a9e81892b6140c56 Mon Sep 17 00:00:00 2001 From: AdrianoDee Date: Fri, 16 Jul 2021 12:49:49 +0200 Subject: [PATCH] Moving to emplace & reserving size --- .../plugins/LUTPackedCandidatesProducer.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/PhysicsTools/PatUtils/plugins/LUTPackedCandidatesProducer.cc b/PhysicsTools/PatUtils/plugins/LUTPackedCandidatesProducer.cc index 12e8e94b531e2..c2daa934cd24f 100644 --- a/PhysicsTools/PatUtils/plugins/LUTPackedCandidatesProducer.cc +++ b/PhysicsTools/PatUtils/plugins/LUTPackedCandidatesProducer.cc @@ -21,7 +21,7 @@ class LUTPackedCandidatesProducer : public edm::global::EDProducer<> { private: const edm::EDGetTokenT inputCandidates_; - + edm::EDPutTokenT outputCandidates_; const unsigned int covSchema_; const unsigned int covVersion_; const unsigned int nHits_; @@ -36,7 +36,8 @@ LUTPackedCandidatesProducer::LUTPackedCandidatesProducer(const edm::ParameterSet covVersion_(iConfig.getParameter("covVersion")), nHits_(iConfig.getParameter("nHits")), nPixelHits_(iConfig.getParameter("nPixelHits")) { - produces(""); + + outputCandidates_ = produces(""); } LUTPackedCandidatesProducer::~LUTPackedCandidatesProducer() {} @@ -45,17 +46,17 @@ void LUTPackedCandidatesProducer::produce(edm::StreamID, edm::Event &iEvent, con edm::Handle packedCandidates; iEvent.getByToken(inputCandidates_, packedCandidates); - auto output = std::make_unique(); - + pat::PackedCandidateCollection output; + output.reserve(packedCandidates->size()); for (unsigned int ic = 0, nc = packedCandidates->size(); ic < nc; ++ic) { const pat::PackedCandidate &cand = (*packedCandidates)[ic]; - output->push_back(pat::PackedCandidate(cand)); + output.push_back(pat::PackedCandidate(cand)); - if (!output->back().hasTrackDetails() && output->back().covarianceVersion() == int(covVersion_)) - output->back().setTrackPropertiesLite(covSchema_, covVersion_, nHits_, nPixelHits_); + if (!output.back().hasTrackDetails() && output.back().covarianceVersion() == int(covVersion_)) + output.back().setTrackPropertiesLite(covSchema_, covVersion_, nHits_, nPixelHits_); } - iEvent.put(std::move(output)); + iEvent.emplace(outputCandidates_,std::move(output)); }; void LUTPackedCandidatesProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {