CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 #include <boost/cstdint.hpp>
27 
28 // user include files
29 // base class
31 
34 
38 
39 // constructor
41  L1GtXmlParserTags(), m_xmlErrHandler(0), m_triggerMenuInterface("NULL"),
42  m_triggerMenuName("NULL"), m_triggerMenuImplementation("NULL"), m_scaleDbKey("NULL")
43 
44 {
45 
46  // menu names, scale key initialized to NULL due to ORACLE treatment of strings
47 
48  // empty
49 
50 }
51 
52 // destructor
54 
55  clearMaps();
56 
57 }
58 
59 // set the number of condition chips in GTL
61  const unsigned int& numberConditionChipsValue) {
62 
63  m_numberConditionChips = numberConditionChipsValue;
64 
65 }
66 
67 // set the number of pins on the GTL condition chips
68 void L1GtTriggerMenuXmlParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
69 
70  m_pinsOnConditionChip = pinsOnConditionChipValue;
71 
72 }
73 
74 // set the correspondence "condition chip - GTL algorithm word"
75 // in the hardware
77  const std::vector<int>& orderConditionChipValue) {
78 
79  m_orderConditionChip = orderConditionChipValue;
80 
81 }
82 
83 // set the number of physics trigger algorithms
85  const unsigned int& numberPhysTriggersValue) {
86 
87  m_numberPhysTriggers = numberPhysTriggersValue;
88 
89 }
90 
91 // set the number of technical triggers
93  const unsigned int& numberTechTriggersValue) {
94 
95  m_numberTechTriggers = numberTechTriggersValue;
96 
97 }
98 
99 // set the number of L1 jet counts received by GT
100 void L1GtTriggerMenuXmlParser::setGtNumberL1JetCounts(const unsigned int& numberL1JetCountsValue) {
101 
102  m_numberL1JetCounts = numberL1JetCountsValue;
103 
104 }
105 
106 
107 // set the condition maps
108 void L1GtTriggerMenuXmlParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) {
109  m_conditionMap = condMap;
110 }
111 
112 // set the trigger menu name
114  m_triggerMenuInterface = menuInterface;
115 }
116 
118  m_triggerMenuName = menuName;
119 }
120 
122  m_triggerMenuImplementation = menuImplementation;
123 }
124 
125 // set menu associated scale key
127  m_scaleDbKey = scaleKey;
128 }
129 
130 // set the vectors containing the conditions
132  const std::vector<std::vector<L1GtMuonTemplate> >& vecMuonTempl) {
133 
134  m_vecMuonTemplate = vecMuonTempl;
135 }
136 
138  const std::vector<std::vector<L1GtCaloTemplate> >& vecCaloTempl) {
139 
140  m_vecCaloTemplate = vecCaloTempl;
141 }
142 
144  const std::vector<std::vector<L1GtEnergySumTemplate> >& vecEnergySumTempl) {
145 
146  m_vecEnergySumTemplate = vecEnergySumTempl;
147 }
148 
150  const std::vector<std::vector<L1GtJetCountsTemplate> >& vecJetCountsTempl) {
151 
152  m_vecJetCountsTemplate = vecJetCountsTempl;
153 }
154 
156  const std::vector<std::vector<L1GtCastorTemplate> >& vecCastorTempl) {
157 
158  m_vecCastorTemplate = vecCastorTempl;
159 }
160 
162  const std::vector<std::vector<L1GtHfBitCountsTemplate> >& vecHfBitCountsTempl) {
163 
164  m_vecHfBitCountsTemplate = vecHfBitCountsTempl;
165 }
166 
168  const std::vector<std::vector<L1GtHfRingEtSumsTemplate> >& vecHfRingEtSumsTempl) {
169 
170  m_vecHfRingEtSumsTemplate = vecHfRingEtSumsTempl;
171 }
172 
174  const std::vector<std::vector<L1GtBptxTemplate> >& vecBptxTempl) {
175 
176  m_vecBptxTemplate = vecBptxTempl;
177 }
178 
180  const std::vector<std::vector<L1GtExternalTemplate> >& vecExternalTempl) {
181 
182  m_vecExternalTemplate = vecExternalTempl;
183 }
184 
186  const std::vector<std::vector<L1GtCorrelationTemplate> >& vecCorrelationTempl) {
187 
188  m_vecCorrelationTemplate = vecCorrelationTempl;
189 }
190 
191 // set the vectors containing the conditions for correlation templates
192 //
194  const std::vector<std::vector<L1GtMuonTemplate> >& corMuonTempl) {
195 
196  m_corMuonTemplate = corMuonTempl;
197 }
198 
200  const std::vector<std::vector<L1GtCaloTemplate> >& corCaloTempl) {
201 
202  m_corCaloTemplate = corCaloTempl;
203 }
204 
206  const std::vector<std::vector<L1GtEnergySumTemplate> >& corEnergySumTempl) {
207 
208  m_corEnergySumTemplate = corEnergySumTempl;
209 }
210 
211 
212 
213 
214 // set the algorithm map (by algorithm names)
216  m_algorithmMap = algoMap;
217 }
218 
219 // set the algorithm map (by algorithm aliases)
221  m_algorithmAliasMap = algoMap;
222 }
223 
224 // set the technical trigger map
226  m_technicalTriggerMap = ttMap;
227 }
228 
229 //
230 
231 
232 // parse def.xml and vme.xml files
234  const std::string& vmeXmlFile) {
235 
236  XERCES_CPP_NAMESPACE_USE
237 
238  // resize the vector of condition maps
239  // the number of condition chips should be correctly set before calling parseXmlFile
241 
251 
256 
257  // set the name of the trigger menu name:
258  // defXmlFile, stripped of absolute path and .xml
259  // will be overwritten by the value read from the xml file, with a warning if
260  // they are not the same
261  m_triggerMenuName = defXmlFile;
262  size_t xmlPos = m_triggerMenuName.find_last_of("/");
264  + xmlPos + 1);
265 
266  xmlPos = m_triggerMenuName.find_last_of(".");
267  m_triggerMenuName.erase(m_triggerMenuName.begin() + xmlPos, m_triggerMenuName.end());
268 
269  // error handler for xml-parser
270  m_xmlErrHandler = 0;
271 
272  XercesDOMParser* parser;
273 
274  LogTrace("L1GtTriggerMenuXmlParser") << "\nOpening XML-File: \n " << defXmlFile << std::endl;
275 
276  if ((parser = initXML(defXmlFile)) != 0) {
277  workXML(parser);
278  }
279  cleanupXML(parser);
280 
281 }
282 
283 //
284 
286 
288 
289 }
290 
292 
294 
295 }
296 
298 
300 
301 }
302 
303 
305 
306  m_triggerMenuDate = val;
307 
308 }
309 
311 
312  m_triggerMenuAuthor = val;
313 
314 }
315 
317 
319 
320 }
321 
323 
325 
326 }
327 
328 // private methods
329 
330 
331 
341 XERCES_CPP_NAMESPACE::XercesDOMParser* L1GtTriggerMenuXmlParser::initXML(const std::string &xmlFile) {
342 
343  XERCES_CPP_NAMESPACE_USE
344 
345  // try to initialize
346  try {
348  }
349  catch (const XMLException& toCatch) {
350  char* message = XMLString::transcode(toCatch.getMessage());
351 
352  edm::LogError("L1GtTriggerMenuXmlParser")
353  << "Error during Xerces-c initialization! :"
354  << message << std::endl;
355 
356  XMLString::release(&message);
357  return 0;
358  }
359 
360  XercesDOMParser* parser = new XercesDOMParser();
361  parser->setValidationScheme(XercesDOMParser::Val_Always);
362  parser->setDoNamespaces(false); // we got no dtd
363 
364  if (m_xmlErrHandler == 0) { // redundant check
365  m_xmlErrHandler = (ErrorHandler*) new HandlerBase();
366  }
367  else {
368  // TODO ASSERTION
369  }
370  parser->setErrorHandler(m_xmlErrHandler);
371 
372  // try to parse the file
373  try {
374  parser->parse(xmlFile.c_str());
375  }
376  catch(const XMLException &toCatch) {
377  char* message = XMLString::transcode(toCatch.getMessage());
378 
379  edm::LogError("L1GtTriggerMenuXmlParser")
380  << "Exception while parsing XML: \n"
381  << message << std::endl;
382 
383  XMLString::release(&message);
384  delete parser;
385  delete m_xmlErrHandler;
386  m_xmlErrHandler = 0;
387  return 0;
388  }
389  catch (const DOMException &toCatch) {
390  char *message = XMLString::transcode(toCatch.msg);
391 
392  edm::LogError("L1GtTriggerMenuXmlParser")
393  << "DOM-Exception while parsing XML: \n"
394  << message << std::endl;
395 
396  XMLString::release(&message);
397  delete parser;
398  delete m_xmlErrHandler;
399  m_xmlErrHandler = 0;
400  return 0;
401  }
402  catch (...) {
403 
404  edm::LogError("L1GtTriggerMenuXmlParser")
405  << "Unexpected Exception while parsing XML!"
406  << std::endl;
407 
408  delete parser;
409  delete m_xmlErrHandler;
410  m_xmlErrHandler = 0;
411  return 0;
412  }
413 
414  return parser;
415 }
416 
417 // find a named child of a xml node
418 XERCES_CPP_NAMESPACE::DOMNode* L1GtTriggerMenuXmlParser::findXMLChild(
419  XERCES_CPP_NAMESPACE::DOMNode* startChild, const std::string& tagName, bool beginOnly,
420  std::string* rest) {
421 
422  XERCES_CPP_NAMESPACE_USE
423 
424  char* nodeName = 0;
425 
426  DOMNode *n1 = startChild;
427  if (n1 == 0) {
428  return 0;
429  }
430 
431  if ( !tagName.empty() ) {
432  nodeName = XMLString::transcode(n1->getNodeName());
433 
434  if (!beginOnly) {
435  //match the whole tag
436  while (XMLString::compareIString(nodeName, tagName.c_str())) {
437 
438  XMLString::release(&nodeName);
439  n1 = n1->getNextSibling();
440  if (n1 == 0) {
441  break;
442  }
443 
444  nodeName = XMLString::transcode(n1->getNodeName());
445  }
446  }
447  else {
448  // match only the beginning
449  while (XMLString::compareNIString(nodeName, tagName.c_str(), tagName.length())) {
450  XMLString::release(&nodeName);
451  n1 = n1->getNextSibling();
452  if (n1 == 0) {
453  break;
454  }
455 
456  nodeName = XMLString::transcode(n1->getNodeName());
457  }
458  if (n1 != 0 && rest != 0) {
459  *rest = std::string(nodeName).substr(tagName.length(), strlen(nodeName) - tagName.length());
460  }
461  }
462  }
463  else { // empty string given
464  while (n1->getNodeType() != DOMNode::ELEMENT_NODE) {
465  n1 = n1->getNextSibling();
466  if (n1 == 0) {
467  break;
468  }
469 
470  }
471  if (n1 != 0 && rest != 0) {
472  nodeName = XMLString::transcode(n1->getNodeName());
473  *rest = std::string(nodeName);
474  }
475  }
476 
477  XMLString::release(&nodeName);
478 
479  return n1;
480 
481 }
482 
492 std::string L1GtTriggerMenuXmlParser::getXMLAttribute(const XERCES_CPP_NAMESPACE::DOMNode* node,
493  const std::string& name) {
494 
495  XERCES_CPP_NAMESPACE_USE
496 
498 
499  // get attributes list
500  DOMNamedNodeMap* attributes = node->getAttributes();
501  if (attributes == 0) {
502  return ret;
503  }
504 
505  // get attribute node
506  XMLCh* attrName = XMLString::transcode(name.c_str());
507  DOMNode* attribNode = attributes->getNamedItem(attrName);
508 
509  XMLString::release(&attrName);
510  if (attribNode == 0) {
511  return ret;
512  }
513 
514  char* retCstr = XMLString::transcode(attribNode->getNodeValue());
515  ret = retCstr;
516  XMLString::release(&retCstr);
517 
518  return ret;
519 }
520 
529 std::string L1GtTriggerMenuXmlParser::getXMLTextValue(XERCES_CPP_NAMESPACE::DOMNode* node) {
530 
531  XERCES_CPP_NAMESPACE_USE
532 
534 
535  DOMNode* n1 = node;
536  if (n1 == 0) {
537  return ret;
538  }
539 
540  const XMLCh* retXmlCh = n1->getTextContent();
541  if (retXmlCh == 0) {
542  return ret;
543  }
544 
545  char* retCstr = XMLString::transcode(retXmlCh);
546  XMLString::trim(retCstr); // trim spaces
547 
548  ret = retCstr;
549  XMLString::release(&retCstr);
550 
551  return ret;
552 }
553 
565  boost::uint64_t& dstL, boost::uint64_t& dstH) {
566 
567  // string to determine start of hex value, do not ignore leading zeros
568  static const std::string valid_hex_start("0123456789ABCDEFabcdef");
569 
570  // string to determine end of hex value
571  static const std::string valid_hex_end("0123456789ABCDEFabcdef");
572 
573  std::string tempStr = hexString;
574 
575  // start / end position of the hex value in the string
576  unsigned int hexStart = tempStr.find_first_of(valid_hex_start);
577  unsigned int hexEnd = tempStr.find_first_not_of(valid_hex_end, hexStart);
578 
579  if (hexStart == hexEnd) {
580 
581  LogDebug("L1GtTriggerMenuXmlParser") << "No hex value found in: " << tempStr << std::endl;
582 
583  return false;
584  }
585 
586  tempStr = tempStr.substr(hexStart, hexEnd - hexStart);
587 
588  if (tempStr.empty() ) {
589 
590  LogDebug("L1GtTriggerMenuXmlParser") << "Empty value in " << __PRETTY_FUNCTION__
591  << std::endl;
592 
593  return false;
594  }
595 
596  // split the string
597  std::string tempStrH, tempStrL;
598 
599  if (tempStr.length() > 16) { // more than 64 bit
600  tempStrL = tempStr.substr(tempStr.length()-16, 16);
601  tempStrH = tempStr.substr(0, tempStr.length()-16);
602  }
603  else {
604  tempStrL = tempStr;
605  tempStrH = "0";
606  }
607 
608  // convert lower 64bit
609  char* endPtr = (char*) tempStrL.c_str();
610  boost::uint64_t tempUIntL = strtoull(tempStrL.c_str(), &endPtr, 16);
611 
612  if (*endPtr != 0) {
613 
614  LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex."
615  << std::endl;
616 
617  return false;
618  }
619 
620  // convert higher64 bit
621  endPtr = (char*) tempStrH.c_str();
622  boost::uint64_t tempUIntH = strtoull(tempStrH.c_str(), &endPtr, 16);
623 
624  if (*endPtr != 0) {
625 
626  LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex."
627  << std::endl;
628 
629  return false;
630  }
631 
632  dstL = tempUIntL;
633  dstH = tempUIntH;
634 
635  return true;
636 }
637 
648 bool L1GtTriggerMenuXmlParser::getXMLHexTextValue128(XERCES_CPP_NAMESPACE::DOMNode* node,
649  boost::uint64_t& dstL, boost::uint64_t& dstH) {
650 
651  if (node == 0) {
652 
653  LogDebug("L1GtTriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
654 
655  return false;
656  }
657 
658  boost::uint64_t tempUIntH, tempUIntL;
659 
660  std::string tempStr = getXMLTextValue(node);
661  if ( !hexString2UInt128(tempStr, tempUIntL, tempUIntH) ) {
662  return false;
663  }
664 
665  dstL = tempUIntL;
666  dstH = tempUIntH;
667 
668  return true;
669 }
670 
682 bool L1GtTriggerMenuXmlParser::getXMLHexTextValue(XERCES_CPP_NAMESPACE::DOMNode* node,
683  boost::uint64_t& dst) {
684 
685  boost::uint64_t dummyH; // dummy for eventual higher 64bit
686  boost::uint64_t tempUInt; // temporary unsigned integer
687 
688  if ( !getXMLHexTextValue128(node, tempUInt, dummyH) ) {
689  return false;
690  }
691 
692  if (dummyH != 0) {
693  edm::LogError("L1GtTriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
694  return false;
695  }
696 
697  dst = tempUInt;
698 
699  return true;
700 }
701 
713 bool L1GtTriggerMenuXmlParser::countConditionChildMaxBits(XERCES_CPP_NAMESPACE::DOMNode* node,
714  const std::string& childName, unsigned int& dst) {
715 
716  XERCES_CPP_NAMESPACE_USE
717 
718  // should never happen...
719  if (node == 0) {
720 
721  LogDebug("L1GtTriggerMenuXmlParser")
722  << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
723 
724  return false;
725  }
726 
727  DOMNode* n1 = findXMLChild(node->getFirstChild(), childName);
728 
729  if (n1 == 0) {
730 
731  LogDebug("L1GtTriggerMenuXmlParser") << "Child of condition not found ( " << childName
732  << ")" << std::endl;
733 
734  return false;
735  }
736 
737  DOMNode* n2 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
738 
739  if (n2 == 0) {
740 
741  LogDebug("L1GtTriggerMenuXmlParser") << "No value tag found for child " << childName
742  << " in " << __PRETTY_FUNCTION__ << std::endl;
743 
744  return false;
745  }
746 
747  // first try direct
748  std::string maxString = getXMLAttribute(n1, m_xmlAttrMax); // string for the maxbits
749 
750  if (maxString.empty() ) {
751  maxString = getXMLAttribute(n2, m_xmlAttrMax); // try next value tag
752  // if no max was found neither in value nor in the childName tag
753  if (maxString.empty() ) {
754 
755  LogDebug("L1GtTriggerMenuXmlParser") << "No Max value found for " << childName
756  << std::endl;
757 
758  return false;
759  }
760  }
761 
762  // do the hex conversion
763 
764  boost::uint64_t maxBitsL, maxBitsH;
765  if ( !hexString2UInt128(maxString, maxBitsL, maxBitsH) ) {
766  return false;
767  }
768 
769  // count the bits
770  //LogTrace("L1GtTriggerMenuXmlParser")
771  //<< std::dec
772  //<< " words: dec: high (MSB) word = " << maxBitsH << " low word = " << maxBitsL
773  //<< std::hex << "\n"
774  //<< " words: hex: high (MSB) word = " << maxBitsH << " low word = " << maxBitsL
775  //<< std::dec
776  //<< std::endl;
777 
778  unsigned int counter = 0;
779 
780  while (maxBitsL != 0) {
781  // check if bits set countinously
782  if ( (maxBitsL & 1) == 0) {
783 
784  edm::LogError("L1GtTriggerMenuXmlParser")
785  << " Confused by not continous set bits for max value " << maxString
786  << "(child=" << childName << ")" << std::endl;
787 
788  return false;
789  }
790 
791  maxBitsL >>= 1;
792  counter++;
793  }
794 
795  if ( (maxBitsH != 0) && (counter != 64)) {
796 
797  edm::LogError("L1GtTriggerMenuXmlParser")
798  << " Confused by not continous set bits for max value " << maxString << "(child="
799  << childName << ")" << std::endl;
800 
801  return false;
802  }
803 
804  while (maxBitsH != 0) {
805  //check if bits set countinously
806  if ( (maxBitsH & 1) == 0) {
807 
808  edm::LogError("L1GtTriggerMenuXmlParser")
809  << " Confused by not continous set bits for max value " << maxString
810  << "(child=" << childName << ")" << std::endl;
811 
812  return false;
813  }
814 
815  maxBitsH >>= 1;
816  counter++;
817  }
818 
819  dst = counter;
820  return true;
821 
822 }
823 
835 bool L1GtTriggerMenuXmlParser::getConditionChildValues(XERCES_CPP_NAMESPACE::DOMNode* node,
836  const std::string& childName, unsigned int num, std::vector<boost::uint64_t>& dst) {
837 
838  XERCES_CPP_NAMESPACE_USE
839 
840  if (node == 0) {
841 
842  LogDebug("L1GtTriggerMenuXmlParser")
843  << "node == 0 in " << __PRETTY_FUNCTION__
844  << std::endl;
845 
846  return false;
847  }
848 
849  DOMNode* n1 = findXMLChild(node->getFirstChild(), childName);
850 
851  // if child not found
852  if (n1 == 0) {
853 
854  LogDebug("L1GtTriggerMenuXmlParser") << "Child of condition not found ( " << childName
855  << ")" << std::endl;
856 
857  return false;
858  }
859 
860  // no values are sucessfull
861  if (num == 0) {
862  return true;
863  }
864 
865  //
866  dst.reserve(num);
867 
868  //
869  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
870  for (unsigned int i = 0; i < num; i++) {
871  if (n1 == 0) {
872 
873  LogDebug("L1GtTriggerMenuXmlParser") << "Not enough values in condition child ( "
874  << childName << ")" << std::endl;
875 
876  return false;
877  }
878 
879  if ( !getXMLHexTextValue(n1, dst[i]) ) {
880 
881  edm::LogError("L1GtTriggerMenuXmlParser") << "Error converting condition child ( "
882  << childName << ") value." << std::endl;
883 
884  return false;
885  }
886 
887  n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue); // next child
888  }
889 
890  return true;
891 }
892 
900 void L1GtTriggerMenuXmlParser::cleanupXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
901 
902  XERCES_CPP_NAMESPACE_USE
903 
904  if (parser != 0) {
905  delete parser;
906  }
907 
908  if (m_xmlErrHandler != 0) {
909  delete m_xmlErrHandler;
910  m_xmlErrHandler = 0;
911  }
912 
914 
915 }
916 
917 
918 // methods for the VME file
919 
920 
930 bool L1GtTriggerMenuXmlParser::parseVmeXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
931 
932  XERCES_CPP_NAMESPACE_USE
933 
934  DOMDocument* doc = parser->getDocument();
935  DOMNode* n1 = doc->getFirstChild();
936 
937  if (n1 == 0) {
938 
939  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: Found no XML child" << std::endl;
940 
941  return false;
942  }
943 
944  // find "vme"-tag
945  n1 = findXMLChild(n1, m_xmlTagVme);
946  if (n1 == 0) {
947 
948  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No vme tag found." << std::endl;
949  return false;
950  }
951 
952  n1 = n1->getFirstChild();
953 
954  unsigned int chipCounter = 0; // count chips
955 
956  while (chipCounter < m_numberConditionChips) {
957 
958  n1 = findXMLChild(n1, m_xmlTagChip, true);
959  if (n1 == 0) {
960  // just break if no more chips found
961  break;
962  }
963 
964  // node for a particle
965  //DOMNode* particleNode = n1->getFirstChild(); // FIXME un-comment
966 
967  // FIXME parse vme.xml, modify the menu
968 
969  n1 = n1->getNextSibling();
970  chipCounter++;
971  } // end while chipCounter
972 
973  return true;
974 
975 }
976 
977 // methods for conditions and algorithms
978 
979 // clearMaps - delete all conditions and algorithms in
980 // the maps and clear the maps.
982 
983  // loop over condition maps (one map per condition chip)
984  // then loop over conditions in the map
985  for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip
986  != m_conditionMap.end(); itCondOnChip++) {
987 
988  // the conditions in the maps are deleted in L1GtTriggerMenu, not here
989 
990  itCondOnChip->clear();
991 
992  }
993 
994  // the algorithms in the maps are deleted in L1GtTriggerMenu, not here
995  m_algorithmMap.clear();
996 
997 }
998 
999 // insertConditionIntoMap - safe insert of condition into condition map.
1000 // if the condition name already exists, do not insert it and return false
1002 
1003  std::string cName = cond.condName();
1004  //LogTrace("L1GtTriggerMenuXmlParser")
1005  //<< " Trying to insert condition \"" << cName << "\" in the condition map." ;
1006 
1007  // no condition name has to appear twice!
1008  if ((m_conditionMap[chipNr]).count(cName) != 0) {
1009  LogTrace("L1GtTriggerMenuXmlParser") << " Condition " << cName
1010  << " already exists - not inserted!" << std::endl;
1011  return false;
1012  }
1013 
1014  (m_conditionMap[chipNr])[cName] = &cond;
1015  //LogTrace("L1GtTriggerMenuXmlParser")
1016  //<< " OK - condition inserted!"
1017  //<< std::endl;
1018 
1019 
1020  return true;
1021 
1022 }
1023 
1024 // insert an algorithm into algorithm map
1026 
1027  std::string algName = alg.algoName();
1028  std::string algAlias = alg.algoAlias();
1029  //LogTrace("L1GtTriggerMenuXmlParser")
1030  //<< " Trying to insert algorithm \"" << algName << "\" in the algorithm map." ;
1031 
1032  // no algorithm name has to appear twice!
1033  if (m_algorithmMap.count(algName) != 0) {
1034  LogTrace("L1GtTriggerMenuXmlParser") << " Algorithm \"" << algName
1035  << "\"already exists in the algorithm map- not inserted!" << std::endl;
1036  return false;
1037  }
1038 
1039  if (m_algorithmAliasMap.count(algAlias) != 0) {
1040  LogTrace("L1GtTriggerMenuXmlParser") << " Algorithm alias \"" << algAlias
1041  << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
1042  return false;
1043  }
1044 
1045  // bit number less than zero or greater than maximum number of algorithms
1046  int bitNumber = alg.algoBitNumber();
1047  if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
1048  LogTrace("L1GtTriggerMenuXmlParser") << " Bit number " << bitNumber
1049  << " outside allowed range [0, " << m_numberPhysTriggers
1050  << ") - algorithm not inserted!" << std::endl;
1051  return false;
1052  }
1053 
1054  // maximum number of algorithms
1055  if (m_algorithmMap.size() >= m_numberPhysTriggers) {
1056  LogTrace("L1GtTriggerMenuXmlParser") << " More than maximum allowed "
1057  << m_numberPhysTriggers << " algorithms in the algorithm map - not inserted!"
1058  << std::endl;
1059  return false;
1060  }
1061 
1062  // chip number outside allowed values
1063  int chipNr = alg.algoChipNumber(static_cast<int>(m_numberConditionChips),
1064  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1065 
1066  if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
1067  LogTrace("L1GtTriggerMenuXmlParser") << " Chip number " << chipNr
1068  << " outside allowed range [0, " << m_numberConditionChips
1069  << ") - algorithm not inserted!" << std::endl;
1070  return false;
1071  }
1072 
1073  // output pin outside allowed values
1074  int outputPin = alg.algoOutputPin(static_cast<int>(m_numberConditionChips),
1075  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1076 
1077  if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
1078  LogTrace("L1GtTriggerMenuXmlParser") << " Output pin " << outputPin
1079  << " outside allowed range [0, " << m_pinsOnConditionChip
1080  << "] - algorithm not inserted!" << std::endl;
1081  return false;
1082  }
1083 
1084  // no two algorithms on the same chip can have the same output pin
1085  for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
1086 
1087  int iPin = (itAlgo->second).algoOutputPin( static_cast<int>(m_numberConditionChips),
1088  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1089  std::string iName = itAlgo->first;
1090  int iChip = (itAlgo->second).algoChipNumber(static_cast<int>(m_numberConditionChips),
1091  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1092 
1093  if ( (outputPin == iPin) && (chipNr == iChip)) {
1094  LogTrace("L1GtTriggerMenuXmlParser") << " Output pin " << outputPin
1095  << " is the same as for algorithm " << iName
1096  << "\n from the same chip number " << chipNr << " - algorithm not inserted!"
1097  << std::endl;
1098  return false;
1099  }
1100 
1101  }
1102 
1103  // insert algorithm
1104  m_algorithmMap[algName] = alg;
1105  m_algorithmAliasMap[algAlias] = alg;
1106 
1107  //LogTrace("L1GtTriggerMenuXmlParser")
1108  //<< " OK - algorithm inserted!"
1109  //<< std::endl;
1110 
1111  return true;
1112 
1113 }
1114 
1115 // insert a technical trigger into technical trigger map
1117 
1118  std::string algName = alg.algoName();
1119  //LogTrace("L1GtTriggerMenuXmlParser")
1120  //<< " Trying to insert technical trigger \"" << algName
1121  //<< "\" in the technical trigger map." ;
1122 
1123  // no technical trigger name has to appear twice!
1124  if (m_technicalTriggerMap.count(algName) != 0) {
1125  LogTrace("L1GtTriggerMenuXmlParser") << " Technical trigger \""
1126  << algName
1127  << "\"already exists in the technical trigger map- not inserted!"
1128  << std::endl;
1129  return false;
1130  }
1131 
1132  // bit number less than zero or greater than maximum number of technical triggers
1133  int bitNumber = alg.algoBitNumber();
1134  if ((bitNumber < 0)
1135  || (bitNumber >= static_cast<int>(m_numberTechTriggers))) {
1136  LogTrace("L1GtTriggerMenuXmlParser") << " Bit number "
1137  << bitNumber << " outside allowed range [0, "
1139  << ") - technical trigger not inserted!" << std::endl;
1140  return false;
1141  }
1142 
1143  // no two technical triggers can have the same bit number
1144  for (CItAlgo itAlgo = m_technicalTriggerMap.begin(); itAlgo
1145  != m_technicalTriggerMap.end(); itAlgo++) {
1146 
1147  int iBitNumber = (itAlgo->second).algoBitNumber();
1148  std::string iName = itAlgo->first;
1149 
1150  if ((iBitNumber == bitNumber)) {
1151  LogTrace("L1GtTriggerMenuXmlParser") << " Bit number "
1152  << iBitNumber << " is the same as for technical trigger "
1153  << iName << " - technical trigger not inserted!"
1154  << std::endl;
1155  return false;
1156  }
1157 
1158  }
1159 
1160  // maximum number of technical triggers
1162  LogTrace("L1GtTriggerMenuXmlParser")
1163  << " More than maximum allowed " << m_numberTechTriggers
1164  << " technical triggers in the technical trigger map - not inserted!"
1165  << std::endl;
1166  return false;
1167  }
1168 
1169  // insert technical trigger
1170  m_technicalTriggerMap[algName] = alg;
1171 
1172  //LogTrace("L1GtTriggerMenuXmlParser")
1173  //<< " OK - technical trigger inserted!"
1174  //<< std::endl;
1175 
1176  return true;
1177 
1178 }
1179 
1180 
1181 
1182 // get the type of the condition, as defined in enum, from the condition type
1183 // as defined in the XML file
1185 
1186  if (type == m_xmlConditionAttrType1s) {
1187  return Type1s;
1188  }
1189 
1190  if (type == m_xmlConditionAttrType2s) {
1191  return Type2s;
1192  }
1193 
1194  if (type == m_xmlConditionAttrType3s) {
1195  return Type3s;
1196  }
1197 
1198  if (type == m_xmlConditionAttrType4s) {
1199  return Type4s;
1200  }
1201 
1202  if (type == m_xmlConditionAttrType2wsc) {
1203  return Type2wsc;
1204  }
1205 
1206  if (type == m_xmlConditionAttrType2cor) {
1207  return Type2cor;
1208  }
1209 
1210  return TypeNull;
1211 }
1212 
1223 
1224  if (type == m_xmlConditionAttrType1s) {
1225  return 1;
1226  }
1227 
1228  if (type == m_xmlConditionAttrType2s) {
1229  return 2;
1230  }
1231 
1232  if (type == m_xmlConditionAttrType3s) {
1233  return 3;
1234  }
1235 
1236  if (type == m_xmlConditionAttrType4s) {
1237  return 4;
1238  }
1239 
1240  if (type == m_xmlConditionAttrType2wsc) {
1241  return 2;
1242  }
1243 
1244  if (type == m_xmlConditionAttrType2cor) {
1245  return 2;
1246  }
1247 
1248  return -1;
1249 }
1250 
1259 int L1GtTriggerMenuXmlParser::getBitFromNode(XERCES_CPP_NAMESPACE::DOMNode* node) {
1260 
1262 
1263  edm::LogError("L1GtTriggerMenuXmlParser") << "Invalid mode for single bit" << std::endl;
1264 
1265  return -1;
1266  }
1267 
1268  std::string tmpStr = getXMLTextValue(node);
1269  if (tmpStr == "0") {
1270  return 0;
1271  }
1272  else if (tmpStr == "1") {
1273  return 1;
1274  }
1275  else {
1276  edm::LogError("L1GtTriggerMenuXmlParser") << "Bad bit value (" << tmpStr << ")"
1277  << std::endl;
1278  return -1;
1279  }
1280 }
1281 
1291 int L1GtTriggerMenuXmlParser::getGEqFlag(XERCES_CPP_NAMESPACE::DOMNode* node,
1292  const std::string& nodeName) {
1293 
1294  XERCES_CPP_NAMESPACE_USE
1295 
1296  if (node == 0) {
1297 
1298  LogDebug("L1GtTriggerMenuXmlParser")
1299  << "node == 0 in " << __PRETTY_FUNCTION__
1300  << std::endl;
1301 
1302  return -1;
1303  }
1304 
1305  // usually the GEq flag is a child of the first child (the first element node)
1306  DOMNode* n1 = node->getFirstChild();
1307  n1 = findXMLChild(n1, nodeName);
1308 
1309  if (n1 != 0) {
1310  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagGEq);
1311  if (n1 == 0) {
1312 
1313  LogDebug("L1GtTriggerMenuXmlParser") << "No \"greater or equal\" tag found"
1314  << std::endl;
1315 
1316  return -1;
1317  }
1318 
1319  return getBitFromNode(n1);
1320  }
1321  else {
1322 
1323  return -1;
1324 
1325  }
1326 
1327 }
1328 
1341 bool L1GtTriggerMenuXmlParser::getMuonMipIsoBits(XERCES_CPP_NAMESPACE::DOMNode* node,
1342  unsigned int num, std::vector<bool>& mipDst, std::vector<bool>& isoEnDst,
1343  std::vector<bool>& isoReqDst) {
1344 
1345  XERCES_CPP_NAMESPACE_USE
1346 
1347  if (node == 0) {
1348  return false;
1349  }
1350 
1351  // find ptLowThreshold child
1352  DOMNode* n1 = findXMLChild(node->getFirstChild(), m_xmlTagPtLowThreshold);
1353 
1354  if (n1 == 0) {
1355  return false;
1356  }
1357 
1358  // get first value tag
1359  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
1360 
1361  for (unsigned int i = 0; i < num; i++) {
1362 
1363  if (n1 == 0) {
1364  return false;
1365  }
1366 
1367  // MIP bit
1368 
1369  DOMNode* bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableMip);
1370  if (bitnode == 0) {
1371  return true;
1372  }
1373 
1374  int tmpint = getBitFromNode(bitnode);
1375  if (tmpint < 0) {
1376  return false;
1377  }
1378 
1379  mipDst[i] = (tmpint != 0);
1380 
1381  //LogTrace("L1GtTriggerMenuXmlParser")
1382  //<< " MIP bit value for muon " << i << " = " << mipDst[i]
1383  //<< std::endl;
1384 
1385 
1386  // enable iso bit
1387  bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableIso);
1388  if (bitnode == 0) {
1389  return true;
1390  }
1391 
1392  tmpint = getBitFromNode(bitnode);
1393  if (tmpint < 0) {
1394  return false;
1395  }
1396 
1397  isoEnDst[i] = (tmpint != 0);
1398 
1399  //LogTrace("L1GtTriggerMenuXmlParser")
1400  //<< " Enabled iso bit value for muon " << i << " = " << isoEnDst[i]
1401  //<< std::endl;
1402 
1403  // request iso bit
1404  bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagRequestIso);
1405  if (bitnode == 0) {
1406  return true;
1407  }
1408 
1409  tmpint = getBitFromNode(bitnode);
1410  if (tmpint < 0) {
1411  return false;
1412  }
1413 
1414  isoReqDst[i] = (tmpint != 0);
1415 
1416  //LogTrace("L1GtTriggerMenuXmlParser")
1417  //<< " Request iso bit value for muon " << i << " = " << isoReqDst[i]
1418  //<< std::endl;
1419 
1420  //
1421  n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue); // next value
1422  }
1423 
1424  return true;
1425 }
1426 
1438 bool L1GtTriggerMenuXmlParser::parseMuon(XERCES_CPP_NAMESPACE::DOMNode* node,
1439  const std::string& name, unsigned int chipNr, const bool corrFlag) {
1440 
1441  XERCES_CPP_NAMESPACE_USE
1442 
1443  // get condition, particle name (must be muon) and type name
1447 
1448  if (particle != m_xmlConditionAttrObjectMu) {
1449  edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for muon-condition ("
1450  << particle << ")" << std::endl;
1451  return false;
1452  }
1453 
1454  int nrObj = getNumFromType(type);
1455  if (nrObj < 0) {
1456  edm::LogError("L1GtTriggerMenuXmlParser") << "Unknown type for muon-condition (" << type
1457  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1458  return false;
1459  }
1460 
1461  // get greater equal flag
1462 
1463  int intGEq = getGEqFlag(node, m_xmlTagPtHighThreshold);
1464  if (intGEq < 0) {
1465  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
1466  << std::endl;
1467  return false;
1468  }
1469  // set the boolean value for the ge_eq mode
1470  bool gEq = (intGEq != 0);
1471 
1472  // get values
1473 
1474  // temporary storage of the parameters
1475  std::vector<L1GtMuonTemplate::ObjectParameter> objParameter(nrObj);
1477 
1478  // need at least two values for deltaPhi
1479  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1480 
1481  // get ptHighThreshold values and fill into structure
1482  if ( !getConditionChildValues(node, m_xmlTagPtHighThreshold, nrObj, tmpValues) ) {
1483  return false;
1484  }
1485 
1486  for (int i = 0; i < nrObj; i++) {
1487  objParameter[i].ptHighThreshold = tmpValues[i];
1488 
1489  //LogTrace("L1GtTriggerMenuXmlParser")
1490  //<< " Muon pT high threshold (hex) for muon " << i << " = "
1491  //<< std::hex << objParameter[i].ptHighThreshold << std::dec
1492  //<< std::endl;
1493  }
1494 
1495  // get ptLowThreshold values and fill into structure
1496  if ( !getConditionChildValues(node, m_xmlTagPtLowThreshold, nrObj, tmpValues) ) {
1497  return false;
1498  }
1499 
1500  for (int i = 0; i < nrObj; i++) {
1501  //LogTrace("L1GtTriggerMenuXmlParser")
1502  //<< " Muon pT low threshold word (hex) for muon " << i << " = "
1503  //<< std::hex << tmpValues[i] << std::dec
1504  //<< std::endl;
1505 
1506  // TODO FIXME stupid format in def.xml...
1507  // one takes mip bit also, therefore one divide by 16
1508  tmpValues[i] = (tmpValues[i])/16;
1509 
1510  objParameter[i].ptLowThreshold = tmpValues[i];
1511 
1512  //LogTrace("L1GtTriggerMenuXmlParser")
1513  //<< " Muon pT low threshold (hex) for muon " << i << " = "
1514  //<< std::hex << objParameter[i].ptLowThreshold << std::dec
1515  //<< std::endl;
1516  }
1517 
1518  // get qualityRange and fill into structure
1519  if ( !getConditionChildValues(node, m_xmlTagQuality, nrObj, tmpValues) ) {
1520  return false;
1521  }
1522 
1523  for (int i = 0; i < nrObj; i++) {
1524  objParameter[i].qualityRange = tmpValues[i];
1525 
1526  //LogTrace("L1GtTriggerMenuXmlParser")
1527  //<< " qualityRange mask (hex) for muon " << i << " = "
1528  //<< std::hex << objParameter[i].qualityRange << std::dec
1529  //<< std::endl;
1530  }
1531 
1532  // get etaRange and fill into structure
1533  if ( !getConditionChildValues(node, m_xmlTagEta, nrObj, tmpValues) ) {
1534  return false;
1535  }
1536 
1537  for (int i = 0; i < nrObj; i++) {
1538 
1539  objParameter[i].etaRange = tmpValues[i];
1540 
1541  //LogTrace("L1GtTriggerMenuXmlParser")
1542  //<< " etaRange (hex) for muon " << i << " = "
1543  //<< std::hex << objParameter[i].etaRange << std::dec
1544  //<< std::endl;
1545  }
1546 
1547  // get phiHigh values and fill into structure
1548  if ( !getConditionChildValues(node, m_xmlTagPhiHigh, nrObj, tmpValues) ) {
1549  return false;
1550  }
1551 
1552  for (int i = 0; i < nrObj; i++) {
1553  objParameter[i].phiHigh = tmpValues[i];
1554 
1555  //LogTrace("L1GtTriggerMenuXmlParser")
1556  //<< " phiHigh (hex) for muon " << i << " = "
1557  //<< std::hex << objParameter[i].phiHigh << std::dec
1558  //<< std::endl;
1559  }
1560 
1561  // get phiLow values and fill into structure
1562  if ( !getConditionChildValues(node, m_xmlTagPhiLow, nrObj, tmpValues) ) {
1563  return false;
1564  }
1565 
1566  for (int i = 0; i < nrObj; i++) {
1567  objParameter[i].phiLow = tmpValues[i];
1568 
1569  //LogTrace("L1GtTriggerMenuXmlParser")
1570  //<< " phiLow (hex) for muon " << i << " = "
1571  //<< std::hex << objParameter[i].phiLow << std::dec
1572  //<< std::endl;
1573  }
1574 
1575  // get charge correlation and fill into structure
1576  if ( !getXMLHexTextValue(findXMLChild(node->getFirstChild(), m_xmlTagChargeCorrelation),
1577  tmpValues[0]) ) {
1578 
1579  LogDebug("L1GtTriggerMenuXmlParser")
1580  << " Error getting charge correlation from muon condition (" << name << ")"
1581  << std::endl;
1582  return false;
1583  }
1584 
1585  corrParameter.chargeCorrelation = tmpValues[0];
1586 
1587  //LogTrace("L1GtTriggerMenuXmlParser")
1588  //<< " charge correlation" << " = "
1589  //<< std::hex << corrParameter.chargeCorrelation << std::dec
1590  //<< std::endl;
1591 
1592  // get mip and iso bits and fill into structure
1593 
1594  std::vector<bool> tmpMip(nrObj);
1595  std::vector<bool> tmpEnableIso(nrObj);
1596  std::vector<bool> tmpRequestIso(nrObj);
1597 
1598  if ( !getMuonMipIsoBits(node, nrObj, tmpMip, tmpEnableIso, tmpRequestIso) ) {
1599  edm::LogError("L1GtTriggerMenuXmlParser")
1600  << " Could not get mip and iso bits from muon condition (" << name << ")"
1601  << std::endl;
1602  return false;
1603  }
1604 
1605  for (int i = 0; i < nrObj; i++) {
1606  objParameter[i].enableMip = tmpMip[i];
1607  objParameter[i].enableIso = tmpEnableIso[i];
1608  objParameter[i].requestIso = tmpRequestIso[i];
1609  }
1610 
1611  // indicates if a correlation is used
1612  bool wscVal = (type == m_xmlConditionAttrType2wsc );
1613 
1614  if (wscVal) {
1615  // get deltaEtaRange
1616  if ( !getConditionChildValues(node, m_xmlTagDeltaEta, 1, tmpValues) ) {
1617  return false;
1618  }
1619 
1620  corrParameter.deltaEtaRange = tmpValues[0];
1621 
1622  // deltaPhi is larger than 64bit
1623  if ( !getXMLHexTextValue128(findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi),
1624  tmpValues[0], tmpValues[1])) {
1625  edm::LogError("L1GtTriggerMenuXmlParser")
1626  << " Could not get deltaPhi for muon condition with wsc (" << name << ")"
1627  << std::endl;
1628  return false;
1629  }
1630 
1631  corrParameter.deltaPhiRange0Word = tmpValues[0];
1632  corrParameter.deltaPhiRange1Word = tmpValues[1];
1633 
1634  // get maximum number of bits for delta phi
1635  //LogTrace("L1GtTriggerMenuXmlParser")
1636  //<< " Counting deltaPhiMaxbits"
1637  //<< std::endl;
1638 
1639  unsigned int maxbits;
1640 
1641  if ( !countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits) ) {
1642  return false;
1643  }
1644 
1645  corrParameter.deltaPhiMaxbits = maxbits;
1646  //LogTrace("L1GtTriggerMenuXmlParser")
1647  //<< " deltaPhiMaxbits (dec) = " << maxbits
1648  //<< std::endl;
1649  }
1650 
1651  // get the type of the condition, as defined in enum, from the condition type
1652  // as defined in the XML file
1653  L1GtConditionType cType = getTypeFromType(type);
1654  //LogTrace("L1GtTriggerMenuXmlParser")
1655  //<< " Condition type (enum value) = " << cType
1656  //<< std::endl;
1657 
1658  if (cType == TypeNull) {
1659  edm::LogError("L1GtTriggerMenuXmlParser")
1660  << "Type for muon condition id TypeNull - it means not defined in the XML file."
1661  << "\nNumber of trigger objects is set to zero. " << std::endl;
1662  return false;
1663  }
1664 
1665  // object types - all muons
1666  std::vector<L1GtObject> objType(nrObj, Mu);
1667 
1668  // now create a new CondMuonition
1669 
1670  L1GtMuonTemplate muonCond(name);
1671 
1672  muonCond.setCondType(cType);
1673  muonCond.setObjectType(objType);
1674  muonCond.setCondGEq(gEq);
1675  muonCond.setCondChipNr(chipNr);
1676 
1677  muonCond.setConditionParameter(objParameter, corrParameter);
1678 
1679  if (edm::isDebugEnabled() ) {
1680  std::ostringstream myCoutStream;
1681  muonCond.print(myCoutStream);
1682  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
1683  }
1684 
1685  // insert condition into the map and into muon template vector
1686  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1687 
1688  edm::LogError("L1GtTriggerMenuXmlParser")
1689  << " Error: duplicate condition (" << name << ")"
1690  << std::endl;
1691  return false;
1692  }
1693  else {
1694  if (corrFlag) {
1695  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1696 
1697  }
1698  else {
1699  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1700  }
1701 
1702  }
1703 
1704  //
1705  return true;
1706 }
1707 
1719 bool L1GtTriggerMenuXmlParser::parseCalo(XERCES_CPP_NAMESPACE::DOMNode* node,
1720  const std::string& name, unsigned int chipNr, const bool corrFlag) {
1721 
1722  XERCES_CPP_NAMESPACE_USE
1723 
1724  // get condition, particle name and type name
1728 
1729  // determine object type type
1730  L1GtObject caloObjType;
1731 
1732  if (particle == m_xmlConditionAttrObjectNoIsoEG) {
1733  caloObjType = NoIsoEG;
1734  }
1735  else if (particle == m_xmlConditionAttrObjectIsoEG) {
1736  caloObjType = IsoEG;
1737  }
1738  else if (particle == m_xmlConditionAttrObjectCenJet) {
1739  caloObjType = CenJet;
1740  }
1741  else if (particle == m_xmlConditionAttrObjectTauJet) {
1742  caloObjType = TauJet;
1743  }
1744  else if (particle == m_xmlConditionAttrObjectForJet) {
1745  caloObjType = ForJet;
1746  }
1747  else {
1748  edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for calo-condition ("
1749  << particle << ")" << std::endl;
1750  return false;
1751  }
1752 
1753  int nrObj = getNumFromType(type);
1754  if (nrObj < 0) {
1755  edm::LogError("L1GtTriggerMenuXmlParser") << "Unknown type for calo-condition (" << type
1756  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1757  return false;
1758  }
1759 
1760  // get greater equal flag
1761 
1762  int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
1763  if (intGEq < 0) {
1764  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
1765  << std::endl;
1766  return false;
1767  }
1768  // set the boolean value for the ge_eq mode
1769  bool gEq = (intGEq != 0);
1770 
1771  // get values
1772 
1773  // temporary storage of the parameters
1774  std::vector<L1GtCaloTemplate::ObjectParameter> objParameter(nrObj);
1776 
1777  // need at least one value for deltaPhiRange
1778  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1779 
1780  // get etThreshold values and fill into structure
1781  if ( !getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
1782  return false;
1783  }
1784 
1785  for (int i = 0; i < nrObj; i++) {
1786  objParameter[i].etThreshold = tmpValues[i];
1787 
1788  //LogTrace("L1GtTriggerMenuXmlParser")
1789  //<< " Calo ET high threshold (hex) for calo object " << i << " = "
1790  //<< std::hex << objParameter[i].etThreshold << std::dec
1791  //<< std::endl;
1792  }
1793 
1794  // get etaRange and fill into structure
1795  if ( !getConditionChildValues(node, m_xmlTagEta, nrObj, tmpValues) ) {
1796  return false;
1797  }
1798 
1799 
1800  for (int i = 0; i < nrObj; i++) {
1801 
1802  objParameter[i].etaRange = tmpValues[i];
1803 
1804  //LogTrace("L1GtTriggerMenuXmlParser")
1805  //<< " etaRange (hex) for calo object " << i << " = "
1806  //<< std::hex << objParameter[i].etaRange << std::dec
1807  //<< std::endl;
1808  }
1809 
1810  // get phiRange values and fill into structure
1811  if ( !getConditionChildValues(node, m_xmlTagPhi, nrObj, tmpValues) ) {
1812  return false;
1813  }
1814 
1815  for (int i = 0; i < nrObj; i++) {
1816  objParameter[i].phiRange = tmpValues[i];
1817 
1818  //LogTrace("L1GtTriggerMenuXmlParser")
1819  //<< " phiRange (hex) for calo object " << i << " = "
1820  //<< std::hex << objParameter[i].phiRange << std::dec
1821  //<< std::endl;
1822  }
1823 
1824  // indicates if a correlation is used
1825  bool wscVal = (type == m_xmlConditionAttrType2wsc );
1826 
1827  if (wscVal) {
1828  // get deltaEtaRange
1829  if ( !getConditionChildValues(node, m_xmlTagDeltaEta, 1, tmpValues) ) {
1830  return false;
1831  }
1832 
1833  corrParameter.deltaEtaRange = tmpValues[0];
1834 
1835  // get deltaPhiRange
1836  if ( !getConditionChildValues(node, m_xmlTagDeltaPhi, 1, tmpValues) ) {
1837  return false;
1838  }
1839 
1840  corrParameter.deltaPhiRange = tmpValues[0];
1841 
1842  // get maximum number of bits for delta phi
1843  //LogTrace("L1GtTriggerMenuXmlParser")
1844  //<< " Counting deltaPhiMaxbits"
1845  //<< std::endl;
1846 
1847  unsigned int maxbits;
1848 
1849  if ( !countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits) ) {
1850  return false;
1851  }
1852 
1853  corrParameter.deltaPhiMaxbits = maxbits;
1854  //LogTrace("L1GtTriggerMenuXmlParser")
1855  //<< " deltaPhiMaxbits (dec) = " << maxbits
1856  //<< std::endl;
1857  }
1858 
1859  // get the type of the condition, as defined in enum, from the condition type
1860  // as defined in the XML file
1861  L1GtConditionType cType = getTypeFromType(type);
1862  //LogTrace("L1GtTriggerMenuXmlParser")
1863  //<< " Condition type (enum value) = " << cType
1864  //<< std::endl;
1865 
1866  if (cType == TypeNull) {
1867  edm::LogError("L1GtTriggerMenuXmlParser")
1868  << "Type for calo condition id TypeNull - it means not defined in the XML file."
1869  << "\nNumber of trigger objects is set to zero. " << std::endl;
1870  return false;
1871  }
1872 
1873  // object types - all same caloObjType
1874  std::vector<L1GtObject> objType(nrObj, caloObjType);
1875 
1876  // now create a new calo condition
1877 
1878  L1GtCaloTemplate caloCond(name);
1879 
1880  caloCond.setCondType(cType);
1881  caloCond.setObjectType(objType);
1882  caloCond.setCondGEq(gEq);
1883  caloCond.setCondChipNr(chipNr);
1884 
1885  caloCond.setConditionParameter(objParameter, corrParameter);
1886 
1887  if (edm::isDebugEnabled() ) {
1888 
1889  std::ostringstream myCoutStream;
1890  caloCond.print(myCoutStream);
1891  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
1892 
1893  }
1894 
1895  // insert condition into the map
1896  if ( !insertConditionIntoMap(caloCond, chipNr)) {
1897 
1898  edm::LogError("L1GtTriggerMenuXmlParser")
1899  << " Error: duplicate condition (" << name << ")"
1900  << std::endl;
1901 
1902  return false;
1903  }
1904  else {
1905 
1906  if (corrFlag) {
1907  (m_corCaloTemplate[chipNr]).push_back(caloCond);
1908  }
1909  else {
1910  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
1911  }
1912 
1913  }
1914 
1915 
1916  //
1917  return true;
1918 }
1919 
1932  XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& name,
1933  unsigned int chipNr, const bool corrFlag) {
1934 
1935  XERCES_CPP_NAMESPACE_USE
1936 
1937  // get condition, particle name and type name
1941 
1942  // determine object type type
1943  L1GtObject energySumObjType;
1944  L1GtConditionType cType;
1945 
1946  if ((particle == m_xmlConditionAttrObjectETM) && (type == m_xmlConditionAttrObjectETM)) {
1947 
1948  energySumObjType = ETM;
1949  cType = TypeETM;
1950 
1951  }
1952  else if ((particle == m_xmlConditionAttrObjectETT) && (type == m_xmlConditionAttrObjectETT)) {
1953 
1954  energySumObjType = ETT;
1955  cType = TypeETT;
1956 
1957  }
1958  else if ((particle == m_xmlConditionAttrObjectHTT) && (type == m_xmlConditionAttrObjectHTT)) {
1959 
1960  energySumObjType = HTT;
1961  cType = TypeHTT;
1962 
1963  }
1964  else if ((particle == m_xmlConditionAttrObjectHTM) && (type == m_xmlConditionAttrObjectHTM)) {
1965 
1966  energySumObjType = HTM;
1967  cType = TypeHTM;
1968 
1969  }
1970  else {
1971  edm::LogError("L1GtTriggerMenuXmlParser")
1972  << "Wrong particle or type for energy-sum condition (" << particle << ", " << type
1973  << ")" << std::endl;
1974  return false;
1975  }
1976 
1977  // global object
1978  int nrObj = 1;
1979 
1980  // get greater equal flag
1981 
1982  int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
1983  if (intGEq < 0) {
1984  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
1985  << std::endl;
1986  return false;
1987  }
1988  // set the boolean value for the ge_eq mode
1989  bool gEq = (intGEq != 0);
1990 
1991  // get values
1992 
1993  // temporary storage of the parameters
1994  std::vector<L1GtEnergySumTemplate::ObjectParameter> objParameter(nrObj);
1995 
1996  // need at least two values for phi
1997  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1998 
1999  // get etThreshold values and fill into structure
2000  if ( !getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
2001  return false;
2002  }
2003 
2004  for (int i = 0; i < nrObj; i++) {
2005  objParameter[i].etThreshold = tmpValues[i];
2006 
2007  //LogTrace("L1GtTriggerMenuXmlParser")
2008  //<< " EnergySum ET high threshold (hex) for energySum object " << i << " = "
2009  //<< std::hex << objParameter[i].etThreshold << std::dec
2010  //<< std::endl;
2011 
2012  // for ETM and HTM read phi value
2013  // phi is larger than 64 bits for ETM - it needs two 64bits words
2014  // phi is less than 64 bits for HTM - it needs one 64bits word
2015  if (energySumObjType == ETM) {
2016 
2017  if (!getXMLHexTextValue128(
2018  findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0], tmpValues[1])) {
2019  edm::LogError("L1GtTriggerMenuXmlParser")
2020  << " Could not get phi for ETM condition (" << name << ")" << std::endl;
2021  return false;
2022  }
2023 
2024  objParameter[i].phiRange0Word = tmpValues[0];
2025  objParameter[i].phiRange1Word = tmpValues[1];
2026 
2027  } else if (energySumObjType == HTM) {
2028 
2029  if (!getXMLHexTextValue(findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0])) {
2030  edm::LogError("L1GtTriggerMenuXmlParser")
2031  << " Could not get phi for HTM condition (" << name << ")" << std::endl;
2032  return false;
2033  }
2034 
2035  objParameter[i].phiRange0Word = tmpValues[0];
2036 
2037  }
2038 
2039  // get energyOverflow logical flag and fill into structure
2040  DOMNode* n1;
2041  if ( (n1 = findXMLChild(node->getFirstChild(), m_xmlTagEtThreshold)) == 0) {
2042  edm::LogError("L1GtTriggerMenuXmlParser")
2043  << " Could not get energyOverflow for EnergySum condition (" << name << ")"
2044  << std::endl;
2045  return false;
2046  }
2047  if ( (n1 = findXMLChild(n1->getFirstChild(), m_xmlTagEnergyOverflow)) == 0) {
2048  edm::LogError("L1GtTriggerMenuXmlParser")
2049  << " Could not get energyOverflow for EnergySum condition (" << name << ")"
2050  << std::endl;
2051  return false;
2052  }
2053 
2054  int tmpInt = getBitFromNode(n1);
2055  if (tmpInt == 0) {
2056  objParameter[i].energyOverflow = false;
2057 
2058  //LogTrace("L1GtTriggerMenuXmlParser")
2059  //<< " EnergySum energyOverflow logical flag (hex) = "
2060  //<< std::hex << objParameter[i].energyOverflow << std::dec
2061  //<< std::endl;
2062  }
2063  else if (tmpInt == 1) {
2064  objParameter[i].energyOverflow = true;
2065 
2066  //LogTrace("L1GtTriggerMenuXmlParser")
2067  //<< " EnergySum energyOverflow logical flag (hex) = "
2068  //<< std::hex << objParameter[i].energyOverflow << std::dec
2069  //<< std::endl;
2070  }
2071  else {
2072  LogTrace("L1GtTriggerMenuXmlParser")
2073  << " EnergySum energyOverflow logical flag (hex) = " << std::hex << tmpInt
2074  << std::dec << " - wrong value! " << std::endl;
2075  return false;
2076  }
2077 
2078  }
2079 
2080  // object types - all same energySumObjType
2081  std::vector<L1GtObject> objType(nrObj, energySumObjType);
2082 
2083  // now create a new energySum condition
2084 
2085  L1GtEnergySumTemplate energySumCond(name);
2086 
2087  energySumCond.setCondType(cType);
2088  energySumCond.setObjectType(objType);
2089  energySumCond.setCondGEq(gEq);
2090  energySumCond.setCondChipNr(chipNr);
2091 
2092  energySumCond.setConditionParameter(objParameter);
2093 
2094  if (edm::isDebugEnabled() ) {
2095 
2096  std::ostringstream myCoutStream;
2097  energySumCond.print(myCoutStream);
2098  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2099 
2100  }
2101 
2102  // insert condition into the map
2103  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2104 
2105  edm::LogError("L1GtTriggerMenuXmlParser")
2106  << " Error: duplicate condition (" << name << ")"
2107  << std::endl;
2108 
2109  return false;
2110  }
2111  else {
2112 
2113  if (corrFlag) {
2114  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2115 
2116  }
2117  else {
2118  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
2119  }
2120 
2121  }
2122 
2123 
2124  //
2125  return true;
2126 }
2127 
2140 bool L1GtTriggerMenuXmlParser::parseJetCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
2141  const std::string& name, unsigned int chipNr) {
2142 
2143  XERCES_CPP_NAMESPACE_USE
2144 
2145  // get condition, particle name and type name
2149 
2150  if (particle != m_xmlConditionAttrObjectJetCounts) {
2151  edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for JetCounts condition ("
2152  << particle << ")" << std::endl;
2153  return false;
2154  }
2155 
2156  // object type and condition type
2157  L1GtObject jetCountsObjType = JetCounts;
2159 
2160  // global object
2161  int nrObj = 1;
2162 
2163  // get greater equal flag
2164 
2165  int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
2166  if (intGEq < 0) {
2167  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2168  << std::endl;
2169  return false;
2170  }
2171  // set the boolean value for the ge_eq mode
2172  bool gEq = (intGEq != 0);
2173 
2174  // get values
2175 
2176  // temporary storage of the parameters
2177  std::vector<L1GtJetCountsTemplate::ObjectParameter> objParameter(nrObj);
2178 
2179  // get countIndex value and fill into structure
2180  // they are expressed in base 10 (values: 0 - m_numberL1JetCounts)
2181  char* endPtr = nullptr;
2182  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2183 
2184  if (*endPtr != 0) {
2185 
2186  LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
2187  << std::endl;
2188 
2189  return false;
2190  }
2191 
2192  // test if count index is out of range
2193  if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1JetCounts))) {
2194  LogDebug("L1GtTriggerMenuXmlParser") << "Count index " << typeInt
2195  << " outside range [0, " << m_numberL1JetCounts << "]" << std::endl;
2196 
2197  return false;
2198  }
2199 
2200  objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
2201 
2202  // get count threshold values and fill into structure
2203  std::vector<boost::uint64_t> tmpValues(nrObj);
2204 
2205  if ( !getConditionChildValues(node, m_xmlTagCountThreshold, nrObj, tmpValues) ) {
2206  return false;
2207  }
2208 
2209  for (int i = 0; i < nrObj; i++) {
2210  objParameter[i].countThreshold = tmpValues[i];
2211 
2212  //LogTrace("L1GtTriggerMenuXmlParser")
2213  //<< " JetCounts count threshold (hex) for JetCounts object " << i << " = "
2214  //<< std::hex << objParameter[i].countThreshold << std::dec
2215  //<< std::endl;
2216 
2217  // TODO FIXME un-comment when tag available in XML file
2218 
2219  // // get countOverflow logical flag and fill into structure
2220  // DOMNode* n1;
2221  // if ( (n1 = findXMLChild(node->getFirstChild(), m_xmlTagCountThreshold)) == 0) {
2222  // edm::LogError("L1GtTriggerMenuXmlParser")
2223  // << " Could not get countOverflow for JetCounts condition ("
2224  // << name << ")"
2225  // << std::endl;
2226  // return false;
2227  // }
2228  // if ( (n1 = findXMLChild(n1->getFirstChild(), m_xmlTagCountThreshold)) == 0) {
2229  // edm::LogError("L1GtTriggerMenuXmlParser")
2230  // << " Could not get countOverflow for JetCounts condition ("
2231  // << name << ")"
2232  // << std::endl;
2233  // return false;
2234  // }
2235  //
2236  // int tmpInt = getBitFromNode(n1);
2237  // if (tmpInt == 0) {
2238  // objParameter[i].countOverflow = false;
2239  //
2240  // LogTrace("L1GtTriggerMenuXmlParser")
2241  // << " JetCounts countOverflow logical flag (hex) = "
2242  // << std::hex << objParameter[i].countOverflow << std::dec
2243  // << std::endl;
2244  // } else if (tmpInt == 1) {
2245  // objParameter[i].countOverflow = true;
2246  //
2247  // LogTrace("L1GtTriggerMenuXmlParser")
2248  // << " JetCounts countOverflow logical flag (hex) = "
2249  // << std::hex << objParameter[i].countOverflow << std::dec
2250  // << std::endl;
2251  // } else {
2252  // LogTrace("L1GtTriggerMenuXmlParser")
2253  // << " JetCounts countOverflow logical flag (hex) = "
2254  // << std::hex << tmpInt << std::dec << " - wrong value! "
2255  // << std::endl;
2256  // return false;
2257  // }
2258 
2259  }
2260 
2261  // object types - all same objType
2262  std::vector<L1GtObject> objType(nrObj, jetCountsObjType);
2263 
2264  // now create a new JetCounts condition
2265 
2266  L1GtJetCountsTemplate jetCountsCond(name);
2267 
2268  jetCountsCond.setCondType(cType);
2269  jetCountsCond.setObjectType(objType);
2270  jetCountsCond.setCondGEq(gEq);
2271  jetCountsCond.setCondChipNr(chipNr);
2272 
2273  jetCountsCond.setConditionParameter(objParameter);
2274 
2275  if (edm::isDebugEnabled() ) {
2276 
2277  std::ostringstream myCoutStream;
2278  jetCountsCond.print(myCoutStream);
2279  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2280 
2281  }
2282 
2283  // insert condition into the map
2284  if ( !insertConditionIntoMap(jetCountsCond, chipNr)) {
2285 
2286  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name
2287  << ")" << std::endl;
2288 
2289  return false;
2290  } else {
2291 
2292  (m_vecJetCountsTemplate[chipNr]).push_back(jetCountsCond);
2293 
2294  }
2295 
2296 
2297  //
2298  return true;
2299 }
2300 
2313 bool L1GtTriggerMenuXmlParser::parseCastor(XERCES_CPP_NAMESPACE::DOMNode* node,
2314  const std::string& name, unsigned int chipNr) {
2315 
2316  XERCES_CPP_NAMESPACE_USE
2317 
2318  // get condition, particle name and type name
2322 
2323  if (particle != m_xmlConditionAttrObjectCastor) {
2324  edm::LogError("L1GtTriggerMenuXmlParser")
2325  << "\nError: wrong particle for Castor condition ("
2326  << particle << ")" << std::endl;
2327  return false;
2328  }
2329 
2330  // object type and condition type
2331  // object type - irrelevant for CASTOR conditions
2332  L1GtConditionType cType = TypeCastor;
2333 
2334  // no objects for CASTOR conditions
2335 
2336  // set the boolean value for the ge_eq mode - irrelevant for CASTOR conditions
2337  bool gEq = false;
2338 
2339  // now create a new CASTOR condition
2340 
2341  L1GtCastorTemplate castorCond(name);
2342 
2343  castorCond.setCondType(cType);
2344  castorCond.setCondGEq(gEq);
2345  castorCond.setCondChipNr(chipNr);
2346 
2347 
2348  if (edm::isDebugEnabled() ) {
2349 
2350  std::ostringstream myCoutStream;
2351  castorCond.print(myCoutStream);
2352  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2353 
2354  }
2355 
2356  // insert condition into the map
2357  if ( !insertConditionIntoMap(castorCond, chipNr)) {
2358 
2359  edm::LogError("L1GtTriggerMenuXmlParser")
2360  << " Error: duplicate condition (" << name
2361  << ")" << std::endl;
2362 
2363  return false;
2364  } else {
2365 
2366  (m_vecCastorTemplate[chipNr]).push_back(castorCond);
2367 
2368  }
2369 
2370 
2371  //
2372  return true;
2373 }
2374 
2375 
2388 bool L1GtTriggerMenuXmlParser::parseHfBitCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
2389  const std::string& name, unsigned int chipNr) {
2390 
2391  XERCES_CPP_NAMESPACE_USE
2392 
2393  // get condition, particle name and type name
2397 
2398  if (particle != m_xmlConditionAttrObjectHfBitCounts) {
2399  edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for HfBitCounts condition ("
2400  << particle << ")" << std::endl;
2401  return false;
2402  }
2403 
2404  // object type and condition type
2405  L1GtObject hfBitCountsObjType = HfBitCounts;
2407 
2408  // global object
2409  int nrObj = 1;
2410 
2411  // get greater equal flag
2412 
2413  int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
2414  if (intGEq < 0) {
2415  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2416  << std::endl;
2417  return false;
2418  }
2419  // set the boolean value for the ge_eq mode
2420  bool gEq = (intGEq != 0);
2421 
2422  // get values
2423 
2424  // temporary storage of the parameters
2425  std::vector<L1GtHfBitCountsTemplate::ObjectParameter> objParameter(nrObj);
2426 
2427  // get countIndex value and fill into structure
2428  // they are expressed in base 10
2429  char* endPtr = nullptr;
2430  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2431 
2432  if (*endPtr != 0) {
2433 
2434  LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
2435  << std::endl;
2436 
2437  return false;
2438  }
2439 
2440  // test if count index is out of range FIXME introduce m_numberL1HfBitCounts?
2441  //if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1HfBitCounts))) {
2442  // LogDebug("L1GtTriggerMenuXmlParser") << "Count index " << typeInt
2443  // << " outside range [0, " << m_numberL1HfBitCounts << "]" << std::endl;
2444  //
2445  // return false;
2446  //}
2447 
2448  objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
2449 
2450  // get count threshold values and fill into structure
2451  std::vector<boost::uint64_t> tmpValues(nrObj);
2452 
2453  if ( !getConditionChildValues(node, m_xmlTagCountThreshold, nrObj, tmpValues) ) {
2454  return false;
2455  }
2456 
2457  for (int i = 0; i < nrObj; i++) {
2458  objParameter[i].countThreshold = tmpValues[i];
2459 
2460  //LogTrace("L1GtTriggerMenuXmlParser")
2461  //<< " HfBitCounts count threshold (hex) for HfBitCounts object " << i << " = "
2462  //<< std::hex << objParameter[i].countThreshold << std::dec
2463  //<< std::endl;
2464 
2465  }
2466 
2467  // object types - all same objType
2468  std::vector<L1GtObject> objType(nrObj, hfBitCountsObjType);
2469 
2470  // now create a new HfBitCounts condition
2471 
2472  L1GtHfBitCountsTemplate hfBitCountsCond(name);
2473 
2474  hfBitCountsCond.setCondType(cType);
2475  hfBitCountsCond.setObjectType(objType);
2476  hfBitCountsCond.setCondGEq(gEq);
2477  hfBitCountsCond.setCondChipNr(chipNr);
2478 
2479  hfBitCountsCond.setConditionParameter(objParameter);
2480 
2481  if (edm::isDebugEnabled() ) {
2482 
2483  std::ostringstream myCoutStream;
2484  hfBitCountsCond.print(myCoutStream);
2485  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2486 
2487  }
2488 
2489  // insert condition into the map
2490  if ( !insertConditionIntoMap(hfBitCountsCond, chipNr)) {
2491 
2492  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name
2493  << ")" << std::endl;
2494 
2495  return false;
2496  } else {
2497 
2498  (m_vecHfBitCountsTemplate[chipNr]).push_back(hfBitCountsCond);
2499 
2500  }
2501 
2502 
2503  //
2504  return true;
2505 }
2506 
2507 
2520 bool L1GtTriggerMenuXmlParser::parseHfRingEtSums(XERCES_CPP_NAMESPACE::DOMNode* node,
2521  const std::string& name, unsigned int chipNr) {
2522 
2523  XERCES_CPP_NAMESPACE_USE
2524 
2525  // get condition, particle name and type name
2529 
2530  if (particle != m_xmlConditionAttrObjectHfRingEtSums) {
2531  edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for HfRingEtSums condition ("
2532  << particle << ")" << std::endl;
2533  return false;
2534  }
2535 
2536  // object type and condition type
2537  L1GtObject hfRingEtSumsObjType = HfRingEtSums;
2539 
2540  // global object
2541  int nrObj = 1;
2542 
2543  // get greater equal flag
2544 
2545  int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
2546  if (intGEq < 0) {
2547  edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2548  << std::endl;
2549  return false;
2550  }
2551  // set the boolean value for the ge_eq mode
2552  bool gEq = (intGEq != 0);
2553 
2554  // get values
2555 
2556  // temporary storage of the parameters
2557  std::vector<L1GtHfRingEtSumsTemplate::ObjectParameter> objParameter(nrObj);
2558 
2559  // get etSumIndex value and fill into structure
2560  // they are expressed in base 10
2561  char* endPtr = nullptr;
2562  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2563 
2564  if (*endPtr != 0) {
2565 
2566  LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
2567  << std::endl;
2568 
2569  return false;
2570  }
2571 
2572  // test if ET sum index is out of range FIXME introduce m_numberL1HfRingEtSums?
2573  //if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1HfRingEtSums))) {
2574  // LogDebug("L1GtTriggerMenuXmlParser") << "Count index " << typeInt
2575  // << " outside range [0, " << m_numberL1HfRingEtSums << "]" << std::endl;
2576  //
2577  // return false;
2578  //}
2579 
2580  objParameter[0].etSumIndex = static_cast<unsigned int>(typeInt);
2581 
2582  // get ET sum threshold values and fill into structure
2583  std::vector<boost::uint64_t> tmpValues(nrObj);
2584 
2585  if ( !getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
2586  return false;
2587  }
2588 
2589  for (int i = 0; i < nrObj; i++) {
2590  objParameter[i].etSumThreshold = tmpValues[i];
2591 
2592  //LogTrace("L1GtTriggerMenuXmlParser")
2593  //<< " HfRingEtSums count threshold (hex) for HfRingEtSums object " << i << " = "
2594  //<< std::hex << objParameter[i].etSumThreshold << std::dec
2595  //<< std::endl;
2596 
2597  }
2598 
2599  // object types - all same objType
2600  std::vector<L1GtObject> objType(nrObj, hfRingEtSumsObjType);
2601 
2602  // now create a new HfRingEtSums condition
2603 
2604  L1GtHfRingEtSumsTemplate hfRingEtSumsCond(name);
2605 
2606  hfRingEtSumsCond.setCondType(cType);
2607  hfRingEtSumsCond.setObjectType(objType);
2608  hfRingEtSumsCond.setCondGEq(gEq);
2609  hfRingEtSumsCond.setCondChipNr(chipNr);
2610 
2611  hfRingEtSumsCond.setConditionParameter(objParameter);
2612 
2613  if (edm::isDebugEnabled() ) {
2614 
2615  std::ostringstream myCoutStream;
2616  hfRingEtSumsCond.print(myCoutStream);
2617  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2618 
2619  }
2620 
2621  // insert condition into the map
2622  if ( !insertConditionIntoMap(hfRingEtSumsCond, chipNr)) {
2623 
2624  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name
2625  << ")" << std::endl;
2626 
2627  return false;
2628  } else {
2629 
2630  (m_vecHfRingEtSumsTemplate[chipNr]).push_back(hfRingEtSumsCond);
2631 
2632  }
2633 
2634 
2635  //
2636  return true;
2637 }
2638 
2651 bool L1GtTriggerMenuXmlParser::parseBptx(XERCES_CPP_NAMESPACE::DOMNode* node,
2652  const std::string& name, unsigned int chipNr) {
2653 
2654  XERCES_CPP_NAMESPACE_USE
2655 
2656  // get condition, particle name and type name
2660 
2661  if (particle != m_xmlConditionAttrObjectBptx) {
2662  edm::LogError("L1GtTriggerMenuXmlParser")
2663  << "\nError: wrong particle for Bptx condition ("
2664  << particle << ")" << std::endl;
2665  return false;
2666  }
2667 
2668  // object type and condition type
2669  // object type - irrelevant for BPTX conditions
2670  L1GtConditionType cType = TypeBptx;
2671 
2672  // no objects for BPTX conditions
2673 
2674  // set the boolean value for the ge_eq mode - irrelevant for BPTX conditions
2675  bool gEq = false;
2676 
2677  // now create a new BPTX condition
2678 
2679  L1GtBptxTemplate bptxCond(name);
2680 
2681  bptxCond.setCondType(cType);
2682  bptxCond.setCondGEq(gEq);
2683  bptxCond.setCondChipNr(chipNr);
2684 
2685  LogTrace("L1GtTriggerMenuXmlParser") << bptxCond << "\n" << std::endl;
2686 
2687  // insert condition into the map
2688  if ( !insertConditionIntoMap(bptxCond, chipNr)) {
2689 
2690  edm::LogError("L1GtTriggerMenuXmlParser")
2691  << " Error: duplicate condition (" << name
2692  << ")" << std::endl;
2693 
2694  return false;
2695  } else {
2696 
2697  (m_vecBptxTemplate[chipNr]).push_back(bptxCond);
2698 
2699  }
2700 
2701 
2702  //
2703  return true;
2704 }
2705 
2706 
2719 bool L1GtTriggerMenuXmlParser::parseExternal(XERCES_CPP_NAMESPACE::DOMNode* node,
2720  const std::string& name, unsigned int chipNr) {
2721 
2722  XERCES_CPP_NAMESPACE_USE
2723 
2724  // get condition, particle name and type name
2728 
2729  if (particle != m_xmlConditionAttrObjectGtExternal) {
2730  edm::LogError("L1GtTriggerMenuXmlParser")
2731  << "\nError: wrong particle for External condition ("
2732  << particle << ")" << std::endl;
2733  return false;
2734  }
2735 
2736  // object type and condition type
2737  // object type - irrelevant for External conditions
2739 
2740  // no objects for External conditions
2741 
2742  // set the boolean value for the ge_eq mode - irrelevant for External conditions
2743  bool gEq = false;
2744 
2745  // now create a new External condition
2746 
2747  L1GtExternalTemplate externalCond(name);
2748 
2749  externalCond.setCondType(cType);
2750  externalCond.setCondGEq(gEq);
2751  externalCond.setCondChipNr(chipNr);
2752 
2753  LogTrace("L1GtTriggerMenuXmlParser") << externalCond << "\n" << std::endl;
2754 
2755  // insert condition into the map
2756  if ( !insertConditionIntoMap(externalCond, chipNr)) {
2757 
2758  edm::LogError("L1GtTriggerMenuXmlParser")
2759  << " Error: duplicate condition (" << name
2760  << ")" << std::endl;
2761 
2762  return false;
2763  } else {
2764 
2765  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2766 
2767  }
2768 
2769 
2770  //
2771  return true;
2772 }
2773 
2774 
2788  XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& name,
2789  unsigned int chipNr) {
2790 
2791  XERCES_CPP_NAMESPACE_USE
2792 
2793  // create a new correlation condition
2794  L1GtCorrelationTemplate correlationCond(name);
2795 
2796  // check that the condition does not exist already in the map
2797  if ( !insertConditionIntoMap(correlationCond, chipNr)) {
2798 
2799  edm::LogError("L1GtTriggerMenuXmlParser")
2800  << " Error: duplicate correlation condition (" << name << ")"
2801  << std::endl;
2802 
2803  return false;
2804  }
2805 
2806  // get condition, particle name and type name
2810 
2811  LogTrace("L1GtTriggerMenuXmlParser") << " Condition category: "
2812  << condition << ", particle: " << particle << ", type: " << type
2813  << "\n" << std::endl;
2814 
2815  // condition type
2816  L1GtConditionType cType = Type2cor;
2817 
2818  // two objects (for sure)
2819  const int nrObj = 2;
2820 
2821  // object types and greater equal flag - filled in the loop
2822  int intGEq[nrObj] = { -1, -1 };
2823  std::vector<L1GtObject> objType(nrObj);
2824  std::vector<L1GtConditionCategory> condCateg(nrObj);
2825 
2826  // correlation flag and index in the cor*vector
2827  const bool corrFlag = true;
2828  int corrIndexVal[nrObj] = { -1, -1 };
2829 
2830  // get the subconditions
2831 
2832  DOMNode* conditionsNode = node->getFirstChild();
2833  std::string conditionNameNodeName;
2834  conditionsNode = findXMLChild(conditionsNode, "", true,
2835  &conditionNameNodeName);
2836 
2837 
2838  for (int iSubCond = 0; iSubCond < nrObj; ++iSubCond) {
2839 
2840  // get for sub-condition: category, object name and type name and condition name
2841  condition = getXMLAttribute(conditionsNode, m_xmlConditionAttrCondition);
2842  particle = getXMLAttribute(conditionsNode, m_xmlConditionAttrObject);
2843  type = getXMLAttribute(conditionsNode, m_xmlConditionAttrType);
2844 
2845  LogTrace("L1GtTriggerMenuXmlParser") << " Sub-condition category: "
2846  << condition << ", particle: " << particle << ", type: "
2847  << type << ", name: " << conditionNameNodeName << "\n"
2848  << std::endl;
2849 
2850  // call the appropriate function for this condition
2851  if (condition == m_xmlConditionAttrConditionMuon) {
2852  if (!parseMuon(conditionsNode, conditionNameNodeName, chipNr,
2853  corrFlag)) {
2854  edm::LogError("L1GtTriggerMenuXmlParser")
2855  << "Error parsing sub-condition " << condition << ")"
2856  << " with name " << conditionNameNodeName << std::endl;
2857 
2858  }
2859 
2860  // get greater equal flag
2861  intGEq[iSubCond] = getGEqFlag(conditionsNode,
2863  if (intGEq[iSubCond] < 0) {
2864  edm::LogError("L1GtTriggerMenuXmlParser")
2865  << "Error getting \"greater or equal\" flag"
2866  << " for sub-condition " << conditionNameNodeName
2867  << " for the correlation condition " << name
2868  << std::endl;
2869  return false;
2870  }
2871 
2872  // set object type and sub-condition category
2873  objType[iSubCond] = Mu;
2874  condCateg[iSubCond] = CondMuon;
2875  corrIndexVal[iSubCond] = (m_corMuonTemplate[chipNr]).size() - 1;
2876 
2877  }
2878  else if (condition == m_xmlConditionAttrConditionCalo) {
2879  if (!parseCalo(conditionsNode, conditionNameNodeName, chipNr,
2880  corrFlag)) {
2881  edm::LogError("L1GtTriggerMenuXmlParser")
2882  << "Error parsing sub-condition " << condition << ")"
2883  << " with name " << conditionNameNodeName << std::endl;
2884 
2885  }
2886 
2887  // get greater equal flag
2888  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
2889  if (intGEq[iSubCond] < 0) {
2890  edm::LogError("L1GtTriggerMenuXmlParser")
2891  << "Error getting \"greater or equal\" flag"
2892  << " for sub-condition " << conditionNameNodeName
2893  << " for the correlation condition " << name
2894  << std::endl;
2895  return false;
2896  }
2897 
2898  // set object type and sub-condition category
2899  if (particle == m_xmlConditionAttrObjectNoIsoEG) {
2900  objType[iSubCond] = NoIsoEG;
2901  }
2902  else if (particle == m_xmlConditionAttrObjectIsoEG) {
2903  objType[iSubCond] = IsoEG;
2904  }
2905  else if (particle == m_xmlConditionAttrObjectCenJet) {
2906  objType[iSubCond] = CenJet;
2907  }
2908  else if (particle == m_xmlConditionAttrObjectTauJet) {
2909  objType[iSubCond] = TauJet;
2910  }
2911  else if (particle == m_xmlConditionAttrObjectForJet) {
2912  objType[iSubCond] = ForJet;
2913  }
2914  else {
2915  edm::LogError("L1GtTriggerMenuXmlParser")
2916  << "Wrong object type " << particle
2917  << " for sub-condition " << conditionNameNodeName
2918  << " from the correlation condition " << name
2919  << std::endl;
2920  return false;
2921  }
2922 
2923  condCateg[iSubCond] = CondCalo;
2924  corrIndexVal[iSubCond] = (m_corCaloTemplate[chipNr]).size() - 1;
2925 
2926  }
2927  else if (condition == m_xmlConditionAttrConditionEnergySum) {
2928  if (!parseEnergySum(conditionsNode, conditionNameNodeName, chipNr,
2929  corrFlag)) {
2930  edm::LogError("L1GtTriggerMenuXmlParser")
2931  << "Error parsing sub-condition " << condition << ")"
2932  << " with name " << conditionNameNodeName << std::endl;
2933 
2934  }
2935 
2936  // get greater equal flag
2937  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
2938  if (intGEq[iSubCond] < 0) {
2939  edm::LogError("L1GtTriggerMenuXmlParser")
2940  << "Error getting \"greater or equal\" flag"
2941  << " for sub-condition " << conditionNameNodeName
2942  << " for the correlation condition " << name
2943  << std::endl;
2944  return false;
2945  }
2946 
2947  // set object type and sub-condition category
2948  if (particle == m_xmlConditionAttrObjectETM) {
2949  objType[iSubCond] = ETM;
2950  }
2951  else if (particle == m_xmlConditionAttrObjectETT) {
2952  objType[iSubCond] = ETT;
2953  }
2954  else if (particle == m_xmlConditionAttrObjectHTT) {
2955  objType[iSubCond] = HTT;
2956  }
2957  else if (particle == m_xmlConditionAttrObjectHTM) {
2958  objType[iSubCond] = HTM;
2959  }
2960  else {
2961  edm::LogError("L1GtTriggerMenuXmlParser")
2962  << "Wrong object type " << particle
2963  << " for sub-condition " << conditionNameNodeName
2964  << " from the correlation condition " << name
2965  << std::endl;
2966  return false;
2967  }
2968 
2969  condCateg[iSubCond] = CondEnergySum;
2970  corrIndexVal[iSubCond] = (m_corEnergySumTemplate[chipNr]).size() - 1;
2971 
2972  }
2973  else {
2974  edm::LogError("L1GtTriggerMenuXmlParser")
2975  << "Unknown or un-adequate sub-condition (" << condition
2976  << ")" << " with name " << conditionNameNodeName
2977  << " for the correlation condition " << name << std::endl;
2978 
2979  return false;
2980  }
2981 
2982  conditionsNode = findXMLChild(conditionsNode->getNextSibling(), "",
2983  true, &conditionNameNodeName);
2984 
2985  }
2986 
2987  // get greater equal flag for the correlation condition
2988  bool gEq = true;
2989  if (intGEq[0] != intGEq[1]) {
2990  edm::LogError("L1GtTriggerMenuXmlParser")
2991  << "Inconsistent GEq flags for sub-conditions (" << condition
2992  << ")" << " with name " << conditionNameNodeName
2993  << " for the correlation condition " << name << std::endl;
2994  return false;
2995 
2996  }
2997  else {
2998  gEq = (intGEq[0] != 0);
2999 
3000  }
3001 
3002  // correlation parameters
3003 
3004  // temporary storage of the parameters
3006  std::vector<boost::uint64_t> tmpValues(nrObj);
3007 
3008  // get deltaEtaRange
3009 // if ( !getConditionChildValues(node, m_xmlTagDeltaEta, 1, tmpValues) ) {
3010 // return false;
3011 // }
3012 //
3013 // corrParameter.deltaEtaRange = tmpValues[0];
3014 
3015  XERCES_CPP_NAMESPACE::DOMNode* node1 = findXMLChild(node->getFirstChild(),
3017 
3018  std::string valString;
3019 
3020  if (node1 == 0) {
3021  edm::LogError("L1GtTriggerMenuXmlParser")
3022  << " Could not get deltaEta for correlation condition "
3023  << name << ". " << std::endl;
3024  return false;
3025  }
3026  else {
3027  valString = getXMLTextValue(node1);
3028  }
3029 
3030  corrParameter.deltaEtaRange = valString;
3031 
3032 // // deltaPhi is larger than 64bit
3033 // if ( !getXMLHexTextValue128(findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi),
3034 // tmpValues[0], tmpValues[1])) {
3035 // edm::LogError("L1GtTriggerMenuXmlParser")
3036 // << " Could not get deltaPhi for correlation condition " << name << ". "
3037 // << std::endl;
3038 // return false;
3039 // }
3040 //
3041 // corrParameter.deltaPhiRange = tmpValues[0];
3042 
3043  node1 = findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi);
3044 
3045  if (node1 == 0) {
3046  return false;
3047  edm::LogError("L1GtTriggerMenuXmlParser")
3048  << " Could not get deltaPhi for correlation condition "
3049  << name << ". " << std::endl;
3050  }
3051  else {
3052  valString = getXMLTextValue(node1);
3053  }
3054 
3055  corrParameter.deltaPhiRange = valString;
3056 
3057  // get maximum number of bits for delta phi
3058  //LogTrace("L1GtTriggerMenuXmlParser")
3059  //<< " Counting deltaPhiMaxbits"
3060  //<< std::endl;
3061 
3062  unsigned int maxbits;
3063 
3064  if ( !countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits) ) {
3065  return false;
3066  }
3067 
3068  corrParameter.deltaPhiMaxbits = maxbits;
3069  //LogTrace("L1GtTriggerMenuXmlParser")
3070  //<< " deltaPhiMaxbits (dec) = " << maxbits
3071  //<< std::endl;
3072 
3073 
3074  // fill the correlation condition
3075  correlationCond.setCondType(cType);
3076  correlationCond.setObjectType(objType);
3077  correlationCond.setCondGEq(gEq);
3078  correlationCond.setCondChipNr(chipNr);
3079 
3080  correlationCond.setCond0Category(condCateg[0]);
3081  correlationCond.setCond1Category(condCateg[1]);
3082 
3083  correlationCond.setCond0Index(corrIndexVal[0]);
3084  correlationCond.setCond1Index(corrIndexVal[1]);
3085 
3086  correlationCond.setCorrelationParameter(corrParameter);
3087 
3088  if (edm::isDebugEnabled() ) {
3089 
3090  std::ostringstream myCoutStream;
3091  correlationCond.print(myCoutStream);
3092  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n"
3093  << std::endl;
3094 
3095  }
3096 
3097  // insert condition into the map
3098  // condition is not duplicate, check was done at the beginning
3099 
3100  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
3101 
3102  //
3103  return true;
3104 }
3105 
3114 bool L1GtTriggerMenuXmlParser::parseId(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3115 
3116  XERCES_CPP_NAMESPACE_USE
3117 
3118  DOMNode* doc = parser->getDocument();
3119  DOMNode* n1 = doc->getFirstChild();
3120 
3121  // we assume that the first child is m_xmlTagDef because it was checked in workXML
3122 
3123  DOMNode* headerNode = n1->getFirstChild();
3124  if (headerNode == 0) {
3125  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef
3126  << "> tag found." << std::endl;
3127  return false;
3128  }
3129 
3130  headerNode = findXMLChild(headerNode, m_xmlTagHeader);
3131  if (headerNode == 0) {
3132 
3133  LogDebug("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagHeader
3134  << "> tag" << "\n - No header information." << std::endl;
3135 
3136  } else {
3137 
3138  DOMNode* idNode = headerNode->getFirstChild();
3139 
3140  // find menu interface name
3141  idNode = findXMLChild(idNode, m_xmlTagMenuInterface);
3142  if (idNode == 0) {
3143 
3144  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
3145  << m_xmlTagMenuInterface << "> tag"
3146  << "\n - Trigger menu interface name derived from file name." << std::endl;
3147 
3148  // set the name of the trigger menu interface: from beginning of file names
3149  // until beginning of "_L1T_Scales"
3150  size_t xmlPos = m_triggerMenuName.find("_L1T_Scales", 0);
3151  if (xmlPos == std::string::npos) {
3152  LogTrace("L1GtTriggerMenuXmlParser")
3153  << "\n Warning: Could not find \"_L1T_Scales\" " << "string in file name"
3154  << "\n - Trigger menu interface name set to file name." << std::endl;
3156 
3157  } else {
3159  m_triggerMenuInterface.erase(
3160  m_triggerMenuInterface.begin(), m_triggerMenuInterface.begin() + xmlPos);
3161  }
3162 
3163  } else {
3165  }
3166 
3167  // find menu interface creation date
3168  idNode = headerNode->getFirstChild();
3169  idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDate);
3170 
3171  if (idNode == 0) {
3172 
3173  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
3174  << m_xmlTagMenuInterfaceDate << "> tag" << "\n - No creation date."
3175  << m_triggerMenuInterfaceDate << std::endl;
3176 
3177  } else {
3178 
3180  }
3181 
3182  // find menu interface creation author
3183  idNode = headerNode->getFirstChild();
3184  idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceAuthor);
3185 
3186  if (idNode == 0) {
3187 
3188  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
3189  << m_xmlTagMenuInterfaceAuthor << "> tag" << "\n - No creation author."
3190  << m_triggerMenuInterfaceAuthor << std::endl;
3191 
3192  } else {
3193 
3195  }
3196 
3197  // find menu interface description
3198  idNode = headerNode->getFirstChild();
3200 
3201  if (idNode == 0) {
3202 
3203  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
3204  << m_xmlTagMenuInterfaceDescription << "> tag" << "\n - No description."
3205  << m_triggerMenuInterfaceDescription << std::endl;
3206 
3207  } else {
3208 
3210  }
3211 
3212  // find menu creation date
3213  idNode = headerNode->getFirstChild();
3214  idNode = findXMLChild(idNode, m_xmlTagMenuDate);
3215 
3216  if (idNode == 0) {
3217 
3218  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
3219  << m_xmlTagMenuDate << "> tag" << "\n - No creation date."
3220  << m_triggerMenuDate << std::endl;
3221 
3222  } else {
3223 
3225  }
3226 
3227  // find menu creation author
3228  idNode = headerNode->getFirstChild();
3229  idNode = findXMLChild(idNode, m_xmlTagMenuAuthor);
3230 
3231  if (idNode == 0) {
3232 
3233  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
3234  << m_xmlTagMenuAuthor << "> tag" << "\n - No creation author."
3235  << m_triggerMenuAuthor << std::endl;
3236 
3237  } else {
3238 
3240  }
3241 
3242  // find menu description
3243  idNode = headerNode->getFirstChild();
3244  idNode = findXMLChild(idNode, m_xmlTagMenuDescription);
3245 
3246  if (idNode == 0) {
3247 
3248  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
3249  << m_xmlTagMenuDescription << "> tag" << "\n - No description."
3250  << m_triggerMenuDescription << std::endl;
3251 
3252  } else {
3253 
3255  }
3256 
3257  // find algorithm implementation tag
3258 
3259  idNode = headerNode->getFirstChild();
3260 
3261  idNode = findXMLChild(idNode, m_xmlTagMenuAlgImpl);
3262  if (idNode == 0) {
3263 
3265  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
3266  << m_xmlTagMenuAlgImpl << "> tag"
3267  << "\n - Algorithm implementation tag set to empty string." << std::endl;
3268 
3269  } else {
3270 
3272  }
3273 
3274  // find DB key for L1 scales
3275 
3276  idNode = headerNode->getFirstChild();
3277 
3278  idNode = findXMLChild(idNode, m_xmlTagScaleDbKey);
3279  if (idNode == 0) {
3280 
3281  m_scaleDbKey = "NULL";
3282  LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
3283  << m_xmlTagScaleDbKey << "> tag" << "\n - Scale key set to " << m_scaleDbKey
3284  << " string." << std::endl;
3285 
3286  } else {
3287  m_scaleDbKey = getXMLTextValue(idNode);
3288  }
3289 
3290  }
3291 
3292  LogDebug("L1GtTriggerMenuXmlParser")
3293  << "\n Parsed values from XML file"
3294  << "\nL1 MenuInterface: " << m_triggerMenuInterface
3295  << "\nL1 MenuInterface - Creation date: " << m_triggerMenuInterfaceDate
3296  << "\nL1 MenuInterface - Creation author: " << m_triggerMenuInterfaceAuthor
3297  << "\nL1 MenuInterface - Description: " << m_triggerMenuInterfaceDescription
3298  << "\n"
3299  << "\nAlgorithm implementation tag: " << m_algorithmImplementation
3300  << "\n"
3301  << "\nL1 Menu - Creation date: " << m_triggerMenuDate
3302  << "\nL1 Menu - Creation author: " << m_triggerMenuAuthor
3303  << "\nL1 Menu - Description: " << m_triggerMenuDescription
3304  << std::endl;
3305 
3306 
3307  // set the trigger menu name
3308  // format:
3309  // L1MenuInterface/ScaleDbKey/AlgorithmImplementationTag
3310 
3312 
3313  if (menuName != m_triggerMenuName) {
3314 
3315  LogDebug("L1GtTriggerMenuXmlParser") << "\n Warning: Inconsistent L1 menu name:"
3316  << "\n from XML file name: " << m_triggerMenuName
3317  << "\n from XML tag: " << menuName << std::endl;
3318 
3319  if (m_triggerMenuInterface != "") {
3320  if (m_scaleDbKey == "NULL") {
3322  } else {
3323  m_triggerMenuName = menuName;
3324  }
3325 
3326  LogTrace("L1GtTriggerMenuXmlParser") << "\n L1 menu name set to value from XML tag!"
3327  << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
3328 
3329  } else {
3330  LogTrace("L1GtTriggerMenuXmlParser") << "\n L1 menu name set to file name!"
3331  << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
3332 
3333  }
3334  }
3335 
3336  //
3337  return true;
3338 }
3339 
3351 bool L1GtTriggerMenuXmlParser::workCondition(XERCES_CPP_NAMESPACE::DOMNode* node,
3352  const std::string& name, unsigned int chipNr) {
3353 
3354  XERCES_CPP_NAMESPACE_USE
3355 
3356  // get condition, particle name and type name
3360 
3361  if (condition.empty() || particle.empty() || type.empty() ) {
3362 
3363  edm::LogError("L1GtTriggerMenuXmlParser") << "Missing attributes for condition " << name
3364  << std::endl;
3365 
3366  return false;
3367  }
3368 
3369  //LogTrace("L1GtTriggerMenuXmlParser")
3370  //<< " condition: " << condition << ", particle: " << particle
3371  //<< ", type: " << type << std::endl;
3372 
3373  // call the appropiate function for this condition
3374 
3375  if (condition == m_xmlConditionAttrConditionMuon) {
3376  return parseMuon(node, name, chipNr);
3377  }
3378  else if (condition == m_xmlConditionAttrConditionCalo) {
3379  return parseCalo(node, name, chipNr);
3380  }
3381  else if (condition == m_xmlConditionAttrConditionEnergySum) {
3382  return parseEnergySum(node, name, chipNr);
3383  }
3384  else if (condition == m_xmlConditionAttrConditionJetCounts) {
3385  return parseJetCounts(node, name, chipNr);
3386  }
3387  else if (condition == m_xmlConditionAttrConditionCastor) {
3388  return parseCastor(node, name, chipNr);
3389  }
3390  else if (condition == m_xmlConditionAttrConditionHfBitCounts) {
3391  return parseHfBitCounts(node, name, chipNr);
3392  }
3393  else if (condition == m_xmlConditionAttrConditionHfRingEtSums) {
3394  return parseHfRingEtSums(node, name, chipNr);
3395  }
3396  else if (condition == m_xmlConditionAttrConditionBptx) {
3397  return parseBptx(node, name, chipNr);
3398  }
3399  else if (condition == m_xmlConditionAttrConditionExternal) {
3400  return parseExternal(node, name, chipNr);
3401  }
3402  else if (condition == m_xmlConditionAttrConditionCorrelation) {
3403  return parseCorrelation(node, name, chipNr);
3404  }
3405  else {
3406  edm::LogError("L1GtTriggerMenuXmlParser")
3407  << "\n Error: unknown condition (" << condition << ")"
3408  << std::endl;
3409 
3410  return false;
3411  }
3412 
3413  return true;
3414 
3415 }
3416 
3427 bool L1GtTriggerMenuXmlParser::parseConditions(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3428 
3429  XERCES_CPP_NAMESPACE_USE
3430 
3431  LogTrace("L1GtTriggerMenuXmlParser") << "\nParsing conditions" << std::endl;
3432 
3433  DOMNode* doc = parser->getDocument();
3434  DOMNode* n1 = doc->getFirstChild();
3435 
3436  // we assume that the first child is m_xmlTagDef because it was checked in workXML
3437 
3438  DOMNode* chipNode = n1->getFirstChild();
3439  if (chipNode == 0) {
3440 
3441  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef
3442  << "> tag found." << std::endl;
3443 
3444  return false;
3445  }
3446 
3447  // find chip
3448 
3449  std::string chipName; // name of the actual chip
3450  chipNode = findXMLChild(chipNode, m_xmlTagChip, true, &chipName);
3451  if (chipNode == 0) {
3452 
3453  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: Could not find <" << m_xmlTagChip
3454  << "> tag" << std::endl;
3455 
3456  return false;
3457  }
3458 
3459  unsigned int chipNr = 0;
3460  do {
3461 
3462  // find conditions
3463  DOMNode* conditionsNode = chipNode->getFirstChild();
3464  conditionsNode = findXMLChild(conditionsNode, m_xmlTagConditions);
3465  if (conditionsNode == 0) {
3466 
3467  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No <" << m_xmlTagConditions
3468  << "> child found in Chip " << chipName << std::endl;
3469 
3470  return false;
3471  }
3472 
3473  char* nodeName = XMLString::transcode(chipNode->getNodeName());
3474  //LogTrace("L1GtTriggerMenuXmlParser")
3475  //<< "\n Found Chip: " << nodeName << " Name: " << chipName
3476  //<< std::endl;
3477 
3478  XMLString::release(&nodeName);
3479 
3480  // walk through conditions
3481  DOMNode* conditionNameNode = conditionsNode->getFirstChild();
3482  std::string conditionNameNodeName;
3483  conditionNameNode = findXMLChild(conditionNameNode, "", true, &conditionNameNodeName);
3484  while (conditionNameNode != 0) {
3485 
3486  LogTrace("L1GtTriggerMenuXmlParser")
3487  << "\n Found a condition with name: " << conditionNameNodeName
3488  << std::endl;
3489 
3490  if ( !workCondition(conditionNameNode, conditionNameNodeName, chipNr) ) {
3491  return false;
3492  }
3493  conditionNameNode = findXMLChild(conditionNameNode->getNextSibling(), "", true,
3494  &conditionNameNodeName);
3495 
3496  }
3497  // next chip
3498  chipNode = findXMLChild(chipNode->getNextSibling(), m_xmlTagChip, true, &chipName);
3499  chipNr++;
3500 
3501  } while (chipNode != 0 && chipNr < m_numberConditionChips);
3502 
3503  return true;
3504 }
3505 
3517 bool L1GtTriggerMenuXmlParser::workAlgorithm(XERCES_CPP_NAMESPACE::DOMNode* node,
3518  const std::string& algName, unsigned int chipNr) {
3519 
3520  XERCES_CPP_NAMESPACE_USE
3521 
3522  if (node == 0) {
3523  LogDebug("L1GtTriggerMenuXmlParser")
3524  << " Node is 0 in " << __PRETTY_FUNCTION__
3525  << " can not parse the algorithm " << algName
3526  << std::endl;
3527  return false;
3528  }
3529 
3530  // get alias
3532 
3533  if (algAlias == "") {
3534  algAlias = algName;
3535  LogDebug("L1GtTriggerMenuXmlParser")
3536  << "\n No alias defined for algorithm. Alias set to algorithm name."
3537  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3538  << std::endl;
3539  } else {
3540  LogDebug("L1GtTriggerMenuXmlParser") << "\n Alias defined for algorithm."
3541  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3542  << std::endl;
3543  }
3544 
3545  // get the logical expression from the node
3546  std::string logExpression = getXMLTextValue(node);
3547 
3548  //LogTrace("L1GtTriggerMenuXmlParser")
3549  //<< " Logical expression: " << logExpression
3550  //<< std::endl;
3551 
3552  //LogTrace("L1GtTriggerMenuXmlParser")
3553  //<< " Chip number: " << chipNr
3554  //<< std::endl;
3555 
3556  // determine output pin
3557  DOMNode* pinNode = findXMLChild(node->getFirstChild(), m_xmlTagOutput);
3558  std::string pinString;
3559  int outputPin = 0;
3560 
3561  pinNode = node->getFirstChild();
3562  if ( (pinNode = findXMLChild(pinNode, m_xmlTagOutputPin) ) != 0) {
3563  pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
3564 
3565  // convert pinString to integer
3566  std::istringstream opStream(pinString);
3567 
3568  if ((opStream >> outputPin).fail()) {
3569  LogDebug("L1GtTriggerMenuXmlParser")
3570  << " Unable to convert pin string " << pinString
3571  << " to int for algorithm : " << algName
3572  << std::endl;
3573 
3574  return false;
3575  }
3576 
3577  }
3578 
3579  if (pinNode == 0) {
3580  LogTrace("L1GtTriggerMenuXmlParser") << " Warning: No pin number found for algorithm: "
3581  << algName << std::endl;
3582 
3583  return false;
3584  }
3585 
3586  //LogTrace("L1GtTriggerMenuXmlParser")
3587  //<< " Output pin: " << outputPin
3588  //<< std::endl;
3589 
3590 
3591  // compute the bit number from chip number, output pin and order of the chips
3592  // pin numbering start with 1, bit numbers with 0
3593  int bitNumber = outputPin + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
3594 
3595  //LogTrace("L1GtTriggerMenuXmlParser")
3596  //<< " Bit number: " << bitNumber
3597  //<< std::endl;
3598 
3599  // create a new algorithm and insert it into algorithm map
3600  L1GtAlgorithm alg(algName, logExpression, bitNumber);
3601  alg.setAlgoChipNumber(static_cast<int>(chipNr));
3602  alg.setAlgoAlias(algAlias);
3603 
3604  if (edm::isDebugEnabled() ) {
3605 
3606  std::ostringstream myCoutStream;
3607  alg.print(myCoutStream);
3608  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3609 
3610  }
3611 
3612  // insert algorithm into the map
3613  if ( !insertAlgorithmIntoMap(alg)) {
3614 
3615  return false;
3616  }
3617 
3618  return true;
3619 
3620 }
3621 
3622 /*
3623  * parseAlgorithms Parse the algorithms
3624  * NOTE: the algorithms used here are equivalent to "prealgo" from XML file
3625  * for the VERSION_FINAL
3626  * The "VERSION_PROTOTYPE algo" will be phased out later in the XML file
3627  * See L1GlobalTriggerConfig.h (in the attic)
3628  *
3629  * @param parser A reference to the XercesDOMParser to use.
3630  *
3631  * @return "true" if succeeded, "false" if an error occurred.
3632  *
3633  */
3634 
3635 bool L1GtTriggerMenuXmlParser::parseAlgorithms(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3636 
3637  XERCES_CPP_NAMESPACE_USE
3638 
3639  //LogTrace("L1GtTriggerMenuXmlParser") << "\nParsing algorithms" << std::endl;
3640 
3641  DOMNode* doc = parser->getDocument();
3642  DOMNode* node = doc->getFirstChild();
3643 
3644  DOMNode* chipNode = node->getFirstChild();
3645  if (chipNode == 0) {
3646  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: No child found for " << m_xmlTagDef
3647  << std::endl;
3648  return false;
3649  }
3650 
3651  // find first chip
3652  std::string chipName;
3653  chipNode = findXMLChild(chipNode, m_xmlTagChip, true, &chipName);
3654  if (chipNode == 0) {
3655  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: Could not find <" << m_xmlTagChip
3656  << std::endl;
3657  return false;
3658  }
3659 
3660  unsigned int chipNr = 0;
3661  do {
3662 
3663  //LogTrace("L1GtTriggerMenuXmlParser") << std::endl;
3664 
3665  std::string nodeName = m_xmlTagChip + chipName;
3666  //LogTrace("L1GtTriggerMenuXmlParser")
3667  //<< " Chip: " << nodeName << " Name: " << chipName
3668  //<< std::endl;
3669 
3670  // find algorithms
3671  DOMNode* algNode = chipNode->getFirstChild();
3672  algNode = findXMLChild(algNode, m_xmlTagAlgorithms);
3673  if (algNode == 0) {
3674  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: No <" << m_xmlTagAlgorithms
3675  << "> child found in chip " << chipName << std::endl;
3676  return false;
3677  }
3678 
3679  // walk through algorithms
3680  DOMNode* algNameNode = algNode->getFirstChild();
3681  std::string algNameNodeName;
3682  algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
3683 
3684  while (algNameNode != 0) {
3685  //LogTrace("L1GtTriggerMenuXmlParser")
3686  //<< " Found an algorithm with name: " << algNameNodeName
3687  //<< std::endl;
3688 
3689  if ( !workAlgorithm(algNameNode, algNameNodeName, chipNr)) {
3690  return false;
3691  }
3692 
3693  algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true, &algNameNodeName);
3694 
3695  }
3696 
3697  // next chip
3698  chipNode = findXMLChild(chipNode->getNextSibling(), m_xmlTagChip, true, &chipName);
3699  chipNr++;
3700 
3701  } while (chipNode != 0 && chipNr < m_numberConditionChips);
3702 
3703  return true;
3704 }
3705 
3716 bool L1GtTriggerMenuXmlParser::workTechTrigger(XERCES_CPP_NAMESPACE::DOMNode* node,
3717  const std::string& algName) {
3718 
3719  XERCES_CPP_NAMESPACE_USE
3720 
3721  if (node == 0) {
3722  LogDebug("L1GtTriggerMenuXmlParser")
3723  << " Node is 0 in " << __PRETTY_FUNCTION__
3724  << " can not parse the technical trigger " << algName
3725  << std::endl;
3726  return false;
3727  }
3728 
3729  // get the logical expression from the node
3730  std::string logExpression = getXMLTextValue(node);
3731 
3732  //LogTrace("L1GtTriggerMenuXmlParser")
3733  //<< " Logical expression: " << logExpression
3734  //<< std::endl;
3735 
3736  // determine bit number (use output pin tag)
3737  DOMNode* pinNode = findXMLChild(node->getFirstChild(), m_xmlTagOutput);
3738  std::string pinString;
3739  int outputPin = 0;
3740 
3741  pinNode = node->getFirstChild();
3742  if ( (pinNode = findXMLChild(pinNode, m_xmlTagOutputPin) ) != 0) {
3743  pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
3744 
3745  // convert pinString to integer
3746  std::istringstream opStream(pinString);
3747 
3748  if ((opStream >> outputPin).fail()) {
3749  LogDebug("L1GtTriggerMenuXmlParser")
3750  << " Unable to convert pin string " << pinString
3751  << " to int for technical trigger : " << algName
3752  << std::endl;
3753 
3754  return false;
3755  }
3756 
3757  }
3758 
3759  if (pinNode == 0) {
3760  LogTrace("L1GtTriggerMenuXmlParser")
3761  << " Warning: No pin number found for technical trigger: "
3762  << algName << std::endl;
3763 
3764  return false;
3765  }
3766 
3767  // set the bit number
3768  int bitNumber = outputPin;
3769 
3770  //LogTrace("L1GtTriggerMenuXmlParser")
3771  //<< " Bit number: " << bitNumber
3772  //<< std::endl;
3773 
3774  // create a new technical trigger and insert it into technical trigger map
3775  // alias set automatically to name
3776  L1GtAlgorithm alg(algName, logExpression, bitNumber);
3777  alg.setAlgoAlias(algName);
3778 
3779  if (edm::isDebugEnabled() ) {
3780 
3781  std::ostringstream myCoutStream;
3782  alg.print(myCoutStream);
3783  LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3784 
3785  }
3786 
3787  // insert technical trigger into the map
3788  if ( !insertTechTriggerIntoMap(alg)) {
3789 
3790  return false;
3791  }
3792 
3793  return true;
3794 
3795 }
3796 
3797 /*
3798  * parseTechTriggers Parse the technical triggers
3799  *
3800  * @param parser A reference to the XercesDOMParser to use.
3801  *
3802  * @return "true" if succeeded, "false" if an error occurred.
3803  *
3804  */
3805 
3806 bool L1GtTriggerMenuXmlParser::parseTechTriggers(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3807 
3808  XERCES_CPP_NAMESPACE_USE
3809 
3810  //LogTrace("L1GtTriggerMenuXmlParser") << "\nParsing technical triggers" << std::endl;
3811 
3812  DOMNode* doc = parser->getDocument();
3813  DOMNode* node = doc->getFirstChild();
3814 
3815  DOMNode* algNode = node->getFirstChild();
3816  if (algNode == 0) {
3817  edm::LogError("L1GtTriggerMenuXmlParser")
3818  << " Error: No child found for " << m_xmlTagDef << std::endl;
3819  return false;
3820  }
3821 
3822  algNode = findXMLChild(algNode, m_xmlTagTechTriggers);
3823  if (algNode == 0) {
3824  edm::LogError("L1GtTriggerMenuXmlParser") << " Error: No <"
3825  << m_xmlTagTechTriggers << "> child found."
3826  << std::endl;
3827  return false;
3828  }
3829 
3830  // walk through technical triggers
3831  DOMNode* algNameNode = algNode->getFirstChild();
3832  std::string algNameNodeName;
3833  algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
3834 
3835  while (algNameNode != 0) {
3836  //LogTrace("L1GtTriggerMenuXmlParser")
3837  //<< " Found an technical trigger with name: " << algNameNodeName
3838  //<< std::endl;
3839 
3840  if ( !workTechTrigger(algNameNode, algNameNodeName)) {
3841  return false;
3842  }
3843 
3844  algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true,
3845  &algNameNodeName);
3846 
3847  }
3848 
3849  return true;
3850 }
3851 
3852 
3861 bool L1GtTriggerMenuXmlParser::workXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3862 
3863  XERCES_CPP_NAMESPACE_USE
3864 
3865  DOMDocument* doc = parser->getDocument();
3866  DOMNode* n1 = doc->getFirstChild();
3867 
3868  if (n1 == 0) {
3869 
3870  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: Found no XML child" << std::endl;
3871 
3872  return false;
3873  }
3874 
3875  char* nodeName = XMLString::transcode(n1->getNodeName());
3876 
3877  if (XMLString::compareIString(nodeName, m_xmlTagDef.c_str())) {
3878 
3879  edm::LogError("L1GtTriggerMenuXmlParser") << "Error: First XML child is not \" "
3880  << m_xmlTagDef << "\" " << std::endl;
3881 
3882  return false;
3883  }
3884 
3885  LogTrace("L1GtTriggerMenuXmlParser")
3886  << "\nFirst node name is: " << nodeName
3887  << std::endl;
3888  XMLString::release(&nodeName);
3889 
3890  // clear possible old maps
3891  clearMaps();
3892 
3893  if ( !parseId(parser) ) {
3894  clearMaps();
3895  return false;
3896  }
3897 
3898 
3899  if ( !parseConditions(parser) ) {
3900  clearMaps();
3901  return false;
3902  }
3903 
3904  if ( !parseAlgorithms(parser) ) {
3905  clearMaps();
3906  return false;
3907  }
3908 
3909  if ( !parseTechTriggers(parser) ) {
3910  clearMaps();
3911  return false;
3912  }
3913 
3914  return true;
3915 
3916 }
3917 
3918 
3919 // static class members
3920 
#define LogDebug(id)
static const std::string m_xmlTagEta
int getBitFromNode(XERCES_CPP_NAMESPACE::DOMNode *node)
get bit from a bit node
type
Definition: HCALResponse.h:21
static const std::string m_xmlConditionAttrObjectIsoEG
void setGtTriggerMenuInterfaceAuthor(const std::string &)
void setGtTechnicalTriggerMap(const AlgorithmMap &)
bool isDebugEnabled()
int i
Definition: DBlmapReader.cc:9
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)
bool getConditionChildValues(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &childName, unsigned int num, std::vector< boost::uint64_t > &dst)
get values from a child of a condition
static const std::string m_xmlConditionAttrConditionHfRingEtSums
void setVecCastorTemplate(const std::vector< std::vector< L1GtCastorTemplate > > &)
Definition: L1GtObject.h:39
void setVecEnergySumTemplate(const std::vector< std::vector< L1GtEnergySumTemplate > > &)
static const std::string m_xmlTagDeltaPhi
void setAlgoAlias(const std::string &algoAliasValue)
Definition: L1GtAlgorithm.h:72
void setGtTriggerMenuDate(const std::string &)
static const std::string m_xmlConditionAttrObjectHfRingEtSums
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
std::vector< std::vector< L1GtExternalTemplate > > m_vecExternalTemplate
virtual void print(std::ostream &myCout) const
print the condition
static const std::string m_xmlConditionAttrObjectCenJet
static const std::string m_xmlTagHeader
void xercesTerminate()
Definition: Xerces.cc:22
Definition: L1GtObject.h:36
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
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:56
const std::string & condName() const
get / set condition name
Definition: L1GtCondition.h:57
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)
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:17
void setGtNumberPhysTriggers(const unsigned int &)
L1GtConditionType
static const std::string m_xmlTagVme
XERCES_CPP_NAMESPACE::DOMNode * findXMLChild(XERCES_CPP_NAMESPACE::DOMNode *startChild, const std::string &tagName, bool beginOnly=false, std::string *rest=0)
find a named child of a xml node
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
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:67
std::string m_scaleDbKey
menu associated scale key
void setCorCaloTemplate(const std::vector< std::vector< L1GtCaloTemplate > > &)
std::vector< std::vector< L1GtBptxTemplate > > m_vecBptxTemplate
virtual void print(std::ostream &myCout) const
print the condition
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:38
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
bool getXMLHexTextValue(XERCES_CPP_NAMESPACE::DOMNode *node, boost::uint64_t &dst)
get a hexadecimal value of a xml node containing text
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)
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:95
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 > > &)
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 > > &)
XMLCh * transcode(const T &fInput)
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:94
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
#define LogTrace(id)
virtual void print(std::ostream &myCout) const
print the condition
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
virtual void print(std::ostream &myCout) const
print the condition
virtual void print(std::ostream &myCout) const
print the condition
bool insertTechTriggerIntoMap(const L1GtAlgorithm &alg)
insert a technical trigger into technical trigger map
void setConditionParameter(const std::vector< ObjectParameter > &)
set functions
static const std::string m_xmlTagTechTriggers
virtual ~L1GtTriggerMenuXmlParser()
destructor
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:30
virtual void print(std::ostream &myCout) const
print the condition
static const std::string m_xmlConditionAttrType3s
unsigned long long uint64_t
Definition: Time.h:15
static const std::string m_xmlAttrModeBit
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
void setCondChipNr(const int &cChipNr)
void setVecHfBitCountsTemplate(const std::vector< std::vector< L1GtHfBitCountsTemplate > > &)
static const std::string m_xmlConditionAttrType2cor
std::vector< std::vector< L1GtCaloTemplate > > m_corCaloTemplate
bool xmlFile(const std::string fParam)
bool parseBptx(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a Bptx condition
static const std::string m_xmlConditionAttrObjectETM
void setConditionParameter(const std::vector< ObjectParameter > &)
set functions
std::vector< std::vector< L1GtEnergySumTemplate > > m_vecEnergySumTemplate
Definition: L1GtObject.h:37
void setGtNumberTechTriggers(const unsigned int &)
void setGtOrderConditionChip(const std::vector< int > &)
const int algoChipNumber() const
get / set algorithm bit number
void setCondType(const L1GtConditionType &cType)
Definition: L1GtCondition.h:84
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
bool hexString2UInt128(const std::string &hexString, boost::uint64_t &dstL, boost::uint64_t &dstH)
convert a hexadecimal string with up to 128 to 2 boost::uint64_t
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
virtual void print(std::ostream &myCout) const
print the condition
static const std::string m_xmlTagMenuDescription
void setGtAlgorithmImplementation(const std::string &)
bool getXMLHexTextValue128(XERCES_CPP_NAMESPACE::DOMNode *node, boost::uint64_t &dstL, boost::uint64_t &dstH)
get a hexadecimal value of a xml node containing text with up to 128 bit
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 &)
static const std::string m_xmlConditionAttrObjectJetCounts
unsigned int m_numberL1JetCounts
jet counts
static const std::string m_xmlTagMenuInterfaceDescription