CMS 3D CMS Logo

EgHLTTrigCodes.cc
Go to the documentation of this file.
2 
4 
6 
7 using namespace egHLT;
8 
9 TrigCodes* TrigCodes::makeCodes(std::vector<std::string>& filterNames) {
10  auto* p = new TrigCodes();
11 
12  for (size_t i = 0; i < filterNames.size(); i++) {
13  p->setCode(filterNames[i].c_str(), i);
14  }
15  p->sort();
16 
17  return p;
18 }
19 
20 void TrigCodes::setCode(const char* descript, int bitNr) {
21  if (bitNr < maxNrBits_) {
22  TrigBitSet code;
23  code.set(bitNr);
24  setCode(descript, code);
25  } else {
26  edm::LogWarning("TrigCodes::TrigBitSetMap")
27  << " Warning, trying to store at bit " << bitNr << " but max nr bits is " << maxNrBits_;
28  }
29 }
30 
31 void TrigCodes::setCode(const char* descript, TrigBitSet code) {
32  bool found = false;
33  for (size_t i = 0; i < codeDefs_.size() && !found; i++) {
34  if (codeDefs_[i].first == descript)
35  found = true;
36  }
37  if (!found)
38  codeDefs_.emplace_back(descript, code);
39  //_codeDefs[descript] = code;
40 }
41 
42 TrigCodes::TrigBitSet TrigCodes::getCode(const char* descript) const {
43  TrigBitSet code;
44 
45  char const* const end = descript + strlen(descript);
46  char const* codeKey = descript;
47  char const* token = nullptr;
48  do {
49  token = std::find(codeKey, end, ':');
50 
51  for (auto const& c : codeDefs_) {
52  if (0 == c.first.compare(0, std::string::npos, codeKey, token - codeKey)) {
53  code |= c.second;
54  break;
55  }
56  }
57  codeKey = token + 1;
58  } while (token != end);
59  return code;
60 }
61 
62 bool TrigCodes::keyComp(const std::pair<std::string, TrigBitSet>& lhs, const std::pair<std::string, TrigBitSet>& rhs) {
63  return lhs.first < rhs.first;
64 }
65 
67  id.clear();
68  for (auto const& codeDef : codeDefs_) {
69  if ((code & codeDef.second) == codeDef.second) {
70  if (!id.empty())
71  id += ":"; //seperating entries by a ':'
72  id += codeDef.first;
73  }
74  }
75 }
76 
78  std::ostringstream msg;
79  msg << " trig bits defined: " << std::endl;
80  for (auto& codeDef : codeDefs_)
81  msg << " key : " << codeDef.first << " bit " << codeDef.second << std::endl;
82  edm::LogInfo("TrigCodes") << msg.str();
83 }
egHLT::TrigCodes::makeCodes
static TrigCodes * makeCodes(std::vector< std::string > &filterNames)
Definition: EgHLTTrigCodes.cc:9
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
egHLT::TrigCodes::TrigCodes
TrigCodes()=default
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
egHLT::TrigCodes::getCodeName
void getCodeName(TrigBitSet code, std::string &id) const
Definition: EgHLTTrigCodes.cc:66
edm::LogInfo
Definition: MessageLogger.h:254
egHLT::TrigCodes
Definition: EgHLTTrigCodes.h:20
mps_check.msg
tuple msg
Definition: mps_check.py:285
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
dqmdumpme.first
first
Definition: dqmdumpme.py:55
end
#define end
Definition: vmac.h:39
egHLT::TrigCodes::printCodes
void printCodes()
Definition: EgHLTTrigCodes.cc:77
egHLT::TrigCodes::TrigBitSet
std::bitset< maxNrBits_ > TrigBitSet
Definition: EgHLTTrigCodes.h:23
egHLT::TrigCodes::maxNrBits_
static const int maxNrBits_
Definition: EgHLTTrigCodes.h:22
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
egHLT::TrigCodes::getCode
TrigBitSet getCode(const char *descript) const
Definition: EgHLTTrigCodes.cc:42
egHLT::TrigCodes::keyComp
static bool keyComp(const std::pair< std::string, TrigBitSet > &lhs, const std::pair< std::string, TrigBitSet > &rhs)
Definition: EgHLTTrigCodes.cc:62
egHLT::TrigCodes::setCode
void setCode(const char *descript, TrigBitSet code)
Definition: EgHLTTrigCodes.cc:31
egHLT::TrigCodes::codeDefs_
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
Definition: EgHLTTrigCodes.h:27
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
EgHLTTrigCodes.h
egHLT
Definition: EgHLTBinData.h:10
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316