Parses the "summary plot" xml configuration file. More...
#include <SummaryPlotXmlParser.h>
Public Member Functions | |
void | parseXML (const std::string &xml_file) |
void | print (std::stringstream &) const |
std::vector< SummaryPlot > | summaryPlots (const sistrip::RunType &) |
SummaryPlotXmlParser () | |
virtual | ~SummaryPlotXmlParser () |
Private Attributes | |
std::map< sistrip::RunType, std::vector< SummaryPlot > > | plots_ |
Static Private Attributes | |
static const std::string | granularityAttr_ = "granularity" |
static const std::string | levelAttr_ = "level" |
static const std::string | monitorableAttr_ = "monitorable" |
static const std::string | presentationAttr_ = "presentation" |
static const std::string | rootTag_ = "root" |
static const std::string | runTypeAttr_ = "name" |
static const std::string | runTypeTag_ = "RunType" |
static const std::string | summaryPlotTag_ = "SummaryPlot" |
static const std::string | viewAttr_ = "view" |
Parses the "summary plot" xml configuration file.
Definition at line 25 of file SummaryPlotXmlParser.h.
SummaryPlotXmlParser::SummaryPlotXmlParser | ( | ) |
virtual SummaryPlotXmlParser::~SummaryPlotXmlParser | ( | ) | [inline, virtual] |
void SummaryPlotXmlParser::parseXML | ( | const std::string & | xml_file | ) |
Fill the map with the required tag/names and values
Definition at line 48 of file SummaryPlotXmlParser.cc.
References asciidump::attr, asciidump::doc, alignCSCRings::e, HTMLExport::elem(), testEve_cfg::level, python::rootplot::argparse::message, sistrip::mlDqmClient_, LaserDQM_cfi::mon, python::Node::node, plotResiduals::plot(), fetchall_from_DQM_v2::release, dbtoconf::root, and environment_file_cff::runType.
Referenced by SiStripCommissioningOfflineClient::beginRun().
{ 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<DOMElement*>( 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<DOMElement*>( 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 ); } }
void SummaryPlotXmlParser::print | ( | std::stringstream & | ss | ) | const |
Debug print method.
Definition at line 201 of file SummaryPlotXmlParser.cc.
References environment_file_cff::runType.
Referenced by operator<<().
{ ss << "[SummaryPlotXmlParser::SummaryPlot::" << __func__ << "]" << " Dumping contents of parsed XML file: " << std::endl; using namespace sistrip; typedef std::vector<SummaryPlot> Plots; std::map<RunType,Plots>::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; } } } }
std::vector< SummaryPlot > SummaryPlotXmlParser::summaryPlots | ( | const sistrip::RunType & | run_type | ) |
Returns SummaryPlot objects for given commissioning task.
Definition at line 33 of file SummaryPlotXmlParser.cc.
References sistrip::mlDqmClient_.
Referenced by SiStripCommissioningOfflineClient::beginRun().
{ 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() ) { return plots_[run_type]; } else { return std::vector<SummaryPlot>(); } }
const std::string SummaryPlotXmlParser::granularityAttr_ = "granularity" [static, private] |
Definition at line 66 of file SummaryPlotXmlParser.h.
const std::string SummaryPlotXmlParser::levelAttr_ = "level" [static, private] |
Definition at line 65 of file SummaryPlotXmlParser.h.
const std::string SummaryPlotXmlParser::monitorableAttr_ = "monitorable" [static, private] |
Definition at line 62 of file SummaryPlotXmlParser.h.
std::map< sistrip::RunType, std::vector<SummaryPlot> > SummaryPlotXmlParser::plots_ [private] |
Container holding the SummaryPlot objects.
Definition at line 53 of file SummaryPlotXmlParser.h.
const std::string SummaryPlotXmlParser::presentationAttr_ = "presentation" [static, private] |
Definition at line 63 of file SummaryPlotXmlParser.h.
const std::string SummaryPlotXmlParser::rootTag_ = "root" [static, private] |
Definition at line 56 of file SummaryPlotXmlParser.h.
const std::string SummaryPlotXmlParser::runTypeAttr_ = "name" [static, private] |
Definition at line 58 of file SummaryPlotXmlParser.h.
const std::string SummaryPlotXmlParser::runTypeTag_ = "RunType" [static, private] |
Definition at line 57 of file SummaryPlotXmlParser.h.
const std::string SummaryPlotXmlParser::summaryPlotTag_ = "SummaryPlot" [static, private] |
Definition at line 61 of file SummaryPlotXmlParser.h.
const std::string SummaryPlotXmlParser::viewAttr_ = "view" [static, private] |
Definition at line 64 of file SummaryPlotXmlParser.h.