CMS 3D CMS Logo

QTestStatusChecker.cc
Go to the documentation of this file.
1 
10 #include <iostream>
11 
13 
15 
16 std::pair<std::string, std::string> QTestStatusChecker::checkGlobalStatus(DQMStore *bei) {
17  std::pair<std::string, std::string> statement;
18  int status = bei->getStatus();
19  switch (status) {
21  statement.first = "Errors detected in quality tests";
22  statement.second = "red";
23  break;
25  statement.first = "Warnings detected in quality tests";
26  statement.second = "orange";
27  break;
29  statement.first = "Some tests did not run";
30  statement.second = "black";
31  break;
32  default:
33  statement.first = "No problems detected in quality tests ";
34  statement.second = "green";
35  }
36 
37  return statement;
38 }
39 
40 std::map<std::string, std::vector<std::string> > QTestStatusChecker::checkDetailedStatus(DQMStore *bei) {
41  std::vector<std::string> allPathNames = this->fullPathNames(bei);
42  detailedWarnings.clear();
43 
44  this->processAlarms(allPathNames, bei);
45  return detailedWarnings;
46 }
47 
48 void QTestStatusChecker::processAlarms(const std::vector<std::string> &allPathNames, DQMStore *bei) {
49  for (std::vector<std::string>::const_iterator fullMePath = allPathNames.begin(); fullMePath != allPathNames.end();
50  ++fullMePath) {
51  MonitorElement *me = nullptr;
52  me = bei->get(*fullMePath);
53 
54  if (me) {
55  std::vector<QReport *> report;
56  std::string colour;
57 
58  if (me->hasError()) {
59  colour = "red";
60  report = me->getQErrors();
61  }
62  if (me->hasWarning()) {
63  colour = "orange";
64  report = me->getQWarnings();
65  }
66  if (me->hasOtherReport()) {
67  colour = "black";
68  report = me->getQOthers();
69  }
70  for (std::vector<QReport *>::iterator itr = report.begin(); itr != report.end(); ++itr) {
71  std::string text = (*fullMePath) + (*itr)->getMessage();
72  std::vector<std::string> messageList;
73 
74  if (detailedWarnings.find(colour) == detailedWarnings.end()) {
75  messageList.push_back(text);
76  detailedWarnings[colour] = messageList;
77 
78  } else {
79  messageList = detailedWarnings[colour];
80  messageList.push_back(text);
81  detailedWarnings[colour] = messageList;
82  }
83  }
84  }
85  }
86 }
87 
88 std::vector<std::string> QTestStatusChecker::fullPathNames(DQMStore *bei) {
89  std::vector<std::string> contents;
90  std::vector<std::string> contentVec;
91  bei->getContents(contentVec);
92  for (std::vector<std::string>::iterator it = contentVec.begin(); it != contentVec.end(); it++) {
93  std::string::size_type dirCharNumber = it->find(":", 0);
94  std::string dirName = it->substr(0, dirCharNumber);
95  dirName += "/";
96  std::string meCollectionName = it->substr(dirCharNumber + 1);
97 
98  std::string reminingNames = meCollectionName;
99  bool anotherME = true;
100  while (anotherME) {
101  if (reminingNames.find(",") == std::string::npos)
102  anotherME = false;
103  std::string::size_type singleMeNameCharNumber = reminingNames.find(",", 0);
104  std::string singleMeName = reminingNames.substr(0, singleMeNameCharNumber);
105  std::string fullpath = dirName + singleMeName;
106  contents.push_back(fullpath);
107  reminingNames = reminingNames.substr(singleMeNameCharNumber + 1);
108  }
109  }
110 
111  return contents;
112 }
std::vector< QReport * > getQWarnings() const
get warnings from last set of quality tests
static const int OTHER
~QTestStatusChecker()
Destructor.
std::vector< MonitorElement * > getContents(std::string const &path) const
Definition: DQMStore.cc:1520
static const int WARNING
bool hasOtherReport() const
true if at least of one of the tests returned some other (non-ok) status
uint16_t size_type
int getStatus(std::string const &path="") const
Definition: DQMStore.cc:2903
std::vector< QReport * > getQErrors() const
get errors from last set of quality tests
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1509
bool hasWarning() const
true if at least of one of the quality tests returned a warning
void processAlarms(const std::vector< std::string > &allPathNames, DQMStore *bei)
std::vector< QReport * > getQOthers() const
from last set of quality tests
bool hasError() const
true if at least of one of the quality tests returned an error
std::vector< std::string > fullPathNames(DQMStore *bei)
std::pair< std::string, std::string > checkGlobalStatus(DQMStore *bei)
Check global status of Quality tests, returns a pair of string: message and color relative to global ...
std::map< std::string, std::vector< std::string > > checkDetailedStatus(DQMStore *bei)
Check status of quality tests for individual ME&#39;s.
static const int ERROR
std::map< std::string, std::vector< std::string > > detailedWarnings