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