File indexing completed on 2023-03-17 10:54:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef CSCDQM_Utility_H
0020 #define CSCDQM_Utility_H
0021
0022 #include <string>
0023 #include <map>
0024 #include <set>
0025 #include <vector>
0026 #include <sstream>
0027 #include <cstdint>
0028 #include <cmath>
0029
0030 #include <TString.h>
0031 #include <TPRegexp.h>
0032
0033 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0034
0035 namespace cscdqm {
0036
0037
0038
0039
0040
0041
0042 template <class T>
0043 const std::string toString(T& t) {
0044 std::ostringstream st;
0045 st << t;
0046 std::string result = st.str();
0047 return result;
0048 }
0049
0050
0051
0052
0053
0054
0055
0056
0057 template <class T>
0058 bool stringToNumber(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) {
0059 std::istringstream iss(s);
0060 return !(iss >> f >> t).fail();
0061 }
0062
0063
0064
0065
0066
0067 class Utility {
0068 public:
0069 static bool regexMatch(const std::string& expression, const std::string& message);
0070 static bool regexMatch(const TPRegexp& re_expression, const std::string& message);
0071 static void regexReplace(const std::string& expression, std::string& message, const std::string replace = "");
0072 static void regexReplace(const TPRegexp& re_expression, std::string& message, const std::string replace = "");
0073 static std::string regexReplaceStr(const std::string& expression,
0074 const std::string& message,
0075 const std::string replace = "");
0076 static std::string regexReplaceStr(const TPRegexp& re_expression,
0077 const std::string& message,
0078 const std::string replace = "");
0079
0080 static int getCSCTypeBin(const std::string& cstr);
0081 static std::string getCSCTypeLabel(int endcap, int station, int ring);
0082 static int tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters = " ");
0083 static void splitString(const std::string& str, const std::string& delim, std::vector<std::string>& results);
0084 static void trimString(std::string& str);
0085 static uint32_t fastHash(const char* data, int len);
0086 static uint32_t fastHash(const char* data) { return fastHash(data, strlen(data)); }
0087
0088 static short checkOccupancy(const unsigned int N,
0089 const unsigned int n,
0090 const double low_threshold,
0091 const double high_threshold,
0092 const double low_sigfail,
0093 const double high_sigfail);
0094 static bool checkError(const unsigned int N, const unsigned int n, const double threshold, const double sigfail);
0095 static double SignificanceLevelLow(const unsigned int N, const unsigned int n, const double eps);
0096 static double SignificanceLevelHigh(const unsigned int N, const unsigned int n);
0097
0098 static int getRUIfromDDUId(unsigned ddu_id);
0099 };
0100 }
0101
0102 #endif