CMS 3D CMS Logo

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

#include <XmlConfigReader.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, TrigSystem &aTrigSystem)
 
void readContexts (const std::string &key, const std::string &sysId, TrigSystem &aTrigSystem)
 
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, TrigSystem &aTrigSystem, const std::string &sysId="")
 
void readHwDescription (const xercesc::DOMElement *element, TrigSystem &aTrigSystem, const std::string &sysId="")
 
void readRootElement (TrigSystem &aTrigSystem, const std::string &sysId="")
 
 XmlConfigReader ()
 
 XmlConfigReader (xercesc::DOMDocument *doc)
 
 ~XmlConfigReader ()
 

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 XmlConfigReader.h.

Constructor & Destructor Documentation

XmlConfigReader::XmlConfigReader ( )

Initialise XML parser

Definition at line 26 of file XmlConfigReader.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, parser_, and XERCES_CPP_NAMESPACE_USE::transcode().

26  :
27  kTagHw(nullptr),
28  kTagAlgo(nullptr),
29  kTagRunSettings(nullptr),
30  kTagDb(nullptr),
31  kTagKey(nullptr),
32  kTagLoad(nullptr),
33  kTagContext(nullptr),
34  kTagParam(nullptr),
35  kTagMask(nullptr),
36  kTagDisable(nullptr),
37  kTagExclBoards(nullptr),
38  kTagExclude(nullptr),
39  kTagColumns(nullptr),
40  kTagTypes(nullptr),
41  kTagRow(nullptr),
42  kTagProcessor( nullptr),
43  kTagRole(nullptr),
44  kTagCrate(nullptr),
45  kTagSlot(nullptr),
46  kTagDaqTtc(nullptr),
47  kAttrId(nullptr),
48  kAttrType(nullptr),
49  kAttrDelim(nullptr),
50  kAttrModule(nullptr),
51  kTypeTable("table")
52 {
53  XMLPlatformUtils::Initialize();
54 
55  kTagHw = XMLString::transcode("system");
57  kTagRunSettings = XMLString::transcode("run-settings");
61  kTagContext = XMLString::transcode("context");
64  kTagDisable = XMLString::transcode("disable");
65  kTagExclBoards = XMLString::transcode("excluded-boards");
66  kTagExclude = XMLString::transcode("exclude");
67  kTagColumns = XMLString::transcode("columns");
70  kTagProcessor = XMLString::transcode("processor");
74  kTagDaqTtc = XMLString::transcode("daqttc-mgr");
77  kAttrDelim = XMLString::transcode("delimiter");
79 
81  parser_ = new XercesDOMParser();
82  parser_->setValidationScheme(XercesDOMParser::Val_Auto);
83  parser_->setDoNamespaces(false);
84 
85  doc_ = nullptr;
86 }
const std::string kTypeTable
const XMLCh * kTagSlot
const XMLCh * kTagExclude
const XMLCh * kTagDaqTtc
const XMLCh * kTagKey
const XMLCh * kTagMask
const XMLCh * kTagCrate
const XMLCh * kTagRow
const XMLCh * kAttrType
const XMLCh * kTagExclBoards
const XMLCh * kTagTypes
const XMLCh * kTagLoad
const XMLCh * kTagContext
XMLCh * transcode(const T &fInput)
xercesc::XercesDOMParser * parser_
const XMLCh * kAttrDelim
const XMLCh * kTagDisable
const XMLCh * kTagHw
const XMLCh * kTagDb
const XMLCh * kTagParam
xercesc::DOMDocument * doc_
const XMLCh * kTagRole
const XMLCh * kAttrModule
const XMLCh * kTagRunSettings
const XMLCh * kTagProcessor
const XMLCh * kTagColumns
const XMLCh * kTagAlgo
const XMLCh * kAttrId
l1t::XmlConfigReader::XmlConfigReader ( xercesc::DOMDocument *  doc)
XmlConfigReader::~XmlConfigReader ( )

Definition at line 148 of file XmlConfigReader.cc.

References parser_.

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

Member Function Documentation

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

Definition at line 504 of file XmlConfigReader.cc.

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

Referenced by buildGlobalDoc().

505 {
506  DOMElement* subDocRootElement = subDoc->getDocumentElement();
507  //std::cout << "root element tag: " << _toString(subDocRootElement->getTagName()) << std::endl;
508  if (XMLString::equals(subDocRootElement->getTagName(), kTagAlgo) || XMLString::equals(subDocRootElement->getTagName(), kTagRunSettings)) {
509  DOMNode* importedNode = doc_->importNode(subDocRootElement, true);
510  parentNode->appendChild(importedNode);
511  }
512 }
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
xercesc::DOMDocument * doc_
const XMLCh * kTagRunSettings
const XMLCh * kTagAlgo
void XmlConfigReader::buildGlobalDoc ( const std::string &  key,
const std::string &  topPath = "" 
)

Definition at line 475 of file XmlConfigReader.cc.

References _toString(), appendNodesFromSubDoc(), MillePedeFileConverter_cfg::fileName, getKeyElement(), i, kAttrModule, kTagLoad, readDOMFromFile(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

476 {
477  DOMElement* keyElement = getKeyElement(key);
478  if (keyElement) {
479  DOMNodeList* loadElements = keyElement->getElementsByTagName(kTagLoad);
480  for (XMLSize_t i = 0; i < loadElements->getLength(); ++i) {
481  DOMElement* loadElement = static_cast<DOMElement*>(loadElements->item(i));
482  std::string fileName = _toString(loadElement->getAttribute(kAttrModule));
483  if (fileName.find("/") != 0) { // load element has a relative path
484  // build an absolute path with directory of top xml file
485  size_t pos;
486  std::string topDir = "";
487  pos = topPath.find_last_of("/");
488  if (pos != std::string::npos) {
489  topDir = topPath.substr(0, pos+1);
490  }
491  fileName = topDir + fileName;
492  }
493  //std::cout << "loading file " << fileName << std::endl;
494  DOMDocument* subDoc = nullptr;
495  readDOMFromFile(fileName, subDoc);
496  if (subDoc) {
497  appendNodesFromSubDoc(keyElement, subDoc);
498  }
499  }
500  }
501 }
void readDOMFromFile(const std::string &fName, xercesc::DOMDocument *&doc)
int i
Definition: DBlmapReader.cc:9
std::string _toString(const XMLCh *toTranscode)
const XMLCh * kTagLoad
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
const XMLCh * kAttrModule
xercesc::DOMElement * getKeyElement(const std::string &key)
void appendNodesFromSubDoc(xercesc::DOMNode *parentNode, xercesc::DOMDocument *subDoc)
DOMElement * XmlConfigReader::getKeyElement ( const std::string &  key)

Definition at line 458 of file XmlConfigReader.cc.

References _toString(), doc_, equals(), i, kAttrId, kTagDb, and kTagKey.

Referenced by buildGlobalDoc(), and readContexts().

459 {
460  DOMElement* rootElement = doc_->getDocumentElement();
461  if (XMLString::equals(rootElement->getTagName(), kTagDb)) {
462  DOMNodeList* keyElements = rootElement->getElementsByTagName(kTagKey);
463 
464  for (XMLSize_t i = 0; i < keyElements->getLength(); ++i) {
465  DOMElement* keyElement = static_cast<DOMElement*>(keyElements->item(i));
466  if (_toString(keyElement->getAttribute(kAttrId)) == key) { // we found the key we were looking for
467  return keyElement;
468  }
469  }
470  }
471  return nullptr;
472 }
int i
Definition: DBlmapReader.cc:9
std::string _toString(const XMLCh *toTranscode)
const XMLCh * kTagKey
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
const XMLCh * kTagDb
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
xercesc::DOMDocument * doc_
const XMLCh * kAttrId
void XmlConfigReader::pruneString ( std::string &  str)
private

Definition at line 554 of file XmlConfigReader.cc.

Referenced by readContext().

555 {
556  std::size_t alphanumBegin = str.find_first_not_of("\n\t ");
557  std::size_t alphanumEnd = str.find_last_not_of("\n\t ");
558  if (alphanumBegin != std::string::npos) {
559  if (alphanumEnd != std::string::npos) {
560  str = str.substr(alphanumBegin, alphanumEnd - alphanumBegin + 1);
561  } else {
562  str = str.substr(alphanumBegin);
563  }
564  }
565 }
char * XmlConfigReader::pruneString ( char *&  str)
private

Definition at line 543 of file XmlConfigReader.cc.

References XmlConfigReader_reject_symbols.

544 {
545  size_t alphanumBegin = 0, alphanumEnd = strlen(str)-1;
546 
547  while( str[alphanumBegin] && XmlConfigReader_reject_symbols[ unsigned(str[alphanumBegin]) ] ) alphanumBegin++;
548  while( alphanumEnd >= alphanumBegin && XmlConfigReader_reject_symbols[ unsigned(str[alphanumEnd] ) ] ) alphanumEnd--;
549 
550  str[alphanumEnd+1] = '\0';
551  return str + alphanumBegin;
552 }
const char XmlConfigReader_reject_symbols[256]
void XmlConfigReader::readContext ( const xercesc::DOMElement *  element,
const std::string &  sysId,
TrigSystem aTrigSystem 
)

columnsStr = _toString(colChilds->item(k)->getNodeValue()); pruneString(columnsStr);

typesStr = _toString(colTypesChilds->item(k)->getNodeValue()); pruneString(typesStr);

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

Definition at line 328 of file XmlConfigReader.cc.

References _toString(), l1t::TrigSystem::addMask(), l1t::TrigSystem::addSetting(), l1t::TrigSystem::addSettingTable(), l1t::TrigSystem::disableDaqProc(), HTMLExport::elem(), equals(), i, j, relval_2017::k, kAttrDelim, kAttrId, kAttrType, kTagColumns, kTagContext, kTagDisable, kTagMask, kTagParam, kTagRow, kTagTypes, kTypeTable, pruneString(), fetchall_from_DQM_v2::release, AlCaHLTBitMon_QueryRunRegistry::string, l1t::TrigSystem::systemId(), XERCES_CPP_NAMESPACE_USE::transcode(), and relativeConstraints::value.

Referenced by readContexts(), and readElement().

329 {
330  std::string systemId = sysId;
331  if (systemId == "") {
332  systemId = aTrigSystem.systemId();
333  }
334  if (_toString(element->getAttribute(kAttrId)) == systemId) {
335  DOMNodeList* contextElements = element->getElementsByTagName(kTagContext);
336 
337  for (XMLSize_t i = 0; i < contextElements->getLength(); ++i) {
338  DOMElement* contextElement = static_cast<DOMElement*>(contextElements->item(i));
339  std::string contextId = _toString(contextElement->getAttribute(kAttrId));
340 
341  for (DOMElement* elem = static_cast<DOMElement*>(contextElement->getFirstChild()); elem; elem = static_cast<DOMElement*>(elem->getNextSibling())) {
342  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
343  if (XMLString::equals(elem->getTagName(), kTagParam)) {
344  // found a parameter
345  char *id = xercesc::XMLString::transcode( elem->getAttribute(kAttrId) );
346  char *type = xercesc::XMLString::transcode( elem->getAttribute(kAttrType) );
347  char *delim = xercesc::XMLString::transcode( elem->getAttribute(kAttrDelim) );
348 
349  // the type table needs special treatment since it consists of child nodes
350  if (type == kTypeTable) {
351 
352  // get the columns string
353  std::string columnsStr = "";
354  DOMNodeList* colElements = elem->getElementsByTagName(kTagColumns);
355  for (XMLSize_t j = 0; j < colElements->getLength(); ++j) {
356  DOMNodeList* colChilds = colElements->item(j)->getChildNodes();
357  for (XMLSize_t k = 0; k < colChilds->getLength(); ++k) {
358  if (colChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
361  char *cStr = xercesc::XMLString::transcode( colChilds->item(k)->getNodeValue() );
362  columnsStr = pruneString( cStr );
364  }
365  }
366  }
367 
368  // get the column type string
369  std::string typesStr = "";
370  DOMNodeList* colTypesElements = elem->getElementsByTagName(kTagTypes);
371  for (XMLSize_t j = 0; j < colTypesElements->getLength(); ++j) {
372  DOMNodeList* colTypesChilds = colTypesElements->item(j)->getChildNodes();
373  for (XMLSize_t k = 0; k < colTypesChilds->getLength(); ++k) {
374  if (colTypesChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
377  char *tStr = xercesc::XMLString::transcode( colTypesChilds->item(k)->getNodeValue() );
378  typesStr = pruneString( tStr );
380  }
381  }
382  }
383 
384  // get the rows
385  std::vector<std::string> rowStrs;
386  DOMNodeList* rowElements = elem->getElementsByTagName(kTagRow);
387  for (XMLSize_t j = 0; j < rowElements->getLength(); ++j) {
388  DOMNodeList* rowChilds = rowElements->item(j)->getChildNodes();
389  for (XMLSize_t k = 0; k < rowChilds->getLength(); ++k) {
390  if (rowChilds->item(k)->getNodeType() == DOMNode::TEXT_NODE) {
394  char *rStr = xercesc::XMLString::transcode( rowChilds->item(k)->getNodeValue() );
395  rowStrs.push_back( pruneString(rStr) );
397  }
398  }
399  }
400 // std::cout << "param element node with id attribute " << id << " and type attribute " << typesStr << std::endl;
401  aTrigSystem.addSettingTable(std::string(id), columnsStr, typesStr, rowStrs, contextId, std::string(delim));
402 
403  } else { // all types other than table
404  std::string value = "";
405  DOMNodeList* valNodes = elem->getChildNodes();
406  for (XMLSize_t j = 0; j < valNodes->getLength(); ++j) {
407  if (valNodes->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
408  value += _toString(valNodes->item(j)->getNodeValue());
409  }
410  }
411 
412  // strip leading and trailing line breaks and spaces
413  pruneString(value);
414 
415 // std::cout << "param element node with id attribute " << id << " and type attribute " << type << " with value: [" << value << "]" << std::endl;
416  aTrigSystem.addSetting(std::string(type), std::string(id), value, contextId, std::string(delim));
417  }
418 
422 
423  } else if (XMLString::equals(elem->getTagName(), kTagMask)) {
424  // found a Mask
425  std::string id = _toString(elem->getAttribute(kAttrId));
426  //std::cout << "Mask element node with id attribute " << id << std::endl;
427  aTrigSystem.addMask(id, contextId);
428 
429  } else if (XMLString::equals(elem->getTagName(), kTagDisable)) {
430  // found a disable
431  std::string id = _toString(elem->getAttribute(kAttrId));
432  aTrigSystem.disableDaqProc(id);
433  }
434  }
435  }
436  }
437  }
438 }
void disableDaqProc(const std::string &daqProc)
Definition: TrigSystem.cc:340
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
const std::string kTypeTable
std::string _toString(const XMLCh *toTranscode)
const XMLCh * kTagMask
void addMask(const std::string &id, const std::string &procRole)
Definition: TrigSystem.cc:231
void addSetting(const std::string &type, const std::string &id, const std::string &value, const std::string &procRole, const std::string &delim="")
Definition: TrigSystem.cc:82
const XMLCh * kTagRow
const XMLCh * kAttrType
const XMLCh * kTagTypes
const XMLCh * kTagContext
XMLCh * transcode(const T &fInput)
int j
Definition: DBlmapReader.cc:9
const XMLCh * kAttrDelim
const XMLCh * kTagDisable
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
std::string systemId()
Definition: TrigSystem.h:37
const XMLCh * kTagParam
void pruneString(std::string &str)
const XMLCh * kTagColumns
const XMLCh * kAttrId
void addSettingTable(const std::string &id, const std::string &columns, const std::string &types, const std::vector< std::string > &rows, const std::string &procRole, const std::string &delim)
Definition: TrigSystem.cc:131
void XmlConfigReader::readContexts ( const std::string &  key,
const std::string &  sysId,
TrigSystem aTrigSystem 
)

Definition at line 441 of file XmlConfigReader.cc.

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

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

442 {
443  DOMElement* keyElement = getKeyElement(key);
444  if (keyElement) {
445  for (DOMElement* elem = static_cast<DOMElement*>(keyElement->getFirstChild()); elem; elem = static_cast<DOMElement*>(elem->getNextSibling())) {
446  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
447  if (XMLString::equals(elem->getTagName(), kTagAlgo) || XMLString::equals(elem->getTagName(), kTagRunSettings)) {
448  readContext(elem, sysId, aTrigSystem);
449  }
450  }
451  }
452  } else {
453  std::cout << "Key not found: " << key << std::endl;
454  }
455 }
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
const XMLCh * kTagRunSettings
tuple cout
Definition: gather_cfg.py:145
xercesc::DOMElement * getKeyElement(const std::string &key)
const XMLCh * kTagAlgo
void readContext(const xercesc::DOMElement *element, const std::string &sysId, TrigSystem &aTrigSystem)
void l1t::XmlConfigReader::readDOMFromFile ( const std::string &  fName,
xercesc::DOMDocument *&  doc 
)
void XmlConfigReader::readDOMFromFile ( const std::string &  fName)

Definition at line 186 of file XmlConfigReader.cc.

References assert(), doc_, and parser_.

187 {
188  parser_->parse(fName.c_str());
189  doc_ = parser_->getDocument();
190 
191  if (! doc_) {
192  edm::LogError("XmlConfigReader") << "Could not parse file " << fName << "\n";
193  }
194 
195  assert(doc_);
196 }
assert(m_qm.get())
xercesc::XercesDOMParser * parser_
xercesc::DOMDocument * doc_
void l1t::XmlConfigReader::readDOMFromString ( const std::string &  str,
xercesc::DOMDocument *&  doc 
)
void XmlConfigReader::readDOMFromString ( const std::string &  str)

Definition at line 164 of file XmlConfigReader.cc.

References assert(), doc_, and parser_.

165 {
166  MemBufInputSource xmlstr_buf((const XMLByte*)(str.c_str()), str.size(), "xmlstrbuf");
167  parser_->parse(xmlstr_buf);
168  doc_ = parser_->getDocument();
169  assert(doc_);
170 }
assert(m_qm.get())
xercesc::XercesDOMParser * parser_
xercesc::DOMDocument * doc_
void XmlConfigReader::readElement ( const xercesc::DOMElement *  element,
TrigSystem aTrigSystem,
const std::string &  sysId = "" 
)

Definition at line 212 of file XmlConfigReader.cc.

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

Referenced by readRootElement().

213 {
214  if (XMLString::equals(element->getTagName(), kTagHw)) {
215  // in case this is a HW description
216  readHwDescription(element, aTrigSystem, sysId);
217  } else if (XMLString::equals(element->getTagName(), kTagAlgo) || XMLString::equals(element->getTagName(), kTagRunSettings)) {
218  // in case this is a configuration snippet
219  readContext(element, sysId, aTrigSystem);
220  }
221 }
void readHwDescription(const xercesc::DOMElement *element, TrigSystem &aTrigSystem, const std::string &sysId="")
const XMLCh * kTagHw
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
const XMLCh * kTagRunSettings
const XMLCh * kTagAlgo
void readContext(const xercesc::DOMElement *element, const std::string &sysId, TrigSystem &aTrigSystem)
void XmlConfigReader::readHwDescription ( const xercesc::DOMElement *  element,
TrigSystem aTrigSystem,
const std::string &  sysId = "" 
)

Definition at line 224 of file XmlConfigReader.cc.

References _toString(), l1t::TrigSystem::addDaqCrate(), l1t::TrigSystem::addDaqRole(), l1t::TrigSystem::addProcCrate(), l1t::TrigSystem::addProcRole(), l1t::TrigSystem::addProcSlot(), l1t::TrigSystem::disableDaqProc(), HTMLExport::elem(), equals(), i, j, kAttrId, kTagCrate, kTagDaqTtc, kTagExclBoards, kTagExclude, kTagProcessor, kTagRole, kTagSlot, l1t::TrigSystem::setSystemId(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by readElement().

225 {
226  // if sysId == "" set the systemId of the trigsystem from the xml sytem id
227  if (sysId != "" && sysId != _toString(element->getAttribute(kAttrId))) {
228  return;
229  }
230  aTrigSystem.setSystemId(_toString(element->getAttribute(kAttrId)));
231 
232  // handle processors
233  DOMNodeList* processors = element->getElementsByTagName(kTagProcessor);
234  XMLSize_t nodeCount = processors->getLength();
235  for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {
236  DOMNode* currentNode = processors->item(xx);
237  if (currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE) { //no null and is element
238  DOMElement* currentElement = static_cast<DOMElement*>( currentNode );
239  std::string procStr = _toString(currentElement->getAttribute(kAttrId));
240 
241  DOMNodeList* roles = currentElement->getElementsByTagName(kTagRole);
242  // roles of this processor (should be only one)
243  for (XMLSize_t i = 0; i < roles->getLength(); ++i) {
244  DOMNodeList* roleChilds = roles->item(i)->getChildNodes();
245  for (XMLSize_t j = 0; j < roleChilds->getLength(); ++j) {
246  if (roleChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
247  aTrigSystem.addProcRole(procStr, _toString(roleChilds->item(j)->getNodeValue()));
248  }
249  }
250  }
251 
252  DOMNodeList* crates = currentElement->getElementsByTagName(kTagCrate);
253  // crates of this processor (should be only one)
254  for (XMLSize_t i = 0; i < crates->getLength(); ++i) {
255  DOMNodeList* crateChilds = crates->item(i)->getChildNodes();
256  for (XMLSize_t j = 0; j < crateChilds->getLength(); ++j) {
257  if (crateChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
258  aTrigSystem.addProcCrate(procStr, _toString(crateChilds->item(j)->getNodeValue()));
259  }
260  }
261  }
262 
263  DOMNodeList* slots = currentElement->getElementsByTagName(kTagSlot);
264  // slots of this processor (should be only one)
265  for (XMLSize_t i = 0; i < slots->getLength(); ++i) {
266  DOMNodeList* slotChilds = slots->item(i)->getChildNodes();
267  for (XMLSize_t j = 0; j < slotChilds->getLength(); ++j) {
268  if (slotChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
269  aTrigSystem.addProcSlot(procStr, _toString(slotChilds->item(j)->getNodeValue()));
270  }
271  }
272  }
273 
274  }
275  }
276 
277  // handle DAQ TTC managers
278  DOMNodeList* daqttcs = element->getElementsByTagName(kTagDaqTtc);
279  nodeCount = daqttcs->getLength();
280  for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {
281  DOMNode* currentNode = daqttcs->item(xx);
282  if (currentNode->getNodeType() && currentNode->getNodeType() == DOMNode::ELEMENT_NODE) { //no null and is element
283  DOMElement* currentElement = static_cast<DOMElement*>( currentNode );
284  std::string daqttcStr = _toString(currentElement->getAttribute(kAttrId));
285 
286  DOMNodeList* roles = currentElement->getElementsByTagName(kTagRole);
287  // roles of this DAQ TTC manager (should be only one)
288  for (XMLSize_t i = 0; i < roles->getLength(); ++i) {
289  DOMNodeList* roleChilds = roles->item(i)->getChildNodes();
290  for (XMLSize_t j = 0; j < roleChilds->getLength(); ++j) {
291  if (roleChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
292  aTrigSystem.addDaqRole(daqttcStr, _toString(roleChilds->item(j)->getNodeValue()));
293  }
294  }
295  }
296 
297  DOMNodeList* crates = currentElement->getElementsByTagName(kTagCrate);
298  // crates of this DAQ TTC manager (should be only one)
299  for (XMLSize_t i = 0; i < crates->getLength(); ++i) {
300  DOMNodeList* crateChilds = crates->item(i)->getChildNodes();
301  for (XMLSize_t j = 0; j < crateChilds->getLength(); ++j) {
302  if (crateChilds->item(j)->getNodeType() == DOMNode::TEXT_NODE) {
303  aTrigSystem.addDaqCrate(daqttcStr, _toString(crateChilds->item(j)->getNodeValue()));
304  }
305  }
306  }
307  }
308  }
309 
310  // handle excluded boards
311  DOMNodeList* exclBoards = element->getElementsByTagName(kTagExclBoards);
312  for (XMLSize_t xx = 0; xx < exclBoards->getLength(); ++xx) {
313  DOMElement* exclBoardElem = static_cast<DOMElement*>(exclBoards->item(xx));
314 
315  for (DOMElement* elem = static_cast<DOMElement*>(exclBoardElem->getFirstChild()); elem; elem = static_cast<DOMElement*>(elem->getNextSibling())) {
316  if (elem->getNodeType() == DOMNode::ELEMENT_NODE) {
317  if (XMLString::equals(elem->getTagName(), kTagExclude)) {
318  // found an excluded board
319  std::string id = _toString(elem->getAttribute(kAttrId));
320  aTrigSystem.disableDaqProc(id); // handle in the same way as disabled ids in the run-settings
321  }
322  }
323  }
324  }
325 }
void disableDaqProc(const std::string &daqProc)
Definition: TrigSystem.cc:340
int i
Definition: DBlmapReader.cc:9
const XMLCh * kTagSlot
const XMLCh * kTagExclude
const XMLCh * kTagDaqTtc
std::string _toString(const XMLCh *toTranscode)
void addDaqRole(const std::string &daq, const std::string &role)
Definition: TrigSystem.cc:65
const XMLCh * kTagCrate
void addProcRole(const std::string &processor, const std::string &role)
Definition: TrigSystem.cc:39
const XMLCh * kTagExclBoards
void addProcCrate(const std::string &processor, const std::string &crate)
Definition: TrigSystem.cc:60
int j
Definition: DBlmapReader.cc:9
void addDaqCrate(const std::string &daq, const std::string &crate)
Definition: TrigSystem.cc:77
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
const XMLCh * kTagRole
void addProcSlot(const std::string &processor, const std::string &slot)
Definition: TrigSystem.cc:55
const XMLCh * kTagProcessor
void setSystemId(const std::string id)
Definition: TrigSystem.h:38
const XMLCh * kAttrId
void XmlConfigReader::readRootElement ( TrigSystem aTrigSystem,
const std::string &  sysId = "" 
)

Definition at line 199 of file XmlConfigReader.cc.

References gather_cfg::cout, doc_, and readElement().

Referenced by l1t::TrigSystem::configureSystemFromFiles(), and L1TGlobalPrescalesVetosESProducer::L1TGlobalPrescalesVetosESProducer().

200 {
201  DOMElement* rootElement = doc_->getDocumentElement();
202  if (rootElement) {
203  if (rootElement->getNodeType() == DOMNode::ELEMENT_NODE) {
204  readElement(rootElement, aTrigSystem, sysId);
205  }
206  } else {
207  std::cout << "No xml root element found" << std::endl;
208  }
209 }
void readElement(const xercesc::DOMElement *element, TrigSystem &aTrigSystem, const std::string &sysId="")
xercesc::DOMDocument * doc_
tuple cout
Definition: gather_cfg.py:145

Member Data Documentation

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

Definition at line 49 of file XmlConfigReader.h.

Referenced by readContext(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kAttrId

Definition at line 47 of file XmlConfigReader.h.

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

const XMLCh* l1t::XmlConfigReader::kAttrModule

Definition at line 50 of file XmlConfigReader.h.

Referenced by buildGlobalDoc(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kAttrType

Definition at line 48 of file XmlConfigReader.h.

Referenced by readContext(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagAlgo
const XMLCh* l1t::XmlConfigReader::kTagColumns

Definition at line 39 of file XmlConfigReader.h.

Referenced by readContext(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagContext

Definition at line 33 of file XmlConfigReader.h.

Referenced by readContext(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagCrate

Definition at line 44 of file XmlConfigReader.h.

Referenced by readHwDescription(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagDaqTtc

Definition at line 46 of file XmlConfigReader.h.

Referenced by readHwDescription(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagDb

Definition at line 30 of file XmlConfigReader.h.

Referenced by getKeyElement(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagDisable

Definition at line 36 of file XmlConfigReader.h.

Referenced by readContext(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagExclBoards

Definition at line 37 of file XmlConfigReader.h.

Referenced by readHwDescription(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagExclude

Definition at line 38 of file XmlConfigReader.h.

Referenced by readHwDescription(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagHw

Definition at line 27 of file XmlConfigReader.h.

Referenced by readElement(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagKey

Definition at line 31 of file XmlConfigReader.h.

Referenced by getKeyElement(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagLoad

Definition at line 32 of file XmlConfigReader.h.

Referenced by buildGlobalDoc(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagMask

Definition at line 35 of file XmlConfigReader.h.

Referenced by readContext(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagParam

Definition at line 34 of file XmlConfigReader.h.

Referenced by readContext(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagProcessor

Definition at line 42 of file XmlConfigReader.h.

Referenced by readHwDescription(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagRole

Definition at line 43 of file XmlConfigReader.h.

Referenced by readHwDescription(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagRow

Definition at line 41 of file XmlConfigReader.h.

Referenced by readContext(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagRunSettings
const XMLCh* l1t::XmlConfigReader::kTagSlot

Definition at line 45 of file XmlConfigReader.h.

Referenced by readHwDescription(), and XmlConfigReader().

const XMLCh* l1t::XmlConfigReader::kTagTypes

Definition at line 40 of file XmlConfigReader.h.

Referenced by readContext(), and XmlConfigReader().

const std::string l1t::XmlConfigReader::kTypeTable

Definition at line 51 of file XmlConfigReader.h.

Referenced by readContext().

xercesc::XercesDOMParser* l1t::XmlConfigReader::parser_
private