CMS 3D CMS Logo

TriggerNames.cc
Go to the documentation of this file.
1 
4 #include <algorithm>
5 
6 namespace {
7  struct PairSort {
8  bool operator()(std::pair<std::string_view, unsigned int> const& iLHS,
9  std::pair<std::string_view, unsigned int> const& iRHS) const {
10  return iLHS.first < iRHS.first;
11  }
12  bool operator()(std::string_view iLHS, std::pair<std::string_view, unsigned int> const& iRHS) const {
13  return iLHS < iRHS.first;
14  }
15  bool operator()(std::pair<std::string_view, unsigned int> const& iLHS, std::string_view iRHS) const {
16  return iLHS.first < iRHS;
17  }
18  };
19 } // namespace
20 namespace edm {
21 
23  : psetID_{pset.id()}, triggerNames_{pset.getParameter<Strings>("@trigger_paths")} {
24  initializeTriggerIndex();
25  }
26 
28  : psetID_{iOther.psetID_}, triggerNames_{iOther.triggerNames_} {
29  initializeTriggerIndex();
30  }
31 
33  TriggerNames temp(iOther);
34  *this = std::move(temp);
35  return *this;
36  }
37 
39  unsigned int index = 0;
40  indexMap_.reserve(triggerNames_.size());
41  for (auto const& name : triggerNames_) {
42  indexMap_.emplace_back(name, index);
43  ++index;
44  }
45  std::sort(indexMap_.begin(), indexMap_.end(), PairSort());
46  }
47 
49 
50  std::string const& TriggerNames::triggerName(unsigned int index) const { return triggerNames_.at(index); }
51 
52  unsigned int TriggerNames::triggerIndex(std::string_view name) const {
53  auto found = std::equal_range(indexMap_.begin(), indexMap_.end(), name, PairSort());
54  if (found.first == found.second)
55  return indexMap_.size();
56  return found.first->second;
57  }
58 
59  std::size_t TriggerNames::size() const { return triggerNames_.size(); }
60 
62 } // namespace edm
edm::TriggerNames::parameterSetID
ParameterSetID const & parameterSetID() const
Definition: TriggerNames.cc:61
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::TriggerNames::TriggerNames
TriggerNames()=default
edm::TriggerNames::triggerNames_
Strings triggerNames_
Definition: TriggerNames.h:93
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::TriggerNames::indexMap_
IndexMap indexMap_
Definition: TriggerNames.h:94
edm::Hash< ParameterSetType >
edm::TriggerNames::triggerNames
Strings const & triggerNames() const
Definition: TriggerNames.cc:48
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Strings
EventSelector::Strings Strings
Definition: EventSelector.cc:48
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
TriggerNames.h
edm::TriggerNames::triggerIndex
unsigned int triggerIndex(std::string_view name) const
Definition: TriggerNames.cc:52
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::TriggerNames::triggerName
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:50
edm::TriggerNames::psetID_
ParameterSetID psetID_
Definition: TriggerNames.h:91
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::TriggerNames::size
std::size_t size() const
Definition: TriggerNames.cc:59
edm::TriggerNames
Definition: TriggerNames.h:55
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
ParameterSet.h
edm::TriggerNames::operator=
TriggerNames & operator=(TriggerNames const &)
Definition: TriggerNames.cc:32
edm::TriggerNames::Strings
std::vector< std::string > Strings
Definition: TriggerNames.h:58
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::TriggerNames::initializeTriggerIndex
void initializeTriggerIndex()
Definition: TriggerNames.cc:38