CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
l1t::XmlConfigParser Class Reference

#include <XmlConfigParser.h>

Public Member Functions

void buildGlobalDoc (const std::string &key, const std::string &topPath="")
 
xercesc::DOMElement * getKeyElement (const std::string &key)
 
void readContext (const xercesc::DOMElement *element, const std::string &sysId, TriggerSystem &aTriggerSystem)
 
void readContexts (const std::string &key, const std::string &sysId, TriggerSystem &aTriggerSystem)
 
void readDOMFromFile (const std::string &fName, xercesc::DOMDocument *&doc)
 
void readDOMFromFile (const std::string &fName)
 
void readDOMFromString (const std::string &str, xercesc::DOMDocument *&doc)
 
void readDOMFromString (const std::string &str)
 
void readElement (const xercesc::DOMElement *element, TriggerSystem &aTriggerSystem, const std::string &sysId="")
 
void readHwDescription (const xercesc::DOMElement *element, TriggerSystem &aTriggerSystem, const std::string &sysId="")
 
void readRootElement (TriggerSystem &aTriggerSystem, const std::string &sysId="")
 
 XmlConfigParser ()
 
 XmlConfigParser (xercesc::DOMDocument *doc)
 
 ~XmlConfigParser ()
 

Public Attributes

const XMLCh * kAttrDelim
 
const XMLCh * kAttrId
 
const XMLCh * kAttrModule
 
const XMLCh * kAttrType
 
const XMLCh * kTagAlgo
 
const XMLCh * kTagColumns
 
const XMLCh * kTagContext
 
const XMLCh * kTagCrate
 
const XMLCh * kTagDaqTtc
 
const XMLCh * kTagDb
 
const XMLCh * kTagDisable
 
const XMLCh * kTagExclBoards
 
const XMLCh * kTagExclude
 
const XMLCh * kTagHw
 
const XMLCh * kTagKey
 
const XMLCh * kTagLoad
 
const XMLCh * kTagMask
 
const XMLCh * kTagParam
 
const XMLCh * kTagProcessor
 
const XMLCh * kTagRole
 
const XMLCh * kTagRow
 
const XMLCh * kTagRunSettings
 
const XMLCh * kTagSlot
 
const XMLCh * kTagTypes
 
const std::string kTypeTable
 

Private Member Functions

void appendNodesFromSubDoc (xercesc::DOMNode *parentNode, xercesc::DOMDocument *subDoc)
 
void pruneString (std::string &str)
 
char * pruneString (char *&str)
 

Private Attributes

xercesc::DOMDocument * doc_
 
xercesc::XercesDOMParser * parser_
 

Detailed Description

Definition at line 23 of file XmlConfigParser.h.

Constructor & Destructor Documentation

XmlConfigParser::XmlConfigParser ( )

Initialise XML parser

Definition at line 30 of file XmlConfigParser.cc.

References common_cff::doc, doc_, kAttrDelim, kAttrId, kAttrModule, kAttrType, kTagAlgo, kTagColumns, kTagContext, kTagCrate, kTagDaqTtc, kTagDb, kTagDisable, kTagExclBoards, kTagExclude, kTagHw, kTagKey, kTagLoad, kTagMask, kTagParam, kTagProcessor, kTagRole, kTagRow, kTagRunSettings, kTagSlot, kTagTypes, kTypeTable, and parser_.

31  : kTagHw(nullptr),
32  kTagAlgo(nullptr),
33  kTagRunSettings(nullptr),
34  kTagDb(nullptr),
35  kTagKey(nullptr),
36  kTagLoad(nullptr),
37  kTagContext(nullptr),
38  kTagParam(nullptr),
39  kTagMask(nullptr),
40  kTagDisable(nullptr),
41  kTagExclBoards(nullptr),
42  kTagExclude(nullptr),
43  kTagColumns(nullptr),
44  kTagTypes(nullptr),
45  kTagRow(nullptr),
46  kTagProcessor(nullptr),
47  kTagRole(nullptr),
48  kTagCrate(nullptr),
49  kTagSlot(nullptr),
50  kTagDaqTtc(nullptr),
51  kAttrId(nullptr),
52  kAttrType(nullptr),
53  kAttrDelim(nullptr),
54  kAttrModule(nullptr),
55  kTypeTable("table") {
56  XMLPlatformUtils::Initialize();
57 
58  kTagHw = XMLString::transcode("system");
59  kTagAlgo = XMLString::transcode("algo");
60  kTagRunSettings = XMLString::transcode("run-settings");
61  kTagDb = XMLString::transcode("db");
62  kTagKey = XMLString::transcode("key");
63  kTagLoad = XMLString::transcode("load");
64  kTagContext = XMLString::transcode("context");
65  kTagParam = XMLString::transcode("param");
66  kTagMask = XMLString::transcode("mask");
67  kTagDisable = XMLString::transcode("disable");
68  kTagExclBoards = XMLString::transcode("excluded-boards");
69  kTagExclude = XMLString::transcode("exclude");
70  kTagColumns = XMLString::transcode("columns");
71  kTagTypes = XMLString::transcode("types");
72  kTagRow = XMLString::transcode("row");
73  kTagProcessor = XMLString::transcode("processor");
74  kTagRole = XMLString::transcode("role");
75  kTagCrate = XMLString::transcode("crate");
76  kTagSlot = XMLString::transcode("slot");
77  kTagDaqTtc = XMLString::transcode("daqttc-mgr");
78  kAttrId = XMLString::transcode("id");
79  kAttrType = XMLString::transcode("type");
80  kAttrDelim = XMLString::transcode("delimiter");
81  kAttrModule = XMLString::transcode("module");
82 
84  parser_ = new XercesDOMParser();
85  parser_->setValidationScheme(XercesDOMParser::Val_Auto);
86  parser_->setDoNamespaces(false);
87 
88  doc_ = nullptr;
89 }
const XMLCh * kTagMask
const std::string kTypeTable
const XMLCh * kTagAlgo
const XMLCh * kAttrDelim
const XMLCh * kTagCrate
const XMLCh * kTagRow
const XMLCh * kTagExclBoards
const XMLCh * kTagRole
const XMLCh * kTagProcessor
const XMLCh * kTagLoad
const XMLCh * kAttrId
const XMLCh * kAttrType
const XMLCh * kTagContext
const XMLCh * kTagParam
const XMLCh * kTagColumns
const XMLCh * kTagKey
xercesc::DOMDocument * doc_
const XMLCh * kTagExclude
const XMLCh * kTagDb
const XMLCh * kTagDisable
const XMLCh * kTagDaqTtc
const XMLCh * kAttrModule
const XMLCh * kTagHw
xercesc::XercesDOMParser * parser_
const XMLCh * kTagTypes
const XMLCh * kTagSlot
const XMLCh * kTagRunSettings
l1t::XmlConfigParser::XmlConfigParser ( xercesc::DOMDocument *  doc)
XmlConfigParser::~XmlConfigParser ( )

Definition at line 148 of file XmlConfigParser.cc.

References common_cff::doc, parser_, readDOMFromString(), str, and AlCaHLTBitMon_QueryRunRegistry::string.

148  {
149  delete parser_;
150  XMLPlatformUtils::Terminate();
151 }
xercesc::XercesDOMParser * parser_

Member Function Documentation

void XmlConfigParser::appendNodesFromSubDoc ( xercesc::DOMNode *  parentNode,
xercesc::DOMDocument *  subDoc 
)
private

Definition at line 560 of file XmlConfigParser.cc.

References doc_, equals(), kTagAlgo, and kTagRunSettings.

Referenced by buildGlobalDoc().

560  {
561  DOMElement* subDocRootElement = subDoc->getDocumentElement();
562  //std::cout << "root element tag: " << cms::xerces::toString(subDocRootElement->getTagName()) << std::endl;
563  if (XMLString::equals(subDocRootElement->getTagName(), kTagAlgo) ||
564  XMLString::equals(subDocRootElement->getTagName(), kTagRunSettings)) {
565  DOMNode* importedNode = doc_->importNode(subDocRootElement, true);
566  parentNode->appendChild(importedNode);
567  }
568 }
const XMLCh * kTagAlgo
xercesc::DOMDocument * doc_
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
const XMLCh * kTagRunSettings
void XmlConfigParser::buildGlobalDoc ( const std::string &  key,
const std::string &  topPath = "" 
)

Definition at line 533 of file XmlConfigParser.cc.

References appendNodesFromSubDoc(), MillePedeFileConverter_cfg::fileName, getKeyElement(), mps_fire::i, kAttrModule, kTagLoad, readDOMFromFile(), AlCaHLTBitMon_QueryRunRegistry::string, and cms::xerces::toString().

Referenced by l1t::TriggerSystem::configureSystemFromFiles().

533  {
534  DOMElement* keyElement = getKeyElement(key);
535  if (keyElement) {
536  DOMNodeList* loadElements = keyElement->getElementsByTagName(kTagLoad);
537  for (XMLSize_t i = 0; i < loadElements->getLength(); ++i) {
538  DOMElement* loadElement = static_cast<DOMElement*>(loadElements->item(i));
539  std::string fileName = cms::xerces::toString(loadElement->getAttribute(kAttrModule));
540  if (fileName.find("/") != 0) { // load element has a relative path
541  // build an absolute path with directory of top xml file
542  size_t pos;
543  std::string topDir = "";
544  pos = topPath.find_last_of("/");
545  if (pos != std::string::npos) {
546  topDir = topPath.substr(0, pos + 1);
547  }
548  fileName = topDir + fileName;
549  }
550  //std::cout << "loading file " << fileName << std::endl;
551  DOMDocument* subDoc = nullptr;
552  readDOMFromFile(fileName, subDoc);
553  if (subDoc) {
554  appendNodesFromSubDoc(keyElement, subDoc);
555  }
556  }
557  }
558 }
void readDOMFromFile(const std::string &fName, xercesc::DOMDocument *&doc)
const XMLCh * kTagLoad
std::string toString(XMLCh const *toTranscode)
void appendNodesFromSubDoc(xercesc::DOMNode *parentNode, xercesc::DOMDocument *subDoc)
xercesc::DOMElement * getKeyElement(const std::string &key)
const XMLCh * kAttrModule
DOMElement * XmlConfigParser::getKeyElement ( const std::string &  key)

Definition at line 518 of file XmlConfigParser.cc.

References doc_, equals(), mps_fire::i, kAttrId, kTagDb, kTagKey, and cms::xerces::toString().

Referenced by buildGlobalDoc(), and readContexts().

518  {
519  DOMElement* rootElement = doc_->getDocumentElement();
520  if (XMLString::equals(rootElement->getTagName(), kTagDb)) {
521  DOMNodeList* keyElements = rootElement->getElementsByTagName(kTagKey);
522 
523  for (XMLSize_t i = 0; i < keyElements->getLength(); ++i) {
524  DOMElement* keyElement = static_cast<DOMElement*>(keyElements->item(i));
525  if (cms::xerces::toString(keyElement->getAttribute(kAttrId)) == key) { // we found the key we were looking for
526  return keyElement;
527  }
528  }
529  }
530  return nullptr;
531 }
const XMLCh * kAttrId
std::string toString(XMLCh const *toTranscode)
const XMLCh * kTagKey
xercesc::DOMDocument * doc_
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
const XMLCh * kTagDb
void XmlConfigParser::pruneString ( std::string &  str)
private

Definition at line 594 of file XmlConfigParser.cc.

Referenced by readContext(), and readHwDescription().

594  {
595  std::size_t alphanumBegin = str.find_first_not_of("\n\t ");
596  std::size_t alphanumEnd = str.find_last_not_of("\n\t ");
597  if (alphanumBegin != std::string::npos) {
598  if (alphanumEnd != std::string::npos) {
599  str = str.substr(alphanumBegin, alphanumEnd - alphanumBegin + 1);
600  } else {
601  str = str.substr(alphanumBegin);
602  }
603  }
604 }
#define str(s)
char * XmlConfigParser::pruneString ( char *&  str)
private

Definition at line 582 of file XmlConfigParser.cc.

References XmlConfigParser_reject_symbols.

582  {
583  size_t alphanumBegin = 0, alphanumEnd = strlen(str) - 1;
584 
585  while (str[alphanumBegin] && XmlConfigParser_reject_symbols[unsigned(str[alphanumBegin])])
586  alphanumBegin++;
587  while (alphanumEnd >= alphanumBegin && XmlConfigParser_reject_symbols[unsigned(str[alphanumEnd])])
588  alphanumEnd--;
589 
590  str[alphanumEnd + 1] = '\0';
591  return str + alphanumBegin;
592 }
const char XmlConfigParser_reject_symbols[256]
#define str(s)
void XmlConfigParser::readContext ( const xercesc::DOMElement *  element,
const std::string &  sysId,
TriggerSystem aTriggerSystem 
)

columnsStr = cms::xerces::toString(colChilds->item(k)->getNodeValue()); pruneString(columnsStr);

typesStr = cms::xerces::toString(colTypesChilds->item(k)->getNodeValue()); pruneString(typesStr);

std::string rowStr = cms::xerces::toString(rowChilds->item(k)->getNodeValue()); pruneString(rowStr); rowStrs.push_back(rowStr);

Definition at line 376 of file XmlConfigParser.cc.

References l1t::TriggerSystem::addMask(), l1t::TriggerSystem::addParameter(), l1t::TriggerSystem::addTable(), cms::xerces::cStr(), l1t::TriggerSystem::disableProcOrRoleOrDaq(), HTMLExport::elem(), equals(), dqmdumpme::first, mps_fire::i, B2GTnPMonitor_cfi::item, dqmiolumiharvest::j, dqmdumpme::k, kAttrDelim, kAttrId, kAttrType, kTagColumns, kTagContext, kTagDisable, kTagMask, kTagParam, kTagRow, kTagTypes, kTypeTable, pruneString(), fetchall_from_DQM_v2::release, AlCaHLTBitMon_QueryRunRegistry::string, l1t::TriggerSystem::systemId(), and cms::xerces::toString().

Referenced by readContexts(), and readElement().

376  {
377  std::string systemId = sysId;
378  if (systemId.empty()) {
379  systemId = aTriggerSystem.systemId();
380  }
381  if (cms::xerces::toString(element->getAttribute(kAttrId)) == systemId) {
382  DOMNodeList* contextElements = element->getElementsByTagName(kTagContext);
383 
384  for (XMLSize_t i = 0; i < contextElements->getLength(); ++i) {
385  DOMElement* contextElement = static_cast<DOMElement*>(contextElements->item(i));
386  std::string contextId = cms::xerces::toString(contextElement->getAttribute(kAttrId));
387  pruneString(contextId);
388 
389  for (DOMElement* elem = static_cast<DOMElement*>(contextElement->getFirstChild()); elem;
390  elem = static_cast<DOMElement*>(elem->getNextSibling())) {
391  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
392  if (XMLString::equals(elem->getTagName(), kTagParam)) {
393  // found a parameter
394  string id = cms::xerces::toString(elem->getAttribute(kAttrId));
395  string type = cms::xerces::toString(elem->getAttribute(kAttrType));
396  string delim = cms::xerces::toString(elem->getAttribute(kAttrDelim));
397  pruneString(id);
398  pruneString(type);
399  pruneString(delim);
400 
401  // the type table needs special treatment since it consists of child nodes
402  if (type == kTypeTable) {
403  // get the columns string
404  std::string columnsStr = "";
405  DOMNodeList* colElements = elem->getElementsByTagName(kTagColumns);
406  for (XMLSize_t j = 0; j < colElements->getLength(); ++j) {
407  DOMNodeList* colChilds = colElements->item(j)->getChildNodes();
408  for (XMLSize_t k = 0; k < colChilds->getLength(); ++k) {
409  if (colChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
412  char* cStr = xercesc::XMLString::transcode(colChilds->item(k)->getNodeValue());
413  char *saveptr, first = 1;
414  for (char* item = strtok_r(cStr, delim.c_str(), &saveptr); item != nullptr;
415  item = strtok_r(nullptr, delim.c_str(), &saveptr), first = 0)
416  columnsStr += (first ? std::string("") : delim) + pruneString(item);
418  }
419  }
420  }
421 
422  // get the column type string
423  std::string typesStr = "";
424  DOMNodeList* colTypesElements = elem->getElementsByTagName(kTagTypes);
425  for (XMLSize_t j = 0; j < colTypesElements->getLength(); ++j) {
426  DOMNodeList* colTypesChilds = colTypesElements->item(j)->getChildNodes();
427  for (XMLSize_t k = 0; k < colTypesChilds->getLength(); ++k) {
428  if (colTypesChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
431  char* tStr = xercesc::XMLString::transcode(colTypesChilds->item(k)->getNodeValue());
432  char *saveptr, first = 1;
433  for (char* item = strtok_r(tStr, delim.c_str(), &saveptr); item != nullptr;
434  item = strtok_r(nullptr, delim.c_str(), &saveptr), first = 0)
435  typesStr += (first ? std::string("") : delim) + pruneString(item);
437  }
438  }
439  }
440 
441  // get the rows
442  std::vector<std::string> rowStrs;
443  DOMNodeList* rowElements = elem->getElementsByTagName(kTagRow);
444  for (XMLSize_t j = 0; j < rowElements->getLength(); ++j) {
445  DOMNodeList* rowChilds = rowElements->item(j)->getChildNodes();
446  for (XMLSize_t k = 0; k < rowChilds->getLength(); ++k) {
447  if (rowChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
451  char* rStr = xercesc::XMLString::transcode(rowChilds->item(k)->getNodeValue());
452  char *saveptr, first = 1;
453  std::string row;
454  for (char* item = strtok_r(rStr, delim.c_str(), &saveptr); item != nullptr;
455  item = strtok_r(nullptr, delim.c_str(), &saveptr), first = 0)
456  row += (first ? std::string("") : delim) + pruneString(item);
457 
458  rowStrs.push_back(row);
460  }
461  }
462  }
463  // std::cout << "param element node with id attribute " << id << " and type attribute " << typesStr << std::endl;
464  aTriggerSystem.addTable(
465  id.c_str(), contextId.c_str(), columnsStr.c_str(), typesStr.c_str(), rowStrs, delim.c_str());
466 
467  } else { // all types other than table
468  std::string value = "";
469  DOMNodeList* valNodes = elem->getChildNodes();
470  for (XMLSize_t j = 0; j < valNodes->getLength(); ++j) {
471  if (valNodes->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
472  value += cms::xerces::toString(valNodes->item(j)->getNodeValue()); // should we prune?
473  }
474  }
475 
476  // strip leading and trailing line breaks and spaces
477  pruneString(value);
478 
479  // std::cout << "param element node with id attribute " << id << " and type attribute " << type << " with value: [" << value << "]" << std::endl;
480  aTriggerSystem.addParameter(id.c_str(), contextId.c_str(), type.c_str(), value.c_str(), delim.c_str());
481  }
482 
483  } else if (XMLString::equals(elem->getTagName(), kTagMask)) {
484  // found a Mask
485  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
486  //std::cout << "Mask element node with id attribute " << id << std::endl;
487  pruneString(id);
488  aTriggerSystem.addMask(id.c_str(), contextId.c_str());
489 
490  } else if (XMLString::equals(elem->getTagName(), kTagDisable)) {
491  // found a disable
492  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
493  pruneString(id);
494  aTriggerSystem.disableProcOrRoleOrDaq(id.c_str());
495  }
496  }
497  }
498  }
499  }
500 }
type
Definition: HCALResponse.h:21
void pruneString(std::string &str)
const XMLCh * kTagMask
const std::string kTypeTable
const XMLCh * kAttrDelim
const XMLCh * kTagRow
const XMLCh * kAttrId
const XMLCh * kAttrType
const XMLCh * kTagContext
const XMLCh * kTagParam
std::string toString(XMLCh const *toTranscode)
const XMLCh * kTagColumns
void addTable(const char *id, const char *procOrRole, const char *columns, const char *types, const std::vector< std::string > &rows, const char *delim)
ZStr< char > cStr(XMLCh const *str)
void addMask(const char *id, const char *procOrRoleOrDaq)
Definition: value.py:1
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
std::string systemId(void) const noexcept
Definition: TriggerSystem.h:71
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
const XMLCh * kTagDisable
void addParameter(const char *id, const char *procOrRole, const char *type, const char *value, const char *delim=",")
void disableProcOrRoleOrDaq(const char *procOrRoleOrDaq)
const XMLCh * kTagTypes
void XmlConfigParser::readContexts ( const std::string &  key,
const std::string &  sysId,
TriggerSystem aTriggerSystem 
)

Definition at line 502 of file XmlConfigParser.cc.

References HTMLExport::elem(), equals(), getKeyElement(), kTagAlgo, kTagRunSettings, and readContext().

Referenced by l1t::TriggerSystem::configureSystemFromFiles().

502  {
503  DOMElement* keyElement = getKeyElement(key);
504  if (keyElement) {
505  for (DOMElement* elem = static_cast<DOMElement*>(keyElement->getFirstChild()); elem;
506  elem = static_cast<DOMElement*>(elem->getNextSibling())) {
507  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
508  if (XMLString::equals(elem->getTagName(), kTagAlgo) || XMLString::equals(elem->getTagName(), kTagRunSettings)) {
509  readContext(elem, sysId, aTriggerSystem);
510  }
511  }
512  }
513  } else {
514  throw std::runtime_error("Key not found: " + key);
515  }
516 }
const XMLCh * kTagAlgo
void readContext(const xercesc::DOMElement *element, const std::string &sysId, TriggerSystem &aTriggerSystem)
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
xercesc::DOMElement * getKeyElement(const std::string &key)
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
const XMLCh * kTagRunSettings
void l1t::XmlConfigParser::readDOMFromFile ( const std::string &  fName,
xercesc::DOMDocument *&  doc 
)
void XmlConfigParser::readDOMFromFile ( const std::string &  fName)

Definition at line 178 of file XmlConfigParser.cc.

References doc_, and parser_.

178  {
179  parser_->parse(fName.c_str());
180  doc_ = parser_->getDocument();
181 
182  if (!doc_) {
183  edm::LogError("XmlConfigParser") << "Could not parse file " << fName << "\n";
184  }
185 
186  assert(doc_);
187 }
xercesc::DOMDocument * doc_
xercesc::XercesDOMParser * parser_
void l1t::XmlConfigParser::readDOMFromString ( const std::string &  str,
xercesc::DOMDocument *&  doc 
)
void XmlConfigParser::readDOMFromString ( const std::string &  str)

Definition at line 160 of file XmlConfigParser.cc.

References common_cff::doc, doc_, MainPageGenerator::fName, parser_, readDOMFromFile(), and AlCaHLTBitMon_QueryRunRegistry::string.

160  {
161  MemBufInputSource xmlstr_buf((const XMLByte*)(str.c_str()), str.size(), "xmlstrbuf");
162  parser_->parse(xmlstr_buf);
163  doc_ = parser_->getDocument();
164  assert(doc_);
165 }
xercesc::DOMDocument * doc_
#define str(s)
xercesc::XercesDOMParser * parser_
void XmlConfigParser::readElement ( const xercesc::DOMElement *  element,
TriggerSystem aTriggerSystem,
const std::string &  sysId = "" 
)

Definition at line 200 of file XmlConfigParser.cc.

References equals(), kTagAlgo, kTagHw, kTagRunSettings, readContext(), and readHwDescription().

Referenced by readRootElement().

200  {
201  if (XMLString::equals(element->getTagName(), kTagHw)) {
202  // in case this is a HW description
203  readHwDescription(element, aTriggerSystem, sysId);
204  } else if (XMLString::equals(element->getTagName(), kTagAlgo) ||
205  XMLString::equals(element->getTagName(), kTagRunSettings)) {
206  // in case this is a configuration snippet
207  readContext(element, sysId, aTriggerSystem);
208  }
209 }
const XMLCh * kTagAlgo
void readContext(const xercesc::DOMElement *element, const std::string &sysId, TriggerSystem &aTriggerSystem)
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
void readHwDescription(const xercesc::DOMElement *element, TriggerSystem &aTriggerSystem, const std::string &sysId="")
const XMLCh * kTagHw
const XMLCh * kTagRunSettings
void XmlConfigParser::readHwDescription ( const xercesc::DOMElement *  element,
TriggerSystem aTriggerSystem,
const std::string &  sysId = "" 
)

Definition at line 211 of file XmlConfigParser.cc.

References l1t::TriggerSystem::addDaq(), l1t::TriggerSystem::addProcessor(), l1t::TriggerSystem::disableProcOrRoleOrDaq(), HTMLExport::elem(), equals(), mps_fire::i, dqmiolumiharvest::j, kAttrId, kTagCrate, kTagDaqTtc, kTagExclBoards, kTagExclude, kTagProcessor, kTagRole, kTagSlot, ValidateTausOnZEEFastSim_cff::proc, pruneString(), fetchall_from_DQM_v2::release, l1t::TriggerSystem::setSystemId(), AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), and geometryCSVtoXML::xx.

Referenced by readElement().

213  {
214  // if sysId == "" set the systemId of the trigsystem from the xml sytem id
215  if (!sysId.empty()) {
216  std::string sId = cms::xerces::toString(element->getAttribute(kAttrId));
217  pruneString(sId);
218  if (sId != sysId)
219  return;
220  }
221 
222  char* sysId_ = xercesc::XMLString::transcode(element->getAttribute(kAttrId));
223  aTriggerSystem.setSystemId(pruneString(sysId_));
225 
226  // handle processors
227  DOMNodeList* processors = element->getElementsByTagName(kTagProcessor);
228  XMLSize_t nodeCount = processors->getLength();
229  for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {
230  DOMNode* currentNode = processors->item(xx);
231  if (currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE) { //no null and is element
232  DOMElement* currentElement = static_cast<DOMElement*>(currentNode);
233 
234  string proc = cms::xerces::toString(currentElement->getAttribute(kAttrId));
235  pruneString(proc);
236  string role, crate, slot;
237 
238  DOMNodeList* roles = currentElement->getElementsByTagName(kTagRole);
239  // roles of this processor (should be only one)
240  if (roles->getLength() != 1)
241  throw std::runtime_error(string("Configutration specify not exactly one role"));
242  // for (XMLSize_t i = 0; i < roles->getLength(); ++i) {
243  {
244  XMLSize_t i = 0;
245  DOMNodeList* roleChilds = roles->item(i)->getChildNodes();
246  if (roleChilds->getLength() != 1)
247  throw std::runtime_error(string("Configutration specify not exactly one role"));
248  {
249  // for (XMLSize_t j = 0; j < roleChilds->getLength(); ++j) {
250  XMLSize_t j = 0;
251  if (roleChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
252  role = cms::xerces::toString(roleChilds->item(j)->getNodeValue());
253  pruneString(role);
254  }
255  }
256  }
257 
258  DOMNodeList* crates = currentElement->getElementsByTagName(kTagCrate);
259  // crates of this processor (should be only one)
260  if (crates->getLength() != 1)
261  throw std::runtime_error(string("Configutration specify not exactly one crate"));
262  // for (XMLSize_t i = 0; i < crates->getLength(); ++i) {
263  {
264  XMLSize_t i = 0;
265  DOMNodeList* crateChilds = crates->item(i)->getChildNodes();
266  if (crateChilds->getLength() != 1)
267  throw std::runtime_error(string("Configutration specify not exactly one crate"));
268  {
269  XMLSize_t j = 0;
270  // for (XMLSize_t j = 0; j < crateChilds->getLength(); ++j) {
271  if (crateChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
272  crate = cms::xerces::toString(crateChilds->item(j)->getNodeValue());
273  pruneString(crate);
274  }
275  }
276  }
277 
278  DOMNodeList* slots = currentElement->getElementsByTagName(kTagSlot);
279  // slots of this processor (should be only one)
280  if (slots->getLength() != 1)
281  throw std::runtime_error(string("Configutration specify not exactly one slot"));
282  // for (XMLSize_t i = 0; i < slots->getLength(); ++i) {
283  {
284  XMLSize_t i = 0;
285  DOMNodeList* slotChilds = slots->item(i)->getChildNodes();
286  if (slotChilds->getLength() != 1)
287  throw std::runtime_error(string("Configutration specify not exactly one slot"));
288  // for (XMLSize_t j = 0; j < slotChilds->getLength(); ++j) {
289  {
290  XMLSize_t j = 0;
291  if (slotChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
292  slot = cms::xerces::toString(slotChilds->item(j)->getNodeValue());
293  pruneString(slot);
294  }
295  }
296  }
297 
298  aTriggerSystem.addProcessor(proc.c_str(), role.c_str(), crate.c_str(), slot.c_str());
299  }
300  }
301 
302  // handle DAQ TTC managers
303  DOMNodeList* daqttcs = element->getElementsByTagName(kTagDaqTtc);
304  nodeCount = daqttcs->getLength();
305  for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {
306  DOMNode* currentNode = daqttcs->item(xx);
307  if (currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE) { //no null and is element
308  DOMElement* currentElement = static_cast<DOMElement*>(currentNode);
309  string daqttc = cms::xerces::toString(currentElement->getAttribute(kAttrId));
310  string role, crate;
311 
312  DOMNodeList* roles = currentElement->getElementsByTagName(kTagRole);
313  // roles of this DAQ TTC manager (should be only one)
314  if (roles->getLength() != 1)
315  throw std::runtime_error(string("Configutration specify not exactly one role"));
316  // for (XMLSize_t i = 0; i < roles->getLength(); ++i) {
317  {
318  XMLSize_t i = 0;
319  DOMNodeList* roleChilds = roles->item(i)->getChildNodes();
320  if (roleChilds->getLength() != 1)
321  throw std::runtime_error(string("Configutration specify not exactly one role"));
322  // for (XMLSize_t j = 0; j < roleChilds->getLength(); ++j) {
323  {
324  XMLSize_t j = 0;
325  if (roleChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
326  role = cms::xerces::toString(roleChilds->item(j)->getNodeValue());
327  pruneString(role);
328  }
329  }
330  }
331 
332  DOMNodeList* crates = currentElement->getElementsByTagName(kTagCrate);
333  // crates of this DAQ TTC manager (should be only one)
334  if (crates->getLength() != 1)
335  throw std::runtime_error(string("Configutration specify not exactly one crate"));
336  // for (XMLSize_t i = 0; i < crates->getLength(); ++i) {
337  {
338  XMLSize_t i = 0;
339  DOMNodeList* crateChilds = crates->item(i)->getChildNodes();
340  if (crateChilds->getLength() != 1)
341  throw std::runtime_error(string("Configutration specify not exactly one crate"));
342  // for (XMLSize_t j = 0; j < crateChilds->getLength(); ++j) {
343  {
344  XMLSize_t j = 0;
345  if (crateChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
346  crate = cms::xerces::toString(crateChilds->item(j)->getNodeValue());
347  pruneString(crate);
348  }
349  }
350  }
351 
352  aTriggerSystem.addDaq(daqttc.c_str(), role.c_str(), crate.c_str());
353  }
354  }
355 
356  // handle excluded boards
357  DOMNodeList* exclBoards = element->getElementsByTagName(kTagExclBoards);
358  for (XMLSize_t xx = 0; xx < exclBoards->getLength(); ++xx) {
359  DOMElement* exclBoardElem = static_cast<DOMElement*>(exclBoards->item(xx));
360 
361  for (DOMElement* elem = static_cast<DOMElement*>(exclBoardElem->getFirstChild()); elem;
362  elem = static_cast<DOMElement*>(elem->getNextSibling())) {
363  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
364  if (XMLString::equals(elem->getTagName(), kTagExclude)) {
365  // found an excluded board
366  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
367  pruneString(id);
368  aTriggerSystem.disableProcOrRoleOrDaq(
369  id.c_str()); // handle in the same way as disabled ids in the run-settings
370  }
371  }
372  }
373  }
374 }
void addDaq(const char *daq, const char *role, const char *crate)
void pruneString(std::string &str)
const XMLCh * kTagCrate
void setSystemId(const char *id) noexcept
Definition: TriggerSystem.h:72
const XMLCh * kTagExclBoards
const XMLCh * kTagRole
const XMLCh * kTagProcessor
const XMLCh * kAttrId
std::string toString(XMLCh const *toTranscode)
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
const XMLCh * kTagExclude
void addProcessor(const char *processor, const char *role, const char *crate, const char *slot)
const XMLCh * kTagDaqTtc
void disableProcOrRoleOrDaq(const char *procOrRoleOrDaq)
const XMLCh * kTagSlot
void XmlConfigParser::readRootElement ( TriggerSystem aTriggerSystem,
const std::string &  sysId = "" 
)

Definition at line 189 of file XmlConfigParser.cc.

References doc_, and readElement().

Referenced by l1t::TriggerSystem::configureSystemFromFiles(), L1TMuonEndCapObjectKeysOnlineProd::fillObjectKeys(), L1TGlobalPrescalesVetosESProducer::L1TGlobalPrescalesVetosESProducer(), L1TMuonGlobalParamsOnlineProd::newObject(), L1TMuonEndCapParamsOnlineProd::newObject(), L1TMuonBarrelParamsOnlineProd::newObject(), L1TCaloParamsOnlineProd::newObject(), and L1TGlobalPrescalesVetosOnlineProd::newObject().

189  {
190  DOMElement* rootElement = doc_->getDocumentElement();
191  if (rootElement) {
192  if (rootElement->getNodeType() == DOMNode::ELEMENT_NODE) {
193  readElement(rootElement, aTriggerSystem, sysId);
194  }
195  } else {
196  throw std::runtime_error("No xml root element found");
197  }
198 }
void readElement(const xercesc::DOMElement *element, TriggerSystem &aTriggerSystem, const std::string &sysId="")
xercesc::DOMDocument * doc_

Member Data Documentation

xercesc::DOMDocument* l1t::XmlConfigParser::doc_
private
const XMLCh* l1t::XmlConfigParser::kAttrDelim

Definition at line 47 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kAttrId

Definition at line 45 of file XmlConfigParser.h.

Referenced by getKeyElement(), readContext(), readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kAttrModule

Definition at line 48 of file XmlConfigParser.h.

Referenced by buildGlobalDoc(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kAttrType

Definition at line 46 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagAlgo
const XMLCh* l1t::XmlConfigParser::kTagColumns

Definition at line 37 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagContext

Definition at line 31 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagCrate

Definition at line 42 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagDaqTtc

Definition at line 44 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagDb

Definition at line 28 of file XmlConfigParser.h.

Referenced by getKeyElement(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagDisable

Definition at line 34 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagExclBoards

Definition at line 35 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagExclude

Definition at line 36 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagHw

Definition at line 25 of file XmlConfigParser.h.

Referenced by readElement(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagKey

Definition at line 29 of file XmlConfigParser.h.

Referenced by getKeyElement(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagLoad

Definition at line 30 of file XmlConfigParser.h.

Referenced by buildGlobalDoc(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagMask

Definition at line 33 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagParam

Definition at line 32 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagProcessor

Definition at line 40 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagRole

Definition at line 41 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagRow

Definition at line 39 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagRunSettings
const XMLCh* l1t::XmlConfigParser::kTagSlot

Definition at line 43 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagTypes

Definition at line 38 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const std::string l1t::XmlConfigParser::kTypeTable

Definition at line 49 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

xercesc::XercesDOMParser* l1t::XmlConfigParser::parser_
private