Skip to content

Commit 6bcf8af

Browse files
authored
Merge pull request cms-sw#42675 from missirol/devel_hltFilterLabel
make `trigger::TriggerEvent::filterLabel` return `std::string_view`
2 parents 9d18c84 + dc1a1a7 commit 6bcf8af

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Calibration/HcalAlCaRecoProducers/plugins/AlCaHcalIsotrkProducer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,10 @@ void AlCaHcalIsotrkProducer::produce(edm::Event& iEvent, edm::EventSetup const&
654654
//loop over all trigger filters in event (i.e. filters passed)
655655
for (unsigned int ifilter = 0; ifilter < triggerEvent.sizeFilters(); ++ifilter) {
656656
std::vector<int> Keys;
657-
std::string label = triggerEvent.filterTag(ifilter).label();
657+
auto const label = triggerEvent.filterLabel(ifilter);
658658
//loop over keys to objects passing this filter
659659
for (unsigned int imodule = 0; imodule < moduleLabels.size(); imodule++) {
660-
if (label.find(moduleLabels[imodule]) != std::string::npos) {
660+
if (label.find(moduleLabels[imodule]) != label.npos) {
661661
#ifdef EDM_ML_DEBUG
662662
if (debug_)
663663
edm::LogVerbatim("HcalIsoTrack") << "FilterName " << label;

DataFormats/HLTReco/interface/TriggerEvent.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "FWCore/Utilities/interface/InputTag.h"
1717
#include "DataFormats/Common/interface/traits.h"
1818
#include <string>
19+
#include <string_view>
1920
#include <vector>
2021
#include <cassert>
2122

@@ -109,10 +110,10 @@ namespace trigger {
109110
return edm::InputTag(triggerFilters_.at(index).filterTag_);
110111
}
111112
const std::string& filterTagEncoded(trigger::size_type index) const { return triggerFilters_.at(index).filterTag_; }
112-
std::string filterLabel(trigger::size_type index) const {
113-
const std::string& tag = triggerFilters_.at(index).filterTag_;
114-
std::string::size_type idx = tag.find(':');
115-
return (idx == std::string::npos ? tag : tag.substr(0, idx));
113+
std::string_view filterLabel(trigger::size_type index) const {
114+
std::string_view tag = triggerFilters_.at(index).filterTag_;
115+
auto const idx = tag.find(':');
116+
return (idx == tag.npos ? tag : tag.substr(0, idx));
116117
}
117118
const Vids& filterIds(trigger::size_type index) const { return triggerFilters_.at(index).filterIds_; }
118119
const Keys& filterKeys(trigger::size_type index) const { return triggerFilters_.at(index).filterKeys_; }

PhysicsTools/PatAlgos/plugins/PATTriggerProducer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ void PATTriggerProducer::produce(Event& iEvent, const EventSetup& iSetup) {
743743
auto triggerFilters = std::make_unique<TriggerFilterCollection>();
744744
triggerFilters->reserve(sizeFilters);
745745
for (size_t iF = 0; iF < sizeFilters; ++iF) {
746-
const std::string nameFilter(handleTriggerEvent->filterTag(iF).label());
746+
const std::string nameFilter(handleTriggerEvent->filterLabel(iF));
747747
const trigger::Keys& keys = handleTriggerEvent->filterKeys(iF); // not cached
748748
const trigger::Vids& types = handleTriggerEvent->filterIds(iF); // not cached
749749
TriggerFilter triggerFilter(nameFilter);

0 commit comments

Comments
 (0)