CMS 3D CMS Logo

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
egHLT::TrigCodes::makeCodes
static TrigCodes * makeCodes(std::vector< std::string > &filterNames)
Definition: EgHLTTrigCodes.cc:9
egHLT::TrigCodes::TrigCodes
TrigCodes()=default
egHLT::TrigCodes::getCodeName
void getCodeName(TrigBitSet code, std::string &id) const
Definition: EgHLTTrigCodes.cc:66
egHLT::TrigCodes
Definition: EgHLTTrigCodes.h:20
egHLT::TrigCodes::getCode
TrigBitSet getCode(const std::string &descript) const
Definition: EgHLTTrigCodes.h:37
egHLT::TrigCodes::size
size_t size() const
Definition: EgHLTTrigCodes.h:51
egHLT::TrigCodes::sort
void sort()
Definition: EgHLTTrigCodes.h:50
egHLT::TrigCodes::printCodes
void printCodes()
Definition: EgHLTTrigCodes.cc:77
egHLT::TrigCodes::TrigBitSet
std::bitset< maxNrBits_ > TrigBitSet
Definition: EgHLTTrigCodes.h:23
egHLT::TrigCodes::maxNrBits_
static const int maxNrBits_
Definition: EgHLTTrigCodes.h:22
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
egHLT::TrigCodes::getCode
TrigBitSet getCode(const char *descript) const
Definition: EgHLTTrigCodes.cc:42
egHLT::TrigCodes::keyComp
static bool keyComp(const std::pair< std::string, TrigBitSet > &lhs, const std::pair< std::string, TrigBitSet > &rhs)
Definition: EgHLTTrigCodes.cc:62
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
egHLT::TrigCodes::setCode
void setCode(const char *descript, TrigBitSet code)
Definition: EgHLTTrigCodes.cc:31
egHLT::TrigCodes::codeDefs_
std::vector< std::pair< std::string, TrigBitSet > > codeDefs_
Definition: EgHLTTrigCodes.h:27
egHLT::TrigCodes::~TrigCodes
~TrigCodes()=default
egHLT::TrigCodes::operator=
TrigCodes & operator=(const TrigCodes &)=delete
egHLT
Definition: EgHLTBinData.h:10