CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MonitorXMLParser Class Reference

#include <MonitorXMLParser.h>

Public Member Functions

const std::vector< DB_ME > & getDB_ME (void) const
 
void load () noexcept(false)
 
 MonitorXMLParser (const std::string &fromFile)
 
 ~MonitorXMLParser () throw ()
 

Private Member Functions

void handleElement (xercesc::DOMElement *element)
 

Private Attributes

std::vector< DB_MEDBMonitoringElements_
 
xercesc::XercesDOMParser * parser_
 
TagNamestags_
 
std::string xmlFile_
 

Detailed Description

Definition at line 154 of file MonitorXMLParser.h.

Constructor & Destructor Documentation

MonitorXMLParser::MonitorXMLParser ( const std::string &  fromFile)

Definition at line 18 of file MonitorXMLParser.cc.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, alignCSCRings::e, ERROR_XERCES_INIT, beamvalidation::exit(), parser_, fetchall_from_DQM_v2::release, tags_, cms::concurrency::xercesInitialize(), and xmlFile_.

18  {
19  try {
21 
22  } catch (xercesc::XMLException &e) {
23  char *message = xercesc::XMLString::transcode(e.getMessage());
24 
25  std::cerr << "XML toolkit initialization error: " << message << std::endl;
26 
28 
30  }
31 
32  xmlFile_ = fromFile;
33  parser_ = new xercesc::XercesDOMParser();
34  tags_ = new TagNames();
35 }
std::string xmlFile_
void xercesInitialize()
Definition: Xerces.cc:18
xercesc::XercesDOMParser * parser_
MonitorXMLParser::~MonitorXMLParser ( )
throw (
)

Definition at line 39 of file MonitorXMLParser.cc.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, alignCSCRings::e, parser_, fetchall_from_DQM_v2::release, tags_, and cms::concurrency::xercesTerminate().

39  {
40  try {
42  } catch (xercesc::XMLException &e) {
43  char *message = xercesc::XMLString::transcode(e.getMessage());
44  std::cerr << "XML toolkit teardown error: " << message << std::endl;
46  }
47 
48  delete parser_;
49  delete tags_;
50 }
void xercesTerminate()
Definition: Xerces.cc:23
xercesc::XercesDOMParser * parser_

Member Function Documentation

const std::vector<DB_ME>& MonitorXMLParser::getDB_ME ( void  ) const
inline

Definition at line 167 of file MonitorXMLParser.h.

References DBMonitoringElements_.

Referenced by MonitorElementsDb::MonitorElementsDb().

167 { return (DBMonitoringElements_); }
std::vector< DB_ME > DBMonitoringElements_
void MonitorXMLParser::handleElement ( xercesc::DOMElement *  element)
private

Definition at line 54 of file MonitorXMLParser.cc.

References DbQuery::alias, DbQuery::arg, TagNames::ATTR_ALIAS, TagNames::ATTR_ARG, TagNames::ATTR_LOOP, TagNames::ATTR_NAME, TagNames::ATTR_NCYCLE, TagNames::ATTR_TITLE, TagNames::ATTR_XBINS, TagNames::ATTR_XFROM, TagNames::ATTR_XTO, TagNames::ATTR_YBINS, TagNames::ATTR_YFROM, TagNames::ATTR_YTO, TagNames::ATTR_ZBINS, TagNames::ATTR_ZFROM, TagNames::ATTR_ZTO, c, ztail::d, DBMonitoringElements_, alignCSCRings::e, equals(), DB_ME::loop, hlt_dqm_clientPB-live_cfg::me, DB_ME::ncycle, DB_ME::queries, DbQuery::query, fetchall_from_DQM_v2::release, alignCSCRings::s, TagNames::TAG_1D, TagNames::TAG_2D, TagNames::TAG_ME, TagNames::TAG_QUERY, TagNames::TAG_TPROFILE, TagNames::TAG_TPROFILE2D, tags_, DB_ME::title, DB_ME::type, DB_ME::xbins, DB_ME::xfrom, DB_ME::xto, DB_ME::ybins, DB_ME::yfrom, DB_ME::yto, DB_ME::zbins, DB_ME::zfrom, and DB_ME::zto.

Referenced by load().

54  {
55  if (xercesc::XMLString::equals(tags_->TAG_ME, element->getTagName())) {
56  char *c;
57  std::stringstream s;
58  DB_ME me;
59  bool meok;
60 
61  meok = false;
62 
63  xercesc::DOMNodeList *d1Nodes = element->getElementsByTagName(tags_->TAG_1D);
64  const XMLSize_t d1Count = d1Nodes->getLength();
65 
66  for (XMLSize_t d1Index = 0; d1Index < d1Count; ++d1Index) {
67  xercesc::DOMNode *d1Node = d1Nodes->item(d1Index);
68 
69  xercesc::DOMElement *d1Element = dynamic_cast<xercesc::DOMElement *>(d1Node);
70 
71  const XMLCh *d1titleXMLCh = d1Element->getAttribute(tags_->ATTR_TITLE);
72  c = xercesc::XMLString::transcode(d1titleXMLCh);
73  me.type = "th1d";
74  me.title = c;
75  meok = true;
77 
78  const XMLCh *d1xbinsXMLCh = d1Element->getAttribute(tags_->ATTR_XBINS);
79  c = xercesc::XMLString::transcode(d1xbinsXMLCh);
80  s.clear();
81  s.str(c);
82  s >> me.xbins;
84 
85  const XMLCh *d1xfromXMLCh = d1Element->getAttribute(tags_->ATTR_XFROM);
86  c = xercesc::XMLString::transcode(d1xfromXMLCh);
87  s.clear();
88  s.str(c);
89  s >> me.xfrom;
91 
92  const XMLCh *d1xtoXMLCh = d1Element->getAttribute(tags_->ATTR_XTO);
93  c = xercesc::XMLString::transcode(d1xtoXMLCh);
94  s.clear();
95  s.str(c);
96  s >> me.xto;
98 
99  const XMLCh *d1ncycleXMLCh = d1Element->getAttribute(tags_->ATTR_NCYCLE);
100  c = xercesc::XMLString::transcode(d1ncycleXMLCh);
101  s.clear();
102  s.str(c);
103  s >> me.ncycle;
105 
106  const XMLCh *d1loopXMLCh = d1Element->getAttribute(tags_->ATTR_LOOP);
107  c = xercesc::XMLString::transcode(d1loopXMLCh);
108  s.clear();
109  s.str(c);
110  s >> me.loop;
112 
113  me.ybins = 0;
114  me.yfrom = 0.0;
115  me.yto = 0.0;
116  me.zbins = 0;
117  me.zfrom = 0.0;
118  me.zto = 0.0;
119  }
120 
121  xercesc::DOMNodeList *d2Nodes = element->getElementsByTagName(tags_->TAG_2D);
122  const XMLSize_t d2Count = d2Nodes->getLength();
123 
124  for (XMLSize_t d2Index = 0; d2Index < d2Count; ++d2Index) {
125  xercesc::DOMNode *d2Node = d2Nodes->item(d2Index);
126 
127  xercesc::DOMElement *d2Element = dynamic_cast<xercesc::DOMElement *>(d2Node);
128 
129  const XMLCh *d2titleXMLCh = d2Element->getAttribute(tags_->ATTR_TITLE);
130  c = xercesc::XMLString::transcode(d2titleXMLCh);
131  me.type = "th2d";
132  me.title = c;
133  meok = true;
135 
136  const XMLCh *d2xbinsXMLCh = d2Element->getAttribute(tags_->ATTR_XBINS);
137  c = xercesc::XMLString::transcode(d2xbinsXMLCh);
138  s.clear();
139  s.str(c);
140  s >> me.xbins;
142 
143  const XMLCh *d2xfromXMLCh = d2Element->getAttribute(tags_->ATTR_XFROM);
144  c = xercesc::XMLString::transcode(d2xfromXMLCh);
145  s.clear();
146  s.str(c);
147  s >> me.xfrom;
149 
150  const XMLCh *d2xtoXMLCh = d2Element->getAttribute(tags_->ATTR_XTO);
151  c = xercesc::XMLString::transcode(d2xtoXMLCh);
152  s.clear();
153  s.str(c);
154  s >> me.xto;
156 
157  const XMLCh *d2ybinsXMLCh = d2Element->getAttribute(tags_->ATTR_YBINS);
158  c = xercesc::XMLString::transcode(d2ybinsXMLCh);
159  s.clear();
160  s.str(c);
161  s >> me.ybins;
163 
164  const XMLCh *d2yfromXMLCh = d2Element->getAttribute(tags_->ATTR_YFROM);
165  c = xercesc::XMLString::transcode(d2yfromXMLCh);
166  s.clear();
167  s.str(c);
168  s >> me.yfrom;
170 
171  const XMLCh *d2ytoXMLCh = d2Element->getAttribute(tags_->ATTR_YTO);
172  c = xercesc::XMLString::transcode(d2ytoXMLCh);
173  s.clear();
174  s.str(c);
175  s >> me.yto;
177 
178  const XMLCh *d2ncycleXMLCh = d2Element->getAttribute(tags_->ATTR_NCYCLE);
179  c = xercesc::XMLString::transcode(d2ncycleXMLCh);
180  s.clear();
181  s.str(c);
182  s >> me.ncycle;
184 
185  const XMLCh *d2loopXMLCh = d2Element->getAttribute(tags_->ATTR_LOOP);
186  c = xercesc::XMLString::transcode(d2loopXMLCh);
187  s.clear();
188  s.str(c);
189  s >> me.loop;
191 
192  me.zbins = 0;
193  me.zfrom = 0.0;
194  me.zto = 0.0;
195  }
196 
197  xercesc::DOMNodeList *tpNodes = element->getElementsByTagName(tags_->TAG_TPROFILE);
198  const XMLSize_t tpCount = tpNodes->getLength();
199 
200  for (XMLSize_t tpIndex = 0; tpIndex < tpCount; ++tpIndex) {
201  xercesc::DOMNode *tpNode = tpNodes->item(tpIndex);
202 
203  xercesc::DOMElement *tpElement = dynamic_cast<xercesc::DOMElement *>(tpNode);
204 
205  const XMLCh *tptitleXMLCh = tpElement->getAttribute(tags_->ATTR_TITLE);
206  c = xercesc::XMLString::transcode(tptitleXMLCh);
207  me.type = "tprofile";
208  me.title = c;
209  meok = true;
211 
212  const XMLCh *tpxbinsXMLCh = tpElement->getAttribute(tags_->ATTR_XBINS);
213  c = xercesc::XMLString::transcode(tpxbinsXMLCh);
214  s.clear();
215  s.str(c);
216  s >> me.xbins;
218 
219  const XMLCh *tpxfromXMLCh = tpElement->getAttribute(tags_->ATTR_XFROM);
220  c = xercesc::XMLString::transcode(tpxfromXMLCh);
221  s.clear();
222  s.str(c);
223  s >> me.xfrom;
225 
226  const XMLCh *tpxtoXMLCh = tpElement->getAttribute(tags_->ATTR_XTO);
227  c = xercesc::XMLString::transcode(tpxtoXMLCh);
228  s.clear();
229  s.str(c);
230  s >> me.xto;
232 
233  const XMLCh *tpybinsXMLCh = tpElement->getAttribute(tags_->ATTR_YBINS);
234  c = xercesc::XMLString::transcode(tpybinsXMLCh);
235  s.clear();
236  s.str(c);
237  s >> me.ybins;
239 
240  const XMLCh *tpyfromXMLCh = tpElement->getAttribute(tags_->ATTR_YFROM);
241  c = xercesc::XMLString::transcode(tpyfromXMLCh);
242  s.clear();
243  s.str(c);
244  s >> me.yfrom;
246 
247  const XMLCh *tpytoXMLCh = tpElement->getAttribute(tags_->ATTR_YTO);
248  c = xercesc::XMLString::transcode(tpytoXMLCh);
249  s.clear();
250  s.str(c);
251  s >> me.yto;
253 
254  const XMLCh *tpncycleXMLCh = tpElement->getAttribute(tags_->ATTR_NCYCLE);
255  c = xercesc::XMLString::transcode(tpncycleXMLCh);
256  s.clear();
257  s.str(c);
258  s >> me.ncycle;
260 
261  const XMLCh *tploopXMLCh = tpElement->getAttribute(tags_->ATTR_LOOP);
262  c = xercesc::XMLString::transcode(tploopXMLCh);
263  s.clear();
264  s.str(c);
265  s >> me.loop;
267 
268  me.zbins = 0;
269  me.zfrom = 0.0;
270  me.zto = 0.0;
271  }
272 
273  xercesc::DOMNodeList *tp2dNodes = element->getElementsByTagName(tags_->TAG_TPROFILE2D);
274  const XMLSize_t tp2dCount = tp2dNodes->getLength();
275 
276  for (XMLSize_t tp2dIndex = 0; tp2dIndex < tp2dCount; ++tp2dIndex) {
277  xercesc::DOMNode *tp2dNode = tp2dNodes->item(tp2dIndex);
278 
279  xercesc::DOMElement *tp2dElement = dynamic_cast<xercesc::DOMElement *>(tp2dNode);
280 
281  const XMLCh *tp2dtitleXMLCh = tp2dElement->getAttribute(tags_->ATTR_TITLE);
282  c = xercesc::XMLString::transcode(tp2dtitleXMLCh);
283  me.type = "tprofile2d";
284  me.title = c;
285  meok = true;
287 
288  const XMLCh *tp2dxbinsXMLCh = tp2dElement->getAttribute(tags_->ATTR_XBINS);
289  c = xercesc::XMLString::transcode(tp2dxbinsXMLCh);
290  s.clear();
291  s.str(c);
292  s >> me.xbins;
294 
295  const XMLCh *tp2dxfromXMLCh = tp2dElement->getAttribute(tags_->ATTR_XFROM);
296  c = xercesc::XMLString::transcode(tp2dxfromXMLCh);
297  s.clear();
298  s.str(c);
299  s >> me.xfrom;
301 
302  const XMLCh *tp2dxtoXMLCh = tp2dElement->getAttribute(tags_->ATTR_XTO);
303  c = xercesc::XMLString::transcode(tp2dxtoXMLCh);
304  s.clear();
305  s.str(c);
306  s >> me.xto;
308 
309  const XMLCh *tp2dybinsXMLCh = tp2dElement->getAttribute(tags_->ATTR_YBINS);
310  c = xercesc::XMLString::transcode(tp2dybinsXMLCh);
311  s.clear();
312  s.str(c);
313  s >> me.ybins;
315 
316  const XMLCh *tp2dyfromXMLCh = tp2dElement->getAttribute(tags_->ATTR_YFROM);
317  c = xercesc::XMLString::transcode(tp2dyfromXMLCh);
318  s.clear();
319  s.str(c);
320  s >> me.yfrom;
322 
323  const XMLCh *tp2dytoXMLCh = tp2dElement->getAttribute(tags_->ATTR_YTO);
324  c = xercesc::XMLString::transcode(tp2dytoXMLCh);
325  s.clear();
326  s.str(c);
327  s >> me.yto;
329 
330  const XMLCh *tp2dzbinsXMLCh = tp2dElement->getAttribute(tags_->ATTR_ZBINS);
331  c = xercesc::XMLString::transcode(tp2dzbinsXMLCh);
332  s.clear();
333  s.str(c);
334  s >> me.zbins;
336 
337  const XMLCh *tp2dzfromXMLCh = tp2dElement->getAttribute(tags_->ATTR_ZFROM);
338  c = xercesc::XMLString::transcode(tp2dzfromXMLCh);
339  s.clear();
340  s.str(c);
341  s >> me.zfrom;
343 
344  const XMLCh *tp2dztoXMLCh = tp2dElement->getAttribute(tags_->ATTR_ZTO);
345  c = xercesc::XMLString::transcode(tp2dztoXMLCh);
346  s.clear();
347  s.str(c);
348  s >> me.zto;
350 
351  const XMLCh *tp2dncycleXMLCh = tp2dElement->getAttribute(tags_->ATTR_NCYCLE);
352  c = xercesc::XMLString::transcode(tp2dncycleXMLCh);
353  s.clear();
354  s.str(c);
355  s >> me.ncycle;
357 
358  const XMLCh *tp2dloopXMLCh = tp2dElement->getAttribute(tags_->ATTR_LOOP);
359  c = xercesc::XMLString::transcode(tp2dloopXMLCh);
360  s.clear();
361  s.str(c);
362  s >> me.loop;
364  }
365 
366  xercesc::DOMNodeList *qNodes = element->getElementsByTagName(tags_->TAG_QUERY);
367  const XMLSize_t qCount = qNodes->getLength();
368 
369  for (XMLSize_t qIndex = 0; qIndex < qCount; ++qIndex) {
370  xercesc::DOMNode *qNode = qNodes->item(qIndex);
371 
372  xercesc::DOMElement *qElement = dynamic_cast<xercesc::DOMElement *>(qNode);
373 
374  const XMLCh *nameXMLCh = qElement->getAttribute(tags_->ATTR_NAME);
375  c = xercesc::XMLString::transcode(nameXMLCh);
376 
377  const XMLCh *argXMLCh = qElement->getAttribute(tags_->ATTR_ARG);
378  char *d = xercesc::XMLString::transcode(argXMLCh);
379 
380  const XMLCh *aliasXMLCh = qElement->getAttribute(tags_->ATTR_ALIAS);
381  char *e = xercesc::XMLString::transcode(aliasXMLCh);
382 
383  DbQuery tmpQuery;
384  tmpQuery.query = c;
385  tmpQuery.arg = d;
386  tmpQuery.alias = e;
387 
388  me.queries.push_back(tmpQuery);
389 
393  }
394 
395  if (meok)
396  DBMonitoringElements_.push_back(me);
397  }
398 } // handleElement()
XMLCh * TAG_ME
std::string type
XMLCh * TAG_QUERY
XMLCh * ATTR_YTO
const edm::EventSetup & c
XMLCh * ATTR_ZBINS
XMLCh * ATTR_XBINS
XMLCh * ATTR_ARG
std::string alias
XMLCh * TAG_2D
double xto
unsigned int ncycle
double yfrom
XMLCh * ATTR_YFROM
tuple d
Definition: ztail.py:151
double yto
std::vector< DB_ME > DBMonitoringElements_
XMLCh * ATTR_ZTO
XMLCh * TAG_1D
XMLCh * ATTR_YBINS
double zfrom
XMLCh * ATTR_NAME
std::string title
XMLCh * ATTR_XTO
unsigned int loop
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
XMLCh * TAG_TPROFILE2D
XMLCh * ATTR_ALIAS
std::string arg
XMLCh * ATTR_NCYCLE
double zto
XMLCh * ATTR_TITLE
XMLCh * ATTR_LOOP
std::string query
XMLCh * ATTR_XFROM
std::vector< DbQuery > queries
XMLCh * TAG_TPROFILE
double xfrom
XMLCh * ATTR_ZFROM
void MonitorXMLParser::load ( )
noexcept

Definition at line 402 of file MonitorXMLParser.cc.

References visDQMUpload::buf, alignCSCRings::e, equals(), handleElement(), parser_, fetchall_from_DQM_v2::release, TagNames::TAG_DBE, tags_, and xmlFile_.

Referenced by MonitorElementsDb::MonitorElementsDb().

402  {
403  parser_->setValidationScheme(xercesc::XercesDOMParser::Val_Never);
404  parser_->setDoNamespaces(false);
405  parser_->setDoSchema(false);
406  parser_->setLoadExternalDTD(false);
407 
408  try {
409  parser_->parse(xmlFile_.c_str());
410 
411  xercesc::DOMDocument *xmlDoc = parser_->getDocument();
412 
413  xercesc::DOMElement *dbe = xmlDoc->getDocumentElement();
414 
415  if (nullptr == dbe) {
416  throw(std::runtime_error("empty XML document"));
417  }
418 
419  if (xercesc::XMLString::equals(tags_->TAG_DBE, dbe->getTagName())) {
420  xercesc::DOMNodeList *children = dbe->getChildNodes();
421  const XMLSize_t nodeCount = children->getLength();
422 
423  for (XMLSize_t ix = 0; ix < nodeCount; ++ix) {
424  xercesc::DOMNode *currentNode = children->item(ix);
425  if (nullptr == currentNode) {
426  // null node...
427  continue;
428  }
429 
430  if (xercesc::DOMNode::ELEMENT_NODE != currentNode->getNodeType()) {
431  continue;
432  }
433 
434  xercesc::DOMElement *currentElement = dynamic_cast<xercesc::DOMElement *>(currentNode);
435 
436  handleElement(currentElement);
437  }
438  }
439 
440  } catch (xercesc::XMLException &e) {
441  char *message = xercesc::XMLString::transcode(e.getMessage());
442 
443  std::ostringstream buf;
444  buf << "Error parsing file: " << message << std::endl;
445 
446  xercesc::XMLString::release(&message);
447 
448  throw(std::runtime_error(buf.str()));
449 
450  } catch (const xercesc::DOMException &e) {
451  char *message = xercesc::XMLString::transcode(e.getMessage());
452 
453  std::ostringstream buf;
454  buf << "Encountered DOM Exception: " << message << std::endl;
455 
456  xercesc::XMLString::release(&message);
457 
458  throw(std::runtime_error(buf.str()));
459  }
460 
461  return;
462 
463 } // load()
std::string xmlFile_
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
void handleElement(xercesc::DOMElement *element)
xercesc::XercesDOMParser * parser_
XMLCh * TAG_DBE

Member Data Documentation

std::vector<DB_ME> MonitorXMLParser::DBMonitoringElements_
private

Definition at line 156 of file MonitorXMLParser.h.

Referenced by getDB_ME(), and handleElement().

xercesc::XercesDOMParser* MonitorXMLParser::parser_
private

Definition at line 158 of file MonitorXMLParser.h.

Referenced by load(), MonitorXMLParser(), and ~MonitorXMLParser().

TagNames* MonitorXMLParser::tags_
private

Definition at line 159 of file MonitorXMLParser.h.

Referenced by handleElement(), load(), MonitorXMLParser(), and ~MonitorXMLParser().

std::string MonitorXMLParser::xmlFile_
private

Definition at line 157 of file MonitorXMLParser.h.

Referenced by load(), and MonitorXMLParser().