CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
egHLT::ComCodes Class Reference

#include <EgHLTComCodes.h>

Public Member Functions

 ComCodes ()=default
 
 ComCodes (const ComCodes &rhs)=default
 
int getCode (const char *descript) const
 
void getCodeName (int code, std::string &id) const
 
void setCode (const char *descript, int code)
 
void sort ()
 
 ~ComCodes ()=default
 

Static Public Member Functions

static bool keyComp (const std::pair< std::string, int > &lhs, const std::pair< std::string, int > &rhs)
 

Private Attributes

std::vector< std::pair< std::string, int > > _codeDefs
 

Detailed Description

Definition at line 12 of file EgHLTComCodes.h.

Constructor & Destructor Documentation

◆ ComCodes() [1/2]

egHLT::ComCodes::ComCodes ( )
default

◆ ComCodes() [2/2]

egHLT::ComCodes::ComCodes ( const ComCodes rhs)
default

◆ ~ComCodes()

egHLT::ComCodes::~ComCodes ( )
default

Member Function Documentation

◆ getCode()

int ComCodes::getCode ( const char *  descript) const

Definition at line 19 of file EgHLTComCodes.cc.

19  {
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 }

References _codeDefs, c, mps_fire::end, spr::find(), newFWLiteAna::found, AlCaHLTBitMon_QueryRunRegistry::string, and unpackBuffers-CaloStage2::token.

Referenced by egHLT::EgCutCodes::getCode().

◆ getCodeName()

void ComCodes::getCodeName ( int  code,
std::string &  id 
) const

Definition at line 48 of file EgHLTComCodes.cc.

48  {
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 }

References _codeDefs, and relativeConstraints::empty.

Referenced by egHLT::EgCutCodes::getCodeName().

◆ keyComp()

bool ComCodes::keyComp ( const std::pair< std::string, int > &  lhs,
const std::pair< std::string, int > &  rhs 
)
static

Definition at line 44 of file EgHLTComCodes.cc.

44  {
45  return lhs.first < rhs.first;
46 }

Referenced by sort().

◆ setCode()

void ComCodes::setCode ( const char *  descript,
int  code 
)

Definition at line 7 of file EgHLTComCodes.cc.

7  {
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 }

References _codeDefs, first, newFWLiteAna::found, and mps_fire::i.

Referenced by egHLT::EgCutCodes::setCodes_().

◆ sort()

void egHLT::ComCodes::sort ( )
inline

Definition at line 30 of file EgHLTComCodes.h.

30 { std::sort(_codeDefs.begin(), _codeDefs.end(), keyComp); }

References _codeDefs, keyComp(), and jetUpdater_cfi::sort.

Referenced by egHLT::EgCutCodes::setCodes_().

Member Data Documentation

◆ _codeDefs

std::vector<std::pair<std::string, int> > egHLT::ComCodes::_codeDefs
private

Definition at line 14 of file EgHLTComCodes.h.

Referenced by getCode(), getCodeName(), setCode(), and sort().

mps_fire.i
i
Definition: mps_fire.py:428
egHLT::ComCodes::_codeDefs
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:14
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
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
mps_fire.end
end
Definition: mps_fire.py:242
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
egHLT::ComCodes::keyComp
static bool keyComp(const std::pair< std::string, int > &lhs, const std::pair< std::string, int > &rhs)
Definition: EgHLTComCodes.cc:44
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316