CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1GtTriggerMenuXmlParser.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <string>
20 #include <vector>
21 
22 #include <iostream>
23 #include <fstream>
24 #include <iomanip>
25 
26 // user include files
27 // base class
29 
32 
36 #include <cstdint>
37 
38 // constructor
41  m_xmlErrHandler(nullptr),
42  m_triggerMenuInterface("NULL"),
43  m_triggerMenuName("NULL"),
44  m_triggerMenuImplementation("NULL"),
45  m_scaleDbKey("NULL")
46 
47 {
48  // menu names, scale key initialized to NULL due to ORACLE treatment of strings
49 
50  // empty
51 }
52 
53 // destructor
55 
56 // set the number of condition chips in GTL
57 void L1GtTriggerMenuXmlParser::setGtNumberConditionChips(const unsigned int& numberConditionChipsValue) {
58  m_numberConditionChips = numberConditionChipsValue;
59 }
60 
61 // set the number of pins on the GTL condition chips
62 void L1GtTriggerMenuXmlParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
63  m_pinsOnConditionChip = pinsOnConditionChipValue;
64 }
65 
66 // set the correspondence "condition chip - GTL algorithm word"
67 // in the hardware
68 void L1GtTriggerMenuXmlParser::setGtOrderConditionChip(const std::vector<int>& orderConditionChipValue) {
69  m_orderConditionChip = orderConditionChipValue;
70 }
71 
72 // set the number of physics trigger algorithms
73 void L1GtTriggerMenuXmlParser::setGtNumberPhysTriggers(const unsigned int& numberPhysTriggersValue) {
74  m_numberPhysTriggers = numberPhysTriggersValue;
75 }
76 
77 // set the number of technical triggers
78 void L1GtTriggerMenuXmlParser::setGtNumberTechTriggers(const unsigned int& numberTechTriggersValue) {
79  m_numberTechTriggers = numberTechTriggersValue;
80 }
81 
82 // set the number of L1 jet counts received by GT
83 void L1GtTriggerMenuXmlParser::setGtNumberL1JetCounts(const unsigned int& numberL1JetCountsValue) {
84  m_numberL1JetCounts = numberL1JetCountsValue;
85 }
86 
87 // set the condition maps
88 void L1GtTriggerMenuXmlParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) { m_conditionMap = condMap; }
89 
90 // set the trigger menu name
92  m_triggerMenuInterface = menuInterface;
93 }
94 
96 
98  m_triggerMenuImplementation = menuImplementation;
99 }
100 
101 // set menu associated scale key
103 
104 // set the vectors containing the conditions
105 void L1GtTriggerMenuXmlParser::setVecMuonTemplate(const std::vector<std::vector<L1GtMuonTemplate> >& vecMuonTempl) {
106  m_vecMuonTemplate = vecMuonTempl;
107 }
108 
109 void L1GtTriggerMenuXmlParser::setVecCaloTemplate(const std::vector<std::vector<L1GtCaloTemplate> >& vecCaloTempl) {
110  m_vecCaloTemplate = vecCaloTempl;
111 }
112 
114  const std::vector<std::vector<L1GtEnergySumTemplate> >& vecEnergySumTempl) {
115  m_vecEnergySumTemplate = vecEnergySumTempl;
116 }
117 
119  const std::vector<std::vector<L1GtJetCountsTemplate> >& vecJetCountsTempl) {
120  m_vecJetCountsTemplate = vecJetCountsTempl;
121 }
122 
124  const std::vector<std::vector<L1GtCastorTemplate> >& vecCastorTempl) {
125  m_vecCastorTemplate = vecCastorTempl;
126 }
127 
129  const std::vector<std::vector<L1GtHfBitCountsTemplate> >& vecHfBitCountsTempl) {
130  m_vecHfBitCountsTemplate = vecHfBitCountsTempl;
131 }
132 
134  const std::vector<std::vector<L1GtHfRingEtSumsTemplate> >& vecHfRingEtSumsTempl) {
135  m_vecHfRingEtSumsTemplate = vecHfRingEtSumsTempl;
136 }
137 
138 void L1GtTriggerMenuXmlParser::setVecBptxTemplate(const std::vector<std::vector<L1GtBptxTemplate> >& vecBptxTempl) {
139  m_vecBptxTemplate = vecBptxTempl;
140 }
141 
143  const std::vector<std::vector<L1GtExternalTemplate> >& vecExternalTempl) {
144  m_vecExternalTemplate = vecExternalTempl;
145 }
146 
148  const std::vector<std::vector<L1GtCorrelationTemplate> >& vecCorrelationTempl) {
149  m_vecCorrelationTemplate = vecCorrelationTempl;
150 }
151 
152 // set the vectors containing the conditions for correlation templates
153 //
154 void L1GtTriggerMenuXmlParser::setCorMuonTemplate(const std::vector<std::vector<L1GtMuonTemplate> >& corMuonTempl) {
155  m_corMuonTemplate = corMuonTempl;
156 }
157 
158 void L1GtTriggerMenuXmlParser::setCorCaloTemplate(const std::vector<std::vector<L1GtCaloTemplate> >& corCaloTempl) {
159  m_corCaloTemplate = corCaloTempl;
160 }
161 
163  const std::vector<std::vector<L1GtEnergySumTemplate> >& corEnergySumTempl) {
164  m_corEnergySumTemplate = corEnergySumTempl;
165 }
166 
167 // set the algorithm map (by algorithm names)
169 
170 // set the algorithm map (by algorithm aliases)
172 
173 // set the technical trigger map
175 
176 //
177 
178 // parse def.xml and vme.xml files
179 void L1GtTriggerMenuXmlParser::parseXmlFile(const std::string& defXmlFile, const std::string& vmeXmlFile) {
180  XERCES_CPP_NAMESPACE_USE
181 
182  // resize the vector of condition maps
183  // the number of condition chips should be correctly set before calling parseXmlFile
185 
195 
200 
201  // set the name of the trigger menu name:
202  // defXmlFile, stripped of absolute path and .xml
203  // will be overwritten by the value read from the xml file, with a warning if
204  // they are not the same
205  m_triggerMenuName = defXmlFile;
206  size_t xmlPos = m_triggerMenuName.find_last_of('/');
207  m_triggerMenuName.erase(m_triggerMenuName.begin(), m_triggerMenuName.begin() + xmlPos + 1);
208 
209  xmlPos = m_triggerMenuName.find_last_of('.');
210  m_triggerMenuName.erase(m_triggerMenuName.begin() + xmlPos, m_triggerMenuName.end());
211 
212  // error handler for xml-parser
213  m_xmlErrHandler = nullptr;
214 
215  XercesDOMParser* parser;
216 
217  LogTrace("L1GtTriggerMenuXmlParser") << "\nOpening XML-File: \n " << defXmlFile << std::endl;
218 
219  if ((parser = initXML(defXmlFile)) != nullptr) {
220  workXML(parser);
221  }
222  cleanupXML(parser);
223 }
224 
225 //
226 
229 }
230 
233 }
234 
237 }
238 
240 
242 
244 
246 
247 // private methods
248 
258 XERCES_CPP_NAMESPACE::XercesDOMParser* L1GtTriggerMenuXmlParser::initXML(const std::string& xmlFile) {
259  XERCES_CPP_NAMESPACE_USE
260 
261  // try to initialize
262  try {
264  } catch (const XMLException& toCatch) {
265  char* message = XMLString::transcode(toCatch.getMessage());
266 
267  edm::LogError("L1GtTriggerMenuXmlParser") << "Error during Xerces-c initialization! :" << message << std::endl;
268 
269  XMLString::release(&message);
270  return nullptr;
271  }
272 
273  XercesDOMParser* parser = new XercesDOMParser();
274  parser->setValidationScheme(XercesDOMParser::Val_Always);
275  parser->setDoNamespaces(false); // we got no dtd
276 
277  if (m_xmlErrHandler == nullptr) { // redundant check
278  m_xmlErrHandler = (ErrorHandler*)new HandlerBase();
279  } else {
280  // TODO ASSERTION
281  }
282  parser->setErrorHandler(m_xmlErrHandler);
283 
284  // try to parse the file
285  try {
286  parser->parse(xmlFile.c_str());
287  } catch (const XMLException& toCatch) {
288  char* message = XMLString::transcode(toCatch.getMessage());
289 
290  edm::LogError("L1GtTriggerMenuXmlParser") << "Exception while parsing XML: \n" << message << std::endl;
291 
292  XMLString::release(&message);
293  delete parser;
294  delete m_xmlErrHandler;
295  m_xmlErrHandler = nullptr;
296  return nullptr;
297  } catch (const DOMException& toCatch) {
298  char* message = XMLString::transcode(toCatch.msg);
299 
300  edm::LogError("L1GtTriggerMenuXmlParser") << "DOM-Exception while parsing XML: \n" << message << std::endl;
301 
302  XMLString::release(&message);
303  delete parser;
304  delete m_xmlErrHandler;
305  m_xmlErrHandler = nullptr;
306  return nullptr;
307  } catch (...) {
308  edm::LogError("L1GtTriggerMenuXmlParser") << "Unexpected Exception while parsing XML!" << std::endl;
309 
310  delete parser;
311  delete m_xmlErrHandler;
312  m_xmlErrHandler = nullptr;
313  return nullptr;
314  }
315 
316  return parser;
317 }
318 
319 // find a named child of a xml node
320 XERCES_CPP_NAMESPACE::DOMNode* L1GtTriggerMenuXmlParser::findXMLChild(XERCES_CPP_NAMESPACE::DOMNode* startChild,
321  const std::string& tagName,
322  bool beginOnly,
323  std::string* rest) {
324  XERCES_CPP_NAMESPACE_USE
325 
326  char* nodeName = nullptr;
327 
328  DOMNode* n1 = startChild;
329  if (n1 == nullptr) {
330  return nullptr;
331  }
332 
333  if (!tagName.empty()) {
334  nodeName = XMLString::transcode(n1->getNodeName());
335 
336  if (!beginOnly) {
337  //match the whole tag
338  while (XMLString::compareIString(nodeName, tagName.c_str())) {
339  XMLString::release(&nodeName);
340  n1 = n1->getNextSibling();
341  if (n1 == nullptr) {
342  break;
343  }
344 
345  nodeName = XMLString::transcode(n1->getNodeName());
346  }
347  } else {
348  // match only the beginning
349  while (XMLString::compareNIString(nodeName, tagName.c_str(), tagName.length())) {
350  XMLString::release(&nodeName);
351  n1 = n1->getNextSibling();
352  if (n1 == nullptr) {
353  break;
354  }
355 
356  nodeName = XMLString::transcode(n1->getNodeName());
357  }
358  if (n1 != nullptr && rest != nullptr) {
359  *rest = std::string(nodeName).substr(tagName.length(), strlen(nodeName) - tagName.length());
360  }
361  }
362  } else { // empty string given
363  while (n1->getNodeType() != DOMNode::ELEMENT_NODE) {
364  n1 = n1->getNextSibling();
365  if (n1 == nullptr) {
366  break;
367  }
368  }
369  if (n1 != nullptr && rest != nullptr) {
370  nodeName = XMLString::transcode(n1->getNodeName());
371  *rest = std::string(nodeName);
372  }
373  }
374 
375  XMLString::release(&nodeName);
376 
377  return n1;
378 }
379 
389 std::string L1GtTriggerMenuXmlParser::getXMLAttribute(const XERCES_CPP_NAMESPACE::DOMNode* node,
390  const std::string& name) {
391  XERCES_CPP_NAMESPACE_USE
392 
394 
395  // get attributes list
396  DOMNamedNodeMap* attributes = node->getAttributes();
397  if (attributes == nullptr) {
398  return ret;
399  }
400 
401  // get attribute node
402  XMLCh* attrName = XMLString::transcode(name.c_str());
403  DOMNode* attribNode = attributes->getNamedItem(attrName);
404 
405  XMLString::release(&attrName);
406  if (attribNode == nullptr) {
407  return ret;
408  }
409 
410  char* retCstr = XMLString::transcode(attribNode->getNodeValue());
411  ret = retCstr;
412  XMLString::release(&retCstr);
413 
414  return ret;
415 }
416 
425 std::string L1GtTriggerMenuXmlParser::getXMLTextValue(XERCES_CPP_NAMESPACE::DOMNode* node) {
426  XERCES_CPP_NAMESPACE_USE
427 
429 
430  DOMNode* n1 = node;
431  if (n1 == nullptr) {
432  return ret;
433  }
434 
435  const XMLCh* retXmlCh = n1->getTextContent();
436  if (retXmlCh == nullptr) {
437  return ret;
438  }
439 
440  char* retCstr = XMLString::transcode(retXmlCh);
441  XMLString::trim(retCstr); // trim spaces
442 
443  ret = retCstr;
444  XMLString::release(&retCstr);
445 
446  return ret;
447 }
448 
460  // string to determine start of hex value, do not ignore leading zeros
461  static const std::string valid_hex_start("0123456789ABCDEFabcdef");
462 
463  // string to determine end of hex value
464  static const std::string valid_hex_end("0123456789ABCDEFabcdef");
465 
466  std::string tempStr = hexString;
467 
468  // start / end position of the hex value in the string
469  unsigned int hexStart = tempStr.find_first_of(valid_hex_start);
470  unsigned int hexEnd = tempStr.find_first_not_of(valid_hex_end, hexStart);
471 
472  if (hexStart == hexEnd) {
473  LogDebug("L1GtTriggerMenuXmlParser") << "No hex value found in: " << tempStr << std::endl;
474 
475  return false;
476  }
477 
478  tempStr = tempStr.substr(hexStart, hexEnd - hexStart);
479 
480  if (tempStr.empty()) {
481  LogDebug("L1GtTriggerMenuXmlParser") << "Empty value in " << __PRETTY_FUNCTION__ << std::endl;
482 
483  return false;
484  }
485 
486  // split the string
487  std::string tempStrH, tempStrL;
488 
489  if (tempStr.length() > 16) { // more than 64 bit
490  tempStrL = tempStr.substr(tempStr.length() - 16, 16);
491  tempStrH = tempStr.substr(0, tempStr.length() - 16);
492  } else {
493  tempStrL = tempStr;
494  tempStrH = "0";
495  }
496 
497  // convert lower 64bit
498  char* endPtr = (char*)tempStrL.c_str();
499  uint64_t tempUIntL = strtoull(tempStrL.c_str(), &endPtr, 16);
500 
501  if (*endPtr != 0) {
502  LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex." << std::endl;
503 
504  return false;
505  }
506 
507  // convert higher64 bit
508  endPtr = (char*)tempStrH.c_str();
509  uint64_t tempUIntH = strtoull(tempStrH.c_str(), &endPtr, 16);
510 
511  if (*endPtr != 0) {
512  LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex." << std::endl;
513 
514  return false;
515  }
516 
517  dstL = tempUIntL;
518  dstH = tempUIntH;
519 
520  return true;
521 }
522 
533 bool L1GtTriggerMenuXmlParser::getXMLHexTextValue128(XERCES_CPP_NAMESPACE::DOMNode* node,
534  uint64_t& dstL,
535  uint64_t& dstH) {
536  if (node == nullptr) {
537  LogDebug("L1GtTriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
538 
539  return false;
540  }
541 
542  uint64_t tempUIntH, tempUIntL;
543 
544  std::string tempStr = getXMLTextValue(node);
545  if (!hexString2UInt128(tempStr, tempUIntL, tempUIntH)) {
546  return false;
547  }
548 
549  dstL = tempUIntL;
550  dstH = tempUIntH;
551 
552  return true;
553 }
554 
566 bool L1GtTriggerMenuXmlParser::getXMLHexTextValue(XERCES_CPP_NAMESPACE::DOMNode* node, uint64_t& dst) {
567  uint64_t dummyH; // dummy for eventual higher 64bit
568  uint64_t tempUInt; // temporary unsigned integer
569 
570  if (!getXMLHexTextValue128(node, tempUInt, dummyH)) {
571  return false;
572  }
573 
574  if (dummyH != 0) {
575  edm::LogError("L1GtTriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
576  return false;
577  }
578 
579  dst = tempUInt;
580 
581  return true;
582 }
583 
595 bool L1GtTriggerMenuXmlParser::countConditionChildMaxBits(XERCES_CPP_NAMESPACE::DOMNode* node,
596  const std::string& childName,
597  unsigned int& dst) {
598  XERCES_CPP_NAMESPACE_USE
599 
600  // should never happen...
601  if (node == nullptr) {
602  LogDebug("L1GtTriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
603 
604  return false;
605  }
606 
607  DOMNode* n1 = findXMLChild(node->getFirstChild(), childName);
608 
609  if (n1 == nullptr) {
610  LogDebug("L1GtTriggerMenuXmlParser") << "Child of condition not found ( " << childName << ")" << std::endl;
611 
612  return false;
613  }
614 
615  DOMNode* n2 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
616 
617  if (n2 == nullptr) {
618  LogDebug("L1GtTriggerMenuXmlParser") << "No value tag found for child " << childName << " in "
619  << __PRETTY_FUNCTION__ << std::endl;
620 
621  return false;
622  }
623 
624  // first try direct
625  std::string maxString = getXMLAttribute(n1, m_xmlAttrMax); // string for the maxbits
626 
627  if (maxString.empty()) {
628  maxString = getXMLAttribute(n2, m_xmlAttrMax); // try next value tag
629  // if no max was found neither in value nor in the childName tag
630  if (maxString.empty()) {
631  LogDebug("L1GtTriggerMenuXmlParser") << "No Max value found for " << childName << std::endl;
632 
633  return false;
634  }
635  }
636 
637  // do the hex conversion
638 
639  uint64_t maxBitsL, maxBitsH;
640  if (!hexString2UInt128(maxString, maxBitsL, maxBitsH)) {
641  return false;
642  }
643 
644  // count the bits
645  //LogTrace("L1GtTriggerMenuXmlParser")
646  //<< std::dec
647  //<< " words: dec: high (MSB) word = " << maxBitsH << " low word = " << maxBitsL
648  //<< std::hex << "\n"
649  //<< " words: hex: high (MSB) word = " << maxBitsH << " low word = " << maxBitsL
650  //<< std::dec
651  //<< std::endl;
652 
653  unsigned int counter = 0;
654 
655  while (maxBitsL != 0) {
656  // check if bits set countinously
657  if ((maxBitsL & 1) == 0) {
658  edm::LogError("L1GtTriggerMenuXmlParser") << " Confused by not continous set bits for max value "
659  << maxString << "(child=" << childName << ")" << std::endl;
660 
661  return false;
662  }
663 
664  maxBitsL >>= 1;
665  counter++;
666  }
667 
668  if ((maxBitsH != 0) && (counter != 64)) {
669  edm::LogError("L1GtTriggerMenuXmlParser") << " Confused by not continous set bits for max value " << maxString
670  << "(child=" << childName << ")" << std::endl;
671 
672  return false;
673  }
674 
675  while (maxBitsH != 0) {
676  //check if bits set countinously
677  if ((maxBitsH & 1) == 0) {
678  edm::LogError("L1GtTriggerMenuXmlParser") << " Confused by not continous set bits for max value "
679  << maxString << "(child=" << childName << ")" << std::endl;
680 
681  return false;
682  }
683 
684  maxBitsH >>= 1;
685  counter++;
686  }
687 
688  dst = counter;
689  return true;
690 }
691 
703 bool L1GtTriggerMenuXmlParser::getConditionChildValues(XERCES_CPP_NAMESPACE::DOMNode* node,
704  const std::string& childName,
705  unsigned int num,
706  std::vector<uint64_t>& dst) {
707  XERCES_CPP_NAMESPACE_USE
708 
709  if (node == nullptr) {
710  LogDebug("L1GtTriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
711 
712  return false;
713  }
714 
715  DOMNode* n1 = findXMLChild(node->getFirstChild(), childName);
716 
717  // if child not found
718  if (n1 == nullptr) {
719  LogDebug("L1GtTriggerMenuXmlParser") << "Child of condition not found ( " << childName << ")" << std::endl;
720 
721  return false;
722  }
723 
724  // no values are sucessfull
725  if (num == 0) {
726  return true;
727  }
728 
729  //
730  dst.reserve(num);
731 
732  //
733  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
734  for (unsigned int i = 0; i < num; i++) {
735  if (n1 == nullptr) {
736  LogDebug("L1GtTriggerMenuXmlParser")
737  << "Not enough values in condition child ( " << childName << ")" << std::endl;
738 
739  return false;
740  }
741 
742  if (!getXMLHexTextValue(n1, dst[i])) {
743  edm::LogError("L1GtTriggerMenuXmlParser")
744  << "Error converting condition child ( " << childName << ") value." << std::endl;
745 
746  return false;
747  }
748 
749  n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue); // next child
750  }
751 
752  return true;
753 }
754 
762 void L1GtTriggerMenuXmlParser::cleanupXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
763  XERCES_CPP_NAMESPACE_USE
764 
765  if (parser != nullptr) {
766  delete parser;
767  }
768 
769  if (m_xmlErrHandler != nullptr) {
770  delete m_xmlErrHandler;
771  m_xmlErrHandler = nullptr;
772  }
773 
775 }
776 
777 // methods for the VME file
778 
788 bool L1GtTriggerMenuXmlParser::parseVmeXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
789  XERCES_CPP_NAMESPACE_USE
790 
791  DOMDocument* doc = parser->getDocument();
792  DOMNode* n1 = doc->getFirstChild();
793 
794  if (n1 == nullptr) {
795  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: Found no XML child" << std::endl;
796 
797  return false;
798  }
799 
800  // find "vme"-tag
801  n1 = findXMLChild(n1, m_xmlTagVme);
802  if (n1 == nullptr) {
803  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No vme tag found." << std::endl;
804  return false;
805  }
806 
807  n1 = n1->getFirstChild();
808 
809  unsigned int chipCounter = 0; // count chips
810 
811  while (chipCounter < m_numberConditionChips) {
812  n1 = findXMLChild(n1, m_xmlTagChip, true);
813  if (n1 == nullptr) {
814  // just break if no more chips found
815  break;
816  }
817 
818  // node for a particle
819  //DOMNode* particleNode = n1->getFirstChild(); // FIXME un-comment
820 
821  // FIXME parse vme.xml, modify the menu
822 
823  n1 = n1->getNextSibling();
824  chipCounter++;
825  } // end while chipCounter
826 
827  return true;
828 }
829 
830 // methods for conditions and algorithms
831 
832 // clearMaps - delete all conditions and algorithms in
833 // the maps and clear the maps.
835  // loop over condition maps (one map per condition chip)
836  // then loop over conditions in the map
837  for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip != m_conditionMap.end();
838  itCondOnChip++) {
839  // the conditions in the maps are deleted in L1GtTriggerMenu, not here
840 
841  itCondOnChip->clear();
842  }
843 
844  // the algorithms in the maps are deleted in L1GtTriggerMenu, not here
845  m_algorithmMap.clear();
846 }
847 
848 // insertConditionIntoMap - safe insert of condition into condition map.
849 // if the condition name already exists, do not insert it and return false
851  std::string cName = cond.condName();
852  //LogTrace("L1GtTriggerMenuXmlParser")
853  //<< " Trying to insert condition \"" << cName << "\" in the condition map." ;
854 
855  // no condition name has to appear twice!
856  if ((m_conditionMap[chipNr]).count(cName) != 0) {
857  LogTrace("L1GtTriggerMenuXmlParser") << " Condition " << cName << " already exists - not inserted!"
858  << std::endl;
859  return false;
860  }
861 
862  (m_conditionMap[chipNr])[cName] = &cond;
863  //LogTrace("L1GtTriggerMenuXmlParser")
864  //<< " OK - condition inserted!"
865  //<< std::endl;
866 
867  return true;
868 }
869 
870 // insert an algorithm into algorithm map
872  std::string algName = alg.algoName();
873  const std::string& algAlias = alg.algoAlias();
874  //LogTrace("L1GtTriggerMenuXmlParser")
875  //<< " Trying to insert algorithm \"" << algName << "\" in the algorithm map." ;
876 
877  // no algorithm name has to appear twice!
878  if (m_algorithmMap.count(algName) != 0) {
879  LogTrace("L1GtTriggerMenuXmlParser") << " Algorithm \"" << algName
880  << "\"already exists in the algorithm map- not inserted!" << std::endl;
881  return false;
882  }
883 
884  if (m_algorithmAliasMap.count(algAlias) != 0) {
885  LogTrace("L1GtTriggerMenuXmlParser") << " Algorithm alias \"" << algAlias
886  << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
887  return false;
888  }
889 
890  // bit number less than zero or greater than maximum number of algorithms
891  int bitNumber = alg.algoBitNumber();
892  if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
893  LogTrace("L1GtTriggerMenuXmlParser") << " Bit number " << bitNumber << " outside allowed range [0, "
894  << m_numberPhysTriggers << ") - algorithm not inserted!" << std::endl;
895  return false;
896  }
897 
898  // maximum number of algorithms
899  if (m_algorithmMap.size() >= m_numberPhysTriggers) {
900  LogTrace("L1GtTriggerMenuXmlParser") << " More than maximum allowed " << m_numberPhysTriggers
901  << " algorithms in the algorithm map - not inserted!" << std::endl;
902  return false;
903  }
904 
905  // chip number outside allowed values
906  int chipNr = alg.algoChipNumber(
907  static_cast<int>(m_numberConditionChips), static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
908 
909  if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
910  LogTrace("L1GtTriggerMenuXmlParser") << " Chip number " << chipNr << " outside allowed range [0, "
911  << m_numberConditionChips << ") - algorithm not inserted!" << std::endl;
912  return false;
913  }
914 
915  // output pin outside allowed values
916  int outputPin = alg.algoOutputPin(
917  static_cast<int>(m_numberConditionChips), static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
918 
919  if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
920  LogTrace("L1GtTriggerMenuXmlParser") << " Output pin " << outputPin << " outside allowed range [0, "
921  << m_pinsOnConditionChip << "] - algorithm not inserted!" << std::endl;
922  return false;
923  }
924 
925  // no two algorithms on the same chip can have the same output pin
926  for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
927  int iPin = (itAlgo->second)
928  .algoOutputPin(static_cast<int>(m_numberConditionChips),
929  static_cast<int>(m_pinsOnConditionChip),
931  std::string iName = itAlgo->first;
932  int iChip = (itAlgo->second)
933  .algoChipNumber(static_cast<int>(m_numberConditionChips),
934  static_cast<int>(m_pinsOnConditionChip),
936 
937  if ((outputPin == iPin) && (chipNr == iChip)) {
938  LogTrace("L1GtTriggerMenuXmlParser")
939  << " Output pin " << outputPin << " is the same as for algorithm " << iName
940  << "\n from the same chip number " << chipNr << " - algorithm not inserted!" << std::endl;
941  return false;
942  }
943  }
944 
945  // insert algorithm
946  m_algorithmMap[algName] = alg;
947  m_algorithmAliasMap[algAlias] = alg;
948 
949  //LogTrace("L1GtTriggerMenuXmlParser")
950  //<< " OK - algorithm inserted!"
951  //<< std::endl;
952 
953  return true;
954 }
955 
956 // insert a technical trigger into technical trigger map
958  std::string algName = alg.algoName();
959  //LogTrace("L1GtTriggerMenuXmlParser")
960  //<< " Trying to insert technical trigger \"" << algName
961  //<< "\" in the technical trigger map." ;
962 
963  // no technical trigger name has to appear twice!
964  if (m_technicalTriggerMap.count(algName) != 0) {
965  LogTrace("L1GtTriggerMenuXmlParser") << " Technical trigger \"" << algName
966  << "\"already exists in the technical trigger map- not inserted!" << std::endl;
967  return false;
968  }
969 
970  // bit number less than zero or greater than maximum number of technical triggers
971  int bitNumber = alg.algoBitNumber();
972  if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberTechTriggers))) {
973  LogTrace("L1GtTriggerMenuXmlParser") << " Bit number " << bitNumber << " outside allowed range [0, "
974  << m_numberTechTriggers << ") - technical trigger not inserted!" << std::endl;
975  return false;
976  }
977 
978  // no two technical triggers can have the same bit number
979  for (CItAlgo itAlgo = m_technicalTriggerMap.begin(); itAlgo != m_technicalTriggerMap.end(); itAlgo++) {
980  int iBitNumber = (itAlgo->second).algoBitNumber();
981  std::string iName = itAlgo->first;
982 
983  if (iBitNumber == bitNumber) {
984  LogTrace("L1GtTriggerMenuXmlParser")
985  << " Bit number " << iBitNumber << " is the same as for technical trigger " << iName
986  << " - technical trigger not inserted!" << std::endl;
987  return false;
988  }
989  }
990 
991  // maximum number of technical triggers
993  LogTrace("L1GtTriggerMenuXmlParser") << " More than maximum allowed " << m_numberTechTriggers
994  << " technical triggers in the technical trigger map - not inserted!"
995  << std::endl;
996  return false;
997  }
998 
999  // insert technical trigger
1000  m_technicalTriggerMap[algName] = alg;
1001 
1002  //LogTrace("L1GtTriggerMenuXmlParser")
1003  //<< " OK - technical trigger inserted!"
1004  //<< std::endl;
1005 
1006  return true;
1007 }
1008 
1009 // get the type of the condition, as defined in enum, from the condition type
1010 // as defined in the XML file
1012  if (type == m_xmlConditionAttrType1s) {
1013  return Type1s;
1014  }
1015 
1016  if (type == m_xmlConditionAttrType2s) {
1017  return Type2s;
1018  }
1019 
1020  if (type == m_xmlConditionAttrType3s) {
1021  return Type3s;
1022  }
1023 
1024  if (type == m_xmlConditionAttrType4s) {
1025  return Type4s;
1026  }
1027 
1028  if (type == m_xmlConditionAttrType2wsc) {
1029  return Type2wsc;
1030  }
1031 
1032  if (type == m_xmlConditionAttrType2cor) {
1033  return Type2cor;
1034  }
1035 
1036  return TypeNull;
1037 }
1038 
1049  if (type == m_xmlConditionAttrType1s) {
1050  return 1;
1051  }
1052 
1053  if (type == m_xmlConditionAttrType2s) {
1054  return 2;
1055  }
1056 
1057  if (type == m_xmlConditionAttrType3s) {
1058  return 3;
1059  }
1060 
1061  if (type == m_xmlConditionAttrType4s) {
1062  return 4;
1063  }
1064 
1065  if (type == m_xmlConditionAttrType2wsc) {
1066  return 2;
1067  }
1068 
1069  if (type == m_xmlConditionAttrType2cor) {
1070  return 2;
1071  }
1072 
1073  return -1;
1074 }
1075 
1084 int L1GtTriggerMenuXmlParser::getBitFromNode(XERCES_CPP_NAMESPACE::DOMNode* node) {
1086  edm::LogError("L1GtTriggerMenuXmlParser") << "Invalid mode for single bit" << std::endl;
1087 
1088  return -1;
1089  }
1090 
1091  std::string tmpStr = getXMLTextValue(node);
1092  if (tmpStr == "0") {
1093  return 0;
1094  } else if (tmpStr == "1") {
1095  return 1;
1096  } else {
1097  edm::LogError("L1GtTriggerMenuXmlParser") << "Bad bit value (" << tmpStr << ")" << std::endl;
1098  return -1;
1099  }
1100 }
1101 
1111 int L1GtTriggerMenuXmlParser::getGEqFlag(XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& nodeName) {
1112  XERCES_CPP_NAMESPACE_USE
1113 
1114  if (node == nullptr) {
1115  LogDebug("L1GtTriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
1116 
1117  return -1;
1118  }
1119 
1120  // usually the GEq flag is a child of the first child (the first element node)
1121  DOMNode* n1 = node->getFirstChild();
1122  n1 = findXMLChild(n1, nodeName);
1123 
1124  if (n1 != nullptr) {
1125  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagGEq);
1126  if (n1 == nullptr) {
1127  LogDebug("L1GtTriggerMenuXmlParser") << "No \"greater or equal\" tag found" << std::endl;
1128 
1129  return -1;
1130  }
1131 
1132  return getBitFromNode(n1);
1133  } else {
1134  return -1;
1135  }
1136 }
1137 
1150 bool L1GtTriggerMenuXmlParser::getMuonMipIsoBits(XERCES_CPP_NAMESPACE::DOMNode* node,
1151  unsigned int num,
1152  std::vector<bool>& mipDst,
1153  std::vector<bool>& isoEnDst,
1154  std::vector<bool>& isoReqDst) {
1155  XERCES_CPP_NAMESPACE_USE
1156 
1157  if (node == nullptr) {
1158  return false;
1159  }
1160 
1161  // find ptLowThreshold child
1162  DOMNode* n1 = findXMLChild(node->getFirstChild(), m_xmlTagPtLowThreshold);
1163 
1164  if (n1 == nullptr) {
1165  return false;
1166  }
1167 
1168  // get first value tag
1169  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
1170 
1171  for (unsigned int i = 0; i < num; i++) {
1172  if (n1 == nullptr) {
1173  return false;
1174  }
1175 
1176  // MIP bit
1177 
1178  DOMNode* bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableMip);
1179  if (bitnode == nullptr) {
1180  return true;
1181  }
1182 
1183  int tmpint = getBitFromNode(bitnode);
1184  if (tmpint < 0) {
1185  return false;
1186  }
1187 
1188  mipDst[i] = (tmpint != 0);
1189 
1190  //LogTrace("L1GtTriggerMenuXmlParser")
1191  //<< " MIP bit value for muon " << i << " = " << mipDst[i]
1192  //<< std::endl;
1193 
1194  // enable iso bit
1195  bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableIso);
1196  if (bitnode == nullptr) {
1197  return true;
1198  }
1199 
1200  tmpint = getBitFromNode(bitnode);
1201  if (tmpint < 0) {
1202  return false;
1203  }
1204 
1205  isoEnDst[i] = (tmpint != 0);
1206 
1207  //LogTrace("L1GtTriggerMenuXmlParser")
1208  //<< " Enabled iso bit value for muon " << i << " = " << isoEnDst[i]
1209  //<< std::endl;
1210 
1211  // request iso bit
1212  bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagRequestIso);
1213  if (bitnode == nullptr) {
1214  return true;
1215  }
1216 
1217  tmpint = getBitFromNode(bitnode);
1218  if (tmpint < 0) {
1219  return false;
1220  }
1221 
1222  isoReqDst[i] = (tmpint != 0);
1223 
1224  //LogTrace("L1GtTriggerMenuXmlParser")
1225  //<< " Request iso bit value for muon " << i << " = " << isoReqDst[i]
1226  //<< std::endl;
1227 
1228  //
1229  n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue); // next value
1230  }
1231 
1232  return true;
1233 }
1234 
1246 bool L1GtTriggerMenuXmlParser::parseMuon(XERCES_CPP_NAMESPACE::DOMNode* node,
1247  const std::string& name,
1248  unsigned int chipNr,
1249  const bool corrFlag) {
1250  XERCES_CPP_NAMESPACE_USE
1251 
1252  // get condition, particle name (must be muon) and type name
1256 
1257  if (particle != m_xmlConditionAttrObjectMu) {
1258  edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for muon-condition (" << particle << ")" << std::endl;
1259  return false;
1260  }
1261 
1262  int nrObj = getNumFromType(type);
1263  if (nrObj < 0) {
1264  edm::LogError("L1GtTriggerMenuXmlParser") << "Unknown type for muon-condition (" << type << ")"
1265  << "\nCan not determine number of trigger objects. " << std::endl;
1266  return false;
1267  }
1268 
1269  // get greater equal flag
1270 
1271  int intGEq = getGEqFlag(node, m_xmlTagPtHighThreshold);
1272  if (intGEq < 0) {
1273  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
1274  return false;
1275  }
1276  // set the boolean value for the ge_eq mode
1277  bool gEq = (intGEq != 0);
1278 
1279  // get values
1280 
1281  // temporary storage of the parameters
1282  std::vector<L1GtMuonTemplate::ObjectParameter> objParameter(nrObj);
1284 
1285  // need at least two values for deltaPhi
1286  std::vector<uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1287 
1288  // get ptHighThreshold values and fill into structure
1289  if (!getConditionChildValues(node, m_xmlTagPtHighThreshold, nrObj, tmpValues)) {
1290  return false;
1291  }
1292 
1293  for (int i = 0; i < nrObj; i++) {
1294  objParameter[i].ptHighThreshold = tmpValues[i];
1295 
1296  //LogTrace("L1GtTriggerMenuXmlParser")
1297  //<< " Muon pT high threshold (hex) for muon " << i << " = "
1298  //<< std::hex << objParameter[i].ptHighThreshold << std::dec
1299  //<< std::endl;
1300  }
1301 
1302  // get ptLowThreshold values and fill into structure
1303  if (!getConditionChildValues(node, m_xmlTagPtLowThreshold, nrObj, tmpValues)) {
1304  return false;
1305  }
1306 
1307  for (int i = 0; i < nrObj; i++) {
1308  //LogTrace("L1GtTriggerMenuXmlParser")
1309  //<< " Muon pT low threshold word (hex) for muon " << i << " = "
1310  //<< std::hex << tmpValues[i] << std::dec
1311  //<< std::endl;
1312 
1313  // TODO FIXME stupid format in def.xml...
1314  // one takes mip bit also, therefore one divide by 16
1315  tmpValues[i] = (tmpValues[i]) / 16;
1316 
1317  objParameter[i].ptLowThreshold = tmpValues[i];
1318 
1319  //LogTrace("L1GtTriggerMenuXmlParser")
1320  //<< " Muon pT low threshold (hex) for muon " << i << " = "
1321  //<< std::hex << objParameter[i].ptLowThreshold << std::dec
1322  //<< std::endl;
1323  }
1324 
1325  // get qualityRange and fill into structure
1326  if (!getConditionChildValues(node, m_xmlTagQuality, nrObj, tmpValues)) {
1327  return false;
1328  }
1329 
1330  for (int i = 0; i < nrObj; i++) {
1331  objParameter[i].qualityRange = tmpValues[i];
1332 
1333  //LogTrace("L1GtTriggerMenuXmlParser")
1334  //<< " qualityRange mask (hex) for muon " << i << " = "
1335  //<< std::hex << objParameter[i].qualityRange << std::dec
1336  //<< std::endl;
1337  }
1338 
1339  // get etaRange and fill into structure
1340  if (!getConditionChildValues(node, m_xmlTagEta, nrObj, tmpValues)) {
1341  return false;
1342  }
1343 
1344  for (int i = 0; i < nrObj; i++) {
1345  objParameter[i].etaRange = tmpValues[i];
1346 
1347  //LogTrace("L1GtTriggerMenuXmlParser")
1348  //<< " etaRange (hex) for muon " << i << " = "
1349  //<< std::hex << objParameter[i].etaRange << std::dec
1350  //<< std::endl;
1351  }
1352 
1353  // get phiHigh values and fill into structure
1354  if (!getConditionChildValues(node, m_xmlTagPhiHigh, nrObj, tmpValues)) {
1355  return false;
1356  }
1357 
1358  for (int i = 0; i < nrObj; i++) {
1359  objParameter[i].phiHigh = tmpValues[i];
1360 
1361  //LogTrace("L1GtTriggerMenuXmlParser")
1362  //<< " phiHigh (hex) for muon " << i << " = "
1363  //<< std::hex << objParameter[i].phiHigh << std::dec
1364  //<< std::endl;
1365  }
1366 
1367  // get phiLow values and fill into structure
1368  if (!getConditionChildValues(node, m_xmlTagPhiLow, nrObj, tmpValues)) {
1369  return false;
1370  }
1371 
1372  for (int i = 0; i < nrObj; i++) {
1373  objParameter[i].phiLow = tmpValues[i];
1374 
1375  //LogTrace("L1GtTriggerMenuXmlParser")
1376  //<< " phiLow (hex) for muon " << i << " = "
1377  //<< std::hex << objParameter[i].phiLow << std::dec
1378  //<< std::endl;
1379  }
1380 
1381  // get charge correlation and fill into structure
1382  if (!getXMLHexTextValue(findXMLChild(node->getFirstChild(), m_xmlTagChargeCorrelation), tmpValues[0])) {
1383  LogDebug("L1GtTriggerMenuXmlParser") << " Error getting charge correlation from muon condition (" << name << ")"
1384  << std::endl;
1385  return false;
1386  }
1387 
1388  corrParameter.chargeCorrelation = tmpValues[0];
1389 
1390  //LogTrace("L1GtTriggerMenuXmlParser")
1391  //<< " charge correlation" << " = "
1392  //<< std::hex << corrParameter.chargeCorrelation << std::dec
1393  //<< std::endl;
1394 
1395  // get mip and iso bits and fill into structure
1396 
1397  std::vector<bool> tmpMip(nrObj);
1398  std::vector<bool> tmpEnableIso(nrObj);
1399  std::vector<bool> tmpRequestIso(nrObj);
1400 
1401  if (!getMuonMipIsoBits(node, nrObj, tmpMip, tmpEnableIso, tmpRequestIso)) {
1402  edm::LogError("L1GtTriggerMenuXmlParser")
1403  << " Could not get mip and iso bits from muon condition (" << name << ")" << std::endl;
1404  return false;
1405  }
1406 
1407  for (int i = 0; i < nrObj; i++) {
1408  objParameter[i].enableMip = tmpMip[i];
1409  objParameter[i].enableIso = tmpEnableIso[i];
1410  objParameter[i].requestIso = tmpRequestIso[i];
1411  }
1412 
1413  // indicates if a correlation is used
1414  bool wscVal = (type == m_xmlConditionAttrType2wsc);
1415 
1416  if (wscVal) {
1417  // get deltaEtaRange
1418  if (!getConditionChildValues(node, m_xmlTagDeltaEta, 1, tmpValues)) {
1419  return false;
1420  }
1421 
1422  corrParameter.deltaEtaRange = tmpValues[0];
1423 
1424  // deltaPhi is larger than 64bit
1425  if (!getXMLHexTextValue128(findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi), tmpValues[0], tmpValues[1])) {
1426  edm::LogError("L1GtTriggerMenuXmlParser")
1427  << " Could not get deltaPhi for muon condition with wsc (" << name << ")" << std::endl;
1428  return false;
1429  }
1430 
1431  corrParameter.deltaPhiRange0Word = tmpValues[0];
1432  corrParameter.deltaPhiRange1Word = tmpValues[1];
1433 
1434  // get maximum number of bits for delta phi
1435  //LogTrace("L1GtTriggerMenuXmlParser")
1436  //<< " Counting deltaPhiMaxbits"
1437  //<< std::endl;
1438 
1439  unsigned int maxbits;
1440 
1441  if (!countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits)) {
1442  return false;
1443  }
1444 
1445  corrParameter.deltaPhiMaxbits = maxbits;
1446  //LogTrace("L1GtTriggerMenuXmlParser")
1447  //<< " deltaPhiMaxbits (dec) = " << maxbits
1448  //<< std::endl;
1449  }
1450 
1451  // get the type of the condition, as defined in enum, from the condition type
1452  // as defined in the XML file
1453  L1GtConditionType cType = getTypeFromType(type);
1454  //LogTrace("L1GtTriggerMenuXmlParser")
1455  //<< " Condition type (enum value) = " << cType
1456  //<< std::endl;
1457 
1458  if (cType == TypeNull) {
1459  edm::LogError("L1GtTriggerMenuXmlParser")
1460  << "Type for muon condition id TypeNull - it means not defined in the XML file."
1461  << "\nNumber of trigger objects is set to zero. " << std::endl;
1462  return false;
1463  }
1464 
1465  // object types - all muons
1466  std::vector<L1GtObject> objType(nrObj, Mu);
1467 
1468  // now create a new CondMuonition
1469 
1470  L1GtMuonTemplate muonCond(name);
1471 
1472  muonCond.setCondType(cType);
1473  muonCond.setObjectType(objType);
1474  muonCond.setCondGEq(gEq);
1475  muonCond.setCondChipNr(chipNr);
1476 
1477  muonCond.setConditionParameter(objParameter, corrParameter);
1478 
1479  if (edm::isDebugEnabled()) {
1480  std::ostringstream myCoutStream;
1481  muonCond.print(myCoutStream);
1482  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
1483  }
1484 
1485  // insert condition into the map and into muon template vector
1486  if (!insertConditionIntoMap(muonCond, chipNr)) {
1487  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1488  return false;
1489  } else {
1490  if (corrFlag) {
1491  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1492 
1493  } else {
1494  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1495  }
1496  }
1497 
1498  //
1499  return true;
1500 }
1501 
1513 bool L1GtTriggerMenuXmlParser::parseCalo(XERCES_CPP_NAMESPACE::DOMNode* node,
1514  const std::string& name,
1515  unsigned int chipNr,
1516  const bool corrFlag) {
1517  XERCES_CPP_NAMESPACE_USE
1518 
1519  // get condition, particle name and type name
1523 
1524  // determine object type type
1525  L1GtObject caloObjType;
1526 
1527  if (particle == m_xmlConditionAttrObjectNoIsoEG) {
1528  caloObjType = NoIsoEG;
1529  } else if (particle == m_xmlConditionAttrObjectIsoEG) {
1530  caloObjType = IsoEG;
1531  } else if (particle == m_xmlConditionAttrObjectCenJet) {
1532  caloObjType = CenJet;
1533  } else if (particle == m_xmlConditionAttrObjectTauJet) {
1534  caloObjType = TauJet;
1535  } else if (particle == m_xmlConditionAttrObjectForJet) {
1536  caloObjType = ForJet;
1537  } else {
1538  edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for calo-condition (" << particle << ")" << std::endl;
1539  return false;
1540  }
1541 
1542  int nrObj = getNumFromType(type);
1543  if (nrObj < 0) {
1544  edm::LogError("L1GtTriggerMenuXmlParser") << "Unknown type for calo-condition (" << type << ")"
1545  << "\nCan not determine number of trigger objects. " << std::endl;
1546  return false;
1547  }
1548 
1549  // get greater equal flag
1550 
1551  int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
1552  if (intGEq < 0) {
1553  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
1554  return false;
1555  }
1556  // set the boolean value for the ge_eq mode
1557  bool gEq = (intGEq != 0);
1558 
1559  // get values
1560 
1561  // temporary storage of the parameters
1562  std::vector<L1GtCaloTemplate::ObjectParameter> objParameter(nrObj);
1564 
1565  // need at least one value for deltaPhiRange
1566  std::vector<uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1567 
1568  // get etThreshold values and fill into structure
1569  if (!getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues)) {
1570  return false;
1571  }
1572 
1573  for (int i = 0; i < nrObj; i++) {
1574  objParameter[i].etThreshold = tmpValues[i];
1575 
1576  //LogTrace("L1GtTriggerMenuXmlParser")
1577  //<< " Calo ET high threshold (hex) for calo object " << i << " = "
1578  //<< std::hex << objParameter[i].etThreshold << std::dec
1579  //<< std::endl;
1580  }
1581 
1582  // get etaRange and fill into structure
1583  if (!getConditionChildValues(node, m_xmlTagEta, nrObj, tmpValues)) {
1584  return false;
1585  }
1586 
1587  for (int i = 0; i < nrObj; i++) {
1588  objParameter[i].etaRange = tmpValues[i];
1589 
1590  //LogTrace("L1GtTriggerMenuXmlParser")
1591  //<< " etaRange (hex) for calo object " << i << " = "
1592  //<< std::hex << objParameter[i].etaRange << std::dec
1593  //<< std::endl;
1594  }
1595 
1596  // get phiRange values and fill into structure
1597  if (!getConditionChildValues(node, m_xmlTagPhi, nrObj, tmpValues)) {
1598  return false;
1599  }
1600 
1601  for (int i = 0; i < nrObj; i++) {
1602  objParameter[i].phiRange = tmpValues[i];
1603 
1604  //LogTrace("L1GtTriggerMenuXmlParser")
1605  //<< " phiRange (hex) for calo object " << i << " = "
1606  //<< std::hex << objParameter[i].phiRange << std::dec
1607  //<< std::endl;
1608  }
1609 
1610  // indicates if a correlation is used
1611  bool wscVal = (type == m_xmlConditionAttrType2wsc);
1612 
1613  if (wscVal) {
1614  // get deltaEtaRange
1615  if (!getConditionChildValues(node, m_xmlTagDeltaEta, 1, tmpValues)) {
1616  return false;
1617  }
1618 
1619  corrParameter.deltaEtaRange = tmpValues[0];
1620 
1621  // get deltaPhiRange
1622  if (!getConditionChildValues(node, m_xmlTagDeltaPhi, 1, tmpValues)) {
1623  return false;
1624  }
1625 
1626  corrParameter.deltaPhiRange = tmpValues[0];
1627 
1628  // get maximum number of bits for delta phi
1629  //LogTrace("L1GtTriggerMenuXmlParser")
1630  //<< " Counting deltaPhiMaxbits"
1631  //<< std::endl;
1632 
1633  unsigned int maxbits;
1634 
1635  if (!countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits)) {
1636  return false;
1637  }
1638 
1639  corrParameter.deltaPhiMaxbits = maxbits;
1640  //LogTrace("L1GtTriggerMenuXmlParser")
1641  //<< " deltaPhiMaxbits (dec) = " << maxbits
1642  //<< std::endl;
1643  }
1644 
1645  // get the type of the condition, as defined in enum, from the condition type
1646  // as defined in the XML file
1647  L1GtConditionType cType = getTypeFromType(type);
1648  //LogTrace("L1GtTriggerMenuXmlParser")
1649  //<< " Condition type (enum value) = " << cType
1650  //<< std::endl;
1651 
1652  if (cType == TypeNull) {
1653  edm::LogError("L1GtTriggerMenuXmlParser")
1654  << "Type for calo condition id TypeNull - it means not defined in the XML file."
1655  << "\nNumber of trigger objects is set to zero. " << std::endl;
1656  return false;
1657  }
1658 
1659  // object types - all same caloObjType
1660  std::vector<L1GtObject> objType(nrObj, caloObjType);
1661 
1662  // now create a new calo condition
1663 
1664  L1GtCaloTemplate caloCond(name);
1665 
1666  caloCond.setCondType(cType);
1667  caloCond.setObjectType(objType);
1668  caloCond.setCondGEq(gEq);
1669  caloCond.setCondChipNr(chipNr);
1670 
1671  caloCond.setConditionParameter(objParameter, corrParameter);
1672 
1673  if (edm::isDebugEnabled()) {
1674  std::ostringstream myCoutStream;
1675  caloCond.print(myCoutStream);
1676  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
1677  }
1678 
1679  // insert condition into the map
1680  if (!insertConditionIntoMap(caloCond, chipNr)) {
1681  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1682 
1683  return false;
1684  } else {
1685  if (corrFlag) {
1686  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1687  } else {
1688  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
1689  }
1690  }
1691 
1692  //
1693  return true;
1694 }
1695 
1707 bool L1GtTriggerMenuXmlParser::parseEnergySum(XERCES_CPP_NAMESPACE::DOMNode* node,
1708  const std::string& name,
1709  unsigned int chipNr,
1710  const bool corrFlag) {
1711  XERCES_CPP_NAMESPACE_USE
1712 
1713  // get condition, particle name and type name
1717 
1718  // determine object type type
1719  L1GtObject energySumObjType;
1720  L1GtConditionType cType;
1721 
1722  if ((particle == m_xmlConditionAttrObjectETM) && (type == m_xmlConditionAttrObjectETM)) {
1723  energySumObjType = ETM;
1724  cType = TypeETM;
1725 
1726  } else if ((particle == m_xmlConditionAttrObjectETT) && (type == m_xmlConditionAttrObjectETT)) {
1727  energySumObjType = ETT;
1728  cType = TypeETT;
1729 
1730  } else if ((particle == m_xmlConditionAttrObjectHTT) && (type == m_xmlConditionAttrObjectHTT)) {
1731  energySumObjType = HTT;
1732  cType = TypeHTT;
1733 
1734  } else if ((particle == m_xmlConditionAttrObjectHTM) && (type == m_xmlConditionAttrObjectHTM)) {
1735  energySumObjType = HTM;
1736  cType = TypeHTM;
1737 
1738  } else {
1739  edm::LogError("L1GtTriggerMenuXmlParser")
1740  << "Wrong particle or type for energy-sum condition (" << particle << ", " << type << ")" << std::endl;
1741  return false;
1742  }
1743 
1744  // global object
1745  int nrObj = 1;
1746 
1747  // get greater equal flag
1748 
1749  int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
1750  if (intGEq < 0) {
1751  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
1752  return false;
1753  }
1754  // set the boolean value for the ge_eq mode
1755  bool gEq = (intGEq != 0);
1756 
1757  // get values
1758 
1759  // temporary storage of the parameters
1760  std::vector<L1GtEnergySumTemplate::ObjectParameter> objParameter(nrObj);
1761 
1762  // need at least two values for phi
1763  std::vector<uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1764 
1765  // get etThreshold values and fill into structure
1766  if (!getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues)) {
1767  return false;
1768  }
1769 
1770  for (int i = 0; i < nrObj; i++) {
1771  objParameter[i].etThreshold = tmpValues[i];
1772 
1773  //LogTrace("L1GtTriggerMenuXmlParser")
1774  //<< " EnergySum ET high threshold (hex) for energySum object " << i << " = "
1775  //<< std::hex << objParameter[i].etThreshold << std::dec
1776  //<< std::endl;
1777 
1778  // for ETM and HTM read phi value
1779  // phi is larger than 64 bits for ETM - it needs two 64bits words
1780  // phi is less than 64 bits for HTM - it needs one 64bits word
1781  if (energySumObjType == ETM) {
1782  if (!getXMLHexTextValue128(findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0], tmpValues[1])) {
1783  edm::LogError("L1GtTriggerMenuXmlParser")
1784  << " Could not get phi for ETM condition (" << name << ")" << std::endl;
1785  return false;
1786  }
1787 
1788  objParameter[i].phiRange0Word = tmpValues[0];
1789  objParameter[i].phiRange1Word = tmpValues[1];
1790 
1791  } else if (energySumObjType == HTM) {
1792  if (!getXMLHexTextValue(findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0])) {
1793  edm::LogError("L1GtTriggerMenuXmlParser")
1794  << " Could not get phi for HTM condition (" << name << ")" << std::endl;
1795  return false;
1796  }
1797 
1798  objParameter[i].phiRange0Word = tmpValues[0];
1799  }
1800 
1801  // get energyOverflow logical flag and fill into structure
1802  DOMNode* n1;
1803  if ((n1 = findXMLChild(node->getFirstChild(), m_xmlTagEtThreshold)) == nullptr) {
1804  edm::LogError("L1GtTriggerMenuXmlParser")
1805  << " Could not get energyOverflow for EnergySum condition (" << name << ")" << std::endl;
1806  return false;
1807  }
1808  if ((n1 = findXMLChild(n1->getFirstChild(), m_xmlTagEnergyOverflow)) == nullptr) {
1809  edm::LogError("L1GtTriggerMenuXmlParser")
1810  << " Could not get energyOverflow for EnergySum condition (" << name << ")" << std::endl;
1811  return false;
1812  }
1813 
1814  int tmpInt = getBitFromNode(n1);
1815  if (tmpInt == 0) {
1816  objParameter[i].energyOverflow = false;
1817 
1818  //LogTrace("L1GtTriggerMenuXmlParser")
1819  //<< " EnergySum energyOverflow logical flag (hex) = "
1820  //<< std::hex << objParameter[i].energyOverflow << std::dec
1821  //<< std::endl;
1822  } else if (tmpInt == 1) {
1823  objParameter[i].energyOverflow = true;
1824 
1825  //LogTrace("L1GtTriggerMenuXmlParser")
1826  //<< " EnergySum energyOverflow logical flag (hex) = "
1827  //<< std::hex << objParameter[i].energyOverflow << std::dec
1828  //<< std::endl;
1829  } else {
1830  LogTrace("L1GtTriggerMenuXmlParser") << " EnergySum energyOverflow logical flag (hex) = " << std::hex
1831  << tmpInt << std::dec << " - wrong value! " << std::endl;
1832  return false;
1833  }
1834  }
1835 
1836  // object types - all same energySumObjType
1837  std::vector<L1GtObject> objType(nrObj, energySumObjType);
1838 
1839  // now create a new energySum condition
1840 
1841  L1GtEnergySumTemplate energySumCond(name);
1842 
1843  energySumCond.setCondType(cType);
1844  energySumCond.setObjectType(objType);
1845  energySumCond.setCondGEq(gEq);
1846  energySumCond.setCondChipNr(chipNr);
1847 
1848  energySumCond.setConditionParameter(objParameter);
1849 
1850  if (edm::isDebugEnabled()) {
1851  std::ostringstream myCoutStream;
1852  energySumCond.print(myCoutStream);
1853  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
1854  }
1855 
1856  // insert condition into the map
1857  if (!insertConditionIntoMap(energySumCond, chipNr)) {
1858  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1859 
1860  return false;
1861  } else {
1862  if (corrFlag) {
1863  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
1864 
1865  } else {
1866  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
1867  }
1868  }
1869 
1870  //
1871  return true;
1872 }
1873 
1886 bool L1GtTriggerMenuXmlParser::parseJetCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
1887  const std::string& name,
1888  unsigned int chipNr) {
1889  XERCES_CPP_NAMESPACE_USE
1890 
1891  // get condition, particle name and type name
1895 
1896  if (particle != m_xmlConditionAttrObjectJetCounts) {
1897  edm::LogError("L1GtTriggerMenuXmlParser")
1898  << "Wrong particle for JetCounts condition (" << particle << ")" << std::endl;
1899  return false;
1900  }
1901 
1902  // object type and condition type
1903  L1GtObject jetCountsObjType = JetCounts;
1905 
1906  // global object
1907  int nrObj = 1;
1908 
1909  // get greater equal flag
1910 
1911  int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
1912  if (intGEq < 0) {
1913  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
1914  return false;
1915  }
1916  // set the boolean value for the ge_eq mode
1917  bool gEq = (intGEq != 0);
1918 
1919  // get values
1920 
1921  // temporary storage of the parameters
1922  std::vector<L1GtJetCountsTemplate::ObjectParameter> objParameter(nrObj);
1923 
1924  // get countIndex value and fill into structure
1925  // they are expressed in base 10 (values: 0 - m_numberL1JetCounts)
1926  char* endPtr = nullptr;
1927  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
1928 
1929  if (*endPtr != 0) {
1930  LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec." << std::endl;
1931 
1932  return false;
1933  }
1934 
1935  // test if count index is out of range
1936  if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1JetCounts))) {
1937  LogDebug("L1GtTriggerMenuXmlParser") << "Count index " << typeInt << " outside range [0, " << m_numberL1JetCounts
1938  << "]" << std::endl;
1939 
1940  return false;
1941  }
1942 
1943  objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
1944 
1945  // get count threshold values and fill into structure
1946  std::vector<uint64_t> tmpValues(nrObj);
1947 
1948  if (!getConditionChildValues(node, m_xmlTagCountThreshold, nrObj, tmpValues)) {
1949  return false;
1950  }
1951 
1952  for (int i = 0; i < nrObj; i++) {
1953  objParameter[i].countThreshold = tmpValues[i];
1954 
1955  //LogTrace("L1GtTriggerMenuXmlParser")
1956  //<< " JetCounts count threshold (hex) for JetCounts object " << i << " = "
1957  //<< std::hex << objParameter[i].countThreshold << std::dec
1958  //<< std::endl;
1959 
1960  // TODO FIXME un-comment when tag available in XML file
1961 
1962  // // get countOverflow logical flag and fill into structure
1963  // DOMNode* n1;
1964  // if ( (n1 = findXMLChild(node->getFirstChild(), m_xmlTagCountThreshold)) == 0) {
1965  // edm::LogError("L1GtTriggerMenuXmlParser")
1966  // << " Could not get countOverflow for JetCounts condition ("
1967  // << name << ")"
1968  // << std::endl;
1969  // return false;
1970  // }
1971  // if ( (n1 = findXMLChild(n1->getFirstChild(), m_xmlTagCountThreshold)) == 0) {
1972  // edm::LogError("L1GtTriggerMenuXmlParser")
1973  // << " Could not get countOverflow for JetCounts condition ("
1974  // << name << ")"
1975  // << std::endl;
1976  // return false;
1977  // }
1978  //
1979  // int tmpInt = getBitFromNode(n1);
1980  // if (tmpInt == 0) {
1981  // objParameter[i].countOverflow = false;
1982  //
1983  // LogTrace("L1GtTriggerMenuXmlParser")
1984  // << " JetCounts countOverflow logical flag (hex) = "
1985  // << std::hex << objParameter[i].countOverflow << std::dec
1986  // << std::endl;
1987  // } else if (tmpInt == 1) {
1988  // objParameter[i].countOverflow = true;
1989  //
1990  // LogTrace("L1GtTriggerMenuXmlParser")
1991  // << " JetCounts countOverflow logical flag (hex) = "
1992  // << std::hex << objParameter[i].countOverflow << std::dec
1993  // << std::endl;
1994  // } else {
1995  // LogTrace("L1GtTriggerMenuXmlParser")
1996  // << " JetCounts countOverflow logical flag (hex) = "
1997  // << std::hex << tmpInt << std::dec << " - wrong value! "
1998  // << std::endl;
1999  // return false;
2000  // }
2001  }
2002 
2003  // object types - all same objType
2004  std::vector<L1GtObject> objType(nrObj, jetCountsObjType);
2005 
2006  // now create a new JetCounts condition
2007 
2008  L1GtJetCountsTemplate jetCountsCond(name);
2009 
2010  jetCountsCond.setCondType(cType);
2011  jetCountsCond.setObjectType(objType);
2012  jetCountsCond.setCondGEq(gEq);
2013  jetCountsCond.setCondChipNr(chipNr);
2014 
2015  jetCountsCond.setConditionParameter(objParameter);
2016 
2017  if (edm::isDebugEnabled()) {
2018  std::ostringstream myCoutStream;
2019  jetCountsCond.print(myCoutStream);
2020  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2021  }
2022 
2023  // insert condition into the map
2024  if (!insertConditionIntoMap(jetCountsCond, chipNr)) {
2025  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2026 
2027  return false;
2028  } else {
2029  (m_vecJetCountsTemplate[chipNr]).push_back(jetCountsCond);
2030  }
2031 
2032  //
2033  return true;
2034 }
2035 
2048 bool L1GtTriggerMenuXmlParser::parseCastor(XERCES_CPP_NAMESPACE::DOMNode* node,
2049  const std::string& name,
2050  unsigned int chipNr) {
2051  XERCES_CPP_NAMESPACE_USE
2052 
2053  // get condition, particle name and type name
2057 
2058  if (particle != m_xmlConditionAttrObjectCastor) {
2059  edm::LogError("L1GtTriggerMenuXmlParser")
2060  << "\nError: wrong particle for Castor condition (" << particle << ")" << std::endl;
2061  return false;
2062  }
2063 
2064  // object type and condition type
2065  // object type - irrelevant for CASTOR conditions
2066  L1GtConditionType cType = TypeCastor;
2067 
2068  // no objects for CASTOR conditions
2069 
2070  // set the boolean value for the ge_eq mode - irrelevant for CASTOR conditions
2071  bool gEq = false;
2072 
2073  // now create a new CASTOR condition
2074 
2075  L1GtCastorTemplate castorCond(name);
2076 
2077  castorCond.setCondType(cType);
2078  castorCond.setCondGEq(gEq);
2079  castorCond.setCondChipNr(chipNr);
2080 
2081  if (edm::isDebugEnabled()) {
2082  std::ostringstream myCoutStream;
2083  castorCond.print(myCoutStream);
2084  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2085  }
2086 
2087  // insert condition into the map
2088  if (!insertConditionIntoMap(castorCond, chipNr)) {
2089  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2090 
2091  return false;
2092  } else {
2093  (m_vecCastorTemplate[chipNr]).push_back(castorCond);
2094  }
2095 
2096  //
2097  return true;
2098 }
2099 
2112 bool L1GtTriggerMenuXmlParser::parseHfBitCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
2113  const std::string& name,
2114  unsigned int chipNr) {
2115  XERCES_CPP_NAMESPACE_USE
2116 
2117  // get condition, particle name and type name
2121 
2122  if (particle != m_xmlConditionAttrObjectHfBitCounts) {
2123  edm::LogError("L1GtTriggerMenuXmlParser")
2124  << "Wrong particle for HfBitCounts condition (" << particle << ")" << std::endl;
2125  return false;
2126  }
2127 
2128  // object type and condition type
2129  L1GtObject hfBitCountsObjType = HfBitCounts;
2131 
2132  // global object
2133  int nrObj = 1;
2134 
2135  // get greater equal flag
2136 
2137  int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
2138  if (intGEq < 0) {
2139  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
2140  return false;
2141  }
2142  // set the boolean value for the ge_eq mode
2143  bool gEq = (intGEq != 0);
2144 
2145  // get values
2146 
2147  // temporary storage of the parameters
2148  std::vector<L1GtHfBitCountsTemplate::ObjectParameter> objParameter(nrObj);
2149 
2150  // get countIndex value and fill into structure
2151  // they are expressed in base 10
2152  char* endPtr = nullptr;
2153  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2154 
2155  if (*endPtr != 0) {
2156  LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec." << std::endl;
2157 
2158  return false;
2159  }
2160 
2161  // test if count index is out of range FIXME introduce m_numberL1HfBitCounts?
2162  //if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1HfBitCounts))) {
2163  // LogDebug("L1GtTriggerMenuXmlParser") << "Count index " << typeInt
2164  // << " outside range [0, " << m_numberL1HfBitCounts << "]" << std::endl;
2165  //
2166  // return false;
2167  //}
2168 
2169  objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
2170 
2171  // get count threshold values and fill into structure
2172  std::vector<uint64_t> tmpValues(nrObj);
2173 
2174  if (!getConditionChildValues(node, m_xmlTagCountThreshold, nrObj, tmpValues)) {
2175  return false;
2176  }
2177 
2178  for (int i = 0; i < nrObj; i++) {
2179  objParameter[i].countThreshold = tmpValues[i];
2180 
2181  //LogTrace("L1GtTriggerMenuXmlParser")
2182  //<< " HfBitCounts count threshold (hex) for HfBitCounts object " << i << " = "
2183  //<< std::hex << objParameter[i].countThreshold << std::dec
2184  //<< std::endl;
2185  }
2186 
2187  // object types - all same objType
2188  std::vector<L1GtObject> objType(nrObj, hfBitCountsObjType);
2189 
2190  // now create a new HfBitCounts condition
2191 
2192  L1GtHfBitCountsTemplate hfBitCountsCond(name);
2193 
2194  hfBitCountsCond.setCondType(cType);
2195  hfBitCountsCond.setObjectType(objType);
2196  hfBitCountsCond.setCondGEq(gEq);
2197  hfBitCountsCond.setCondChipNr(chipNr);
2198 
2199  hfBitCountsCond.setConditionParameter(objParameter);
2200 
2201  if (edm::isDebugEnabled()) {
2202  std::ostringstream myCoutStream;
2203  hfBitCountsCond.print(myCoutStream);
2204  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2205  }
2206 
2207  // insert condition into the map
2208  if (!insertConditionIntoMap(hfBitCountsCond, chipNr)) {
2209  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2210 
2211  return false;
2212  } else {
2213  (m_vecHfBitCountsTemplate[chipNr]).push_back(hfBitCountsCond);
2214  }
2215 
2216  //
2217  return true;
2218 }
2219 
2232 bool L1GtTriggerMenuXmlParser::parseHfRingEtSums(XERCES_CPP_NAMESPACE::DOMNode* node,
2233  const std::string& name,
2234  unsigned int chipNr) {
2235  XERCES_CPP_NAMESPACE_USE
2236 
2237  // get condition, particle name and type name
2241 
2242  if (particle != m_xmlConditionAttrObjectHfRingEtSums) {
2243  edm::LogError("L1GtTriggerMenuXmlParser")
2244  << "Wrong particle for HfRingEtSums condition (" << particle << ")" << std::endl;
2245  return false;
2246  }
2247 
2248  // object type and condition type
2249  L1GtObject hfRingEtSumsObjType = HfRingEtSums;
2251 
2252  // global object
2253  int nrObj = 1;
2254 
2255  // get greater equal flag
2256 
2257  int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
2258  if (intGEq < 0) {
2259  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
2260  return false;
2261  }
2262  // set the boolean value for the ge_eq mode
2263  bool gEq = (intGEq != 0);
2264 
2265  // get values
2266 
2267  // temporary storage of the parameters
2268  std::vector<L1GtHfRingEtSumsTemplate::ObjectParameter> objParameter(nrObj);
2269 
2270  // get etSumIndex value and fill into structure
2271  // they are expressed in base 10
2272  char* endPtr = nullptr;
2273  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2274 
2275  if (*endPtr != 0) {
2276  LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec." << std::endl;
2277 
2278  return false;
2279  }
2280 
2281  // test if ET sum index is out of range FIXME introduce m_numberL1HfRingEtSums?
2282  //if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1HfRingEtSums))) {
2283  // LogDebug("L1GtTriggerMenuXmlParser") << "Count index " << typeInt
2284  // << " outside range [0, " << m_numberL1HfRingEtSums << "]" << std::endl;
2285  //
2286  // return false;
2287  //}
2288 
2289  objParameter[0].etSumIndex = static_cast<unsigned int>(typeInt);
2290 
2291  // get ET sum threshold values and fill into structure
2292  std::vector<uint64_t> tmpValues(nrObj);
2293 
2294  if (!getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues)) {
2295  return false;
2296  }
2297 
2298  for (int i = 0; i < nrObj; i++) {
2299  objParameter[i].etSumThreshold = tmpValues[i];
2300 
2301  //LogTrace("L1GtTriggerMenuXmlParser")
2302  //<< " HfRingEtSums count threshold (hex) for HfRingEtSums object " << i << " = "
2303  //<< std::hex << objParameter[i].etSumThreshold << std::dec
2304  //<< std::endl;
2305  }
2306 
2307  // object types - all same objType
2308  std::vector<L1GtObject> objType(nrObj, hfRingEtSumsObjType);
2309 
2310  // now create a new HfRingEtSums condition
2311 
2312  L1GtHfRingEtSumsTemplate hfRingEtSumsCond(name);
2313 
2314  hfRingEtSumsCond.setCondType(cType);
2315  hfRingEtSumsCond.setObjectType(objType);
2316  hfRingEtSumsCond.setCondGEq(gEq);
2317  hfRingEtSumsCond.setCondChipNr(chipNr);
2318 
2319  hfRingEtSumsCond.setConditionParameter(objParameter);
2320 
2321  if (edm::isDebugEnabled()) {
2322  std::ostringstream myCoutStream;
2323  hfRingEtSumsCond.print(myCoutStream);
2324  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2325  }
2326 
2327  // insert condition into the map
2328  if (!insertConditionIntoMap(hfRingEtSumsCond, chipNr)) {
2329  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2330 
2331  return false;
2332  } else {
2333  (m_vecHfRingEtSumsTemplate[chipNr]).push_back(hfRingEtSumsCond);
2334  }
2335 
2336  //
2337  return true;
2338 }
2339 
2352 bool L1GtTriggerMenuXmlParser::parseBptx(XERCES_CPP_NAMESPACE::DOMNode* node,
2353  const std::string& name,
2354  unsigned int chipNr) {
2355  XERCES_CPP_NAMESPACE_USE
2356 
2357  // get condition, particle name and type name
2361 
2362  if (particle != m_xmlConditionAttrObjectBptx) {
2363  edm::LogError("L1GtTriggerMenuXmlParser")
2364  << "\nError: wrong particle for Bptx condition (" << particle << ")" << std::endl;
2365  return false;
2366  }
2367 
2368  // object type and condition type
2369  // object type - irrelevant for BPTX conditions
2370  L1GtConditionType cType = TypeBptx;
2371 
2372  // no objects for BPTX conditions
2373 
2374  // set the boolean value for the ge_eq mode - irrelevant for BPTX conditions
2375  bool gEq = false;
2376 
2377  // now create a new BPTX condition
2378 
2379  L1GtBptxTemplate bptxCond(name);
2380 
2381  bptxCond.setCondType(cType);
2382  bptxCond.setCondGEq(gEq);
2383  bptxCond.setCondChipNr(chipNr);
2384 
2385  LogTrace("L1GtTriggerMenuXmlParser") << bptxCond << "\n" << std::endl;
2386 
2387  // insert condition into the map
2388  if (!insertConditionIntoMap(bptxCond, chipNr)) {
2389  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2390 
2391  return false;
2392  } else {
2393  (m_vecBptxTemplate[chipNr]).push_back(bptxCond);
2394  }
2395 
2396  //
2397  return true;
2398 }
2399 
2412 bool L1GtTriggerMenuXmlParser::parseExternal(XERCES_CPP_NAMESPACE::DOMNode* node,
2413  const std::string& name,
2414  unsigned int chipNr) {
2415  XERCES_CPP_NAMESPACE_USE
2416 
2417  // get condition, particle name and type name
2421 
2422  if (particle != m_xmlConditionAttrObjectGtExternal) {
2423  edm::LogError("L1GtTriggerMenuXmlParser")
2424  << "\nError: wrong particle for External condition (" << particle << ")" << std::endl;
2425  return false;
2426  }
2427 
2428  // object type and condition type
2429  // object type - irrelevant for External conditions
2431 
2432  // no objects for External conditions
2433 
2434  // set the boolean value for the ge_eq mode - irrelevant for External conditions
2435  bool gEq = false;
2436 
2437  // now create a new External condition
2438 
2439  L1GtExternalTemplate externalCond(name);
2440 
2441  externalCond.setCondType(cType);
2442  externalCond.setCondGEq(gEq);
2443  externalCond.setCondChipNr(chipNr);
2444 
2445  LogTrace("L1GtTriggerMenuXmlParser") << externalCond << "\n" << std::endl;
2446 
2447  // insert condition into the map
2448  if (!insertConditionIntoMap(externalCond, chipNr)) {
2449  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2450 
2451  return false;
2452  } else {
2453  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2454  }
2455 
2456  //
2457  return true;
2458 }
2459 
2472 bool L1GtTriggerMenuXmlParser::parseCorrelation(XERCES_CPP_NAMESPACE::DOMNode* node,
2473  const std::string& name,
2474  unsigned int chipNr) {
2475  XERCES_CPP_NAMESPACE_USE
2476 
2477  // create a new correlation condition
2478  L1GtCorrelationTemplate correlationCond(name);
2479 
2480  // check that the condition does not exist already in the map
2481  if (!insertConditionIntoMap(correlationCond, chipNr)) {
2482  edm::LogError("L1GtTriggerMenuXmlParser")
2483  << " Error: duplicate correlation condition (" << name << ")" << std::endl;
2484 
2485  return false;
2486  }
2487 
2488  // get condition, particle name and type name
2492 
2493  LogTrace("L1GtTriggerMenuXmlParser") << " Condition category: " << condition << ", particle: " << particle
2494  << ", type: " << type << "\n"
2495  << std::endl;
2496 
2497  // condition type
2498  L1GtConditionType cType = Type2cor;
2499 
2500  // two objects (for sure)
2501  const int nrObj = 2;
2502 
2503  // object types and greater equal flag - filled in the loop
2504  int intGEq[nrObj] = {-1, -1};
2505  std::vector<L1GtObject> objType(nrObj);
2506  std::vector<L1GtConditionCategory> condCateg(nrObj);
2507 
2508  // correlation flag and index in the cor*vector
2509  const bool corrFlag = true;
2510  int corrIndexVal[nrObj] = {-1, -1};
2511 
2512  // get the subconditions
2513 
2514  DOMNode* conditionsNode = node->getFirstChild();
2515  std::string conditionNameNodeName;
2516  conditionsNode = findXMLChild(conditionsNode, "", true, &conditionNameNodeName);
2517 
2518  for (int iSubCond = 0; iSubCond < nrObj; ++iSubCond) {
2519  // get for sub-condition: category, object name and type name and condition name
2520  condition = getXMLAttribute(conditionsNode, m_xmlConditionAttrCondition);
2521  particle = getXMLAttribute(conditionsNode, m_xmlConditionAttrObject);
2522  type = getXMLAttribute(conditionsNode, m_xmlConditionAttrType);
2523 
2524  LogTrace("L1GtTriggerMenuXmlParser") << " Sub-condition category: " << condition << ", particle: " << particle
2525  << ", type: " << type << ", name: " << conditionNameNodeName << "\n"
2526  << std::endl;
2527 
2528  // call the appropriate function for this condition
2529  if (condition == m_xmlConditionAttrConditionMuon) {
2530  if (!parseMuon(conditionsNode, conditionNameNodeName, chipNr, corrFlag)) {
2531  edm::LogError("L1GtTriggerMenuXmlParser") << "Error parsing sub-condition " << condition << ")"
2532  << " with name " << conditionNameNodeName << std::endl;
2533  }
2534 
2535  // get greater equal flag
2536  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagPtHighThreshold);
2537  if (intGEq[iSubCond] < 0) {
2538  edm::LogError("L1GtTriggerMenuXmlParser")
2539  << "Error getting \"greater or equal\" flag"
2540  << " for sub-condition " << conditionNameNodeName << " for the correlation condition " << name << std::endl;
2541  return false;
2542  }
2543 
2544  // set object type and sub-condition category
2545  objType[iSubCond] = Mu;
2546  condCateg[iSubCond] = CondMuon;
2547  corrIndexVal[iSubCond] = (m_corMuonTemplate[chipNr]).size() - 1;
2548 
2549  } else if (condition == m_xmlConditionAttrConditionCalo) {
2550  if (!parseCalo(conditionsNode, conditionNameNodeName, chipNr, corrFlag)) {
2551  edm::LogError("L1GtTriggerMenuXmlParser") << "Error parsing sub-condition " << condition << ")"
2552  << " with name " << conditionNameNodeName << std::endl;
2553  }
2554 
2555  // get greater equal flag
2556  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
2557  if (intGEq[iSubCond] < 0) {
2558  edm::LogError("L1GtTriggerMenuXmlParser")
2559  << "Error getting \"greater or equal\" flag"
2560  << " for sub-condition " << conditionNameNodeName << " for the correlation condition " << name << std::endl;
2561  return false;
2562  }
2563 
2564  // set object type and sub-condition category
2565  if (particle == m_xmlConditionAttrObjectNoIsoEG) {
2566  objType[iSubCond] = NoIsoEG;
2567  } else if (particle == m_xmlConditionAttrObjectIsoEG) {
2568  objType[iSubCond] = IsoEG;
2569  } else if (particle == m_xmlConditionAttrObjectCenJet) {
2570  objType[iSubCond] = CenJet;
2571  } else if (particle == m_xmlConditionAttrObjectTauJet) {
2572  objType[iSubCond] = TauJet;
2573  } else if (particle == m_xmlConditionAttrObjectForJet) {
2574  objType[iSubCond] = ForJet;
2575  } else {
2576  edm::LogError("L1GtTriggerMenuXmlParser")
2577  << "Wrong object type " << particle << " for sub-condition " << conditionNameNodeName
2578  << " from the correlation condition " << name << std::endl;
2579  return false;
2580  }
2581 
2582  condCateg[iSubCond] = CondCalo;
2583  corrIndexVal[iSubCond] = (m_corCaloTemplate[chipNr]).size() - 1;
2584 
2585  } else if (condition == m_xmlConditionAttrConditionEnergySum) {
2586  if (!parseEnergySum(conditionsNode, conditionNameNodeName, chipNr, corrFlag)) {
2587  edm::LogError("L1GtTriggerMenuXmlParser") << "Error parsing sub-condition " << condition << ")"
2588  << " with name " << conditionNameNodeName << std::endl;
2589  }
2590 
2591  // get greater equal flag
2592  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
2593  if (intGEq[iSubCond] < 0) {
2594  edm::LogError("L1GtTriggerMenuXmlParser")
2595  << "Error getting \"greater or equal\" flag"
2596  << " for sub-condition " << conditionNameNodeName << " for the correlation condition " << name << std::endl;
2597  return false;
2598  }
2599 
2600  // set object type and sub-condition category
2601  if (particle == m_xmlConditionAttrObjectETM) {
2602  objType[iSubCond] = ETM;
2603  } else if (particle == m_xmlConditionAttrObjectETT) {
2604  objType[iSubCond] = ETT;
2605  } else if (particle == m_xmlConditionAttrObjectHTT) {
2606  objType[iSubCond] = HTT;
2607  } else if (particle == m_xmlConditionAttrObjectHTM) {
2608  objType[iSubCond] = HTM;
2609  } else {
2610  edm::LogError("L1GtTriggerMenuXmlParser")
2611  << "Wrong object type " << particle << " for sub-condition " << conditionNameNodeName
2612  << " from the correlation condition " << name << std::endl;
2613  return false;
2614  }
2615 
2616  condCateg[iSubCond] = CondEnergySum;
2617  corrIndexVal[iSubCond] = (m_corEnergySumTemplate[chipNr]).size() - 1;
2618 
2619  } else {
2620  edm::LogError("L1GtTriggerMenuXmlParser")
2621  << "Unknown or un-adequate sub-condition (" << condition << ")"
2622  << " with name " << conditionNameNodeName << " for the correlation condition " << name << std::endl;
2623 
2624  return false;
2625  }
2626 
2627  conditionsNode = findXMLChild(conditionsNode->getNextSibling(), "", true, &conditionNameNodeName);
2628  }
2629 
2630  // get greater equal flag for the correlation condition
2631  bool gEq = true;
2632  if (intGEq[0] != intGEq[1]) {
2633  edm::LogError("L1GtTriggerMenuXmlParser")
2634  << "Inconsistent GEq flags for sub-conditions (" << condition << ")"
2635  << " with name " << conditionNameNodeName << " for the correlation condition " << name << std::endl;
2636  return false;
2637 
2638  } else {
2639  gEq = (intGEq[0] != 0);
2640  }
2641 
2642  // correlation parameters
2643 
2644  // temporary storage of the parameters
2646  std::vector<uint64_t> tmpValues(nrObj);
2647 
2648  // get deltaEtaRange
2649  // if ( !getConditionChildValues(node, m_xmlTagDeltaEta, 1, tmpValues) ) {
2650  // return false;
2651  // }
2652  //
2653  // corrParameter.deltaEtaRange = tmpValues[0];
2654 
2655  XERCES_CPP_NAMESPACE::DOMNode* node1 = findXMLChild(node->getFirstChild(), m_xmlTagDeltaEta);
2656 
2657  std::string valString;
2658 
2659  if (node1 == nullptr) {
2660  edm::LogError("L1GtTriggerMenuXmlParser")
2661  << " Could not get deltaEta for correlation condition " << name << ". " << std::endl;
2662  return false;
2663  } else {
2664  valString = getXMLTextValue(node1);
2665  }
2666 
2667  corrParameter.deltaEtaRange = valString;
2668 
2669  // // deltaPhi is larger than 64bit
2670  // if ( !getXMLHexTextValue128(findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi),
2671  // tmpValues[0], tmpValues[1])) {
2672  // edm::LogError("L1GtTriggerMenuXmlParser")
2673  // << " Could not get deltaPhi for correlation condition " << name << ". "
2674  // << std::endl;
2675  // return false;
2676  // }
2677  //
2678  // corrParameter.deltaPhiRange = tmpValues[0];
2679 
2680  node1 = findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi);
2681 
2682  if (node1 == nullptr) {
2683  return false;
2684  edm::LogError("L1GtTriggerMenuXmlParser")
2685  << " Could not get deltaPhi for correlation condition " << name << ". " << std::endl;
2686  } else {
2687  valString = getXMLTextValue(node1);
2688  }
2689 
2690  corrParameter.deltaPhiRange = valString;
2691 
2692  // get maximum number of bits for delta phi
2693  //LogTrace("L1GtTriggerMenuXmlParser")
2694  //<< " Counting deltaPhiMaxbits"
2695  //<< std::endl;
2696 
2697  unsigned int maxbits;
2698 
2699  if (!countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits)) {
2700  return false;
2701  }
2702 
2703  corrParameter.deltaPhiMaxbits = maxbits;
2704  //LogTrace("L1GtTriggerMenuXmlParser")
2705  //<< " deltaPhiMaxbits (dec) = " << maxbits
2706  //<< std::endl;
2707 
2708  // fill the correlation condition
2709  correlationCond.setCondType(cType);
2710  correlationCond.setObjectType(objType);
2711  correlationCond.setCondGEq(gEq);
2712  correlationCond.setCondChipNr(chipNr);
2713 
2714  correlationCond.setCond0Category(condCateg[0]);
2715  correlationCond.setCond1Category(condCateg[1]);
2716 
2717  correlationCond.setCond0Index(corrIndexVal[0]);
2718  correlationCond.setCond1Index(corrIndexVal[1]);
2719 
2720  correlationCond.setCorrelationParameter(corrParameter);
2721 
2722  if (edm::isDebugEnabled()) {
2723  std::ostringstream myCoutStream;
2724  correlationCond.print(myCoutStream);
2725  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2726  }
2727 
2728  // insert condition into the map
2729  // condition is not duplicate, check was done at the beginning
2730 
2731  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
2732 
2733  //
2734  return true;
2735 }
2736 
2745 bool L1GtTriggerMenuXmlParser::parseId(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
2746  XERCES_CPP_NAMESPACE_USE
2747 
2748  DOMNode* doc = parser->getDocument();
2749  DOMNode* n1 = doc->getFirstChild();
2750 
2751  // we assume that the first child is m_xmlTagDef because it was checked in workXML
2752 
2753  DOMNode* headerNode = n1->getFirstChild();
2754  if (headerNode == nullptr) {
2755  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef << "> tag found." << std::endl;
2756  return false;
2757  }
2758 
2759  headerNode = findXMLChild(headerNode, m_xmlTagHeader);
2760  if (headerNode == nullptr) {
2761  LogDebug("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagHeader << "> tag"
2762  << "\n - No header information." << std::endl;
2763 
2764  } else {
2765  DOMNode* idNode = headerNode->getFirstChild();
2766 
2767  // find menu interface name
2768  idNode = findXMLChild(idNode, m_xmlTagMenuInterface);
2769  if (idNode == nullptr) {
2770  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuInterface << "> tag"
2771  << "\n - Trigger menu interface name derived from file name." << std::endl;
2772 
2773  // set the name of the trigger menu interface: from beginning of file names
2774  // until beginning of "_L1T_Scales"
2775  size_t xmlPos = m_triggerMenuName.find("_L1T_Scales", 0);
2776  if (xmlPos == std::string::npos) {
2777  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find \"_L1T_Scales\" "
2778  << "string in file name"
2779  << "\n - Trigger menu interface name set to file name." << std::endl;
2781 
2782  } else {
2784  m_triggerMenuInterface.erase(m_triggerMenuInterface.begin(), m_triggerMenuInterface.begin() + xmlPos);
2785  }
2786 
2787  } else {
2789  }
2790 
2791  // find menu interface creation date
2792  idNode = headerNode->getFirstChild();
2793  idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDate);
2794 
2795  if (idNode == nullptr) {
2796  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuInterfaceDate << "> tag"
2797  << "\n - No creation date." << m_triggerMenuInterfaceDate << std::endl;
2798 
2799  } else {
2801  }
2802 
2803  // find menu interface creation author
2804  idNode = headerNode->getFirstChild();
2805  idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceAuthor);
2806 
2807  if (idNode == nullptr) {
2808  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuInterfaceAuthor << "> tag"
2809  << "\n - No creation author." << m_triggerMenuInterfaceAuthor << std::endl;
2810 
2811  } else {
2813  }
2814 
2815  // find menu interface description
2816  idNode = headerNode->getFirstChild();
2818 
2819  if (idNode == nullptr) {
2820  LogTrace("L1GtTriggerMenuXmlParser")
2821  << "\n Warning: Could not find <" << m_xmlTagMenuInterfaceDescription << "> tag"
2822  << "\n - No description." << m_triggerMenuInterfaceDescription << std::endl;
2823 
2824  } else {
2826  }
2827 
2828  // find menu creation date
2829  idNode = headerNode->getFirstChild();
2830  idNode = findXMLChild(idNode, m_xmlTagMenuDate);
2831 
2832  if (idNode == nullptr) {
2833  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuDate << "> tag"
2834  << "\n - No creation date." << m_triggerMenuDate << std::endl;
2835 
2836  } else {
2838  }
2839 
2840  // find menu creation author
2841  idNode = headerNode->getFirstChild();
2842  idNode = findXMLChild(idNode, m_xmlTagMenuAuthor);
2843 
2844  if (idNode == nullptr) {
2845  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuAuthor << "> tag"
2846  << "\n - No creation author." << m_triggerMenuAuthor << std::endl;
2847 
2848  } else {
2850  }
2851 
2852  // find menu description
2853  idNode = headerNode->getFirstChild();
2854  idNode = findXMLChild(idNode, m_xmlTagMenuDescription);
2855 
2856  if (idNode == nullptr) {
2857  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuDescription << "> tag"
2858  << "\n - No description." << m_triggerMenuDescription << std::endl;
2859 
2860  } else {
2862  }
2863 
2864  // find algorithm implementation tag
2865 
2866  idNode = headerNode->getFirstChild();
2867 
2868  idNode = findXMLChild(idNode, m_xmlTagMenuAlgImpl);
2869  if (idNode == nullptr) {
2871  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuAlgImpl << "> tag"
2872  << "\n - Algorithm implementation tag set to empty string." << std::endl;
2873 
2874  } else {
2876  }
2877 
2878  // find DB key for L1 scales
2879 
2880  idNode = headerNode->getFirstChild();
2881 
2882  idNode = findXMLChild(idNode, m_xmlTagScaleDbKey);
2883  if (idNode == nullptr) {
2884  m_scaleDbKey = "NULL";
2885  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagScaleDbKey << "> tag"
2886  << "\n - Scale key set to " << m_scaleDbKey << " string." << std::endl;
2887 
2888  } else {
2889  m_scaleDbKey = getXMLTextValue(idNode);
2890  }
2891  }
2892 
2893  LogDebug("L1GtTriggerMenuXmlParser") << "\n Parsed values from XML file"
2894  << "\nL1 MenuInterface: " << m_triggerMenuInterface
2895  << "\nL1 MenuInterface - Creation date: " << m_triggerMenuInterfaceDate
2896  << "\nL1 MenuInterface - Creation author: " << m_triggerMenuInterfaceAuthor
2897  << "\nL1 MenuInterface - Description: " << m_triggerMenuInterfaceDescription
2898  << "\n"
2899  << "\nAlgorithm implementation tag: " << m_algorithmImplementation << "\n"
2900  << "\nL1 Menu - Creation date: " << m_triggerMenuDate
2901  << "\nL1 Menu - Creation author: " << m_triggerMenuAuthor
2902  << "\nL1 Menu - Description: " << m_triggerMenuDescription
2903  << std::endl;
2904 
2905  // set the trigger menu name
2906  // format:
2907  // L1MenuInterface/ScaleDbKey/AlgorithmImplementationTag
2908 
2910 
2911  if (menuName != m_triggerMenuName) {
2912  LogDebug("L1GtTriggerMenuXmlParser") << "\n Warning: Inconsistent L1 menu name:"
2913  << "\n from XML file name: " << m_triggerMenuName
2914  << "\n from XML tag: " << menuName << std::endl;
2915 
2916  if (!m_triggerMenuInterface.empty()) {
2917  if (m_scaleDbKey == "NULL") {
2919  } else {
2920  m_triggerMenuName = menuName;
2921  }
2922 
2923  LogTrace("L1GtTriggerMenuXmlParser") << "\n L1 menu name set to value from XML tag!"
2924  << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
2925 
2926  } else {
2927  LogTrace("L1GtTriggerMenuXmlParser") << "\n L1 menu name set to file name!"
2928  << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
2929  }
2930  }
2931 
2932  //
2933  return true;
2934 }
2935 
2947 bool L1GtTriggerMenuXmlParser::workCondition(XERCES_CPP_NAMESPACE::DOMNode* node,
2948  const std::string& name,
2949  unsigned int chipNr) {
2950  XERCES_CPP_NAMESPACE_USE
2951 
2952  // get condition, particle name and type name
2956 
2957  if (condition.empty() || particle.empty() || type.empty()) {
2958  edm::LogError("L1GtTriggerMenuXmlParser") << "Missing attributes for condition " << name << std::endl;
2959 
2960  return false;
2961  }
2962 
2963  //LogTrace("L1GtTriggerMenuXmlParser")
2964  //<< " condition: " << condition << ", particle: " << particle
2965  //<< ", type: " << type << std::endl;
2966 
2967  // call the appropiate function for this condition
2968 
2969  if (condition == m_xmlConditionAttrConditionMuon) {
2970  return parseMuon(node, name, chipNr);
2971  } else if (condition == m_xmlConditionAttrConditionCalo) {
2972  return parseCalo(node, name, chipNr);
2973  } else if (condition == m_xmlConditionAttrConditionEnergySum) {
2974  return parseEnergySum(node, name, chipNr);
2975  } else if (condition == m_xmlConditionAttrConditionJetCounts) {
2976  return parseJetCounts(node, name, chipNr);
2977  } else if (condition == m_xmlConditionAttrConditionCastor) {
2978  return parseCastor(node, name, chipNr);
2979  } else if (condition == m_xmlConditionAttrConditionHfBitCounts) {
2980  return parseHfBitCounts(node, name, chipNr);
2981  } else if (condition == m_xmlConditionAttrConditionHfRingEtSums) {
2982  return parseHfRingEtSums(node, name, chipNr);
2983  } else if (condition == m_xmlConditionAttrConditionBptx) {
2984  return parseBptx(node, name, chipNr);
2985  } else if (condition == m_xmlConditionAttrConditionExternal) {
2986  return parseExternal(node, name, chipNr);
2987  } else if (condition == m_xmlConditionAttrConditionCorrelation) {
2988  return parseCorrelation(node, name, chipNr);
2989  } else {
2990  edm::LogError("L1GtTriggerMenuXmlParser") << "\n Error: unknown condition (" << condition << ")" << std::endl;
2991 
2992  return false;
2993  }
2994 
2995  return true;
2996 }
2997 
3008 bool L1GtTriggerMenuXmlParser::parseConditions(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3009  XERCES_CPP_NAMESPACE_USE
3010 
3011  LogTrace("L1GtTriggerMenuXmlParser") << "\nParsing conditions" << std::endl;
3012 
3013  DOMNode* doc = parser->getDocument();
3014  DOMNode* n1 = doc->getFirstChild();
3015 
3016  // we assume that the first child is m_xmlTagDef because it was checked in workXML
3017 
3018  DOMNode* chipNode = n1->getFirstChild();
3019  if (chipNode == nullptr) {
3020  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef << "> tag found." << std::endl;
3021 
3022  return false;
3023  }
3024 
3025  // find chip
3026 
3027  std::string chipName; // name of the actual chip
3028  chipNode = findXMLChild(chipNode, m_xmlTagChip, true, &chipName);
3029  if (chipNode == nullptr) {
3030  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: Could not find <" << m_xmlTagChip << "> tag" << std::endl;
3031 
3032  return false;
3033  }
3034 
3035  unsigned int chipNr = 0;
3036  do {
3037  // find conditions
3038  DOMNode* conditionsNode = chipNode->getFirstChild();
3039  conditionsNode = findXMLChild(conditionsNode, m_xmlTagConditions);
3040  if (conditionsNode == nullptr) {
3041  edm::LogError("L1GtTriggerMenuXmlParser")
3042  << "Error: No <" << m_xmlTagConditions << "> child found in Chip " << chipName << std::endl;
3043 
3044  return false;
3045  }
3046 
3047  char* nodeName = XMLString::transcode(chipNode->getNodeName());
3048  //LogTrace("L1GtTriggerMenuXmlParser")
3049  //<< "\n Found Chip: " << nodeName << " Name: " << chipName
3050  //<< std::endl;
3051 
3052  XMLString::release(&nodeName);
3053 
3054  // walk through conditions
3055  DOMNode* conditionNameNode = conditionsNode->getFirstChild();
3056  std::string conditionNameNodeName;
3057  conditionNameNode = findXMLChild(conditionNameNode, "", true, &conditionNameNodeName);
3058  while (conditionNameNode != nullptr) {
3059  LogTrace("L1GtTriggerMenuXmlParser")
3060  << "\n Found a condition with name: " << conditionNameNodeName << std::endl;
3061 
3062  if (!workCondition(conditionNameNode, conditionNameNodeName, chipNr)) {
3063  return false;
3064  }
3065  conditionNameNode = findXMLChild(conditionNameNode->getNextSibling(), "", true, &conditionNameNodeName);
3066  }
3067  // next chip
3068  chipNode = findXMLChild(chipNode->getNextSibling(), m_xmlTagChip, true, &chipName);
3069  chipNr++;
3070 
3071  } while (chipNode != nullptr && chipNr < m_numberConditionChips);
3072 
3073  return true;
3074 }
3075 
3087 bool L1GtTriggerMenuXmlParser::workAlgorithm(XERCES_CPP_NAMESPACE::DOMNode* node,
3088  const std::string& algName,
3089  unsigned int chipNr) {
3090  XERCES_CPP_NAMESPACE_USE
3091 
3092  if (node == nullptr) {
3093  LogDebug("L1GtTriggerMenuXmlParser") << " Node is 0 in " << __PRETTY_FUNCTION__
3094  << " can not parse the algorithm " << algName << std::endl;
3095  return false;
3096  }
3097 
3098  // get alias
3100 
3101  if (algAlias.empty()) {
3102  algAlias = algName;
3103  LogDebug("L1GtTriggerMenuXmlParser") << "\n No alias defined for algorithm. Alias set to algorithm name."
3104  << "\n Algorithm name: " << algName
3105  << "\n Algorithm alias: " << algAlias << std::endl;
3106  } else {
3107  LogDebug("L1GtTriggerMenuXmlParser") << "\n Alias defined for algorithm."
3108  << "\n Algorithm name: " << algName
3109  << "\n Algorithm alias: " << algAlias << std::endl;
3110  }
3111 
3112  // get the logical expression from the node
3113  std::string logExpression = getXMLTextValue(node);
3114 
3115  //LogTrace("L1GtTriggerMenuXmlParser")
3116  //<< " Logical expression: " << logExpression
3117  //<< std::endl;
3118 
3119  //LogTrace("L1GtTriggerMenuXmlParser")
3120  //<< " Chip number: " << chipNr
3121  //<< std::endl;
3122 
3123  // determine output pin
3124  DOMNode* pinNode = findXMLChild(node->getFirstChild(), m_xmlTagOutput);
3125  std::string pinString;
3126  int outputPin = 0;
3127 
3128  pinNode = node->getFirstChild();
3129  if ((pinNode = findXMLChild(pinNode, m_xmlTagOutputPin)) != nullptr) {
3130  pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
3131 
3132  // convert pinString to integer
3133  std::istringstream opStream(pinString);
3134 
3135  if ((opStream >> outputPin).fail()) {
3136  LogDebug("L1GtTriggerMenuXmlParser")
3137  << " Unable to convert pin string " << pinString << " to int for algorithm : " << algName << std::endl;
3138 
3139  return false;
3140  }
3141  }
3142 
3143  if (pinNode == nullptr) {
3144  LogTrace("L1GtTriggerMenuXmlParser") << " Warning: No pin number found for algorithm: " << algName << std::endl;
3145 
3146  return false;
3147  }
3148 
3149  //LogTrace("L1GtTriggerMenuXmlParser")
3150  //<< " Output pin: " << outputPin
3151  //<< std::endl;
3152 
3153  // compute the bit number from chip number, output pin and order of the chips
3154  // pin numbering start with 1, bit numbers with 0
3155  int bitNumber = outputPin + (m_orderConditionChip[chipNr] - 1) * m_pinsOnConditionChip - 1;
3156 
3157  //LogTrace("L1GtTriggerMenuXmlParser")
3158  //<< " Bit number: " << bitNumber
3159  //<< std::endl;
3160 
3161  // create a new algorithm and insert it into algorithm map
3162  L1GtAlgorithm alg(algName, logExpression, bitNumber);
3163  alg.setAlgoChipNumber(static_cast<int>(chipNr));
3164  alg.setAlgoAlias(algAlias);
3165 
3166  if (edm::isDebugEnabled()) {
3167  std::ostringstream myCoutStream;
3168  alg.print(myCoutStream);
3169  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3170  }
3171 
3172  // insert algorithm into the map
3173  if (!insertAlgorithmIntoMap(alg)) {
3174  return false;
3175  }
3176 
3177  return true;
3178 }
3179 
3180 /*
3181  * parseAlgorithms Parse the algorithms
3182  * NOTE: the algorithms used here are equivalent to "prealgo" from XML file
3183  * for the VERSION_FINAL
3184  * The "VERSION_PROTOTYPE algo" will be phased out later in the XML file
3185  * See L1GlobalTriggerConfig.h (in the attic)
3186  *
3187  * @param parser A reference to the XercesDOMParser to use.
3188  *
3189  * @return "true" if succeeded, "false" if an error occurred.
3190  *
3191  */
3192 
3193 bool L1GtTriggerMenuXmlParser::parseAlgorithms(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3194  XERCES_CPP_NAMESPACE_USE
3195 
3196  //LogTrace("L1GtTriggerMenuXmlParser") << "\nParsing algorithms" << std::endl;
3197 
3198  DOMNode* doc = parser->getDocument();
3199  DOMNode* node = doc->getFirstChild();
3200 
3201  DOMNode* chipNode = node->getFirstChild();
3202  if (chipNode == nullptr) {
3203  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: No child found for " << m_xmlTagDef << std::endl;
3204  return false;
3205  }
3206 
3207  // find first chip
3208  std::string chipName;
3209  chipNode = findXMLChild(chipNode, m_xmlTagChip, true, &chipName);
3210  if (chipNode == nullptr) {
3211  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: Could not find <" << m_xmlTagChip << std::endl;
3212  return false;
3213  }
3214 
3215  unsigned int chipNr = 0;
3216  do {
3217  //LogTrace("L1GtTriggerMenuXmlParser") << std::endl;
3218 
3219  std::string nodeName = m_xmlTagChip + chipName;
3220  //LogTrace("L1GtTriggerMenuXmlParser")
3221  //<< " Chip: " << nodeName << " Name: " << chipName
3222  //<< std::endl;
3223 
3224  // find algorithms
3225  DOMNode* algNode = chipNode->getFirstChild();
3226  algNode = findXMLChild(algNode, m_xmlTagAlgorithms);
3227  if (algNode == nullptr) {
3228  edm::LogError("L1GtTriggerMenuXmlParser")
3229  << " Error: No <" << m_xmlTagAlgorithms << "> child found in chip " << chipName << std::endl;
3230  return false;
3231  }
3232 
3233  // walk through algorithms
3234  DOMNode* algNameNode = algNode->getFirstChild();
3235  std::string algNameNodeName;
3236  algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
3237 
3238  while (algNameNode != nullptr) {
3239  //LogTrace("L1GtTriggerMenuXmlParser")
3240  //<< " Found an algorithm with name: " << algNameNodeName
3241  //<< std::endl;
3242 
3243  if (!workAlgorithm(algNameNode, algNameNodeName, chipNr)) {
3244  return false;
3245  }
3246 
3247  algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true, &algNameNodeName);
3248  }
3249 
3250  // next chip
3251  chipNode = findXMLChild(chipNode->getNextSibling(), m_xmlTagChip, true, &chipName);
3252  chipNr++;
3253 
3254  } while (chipNode != nullptr && chipNr < m_numberConditionChips);
3255 
3256  return true;
3257 }
3258 
3269 bool L1GtTriggerMenuXmlParser::workTechTrigger(XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& algName) {
3270  XERCES_CPP_NAMESPACE_USE
3271 
3272  if (node == nullptr) {
3273  LogDebug("L1GtTriggerMenuXmlParser") << " Node is 0 in " << __PRETTY_FUNCTION__
3274  << " can not parse the technical trigger " << algName << std::endl;
3275  return false;
3276  }
3277 
3278  // get the logical expression from the node
3279  std::string logExpression = getXMLTextValue(node);
3280 
3281  //LogTrace("L1GtTriggerMenuXmlParser")
3282  //<< " Logical expression: " << logExpression
3283  //<< std::endl;
3284 
3285  // determine bit number (use output pin tag)
3286  DOMNode* pinNode = findXMLChild(node->getFirstChild(), m_xmlTagOutput);
3287  std::string pinString;
3288  int outputPin = 0;
3289 
3290  pinNode = node->getFirstChild();
3291  if ((pinNode = findXMLChild(pinNode, m_xmlTagOutputPin)) != nullptr) {
3292  pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
3293 
3294  // convert pinString to integer
3295  std::istringstream opStream(pinString);
3296 
3297  if ((opStream >> outputPin).fail()) {
3298  LogDebug("L1GtTriggerMenuXmlParser") << " Unable to convert pin string " << pinString
3299  << " to int for technical trigger : " << algName << std::endl;
3300 
3301  return false;
3302  }
3303  }
3304 
3305  if (pinNode == nullptr) {
3306  LogTrace("L1GtTriggerMenuXmlParser") << " Warning: No pin number found for technical trigger: " << algName
3307  << std::endl;
3308 
3309  return false;
3310  }
3311 
3312  // set the bit number
3313  int bitNumber = outputPin;
3314 
3315  //LogTrace("L1GtTriggerMenuXmlParser")
3316  //<< " Bit number: " << bitNumber
3317  //<< std::endl;
3318 
3319  // create a new technical trigger and insert it into technical trigger map
3320  // alias set automatically to name
3321  L1GtAlgorithm alg(algName, logExpression, bitNumber);
3322  alg.setAlgoAlias(algName);
3323 
3324  if (edm::isDebugEnabled()) {
3325  std::ostringstream myCoutStream;
3326  alg.print(myCoutStream);
3327  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3328  }
3329 
3330  // insert technical trigger into the map
3331  if (!insertTechTriggerIntoMap(alg)) {
3332  return false;
3333  }
3334 
3335  return true;
3336 }
3337 
3338 /*
3339  * parseTechTriggers Parse the technical triggers
3340  *
3341  * @param parser A reference to the XercesDOMParser to use.
3342  *
3343  * @return "true" if succeeded, "false" if an error occurred.
3344  *
3345  */
3346 
3347 bool L1GtTriggerMenuXmlParser::parseTechTriggers(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3348  XERCES_CPP_NAMESPACE_USE
3349 
3350  //LogTrace("L1GtTriggerMenuXmlParser") << "\nParsing technical triggers" << std::endl;
3351 
3352  DOMNode* doc = parser->getDocument();
3353  DOMNode* node = doc->getFirstChild();
3354 
3355  DOMNode* algNode = node->getFirstChild();
3356  if (algNode == nullptr) {
3357  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: No child found for " << m_xmlTagDef << std::endl;
3358  return false;
3359  }
3360 
3361  algNode = findXMLChild(algNode, m_xmlTagTechTriggers);
3362  if (algNode == nullptr) {
3363  edm::LogError("L1GtTriggerMenuXmlParser")
3364  << " Error: No <" << m_xmlTagTechTriggers << "> child found." << std::endl;
3365  return false;
3366  }
3367 
3368  // walk through technical triggers
3369  DOMNode* algNameNode = algNode->getFirstChild();
3370  std::string algNameNodeName;
3371  algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
3372 
3373  while (algNameNode != nullptr) {
3374  //LogTrace("L1GtTriggerMenuXmlParser")
3375  //<< " Found an technical trigger with name: " << algNameNodeName
3376  //<< std::endl;
3377 
3378  if (!workTechTrigger(algNameNode, algNameNodeName)) {
3379  return false;
3380  }
3381 
3382  algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true, &algNameNodeName);
3383  }
3384 
3385  return true;
3386 }
3387 
3396 bool L1GtTriggerMenuXmlParser::workXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3397  XERCES_CPP_NAMESPACE_USE
3398 
3399  DOMDocument* doc = parser->getDocument();
3400  DOMNode* n1 = doc->getFirstChild();
3401 
3402  if (n1 == nullptr) {
3403  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: Found no XML child" << std::endl;
3404 
3405  return false;
3406  }
3407 
3408  char* nodeName = XMLString::transcode(n1->getNodeName());
3409 
3410  if (XMLString::compareIString(nodeName, m_xmlTagDef.c_str())) {
3411  edm::LogError("L1GtTriggerMenuXmlParser")
3412  << "Error: First XML child is not \" " << m_xmlTagDef << "\" " << std::endl;
3413 
3414  return false;
3415  }
3416 
3417  LogTrace("L1GtTriggerMenuXmlParser") << "\nFirst node name is: " << nodeName << std::endl;
3418  XMLString::release(&nodeName);
3419 
3420  // clear possible old maps
3421  clearMaps();
3422 
3423  if (!parseId(parser)) {
3424  clearMaps();
3425  return false;
3426  }
3427 
3428  if (!parseConditions(parser)) {
3429  clearMaps();
3430  return false;
3431  }
3432 
3433  if (!parseAlgorithms(parser)) {
3434  clearMaps();
3435  return false;
3436  }
3437 
3438  if (!parseTechTriggers(parser)) {
3439  clearMaps();
3440  return false;
3441  }
3442 
3443  return true;
3444 }
3445 
3446 // static class members
static const std::string m_xmlTagEta
int getBitFromNode(XERCES_CPP_NAMESPACE::DOMNode *node)
get bit from a bit node
static const std::string m_xmlConditionAttrObjectIsoEG
void setGtTriggerMenuInterfaceAuthor(const std::string &)
void setGtTechnicalTriggerMap(const AlgorithmMap &)
bool isDebugEnabled()
tuple ret
prodAgent to be discontinued
static const std::string m_xmlConditionAttrConditionEnergySum
static const std::string m_xmlTagEnableIso
std::vector< std::vector< L1GtCastorTemplate > > m_vecCastorTemplate
static const std::string m_xmlConditionAttrType1s
static const std::string m_xmlTagPhiLow
std::string getXMLTextValue(XERCES_CPP_NAMESPACE::DOMNode *node)
get the text value of a xml node as string
AlgorithmMap m_algorithmAliasMap
map containing the physics algorithms (by alias)
static const std::string m_xmlConditionAttrConditionHfRingEtSums
void setVecCastorTemplate(const std::vector< std::vector< L1GtCastorTemplate > > &)
Definition: L1GtObject.h:38
void setVecEnergySumTemplate(const std::vector< std::vector< L1GtEnergySumTemplate > > &)
static const std::string m_xmlTagDeltaPhi
void setAlgoAlias(const std::string &algoAliasValue)
Definition: L1GtAlgorithm.h:59
void setGtTriggerMenuDate(const std::string &)
static const std::string m_xmlConditionAttrObjectHfRingEtSums
bool hexString2UInt128(const std::string &hexString, uint64_t &dstL, uint64_t &dstH)
convert a hexadecimal string with up to 128 to 2 uint64_t
bool workAlgorithm(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr)
parse an algorithm and insert it into algorithm map.
static const std::string m_xmlConditionAttrConditionCorrelation
void print(std::ostream &myCout) const override
print the condition
std::vector< std::vector< L1GtExternalTemplate > > m_vecExternalTemplate
static const std::string m_xmlConditionAttrObjectCenJet
void print(std::ostream &myCout) const override
print the condition
static const std::string m_xmlTagHeader
void xercesTerminate()
Definition: Xerces.cc:23
Definition: L1GtObject.h:35
virtual void print(std::ostream &myCout) const
print condition
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
void setGtConditionMap(const std::vector< ConditionMap > &)
std::vector< std::vector< L1GtCorrelationTemplate > > m_vecCorrelationTemplate
L1GtConditionType
void setGtPinsOnConditionChip(const unsigned int &)
AlgorithmMap m_technicalTriggerMap
map containing the technical triggers
static const std::string m_xmlConditionAttrObject
void setConditionParameter(const std::vector< ObjectParameter > &)
set functions
bool parseTechTriggers(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
parse all algorithms
static const std::string m_xmlTagEtThreshold
static const std::string m_xmlConditionAttrCondition
bool parseId(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
parse all parse all identification attributes (trigger menu names, scale DB key, etc) ...
unsigned int m_numberPhysTriggers
number of physics trigger algorithms
void setGtAlgorithmMap(const AlgorithmMap &)
const std::string algoName() const
get / set algorithm name
Definition: L1GtAlgorithm.h:52
static void trim(std::string &s)
const std::string & condName() const
get / set condition name
Definition: L1GtCondition.h:52
static const std::string m_xmlConditionAttrType
static const std::string m_xmlConditionAttrType4s
static const std::string m_xmlConditionAttrConditionCalo
void setGtAlgorithmAliasMap(const AlgorithmMap &)
static const std::string m_xmlTagMenuInterface
static const std::string m_xmlTagScaleDbKey
static const std::string m_xmlConditionAttrConditionBptx
AlgorithmMap m_algorithmMap
map containing the physics algorithms (by name)
void setCondGEq(const bool &cGEq)
Definition: L1GtCondition.h:74
void setGtTriggerMenuDescription(const std::string &)
bool parseExternal(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse an External condition
XERCES_CPP_NAMESPACE::XercesDOMParser * initXML(const std::string &xmlFile)
init xml system
bool parseConditions(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
parse all conditions
static const std::string m_xmlConditionAttrConditionMuon
static const std::string m_xmlTagGEq
void setGtTriggerMenuAuthor(const std::string &)
void xercesInitialize()
Definition: Xerces.cc:18
Log< level::Error, false > LogError
void setGtNumberPhysTriggers(const unsigned int &)
static const std::string m_xmlTagVme
void setGtScaleDbKey(const std::string &)
bool getMuonMipIsoBits(XERCES_CPP_NAMESPACE::DOMNode *node, unsigned int num, std::vector< bool > &mipDst, std::vector< bool > &isoEnDst, std::vector< bool > &isoReqDst)
get MIP and Isolation bits from a muon
XERCES_CPP_NAMESPACE::ErrorHandler * m_xmlErrHandler
error handler for xml-parser
static const std::string m_xmlTagMenuInterfaceAuthor
static const std::string m_xmlConditionAttrObjectCastor
static const std::string m_xmlConditionAttrObjectForJet
void print(std::ostream &myCout) const override
print the condition
std::string m_triggerMenuInterfaceDate
members for XML parser only (do not appear in CondFormats)
std::string const & algoAlias() const
get / set algorithm alias
Definition: L1GtAlgorithm.h:57
#define LogTrace(id)
std::string m_scaleDbKey
menu associated scale key
void setCorCaloTemplate(const std::vector< std::vector< L1GtCaloTemplate > > &)
std::vector< std::vector< L1GtBptxTemplate > > m_vecBptxTemplate
bool parseMuon(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0, const bool corrFlag=false)
parse a muon condition
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
Definition: L1GtObject.h:37
static const std::string m_xmlConditionAttrObjectHTM
static const std::string m_xmlConditionAttrObjectNoIsoEG
int getGEqFlag(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &nodeName)
getGEqFlag - get the &quot;greater or equal flag&quot; from a condition
bool parseCorrelation(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a correlation condition
void setVecHfRingEtSumsTemplate(const std::vector< std::vector< L1GtHfRingEtSumsTemplate > > &)
void cleanupXML(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
shutdown the xml utils and deallocate parser and error handler
std::vector< std::vector< L1GtHfBitCountsTemplate > > m_vecHfBitCountsTemplate
static const std::string m_xmlTagChargeCorrelation
void setConditionParameter(const std::vector< ObjectParameter > &objParameter, const CorrelationParameter &corrParameter)
set functions
void setCorMuonTemplate(const std::vector< std::vector< L1GtMuonTemplate > > &)
bool insertConditionIntoMap(L1GtCondition &cond, const int chipNr)
void print(std::ostream &myCout) const override
print the condition
static const std::string m_xmlTagOutputPin
static const std::string m_xmlTagPhi
std::vector< std::vector< L1GtMuonTemplate > > m_corMuonTemplate
void setObjectType(const std::vector< L1GtObject > &objType)
Definition: L1GtCondition.h:69
static const std::string m_xmlTagMenuDate
static const std::string m_xmlTagPhiHigh
void setVecCaloTemplate(const std::vector< std::vector< L1GtCaloTemplate > > &)
unsigned int m_numberTechTriggers
number of technical triggers
std::string getXMLAttribute(const XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name)
get a named attribute for an xml node as string
void setVecBptxTemplate(const std::vector< std::vector< L1GtBptxTemplate > > &)
XERCES_CPP_NAMESPACE::DOMNode * findXMLChild(XERCES_CPP_NAMESPACE::DOMNode *startChild, const std::string &tagName, bool beginOnly=false, std::string *rest=nullptr)
find a named child of a xml node
~L1GtTriggerMenuXmlParser() override
destructor
const int algoOutputPin(const int numberConditionChips, const int pinsOnConditionChip, const std::vector< int > &orderConditionChip) const
get the output pin on the condition chip for the algorithm
std::string m_triggerMenuInterface
menu names
bool parseHfBitCounts(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a HfBitCounts condition
bool parseHfRingEtSums(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a HfRingEtSums condition
void setVecMuonTemplate(const std::vector< std::vector< L1GtMuonTemplate > > &)
std::vector< std::vector< L1GtEnergySumTemplate > > m_corEnergySumTemplate
bool parseVmeXML(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
parse the vme xml file
void setGtTriggerMenuInterfaceDescription(const std::string &)
static const std::string m_xmlConditionAttrObjectTauJet
static const std::string m_xmlTagCountThreshold
typedef for correlation parameters
static const std::string m_xmlTagEnergyOverflow
bool parseJetCounts(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a &quot;jet counts&quot; condition
static const std::string m_xmlTagOutput
static const std::string m_xmlTagDeltaEta
bool parseEnergySum(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0, const bool corrFlag=false)
parse an &quot;energy sum&quot; condition
void parseXmlFile(const std::string &defXmlFile, const std::string &vmeXmlFile)
parse def.xml and vme.xml files
static const std::string m_xmlConditionAttrObjectHfBitCounts
int algoBitNumber() const
get / set algorithm bit number
Definition: L1GtAlgorithm.h:72
static const std::string m_xmlAttrNr
void setGtTriggerMenuName(const std::string &)
static const std::string m_xmlTagPtHighThreshold
static const std::string m_xmlAttrMode
unsigned int m_numberConditionChips
hardware limits
std::vector< std::vector< L1GtJetCountsTemplate > > m_vecJetCountsTemplate
bool workCondition(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr)
choose the parser for a particular condition
void setGtTriggerMenuInterfaceDate(const std::string &)
bool workXML(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
do all the steps for filling a trigger menu
unsigned int m_pinsOnConditionChip
number of pins on the GTL condition chips
bool parseCastor(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a CASTOR condition
void print(std::ostream &myCout) const override
print the condition
bool insertTechTriggerIntoMap(const L1GtAlgorithm &alg)
insert a technical trigger into technical trigger map
void setConditionParameter(const std::vector< ObjectParameter > &)
set functions
bool getConditionChildValues(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &childName, unsigned int num, std::vector< uint64_t > &dst)
get values from a child of a condition
static const std::string m_xmlTagTechTriggers
static const std::string m_xmlConditionAttrConditionCastor
void setGtNumberConditionChips(const unsigned int &)
std::vector< std::vector< L1GtCaloTemplate > > m_vecCaloTemplate
bool parseAlgorithms(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
parse all algorithms
static const std::string m_xmlConditionAttrConditionJetCounts
static const std::string m_xmlConditionAttrObjectHTT
static const std::string m_xmlTagPtLowThreshold
static const std::string m_xmlConditionAttrConditionExternal
void setGtTriggerMenuInterface(const std::string &)
Definition: L1GtObject.h:29
static const std::string m_xmlConditionAttrType3s
unsigned long long uint64_t
Definition: Time.h:13
static const std::string m_xmlAttrModeBit
void print(std::ostream &myCout) const override
print the condition
static const std::string m_xmlConditionAttrObjectBptx
void setVecCorrelationTemplate(const std::vector< std::vector< L1GtCorrelationTemplate > > &)
static const std::string m_xmlConditionAttrObjectMu
int getNumFromType(const std::string &type)
get number of particles from condition type
bool getXMLHexTextValue(XERCES_CPP_NAMESPACE::DOMNode *node, uint64_t &dst)
get a hexadecimal value of a xml node containing text
void setCondChipNr(const int &cChipNr)
Definition: L1GtCondition.h:79
void setVecHfBitCountsTemplate(const std::vector< std::vector< L1GtHfBitCountsTemplate > > &)
static const std::string m_xmlConditionAttrType2cor
constexpr void M2 & dst
std::vector< std::vector< L1GtCaloTemplate > > m_corCaloTemplate
bool parseBptx(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a Bptx condition
deadvectors[0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
static const std::string m_xmlConditionAttrObjectETM
bool getXMLHexTextValue128(XERCES_CPP_NAMESPACE::DOMNode *node, uint64_t &dstL, uint64_t &dstH)
get a hexadecimal value of a xml node containing text with up to 128 bit
void setConditionParameter(const std::vector< ObjectParameter > &)
set functions
std::vector< std::vector< L1GtEnergySumTemplate > > m_vecEnergySumTemplate
Definition: L1GtObject.h:36
void setGtNumberTechTriggers(const unsigned int &)
void setGtOrderConditionChip(const std::vector< int > &)
const int algoChipNumber() const
get / set algorithm bit number
Definition: L1GtAlgorithm.h:77
void setCondType(const L1GtConditionType &cType)
Definition: L1GtCondition.h:64
static const std::string m_xmlTagConditions
static const std::string m_xmlConditionAttrConditionHfBitCounts
bool parseCalo(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0, const bool corrFlag=false)
parse a calorimeter condition
static std::atomic< unsigned int > counter
std::vector< ConditionMap > m_conditionMap
map containing the conditions (per condition chip) - transient
void setCorEnergySumTemplate(const std::vector< std::vector< L1GtEnergySumTemplate > > &)
static const std::string m_xmlTagChip
static const std::string m_xmlTagEnableMip
static const std::string m_xmlConditionAttrObjectETT
static const std::string m_xmlConditionAttrType2s
static const std::string m_xmlTagMenuAuthor
static const std::string m_xmlTagMenuAlgImpl
void setVecJetCountsTemplate(const std::vector< std::vector< L1GtJetCountsTemplate > > &)
bool insertAlgorithmIntoMap(const L1GtAlgorithm &alg)
insert an algorithm into algorithm map
std::vector< std::vector< L1GtHfRingEtSumsTemplate > > m_vecHfRingEtSumsTemplate
static const std::string m_xmlTagQuality
void print(std::ostream &myCout) const override
print the condition
static const std::string m_xmlTagMenuDescription
void setGtAlgorithmImplementation(const std::string &)
static const std::string m_xmlConditionAttrType2wsc
static const std::string m_xmlTagValue
static const std::string m_xmlTagRequestIso
bool countConditionChildMaxBits(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &childName, unsigned int &dst)
get the number of bits in the max attribute of a condition child
void setGtTriggerMenuImplementation(const std::string &)
static const std::string m_xmlTagAlgorithms
static const std::string m_xmlAttrMax
void setConditionParameter(const std::vector< ObjectParameter > &objParameter, const CorrelationParameter &corrParameter)
set functions
L1GtConditionType getTypeFromType(const std::string &type)
tuple size
Write out results.
static const std::string m_xmlTagMenuInterfaceDate
void setConditionParameter(const std::vector< ObjectParameter > &)
set functions
bool workTechTrigger(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name)
parse an algorithm and insert it into algorithm map.
static const std::string m_xmlTagDef
void setVecExternalTemplate(const std::vector< std::vector< L1GtExternalTemplate > > &)
std::vector< int > m_orderConditionChip
static const std::string m_xmlConditionAttrObjectGtExternal
static const std::string m_xmlAlgorithmAttrAlias
std::vector< std::vector< L1GtMuonTemplate > > m_vecMuonTemplate
void setGtNumberL1JetCounts(const unsigned int &)
#define LogDebug(id)
static const std::string m_xmlConditionAttrObjectJetCounts
unsigned int m_numberL1JetCounts
jet counts
static const std::string m_xmlTagMenuInterfaceDescription