CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgHLTTrigCodes.h
Go to the documentation of this file.
1 #ifndef DQMOFFLINE_TRIGGER_EGHLTTRIGCODES
2 #define DQMOFFLINE_TRIGGER_EGHLTTRIGCODES
3 
4 
5 //author: Sam Harper
6 //aim: to define the trigger bits we are interested in
7 //implimentation: likely to be more than 32 (or even 64 bits) so differs from CutCodes in the fact it stores the bit position, not the bit mask
8 
9 #include <cstring>
10 #include <string>
11 #include <iostream>
12 #include <bitset>
13 #include <vector>
14 #include <algorithm>
15 
16 //unforunately hard coded limit of 64 bits which needs to be checked when setting it up
17 //if this becomes a problem, will be replaced by boost::dynamic_bitset
18 //my appologies for the typedef, it was better this way
19 
20 namespace egHLT {
21  class TrigCodes {
22 
23  public:
24  static const int maxNrBits_=128;
25  typedef std::bitset<maxNrBits_> TrigBitSet;
26 
27  private:
28  //sorted vector
29  std::vector<std::pair<std::string,TrigBitSet> > codeDefs_;
30 
31  public:
32  static TrigCodes *makeCodes(std::vector<std::string>& filterNames);
34 
35  TrigCodes & operator=(const TrigCodes&) = delete;
36  TrigCodes(const TrigCodes&) = delete;
37 
38  TrigBitSet getCode(const char *descript) const;
39  TrigBitSet getCode(const std::string& descript) const { return getCode(descript.c_str()); }
40 
41  private:
43 
44  void getCodeName(TrigBitSet code,std::string& id)const;
45 
46  //modifiers
47  void setCode(const char *descript,TrigBitSet code);
48  void setCode(const char *descript,int bitNr);
49 
50  //key comp
51  static bool keyComp(const std::pair<std::string,TrigBitSet>& lhs,const std::pair<std::string,TrigBitSet>& rhs);
52  void sort(){std::sort(codeDefs_.begin(),codeDefs_.end(),keyComp);}
53  size_t size()const{return codeDefs_.size();}
54  void printCodes();
55  };
56 }
57 
58 #endif
TrigBitSet getCode(const char *descript) const
void setCode(const char *descript, TrigBitSet code)
TrigBitSet getCode(const std::string &descript) const
static TrigCodes * makeCodes(std::vector< std::string > &filterNames)
TrigCodes & operator=(const TrigCodes &)=delete
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
size_t size() const
static const int maxNrBits_
void getCodeName(TrigBitSet code, std::string &id) const
static bool keyComp(const std::pair< std::string, TrigBitSet > &lhs, const std::pair< std::string, TrigBitSet > &rhs)
std::bitset< maxNrBits_ > TrigBitSet