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 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_.

30  :
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 {
57  XMLPlatformUtils::Initialize();
58 
59  kTagHw = XMLString::transcode("system");
60  kTagAlgo = XMLString::transcode("algo");
61  kTagRunSettings = XMLString::transcode("run-settings");
62  kTagDb = XMLString::transcode("db");
63  kTagKey = XMLString::transcode("key");
64  kTagLoad = XMLString::transcode("load");
65  kTagContext = XMLString::transcode("context");
66  kTagParam = XMLString::transcode("param");
67  kTagMask = XMLString::transcode("mask");
68  kTagDisable = XMLString::transcode("disable");
69  kTagExclBoards = XMLString::transcode("excluded-boards");
70  kTagExclude = XMLString::transcode("exclude");
71  kTagColumns = XMLString::transcode("columns");
72  kTagTypes = XMLString::transcode("types");
73  kTagRow = XMLString::transcode("row");
74  kTagProcessor = XMLString::transcode("processor");
75  kTagRole = XMLString::transcode("role");
76  kTagCrate = XMLString::transcode("crate");
77  kTagSlot = XMLString::transcode("slot");
78  kTagDaqTtc = XMLString::transcode("daqttc-mgr");
79  kAttrId = XMLString::transcode("id");
80  kAttrType = XMLString::transcode("type");
81  kAttrDelim = XMLString::transcode("delimiter");
82  kAttrModule = XMLString::transcode("module");
83 
85  parser_ = new XercesDOMParser();
86  parser_->setValidationScheme(XercesDOMParser::Val_Auto);
87  parser_->setDoNamespaces(false);
88 
89  doc_ = nullptr;
90 }
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 152 of file XmlConfigParser.cc.

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

153 {
154  delete parser_;
155  XMLPlatformUtils::Terminate();
156 }
xercesc::XercesDOMParser * parser_

Member Function Documentation

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

Definition at line 584 of file XmlConfigParser.cc.

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

Referenced by buildGlobalDoc().

585 {
586  DOMElement* subDocRootElement = subDoc->getDocumentElement();
587  //std::cout << "root element tag: " << cms::xerces::toString(subDocRootElement->getTagName()) << std::endl;
588  if (XMLString::equals(subDocRootElement->getTagName(), kTagAlgo) || XMLString::equals(subDocRootElement->getTagName(), kTagRunSettings)) {
589  DOMNode* importedNode = doc_->importNode(subDocRootElement, true);
590  parentNode->appendChild(importedNode);
591  }
592 }
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 555 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().

556 {
557  DOMElement* keyElement = getKeyElement(key);
558  if (keyElement) {
559  DOMNodeList* loadElements = keyElement->getElementsByTagName(kTagLoad);
560  for (XMLSize_t i = 0; i < loadElements->getLength(); ++i) {
561  DOMElement* loadElement = static_cast<DOMElement*>(loadElements->item(i));
562  std::string fileName = cms::xerces::toString(loadElement->getAttribute(kAttrModule));
563  if (fileName.find("/") != 0) { // load element has a relative path
564  // build an absolute path with directory of top xml file
565  size_t pos;
566  std::string topDir = "";
567  pos = topPath.find_last_of("/");
568  if (pos != std::string::npos) {
569  topDir = topPath.substr(0, pos+1);
570  }
571  fileName = topDir + fileName;
572  }
573  //std::cout << "loading file " << fileName << std::endl;
574  DOMDocument* subDoc = nullptr;
575  readDOMFromFile(fileName, subDoc);
576  if (subDoc) {
577  appendNodesFromSubDoc(keyElement, subDoc);
578  }
579  }
580  }
581 }
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 538 of file XmlConfigParser.cc.

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

Referenced by buildGlobalDoc(), and readContexts().

539 {
540  DOMElement* rootElement = doc_->getDocumentElement();
541  if (XMLString::equals(rootElement->getTagName(), kTagDb)) {
542  DOMNodeList* keyElements = rootElement->getElementsByTagName(kTagKey);
543 
544  for (XMLSize_t i = 0; i < keyElements->getLength(); ++i) {
545  DOMElement* keyElement = static_cast<DOMElement*>(keyElements->item(i));
546  if (cms::xerces::toString(keyElement->getAttribute(kAttrId)) == key) { // we found the key we were looking for
547  return keyElement;
548  }
549  }
550  }
551  return nullptr;
552 }
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 634 of file XmlConfigParser.cc.

Referenced by readContext(), and readHwDescription().

635 {
636  std::size_t alphanumBegin = str.find_first_not_of("\n\t ");
637  std::size_t alphanumEnd = str.find_last_not_of("\n\t ");
638  if (alphanumBegin != std::string::npos) {
639  if (alphanumEnd != std::string::npos) {
640  str = str.substr(alphanumBegin, alphanumEnd - alphanumBegin + 1);
641  } else {
642  str = str.substr(alphanumBegin);
643  }
644  }
645 }
char * XmlConfigParser::pruneString ( char *&  str)
private

Definition at line 623 of file XmlConfigParser.cc.

References XmlConfigParser_reject_symbols.

624 {
625  size_t alphanumBegin = 0, alphanumEnd = strlen(str)-1;
626 
627  while( str[alphanumBegin] && XmlConfigParser_reject_symbols[ unsigned(str[alphanumBegin]) ] ) alphanumBegin++;
628  while( alphanumEnd >= alphanumBegin && XmlConfigParser_reject_symbols[ unsigned(str[alphanumEnd] ) ] ) alphanumEnd--;
629 
630  str[alphanumEnd+1] = '\0';
631  return str + alphanumBegin;
632 }
const char XmlConfigParser_reject_symbols[256]
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 390 of file XmlConfigParser.cc.

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

Referenced by readContexts(), and readElement().

391 {
392  std::string systemId = sysId;
393  if (systemId == "") {
394  systemId = aTriggerSystem.systemId();
395  }
396  if (cms::xerces::toString(element->getAttribute(kAttrId)) == systemId) {
397  DOMNodeList* contextElements = element->getElementsByTagName(kTagContext);
398 
399  for (XMLSize_t i = 0; i < contextElements->getLength(); ++i) {
400  DOMElement* contextElement = static_cast<DOMElement*>(contextElements->item(i));
401  std::string contextId = cms::xerces::toString(contextElement->getAttribute(kAttrId));
402  pruneString(contextId);
403 
404  for (DOMElement* elem = static_cast<DOMElement*>(contextElement->getFirstChild()); elem; elem = static_cast<DOMElement*>(elem->getNextSibling())) {
405  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
406  if (XMLString::equals(elem->getTagName(), kTagParam)) {
407  // found a parameter
408  string id = cms::xerces::toString( elem->getAttribute(kAttrId) );
409  string type = cms::xerces::toString( elem->getAttribute(kAttrType) );
410  string delim = cms::xerces::toString( elem->getAttribute(kAttrDelim) );
411  pruneString(id);
412  pruneString(type);
413  pruneString(delim);
414 
415  // the type table needs special treatment since it consists of child nodes
416  if (type == kTypeTable) {
417 
418  // get the columns string
419  std::string columnsStr = "";
420  DOMNodeList* colElements = elem->getElementsByTagName(kTagColumns);
421  for (XMLSize_t j = 0; j < colElements->getLength(); ++j) {
422  DOMNodeList* colChilds = colElements->item(j)->getChildNodes();
423  for (XMLSize_t k = 0; k < colChilds->getLength(); ++k) {
424  if (colChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
427  char *cStr = xercesc::XMLString::transcode( colChilds->item(k)->getNodeValue() );
428  char *saveptr, first = 1;
429  for(char *item=strtok_r(cStr,delim.c_str(),&saveptr);
430  item != NULL;
431  item = strtok_r(NULL,delim.c_str(),&saveptr), first=0
432  ) columnsStr += (first ? std::string("") : delim) + pruneString(item);
434  }
435  }
436  }
437 
438  // get the column type string
439  std::string typesStr = "";
440  DOMNodeList* colTypesElements = elem->getElementsByTagName(kTagTypes);
441  for (XMLSize_t j = 0; j < colTypesElements->getLength(); ++j) {
442  DOMNodeList* colTypesChilds = colTypesElements->item(j)->getChildNodes();
443  for (XMLSize_t k = 0; k < colTypesChilds->getLength(); ++k) {
444  if (colTypesChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
447  char *tStr = xercesc::XMLString::transcode( colTypesChilds->item(k)->getNodeValue() );
448  char *saveptr, first = 1;
449  for(char *item=strtok_r(tStr,delim.c_str(),&saveptr);
450  item != NULL;
451  item = strtok_r(NULL,delim.c_str(),&saveptr), first=0
452  ) typesStr += (first ? std::string("") : delim) + pruneString(item);
454  }
455  }
456  }
457 
458  // get the rows
459  std::vector<std::string> rowStrs;
460  DOMNodeList* rowElements = elem->getElementsByTagName(kTagRow);
461  for (XMLSize_t j = 0; j < rowElements->getLength(); ++j) {
462  DOMNodeList* rowChilds = rowElements->item(j)->getChildNodes();
463  for (XMLSize_t k = 0; k < rowChilds->getLength(); ++k) {
464  if (rowChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
468  char *rStr = xercesc::XMLString::transcode( rowChilds->item(k)->getNodeValue() );
469  char *saveptr, first = 1;
470  std::string row;
471  for(char *item=strtok_r(rStr,delim.c_str(),&saveptr);
472  item != NULL;
473  item = strtok_r(NULL,delim.c_str(),&saveptr), first=0
474  ) row += (first ? std::string("") : delim) + pruneString(item);
475 
476  rowStrs.push_back(row);
478  }
479  }
480  }
481 // std::cout << "param element node with id attribute " << id << " and type attribute " << typesStr << std::endl;
482  aTriggerSystem.addTable(id.c_str(), contextId.c_str(), columnsStr.c_str(), typesStr.c_str(), rowStrs, delim.c_str());
483 
484  } else { // all types other than table
485  std::string value = "";
486  DOMNodeList* valNodes = elem->getChildNodes();
487  for (XMLSize_t j = 0; j < valNodes->getLength(); ++j) {
488  if (valNodes->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
489  value += cms::xerces::toString(valNodes->item(j)->getNodeValue()); // should we prune?
490  }
491  }
492 
493  // strip leading and trailing line breaks and spaces
494  pruneString(value);
495 
496 // std::cout << "param element node with id attribute " << id << " and type attribute " << type << " with value: [" << value << "]" << std::endl;
497  aTriggerSystem.addParameter(id.c_str(), contextId.c_str(), type.c_str(), value.c_str(), delim.c_str());
498 
499  }
500 
501  } else if (XMLString::equals(elem->getTagName(), kTagMask)) {
502  // found a Mask
503  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
504  //std::cout << "Mask element node with id attribute " << id << std::endl;
505  pruneString(id);
506  aTriggerSystem.addMask(id.c_str(), contextId.c_str());
507 
508  } else if (XMLString::equals(elem->getTagName(), kTagDisable)) {
509  // found a disable
510  std::string id = cms::xerces::toString(elem->getAttribute(kAttrId));
511  pruneString(id);
512  aTriggerSystem.disableProcOrRoleOrDaq(id.c_str());
513  }
514  }
515  }
516  }
517  }
518 }
type
Definition: HCALResponse.h:21
void pruneString(std::string &str)
const XMLCh * kTagMask
const std::string kTypeTable
const XMLCh * kAttrDelim
const XMLCh * kTagRow
#define NULL
Definition: scimark2.h:8
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:18
int k[5][pyjets_maxn]
std::string systemId(void) const noexcept
Definition: TriggerSystem.h:70
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 521 of file XmlConfigParser.cc.

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

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

522 {
523  DOMElement* keyElement = getKeyElement(key);
524  if (keyElement) {
525  for (DOMElement* elem = static_cast<DOMElement*>(keyElement->getFirstChild()); elem; elem = static_cast<DOMElement*>(elem->getNextSibling())) {
526  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
527  if (XMLString::equals(elem->getTagName(), kTagAlgo) || XMLString::equals(elem->getTagName(), kTagRunSettings)) {
528  readContext(elem, sysId, aTriggerSystem);
529  }
530  }
531  }
532  } else {
533  throw std::runtime_error("Key not found: " + key);
534  }
535 }
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:18
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 190 of file XmlConfigParser.cc.

References doc_, and parser_.

191 {
192  parser_->parse(fName.c_str());
193  doc_ = parser_->getDocument();
194 
195  if (! doc_) {
196  edm::LogError("XmlConfigParser") << "Could not parse file " << fName << "\n";
197  }
198 
199  assert(doc_);
200 }
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 168 of file XmlConfigParser.cc.

References doc_, parser_, readDOMFromFile(), and AlCaHLTBitMon_QueryRunRegistry::string.

169 {
170  MemBufInputSource xmlstr_buf((const XMLByte*)(str.c_str()), str.size(), "xmlstrbuf");
171  parser_->parse(xmlstr_buf);
172  doc_ = parser_->getDocument();
173  assert(doc_);
174 }
xercesc::DOMDocument * doc_
xercesc::XercesDOMParser * parser_
void XmlConfigParser::readElement ( const xercesc::DOMElement *  element,
TriggerSystem aTriggerSystem,
const std::string &  sysId = "" 
)

Definition at line 216 of file XmlConfigParser.cc.

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

Referenced by readRootElement().

217 {
218  if (XMLString::equals(element->getTagName(), kTagHw)) {
219  // in case this is a HW description
220  readHwDescription(element, aTriggerSystem, sysId);
221  } else if (XMLString::equals(element->getTagName(), kTagAlgo) || XMLString::equals(element->getTagName(), kTagRunSettings)) {
222  // in case this is a configuration snippet
223  readContext(element, sysId, aTriggerSystem);
224  }
225 }
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 228 of file XmlConfigParser.cc.

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

Referenced by readElement().

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

References doc_, and readElement().

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

204 {
205  DOMElement* rootElement = doc_->getDocumentElement();
206  if (rootElement) {
207  if (rootElement->getNodeType() == DOMNode::ELEMENT_NODE) {
208  readElement(rootElement, aTriggerSystem, sysId);
209  }
210  } else {
211  throw std::runtime_error("No xml root element found");
212  }
213 }
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 49 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kAttrId

Definition at line 47 of file XmlConfigParser.h.

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

const XMLCh* l1t::XmlConfigParser::kAttrModule

Definition at line 50 of file XmlConfigParser.h.

Referenced by buildGlobalDoc(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kAttrType

Definition at line 48 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

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

Definition at line 39 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagContext

Definition at line 33 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagCrate

Definition at line 44 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagDaqTtc

Definition at line 46 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagDb

Definition at line 30 of file XmlConfigParser.h.

Referenced by getKeyElement(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagDisable

Definition at line 36 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagExclBoards

Definition at line 37 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagExclude

Definition at line 38 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagHw

Definition at line 27 of file XmlConfigParser.h.

Referenced by readElement(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagKey

Definition at line 31 of file XmlConfigParser.h.

Referenced by getKeyElement(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagLoad

Definition at line 32 of file XmlConfigParser.h.

Referenced by buildGlobalDoc(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagMask

Definition at line 35 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagParam

Definition at line 34 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagProcessor

Definition at line 42 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagRole

Definition at line 43 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagRow

Definition at line 41 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

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

Definition at line 45 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

const XMLCh* l1t::XmlConfigParser::kTagTypes

Definition at line 40 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

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

Definition at line 51 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

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