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)
 
void readDOMFromFile (const std::string &fName, xercesc::DOMDocument *&doc)
 
void readDOMFromString (const std::string &str)
 
void readDOMFromString (const std::string &str, xercesc::DOMDocument *&doc)
 
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)
 
char * pruneString (char *&str)
 
void pruneString (std::string &str)
 

Private Attributes

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

Detailed Description

Definition at line 23 of file XmlConfigParser.h.

Constructor & Destructor Documentation

◆ XmlConfigParser() [1/2]

XmlConfigParser::XmlConfigParser ( )

Initialise XML parser

Definition at line 30 of file XmlConfigParser.cc.

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 }

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, and parser_.

◆ XmlConfigParser() [2/2]

l1t::XmlConfigParser::XmlConfigParser ( xercesc::DOMDocument *  doc)

◆ ~XmlConfigParser()

XmlConfigParser::~XmlConfigParser ( )

Definition at line 148 of file XmlConfigParser.cc.

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

References parser_.

Member Function Documentation

◆ appendNodesFromSubDoc()

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

Definition at line 560 of file XmlConfigParser.cc.

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 }

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

Referenced by buildGlobalDoc().

◆ buildGlobalDoc()

void XmlConfigParser::buildGlobalDoc ( const std::string &  key,
const std::string &  topPath = "" 
)

Definition at line 533 of file XmlConfigParser.cc.

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 }

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

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

◆ getKeyElement()

DOMElement * XmlConfigParser::getKeyElement ( const std::string &  key)

Definition at line 518 of file XmlConfigParser.cc.

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 }

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

Referenced by buildGlobalDoc(), and readContexts().

◆ pruneString() [1/2]

char * XmlConfigParser::pruneString ( char *&  str)
private

Definition at line 582 of file XmlConfigParser.cc.

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 }

References str, and XmlConfigParser_reject_symbols.

◆ pruneString() [2/2]

void XmlConfigParser::pruneString ( std::string &  str)
private

Definition at line 594 of file XmlConfigParser.cc.

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 }

References str.

Referenced by readContext(), and readHwDescription().

◆ readContext()

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.

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
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 }

References l1t::TriggerSystem::addMask(), l1t::TriggerSystem::addParameter(), l1t::TriggerSystem::addTable(), cms::xerces::cStr(), l1t::TriggerSystem::disableProcOrRoleOrDaq(), 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().

◆ readContexts()

void XmlConfigParser::readContexts ( const std::string &  key,
const std::string &  sysId,
TriggerSystem aTriggerSystem 
)

Definition at line 502 of file XmlConfigParser.cc.

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 }

References equals(), getKeyElement(), crabWrapper::key, kTagAlgo, kTagRunSettings, and readContext().

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

◆ readDOMFromFile() [1/2]

void XmlConfigParser::readDOMFromFile ( const std::string &  fName)

Definition at line 178 of file XmlConfigParser.cc.

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 }

References cms::cuda::assert(), doc_, MainPageGenerator::fName, and parser_.

◆ readDOMFromFile() [2/2]

void l1t::XmlConfigParser::readDOMFromFile ( const std::string &  fName,
xercesc::DOMDocument *&  doc 
)

◆ readDOMFromString() [1/2]

void XmlConfigParser::readDOMFromString ( const std::string &  str)

Definition at line 160 of file XmlConfigParser.cc.

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 }

References cms::cuda::assert(), doc_, parser_, and str.

◆ readDOMFromString() [2/2]

void l1t::XmlConfigParser::readDOMFromString ( const std::string &  str,
xercesc::DOMDocument *&  doc 
)

◆ readElement()

void XmlConfigParser::readElement ( const xercesc::DOMElement *  element,
TriggerSystem aTriggerSystem,
const std::string &  sysId = "" 
)

Definition at line 200 of file XmlConfigParser.cc.

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 }

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

Referenced by readRootElement().

◆ readHwDescription()

void XmlConfigParser::readHwDescription ( const xercesc::DOMElement *  element,
TriggerSystem aTriggerSystem,
const std::string &  sysId = "" 
)

Definition at line 211 of file XmlConfigParser.cc.

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 }

References l1t::TriggerSystem::addDaq(), l1t::TriggerSystem::addProcessor(), l1t::TriggerSystem::disableProcOrRoleOrDaq(), 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().

◆ readRootElement()

void XmlConfigParser::readRootElement ( TriggerSystem aTriggerSystem,
const std::string &  sysId = "" 
)

Definition at line 189 of file XmlConfigParser.cc.

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 }

References doc_, and readElement().

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

Member Data Documentation

◆ doc_

xercesc::DOMDocument* l1t::XmlConfigParser::doc_
private

◆ kAttrDelim

const XMLCh* l1t::XmlConfigParser::kAttrDelim

Definition at line 47 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

◆ kAttrId

const XMLCh* l1t::XmlConfigParser::kAttrId

Definition at line 45 of file XmlConfigParser.h.

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

◆ kAttrModule

const XMLCh* l1t::XmlConfigParser::kAttrModule

Definition at line 48 of file XmlConfigParser.h.

Referenced by buildGlobalDoc(), and XmlConfigParser().

◆ kAttrType

const XMLCh* l1t::XmlConfigParser::kAttrType

Definition at line 46 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

◆ kTagAlgo

const XMLCh* l1t::XmlConfigParser::kTagAlgo

◆ kTagColumns

const XMLCh* l1t::XmlConfigParser::kTagColumns

Definition at line 37 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

◆ kTagContext

const XMLCh* l1t::XmlConfigParser::kTagContext

Definition at line 31 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

◆ kTagCrate

const XMLCh* l1t::XmlConfigParser::kTagCrate

Definition at line 42 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

◆ kTagDaqTtc

const XMLCh* l1t::XmlConfigParser::kTagDaqTtc

Definition at line 44 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

◆ kTagDb

const XMLCh* l1t::XmlConfigParser::kTagDb

Definition at line 28 of file XmlConfigParser.h.

Referenced by getKeyElement(), and XmlConfigParser().

◆ kTagDisable

const XMLCh* l1t::XmlConfigParser::kTagDisable

Definition at line 34 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

◆ kTagExclBoards

const XMLCh* l1t::XmlConfigParser::kTagExclBoards

Definition at line 35 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

◆ kTagExclude

const XMLCh* l1t::XmlConfigParser::kTagExclude

Definition at line 36 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

◆ kTagHw

const XMLCh* l1t::XmlConfigParser::kTagHw

Definition at line 25 of file XmlConfigParser.h.

Referenced by readElement(), and XmlConfigParser().

◆ kTagKey

const XMLCh* l1t::XmlConfigParser::kTagKey

Definition at line 29 of file XmlConfigParser.h.

Referenced by getKeyElement(), and XmlConfigParser().

◆ kTagLoad

const XMLCh* l1t::XmlConfigParser::kTagLoad

Definition at line 30 of file XmlConfigParser.h.

Referenced by buildGlobalDoc(), and XmlConfigParser().

◆ kTagMask

const XMLCh* l1t::XmlConfigParser::kTagMask

Definition at line 33 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

◆ kTagParam

const XMLCh* l1t::XmlConfigParser::kTagParam

Definition at line 32 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

◆ kTagProcessor

const XMLCh* l1t::XmlConfigParser::kTagProcessor

Definition at line 40 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

◆ kTagRole

const XMLCh* l1t::XmlConfigParser::kTagRole

Definition at line 41 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

◆ kTagRow

const XMLCh* l1t::XmlConfigParser::kTagRow

Definition at line 39 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

◆ kTagRunSettings

const XMLCh* l1t::XmlConfigParser::kTagRunSettings

◆ kTagSlot

const XMLCh* l1t::XmlConfigParser::kTagSlot

Definition at line 43 of file XmlConfigParser.h.

Referenced by readHwDescription(), and XmlConfigParser().

◆ kTagTypes

const XMLCh* l1t::XmlConfigParser::kTagTypes

Definition at line 38 of file XmlConfigParser.h.

Referenced by readContext(), and XmlConfigParser().

◆ kTypeTable

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

Definition at line 49 of file XmlConfigParser.h.

Referenced by readContext().

◆ parser_

xercesc::XercesDOMParser* l1t::XmlConfigParser::parser_
private
l1t::XmlConfigParser::doc_
xercesc::DOMDocument * doc_
Definition: XmlConfigParser.h:70
l1t::XmlConfigParser::kTagColumns
const XMLCh * kTagColumns
Definition: XmlConfigParser.h:37
mps_fire.i
i
Definition: mps_fire.py:428
l1t::TriggerSystem::addMask
void addMask(const char *id, const char *procOrRoleOrDaq)
Definition: TriggerSystem.cc:179
l1t::TriggerSystem::setSystemId
void setSystemId(const char *id) noexcept
Definition: TriggerSystem.h:72
l1t::XmlConfigParser::kTagDb
const XMLCh * kTagDb
Definition: XmlConfigParser.h:28
l1t::XmlConfigParser::appendNodesFromSubDoc
void appendNodesFromSubDoc(xercesc::DOMNode *parentNode, xercesc::DOMDocument *subDoc)
Definition: XmlConfigParser.cc:560
pos
Definition: PixelAliasList.h:18
l1t::TriggerSystem::addProcessor
void addProcessor(const char *processor, const char *role, const char *crate, const char *slot)
Definition: TriggerSystem.cc:26
cms::cuda::assert
assert(be >=bs)
l1t::XmlConfigParser::kTagDaqTtc
const XMLCh * kTagDaqTtc
Definition: XmlConfigParser.h:44
l1t::XmlConfigParser::kTagExclude
const XMLCh * kTagExclude
Definition: XmlConfigParser.h:36
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
dqmdumpme.first
first
Definition: dqmdumpme.py:55
MainPageGenerator.fName
fName
Definition: MainPageGenerator.py:301
cms::xerces::cStr
ZStr< char > cStr(XMLCh const *str)
Definition: XercesStrUtils.h:32
l1t::XmlConfigParser::getKeyElement
xercesc::DOMElement * getKeyElement(const std::string &key)
Definition: XmlConfigParser.cc:518
l1t::TriggerSystem::addTable
void addTable(const char *id, const char *procOrRole, const char *columns, const char *types, const std::vector< std::string > &rows, const char *delim)
Definition: TriggerSystem.cc:111
cms::xerces::toString
std::string toString(XMLCh const *toTranscode)
Definition: XercesStrUtils.h:34
l1t::XmlConfigParser::kTagRunSettings
const XMLCh * kTagRunSettings
Definition: XmlConfigParser.h:27
l1t::XmlConfigParser::kTagHw
const XMLCh * kTagHw
Definition: XmlConfigParser.h:25
l1t::XmlConfigParser::kTagSlot
const XMLCh * kTagSlot
Definition: XmlConfigParser.h:43
l1t::XmlConfigParser::kTagDisable
const XMLCh * kTagDisable
Definition: XmlConfigParser.h:34
equals
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
Definition: DeepCMVATagInfoProducer.cc:56
l1t::XmlConfigParser::kAttrModule
const XMLCh * kAttrModule
Definition: XmlConfigParser.h:48
str
#define str(s)
Definition: TestProcessor.cc:51
l1t::XmlConfigParser::readHwDescription
void readHwDescription(const xercesc::DOMElement *element, TriggerSystem &aTriggerSystem, const std::string &sysId="")
Definition: XmlConfigParser.cc:211
l1t::XmlConfigParser::kTagCrate
const XMLCh * kTagCrate
Definition: XmlConfigParser.h:42
dqmdumpme.k
k
Definition: dqmdumpme.py:60
l1t::TriggerSystem::disableProcOrRoleOrDaq
void disableProcOrRoleOrDaq(const char *procOrRoleOrDaq)
Definition: TriggerSystem.cc:282
l1t::XmlConfigParser::kTagTypes
const XMLCh * kTagTypes
Definition: XmlConfigParser.h:38
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
l1t::XmlConfigParser::kTagExclBoards
const XMLCh * kTagExclBoards
Definition: XmlConfigParser.h:35
l1t::XmlConfigParser::kTagAlgo
const XMLCh * kTagAlgo
Definition: XmlConfigParser.h:26
l1t::XmlConfigParser::readElement
void readElement(const xercesc::DOMElement *element, TriggerSystem &aTriggerSystem, const std::string &sysId="")
Definition: XmlConfigParser.cc:200
ValidateTausOnZEEFastSim_cff.proc
proc
Definition: ValidateTausOnZEEFastSim_cff.py:6
l1t::XmlConfigParser::readDOMFromFile
void readDOMFromFile(const std::string &fName, xercesc::DOMDocument *&doc)
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
l1t::XmlConfigParser::parser_
xercesc::XercesDOMParser * parser_
Definition: XmlConfigParser.h:69
l1t::XmlConfigParser::kTagMask
const XMLCh * kTagMask
Definition: XmlConfigParser.h:33
l1t::XmlConfigParser::kTypeTable
const std::string kTypeTable
Definition: XmlConfigParser.h:49
XmlConfigParser_reject_symbols
const char XmlConfigParser_reject_symbols[256]
Definition: XmlConfigParser.cc:571
value
Definition: value.py:1
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
l1t::XmlConfigParser::kTagRow
const XMLCh * kTagRow
Definition: XmlConfigParser.h:39
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
l1t::XmlConfigParser::kAttrId
const XMLCh * kAttrId
Definition: XmlConfigParser.h:45
l1t::XmlConfigParser::pruneString
void pruneString(std::string &str)
Definition: XmlConfigParser.cc:594
l1t::XmlConfigParser::kTagContext
const XMLCh * kTagContext
Definition: XmlConfigParser.h:31
l1t::XmlConfigParser::readContext
void readContext(const xercesc::DOMElement *element, const std::string &sysId, TriggerSystem &aTriggerSystem)
Definition: XmlConfigParser.cc:376
l1t::XmlConfigParser::kAttrDelim
const XMLCh * kAttrDelim
Definition: XmlConfigParser.h:47
l1t::XmlConfigParser::kTagRole
const XMLCh * kTagRole
Definition: XmlConfigParser.h:41
l1t::XmlConfigParser::kTagProcessor
const XMLCh * kTagProcessor
Definition: XmlConfigParser.h:40
l1t::XmlConfigParser::kAttrType
const XMLCh * kAttrType
Definition: XmlConfigParser.h:46
l1t::TriggerSystem::addParameter
void addParameter(const char *id, const char *procOrRole, const char *type, const char *value, const char *delim=",")
Definition: TriggerSystem.cc:54
l1t::XmlConfigParser::kTagLoad
const XMLCh * kTagLoad
Definition: XmlConfigParser.h:30
l1t::XmlConfigParser::kTagKey
const XMLCh * kTagKey
Definition: XmlConfigParser.h:29
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
l1t::TriggerSystem::addDaq
void addDaq(const char *daq, const char *role, const char *crate)
Definition: TriggerSystem.cc:43
crabWrapper.key
key
Definition: crabWrapper.py:19
l1t::TriggerSystem::systemId
std::string systemId(void) const noexcept
Definition: TriggerSystem.h:71
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
l1t::XmlConfigParser::kTagParam
const XMLCh * kTagParam
Definition: XmlConfigParser.h:32