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

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

Member Function Documentation

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

Definition at line 20 of file EgHLTComCodes.cc.

References _codeDefs, EnergyCorrector::c, end, spr::find(), runEdmFileComparison::found, and AlCaHLTBitMon_QueryRunRegistry::string.

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

21 {
22  int code = 0x0000;
23  char const * const end = descript+strlen(descript);
24  char const * codeKey = descript;
25  char const * token = nullptr;
26  do {
27  token = std::find(codeKey, end, ':');
28 
29  bool found = false;
30  for(auto const& c: _codeDefs) {
31  if(0==c.first.compare(0,std::string::npos,codeKey, token-codeKey)){
32  code |= c.second;
33  found = true;
34  break;
35  }
36  }
37  if(!found) edm::LogWarning("EgHLTComCodes") <<"ComCodes::getCode : Error, Key "<<std::string(codeKey,token-codeKey)<<" not found (likely mistyped, practical upshot is the selection is not what you think it is)";//<<std::endl;
38  codeKey = token+1;
39  } while(token != end);
40  return code;
41 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:15
#define end
Definition: vmac.h:39
void ComCodes::getCodeName ( int  code,
std::string &  id 
) const

Definition at line 48 of file EgHLTComCodes.cc.

References _codeDefs, and relativeConstraints::empty.

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

49 {
50  id.clear();
51  for(auto const & _codeDef : _codeDefs){
52  if((code&_codeDef.second)==_codeDef.second){
53  if(!id.empty()) id+=":";//seperating entries by a ':'
54  id+=_codeDef.first;
55  }
56 
57  }
58 
59 }
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:15
bool ComCodes::keyComp ( const std::pair< std::string, int > &  lhs,
const std::pair< std::string, int > &  rhs 
)
static

Definition at line 43 of file EgHLTComCodes.cc.

Referenced by sort().

44 {
45  return lhs.first < rhs.first;
46 }
void ComCodes::setCode ( const char *  descript,
int  code 
)

Definition at line 7 of file EgHLTComCodes.cc.

References _codeDefs, plotBeamSpotDB::first, runEdmFileComparison::found, and mps_fire::i.

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

8 {
9  bool found=false;
10  for(size_t i=0;i<_codeDefs.size() && !found;i++){
11  if(_codeDefs[i].first==descript) found=true;
12  }
13  if(!found) _codeDefs.emplace_back(descript,code);
14 
15  //_codeDefs[descript] = code;
16 }
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:15
void egHLT::ComCodes::sort ( )
inline

Definition at line 31 of file EgHLTComCodes.h.

References keyComp(), and jetUpdater_cfi::sort.

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

31 {std::sort(_codeDefs.begin(),_codeDefs.end(),keyComp);}
std::vector< std::pair< std::string, int > > _codeDefs
Definition: EgHLTComCodes.h:15
static bool keyComp(const std::pair< std::string, int > &lhs, const std::pair< std::string, int > &rhs)

Member Data Documentation

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

Definition at line 15 of file EgHLTComCodes.h.

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