From 68beb45c40c2408e3fa8310105fc3cda311b7529 Mon Sep 17 00:00:00 2001 From: Marcel Andre Schneider Date: Wed, 5 Feb 2020 15:44:09 +0100 Subject: [PATCH] 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; } } }