CMS 3D CMS Logo

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

#include <EgHLTTrigCodes.h>

Public Types

using TrigBitSet = std::bitset< maxNrBits_ >
 

Public Member Functions

TrigBitSet getCode (const char *descript) const
 
TrigBitSet getCode (const std::string &descript) const
 
TrigCodesoperator= (const TrigCodes &)=delete
 
 TrigCodes (const TrigCodes &)=delete
 
 ~TrigCodes ()=default
 

Static Public Member Functions

static TrigCodesmakeCodes (std::vector< std::string > &filterNames)
 

Static Public Attributes

static const int maxNrBits_ =128
 

Private Member Functions

void getCodeName (TrigBitSet code, std::string &id) const
 
void printCodes ()
 
void setCode (const char *descript, TrigBitSet code)
 
void setCode (const char *descript, int bitNr)
 
size_t size () const
 
void sort ()
 
 TrigCodes ()=default
 

Static Private Member Functions

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

Private Attributes

std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
 

Detailed Description

Definition at line 21 of file EgHLTTrigCodes.h.

Member Typedef Documentation

Definition at line 25 of file EgHLTTrigCodes.h.

Constructor & Destructor Documentation

egHLT::TrigCodes::~TrigCodes ( )
default
egHLT::TrigCodes::TrigCodes ( const TrigCodes )
delete
egHLT::TrigCodes::TrigCodes ( )
privatedefault

Referenced by getCode(), and makeCodes().

Member Function Documentation

TrigCodes::TrigBitSet TrigCodes::getCode ( const char *  descript) const

Definition at line 44 of file EgHLTTrigCodes.cc.

References EnergyCorrector::c, codeDefs_, end, and spr::find().

Referenced by egHLT::MonElemFuncs::addTightLooseTrigHist(), egHLT::trigTools::getFiltersPassed(), egHLT::MonElemFuncs::initTightLooseDiObjTrigHistsTrigCuts(), egHLT::MonElemFuncs::initTightLooseTrigHistsTrigCuts(), egHLT::MonElemFuncs::initTrigTagProbeHist(), egHLT::MonElemFuncs::initTrigTagProbeHist_2Leg(), egHLT::MonElemFuncs::initTrigTagProbeHists(), egHLT::trigTools::setFiltersObjPasses(), egHLT::OffHelper::setTrigInfo(), and egHLT::OffHelper::setupTriggers().

45 {
46  TrigBitSet code;
47 
48  char const * const end = descript+strlen(descript);
49  char const * codeKey = descript;
50  char const * token = nullptr;
51  do {
52  token = std::find(codeKey, end, ':');
53 
54  for(auto const& c: codeDefs_) {
55  if(0==c.first.compare(0,std::string::npos,codeKey, token-codeKey)){
56  code |= c.second;
57  break;
58  }
59  }
60  codeKey = token+1;
61  } while(token != end);
62  return code;
63 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
#define end
Definition: vmac.h:39
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
std::bitset< maxNrBits_ > TrigBitSet
TrigBitSet egHLT::TrigCodes::getCode ( const std::string &  descript) const
inline

Definition at line 39 of file EgHLTTrigCodes.h.

References getCode(), getCodeName(), keyComp(), setCode(), AlCaHLTBitMon_QueryRunRegistry::string, and TrigCodes().

Referenced by getCode().

39 { return getCode(descript.c_str()); }
TrigBitSet getCode(const char *descript) const
void TrigCodes::getCodeName ( TrigBitSet  code,
std::string &  id 
) const
private

Definition at line 70 of file EgHLTTrigCodes.cc.

References codeDefs_, and relativeConstraints::empty.

Referenced by getCode().

71 {
72  id.clear();
73  for(auto const & codeDef : codeDefs_){
74  if((code&codeDef.second)==codeDef.second){
75  if(!id.empty()) id+=":";//seperating entries by a ':'
76  id+=codeDef.first;
77  }
78 
79  }
80 
81 }
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
bool TrigCodes::keyComp ( const std::pair< std::string, TrigBitSet > &  lhs,
const std::pair< std::string, TrigBitSet > &  rhs 
)
staticprivate

Definition at line 65 of file EgHLTTrigCodes.cc.

Referenced by getCode(), and sort().

66 {
67  return lhs.first < rhs.first;
68 }
TrigCodes * TrigCodes::makeCodes ( std::vector< std::string > &  filterNames)
static

Definition at line 9 of file EgHLTTrigCodes.cc.

References mps_fire::i, AlCaHLTBitMon_ParallelJobs::p, and TrigCodes().

10 {
11  auto *p = new TrigCodes();
12 
13  for (size_t i=0;i<filterNames.size();i++) {
14  p->setCode(filterNames[i].c_str(),i);
15  }
16  p->sort();
17 
18  return p;
19 }
TrigCodes()=default
TrigCodes& egHLT::TrigCodes::operator= ( const TrigCodes )
delete
void TrigCodes::printCodes ( )
private

Definition at line 83 of file EgHLTTrigCodes.cc.

References codeDefs_, and mps_check::msg.

Referenced by size().

84 {
85  std::ostringstream msg;
86  msg <<" trig bits defined: "<<std::endl;
87  for(auto & codeDef : codeDefs_) msg <<" key : "<<codeDef.first<<" bit "<<codeDef.second<<std::endl;
88  edm::LogInfo("TrigCodes") << msg.str();
89 
90 }
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
tuple msg
Definition: mps_check.py:279
void TrigCodes::setCode ( const char *  descript,
TrigBitSet  code 
)
private

Definition at line 32 of file EgHLTTrigCodes.cc.

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

Referenced by getCode(), and setCode().

33 {
34  bool found=false;
35  for(size_t i=0;i<codeDefs_.size() && !found;i++){
36  if(codeDefs_[i].first==descript) found=true;
37  }
38  if(!found) codeDefs_.emplace_back(descript,code);
39  //_codeDefs[descript] = code;
40 }
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
void TrigCodes::setCode ( const char *  descript,
int  bitNr 
)
private

Definition at line 21 of file EgHLTTrigCodes.cc.

References maxNrBits_, and setCode().

22 {
23  if(bitNr < maxNrBits_){
24  TrigBitSet code;
25  code.set(bitNr);
26  setCode(descript,code);
27  }else{
28  edm::LogWarning("TrigCodes::TrigBitSetMap") <<" Warning, trying to store at bit "<<bitNr<<" but max nr bits is "<<maxNrBits_;
29  }
30 }
void setCode(const char *descript, TrigBitSet code)
static const int maxNrBits_
std::bitset< maxNrBits_ > TrigBitSet
size_t egHLT::TrigCodes::size ( void  ) const
inlineprivate

Definition at line 53 of file EgHLTTrigCodes.h.

References printCodes().

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

53 {return codeDefs_.size();}
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
void egHLT::TrigCodes::sort ( )
inlineprivate

Definition at line 52 of file EgHLTTrigCodes.h.

References keyComp().

52 {std::sort(codeDefs_.begin(),codeDefs_.end(),keyComp);}
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
static bool keyComp(const std::pair< std::string, TrigBitSet > &lhs, const std::pair< std::string, TrigBitSet > &rhs)

Member Data Documentation

std::vector<std::pair<std::string,TrigBitSet> > egHLT::TrigCodes::codeDefs_
private

Definition at line 29 of file EgHLTTrigCodes.h.

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

const int egHLT::TrigCodes::maxNrBits_ =128
static

Definition at line 24 of file EgHLTTrigCodes.h.

Referenced by setCode().