CMS 3D CMS Logo

ComCodes Class Reference

#include <DQMOffline/Trigger/interface/ComCodes.h>

List of all members.

Public Member Functions

 ComCodes (const ComCodes &rhs)
 ComCodes ()
int getCode (const char *descript) const
void getCodeName (int code, std::string &id) const
void setCode (const char *descript, int code)
void sort ()
 ~ComCodes ()

Static Public Member Functions

static bool keyComp (const std::pair< std::string, int > &lhs, const std::pair< std::string, int > &rhs)

Private Attributes

std::vector< std::pair
< std::string, int > > 
_codeDefs


Detailed Description

Definition at line 14 of file ComCodes.h.


Constructor & Destructor Documentation

ComCodes::ComCodes (  )  [inline]

Definition at line 21 of file ComCodes.h.

00021 {} 

ComCodes::ComCodes ( const ComCodes rhs  )  [inline]

Definition at line 22 of file ComCodes.h.

00022 :_codeDefs(rhs._codeDefs){}

ComCodes::~ComCodes (  )  [inline]

Definition at line 23 of file ComCodes.h.

00023 {} 


Member Function Documentation

int ComCodes::getCode ( const char *  descript  )  const

Definition at line 17 of file ComCodes.cc.

References _codeDefs, code, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), first, i, and NULL.

Referenced by EleTypeCodes::getCode(), and CutCodes::getCode().

00018 { 
00019   //first copy the character string to a local array so we can manipulate it
00020   char localDescript[256];
00021   strcpy(localDescript,descript);
00022   
00023   int code = 0x0000; 
00024   char* codeKey = strtok(localDescript,":");
00025   //  std::map<std::string,int> ::const_iterator mapIt;
00026   while(codeKey!=NULL){
00027     bool found=false;
00028 
00029     for(size_t i=0;i<_codeDefs.size() && !found;i++){
00030       if(_codeDefs[i].first.compare(codeKey)==0){
00031         found=true;
00032         code |= _codeDefs[i].second;
00033 
00034        }
00035     }
00036    
00037     if(!found)  std::cout<<"ComCodes::getCode : Error, Key "<<codeKey<<" not found"<<std::endl;
00038     codeKey = strtok(NULL,":"); //getting new substring
00039     
00040   }
00041   return code;
00042 }

void ComCodes::getCodeName ( int  code,
std::string &  id 
) const

Definition at line 49 of file ComCodes.cc.

References _codeDefs, empty, i, and edm::second().

Referenced by CutCodes::getCodeName(), and EleTypeCodes::getCodeName().

00050 {
00051   id.clear();
00052   for(size_t i=0;i<_codeDefs.size();i++){ 
00053     if((code&_codeDefs[i].second)==_codeDefs[i].second){
00054       if(!id.empty()) id+=":";//seperating entries by a ':'
00055       id+=_codeDefs[i].first;
00056     }
00057     
00058   }
00059  
00060 }

bool ComCodes::keyComp ( const std::pair< std::string, int > &  lhs,
const std::pair< std::string, int > &  rhs 
) [static]

Definition at line 44 of file ComCodes.cc.

Referenced by sort().

00045 {
00046   return lhs.first < rhs.first;
00047 }

void ComCodes::setCode ( const char *  descript,
int  code 
)

Definition at line 4 of file ComCodes.cc.

References _codeDefs, first, and i.

Referenced by EleTypeCodes::setCodes_(), and CutCodes::setCodes_().

00005 {
00006   bool found=false;
00007   for(size_t i=0;i<_codeDefs.size() && !found;i++){
00008     if(_codeDefs[i].first.compare(descript)==0) found=true;
00009   }
00010   if(!found) _codeDefs.push_back(std::make_pair<std::string,int>(descript,code));
00011  
00012   //_codeDefs[descript] = code;
00013 }

void ComCodes::sort (  )  [inline]

Definition at line 34 of file ComCodes.h.

References _codeDefs, keyComp(), and python::multivaluedict::sort().

Referenced by CutCodes::setCodes_().

00034 {std::sort(_codeDefs.begin(),_codeDefs.end(),keyComp);}


Member Data Documentation

std::vector<std::pair<std::string,int> > ComCodes::_codeDefs [private]

Definition at line 18 of file ComCodes.h.

Referenced by getCode(), getCodeName(), setCode(), and sort().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:16:31 2009 for CMSSW by  doxygen 1.5.4