CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
SummaryPlotXmlParser Class Reference

Parses the "summary plot" xml configuration file. More...

#include <SummaryPlotXmlParser.h>

Inheritance diagram for SummaryPlotXmlParser:
DQMParserBase

Public Member Functions

void parseXML (const std::string &xml_file)
 
void print (std::stringstream &) const
 
std::vector< SummaryPlotsummaryPlots (const sistrip::RunType &)
 
 SummaryPlotXmlParser ()
 
 ~SummaryPlotXmlParser () override
 
- Public Member Functions inherited from DQMParserBase
int countNodes (std::string tagName)
 Returns the number of nodes with given name. More...
 
xercesc::DOMDocument * doc ()
 DOM Document. More...
 
 DQMParserBase ()
 Creator. More...
 
void getDocument (std::string configFile, bool UseDB=false)
 Methor that parses the xml file configFile. More...
 
void getNewDocument (std::string configFile, bool UseDB=false)
 Parses a new Document. More...
 
virtual ~DQMParserBase ()
 Destructor. More...
 

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"
 

Additional Inherited Members

- Protected Attributes inherited from DQMParserBase
xercesc::XercesDOMParser * parser
 

Detailed Description

Parses the "summary plot" xml configuration file.

Author
P.Kalavase, R.Bainbridge

Definition at line 25 of file SummaryPlotXmlParser.h.

Constructor & Destructor Documentation

SummaryPlotXmlParser::SummaryPlotXmlParser ( )

Default constructor.

Definition at line 23 of file SummaryPlotXmlParser.cc.

References f, and cms::concurrency::xercesInitialize().

23  {
24  plots_.clear();
25  try {
27  } catch (const XMLException& f) {
28  throw(std::runtime_error("Standard pool exception : Fatal Error on pool::TrivialFileCatalog"));
29  }
30 }
void xercesInitialize()
Definition: Xerces.cc:18
double f[11][100]
std::map< sistrip::RunType, std::vector< SummaryPlot > > plots_
SummaryPlotXmlParser::~SummaryPlotXmlParser ( )
inlineoverride

Default destructor.

Definition at line 33 of file SummaryPlotXmlParser.h.

References parseXML(), print(), AlCaHLTBitMon_QueryRunRegistry::string, and summaryPlots().

33 { ; }

Member Function Documentation

void SummaryPlotXmlParser::parseXML ( const std::string &  xml_file)

Fill the map with the required tag/names and values

Definition at line 49 of file SummaryPlotXmlParser.cc.

References class-composition::child, class-composition::children, common_cff::doc, MillePedeFileConverter_cfg::e, HTMLExport::elem(), equals(), personalPlayback::level, sistrip::mlDqmClient_, LaserDQM_cfi::mon, class-composition::nodes, plotFactory::plot, fetchall_from_DQM_v2::release, SiStripEnumsAndStrings::runType(), and contentValuesCheck::ss.

Referenced by SiStripCommissioningOfflineClient::beginRun(), and ~SummaryPlotXmlParser().

49  {
50  plots_.clear();
51 
52  try {
53  // Create parser and open XML document
54  getDocument(f);
55 
56  // Retrieve root element
57  DOMElement* root = this->doc()->getDocumentElement();
58  if (!root) {
59  std::stringstream ss;
60  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
61  << " Unable to find any elements!"
62  << " Empty xml document?...";
63  throw(std::runtime_error(ss.str()));
64  }
65 
66  // Check on "root" tag
67  if (!XMLString::equals(root->getTagName(), XMLString::transcode(rootTag_.c_str()))) {
68  std::stringstream ss;
69  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
70  << " Did not find \"" << rootTag_ << "\" tag! "
71  << " Tag name is " << XMLString::transcode(root->getNodeName());
72  edm::LogWarning(mlDqmClient_) << ss.str();
73  return;
74  }
75 
76  // Retrieve nodes in xml document
77  DOMNodeList* nodes = root->getChildNodes();
78  if (nodes->getLength() == 0) {
79  std::stringstream ss;
80  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
81  << " Unable to find any children nodes!"
82  << " Empty xml document?...";
83  throw(std::runtime_error(ss.str()));
84  return;
85  }
86 
87  // LogTrace(mlDqmClient_)
88  // << "[SummaryPlotXmlParser::" << __func__ << "]"
89  // << " Found \"" << rootTag_ << "\" tag!";
90 
91  // LogTrace(mlDqmClient_)
92  // << "[SummaryPlotXmlParser::" << __func__ << "]"
93  // << " Found " << nodes->getLength()
94  // << " children nodes!";
95 
96  // Iterate through nodes
97  for (XMLSize_t inode = 0; inode < nodes->getLength(); ++inode) {
98  // Check on whether node is element
99  DOMNode* node = nodes->item(inode);
100  if (node->getNodeType() && node->getNodeType() == DOMNode::ELEMENT_NODE) {
101  DOMElement* element = dynamic_cast<DOMElement*>(node);
102  if (!element) {
103  continue;
104  }
105 
106  if (XMLString::equals(element->getTagName(), XMLString::transcode(runTypeTag_.c_str()))) {
107  const XMLCh* attr = element->getAttribute(XMLString::transcode(runTypeAttr_.c_str()));
108  sistrip::RunType run_type = SiStripEnumsAndStrings::runType(XMLString::transcode(attr));
109 
110  // std::stringstream ss;
111  // ss << "[SummaryPlotXmlParser::" << __func__ << "]"
112  // << " Found \"" << runTypeTag_ << "\" tag!" << std::endl
113  // << " with tag name \"" << XMLString::transcode(element->getNodeName()) << "\"" << std::endl
114  // << " and attr \"" << runTypeAttr_ << "\" with value \"" << XMLString::transcode(attr) << "\"";
115  // LogTrace(mlDqmClient_) << ss.str();
116 
117  // Retrieve nodes in xml document
118  DOMNodeList* children = node->getChildNodes();
119  if (nodes->getLength() == 0) {
120  std::stringstream ss;
121  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
122  << " Unable to find any children nodes!"
123  << " Empty xml document?...";
124  throw(std::runtime_error(ss.str()));
125  return;
126  }
127 
128  // Iterate through nodes
129  for (XMLSize_t jnode = 0; jnode < children->getLength(); ++jnode) {
130  // Check on whether node is element
131  DOMNode* child = children->item(jnode);
132  if (child->getNodeType() && child->getNodeType() == DOMNode::ELEMENT_NODE) {
133  DOMElement* elem = dynamic_cast<DOMElement*>(child);
134  if (!elem) {
135  continue;
136  }
137 
138  if (XMLString::equals(elem->getTagName(), XMLString::transcode(summaryPlotTag_.c_str()))) {
139  const XMLCh* mon = elem->getAttribute(XMLString::transcode(monitorableAttr_.c_str()));
140  const XMLCh* pres = elem->getAttribute(XMLString::transcode(presentationAttr_.c_str()));
141  const XMLCh* level = elem->getAttribute(XMLString::transcode(levelAttr_.c_str()));
142  const XMLCh* gran = elem->getAttribute(XMLString::transcode(granularityAttr_.c_str()));
143 
144  SummaryPlot plot(XMLString::transcode(mon),
145  XMLString::transcode(pres),
146  XMLString::transcode(gran),
147  XMLString::transcode(level));
148  plots_[run_type].push_back(plot);
149 
150  // std::stringstream ss;
151  // ss << "[SummaryPlotXmlParser::" << __func__ << "]"
152  // << " Found \"" << summaryPlotTag_ << "\" tag!" << std::endl
153  // << " with tag name \"" << XMLString::transcode(elem->getNodeName()) << "\"" << std::endl
154  // << " and attr \"" << monitorableAttr_ << "\" with value \"" << XMLString::transcode(mon) << "\"" << std::endl
155  // << " and attr \"" << presentationAttr_ << "\" with value \"" << XMLString::transcode(pres) << "\"" << std::endl
156  // //<< " and attr \"" << viewAttr_ << "\" with value \"" << XMLString::transcode(view) << "\"" << std::endl
157  // << " and attr \"" << levelAttr_ << "\" with value \"" << XMLString::transcode(level) << "\"" << std::endl
158  // << " and attr \"" << granularityAttr_ << "\" with value \"" << XMLString::transcode(gran) << "\"";
159  // LogTrace(mlDqmClient_) << ss.str();
160 
161  // Update SummaryPlot object and push back into map
162  }
163  }
164  }
165  }
166  }
167  }
168 
169  } catch (XMLException& e) {
170  char* message = XMLString::transcode(e.getMessage());
171  std::ostringstream ss;
172  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
173  << " Error parsing file: " << message << std::flush;
174  XMLString::release(&message);
175  }
176 }
static const std::string monitorableAttr_
void getDocument(std::string configFile, bool UseDB=false)
Methor that parses the xml file configFile.
static const std::string rootTag_
static const std::string runTypeTag_
static const std::string presentationAttr_
static const std::string runTypeAttr_
static const std::string granularityAttr_
static const char mlDqmClient_[]
static std::string runType(const sistrip::RunType &)
Class holding info that defines a summary plot.
Definition: SummaryPlot.h:19
double f[11][100]
std::map< sistrip::RunType, std::vector< SummaryPlot > > plots_
static const std::string summaryPlotTag_
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
static const std::string levelAttr_
xercesc::DOMDocument * doc()
DOM Document.
Definition: DQMParserBase.h:39
void SummaryPlotXmlParser::print ( std::stringstream &  ss) const

Debug print method.

Definition at line 189 of file SummaryPlotXmlParser.cc.

References heavyFlavorValidationHarvestingSequence_cff::Plots, and SiStripEnumsAndStrings::runType().

Referenced by operator<<(), and ~SummaryPlotXmlParser().

189  {
190  ss << "[SummaryPlotXmlParser::SummaryPlot::" << __func__ << "]"
191  << " Dumping contents of parsed XML file: " << std::endl;
192  using namespace sistrip;
193  typedef std::vector<SummaryPlot> Plots;
194  std::map<RunType, Plots>::const_iterator irun = plots_.begin();
195  for (; irun != plots_.end(); irun++) {
196  ss << " RunType=\"" << SiStripEnumsAndStrings::runType(irun->first) << "\"" << std::endl;
197  if (irun->second.empty()) {
198  ss << " No summary plots for this RunType!";
199  } else {
200  Plots::const_iterator iplot = irun->second.begin();
201  for (; iplot != irun->second.end(); iplot++) {
202  ss << *iplot << std::endl;
203  }
204  }
205  }
206 }
sistrip classes
static std::string runType(const sistrip::RunType &)
std::map< sistrip::RunType, std::vector< SummaryPlot > > plots_
std::vector< SummaryPlot > SummaryPlotXmlParser::summaryPlots ( const sistrip::RunType run_type)

Returns SummaryPlot objects for given commissioning task.

Definition at line 34 of file SummaryPlotXmlParser.cc.

References sistrip::mlDqmClient_.

Referenced by SiStripCommissioningOfflineClient::beginRun(), and ~SummaryPlotXmlParser().

34  {
35  if (plots_.empty()) {
36  edm::LogWarning(mlDqmClient_) << "[SummaryPlotXmlParser" << __func__ << "]"
37  << " You have not called the parseXML function,"
38  << " or your XML file is erronious" << std::endl;
39  }
40  if (plots_.find(run_type) != plots_.end()) {
41  return plots_[run_type];
42  } else {
43  return std::vector<SummaryPlot>();
44  }
45 }
static const char mlDqmClient_[]
std::map< sistrip::RunType, std::vector< SummaryPlot > > plots_

Member Data Documentation

const std::string SummaryPlotXmlParser::granularityAttr_ = "granularity"
staticprivate

Definition at line 63 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::levelAttr_ = "level"
staticprivate

Definition at line 62 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::monitorableAttr_ = "monitorable"
staticprivate

Definition at line 59 of file SummaryPlotXmlParser.h.

std::map<sistrip::RunType, std::vector<SummaryPlot> > SummaryPlotXmlParser::plots_
private

Container holding the SummaryPlot objects.

Definition at line 50 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::presentationAttr_ = "presentation"
staticprivate

Definition at line 60 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::rootTag_ = "root"
staticprivate

Definition at line 53 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::runTypeAttr_ = "name"
staticprivate

Definition at line 55 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::runTypeTag_ = "RunType"
staticprivate

Definition at line 54 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::summaryPlotTag_ = "SummaryPlot"
staticprivate

Definition at line 58 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::viewAttr_ = "view"
staticprivate

Definition at line 61 of file SummaryPlotXmlParser.h.