CMS 3D CMS Logo

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