CMS 3D CMS Logo

EgHLTComCodes.cc
Go to the documentation of this file.
2 
4 
5 using namespace egHLT;
6 
7 void ComCodes::setCode(const char* descript, int code) {
8  bool found = false;
9  for (size_t i = 0; i < _codeDefs.size() && !found; i++) {
10  if (_codeDefs[i].first == descript)
11  found = true;
12  }
13  if (!found)
14  _codeDefs.emplace_back(descript, code);
15 
16  //_codeDefs[descript] = code;
17 }
18 
19 int ComCodes::getCode(const char* descript) const {
20  int code = 0x0000;
21  char const* const end = descript + strlen(descript);
22  char const* codeKey = descript;
23  char const* token = nullptr;
24  do {
25  token = std::find(codeKey, end, ':');
26 
27  bool found = false;
28  for (auto const& c : _codeDefs) {
29  if (0 == c.first.compare(0, std::string::npos, codeKey, token - codeKey)) {
30  code |= c.second;
31  found = true;
32  break;
33  }
34  }
35  if (!found)
36  edm::LogWarning("EgHLTComCodes")
37  << "ComCodes::getCode : Error, Key " << std::string(codeKey, token - codeKey)
38  << " not found (likely mistyped, practical upshot is the selection is not what you think it is)"; //<<std::endl;
39  codeKey = token + 1;
40  } while (token != end);
41  return code;
42 }
43 
44 bool ComCodes::keyComp(const std::pair<std::string, int>& lhs, const std::pair<std::string, int>& rhs) {
45  return lhs.first < rhs.first;
46 }
47 
48 void ComCodes::getCodeName(int code, std::string& id) const {
49  id.clear();
50  for (auto const& _codeDef : _codeDefs) {
51  if ((code & _codeDef.second) == _codeDef.second) {
52  if (!id.empty())
53  id += ":"; //seperating entries by a ':'
54  id += _codeDef.first;
55  }
56  }
57 }
mps_fire.i
i
Definition: mps_fire.py:355
egHLT::ComCodes::_codeDefs
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:14
egHLT::ComCodes::getCodeName
void getCodeName(int code, std::string &id) const
Definition: EgHLTComCodes.cc:48
MessageLogger.h
EgHLTComCodes.h
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
egHLT::ComCodes::keyComp
static bool keyComp(const std::pair< std::string, int > &lhs, const std::pair< std::string, int > &rhs)
Definition: EgHLTComCodes.cc:44
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
egHLT::ComCodes::getCode
int getCode(const char *descript) const
Definition: EgHLTComCodes.cc:19
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
egHLT
Definition: EgHLTBinData.h:10
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316
egHLT::ComCodes::setCode
void setCode(const char *descript, int code)
Definition: EgHLTComCodes.cc:7