Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:18

0001 #ifndef DQMOFFLINE_TRIGGER_EGHLTTRIGCODES
0002 #define DQMOFFLINE_TRIGGER_EGHLTTRIGCODES
0003 
0004 //author: Sam Harper
0005 //aim: to define the trigger bits we are interested in
0006 //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
0007 
0008 #include <cstring>
0009 #include <string>
0010 #include <iostream>
0011 #include <bitset>
0012 #include <vector>
0013 #include <algorithm>
0014 
0015 //unforunately hard coded limit of 64 bits which needs to be checked when setting it up
0016 //if this becomes a problem, will be replaced by boost::dynamic_bitset
0017 //my appologies for the typedef, it was better this way
0018 
0019 namespace egHLT {
0020   class TrigCodes {
0021   public:
0022     static const int maxNrBits_ = 128;
0023     using TrigBitSet = std::bitset<maxNrBits_>;
0024 
0025   private:
0026     //sorted vector
0027     std::vector<std::pair<std::string, TrigBitSet> > codeDefs_;
0028 
0029   public:
0030     static TrigCodes* makeCodes(std::vector<std::string>& filterNames);
0031     ~TrigCodes() = default;
0032 
0033     TrigCodes& operator=(const TrigCodes&) = delete;
0034     TrigCodes(const TrigCodes&) = delete;
0035 
0036     TrigBitSet getCode(const char* descript) const;
0037     TrigBitSet getCode(const std::string& descript) const { return getCode(descript.c_str()); }
0038 
0039   private:
0040     TrigCodes() = default;
0041 
0042     void getCodeName(TrigBitSet code, std::string& id) const;
0043 
0044     //modifiers
0045     void setCode(const char* descript, TrigBitSet code);
0046     void setCode(const char* descript, int bitNr);
0047 
0048     //key comp
0049     static bool keyComp(const std::pair<std::string, TrigBitSet>& lhs, const std::pair<std::string, TrigBitSet>& rhs);
0050     void sort() { std::sort(codeDefs_.begin(), codeDefs_.end(), keyComp); }
0051     size_t size() const { return codeDefs_.size(); }
0052     void printCodes();
0053   };
0054 }  // namespace egHLT
0055 
0056 #endif