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
EventSelector::Strings Strings
std::vector< std::string > Strings
Definition: TriggerNames.h:58
Strings const & triggerNames() const
Definition: TriggerNames.cc:48
IndexMap indexMap_
Definition: TriggerNames.h:94
unsigned int triggerIndex(std::string_view name) const
Definition: TriggerNames.cc:52
TriggerNames & operator=(TriggerNames const &)
Definition: TriggerNames.cc:32
ParameterSetID const & parameterSetID() const
Definition: TriggerNames.cc:61
TriggerNames()=default
void initializeTriggerIndex()
Definition: TriggerNames.cc:38
std::size_t size() const
Definition: TriggerNames.cc:59
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:50
HLT enums.
Strings triggerNames_
Definition: TriggerNames.h:93
def move(src, dest)
Definition: eostools.py:511
ParameterSetID psetID_
Definition: TriggerNames.h:91