Skip to content

Commit

Permalink
Code-format && code-checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
schneiml committed Feb 5, 2020
1 parent b1c0af6 commit 68beb45
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 90 deletions.
32 changes: 12 additions & 20 deletions DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class SummaryPlotXmlParser;

/** Debug information. */
std::ostream& operator<< ( std::ostream&, const SummaryPlotXmlParser& );
std::ostream& operator<<(std::ostream&, const SummaryPlotXmlParser&);

/**
@class SummaryPlotXmlParser
Expand All @@ -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<SummaryPlot> summaryPlots( const sistrip::RunType& );
std::vector<SummaryPlot> 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<SummaryPlot> > plots_;
std::map<sistrip::RunType, std::vector<SummaryPlot> > plots_;

// RunType tags and attributes
static const std::string rootTag_;
Expand All @@ -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
133 changes: 63 additions & 70 deletions DQM/SiStripCommissioningClients/src/SummaryPlotXmlParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,112 +19,105 @@ const std::string SummaryPlotXmlParser::granularityAttr_ = "granularity";

// -----------------------------------------------------------------------------
//
SummaryPlotXmlParser::SummaryPlotXmlParser() {
plots_.clear();
}
SummaryPlotXmlParser::SummaryPlotXmlParser() { plots_.clear(); }

// -----------------------------------------------------------------------------
//
std::vector<SummaryPlot> 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<SummaryPlot> 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<SummaryPlot>(); }

} else {
return std::vector<SummaryPlot>();
}
}

// -----------------------------------------------------------------------------
//
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<std::string>("<xmlattr>."+runTypeAttr_));
for(auto & sumplot: runtype.second){
if(sumplot.first == summaryPlotTag_){
std::string mon = sumplot.second.get<std::string>("<xmlattr>."+monitorableAttr_);
std::string pres = sumplot.second.get<std::string>("<xmlattr>."+presentationAttr_);
std::string level = sumplot.second.get<std::string>("<xmlattr>."+levelAttr_);
std::string gran = sumplot.second.get<std::string>("<xmlattr>."+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;
}
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<std::string>("<xmlattr>." + runTypeAttr_));
for (auto& sumplot : runtype.second) {
if (sumplot.first == summaryPlotTag_) {
std::string mon = sumplot.second.get<std::string>("<xmlattr>." + monitorableAttr_);
std::string pres = sumplot.second.get<std::string>("<xmlattr>." + presentationAttr_);
std::string level = sumplot.second.get<std::string>("<xmlattr>." + levelAttr_);
std::string gran = sumplot.second.get<std::string>("<xmlattr>." + 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();
return os;
}

// -----------------------------------------------------------------------------
//
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<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() ) {
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;
for (; iplot != irun->second.end(); iplot++) {
ss << *iplot << std::endl;
}
}
}
Expand Down

0 comments on commit 68beb45

Please sign in to comment.