CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
egHLT::TrigCodes::TrigBitSetMap Class Reference

#include <EgHLTTrigCodes.h>

Public Member Functions

TrigBitSet getCode (const char *descript) const
 
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 ()
 
 TrigBitSetMap ()
 
 ~TrigBitSetMap ()
 

Static Public 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 27 of file EgHLTTrigCodes.h.

Constructor & Destructor Documentation

egHLT::TrigCodes::TrigBitSetMap::TrigBitSetMap ( )
inline

Definition at line 34 of file EgHLTTrigCodes.h.

34 {}
egHLT::TrigCodes::TrigBitSetMap::~TrigBitSetMap ( )
inline

Definition at line 35 of file EgHLTTrigCodes.h.

35 {}

Member Function Documentation

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

Definition at line 42 of file EgHLTTrigCodes.cc.

References first, newFWLiteAna::found, i, and NULL.

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

43 {
44  //first copy the character string to a local array so we can manipulate it
45  char localDescript[512];
46  strcpy(localDescript,descript);
47 
48  TrigBitSet code;
49  char* codeKey = strtok(localDescript,":");
50  // std::map<std::string,int> ::const_iterator mapIt;
51  while(codeKey!=NULL){
52  bool found=false;
53 
54  for(size_t i=0;i<codeDefs_.size() && !found;i++){
55  if(codeDefs_[i].first.compare(codeKey)==0){
56  found=true;
57  code |= codeDefs_[i].second;
58 
59  }
60  }
61 
62  // if(!found) edm::LogError("TrigCodes::TrigBitSetMap") <<"TrigCodes::TrigBitSetMap::getCode : Error, Key "<<codeKey<<" not found";
63  codeKey = strtok(NULL,":"); //getting new substring
64 
65  }
66  return code;
67 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
#define NULL
Definition: scimark2.h:8
bool first
Definition: L1TdeRCT.cc:79
std::bitset< maxNrBits_ > TrigBitSet
void TrigCodes::TrigBitSetMap::getCodeName ( TrigBitSet  code,
std::string &  id 
) const

Definition at line 74 of file EgHLTTrigCodes.cc.

References relativeConstraints::empty, i, and edm::second().

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

75 {
76  id.clear();
77  for(size_t i=0;i<codeDefs_.size();i++){
78  if((code&codeDefs_[i].second)==codeDefs_[i].second){
79  if(!id.empty()) id+=":";//seperating entries by a ':'
80  id+=codeDefs_[i].first;
81  }
82 
83  }
84 
85 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
U second(std::pair< T, U > const &p)
bool TrigCodes::TrigBitSetMap::keyComp ( const std::pair< std::string, TrigBitSet > &  lhs,
const std::pair< std::string, TrigBitSet > &  rhs 
)
static

Definition at line 69 of file EgHLTTrigCodes.cc.

Referenced by sort().

70 {
71  return lhs.first < rhs.first;
72 }
void TrigCodes::TrigBitSetMap::printCodes ( )

Definition at line 87 of file EgHLTTrigCodes.cc.

References first, i, lumiQueryAPI::msg, and edm::second().

Referenced by egHLT::TrigCodes::printCodes().

88 {
89  std::ostringstream msg;
90  msg <<" trig bits defined: "<<std::endl;
91  for(size_t i=0;i<codeDefs_.size();i++) msg <<" key : "<<codeDefs_[i].first<<" bit "<<codeDefs_[i].second<<std::endl;
92  edm::LogInfo("TrigCodes") <<msg;
93 
94 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
U second(std::pair< T, U > const &p)
bool first
Definition: L1TdeRCT.cc:79
void TrigCodes::TrigBitSetMap::setCode ( const char *  descript,
TrigBitSet  code 
)

Definition at line 30 of file EgHLTTrigCodes.cc.

References first, newFWLiteAna::found, and i.

Referenced by setCode(), and egHLT::TrigCodes::setCodes().

31 {
32  bool found=false;
33  for(size_t i=0;i<codeDefs_.size() && !found;i++){
34  if(codeDefs_[i].first.compare(descript)==0) found=true;
35  }
36  if(!found) codeDefs_.push_back(std::pair<std::string,TrigBitSet>(descript,code));
37  //_codeDefs[descript] = code;
38 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
bool first
Definition: L1TdeRCT.cc:79
void TrigCodes::TrigBitSetMap::setCode ( const char *  descript,
int  bitNr 
)

Definition at line 19 of file EgHLTTrigCodes.cc.

References egHLT::TrigCodes::maxNrBits(), and setCode().

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

Definition at line 48 of file EgHLTTrigCodes.h.

References codeDefs_.

Referenced by egHLT::TrigCodes::setCodes().

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

Definition at line 47 of file EgHLTTrigCodes.h.

References codeDefs_, keyComp(), and python.multivaluedict::sort().

Referenced by egHLT::TrigCodes::setCodes().

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

Member Data Documentation

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

Definition at line 31 of file EgHLTTrigCodes.h.

Referenced by size(), and sort().