CMS 3D CMS Logo

cscdqm::Utility Class Reference

General and CSCDQM Framework related utility routines. More...

#include <DQM/CSCMonitorModule/interface/CSCDQM_Utility.h>

List of all members.

Static Public Member Functions

static uint32_t fastHash (const char *data)
static uint32_t fastHash (const char *data, int len)
 Calculate super fast hash (from https://www.azillionmonkeys.com/qed/hash.html).
static const int getCSCTypeBin (const std::string &cstr)
 Get CSC y-axis position from chamber string.
static const std::string getCSCTypeLabel (int endcap, int station, int ring)
 Get CSC label from CSC parameters.
static const bool regexMatch (const std::string &expression, const std::string &message)
static const bool regexMatch (const TPRegexp &re_expression, const std::string &message)
static void splitString (std::string str, const std::string delim, std::vector< std::string > &results)
 Split string according to delimiter.
static const int tokenize (const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
 Break string into tokens.
static void trimString (std::string &str)
 Trim string.


Detailed Description

General and CSCDQM Framework related utility routines.

Definition at line 65 of file CSCDQM_Utility.h.


Member Function Documentation

static uint32_t cscdqm::Utility::fastHash ( const char *  data  )  [inline, static]

Definition at line 78 of file CSCDQM_Utility.h.

References fastHash().

00078 { return fastHash(data, strlen(data)); }

uint32_t cscdqm::Utility::fastHash ( const char *  data,
int  len 
) [static]

Calculate super fast hash (from https://www.azillionmonkeys.com/qed/hash.html).

Parameters:
data Source Data
length of data
Returns:
hash result

Definition at line 154 of file CSCDQM_Utility.cc.

References get16bits, NULL, and tmp.

Referenced by fastHash().

00154                                                        {
00155     uint32_t hash = len, tmp;
00156     int rem;
00157   
00158     if (len <= 0 || data == NULL) return 0;
00159     rem = len & 3;
00160     len >>= 2;
00161 
00162     /* Main loop */
00163     for (;len > 0; len--) {
00164       hash  += get16bits (data);
00165       tmp    = (get16bits (data+2) << 11) ^ hash;
00166       hash   = (hash << 16) ^ tmp;
00167       data  += 2*sizeof (uint16_t);
00168       hash  += hash >> 11;
00169     }
00170 
00171     /* Handle end cases */
00172     switch (rem) {
00173       case 3: hash += get16bits (data);
00174               hash ^= hash << 16;
00175               hash ^= data[sizeof (uint16_t)] << 18;
00176               hash += hash >> 11;
00177               break;
00178       case 2: hash += get16bits (data);
00179               hash ^= hash << 11;
00180               hash += hash >> 17;
00181               break;
00182       case 1: hash += *data;
00183               hash ^= hash << 10;
00184               hash += hash >> 1;
00185     }
00186 
00187     /* Force "avalanching" of final 127 bits */
00188     hash ^= hash << 3;
00189     hash += hash >> 5;
00190     hash ^= hash << 4;
00191     hash += hash >> 17;
00192     hash ^= hash << 25;
00193     hash += hash >> 6;
00194 
00195     return hash;
00196   }

const int cscdqm::Utility::getCSCTypeBin ( const std::string &  cstr  )  [static]

Get CSC y-axis position from chamber string.

Parameters:
cstr Chamber string
Returns:
chamber y-axis position

Definition at line 27 of file CSCDQM_Utility.cc.

Referenced by cscdqm::EventProcessor::getCSCFromMap().

00027                                                         {
00028     if (cstr.compare("ME-4/2") == 0) return 0;
00029     if (cstr.compare("ME-4/1") == 0) return 1;
00030     if (cstr.compare("ME-3/2") == 0) return 2;
00031     if (cstr.compare("ME-3/1") == 0) return 3;
00032     if (cstr.compare("ME-2/2") == 0) return 4;
00033     if (cstr.compare("ME-2/1") == 0) return 5;
00034     if (cstr.compare("ME-1/3") == 0) return 6;
00035     if (cstr.compare("ME-1/2") == 0) return 7;
00036     if (cstr.compare("ME-1/1") == 0) return 8;
00037     if (cstr.compare("ME+1/1") == 0) return 9;
00038     if (cstr.compare("ME+1/2") == 0) return 10;
00039     if (cstr.compare("ME+1/3") == 0) return 11;
00040     if (cstr.compare("ME+2/1") == 0) return 12;
00041     if (cstr.compare("ME+2/2") == 0) return 13;
00042     if (cstr.compare("ME+3/1") == 0) return 14;
00043     if (cstr.compare("ME+3/2") == 0) return 15;
00044     if (cstr.compare("ME+4/1") == 0) return 16;
00045     if (cstr.compare("ME+4/2") == 0) return 17;
00046     return 0;
00047   }

const std::string cscdqm::Utility::getCSCTypeLabel ( int  endcap,
int  station,
int  ring 
) [static]

Get CSC label from CSC parameters.

Parameters:
endcap Endcap number
station Station number
ring Ring number
Returns:
chamber label

Definition at line 56 of file CSCDQM_Utility.cc.

References label, and st.

Referenced by cscdqm::EventProcessor::getCSCFromMap().

00056                                                                              {
00057     std::string label = "Unknown";
00058     std::ostringstream st;
00059     if ((endcap > 0) && (station > 0) && (ring > 0)) {
00060       if (endcap == 1) {
00061         st << "ME+" << station << "/" << ring;
00062         label = st.str();
00063       } else if (endcap==2) {
00064         st << "ME-" << station << "/" << ring;
00065         label = st.str();
00066       } else {
00067         label = "Unknown";
00068       }
00069     }
00070     return label;
00071   }

const bool cscdqm::Utility::regexMatch ( const std::string &  expression,
const std::string &  message 
) [static]

Definition at line 134 of file CSCDQM_Utility.cc.

References regexMatch().

00134                                                                                       {
00135     return regexMatch(TPRegexp(expression), message);
00136   }

const bool cscdqm::Utility::regexMatch ( const TPRegexp &  re_expression,
const std::string &  message 
) [static]

Definition at line 129 of file CSCDQM_Utility.cc.

Referenced by cscdqm::Collection::load(), cscdqm::Configuration::needBookMO(), cscdqm::HistoDef::processName(), and regexMatch().

00129                                                                                         {
00130     TPRegexp *re = const_cast<TPRegexp*>(&re_expression);
00131     return re->MatchB(message);
00132   }

void cscdqm::Utility::splitString ( std::string  str,
const std::string  delim,
std::vector< std::string > &  results 
) [static]

Split string according to delimiter.

Parameters:
str String to split
delim Delimiter
results Vector to write results to
Returns:

Definition at line 99 of file CSCDQM_Utility.cc.

00099                                                                                                {
00100     unsigned int cutAt;
00101     while ((cutAt = str.find_first_of(delim)) != str.npos) {
00102       if(cutAt > 0) {
00103         results.push_back(str.substr(0, cutAt));
00104       }
00105       str = str.substr(cutAt + 1);
00106     }
00107     if(str.length() > 0) {
00108       results.push_back(str);
00109     }
00110   }

const int cscdqm::Utility::tokenize ( const std::string &  str,
std::vector< std::string > &  tokens,
const std::string &  delimiters = " " 
) [static]

Break string into tokens.

Parameters:
str source string to break
tokens pointer to result vector
delimiters delimiter string, default " "
Returns:

Definition at line 81 of file CSCDQM_Utility.cc.

Referenced by cscdqm::Collection::book().

00081                                                                                                              {
00082     std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
00083     std::string::size_type pos = str.find_first_of(delimiters, lastPos);
00084     while (std::string::npos != pos || std::string::npos != lastPos) {
00085       tokens.push_back(str.substr(lastPos, pos - lastPos));
00086       lastPos = str.find_first_not_of(delimiters, pos);
00087       pos = str.find_first_of(delimiters, lastPos);
00088     }
00089     return tokens.size();
00090   }

void cscdqm::Utility::trimString ( std::string &  str  )  [static]

Trim string.

Parameters:
str string to trim
Returns:

Definition at line 117 of file CSCDQM_Utility.cc.

Referenced by cscdqm::Detector::AddressFromString().

00117                                          {
00118     std::string::size_type pos = str.find_last_not_of(' ');
00119     if(pos != std::string::npos) {
00120       str.erase(pos + 1);
00121       pos = str.find_first_not_of(' ');
00122       if(pos != std::string::npos) 
00123         str.erase(0, pos);
00124     } else 
00125       str.erase(str.begin(), str.end());
00126   }


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