CMS 3D CMS Logo

QTestHandle.cc
Go to the documentation of this file.
1 
14 #include "boost/scoped_ptr.hpp"
15 #include <atomic>
16 
17 namespace {
18  std::atomic<bool> firstTime{true};
19 }
20 
22 {
26 
27  testsConfigured = false;
28 
29 }
30 
32 {
33  delete qtParser;
34  delete qtConfigurer;
35  delete qtChecker;
36 }
37 
38 bool QTestHandle::configureTests(const std::string &configFile, DQMStore *bei, bool UseDB)
39 {
40  //In case of UseDB==true the configFile is the content of the xml file itself
41  //In case of UseDB==false (default) configFile is just the name of the file
42  if (testsConfigured)
43  qtParser->getNewDocument(configFile,UseDB);
44  else
45  {
46  qtParser->getDocument(configFile,UseDB);
47  testsConfigured=true;
48  }
49 
51  {
52  std::map<std::string, std::map<std::string, std::string> > testsONList
53  = qtParser->testsList();
54 
55  if (qtConfigurer->enableTests(testsONList,bei))
56  return true;
57  }
58  else
59  return true;
60 
61  return false;
62 }
63 
64 
66 {
67 
68  std::map<std::string, std::vector<std::string> > mapMeToTests
70 
71  //If firstTime is true, then firstCaller will be true
72  bool expected = true;
73  const bool firstCaller = firstTime.compare_exchange_strong(expected,false);
74 
75  for (std::map<std::string, std::vector<std::string> >::iterator itr = mapMeToTests.begin();
76  itr != mapMeToTests.end();
77  ++itr)
78  {
79  const std::string &meName = itr->first;
80  const std::vector<std::string> &tests = itr->second;
81 
82  for (std::vector<std::string>::const_iterator testsItr = tests.begin();
83  testsItr != tests.end(); ++testsItr){
84  int cases = bei->useQTestByMatch(meName, *testsItr);
85  if (firstCaller && verboseQT && cases == 0)
86  edm::LogWarning ("QTestHandle::attachTests")
87  << " ==>> Invalid qtest xml: Link '"<< meName
88  <<"', QTest '"<< *testsItr << "' - no matching ME! <<== ";
89  }
90  }
91 }
92 
93 std::pair<std::string,std::string>
95 {
96  return qtChecker->checkGlobalStatus(bei);
97 }
98 
99 std::map< std::string, std::vector<std::string> >
101 {
102  return qtChecker->checkDetailedStatus(bei);
103 }
QTestHandle()
Creator.
Definition: QTestHandle.cc:21
void getDocument(std::string configFile, bool UseDB=false)
Methor that parses the xml file configFile.
std::map< std::string, std::vector< std::string > > checkDetailedQTStatus(DQMStore *bei) const
Checks alarms for single MonitorElements.
Definition: QTestHandle.cc:100
bool parseQTestsConfiguration()
Methor that parses the xml file configFile, returns false if no errors are encountered.
void attachTests(DQMStore *bei, bool verboseQT=true)
Attaches the quality tests to the MonitorElement.
Definition: QTestHandle.cc:65
~QTestHandle()
Destructor.
Definition: QTestHandle.cc:31
std::pair< std::string, std::string > checkGlobalQTStatus(DQMStore *bei) const
Checks global status of Quality Tests.
Definition: QTestHandle.cc:94
QTestConfigurationParser * qtParser
Definition: QTestHandle.h:36
std::map< std::string, std::map< std::string, std::string > > testsList() const
Returns the Quality Tests list with their parameters obtained from the xml file.
QTestConfigure * qtConfigurer
Definition: QTestHandle.h:37
void getNewDocument(std::string configFile, bool UseDB=false)
Parses a new Document.
std::map< std::string, std::vector< std::string > > meToTestsList() const
Returns the map between the MonitoElemnt and the list of tests requested for it.
QTestStatusChecker * qtChecker
Definition: QTestHandle.h:38
bool testsConfigured
Definition: QTestHandle.h:39
int useQTestByMatch(const std::string &pattern, const std::string &qtname)
attach quality test <qc> to monitor elements matching <pattern>.
Definition: DQMStore.cc:3314
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 ...
bool configureTests(const std::string &configFile, DQMStore *bei, bool UseDB=false)
Parses Config File and configures the quality tests.
Definition: QTestHandle.cc:38
std::map< std::string, std::vector< std::string > > checkDetailedStatus(DQMStore *bei)
Check status of quality tests for individual ME&#39;s.
bool enableTests(const std::map< std::string, std::map< std::string, std::string > > &tests, DQMStore *bei)
Creates and defines quality tests.