test
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  class TrigBitSetMap {
28 
29  private:
30  //sorted vector
31  std::vector<std::pair<std::string,TrigBitSet> > codeDefs_;
32 
33  public:
36 
37  public:
38  TrigBitSet getCode(const char *descript)const;
39  void getCodeName(TrigBitSet code,std::string& id)const;
40 
41  //modifiers
42  void setCode(const char *descript,TrigBitSet code);
43  void setCode(const char *descript,int bitNr);
44 
45  //key comp
46  static bool keyComp(const std::pair<std::string,TrigBitSet>& lhs,const std::pair<std::string,TrigBitSet>& rhs);
47  void sort(){std::sort(codeDefs_.begin(),codeDefs_.end(),keyComp);}
48  size_t size()const{return codeDefs_.size();}
49  void printCodes();
50  };
51 
52 
53  private:
55 
56  private:
57  TrigCodes(){}//not allowed to instanstiate
59 
60  public:
61  // static void setCode(const char *descript,TrigBitSet code){trigBitSetMap_.setCode(descript,code);}
62  //static void setCode(const char *descript,int bitNr){trigBitSetMap_.setCode(descript,bitNr);}
63  static void setCodes(std::vector<std::string>& filterNames);
64 
65 
66  static TrigBitSet getCode(const std::string& descript){return trigBitSetMap_.getCode(descript.c_str());}
67  static void getCodeName(TrigBitSet code,std::string& id){return trigBitSetMap_.getCodeName(code,id);}
68  static int maxNrBits(){return maxNrBits_;}
69  static void printCodes(){return trigBitSetMap_.printCodes();}
70 
71  };
72 }
73 
74 #endif
static int maxNrBits()
static void getCodeName(TrigBitSet code, std::string &id)
static void printCodes()
static bool keyComp(const std::pair< std::string, TrigBitSet > &lhs, const std::pair< std::string, TrigBitSet > &rhs)
static TrigBitSet getCode(const std::string &descript)
void getCodeName(TrigBitSet code, std::string &id) const
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
void setCode(const char *descript, TrigBitSet code)
static TrigBitSetMap trigBitSetMap_
static const int maxNrBits_
static void setCodes(std::vector< std::string > &filterNames)
TrigBitSet getCode(const char *descript) const
std::bitset< maxNrBits_ > TrigBitSet