CMS 3D CMS Logo

SummaryPlotXmlParser.cc
Go to the documentation of this file.
4 #include <stdexcept>
5 
6 using namespace sistrip;
7 
8 // -----------------------------------------------------------------------------
9 //
19 
20 // -----------------------------------------------------------------------------
21 //
23 
24 // -----------------------------------------------------------------------------
25 //
26 std::vector<SummaryPlot> SummaryPlotXmlParser::summaryPlots(const sistrip::RunType& run_type) {
27  if (plots_.empty()) {
28  edm::LogWarning(mlDqmClient_) << "[SummaryPlotXmlParser" << __func__ << "]"
29  << " You have not called the parseXML function,"
30  << " or your XML file is erronious" << std::endl;
31  }
32  if (plots_.find(run_type) != plots_.end()) {
33  return plots_[run_type];
34  } else {
35  return std::vector<SummaryPlot>();
36  }
37 }
38 
39 // -----------------------------------------------------------------------------
40 //
42  plots_.clear();
43 
44  boost::property_tree::ptree xmltree;
45  boost::property_tree::read_xml(filename, xmltree);
46 
47  auto runs = xmltree.find(rootTag_);
48  if (runs == xmltree.not_found()) {
49  }
50 
51  // Iterate through nodes
52  for (auto& xml : xmltree) {
53  if (xml.first == rootTag_) { // find main root
54  for (auto& runtype : xml.second) {
55  if (runtype.first == runTypeTag_) { // enter in the run type
56  sistrip::RunType run_type =
57  SiStripEnumsAndStrings::runType(runtype.second.get<std::string>("<xmlattr>." + runTypeAttr_));
58  for (auto& sumplot : runtype.second) {
59  if (sumplot.first == summaryPlotTag_) {
60  std::string mon = sumplot.second.get<std::string>("<xmlattr>." + monitorableAttr_);
61  std::string pres = sumplot.second.get<std::string>("<xmlattr>." + presentationAttr_);
62  std::string level = sumplot.second.get<std::string>("<xmlattr>." + levelAttr_);
63  std::string gran = sumplot.second.get<std::string>("<xmlattr>." + granularityAttr_);
64  SummaryPlot plot(mon, pres, gran, level);
65  plots_[run_type].push_back(plot);
66  }
67  }
68  if (plots_[run_type].empty()) {
69  std::stringstream ss;
70  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
71  << " Unable to find any summary plot for " << runTypeTag_ << " nodes!"
72  << " Empty xml summary histo block?";
73  throw(std::runtime_error(ss.str()));
74  return;
75  }
76  } else {
77  std::stringstream ss;
78  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
79  << " Unable to find any " << runTypeTag_ << " nodes!"
80  << " Empty xml run-type block?";
81  throw(std::runtime_error(ss.str()));
82  return;
83  }
84  }
85  } else {
86  std::stringstream ss;
87  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
88  << " Did not find \"" << rootTag_ << "\" tag! "
89  << " Tag name is " << rootTag_;
90  throw(std::runtime_error(ss.str()));
91  return;
92  }
93  }
94 }
95 
96 // -----------------------------------------------------------------------------
97 //
98 std::ostream& operator<<(std::ostream& os, const SummaryPlotXmlParser& parser) {
99  std::stringstream ss;
100  parser.print(ss);
101  os << ss.str();
102  return os;
103 }
104 
105 // -----------------------------------------------------------------------------
106 //
107 void SummaryPlotXmlParser::print(std::stringstream& ss) const {
108  ss << "[SummaryPlotXmlParser::SummaryPlot::" << __func__ << "]"
109  << " Dumping contents of parsed XML file: " << std::endl;
110  using namespace sistrip;
111  typedef std::vector<SummaryPlot> Plots;
112  std::map<RunType, Plots>::const_iterator irun = plots_.begin();
113  for (; irun != plots_.end(); irun++) {
114  ss << " RunType=\"" << SiStripEnumsAndStrings::runType(irun->first) << "\"" << std::endl;
115  if (irun->second.empty()) {
116  ss << " No summary plots for this RunType!";
117  } else {
118  Plots::const_iterator iplot = irun->second.begin();
119  for (; iplot != irun->second.end(); iplot++) {
120  ss << *iplot << std::endl;
121  }
122  }
123  }
124 }
personalPlayback.level
level
Definition: personalPlayback.py:22
SiStripEnumsAndStrings::runType
static std::string runType(const sistrip::RunType &)
Definition: SiStripEnumsAndStrings.cc:39
MessageLogger.h
SummaryPlotXmlParser.h
SummaryPlotXmlParser::presentationAttr_
static const std::string presentationAttr_
Definition: SummaryPlotXmlParser.h:61
sistrip::operator<<
std::ostream & operator<<(std::ostream &os, const FEDBufferFormat &value)
Definition: SiStripFEDBufferComponents.cc:79
writedatasetfile.runs
runs
Definition: writedatasetfile.py:27
SummaryPlotXmlParser::SummaryPlotXmlParser
SummaryPlotXmlParser()
Definition: SummaryPlotXmlParser.cc:22
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
sistrip::RunType
RunType
Definition: ConstantsForRunType.h:70
plotFactory.plot
plot
Definition: plotFactory.py:109
heavyFlavorValidationHarvestingSequence_cff.Plots
Plots
Definition: heavyFlavorValidationHarvestingSequence_cff.py:109
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
sistrip::mlDqmClient_
static const char mlDqmClient_[]
Definition: ConstantsForLogger.h:19
SummaryPlotXmlParser::viewAttr_
static const std::string viewAttr_
Definition: SummaryPlotXmlParser.h:62
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SummaryPlotXmlParser::rootTag_
static const std::string rootTag_
Definition: SummaryPlotXmlParser.h:54
SummaryPlotXmlParser::summaryPlotTag_
static const std::string summaryPlotTag_
Definition: SummaryPlotXmlParser.h:59
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
SummaryPlotXmlParser::print
void print(std::stringstream &) const
Definition: SummaryPlotXmlParser.cc:107
LaserDQM_cfi.mon
mon
Definition: LaserDQM_cfi.py:3
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SummaryPlotXmlParser::granularityAttr_
static const std::string granularityAttr_
Definition: SummaryPlotXmlParser.h:64
SummaryPlotXmlParser::levelAttr_
static const std::string levelAttr_
Definition: SummaryPlotXmlParser.h:63
SummaryPlotXmlParser
Parses the "summary plot" xml configuration file.
Definition: SummaryPlotXmlParser.h:26
SummaryPlotXmlParser::runTypeAttr_
static const std::string runTypeAttr_
Definition: SummaryPlotXmlParser.h:56
SummaryPlotXmlParser::runTypeTag_
static const std::string runTypeTag_
Definition: SummaryPlotXmlParser.h:55
SiStripEnumsAndStrings.h
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
SummaryPlotXmlParser::parseXML
void parseXML(const std::string &xml_file)
Definition: SummaryPlotXmlParser.cc:41
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
SummaryPlotXmlParser::summaryPlots
std::vector< SummaryPlot > summaryPlots(const sistrip::RunType &)
Definition: SummaryPlotXmlParser.cc:26
SummaryPlotXmlParser::monitorableAttr_
static const std::string monitorableAttr_
Definition: SummaryPlotXmlParser.h:60
SummaryPlot
Class holding info that defines a summary plot.
Definition: SummaryPlot.h:19
SiStripCommissioningClient_cfg.runtype
runtype
Definition: SiStripCommissioningClient_cfg.py:9