CMS 3D CMS Logo

CSCDQM_Utility.h
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: CSCDQM_Utility.h
5  *
6  * Description: CSC Utilities class
7  *
8  * Version: 1.0
9  * Created: 10/30/2008 04:40:38 PM
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch
14  * Company: CERN, CH
15  *
16  * =====================================================================================
17  */
18 
19 #ifndef CSCDQM_Utility_H
20 #define CSCDQM_Utility_H
21 
22 #include <string>
23 #include <map>
24 #include <set>
25 #include <vector>
26 #include <sstream>
27 #include <cstdint>
28 #include <cmath>
29 
30 #include <TString.h>
31 #include <TPRegexp.h>
32 
34 
35 namespace cscdqm {
36 
42  template <class T>
43  const std::string toString(T& t) {
44  std::ostringstream st;
45  st << t;
46  std::string result = st.str();
47  return result;
48  }
49 
57  template <class T>
58  bool stringToNumber(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) {
59  std::istringstream iss(s);
60  return !(iss >> f >> t).fail();
61  }
62 
67  class Utility {
68  public:
69  static bool regexMatch(const std::string& expression, const std::string& message);
70  static bool regexMatch(const TPRegexp& re_expression, const std::string& message);
71  static void regexReplace(const std::string& expression, std::string& message, const std::string replace = "");
72  static void regexReplace(const TPRegexp& re_expression, std::string& message, const std::string replace = "");
73  static std::string regexReplaceStr(const std::string& expression,
74  const std::string& message,
75  const std::string replace = "");
76  static std::string regexReplaceStr(const TPRegexp& re_expression,
77  const std::string& message,
78  const std::string replace = "");
79 
80  static int getCSCTypeBin(const std::string& cstr);
81  static std::string getCSCTypeLabel(int endcap, int station, int ring);
82  static int tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters = " ");
83  static void splitString(const std::string& str, const std::string& delim, std::vector<std::string>& results);
84  static void trimString(std::string& str);
85  static uint32_t fastHash(const char* data, int len);
86  static uint32_t fastHash(const char* data) { return fastHash(data, strlen(data)); }
87 
88  static short checkOccupancy(const unsigned int N,
89  const unsigned int n,
90  const double low_threshold,
91  const double high_threshold,
92  const double low_sigfail,
93  const double high_sigfail);
94  static bool checkError(const unsigned int N, const unsigned int n, const double threshold, const double sigfail);
95  static double SignificanceLevelLow(const unsigned int N, const unsigned int n, const double eps);
96  static double SignificanceLevelHigh(const unsigned int N, const unsigned int n);
97 
98  static int getRUIfromDDUId(unsigned ddu_id);
99  };
100 } // namespace cscdqm
101 
102 #endif
FEDNumbering.h
cscdqm::stringToNumber
bool stringToNumber(T &t, const std::string &s, std::ios_base &(*f)(std::ios_base &))
Converting from string to whatever number (failsafe!)
Definition: CSCDQM_Utility.h:58
cscdqm::Utility::splitString
static void splitString(const std::string &str, const std::string &delim, std::vector< std::string > &results)
Split string according to delimiter.
Definition: CSCDQM_Utility.cc:122
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
cscdqm::Utility::SignificanceLevelHigh
static double SignificanceLevelHigh(const unsigned int N, const unsigned int n)
Calculate error significance alpha for the given number of events based on reference number of errors...
Definition: CSCDQM_Utility.cc:385
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
relativeConstraints.station
station
Definition: relativeConstraints.py:67
cscdqm::Utility::SignificanceLevelLow
static double SignificanceLevelLow(const unsigned int N, const unsigned int n, const double eps)
Calculate error significance alpha for the given number of errors based on reference number of errors...
Definition: CSCDQM_Utility.cc:352
bookConverter.results
results
Definition: bookConverter.py:144
cscdqm::Utility::regexMatch
static bool regexMatch(const std::string &expression, const std::string &message)
Match RegExp expression string against string message and return result.
Definition: CSCDQM_Utility.cc:166
cscdqm::Utility::checkError
static bool checkError(const unsigned int N, const unsigned int n, const double threshold, const double sigfail)
Check the hypothesis that error events (n) value above threshold comparing with the expected 0 and st...
Definition: CSCDQM_Utility.cc:331
cscdqm::Utility::fastHash
static uint32_t fastHash(const char *data, int len)
Calculate super fast hash (from http://www.azillionmonkeys.com/qed/hash.html)
Definition: CSCDQM_Utility.cc:242
cscdqm::Utility::regexReplaceStr
static std::string regexReplaceStr(const std::string &expression, const std::string &message, const std::string replace="")
Replace string part that matches RegExp expression with some string.
Definition: CSCDQM_Utility.cc:203
cscdqm::Utility::getRUIfromDDUId
static int getRUIfromDDUId(unsigned ddu_id)
Get RUI Number from DDU source ID for post LS1 configuration.
Definition: CSCDQM_Utility.cc:397
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
cscdqm::Utility::trimString
static void trimString(std::string &str)
Trim string.
Definition: CSCDQM_Utility.cc:136
alignCSCRings.s
s
Definition: alignCSCRings.py:92
str
#define str(s)
Definition: TestProcessor.cc:48
N
#define N
Definition: blowfish.cc:9
cscdqm::Utility::getCSCTypeLabel
static std::string getCSCTypeLabel(int endcap, int station, int ring)
Get CSC label from CSC parameters.
Definition: CSCDQM_Utility.cc:80
OrderedSet.t
t
Definition: OrderedSet.py:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cscdqm::Utility::fastHash
static uint32_t fastHash(const char *data)
Definition: CSCDQM_Utility.h:86
cscdqm::Utility
General and CSCDQM Framework related utility routines.
Definition: CSCDQM_Utility.h:67
cscdqm
Definition: CSCDQM_DCSBase.h:29
cscdqm::Utility::getCSCTypeBin
static int getCSCTypeBin(const std::string &cstr)
Get CSC y-axis position from chamber string.
Definition: CSCDQM_Utility.cc:33
cscdqm::toString
const std::string toString(T &t)
Converting from whatever to string (failsafe!)
Definition: CSCDQM_Utility.h:43
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
cscdqm::Utility::checkOccupancy
static short checkOccupancy(const unsigned int N, const unsigned int n, const double low_threshold, const double high_threshold, const double low_sigfail, const double high_sigfail)
Check the hypothesis that observed events (n) value is too low or too high comparing with the expecte...
Definition: CSCDQM_Utility.cc:302
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cscdqm::Utility::regexReplace
static void regexReplace(const std::string &expression, std::string &message, const std::string replace="")
Replace string part that matches RegExp expression with some string.
Definition: CSCDQM_Utility.cc:177
mps_fire.result
result
Definition: mps_fire.py:303
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:426
cscdqm::Utility::tokenize
static int tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
Break string into tokens.
Definition: CSCDQM_Utility.cc:104
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444