CMS 3D CMS Logo

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