From 6a8e043d52c7f7bbc930141fddf7e0a04c6616ec Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 29 Oct 2019 11:30:04 +0100 Subject: [PATCH 01/12] Stub out SiStripCommissioningClients SummaryPlotXmlParser --- .../interface/SummaryPlotXmlParser.h | 22 +-- .../src/SummaryPlotXmlParser.cc | 147 +----------------- 2 files changed, 5 insertions(+), 164 deletions(-) diff --git a/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h b/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h index a7ada0a37990b..9a1ab3d0221c9 100644 --- a/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h +++ b/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h @@ -3,14 +3,15 @@ #include "DataFormats/SiStripCommon/interface/SiStripConstants.h" #include "DQM/SiStripCommissioningSummary/interface/SummaryPlot.h" -#include "DQMServices/ClientConfig/interface/DQMParserBase.h" -#include "DQMServices/ClientConfig/interface/ParserFunctions.h" #include #include #include #include #include +#include +#include + class SummaryPlotXmlParser; /** Debug information. */ @@ -22,16 +23,13 @@ std::ostream& operator<<(std::ostream&, const SummaryPlotXmlParser&); @brief Parses the "summary plot" xml configuration file */ -class SummaryPlotXmlParser : public DQMParserBase { +class SummaryPlotXmlParser { public: // ---------- Co(de)nstructors and consts ---------- /** Default constructor. */ SummaryPlotXmlParser(); - /** Default destructor. */ - ~SummaryPlotXmlParser() override { ; } - // ---------- Public interface ---------- /** Fill the map with the required tag/names and values */ @@ -49,18 +47,6 @@ class SummaryPlotXmlParser : public DQMParserBase { /** Container holding the SummaryPlot objects. */ std::map > plots_; - // RunType tags and attributes - static const std::string rootTag_; - static const std::string runTypeTag_; - static const std::string runTypeAttr_; - - // SummaryPlot tags and attributes - static const std::string summaryPlotTag_; - static const std::string monitorableAttr_; - static const std::string presentationAttr_; - static const std::string viewAttr_; - static const std::string levelAttr_; - static const std::string granularityAttr_; }; #endif // DQM_SiStripCommissioningClients_SummaryPlotXmlParser_H diff --git a/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc b/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc index 2e4ea33e500e3..86bfb9efcd81c 100644 --- a/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc +++ b/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc @@ -3,30 +3,9 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include -using namespace xercesc; using namespace sistrip; -// ----------------------------------------------------------------------------- -// -const std::string SummaryPlotXmlParser::rootTag_ = "root"; -const std::string SummaryPlotXmlParser::runTypeTag_ = "RunType"; -const std::string SummaryPlotXmlParser::runTypeAttr_ = "name"; -const std::string SummaryPlotXmlParser::summaryPlotTag_ = "SummaryPlot"; -const std::string SummaryPlotXmlParser::monitorableAttr_ = "monitorable"; -const std::string SummaryPlotXmlParser::presentationAttr_ = "presentation"; -const std::string SummaryPlotXmlParser::viewAttr_ = "view"; -const std::string SummaryPlotXmlParser::levelAttr_ = "level"; -const std::string SummaryPlotXmlParser::granularityAttr_ = "granularity"; - -// ----------------------------------------------------------------------------- -// SummaryPlotXmlParser::SummaryPlotXmlParser() { - plots_.clear(); - try { - cms::concurrency::xercesInitialize(); - } catch (const XMLException& f) { - throw(std::runtime_error("Standard pool exception : Fatal Error on pool::TrivialFileCatalog")); - } } // ----------------------------------------------------------------------------- @@ -48,131 +27,7 @@ std::vector SummaryPlotXmlParser::summaryPlots(const sistrip::RunTy // void SummaryPlotXmlParser::parseXML(const std::string& f) { plots_.clear(); - - try { - // Create parser and open XML document - getDocument(f); - - // Retrieve root element - DOMElement* root = this->doc()->getDocumentElement(); - if (!root) { - std::stringstream ss; - ss << "[SummaryPlotXmlParser::" << __func__ << "]" - << " Unable to find any elements!" - << " Empty xml document?..."; - throw(std::runtime_error(ss.str())); - } - - // Check on "root" tag - if (!XMLString::equals(root->getTagName(), XMLString::transcode(rootTag_.c_str()))) { - std::stringstream ss; - ss << "[SummaryPlotXmlParser::" << __func__ << "]" - << " Did not find \"" << rootTag_ << "\" tag! " - << " Tag name is " << XMLString::transcode(root->getNodeName()); - edm::LogWarning(mlDqmClient_) << ss.str(); - return; - } - - // Retrieve nodes in xml document - DOMNodeList* nodes = root->getChildNodes(); - if (nodes->getLength() == 0) { - std::stringstream ss; - ss << "[SummaryPlotXmlParser::" << __func__ << "]" - << " Unable to find any children nodes!" - << " Empty xml document?..."; - throw(std::runtime_error(ss.str())); - return; - } - - // LogTrace(mlDqmClient_) - // << "[SummaryPlotXmlParser::" << __func__ << "]" - // << " Found \"" << rootTag_ << "\" tag!"; - - // LogTrace(mlDqmClient_) - // << "[SummaryPlotXmlParser::" << __func__ << "]" - // << " Found " << nodes->getLength() - // << " children nodes!"; - - // Iterate through nodes - for (XMLSize_t inode = 0; inode < nodes->getLength(); ++inode) { - // Check on whether node is element - DOMNode* node = nodes->item(inode); - if (node->getNodeType() && node->getNodeType() == DOMNode::ELEMENT_NODE) { - DOMElement* element = dynamic_cast(node); - if (!element) { - continue; - } - - if (XMLString::equals(element->getTagName(), XMLString::transcode(runTypeTag_.c_str()))) { - const XMLCh* attr = element->getAttribute(XMLString::transcode(runTypeAttr_.c_str())); - sistrip::RunType run_type = SiStripEnumsAndStrings::runType(XMLString::transcode(attr)); - - // std::stringstream ss; - // ss << "[SummaryPlotXmlParser::" << __func__ << "]" - // << " Found \"" << runTypeTag_ << "\" tag!" << std::endl - // << " with tag name \"" << XMLString::transcode(element->getNodeName()) << "\"" << std::endl - // << " and attr \"" << runTypeAttr_ << "\" with value \"" << XMLString::transcode(attr) << "\""; - // LogTrace(mlDqmClient_) << ss.str(); - - // Retrieve nodes in xml document - DOMNodeList* children = node->getChildNodes(); - if (nodes->getLength() == 0) { - std::stringstream ss; - ss << "[SummaryPlotXmlParser::" << __func__ << "]" - << " Unable to find any children nodes!" - << " Empty xml document?..."; - throw(std::runtime_error(ss.str())); - return; - } - - // Iterate through nodes - for (XMLSize_t jnode = 0; jnode < children->getLength(); ++jnode) { - // Check on whether node is element - DOMNode* child = children->item(jnode); - if (child->getNodeType() && child->getNodeType() == DOMNode::ELEMENT_NODE) { - DOMElement* elem = dynamic_cast(child); - if (!elem) { - continue; - } - - if (XMLString::equals(elem->getTagName(), XMLString::transcode(summaryPlotTag_.c_str()))) { - const XMLCh* mon = elem->getAttribute(XMLString::transcode(monitorableAttr_.c_str())); - const XMLCh* pres = elem->getAttribute(XMLString::transcode(presentationAttr_.c_str())); - const XMLCh* level = elem->getAttribute(XMLString::transcode(levelAttr_.c_str())); - const XMLCh* gran = elem->getAttribute(XMLString::transcode(granularityAttr_.c_str())); - - SummaryPlot plot(XMLString::transcode(mon), - XMLString::transcode(pres), - XMLString::transcode(gran), - XMLString::transcode(level)); - plots_[run_type].push_back(plot); - - // std::stringstream ss; - // ss << "[SummaryPlotXmlParser::" << __func__ << "]" - // << " Found \"" << summaryPlotTag_ << "\" tag!" << std::endl - // << " with tag name \"" << XMLString::transcode(elem->getNodeName()) << "\"" << std::endl - // << " and attr \"" << monitorableAttr_ << "\" with value \"" << XMLString::transcode(mon) << "\"" << std::endl - // << " and attr \"" << presentationAttr_ << "\" with value \"" << XMLString::transcode(pres) << "\"" << std::endl - // //<< " and attr \"" << viewAttr_ << "\" with value \"" << XMLString::transcode(view) << "\"" << std::endl - // << " and attr \"" << levelAttr_ << "\" with value \"" << XMLString::transcode(level) << "\"" << std::endl - // << " and attr \"" << granularityAttr_ << "\" with value \"" << XMLString::transcode(gran) << "\""; - // LogTrace(mlDqmClient_) << ss.str(); - - // Update SummaryPlot object and push back into map - } - } - } - } - } - } - - } catch (XMLException& e) { - char* message = XMLString::transcode(e.getMessage()); - std::ostringstream ss; - ss << "[SummaryPlotXmlParser::" << __func__ << "]" - << " Error parsing file: " << message << std::flush; - XMLString::release(&message); - } + // TODO: implement parser based on property tree. } // ----------------------------------------------------------------------------- From 2f9fd60192bebb29804a9326506fad98cfb48afa Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 29 Oct 2019 11:54:46 +0100 Subject: [PATCH 02/12] Stub out xml stuff in SiPixelMonitorClient. --- .../interface/SiPixelConfigParser.h | 10 +- .../interface/SiPixelLayoutParser.h | 6 +- .../src/SiPixelConfigParser.cc | 464 +----------------- .../src/SiPixelConfigWriter.cc | 46 -- .../src/SiPixelLayoutParser.cc | 56 +-- 5 files changed, 31 insertions(+), 551 deletions(-) diff --git a/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h b/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h index 5b1733711697c..4aaf768589792 100644 --- a/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h +++ b/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h @@ -8,19 +8,21 @@ * \author Petra Merkel */ -#include "DQMServices/ClientConfig/interface/DQMParserBase.h" #include #include #include #include -class SiPixelConfigParser : public DQMParserBase { +#include +#include + + +class SiPixelConfigParser { public: // Constructor SiPixelConfigParser(); - // Destructor - ~SiPixelConfigParser() override; + void getDocument(std::string filename); // get List of MEs for TrackerMap bool getMENamesForTrackerMap(std::string &tkmap_name, std::vector &me_names); diff --git a/DQM/SiPixelMonitorClient/interface/SiPixelLayoutParser.h b/DQM/SiPixelMonitorClient/interface/SiPixelLayoutParser.h index 5a0b2d9426cf0..8193e303794b3 100644 --- a/DQM/SiPixelMonitorClient/interface/SiPixelLayoutParser.h +++ b/DQM/SiPixelMonitorClient/interface/SiPixelLayoutParser.h @@ -8,20 +8,16 @@ * \author Suchandra Dutta */ -#include "DQMServices/ClientConfig/interface/DQMParserBase.h" #include #include #include #include -class SiPixelLayoutParser : public DQMParserBase { +class SiPixelLayoutParser { public: // Constructor SiPixelLayoutParser(); - // Destructor - ~SiPixelLayoutParser() override; - // Get list of Layouts for ME groups bool getAllLayouts(std::map> &me_names); diff --git a/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc b/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc index 1c00554fd14a8..4240cd4a00aa8 100644 --- a/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc +++ b/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc @@ -1,512 +1,88 @@ #include "DQM/SiPixelMonitorClient/interface/ANSIColors.h" #include "DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h" -#include "DQMServices/ClientConfig/interface/ParserFunctions.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include -using namespace xercesc; using namespace std; // // -- Constructor // -SiPixelConfigParser::SiPixelConfigParser() : DQMParserBase() { +SiPixelConfigParser::SiPixelConfigParser() { edm::LogInfo("SiPixelConfigParser") << " Creating SiPixelConfigParser " << "\n"; } -// -// -- Destructor -// -SiPixelConfigParser::~SiPixelConfigParser() { - edm::LogInfo("SiPixelActionExecutor") << " Deleting SiPixelConfigParser " - << "\n"; + +void SiPixelConfigParser::getDocument(std::string filename) { + //TODO: implement new parser using property_tree } + // // -- Read ME list for the TrackerMap // bool SiPixelConfigParser::getMENamesForTrackerMap(string &tkmap_name, vector &me_names) { - if (!doc()) { - cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl; - return false; - } - - me_names.clear(); - unsigned int tkMapNodes = doc()->getElementsByTagName(qtxml::_toDOMS("TkMap"))->getLength(); - if (tkMapNodes != 1) { - cout << ACYellow << ACBold << "[SiPixelConfigParser::getMENamesForTrackerMap()]" << ACRed << ACBold - << "No TkMap tag found in configuration file" << ACPlain << endl; - return false; - } - /// Get Node - DOMNode *tkMapNode = doc()->getElementsByTagName(qtxml::_toDOMS("TkMap"))->item(0); - // Get QTEST name - if (!tkMapNode) { - cout << ACYellow << ACBold << "[SiPixelConfigParser::getMENamesForTrackerMap()]" << ACRed << ACBold - << " No TkMap tag elements found in configuration file" << ACPlain << endl; - return false; - } - DOMElement *tkMapElement = static_cast(tkMapNode); - if (!tkMapElement) { - cout << ACYellow << ACBold << "[SiPixelConfigParser::getMENamesForTrackerMap()]" << ACRed << ACBold - << " No TkMap tag dom elements found in configuration file" << ACPlain << endl; - return false; - } - tkmap_name = qtxml::_toString(tkMapElement->getAttribute(qtxml::_toDOMS("name"))); - - DOMNodeList *meList = tkMapElement->getElementsByTagName(qtxml::_toDOMS("MonElement")); - if (meList->getLength() == 0) { - cout << ACYellow << ACBold << "[SiPixelConfigParser::getMENamesForTrackerMap()]" << ACRed << ACBold - << " No MonElement found in configuration file" << ACPlain << endl; - } - for (unsigned int k = 0; k < meList->getLength(); k++) { - DOMNode *meNode = meList->item(k); - if (!meNode) { - cout << ACYellow << ACBold << "[SiPixelConfigParser::getMENamesForTrackerMap()]" << ACRed << ACBold - << " No MonElement item found in configuration file" << ACPlain << endl; - return false; - } - DOMElement *meElement = static_cast(meNode); - if (!meElement) { - cout << ACYellow << ACBold << "[SiPixelConfigParser::getMENamesForTrackerMap()]" << ACRed << ACBold - << " No MonElement sub-elements found in configuration file" << ACPlain << endl; - return false; - } - string me_name = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("name"))); - me_names.push_back(me_name); - } - if (me_names.empty()) { - cout << ACYellow << ACBold << "[SiPixelConfigParser::getMENamesForTrackerMap()]" << ACRed << ACBold - << " No MonElement sub-element names found in configuration file" << ACPlain << endl; - return false; - } else { - return true; - } + return false; } // // -- Read Update Frequency for the TrackerMap // bool SiPixelConfigParser::getFrequencyForTrackerMap(int &u_freq) { - if (!doc()) { - cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl; - return false; - } - - unsigned int tkMapNodes = doc()->getElementsByTagName(qtxml::_toDOMS("TkMap"))->getLength(); - if (tkMapNodes != 1) - return false; - /// Get Node - DOMNode *tkMapNode = doc()->getElementsByTagName(qtxml::_toDOMS("TkMap"))->item(0); - // Get Node name - if (!tkMapNode) - return false; - DOMElement *tkMapElement = static_cast(tkMapNode); - if (!tkMapElement) - return false; - - u_freq = atoi(qtxml::_toString(tkMapElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str()); - return true; + return false; } // // -- Get List of MEs for the module tree plots: // bool SiPixelConfigParser::getMENamesForTree(string &structure_name, vector &me_names) { - // cout<<"Entering SiPixelConfigParser::getMENamesForTree..."<getElementsByTagName(qtxml::_toDOMS("SubStructureLevel"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureLevel"))->item(0); - // Get QTEST name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); - - DOMNodeList *meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement")); - for (unsigned int k = 0; k < meList->getLength(); k++) { - DOMNode *meNode = meList->item(k); - if (!meNode) - return false; - DOMElement *meElement = static_cast(meNode); - if (!meElement) - return false; - string me_name = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("name"))); - me_names.push_back(me_name); - } - if (me_names.empty()) - return false; - else - return true; - // cout<<"...leaving SiPixelConfigParser::getMENamesForTree!"< &me_names) { - // cout<<"Entering SiPixelConfigParser::getMENamesForBarrelSummary..."<getElementsByTagName(qtxml::_toDOMS("SubStructureBarrelLevel"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureBarrelLevel"))->item(0); - // Get QTEST name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); - - DOMNodeList *meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement")); - for (unsigned int k = 0; k < meList->getLength(); k++) { - DOMNode *meNode = meList->item(k); - if (!meNode) - return false; - DOMElement *meElement = static_cast(meNode); - if (!meElement) - return false; - string me_name = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("name"))); - me_names.push_back(me_name); - } - // cout<<"...leaving SiPixelConfigParser::getMENamesForBarrelSummary!"< &me_names) { - // cout<<"Entering SiPixelConfigParser::getMENamesForEndcapSummary..."<getElementsByTagName(qtxml::_toDOMS("SubStructureEndcapLevel"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureEndcapLevel"))->item(0); - // Get QTEST name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); - - DOMNodeList *meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement")); - for (unsigned int k = 0; k < meList->getLength(); k++) { - DOMNode *meNode = meList->item(k); - if (!meNode) - return false; - DOMElement *meElement = static_cast(meNode); - if (!meElement) - return false; - string me_name = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("name"))); - me_names.push_back(me_name); - } - if (me_names.empty()) - return false; - else - return true; - // cout<<"...leaving SiPixelConfigParser::getMENamesForEndcapSummary!"< &me_names) { - // cout<<"Entering - // SiPixelConfigParser::getMENamesForFEDErrorSummary..."<getElementsByTagName(qtxml::_toDOMS("SubStructureNonDetId"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureNonDetId"))->item(0); - // Get QTEST name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); - - DOMNodeList *meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement")); - for (unsigned int k = 0; k < meList->getLength(); k++) { - DOMNode *meNode = meList->item(k); - if (!meNode) - return false; - DOMElement *meElement = static_cast(meNode); - if (!meElement) - return false; - string me_name = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("name"))); - me_names.push_back(me_name); - } - if (me_names.empty()) - return false; - else - return true; - // cout<<"...leaving - // SiPixelConfigParser::getMENamesForFEDErrorSummary!"<getElementsByTagName(qtxml::_toDOMS("SubStructureBarrelLevel"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureBarrelLevel"))->item(0); - // Get Node name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str()); - return true; + return false; } bool SiPixelConfigParser::getFrequencyForEndcapSummary(int &u_freq) { - if (!doc()) { - cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl; - return false; - } - - unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureEndcapLevel"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureEndcapLevel"))->item(0); - // Get Node name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str()); - return true; + return false; } bool SiPixelConfigParser::getMENamesForGrandBarrelSummary(string &structure_name, vector &me_names) { - // cout<<"Entering - // SiPixelConfigParser::getMENamesForGrandBarrelSummary..."<getElementsByTagName(qtxml::_toDOMS("SubStructureGrandBarrelLevel"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandBarrelLevel"))->item(0); - // Get QTEST name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); - - DOMNodeList *meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement")); - for (unsigned int k = 0; k < meList->getLength(); k++) { - DOMNode *meNode = meList->item(k); - if (!meNode) - return false; - DOMElement *meElement = static_cast(meNode); - if (!meElement) - return false; - string me_name = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("name"))); - me_names.push_back(me_name); - } - if (me_names.empty()) - return false; - else - return true; - // cout<<"...leaving - // SiPixelConfigParser::getMENamesForGrandBarrelSummary!"< &me_names) { - // cout<<"Entering - // SiPixelConfigParser::getMENamesForGrandEndcapSummary..."<getElementsByTagName(qtxml::_toDOMS("SubStructureGrandEndcapLevel"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandEndcapLevel"))->item(0); - // Get QTEST name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - structure_name = qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("name"))); - - DOMNodeList *meList = structureElement->getElementsByTagName(qtxml::_toDOMS("MonElement")); - for (unsigned int k = 0; k < meList->getLength(); k++) { - DOMNode *meNode = meList->item(k); - if (!meNode) - return false; - DOMElement *meElement = static_cast(meNode); - if (!meElement) - return false; - string me_name = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("name"))); - me_names.push_back(me_name); - } - if (me_names.empty()) - return false; - else - return true; - // cout<<"...leaving - // SiPixelConfigParser::getMENamesForGrandEndcapSummary!"<getElementsByTagName(qtxml::_toDOMS("SubStructureGrandBarrelLevel"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandBarrelLevel"))->item(0); - // Get Node name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str()); - return true; + return false; } bool SiPixelConfigParser::getFrequencyForGrandEndcapSummary(int &u_freq) { - if (!doc()) { - cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl; - return false; - } - - unsigned int structureNodes = - doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandEndcapLevel"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SubStructureGrandEndcapLevel"))->item(0); - // Get Node name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str()); - return true; + return false; } bool SiPixelConfigParser::getMessageLimitForQTests(int &u_freq) { - if (!doc()) { - cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl; - return false; - } - unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("QTestMessageLimit"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("QTestMessageLimit"))->item(0); - // Get Node name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("value"))).c_str()); - return true; + return false; } bool SiPixelConfigParser::getSourceType(int &u_freq) { - if (!doc()) { - cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl; - return false; - } - unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SourceType"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("SourceType"))->item(0); - // Get Node name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("code"))).c_str()); - return true; + return false; } bool SiPixelConfigParser::getCalibType(int &u_freq) { - if (!doc()) { - cout << " SiPixelConfigParser::Configuration File is not set!!! " << endl; - return false; - } - unsigned int structureNodes = doc()->getElementsByTagName(qtxml::_toDOMS("CalibType"))->getLength(); - if (structureNodes == 0) - return false; - /// Get Node - DOMNode *structureNode = doc()->getElementsByTagName(qtxml::_toDOMS("CalibType"))->item(0); - // Get Node name - if (!structureNode) - return false; - DOMElement *structureElement = static_cast(structureNode); - if (!structureElement) - return false; - - u_freq = atoi(qtxml::_toString(structureElement->getAttribute(qtxml::_toDOMS("value"))).c_str()); - return true; + return false; } diff --git a/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc b/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc index 4a9adfea94228..85ce7cacc2503 100644 --- a/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc +++ b/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc @@ -1,9 +1,7 @@ #include "DQM/SiPixelMonitorClient/interface/SiPixelConfigWriter.h" -#include "DQMServices/ClientConfig/interface/ParserFunctions.h" #include -using namespace xercesc; using namespace std; // // -- Constructor @@ -17,69 +15,25 @@ SiPixelConfigWriter::~SiPixelConfigWriter() {} // -- Initialize XML // bool SiPixelConfigWriter::init() { - try { - cms::concurrency::xercesInitialize(); - } catch (const XMLException &toCatch) { - cout << "Problem to initialise XML !!! " << endl; - return false; - } - unique_ptr domImpl(DOMImplementationRegistry::getDOMImplementation(qtxml::_toDOMS("Range"))); - if (domImpl == nullptr) - return false; - theDomWriter = domImpl->createLSSerializer(); - if (theDomWriter == nullptr) - return false; - if (theDomWriter->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true)) - theDomWriter->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true); - theDoc = domImpl->createDocument(nullptr, qtxml::_toDOMS("Layouts"), nullptr); - if (theDoc == nullptr) - return false; - theTopElement = theDoc->getDocumentElement(); - theTopElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n"))); - theOutput = domImpl->createLSOutput(); - if (theOutput == nullptr) - return false; return true; } // // -- Add an Element // void SiPixelConfigWriter::createLayout(string &name) { - theLastLayout = theDoc->createElement(qtxml::_toDOMS("layout")); - theLastLayout->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name)); - theTopElement->appendChild(theLastLayout); } // // -- Add an Element // void SiPixelConfigWriter::createRow() { - theLastLayout->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n"))); - - theLastRow = theDoc->createElement(qtxml::_toDOMS("row")); - theLastLayout->appendChild(theLastRow); - theLastLayout->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n"))); } // // -- Add an Element with Children // void SiPixelConfigWriter::createColumn(string &element, string &name) { - theLastRow->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n"))); - DOMElement *e1 = theDoc->createElement(qtxml::_toDOMS("column")); - theLastRow->appendChild(e1); - - DOMElement *e2 = theDoc->createElement(qtxml::_toDOMS(element)); - e2->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name)); - e1->appendChild(e2); } // // -- Write to File // void SiPixelConfigWriter::write(string &fname) { - XMLFormatTarget *formTarget = new LocalFileFormatTarget(fname.c_str()); - theOutput->setByteStream(formTarget); - theDomWriter->write(theTopElement, theOutput); - delete formTarget; - theOutput->release(); - theDoc->release(); - theDomWriter->release(); } diff --git a/DQM/SiPixelMonitorClient/src/SiPixelLayoutParser.cc b/DQM/SiPixelMonitorClient/src/SiPixelLayoutParser.cc index 3337da1d66bc6..b901a1e2381f8 100644 --- a/DQM/SiPixelMonitorClient/src/SiPixelLayoutParser.cc +++ b/DQM/SiPixelMonitorClient/src/SiPixelLayoutParser.cc @@ -1,70 +1,22 @@ #include "DQM/SiPixelMonitorClient/interface/SiPixelLayoutParser.h" -#include "DQMServices/ClientConfig/interface/ParserFunctions.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include -using namespace xercesc; using namespace std; // // -- Constructor // -SiPixelLayoutParser::SiPixelLayoutParser() : DQMParserBase() { +SiPixelLayoutParser::SiPixelLayoutParser() { edm::LogInfo("SiPixelLayoutParser") << " Creating SiPixelLayoutParser " << "\n"; cout << " Creating SiPixelLayoutParser " << endl; } -// -// -- Destructor -// -SiPixelLayoutParser::~SiPixelLayoutParser() { - edm::LogInfo("SiPixelActionExecutor") << " Deleting SiPixelLayoutParser " - << "\n"; -} + // // -- Get list of Layouts for ME groups // bool SiPixelLayoutParser::getAllLayouts(map> &layouts) { - if (!doc()) { - cout << " SiPixelLayoutParser::Configuration File is not set!!! " << endl; - return false; - } - - layouts.clear(); - - DOMNodeList *layoutList = doc()->getElementsByTagName(qtxml::_toDOMS("layout")); - - unsigned int nlayout = layoutList->getLength(); - if (nlayout == 0) - return false; - - for (unsigned int k = 0; k < layoutList->getLength(); k++) { - DOMNode *layoutNode = layoutList->item(k); - if (!layoutNode) - return false; - - DOMElement *layoutElement = static_cast(layoutNode); - if (!layoutElement) - return false; - string layoutName = qtxml::_toString(layoutElement->getAttribute(qtxml::_toDOMS("name"))); - - DOMNodeList *meList = layoutElement->getElementsByTagName(qtxml::_toDOMS("monitorable")); - vector me_names; - for (unsigned int l = 0; l < meList->getLength(); l++) { - DOMNode *meNode = meList->item(l); - if (!meNode) - return false; - DOMElement *meElement = static_cast(meNode); - if (!meElement) - return false; - string meName = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("name"))); - me_names.push_back(meName); - } - if (!me_names.empty()) - layouts[layoutName] = me_names; - } - if (!layouts.empty()) - return true; - else - return false; + // TODO: implement parser based on property_tree. + return false; } From df7ed055c89676178eb9a1830f5a43e208412025 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 29 Oct 2019 12:06:03 +0100 Subject: [PATCH 03/12] Stub out xml stuff in SiStripMonitorClient. --- .../interface/SiStripConfigParser.h | 6 +- .../interface/SiStripLayoutParser.h | 6 +- .../src/SiStripConfigParser.cc | 69 ++----------------- .../src/SiStripConfigWriter.cc | 56 --------------- .../src/SiStripLayoutParser.cc | 54 ++------------- 5 files changed, 15 insertions(+), 176 deletions(-) diff --git a/DQM/SiStripMonitorClient/interface/SiStripConfigParser.h b/DQM/SiStripMonitorClient/interface/SiStripConfigParser.h index 3f53c45591758..c5e144e93d49a 100644 --- a/DQM/SiStripMonitorClient/interface/SiStripConfigParser.h +++ b/DQM/SiStripMonitorClient/interface/SiStripConfigParser.h @@ -8,19 +8,17 @@ * \author Suchandra Dutta */ -#include "DQMServices/ClientConfig/interface/DQMParserBase.h" #include #include #include #include -class SiStripConfigParser : public DQMParserBase { +class SiStripConfigParser { public: // Constructor SiStripConfigParser(); - // Destructor - ~SiStripConfigParser() override; + void getDocument(std::string filepath); // get List of MEs for TrackerMap bool getMENamesForSummary(std::map& me_names); diff --git a/DQM/SiStripMonitorClient/interface/SiStripLayoutParser.h b/DQM/SiStripMonitorClient/interface/SiStripLayoutParser.h index 1ed2c9f60fd40..47852de2418ee 100644 --- a/DQM/SiStripMonitorClient/interface/SiStripLayoutParser.h +++ b/DQM/SiStripMonitorClient/interface/SiStripLayoutParser.h @@ -8,19 +8,17 @@ * \author Suchandra Dutta */ -#include "DQMServices/ClientConfig/interface/DQMParserBase.h" #include #include #include #include -class SiStripLayoutParser : public DQMParserBase { +class SiStripLayoutParser { public: // Constructor SiStripLayoutParser(); - // Destructor - ~SiStripLayoutParser() override; + void getDocument(std::string filepath); // Get list of Layouts for ME groups bool getAllLayouts(std::map >& me_names); diff --git a/DQM/SiStripMonitorClient/src/SiStripConfigParser.cc b/DQM/SiStripMonitorClient/src/SiStripConfigParser.cc index e9bffd8a42d96..16b86caae0a5e 100644 --- a/DQM/SiStripMonitorClient/src/SiStripConfigParser.cc +++ b/DQM/SiStripMonitorClient/src/SiStripConfigParser.cc @@ -1,82 +1,27 @@ #include "DQM/SiStripMonitorClient/interface/SiStripConfigParser.h" -#include "DQMServices/ClientConfig/interface/ParserFunctions.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include // // -- Constructor // -SiStripConfigParser::SiStripConfigParser() : DQMParserBase() { +SiStripConfigParser::SiStripConfigParser() { edm::LogInfo("SiStripConfigParser") << " Creating SiStripConfigParser " << "\n"; } -// -// -- Destructor -// -SiStripConfigParser::~SiStripConfigParser() { - edm::LogInfo("SiStripConfigParser") << " Deleting SiStripConfigParser " - << "\n"; + +void SiStripConfigParser::getDocument(std::string filepath) { + // TODO: add new parser. } -// + // -- Get List of MEs for the summary plot and the // bool SiStripConfigParser::getMENamesForSummary(std::map& me_names) { - if (!doc()) { - std::cout << " SiStripConfigParser::Configuration File is not set!!! " << std::endl; - return false; - } - - me_names.clear(); - unsigned int summaryNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SummaryPlot"))->getLength(); - if (summaryNodes == 0) - return false; - /// Get Node - xercesc::DOMNode* summaryNode = doc()->getElementsByTagName(qtxml::_toDOMS("SummaryPlot"))->item(0); - //Get Summary ME name and type - if (!summaryNode) - return false; - xercesc::DOMElement* summaryElement = static_cast(summaryNode); - if (!summaryElement) - return false; - - xercesc::DOMNodeList* meList = summaryElement->getElementsByTagName(qtxml::_toDOMS("MonElement")); - for (unsigned int k = 0; k < meList->getLength(); k++) { - xercesc::DOMNode* meNode = meList->item(k); - if (!meNode) - return false; - xercesc::DOMElement* meElement = static_cast(meNode); - if (!meElement) - return false; - std::string me_name = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("name"))); - std::string me_type = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("type"))); - me_names.insert(std::pair(me_name, me_type)); - } - if (me_names.empty()) - return false; - else - return true; + return false; } // // -- Get List of MEs for the summary plot and the // bool SiStripConfigParser::getFrequencyForSummary(int& u_freq) { - if (!doc()) { - std::cout << " SiStripConfigParser::Configuration File is not set!!! " << std::endl; - return false; - } - - unsigned int summaryNodes = doc()->getElementsByTagName(qtxml::_toDOMS("SummaryPlot"))->getLength(); - if (summaryNodes != 1) - return false; - /// Get Node - xercesc::DOMNode* summaryNode = doc()->getElementsByTagName(qtxml::_toDOMS("SummaryPlot"))->item(0); - //Get Node name - if (!summaryNode) - return false; - xercesc::DOMElement* summaryElement = static_cast(summaryNode); - if (!summaryElement) - return false; - - u_freq = atoi(qtxml::_toString(summaryElement->getAttribute(qtxml::_toDOMS("update_frequency"))).c_str()); - return true; + return false; } diff --git a/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc b/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc index 90f18c1b7b105..18e0bbeb4ccf6 100644 --- a/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc +++ b/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc @@ -1,9 +1,7 @@ #include "DQM/SiStripMonitorClient/interface/SiStripConfigWriter.h" -#include "DQMServices/ClientConfig/interface/ParserFunctions.h" #include using namespace std; -using namespace xercesc; // // -- Constructor @@ -17,50 +15,22 @@ SiStripConfigWriter::~SiStripConfigWriter() {} // -- Initialize XML // bool SiStripConfigWriter::init(std::string main) { - cms::concurrency::xercesInitialize(); - - unique_ptr domImpl(DOMImplementationRegistry::getDOMImplementation(qtxml::_toDOMS("Range"))); - if (domImpl == nullptr) - return false; - theDomWriter = domImpl->createLSSerializer(); - if (theDomWriter == nullptr) - return false; - if (theDomWriter->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true)) - theDomWriter->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true); - theDoc = domImpl->createDocument(nullptr, qtxml::_toDOMS(main), nullptr); - if (theDoc == nullptr) - return false; - theTopElement = theDoc->getDocumentElement(); - theOutput = domImpl->createLSOutput(); - if (theOutput == nullptr) - return false; return true; } // // -- Add an Element to the top node // void SiStripConfigWriter::createElement(std::string tag) { - theTopElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n"))); - theLastElement = theDoc->createElement(qtxml::_toDOMS(tag)); - theTopElement->appendChild(theLastElement); } // // -- Add an Element to the top node // void SiStripConfigWriter::createElement(std::string tag, std::string name) { - theTopElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n"))); - theLastElement = theDoc->createElement(qtxml::_toDOMS(tag)); - theLastElement->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name)); - theTopElement->appendChild(theLastElement); } // // -- Add a child to the last element // void SiStripConfigWriter::createChildElement(std::string tag, std::string name) { - theLastElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n"))); - DOMElement* newElement = theDoc->createElement(qtxml::_toDOMS(tag)); - newElement->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name)); - theLastElement->appendChild(newElement); } // // -- Add a child to the last element @@ -69,12 +39,6 @@ void SiStripConfigWriter::createChildElement(std::string tag, std::string name, std::string att_name, std::string att_val) { - theLastElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n"))); - DOMElement* newElement = theDoc->createElement(qtxml::_toDOMS(tag)); - newElement->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name)); - newElement->setAttribute(qtxml::_toDOMS(att_name), qtxml::_toDOMS(att_val)); - - theLastElement->appendChild(newElement); } // // -- Add a child to the last element @@ -85,12 +49,6 @@ void SiStripConfigWriter::createChildElement(std::string tag, std::string att_val1, std::string att_name2, std::string att_val2) { - theLastElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n"))); - DOMElement* newElement = theDoc->createElement(qtxml::_toDOMS(tag)); - newElement->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name)); - newElement->setAttribute(qtxml::_toDOMS(att_name1), qtxml::_toDOMS(att_val1)); - newElement->setAttribute(qtxml::_toDOMS(att_name2), qtxml::_toDOMS(att_val2)); - theLastElement->appendChild(newElement); } // // -- Add a child to the last element @@ -103,23 +61,9 @@ void SiStripConfigWriter::createChildElement(std::string tag, std::string att_val2, std::string att_name3, std::string att_val3) { - theLastElement->appendChild(theDoc->createTextNode(qtxml::_toDOMS("\n"))); - DOMElement* newElement = theDoc->createElement(qtxml::_toDOMS(tag)); - newElement->setAttribute(qtxml::_toDOMS("name"), qtxml::_toDOMS(name)); - newElement->setAttribute(qtxml::_toDOMS(att_name1), qtxml::_toDOMS(att_val1)); - newElement->setAttribute(qtxml::_toDOMS(att_name2), qtxml::_toDOMS(att_val2)); - newElement->setAttribute(qtxml::_toDOMS(att_name3), qtxml::_toDOMS(att_val3)); - theLastElement->appendChild(newElement); } // // -- Write to File // void SiStripConfigWriter::write(std::string fname) { - XMLFormatTarget* formTarget = new LocalFileFormatTarget(fname.c_str()); - theOutput->setByteStream(formTarget); - theDomWriter->write(theTopElement, theOutput); - delete formTarget; - theOutput->release(); - theDoc->release(); - theDomWriter->release(); } diff --git a/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc b/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc index 81b3b67fc5017..cc399cd1058f1 100644 --- a/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc +++ b/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc @@ -1,66 +1,20 @@ #include "DQM/SiStripMonitorClient/interface/SiStripLayoutParser.h" -#include "DQMServices/ClientConfig/interface/ParserFunctions.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include // // -- Constructor // -SiStripLayoutParser::SiStripLayoutParser() : DQMParserBase() { +SiStripLayoutParser::SiStripLayoutParser() { edm::LogInfo("SiStripLayoutParser") << " Creating SiStripLayoutParser " << "\n"; } -// -// -- Destructor -// -SiStripLayoutParser::~SiStripLayoutParser() { - edm::LogInfo("SiStripActionExecutor") << " Deleting SiStripLayoutParser " - << "\n"; +void SiStripLayoutParser::getDocument(std::string filepath) { + // TODO: add new parser. } // // -- Get list of Layouts for ME groups // bool SiStripLayoutParser::getAllLayouts(std::map >& layouts) { - if (!doc()) { - std::cout << " SiStripLayoutParser::Configuration File is not set!!! " << std::endl; - return false; - } - - layouts.clear(); - - xercesc::DOMNodeList* layoutList = doc()->getElementsByTagName(qtxml::_toDOMS("layout")); - - unsigned int nlayout = layoutList->getLength(); - if (nlayout == 0) - return false; - - for (unsigned int k = 0; k < layoutList->getLength(); k++) { - xercesc::DOMNode* layoutNode = layoutList->item(k); - if (!layoutNode) - return false; - - xercesc::DOMElement* layoutElement = static_cast(layoutNode); - if (!layoutElement) - return false; - std::string layoutName = qtxml::_toString(layoutElement->getAttribute(qtxml::_toDOMS("name"))); - - xercesc::DOMNodeList* meList = layoutElement->getElementsByTagName(qtxml::_toDOMS("monitorable")); - std::vector me_names; - for (unsigned int l = 0; l < meList->getLength(); l++) { - xercesc::DOMNode* meNode = meList->item(l); - if (!meNode) - return false; - xercesc::DOMElement* meElement = static_cast(meNode); - if (!meElement) - return false; - std::string meName = qtxml::_toString(meElement->getAttribute(qtxml::_toDOMS("name"))); - me_names.push_back(meName); - } - if (!me_names.empty()) - layouts[layoutName] = me_names; - } - if (!layouts.empty()) - return true; - else - return false; + return false; } From b585d481aacb19b1e30e3359627e3cb2159a4d01 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Mon, 4 Nov 2019 16:14:55 +0100 Subject: [PATCH 04/12] Implement SiPixel config reading. --- .../interface/SiPixelConfigParser.h | 1 + .../src/SiPixelConfigParser.cc | 87 +++++++++++++++++-- 2 files changed, 81 insertions(+), 7 deletions(-) diff --git a/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h b/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h index 4aaf768589792..035049a02c09e 100644 --- a/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h +++ b/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h @@ -42,6 +42,7 @@ class SiPixelConfigParser { bool getCalibType(int &u_freq); private: + boost::property_tree::ptree config_; }; #endif diff --git a/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc b/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc index 4240cd4a00aa8..b888b76df80e9 100644 --- a/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc +++ b/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc @@ -15,74 +15,147 @@ SiPixelConfigParser::SiPixelConfigParser() { void SiPixelConfigParser::getDocument(std::string filename) { //TODO: implement new parser using property_tree + + boost::property_tree::ptree xml; + boost::property_tree::read_xml(filename, xml); + + auto it = xml.find("MonElementConfiguration"); + if (it == xml.not_found()) { + throw cms::Exception("SiPixelConfigParser") + << "SiPixelConfigParser XML needs to have a MonElementConfiguration node."; + } + this->config_ = it->second; +} + +static bool readMEListHelper(boost::property_tree::ptree &config, string const &tagname, vector &me_names) { + for (auto &kv : config) { + if (kv.first == tagname) { + for (auto &mekv : kv.second) { + if (mekv.first == "MonElement") { + me_names.push_back(mekv.second.get(".name")); + } + } + return true; + } + } + return false; } // // -- Read ME list for the TrackerMap // bool SiPixelConfigParser::getMENamesForTrackerMap(string &tkmap_name, vector &me_names) { - return false; + tkmap_name = config_.get("TkMap..name", ""); + return readMEListHelper(config_, "TkMap", me_names); } // // -- Read Update Frequency for the TrackerMap // bool SiPixelConfigParser::getFrequencyForTrackerMap(int &u_freq) { + u_freq = config_.get("TkMap..update_frequency", -1); + if (u_freq >= 0) + return true; return false; } // // -- Get List of MEs for the module tree plots: // bool SiPixelConfigParser::getMENamesForTree(string &structure_name, vector &me_names) { - return false; + structure_name = config_.get("SummaryPlot.SubStructureLevel..name", ""); + auto it = config_.find("SummaryPlot"); + if (it == config_.not_found()) + return false; + return readMEListHelper(it->second, "SubStructureLevel", me_names); } // // -- Get List of MEs for the summary plot and the // bool SiPixelConfigParser::getMENamesForBarrelSummary(string &structure_name, vector &me_names) { - return false; + structure_name = config_.get("SummaryPlot.SubStructureBarrelLevel..name", ""); + auto it = config_.find("SummaryPlot"); + if (it == config_.not_found()) + return false; + return readMEListHelper(it->second, "SubStructureBarrelLevel", me_names); } bool SiPixelConfigParser::getMENamesForEndcapSummary(string &structure_name, vector &me_names) { - return false; + structure_name = config_.get("SummaryPlot.SubStructureEndcapLevel..name", ""); + auto it = config_.find("SummaryPlot"); + if (it == config_.not_found()) + return false; + return readMEListHelper(it->second, "SubStructureEndcapLevel", me_names); } bool SiPixelConfigParser::getMENamesForFEDErrorSummary(string &structure_name, vector &me_names) { - return false; + structure_name = config_.get("SummaryPlot.SubStructureNonDetId..name", ""); + auto it = config_.find("SummaryPlot"); + if (it == config_.not_found()) + return false; + return readMEListHelper(it->second, "SubStructureNonDetId", me_names); } //// // -- Get List of MEs for the summary plot and the // bool SiPixelConfigParser::getFrequencyForBarrelSummary(int &u_freq) { + u_freq = config_.get("SummaryPlot.SubStructureBarrelLevel..update_frequency", -1); + if (u_freq >= 0) + return true; return false; } bool SiPixelConfigParser::getFrequencyForEndcapSummary(int &u_freq) { + u_freq = config_.get("SummaryPlot.SubStructureEndcapLevel..update_frequency", -1); + if (u_freq >= 0) + return true; return false; } bool SiPixelConfigParser::getMENamesForGrandBarrelSummary(string &structure_name, vector &me_names) { - return false; + structure_name = config_.get("SummaryPlot.SubStructureGrandBarrelLevel..name", ""); + auto it = config_.find("SummaryPlot"); + if (it == config_.not_found()) + return false; + return readMEListHelper(it->second, "SubStructureGrandBarrelLevel", me_names); } bool SiPixelConfigParser::getMENamesForGrandEndcapSummary(string &structure_name, vector &me_names) { - return false; + structure_name = config_.get("SummaryPlot.SubStructureGrandEndcapLevel..name", ""); + auto it = config_.find("SummaryPlot"); + if (it == config_.not_found()) + return false; + return readMEListHelper(it->second, "SubStructureGrandEndcapLevel", me_names); } bool SiPixelConfigParser::getFrequencyForGrandBarrelSummary(int &u_freq) { + u_freq = config_.get("SummaryPlot.SubStructureGrandBarrelLevel..update_frequency", -1); + if (u_freq >= 0) + return true; return false; } bool SiPixelConfigParser::getFrequencyForGrandEndcapSummary(int &u_freq) { + u_freq = config_.get("SummaryPlot.SubStructureGrandEndcapLevel..update_frequency", -1); + if (u_freq >= 0) + return true; return false; } bool SiPixelConfigParser::getMessageLimitForQTests(int &u_freq) { + u_freq = config_.get("QTests.QTestMessageLimit..value", -1); + if (u_freq >= 0) + return true; return false; } bool SiPixelConfigParser::getSourceType(int &u_freq) { + u_freq = config_.get("Source.SourceType..code", -1); + if (u_freq >= 0) + return true; return false; } bool SiPixelConfigParser::getCalibType(int &u_freq) { + u_freq = config_.get("Calib.CalibType..value", -1); + if (u_freq >= 0) + return true; return false; } From 2de4a6047cebc2686bce5b93ce98cadcf762c133 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 5 Nov 2019 15:04:56 +0100 Subject: [PATCH 05/12] Implement SiStripConfigParser. --- .../src/SiPixelConfigParser.cc | 2 -- .../interface/SiStripConfigParser.h | 4 +++ .../src/SiStripConfigParser.cc | 28 +++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc b/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc index b888b76df80e9..33f2366fc1914 100644 --- a/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc +++ b/DQM/SiPixelMonitorClient/src/SiPixelConfigParser.cc @@ -14,8 +14,6 @@ SiPixelConfigParser::SiPixelConfigParser() { } void SiPixelConfigParser::getDocument(std::string filename) { - //TODO: implement new parser using property_tree - boost::property_tree::ptree xml; boost::property_tree::read_xml(filename, xml); diff --git a/DQM/SiStripMonitorClient/interface/SiStripConfigParser.h b/DQM/SiStripMonitorClient/interface/SiStripConfigParser.h index c5e144e93d49a..6e77cb86c37b8 100644 --- a/DQM/SiStripMonitorClient/interface/SiStripConfigParser.h +++ b/DQM/SiStripMonitorClient/interface/SiStripConfigParser.h @@ -13,6 +13,9 @@ #include #include +#include +#include + class SiStripConfigParser { public: // Constructor @@ -25,6 +28,7 @@ class SiStripConfigParser { bool getFrequencyForSummary(int& u_freq); private: + boost::property_tree::ptree config_; }; #endif diff --git a/DQM/SiStripMonitorClient/src/SiStripConfigParser.cc b/DQM/SiStripMonitorClient/src/SiStripConfigParser.cc index 16b86caae0a5e..8c52d0cb59fbc 100644 --- a/DQM/SiStripMonitorClient/src/SiStripConfigParser.cc +++ b/DQM/SiStripMonitorClient/src/SiStripConfigParser.cc @@ -10,18 +10,42 @@ SiStripConfigParser::SiStripConfigParser() { << "\n"; } -void SiStripConfigParser::getDocument(std::string filepath) { - // TODO: add new parser. +void SiStripConfigParser::getDocument(std::string filename) { + boost::property_tree::ptree xml; + boost::property_tree::read_xml(filename, xml); + + auto it = xml.find("MonElementConfiguration"); + if (it == xml.not_found()) { + throw cms::Exception("SiPixelConfigParser") + << "SiPixelConfigParser XML needs to have a MonElementConfiguration node."; + } + this->config_ = it->second; } // -- Get List of MEs for the summary plot and the // bool SiStripConfigParser::getMENamesForSummary(std::map& me_names) { + for (auto& kv : config_) { + if (kv.first == "SummaryPlot") { + for (auto& mekv : kv.second) { + if (mekv.first == "MonElement") { + auto name = mekv.second.get(".name"); + auto type = mekv.second.get(".type"); + me_names[name] = type; + } + } + return true; + } + } return false; } + // // -- Get List of MEs for the summary plot and the // bool SiStripConfigParser::getFrequencyForSummary(int& u_freq) { + u_freq = config_.get("SummaryPlot..update_frequency", -1); + if (u_freq >= 0) + return true; return false; } From 8cf92e55ddce50f0df07c90e0855232dc58a6654 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 12 Nov 2019 12:54:25 +0100 Subject: [PATCH 06/12] Remove DQMServices/ClientConfig. The package should be unused now. --- DQMServices/ClientConfig/BuildFile.xml | 6 -- DQMServices/ClientConfig/doc/ClientConfig.doc | 56 ------------------- .../ClientConfig/interface/DQMParserBase.h | 47 ---------------- .../ClientConfig/interface/ParserFunctions.h | 21 ------- .../python/genericClientPSetHelper_cff.py | 10 ---- DQMServices/ClientConfig/src/DQMParserBase.cc | 53 ------------------ .../ClientConfig/test/QT_ContentSigma.xml | 28 ---------- .../test/QT_ContentsWithinExpected.xml | 21 ------- .../ClientConfig/test/QT_ContentsXRange.xml | 16 ------ .../ClientConfig/test/QT_ContentsYRange.xml | 17 ------ .../ClientConfig/test/QT_DeadChannel.xml | 15 ----- .../test/QT_MeanWithinExpected.xml | 20 ------- .../ClientConfig/test/QT_NoisyChannel.xml | 16 ------ 13 files changed, 326 deletions(-) delete mode 100644 DQMServices/ClientConfig/BuildFile.xml delete mode 100644 DQMServices/ClientConfig/doc/ClientConfig.doc delete mode 100644 DQMServices/ClientConfig/interface/DQMParserBase.h delete mode 100644 DQMServices/ClientConfig/interface/ParserFunctions.h delete mode 100644 DQMServices/ClientConfig/python/genericClientPSetHelper_cff.py delete mode 100644 DQMServices/ClientConfig/src/DQMParserBase.cc delete mode 100644 DQMServices/ClientConfig/test/QT_ContentSigma.xml delete mode 100644 DQMServices/ClientConfig/test/QT_ContentsWithinExpected.xml delete mode 100644 DQMServices/ClientConfig/test/QT_ContentsXRange.xml delete mode 100644 DQMServices/ClientConfig/test/QT_ContentsYRange.xml delete mode 100644 DQMServices/ClientConfig/test/QT_DeadChannel.xml delete mode 100644 DQMServices/ClientConfig/test/QT_MeanWithinExpected.xml delete mode 100644 DQMServices/ClientConfig/test/QT_NoisyChannel.xml diff --git a/DQMServices/ClientConfig/BuildFile.xml b/DQMServices/ClientConfig/BuildFile.xml deleted file mode 100644 index a4294f68dbb70..0000000000000 --- a/DQMServices/ClientConfig/BuildFile.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/DQMServices/ClientConfig/doc/ClientConfig.doc b/DQMServices/ClientConfig/doc/ClientConfig.doc deleted file mode 100644 index f4667d6696087..0000000000000 --- a/DQMServices/ClientConfig/doc/ClientConfig.doc +++ /dev/null @@ -1,56 +0,0 @@ - -/*! - -\page DQMServices_ClientConfig Package DQMServices/ClientConfig - -
- - - -Source code (CVS tag: @CVS_TAG@) - -Administrative privileges - -
- -\section desc Description - - -(THE PACKAGE ADMINISTATOR SHOULD REPLACE THIS SENTENCE WITH HAND-WRITTEN DOCUMENTATION SAYING WHAT THE PACKAGE DOES.) - -\subsection interface Public interface - - -- DQMGenericClient -- DQMParserBase -- FitSlicesYTool -- ParserFunctions -- QTestConfigurationParser -- QTestConfigure -- QTestHandle -- QTestParameterNames -- QTestStatusChecker - - -\subsection pluginai Plugins - - - - - -\subsection modules Modules - - - -\subsection tests Unit tests and examples - -Unknown - -\section status Status and planned development - -Unknown - -
-Last updated: -@DATE@ Author: computer-generated. -*/ - diff --git a/DQMServices/ClientConfig/interface/DQMParserBase.h b/DQMServices/ClientConfig/interface/DQMParserBase.h deleted file mode 100644 index 2f30d5c342560..0000000000000 --- a/DQMServices/ClientConfig/interface/DQMParserBase.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef DQMParserBase_H -#define DQMParserBase_H - -/** \class DQMParserBase - * * - * Base class for Parsers used by DQM - * - * - * \author Ilaria Segoni - */ - -#include -#include -#include -#include "Utilities/Xerces/interface/Xerces.h" -#include -#include -#include -#include - -#include -#include -#include -#include - -class DQMParserBase { -public: - ///Creator - DQMParserBase(); - ///Destructor - virtual ~DQMParserBase(); - ///Methor that parses the xml file configFile - void getDocument(std::string configFile, bool UseDB = false); - ///Returns the number of nodes with given name - int countNodes(std::string tagName); - ///Parses a new Document - void getNewDocument(std::string configFile, bool UseDB = false); - /// DOM Document - xercesc::DOMDocument* doc() { return parser->getDocument(); } - -protected: - xercesc::XercesDOMParser* parser; - -private: -}; - -#endif diff --git a/DQMServices/ClientConfig/interface/ParserFunctions.h b/DQMServices/ClientConfig/interface/ParserFunctions.h deleted file mode 100644 index ccd6540eae8ac..0000000000000 --- a/DQMServices/ClientConfig/interface/ParserFunctions.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef DQMServices_ClientConfig_ParserFunctions_h -#define DQMServices_ClientConfig_ParserFunctions_h - -#include "xercesc/util/XercesDefs.hpp" -#include "xercesc/parsers/XercesDOMParser.hpp" - -#include - -namespace qtxml { - inline std::string _toString(const XMLCh* toTranscode) { - std::string tmp(xercesc::XMLString::transcode(toTranscode)); - return tmp; - } - - inline XMLCh* _toDOMS(std::string temp) { - XMLCh* buff = xercesc::XMLString::transcode(temp.c_str()); - return buff; - } - -} // namespace qtxml -#endif // DQMServices_ClientConfig_ParserFunctions_h diff --git a/DQMServices/ClientConfig/python/genericClientPSetHelper_cff.py b/DQMServices/ClientConfig/python/genericClientPSetHelper_cff.py deleted file mode 100644 index 4fc8c15109c96..0000000000000 --- a/DQMServices/ClientConfig/python/genericClientPSetHelper_cff.py +++ /dev/null @@ -1,10 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -def efficSet(nameIn, titleIn, numeratorIn, denominatorIn, typeIn="eff"): - pset = cms.PSet(name=cms.untracked.string(nameIn), - title=cms.untracked.string(titleIn), - numerator=cms.untracked.string(numeratorIn), - denominator=cms.untracked.string(denominatorIn), - type=cms.untracked.string(typeIn)) - return pset - diff --git a/DQMServices/ClientConfig/src/DQMParserBase.cc b/DQMServices/ClientConfig/src/DQMParserBase.cc deleted file mode 100644 index 4d079711506e7..0000000000000 --- a/DQMServices/ClientConfig/src/DQMParserBase.cc +++ /dev/null @@ -1,53 +0,0 @@ -#include "DQMServices/ClientConfig/interface/DQMParserBase.h" -#include "DQMServices/ClientConfig/interface/ParserFunctions.h" - -#include -/** \file - * - * Implementation of DQMParserBase - * - * \author Ilaria Segoni - */ - -using namespace xercesc; - -DQMParserBase::DQMParserBase() { parser = nullptr; } - -DQMParserBase::~DQMParserBase() { - delete parser; - parser = nullptr; -} - -void DQMParserBase::getDocument(std::string configFile, bool UseDB) { - parser = new XercesDOMParser; - parser->setValidationScheme(XercesDOMParser::Val_Auto); - parser->setDoNamespaces(false); - if (UseDB) { - // std::cout<<"=== This is config file from getDocument ====== "<parse(mb); - } else { - parser->parse(configFile.c_str()); - } - xercesc::DOMDocument* doc = parser->getDocument(); - assert(doc); -} - -void DQMParserBase::getNewDocument(std::string configFile, bool UseDB) { - parser->resetDocumentPool(); - if (UseDB) { - std::cout << "=== This is config file from getNewDocument ==== " << std::endl; - std::cout << configFile << std::endl; - MemBufInputSource mb((const XMLByte*)configFile.c_str(), strlen(configFile.c_str()), "", false); - parser->parse(mb); - } else { - parser->parse(configFile.c_str()); - } - xercesc::DOMDocument* doc = parser->getDocument(); - assert(doc); -} -int DQMParserBase::countNodes(std::string tagName) { - unsigned int tagsNum = parser->getDocument()->getElementsByTagName(qtxml::_toDOMS(tagName))->getLength(); - return tagsNum; -} diff --git a/DQMServices/ClientConfig/test/QT_ContentSigma.xml b/DQMServices/ClientConfig/test/QT_ContentSigma.xml deleted file mode 100644 index 0f5998d745896..0000000000000 --- a/DQMServices/ClientConfig/test/QT_ContentSigma.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - ContentSigma - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 0.30 - 0.70 - - - 1 - 1000 - 1 - 1000 - - - - - exampleQTest - - - diff --git a/DQMServices/ClientConfig/test/QT_ContentsWithinExpected.xml b/DQMServices/ClientConfig/test/QT_ContentsWithinExpected.xml deleted file mode 100644 index 94297127dfea3..0000000000000 --- a/DQMServices/ClientConfig/test/QT_ContentsWithinExpected.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - ContentsWithinExpected - 0 - 10 - 0 - 10 - 0.5 - 20 - 1 - 0.30 - 0.70 - - - - - exampleQTest - - - diff --git a/DQMServices/ClientConfig/test/QT_ContentsXRange.xml b/DQMServices/ClientConfig/test/QT_ContentsXRange.xml deleted file mode 100644 index bea661106b86c..0000000000000 --- a/DQMServices/ClientConfig/test/QT_ContentsXRange.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - ContentsXRange - 0 - 11 - 0.30 - 0.70 - - - - - exampleQTest - - - diff --git a/DQMServices/ClientConfig/test/QT_ContentsYRange.xml b/DQMServices/ClientConfig/test/QT_ContentsYRange.xml deleted file mode 100644 index 7e495ab5a6fb4..0000000000000 --- a/DQMServices/ClientConfig/test/QT_ContentsYRange.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - ContentsYRange - 0 - 10 - 1 - 0.30 - 0.70 - - - - - exampleQTest - - - diff --git a/DQMServices/ClientConfig/test/QT_DeadChannel.xml b/DQMServices/ClientConfig/test/QT_DeadChannel.xml deleted file mode 100644 index c1bdc461a61fa..0000000000000 --- a/DQMServices/ClientConfig/test/QT_DeadChannel.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - DeadChannel - 0 - 0.30 - 0.70 - - - - - exampleQTest - - - diff --git a/DQMServices/ClientConfig/test/QT_MeanWithinExpected.xml b/DQMServices/ClientConfig/test/QT_MeanWithinExpected.xml deleted file mode 100644 index 63c024fba6046..0000000000000 --- a/DQMServices/ClientConfig/test/QT_MeanWithinExpected.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - MeanWithinExpected - 8 - 0 - 0 - 1 - 0 - 12 - 0.30 - 0.70 - - - - - exampleQTest - - - diff --git a/DQMServices/ClientConfig/test/QT_NoisyChannel.xml b/DQMServices/ClientConfig/test/QT_NoisyChannel.xml deleted file mode 100644 index 91e1150fd651e..0000000000000 --- a/DQMServices/ClientConfig/test/QT_NoisyChannel.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - NoisyChannel - 0.2 - 2 - 0.30 - 0.70 - - - - - exampleQTest - - - From 609f6758b70085677922c6bda1136575629ee21b Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 10 Dec 2019 12:20:51 +0100 Subject: [PATCH 07/12] Code-format. --- .../interface/SiPixelConfigParser.h | 1 - .../src/SiPixelConfigWriter.cc | 16 ++++-------- .../interface/SummaryPlotXmlParser.h | 1 - .../src/SummaryPlotXmlParser.cc | 3 +-- .../src/SiStripConfigWriter.cc | 25 ++++++------------- .../src/SiStripLayoutParser.cc | 4 +-- 6 files changed, 15 insertions(+), 35 deletions(-) diff --git a/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h b/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h index 035049a02c09e..2db8fd713b9ef 100644 --- a/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h +++ b/DQM/SiPixelMonitorClient/interface/SiPixelConfigParser.h @@ -16,7 +16,6 @@ #include #include - class SiPixelConfigParser { public: // Constructor diff --git a/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc b/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc index 85ce7cacc2503..9d066a85ea606 100644 --- a/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc +++ b/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc @@ -14,26 +14,20 @@ SiPixelConfigWriter::~SiPixelConfigWriter() {} // // -- Initialize XML // -bool SiPixelConfigWriter::init() { - return true; -} +bool SiPixelConfigWriter::init() { return true; } // // -- Add an Element // -void SiPixelConfigWriter::createLayout(string &name) { -} +void SiPixelConfigWriter::createLayout(string &name) {} // // -- Add an Element // -void SiPixelConfigWriter::createRow() { -} +void SiPixelConfigWriter::createRow() {} // // -- Add an Element with Children // -void SiPixelConfigWriter::createColumn(string &element, string &name) { -} +void SiPixelConfigWriter::createColumn(string &element, string &name) {} // // -- Write to File // -void SiPixelConfigWriter::write(string &fname) { -} +void SiPixelConfigWriter::write(string &fname) {} diff --git a/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h b/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h index 9a1ab3d0221c9..a4e017f2b7ef4 100644 --- a/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h +++ b/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h @@ -46,7 +46,6 @@ class SummaryPlotXmlParser { /** Container holding the SummaryPlot objects. */ std::map > plots_; - }; #endif // DQM_SiStripCommissioningClients_SummaryPlotXmlParser_H diff --git a/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc b/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc index 86bfb9efcd81c..80667587e73b2 100644 --- a/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc +++ b/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc @@ -5,8 +5,7 @@ using namespace sistrip; -SummaryPlotXmlParser::SummaryPlotXmlParser() { -} +SummaryPlotXmlParser::SummaryPlotXmlParser() {} // ----------------------------------------------------------------------------- // diff --git a/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc b/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc index 18e0bbeb4ccf6..1329c6cdc7a9d 100644 --- a/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc +++ b/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc @@ -14,32 +14,26 @@ SiStripConfigWriter::~SiStripConfigWriter() {} // // -- Initialize XML // -bool SiStripConfigWriter::init(std::string main) { - return true; -} +bool SiStripConfigWriter::init(std::string main) { return true; } // // -- Add an Element to the top node // -void SiStripConfigWriter::createElement(std::string tag) { -} +void SiStripConfigWriter::createElement(std::string tag) {} // // -- Add an Element to the top node // -void SiStripConfigWriter::createElement(std::string tag, std::string name) { -} +void SiStripConfigWriter::createElement(std::string tag, std::string name) {} // // -- Add a child to the last element // -void SiStripConfigWriter::createChildElement(std::string tag, std::string name) { -} +void SiStripConfigWriter::createChildElement(std::string tag, std::string name) {} // // -- Add a child to the last element // void SiStripConfigWriter::createChildElement(std::string tag, std::string name, std::string att_name, - std::string att_val) { -} + std::string att_val) {} // // -- Add a child to the last element // @@ -48,8 +42,7 @@ void SiStripConfigWriter::createChildElement(std::string tag, std::string att_name1, std::string att_val1, std::string att_name2, - std::string att_val2) { -} + std::string att_val2) {} // // -- Add a child to the last element // @@ -60,10 +53,8 @@ void SiStripConfigWriter::createChildElement(std::string tag, std::string att_name2, std::string att_val2, std::string att_name3, - std::string att_val3) { -} + std::string att_val3) {} // // -- Write to File // -void SiStripConfigWriter::write(std::string fname) { -} +void SiStripConfigWriter::write(std::string fname) {} diff --git a/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc b/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc index cc399cd1058f1..3ee3fa6eef629 100644 --- a/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc +++ b/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc @@ -15,6 +15,4 @@ void SiStripLayoutParser::getDocument(std::string filepath) { // // -- Get list of Layouts for ME groups // -bool SiStripLayoutParser::getAllLayouts(std::map >& layouts) { - return false; -} +bool SiStripLayoutParser::getAllLayouts(std::map >& layouts) { return false; } From 2517c51d2d1d74515ea0191571988daff5b90183 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 12 Nov 2019 14:37:40 +0100 Subject: [PATCH 08/12] Add assertions to stubbed out code paths. --- DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc | 5 ++++- DQM/SiPixelMonitorClient/src/SiPixelLayoutParser.cc | 2 ++ DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc | 2 ++ DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc | 5 ++++- DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc | 4 +++- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc b/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc index 9d066a85ea606..091addb5d056e 100644 --- a/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc +++ b/DQM/SiPixelMonitorClient/src/SiPixelConfigWriter.cc @@ -14,7 +14,10 @@ SiPixelConfigWriter::~SiPixelConfigWriter() {} // // -- Initialize XML // -bool SiPixelConfigWriter::init() { return true; } +bool SiPixelConfigWriter::init() { + assert(!"No longer implemented."); + return true; +} // // -- Add an Element // diff --git a/DQM/SiPixelMonitorClient/src/SiPixelLayoutParser.cc b/DQM/SiPixelMonitorClient/src/SiPixelLayoutParser.cc index b901a1e2381f8..b813cf2bbb389 100644 --- a/DQM/SiPixelMonitorClient/src/SiPixelLayoutParser.cc +++ b/DQM/SiPixelMonitorClient/src/SiPixelLayoutParser.cc @@ -1,6 +1,7 @@ #include "DQM/SiPixelMonitorClient/interface/SiPixelLayoutParser.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include +#include using namespace std; @@ -18,5 +19,6 @@ SiPixelLayoutParser::SiPixelLayoutParser() { // bool SiPixelLayoutParser::getAllLayouts(map> &layouts) { // TODO: implement parser based on property_tree. + assert(!"No longer implemented."); return false; } diff --git a/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc b/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc index 80667587e73b2..72f429af014b9 100644 --- a/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc +++ b/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc @@ -2,6 +2,7 @@ #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include +#include using namespace sistrip; @@ -27,6 +28,7 @@ std::vector SummaryPlotXmlParser::summaryPlots(const sistrip::RunTy void SummaryPlotXmlParser::parseXML(const std::string& f) { plots_.clear(); // TODO: implement parser based on property tree. + assert(!"No longer implemented."); } // ----------------------------------------------------------------------------- diff --git a/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc b/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc index 1329c6cdc7a9d..ad932b2ea135c 100644 --- a/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc +++ b/DQM/SiStripMonitorClient/src/SiStripConfigWriter.cc @@ -14,7 +14,10 @@ SiStripConfigWriter::~SiStripConfigWriter() {} // // -- Initialize XML // -bool SiStripConfigWriter::init(std::string main) { return true; } +bool SiStripConfigWriter::init(std::string main) { + assert(!"No longer implemented."); + return true; +} // // -- Add an Element to the top node // diff --git a/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc b/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc index 3ee3fa6eef629..4c48e4f4d2097 100644 --- a/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc +++ b/DQM/SiStripMonitorClient/src/SiStripLayoutParser.cc @@ -1,6 +1,7 @@ #include "DQM/SiStripMonitorClient/interface/SiStripLayoutParser.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include +#include // // -- Constructor @@ -10,7 +11,8 @@ SiStripLayoutParser::SiStripLayoutParser() { << "\n"; } void SiStripLayoutParser::getDocument(std::string filepath) { - // TODO: add new parser. + // TODO: add new parser based on boost::property_tree. + assert(!"No longer implemented."); } // // -- Get list of Layouts for ME groups From 55a5dac88375e511feccd80e99764e6af684ec2c Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Fri, 29 Nov 2019 09:58:09 +0100 Subject: [PATCH 09/12] Remove mentions of ClientConfig in BuildFiles. --- DQM/SiPixelMonitorClient/BuildFile.xml | 1 - DQM/SiStripCommissioningClients/BuildFile.xml | 1 - DQM/SiStripMonitorClient/BuildFile.xml | 1 - DQM/TrackingMonitorClient/BuildFile.xml | 1 - DQM/TrackingMonitorClient/plugins/BuildFile.xml | 1 - DQMServices/Components/BuildFile.xml | 1 - Validation/RecoMuon/plugins/BuildFile.xml | 1 - Validation/RecoTrack/BuildFile.xml | 1 - Validation/RecoTrack/plugins/BuildFile.xml | 1 - 9 files changed, 9 deletions(-) diff --git a/DQM/SiPixelMonitorClient/BuildFile.xml b/DQM/SiPixelMonitorClient/BuildFile.xml index 2e6528d37a307..599998b986227 100644 --- a/DQM/SiPixelMonitorClient/BuildFile.xml +++ b/DQM/SiPixelMonitorClient/BuildFile.xml @@ -10,7 +10,6 @@ - diff --git a/DQM/SiStripCommissioningClients/BuildFile.xml b/DQM/SiStripCommissioningClients/BuildFile.xml index 2933bc25b26ee..a992c7dab42da 100644 --- a/DQM/SiStripCommissioningClients/BuildFile.xml +++ b/DQM/SiStripCommissioningClients/BuildFile.xml @@ -4,7 +4,6 @@ - diff --git a/DQM/SiStripMonitorClient/BuildFile.xml b/DQM/SiStripMonitorClient/BuildFile.xml index 83f7065545021..995a200f2ce49 100644 --- a/DQM/SiStripMonitorClient/BuildFile.xml +++ b/DQM/SiStripMonitorClient/BuildFile.xml @@ -1,7 +1,6 @@ - diff --git a/DQM/TrackingMonitorClient/BuildFile.xml b/DQM/TrackingMonitorClient/BuildFile.xml index 21c886ca3d3f3..63c4c21e3c117 100644 --- a/DQM/TrackingMonitorClient/BuildFile.xml +++ b/DQM/TrackingMonitorClient/BuildFile.xml @@ -1,7 +1,6 @@ - diff --git a/DQM/TrackingMonitorClient/plugins/BuildFile.xml b/DQM/TrackingMonitorClient/plugins/BuildFile.xml index 39f710cde57d3..2e1bd3bcc2e52 100644 --- a/DQM/TrackingMonitorClient/plugins/BuildFile.xml +++ b/DQM/TrackingMonitorClient/plugins/BuildFile.xml @@ -1,7 +1,6 @@ - diff --git a/DQMServices/Components/BuildFile.xml b/DQMServices/Components/BuildFile.xml index 1f8e7b120db07..7eb6c9ffb0829 100644 --- a/DQMServices/Components/BuildFile.xml +++ b/DQMServices/Components/BuildFile.xml @@ -5,7 +5,6 @@ - diff --git a/Validation/RecoMuon/plugins/BuildFile.xml b/Validation/RecoMuon/plugins/BuildFile.xml index be9dec72f668f..ba4b3adce00bc 100644 --- a/Validation/RecoMuon/plugins/BuildFile.xml +++ b/Validation/RecoMuon/plugins/BuildFile.xml @@ -24,7 +24,6 @@ - diff --git a/Validation/RecoTrack/BuildFile.xml b/Validation/RecoTrack/BuildFile.xml index 569b333dc5c42..53ec2c4a78a38 100644 --- a/Validation/RecoTrack/BuildFile.xml +++ b/Validation/RecoTrack/BuildFile.xml @@ -1,4 +1,3 @@ - diff --git a/Validation/RecoTrack/plugins/BuildFile.xml b/Validation/RecoTrack/plugins/BuildFile.xml index 23000d947e6e0..66b79cbfb3b0d 100644 --- a/Validation/RecoTrack/plugins/BuildFile.xml +++ b/Validation/RecoTrack/plugins/BuildFile.xml @@ -24,7 +24,6 @@ - From 6fee490cfa53226dc4fc82a0f77c48bbf53b32e2 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Tue, 10 Dec 2019 12:25:51 +0100 Subject: [PATCH 10/12] Inline genericClientPSetHelper in Validation/RPCRecHits --- Validation/RPCRecHits/python/postValidation_cfi.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Validation/RPCRecHits/python/postValidation_cfi.py b/Validation/RPCRecHits/python/postValidation_cfi.py index 15b6c40c95ff1..47e69fbb45f53 100644 --- a/Validation/RPCRecHits/python/postValidation_cfi.py +++ b/Validation/RPCRecHits/python/postValidation_cfi.py @@ -1,7 +1,13 @@ import FWCore.ParameterSet.Config as cms from DQMServices.Core.DQMEDHarvester import DQMEDHarvester -from DQMServices.ClientConfig.genericClientPSetHelper_cff import * +def efficSet(nameIn, titleIn, numeratorIn, denominatorIn, typeIn="eff"): + pset = cms.PSet(name=cms.untracked.string(nameIn), + title=cms.untracked.string(titleIn), + numerator=cms.untracked.string(numeratorIn), + denominator=cms.untracked.string(denominatorIn), + type=cms.untracked.string(typeIn)) + return pset rpcRecHitSimRecoClient = DQMEDHarvester("RPCRecHitValidClient", subDir = cms.string("RPC/RPCRecHitV/SimVsReco"), From b1c0af60a5385ecea2dcccaf31181ee84a4efb52 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Wed, 5 Feb 2020 15:41:22 +0100 Subject: [PATCH 11/12] Changes by @rgerosa to SiStripCommissioningClients ... to make it independent from DQM/ClientConfig. --- .../interface/SummaryPlotXmlParser.h | 46 +++++-- .../src/SummaryPlotXmlParser.cc | 117 ++++++++++++++---- 2 files changed, 128 insertions(+), 35 deletions(-) diff --git a/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h b/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h index a4e017f2b7ef4..96ec7e8c94f00 100644 --- a/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h +++ b/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h @@ -8,14 +8,14 @@ #include #include #include - +#include #include #include class SummaryPlotXmlParser; /** Debug information. */ -std::ostream& operator<<(std::ostream&, const SummaryPlotXmlParser&); +std::ostream& operator<< ( std::ostream&, const SummaryPlotXmlParser& ); /** @class SummaryPlotXmlParser @@ -24,28 +24,52 @@ std::ostream& operator<<(std::ostream&, const SummaryPlotXmlParser&); @brief Parses the "summary plot" xml configuration file */ class SummaryPlotXmlParser { -public: + + public: + // ---------- Co(de)nstructors and consts ---------- /** Default constructor. */ SummaryPlotXmlParser(); + /** Default destructor. */ + ~SummaryPlotXmlParser(){;} + // ---------- Public interface ---------- + /** Fill the map with the required tag/names and values */ - void parseXML(const std::string& xml_file); - + void parseXML( const std::string& xml_file ); + /** Returns SummaryPlot objects for given commissioning task. */ - std::vector summaryPlots(const sistrip::RunType&); - + std::vector summaryPlots( const sistrip::RunType& ); + /** Debug print method. */ - void print(std::stringstream&) const; + void print( std::stringstream& ) const; + + private: -private: // ---------- Private member data ---------- /** Container holding the SummaryPlot objects. */ - std::map > plots_; + std::map< sistrip::RunType, std::vector > plots_; + + // RunType tags and attributes + static const std::string rootTag_; + static const std::string runTypeTag_; + static const std::string runTypeAttr_; + + // SummaryPlot tags and attributes + static const std::string summaryPlotTag_; + static const std::string monitorableAttr_; + static const std::string presentationAttr_; + static const std::string viewAttr_; + static const std::string levelAttr_; + static const std::string granularityAttr_; + }; -#endif // DQM_SiStripCommissioningClients_SummaryPlotXmlParser_H +#endif // DQM_SiStripCommissioningClients_SummaryPlotXmlParser_H + + + diff --git a/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc b/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc index 72f429af014b9..370d28de7f301 100644 --- a/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc +++ b/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc @@ -2,38 +2,105 @@ #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include -#include using namespace sistrip; -SummaryPlotXmlParser::SummaryPlotXmlParser() {} +// ----------------------------------------------------------------------------- +// +const std::string SummaryPlotXmlParser::rootTag_ = "root"; +const std::string SummaryPlotXmlParser::runTypeTag_ = "RunType"; +const std::string SummaryPlotXmlParser::runTypeAttr_ = "name"; +const std::string SummaryPlotXmlParser::summaryPlotTag_ = "SummaryPlot"; +const std::string SummaryPlotXmlParser::monitorableAttr_ = "monitorable"; +const std::string SummaryPlotXmlParser::presentationAttr_ = "presentation"; +const std::string SummaryPlotXmlParser::viewAttr_ = "view"; +const std::string SummaryPlotXmlParser::levelAttr_ = "level"; +const std::string SummaryPlotXmlParser::granularityAttr_ = "granularity"; + +// ----------------------------------------------------------------------------- +// +SummaryPlotXmlParser::SummaryPlotXmlParser() { + plots_.clear(); +} // ----------------------------------------------------------------------------- // -std::vector SummaryPlotXmlParser::summaryPlots(const sistrip::RunType& run_type) { - if (plots_.empty()) { - edm::LogWarning(mlDqmClient_) << "[SummaryPlotXmlParser" << __func__ << "]" - << " You have not called the parseXML function," - << " or your XML file is erronious" << std::endl; +std::vector SummaryPlotXmlParser::summaryPlots( const sistrip::RunType& run_type ) { + if( plots_.empty() ) { + edm::LogWarning(mlDqmClient_) + << "[SummaryPlotXmlParser" << __func__ << "]" + << " You have not called the parseXML function," + << " or your XML file is erronious" << std::endl; } - if (plots_.find(run_type) != plots_.end()) { + if( plots_.find( run_type ) != plots_.end() ) { return plots_[run_type]; - } else { - return std::vector(); - } + } else { return std::vector(); } + } // ----------------------------------------------------------------------------- // -void SummaryPlotXmlParser::parseXML(const std::string& f) { +void SummaryPlotXmlParser::parseXML( const std::string& filename ) { + plots_.clear(); - // TODO: implement parser based on property tree. - assert(!"No longer implemented."); + + boost::property_tree::ptree xmltree; + boost::property_tree::read_xml(filename, xmltree); + + auto runs = xmltree.find(rootTag_); + if(runs == xmltree.not_found()){ + } + + // Iterate through nodes + for(auto & xml: xmltree){ + if(xml.first == rootTag_){// find main root + for(auto & runtype: xml.second){ + if(runtype.first == runTypeTag_){ // enter in the run type + sistrip::RunType run_type = SiStripEnumsAndStrings::runType(runtype.second.get("."+runTypeAttr_)); + for(auto & sumplot: runtype.second){ + if(sumplot.first == summaryPlotTag_){ + std::string mon = sumplot.second.get("."+monitorableAttr_); + std::string pres = sumplot.second.get("."+presentationAttr_); + std::string level = sumplot.second.get("."+levelAttr_); + std::string gran = sumplot.second.get("."+granularityAttr_); + SummaryPlot plot(mon,pres,gran,level); + plots_[run_type].push_back( plot ); + } + } + if(plots_[run_type].empty()){ + std::stringstream ss; + ss << "[SummaryPlotXmlParser::" << __func__ << "]" + << " Unable to find any summary plot for "< Plots; - std::map::const_iterator irun = plots_.begin(); - for (; irun != plots_.end(); irun++) { - ss << " RunType=\"" << SiStripEnumsAndStrings::runType(irun->first) << "\"" << std::endl; - if (irun->second.empty()) { + std::map::const_iterator irun = plots_.begin(); + for ( ; irun != plots_.end(); irun++ ) { + ss << " RunType=\"" + << SiStripEnumsAndStrings::runType( irun->first ) + << "\"" << std::endl; + if ( irun->second.empty() ) { ss << " No summary plots for this RunType!"; } else { Plots::const_iterator iplot = irun->second.begin(); - for (; iplot != irun->second.end(); iplot++) { - ss << *iplot << std::endl; + for ( ; iplot != irun->second.end(); iplot++ ) { + ss << *iplot << std::endl; } } } From 68beb45c40c2408e3fa8310105fc3cda311b7529 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Wed, 5 Feb 2020 15:44:09 +0100 Subject: [PATCH 12/12] Code-format && code-checks. --- .../interface/SummaryPlotXmlParser.h | 32 ++--- .../src/SummaryPlotXmlParser.cc | 133 +++++++++--------- 2 files changed, 75 insertions(+), 90 deletions(-) diff --git a/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h b/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h index 96ec7e8c94f00..a73336c8e89ab 100644 --- a/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h +++ b/DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h @@ -15,7 +15,7 @@ class SummaryPlotXmlParser; /** Debug information. */ -std::ostream& operator<< ( std::ostream&, const SummaryPlotXmlParser& ); +std::ostream& operator<<(std::ostream&, const SummaryPlotXmlParser&); /** @class SummaryPlotXmlParser @@ -24,35 +24,31 @@ std::ostream& operator<< ( std::ostream&, const SummaryPlotXmlParser& ); @brief Parses the "summary plot" xml configuration file */ class SummaryPlotXmlParser { - - public: - +public: // ---------- Co(de)nstructors and consts ---------- /** Default constructor. */ SummaryPlotXmlParser(); /** Default destructor. */ - ~SummaryPlotXmlParser(){;} - + ~SummaryPlotXmlParser() { ; } + // ---------- Public interface ---------- - /** Fill the map with the required tag/names and values */ - void parseXML( const std::string& xml_file ); - + void parseXML(const std::string& xml_file); + /** Returns SummaryPlot objects for given commissioning task. */ - std::vector summaryPlots( const sistrip::RunType& ); - + std::vector summaryPlots(const sistrip::RunType&); + /** Debug print method. */ - void print( std::stringstream& ) const; - - private: + void print(std::stringstream&) const; +private: // ---------- Private member data ---------- /** Container holding the SummaryPlot objects. */ - std::map< sistrip::RunType, std::vector > plots_; + std::map > plots_; // RunType tags and attributes static const std::string rootTag_; @@ -66,10 +62,6 @@ class SummaryPlotXmlParser { static const std::string viewAttr_; static const std::string levelAttr_; static const std::string granularityAttr_; - }; -#endif // DQM_SiStripCommissioningClients_SummaryPlotXmlParser_H - - - +#endif // DQM_SiStripCommissioningClients_SummaryPlotXmlParser_H diff --git a/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc b/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc index 370d28de7f301..2c778ae518e55 100644 --- a/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc +++ b/DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc @@ -19,88 +19,83 @@ const std::string SummaryPlotXmlParser::granularityAttr_ = "granularity"; // ----------------------------------------------------------------------------- // -SummaryPlotXmlParser::SummaryPlotXmlParser() { - plots_.clear(); -} +SummaryPlotXmlParser::SummaryPlotXmlParser() { plots_.clear(); } // ----------------------------------------------------------------------------- // -std::vector SummaryPlotXmlParser::summaryPlots( const sistrip::RunType& run_type ) { - if( plots_.empty() ) { - edm::LogWarning(mlDqmClient_) - << "[SummaryPlotXmlParser" << __func__ << "]" - << " You have not called the parseXML function," - << " or your XML file is erronious" << std::endl; +std::vector SummaryPlotXmlParser::summaryPlots(const sistrip::RunType& run_type) { + if (plots_.empty()) { + edm::LogWarning(mlDqmClient_) << "[SummaryPlotXmlParser" << __func__ << "]" + << " You have not called the parseXML function," + << " or your XML file is erronious" << std::endl; } - if( plots_.find( run_type ) != plots_.end() ) { + if (plots_.find(run_type) != plots_.end()) { return plots_[run_type]; - } else { return std::vector(); } - + } else { + return std::vector(); + } } // ----------------------------------------------------------------------------- // -void SummaryPlotXmlParser::parseXML( const std::string& filename ) { - +void SummaryPlotXmlParser::parseXML(const std::string& filename) { plots_.clear(); - + boost::property_tree::ptree xmltree; boost::property_tree::read_xml(filename, xmltree); - + auto runs = xmltree.find(rootTag_); - if(runs == xmltree.not_found()){ + if (runs == xmltree.not_found()) { } - + // Iterate through nodes - for(auto & xml: xmltree){ - if(xml.first == rootTag_){// find main root - for(auto & runtype: xml.second){ - if(runtype.first == runTypeTag_){ // enter in the run type - sistrip::RunType run_type = SiStripEnumsAndStrings::runType(runtype.second.get("."+runTypeAttr_)); - for(auto & sumplot: runtype.second){ - if(sumplot.first == summaryPlotTag_){ - std::string mon = sumplot.second.get("."+monitorableAttr_); - std::string pres = sumplot.second.get("."+presentationAttr_); - std::string level = sumplot.second.get("."+levelAttr_); - std::string gran = sumplot.second.get("."+granularityAttr_); - SummaryPlot plot(mon,pres,gran,level); - plots_[run_type].push_back( plot ); - } - } - if(plots_[run_type].empty()){ - std::stringstream ss; - ss << "[SummaryPlotXmlParser::" << __func__ << "]" - << " Unable to find any summary plot for "<("." + runTypeAttr_)); + for (auto& sumplot : runtype.second) { + if (sumplot.first == summaryPlotTag_) { + std::string mon = sumplot.second.get("." + monitorableAttr_); + std::string pres = sumplot.second.get("." + presentationAttr_); + std::string level = sumplot.second.get("." + levelAttr_); + std::string gran = sumplot.second.get("." + granularityAttr_); + SummaryPlot plot(mon, pres, gran, level); + plots_[run_type].push_back(plot); + } + } + if (plots_[run_type].empty()) { + std::stringstream ss; + ss << "[SummaryPlotXmlParser::" << __func__ << "]" + << " Unable to find any summary plot for " << runTypeTag_ << " nodes!" + << " Empty xml summary histo block?"; + throw(std::runtime_error(ss.str())); + return; + } + } else { + std::stringstream ss; + ss << "[SummaryPlotXmlParser::" << __func__ << "]" + << " Unable to find any " << runTypeTag_ << " nodes!" + << " Empty xml run-type block?"; + throw(std::runtime_error(ss.str())); + return; + } } - } - else{ + } else { std::stringstream ss; - ss << "[SummaryPlotXmlParser::" << __func__ << "]" - << " Did not find \"" << rootTag_ << "\" tag! " - << " Tag name is " - << rootTag_; - throw( std::runtime_error( ss.str() ) ); - return; + ss << "[SummaryPlotXmlParser::" << __func__ << "]" + << " Did not find \"" << rootTag_ << "\" tag! " + << " Tag name is " << rootTag_; + throw(std::runtime_error(ss.str())); + return; } } } // ----------------------------------------------------------------------------- // -std::ostream& operator<< ( std::ostream& os, const SummaryPlotXmlParser& parser ) { +std::ostream& operator<<(std::ostream& os, const SummaryPlotXmlParser& parser) { std::stringstream ss; parser.print(ss); os << ss.str(); @@ -108,23 +103,21 @@ std::ostream& operator<< ( std::ostream& os, const SummaryPlotXmlParser& parser } // ----------------------------------------------------------------------------- -// -void SummaryPlotXmlParser::print( std::stringstream& ss ) const { - ss << "[SummaryPlotXmlParser::SummaryPlot::" << __func__ << "]" +// +void SummaryPlotXmlParser::print(std::stringstream& ss) const { + ss << "[SummaryPlotXmlParser::SummaryPlot::" << __func__ << "]" << " Dumping contents of parsed XML file: " << std::endl; using namespace sistrip; typedef std::vector Plots; - std::map::const_iterator irun = plots_.begin(); - for ( ; irun != plots_.end(); irun++ ) { - ss << " RunType=\"" - << SiStripEnumsAndStrings::runType( irun->first ) - << "\"" << std::endl; - if ( irun->second.empty() ) { + std::map::const_iterator irun = plots_.begin(); + for (; irun != plots_.end(); irun++) { + ss << " RunType=\"" << SiStripEnumsAndStrings::runType(irun->first) << "\"" << std::endl; + if (irun->second.empty()) { ss << " No summary plots for this RunType!"; } else { Plots::const_iterator iplot = irun->second.begin(); - for ( ; iplot != irun->second.end(); iplot++ ) { - ss << *iplot << std::endl; + for (; iplot != irun->second.end(); iplot++) { + ss << *iplot << std::endl; } } }