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 codeDefs_, plotBeamSpotDB::first, runEdmFileComparison::found, and mps_fire::i.

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  //first copy the character string to a local array so we can manipulate it
47  char localDescript[512];
48  strcpy(localDescript,descript);
49 
50  TrigBitSet code;
51  char* codeKey = strtok(localDescript,":");
52  // std::map<std::string,int> ::const_iterator mapIt;
53  while(codeKey!=nullptr){
54  bool found=false;
55 
56  for(size_t i=0;i<codeDefs_.size() && !found;i++){
57  if(codeDefs_[i].first==codeKey){
58  found=true;
59  code |= codeDefs_[i].second;
60 
61  }
62  }
63 
64  // if(!found) edm::LogError("TrigCodes::TrigBitSetMap") <<"TrigCodes::TrigBitSetMap::getCode : Error, Key "<<codeKey<<" not found";
65  codeKey = strtok(nullptr,":"); //getting new substring
66 
67  }
68  return code;
69 }
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 76 of file EgHLTTrigCodes.cc.

References codeDefs_, and relativeConstraints::empty.

Referenced by getCode().

77 {
78  id.clear();
79  for(auto const & codeDef : codeDefs_){
80  if((code&codeDef.second)==codeDef.second){
81  if(!id.empty()) id+=":";//seperating entries by a ':'
82  id+=codeDef.first;
83  }
84 
85  }
86 
87 }
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 71 of file EgHLTTrigCodes.cc.

Referenced by getCode(), and sort().

72 {
73  return lhs.first < rhs.first;
74 }
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 89 of file EgHLTTrigCodes.cc.

References codeDefs_, and mps_alisetup::msg.

Referenced by size().

90 {
91  std::ostringstream msg;
92  msg <<" trig bits defined: "<<std::endl;
93  for(auto & codeDef : codeDefs_) msg <<" key : "<<codeDef.first<<" bit "<<codeDef.second<<std::endl;
94  edm::LogInfo("TrigCodes") << msg.str();
95 
96 }
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
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().