CMS 3D CMS Logo

TrigCodes.h

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

Generated on Tue Jun 9 17:34:09 2009 for CMSSW by  doxygen 1.5.4