30 #include <boost/property_tree/xml_parser.hpp>
31 #include <boost/property_tree/ptree.hpp>
90 if (getQualityTestsFromFile) {
94 assert(!
"Reading from DB no longer supported.");
143 for (
auto me : mes) {
148 int match = fnmatch(pattern.c_str(), name.c_str(), 0);
149 if (match == FNM_NOMATCH)
153 <<
"Something went wrong with fnmatch: pattern = '" << pattern <<
"' and string = '" << name <<
"'";
159 me->getQReport(
true, qtest->
getName(), qr, qv);
165 me->syncCoreObject();
171 std::map<std::string, std::vector<std::string>> theAlarms;
173 for (
auto me : mes) {
177 std::vector<QReport*>
report;
179 if (
me->hasError()) {
181 report =
me->getQErrors();
183 if (
me->hasWarning()) {
185 report =
me->getQWarnings();
187 if (
me->hasOtherReport()) {
189 report =
me->getQOthers();
191 for (
auto r : report) {
192 theAlarms[colour].push_back(
r->getMessage());
197 for (
auto& theAlarm : theAlarms) {
199 const std::vector<std::string>& msgs = theAlarm.second;
201 (
reportThreshold ==
"orange" && (alarmType ==
"orange" || alarmType ==
"red")) ||
204 std::cout <<
"Error Type: " << alarmType << std::endl;
205 for (
auto const&
msg : msgs)
216 #define get template get
220 std::function<std::unique_ptr<QCriterion>(boost::property_tree::ptree
const&, std::string&
name)>>
223 auto test = std::make_unique<CheckVariance>(
name);
230 auto test = std::make_unique<CompareLastFilledBin>(
name);
233 test->setAverage(config.get<
float>(
"AvVal"));
234 test->setMin(config.get<
float>(
"MinVal"));
235 test->setMax(config.get<
float>(
"MaxVal"));
240 auto test = std::make_unique<CompareToMedian>(
name);
243 test->setMin(config.get<
float>(
"MinRel"));
244 test->setMax(config.get<
float>(
"MaxRel"));
245 test->setMinMedian(config.get<
float>(
"MinAbs"));
246 test->setMaxMedian(config.get<
float>(
"MaxAbs"));
247 test->setEmptyBins(config.get<
int>(
"UseEmptyBins"));
248 test->setStatCut(config.get<
float>(
"StatCut", 0));
253 auto test = std::make_unique<ContentSigma>(
name);
256 test->setNumXblocks(config.get<
int>(
"Xblocks"));
257 test->setNumYblocks(config.get<
int>(
"Yblocks"));
258 test->setNumNeighborsX(config.get<
int>(
"neighboursX"));
259 test->setNumNeighborsY(config.get<
int>(
"neighboursY"));
260 test->setToleranceNoisy(config.get<
double>(
"toleranceNoisy"));
261 test->setToleranceDead(config.get<
double>(
"toleranceDead"));
262 test->setNoisy(config.get<
double>(
"noisy"));
263 test->setDead(config.get<
double>(
"dead"));
264 test->setXMin(config.get<
int>(
"xMin"));
265 test->setXMax(config.get<
int>(
"xMax"));
266 test->setYMin(config.get<
int>(
"yMin"));
267 test->setYMax(config.get<
int>(
"yMax"));
272 auto test = std::make_unique<ContentsWithinExpected>(
name);
275 test->setUseEmptyBins(config.get<
bool>(
"useEmptyBins"));
276 test->setMinimumEntries(config.get<
int>(
"minEntries"));
277 test->setMeanTolerance(config.get<
float>(
"toleranceMean"));
278 if (config.get<
double>(
"minMean", 0) || config.get<
double>(
"maxMean", 0))
279 test->setMeanRange(config.get<
double>(
"minMean"), config.get<
double>(
"maxMean"));
280 if (config.get<
double>(
"minRMS", 0) || config.get<
double>(
"maxRMS", 0))
281 test->setRMSRange(config.get<
double>(
"minRMS"), config.get<
double>(
"maxRMS"));
286 auto test = std::make_unique<ContentsXRange>(
name);
289 test->setAllowedXRange(config.get<
double>(
"xmin"), config.get<
double>(
"xmax"));
294 auto test = std::make_unique<ContentsYRange>(
name);
297 test->setAllowedYRange(config.get<
double>(
"ymin"), config.get<
double>(
"ymax"));
298 test->setUseEmptyBins(config.get<
bool>(
"useEmptyBins"));
303 auto test = std::make_unique<DeadChannel>(
name);
306 test->setThreshold(config.get<
float>(
"threshold"));
311 auto test = std::make_unique<MeanWithinExpected>(
name);
314 test->setMinimumEntries(config.get<
int>(
"minEntries", 0));
315 test->setExpectedMean(config.get<
double>(
"mean"));
316 if (config.get<
double>(
"useSigma", 0))
317 test->useSigma(config.get<
double>(
"useSigma"));
318 if (config.get<
int>(
"useRMS", 0))
320 if (config.get<
int>(
"useRange", 0))
321 test->useRange(config.get<
float>(
"xmin"), config.get<
float>(
"xmax"));
325 auto test = std::make_unique<NoisyChannel>(
name);
328 test->setTolerance(config.get<
double>(
"tolerance"));
329 test->setNumNeighbors(config.get<
double>(
"neighbours"));
334 auto maker = qtestmakers.find(config.get<std::string>(
"TYPE"));
336 if (maker == qtestmakers.end())
344 boost::property_tree::ptree reordered;
345 for (
auto kv : config) {
347 if (kv.first ==
"PARAM") {
348 reordered.put(kv.second.get<std::string>(
"<xmlattr>.name"), kv.second.data());
352 auto name = config.get<std::string>(
"<xmlattr>.name");
353 return maker->second(reordered,
name);
360 std::unique_ptr<QCriterion> qtest;
361 std::vector<std::string> pathpatterns;
363 std::map<std::string, TestItem> qtestmap;
366 boost::property_tree::ptree xml;
367 boost::property_tree::read_xml(file, xml);
369 auto it = xml.find(
"TESTSCONFIGURATION");
370 if (it == xml.not_found()) {
371 throw cms::Exception(
"QualityTester") <<
"QTest XML needs to have a TESTSCONFIGURATION node.";
373 auto& testconfig = it->second;
374 for (
auto& kv : testconfig) {
376 if (kv.first ==
"QTEST") {
377 auto& qtestconfig = kv.second;
384 if (kv.first ==
"LINK") {
385 auto& linkconfig = kv.second;
386 auto pathpattern = linkconfig.get<
std::string>(
"<xmlattr>.name");
387 for (
auto& subkv : linkconfig) {
388 if (subkv.first ==
"TestName") {
390 bool enabled = subkv.second.get<
bool>(
"<xmlattr>.activate");
393 qtestmap[testname].pathpatterns.push_back(pathpattern);
405 for (
auto& kv : qtestmap) {
407 for (
auto&
p : kv.second.pathpatterns) {
LuminosityBlockID id() const
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
std::vector< std::pair< std::string, QCriterion * > > qtestpatterns
#define DEFINE_FWK_MODULE(type)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
float runTest(const MonitorElement *me, QReport &qr, DQMNet::QValue &qv)
bool getQualityTestsFromFile
~QualityTester() override
Destructor.
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c) override
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
void configureTests(std::string const &file)
static std::string getAlgoName()
void performTests(DQMStore::IGetter &igetter)
static std::string getAlgoName()
static const float ERROR_PROB_THRESHOLD
static std::string getAlgoName()
LuminosityBlockNumber_t luminosityBlock() const
void dqmEndRun(DQMStore::IBooker &, DQMStore::IGetter &, const edm::Run &r, const edm::EventSetup &c) override
static std::string getAlgoName()
tuple config
parse the configuration file
std::string reportThreshold
static std::string getAlgoName()
get algorithm name
QualityTester(const edm::ParameterSet &ps)
Constructor.
std::string getName() const
get name of quality test
std::vector< std::unique_ptr< QCriterion > > qtestobjects
std::string fullPath() const
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
std::unique_ptr< QCriterion > makeQCriterion(boost::property_tree::ptree const &config)
static std::string getAlgoName()
void dqmAnalyze(DQMStore::IBooker &, DQMStore::IGetter &, const edm::Event &e, const edm::EventSetup &c) override
perform the actual quality tests
static std::string getAlgoName()
static const float WARNING_PROB_THRESHOLD
default "probability" values for setting warnings & errors when running tests
static std::string getAlgoName()
static std::string getAlgoName()