CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQMOffline/Trigger/interface/EgHLTTrigCodes.h

Go to the documentation of this file.
00001 #ifndef DQMOFFLINE_TRIGGER_EGHLTTRIGCODES
00002 #define DQMOFFLINE_TRIGGER_EGHLTTRIGCODES
00003 
00004 
00005 //author: Sam Harper
00006 //aim: to define the trigger bits we are interested in
00007 //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
00008 
00009 #include <cstring>
00010 #include <string>
00011 #include <iostream>
00012 #include <bitset>
00013 #include <vector>
00014 #include <algorithm>
00015 
00016 //unforunately hard coded limit of 64 bits which needs to be checked when setting it up
00017 //if this becomes a problem, will be replaced by boost::dynamic_bitset
00018 //my appologies for the typedef, it was better this way 
00019 
00020 namespace egHLT {
00021   class TrigCodes {
00022     
00023   public:
00024     static const int maxNrBits_=128;
00025     typedef std::bitset<maxNrBits_> TrigBitSet;
00026     
00027     class TrigBitSetMap {
00028       
00029     private:
00030       //sorted vector
00031       std::vector<std::pair<std::string,TrigBitSet> > codeDefs_;
00032       
00033     public:
00034       TrigBitSetMap(){}
00035       ~TrigBitSetMap(){}
00036       
00037     public:
00038       TrigBitSet getCode(const char *descript)const;
00039       void getCodeName(TrigBitSet code,std::string& id)const;
00040       
00041       //modifiers
00042       void setCode(const char *descript,TrigBitSet code);
00043       void setCode(const char *descript,int bitNr);
00044       
00045       //key comp
00046       static bool keyComp(const std::pair<std::string,TrigBitSet>& lhs,const std::pair<std::string,TrigBitSet>& rhs);
00047       void sort(){std::sort(codeDefs_.begin(),codeDefs_.end(),keyComp);}
00048       size_t size()const{return codeDefs_.size();}
00049       void printCodes();
00050     };
00051     
00052     
00053   private:
00054     static TrigBitSetMap trigBitSetMap_;
00055     
00056   private:
00057     TrigCodes(){}//not allowed to instanstiate
00058     ~TrigCodes(){}
00059     
00060   public:
00061     // static void setCode(const char *descript,TrigBitSet code){trigBitSetMap_.setCode(descript,code);}
00062   //static void setCode(const char *descript,int bitNr){trigBitSetMap_.setCode(descript,bitNr);}
00063     static void setCodes(std::vector<std::string>& filterNames);
00064     
00065     
00066     static TrigBitSet getCode(const std::string& descript){return trigBitSetMap_.getCode(descript.c_str());}
00067     static void getCodeName(TrigBitSet code,std::string& id){return trigBitSetMap_.getCodeName(code,id);}
00068     static int maxNrBits(){return maxNrBits_;}
00069     static void printCodes(){return trigBitSetMap_.printCodes();}
00070     
00071   };
00072 }
00073 
00074 #endif