CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerMenuXmlParser.cc
Go to the documentation of this file.
1 
17 // this class header
18 #include "TriggerMenuXmlParser.h"
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 #include "L1Trigger/L1TGlobal/src/L1TMenuEditor/L1TriggerMenu.hxx"
41 
42 // constructor
44  L1GtXmlParserTags(), m_xmlErrHandler(0), m_triggerMenuInterface("NULL"),
45  m_triggerMenuName("NULL"), m_triggerMenuImplementation("NULL"), m_scaleDbKey("NULL")
46 
47 {
48 
49  // menu names, scale key initialized to NULL due to ORACLE treatment of strings
50 
51  // empty
52 
53 }
54 
55 // destructor
57 
58  clearMaps();
59 
60 }
61 
62 // set the number of condition chips in GTL
64  const unsigned int& numberConditionChipsValue) {
65 
66  m_numberConditionChips = numberConditionChipsValue;
67 
68 }
69 
70 // set the number of pins on the GTL condition chips
71 void l1t::TriggerMenuXmlParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
72 
73  m_pinsOnConditionChip = pinsOnConditionChipValue;
74 
75 }
76 
77 // set the correspondence "condition chip - GTL algorithm word"
78 // in the hardware
80  const std::vector<int>& orderConditionChipValue) {
81 
82  m_orderConditionChip = orderConditionChipValue;
83 
84 }
85 
86 // set the number of physics trigger algorithms
88  const unsigned int& numberPhysTriggersValue) {
89 
90  m_numberPhysTriggers = numberPhysTriggersValue;
91 
92 }
93 
94 // set the number of technical triggers
96  const unsigned int& numberTechTriggersValue) {
97 
98  m_numberTechTriggers = numberTechTriggersValue;
99 
100 }
101 
102 // set the number of L1 jet counts received by GT
103 void l1t::TriggerMenuXmlParser::setGtNumberL1JetCounts(const unsigned int& numberL1JetCountsValue) {
104 
105  m_numberL1JetCounts = numberL1JetCountsValue;
106 
107 }
108 
109 
110 // set the condition maps
111 void l1t::TriggerMenuXmlParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) {
112  m_conditionMap = condMap;
113 }
114 
115 // set the trigger menu name
117  m_triggerMenuInterface = menuInterface;
118 }
119 
121  m_triggerMenuName = menuName;
122 }
123 
125  m_triggerMenuImplementation = menuImplementation;
126 }
127 
128 // set menu associated scale key
130  m_scaleDbKey = scaleKey;
131 }
132 
133 // set the vectors containing the conditions
135  const std::vector<std::vector<MuonTemplate> >& vecMuonTempl) {
136 
137  m_vecMuonTemplate = vecMuonTempl;
138 }
139 
141  const std::vector<std::vector<CaloTemplate> >& vecCaloTempl) {
142 
143  m_vecCaloTemplate = vecCaloTempl;
144 }
145 
147  const std::vector<std::vector<L1GtEnergySumTemplate> >& vecEnergySumTempl) {
148 
149  m_vecEnergySumTemplate = vecEnergySumTempl;
150 }
151 
153  const std::vector<std::vector<L1GtJetCountsTemplate> >& vecJetCountsTempl) {
154 
155  m_vecJetCountsTemplate = vecJetCountsTempl;
156 }
157 
159  const std::vector<std::vector<L1GtCastorTemplate> >& vecCastorTempl) {
160 
161  m_vecCastorTemplate = vecCastorTempl;
162 }
163 
165  const std::vector<std::vector<L1GtHfBitCountsTemplate> >& vecHfBitCountsTempl) {
166 
167  m_vecHfBitCountsTemplate = vecHfBitCountsTempl;
168 }
169 
171  const std::vector<std::vector<L1GtHfRingEtSumsTemplate> >& vecHfRingEtSumsTempl) {
172 
173  m_vecHfRingEtSumsTemplate = vecHfRingEtSumsTempl;
174 }
175 
177  const std::vector<std::vector<L1GtBptxTemplate> >& vecBptxTempl) {
178 
179  m_vecBptxTemplate = vecBptxTempl;
180 }
181 
183  const std::vector<std::vector<L1GtExternalTemplate> >& vecExternalTempl) {
184 
185  m_vecExternalTemplate = vecExternalTempl;
186 }
187 
189  const std::vector<std::vector<CorrelationTemplate> >& vecCorrelationTempl) {
190 
191  m_vecCorrelationTemplate = vecCorrelationTempl;
192 }
193 
194 // set the vectors containing the conditions for correlation templates
195 //
197  const std::vector<std::vector<MuonTemplate> >& corMuonTempl) {
198 
199  m_corMuonTemplate = corMuonTempl;
200 }
201 
203  const std::vector<std::vector<CaloTemplate> >& corCaloTempl) {
204 
205  m_corCaloTemplate = corCaloTempl;
206 }
207 
209  const std::vector<std::vector<L1GtEnergySumTemplate> >& corEnergySumTempl) {
210 
211  m_corEnergySumTemplate = corEnergySumTempl;
212 }
213 
214 
215 
216 
217 // set the algorithm map (by algorithm names)
219  m_algorithmMap = algoMap;
220 }
221 
222 // set the algorithm map (by algorithm aliases)
224  m_algorithmAliasMap = algoMap;
225 }
226 
227 // set the technical trigger map
229  m_technicalTriggerMap = ttMap;
230 }
231 
232 //
233 
234 
235 // parse def.xml and vme.xml files
237  const std::string& vmeXmlFile) {
238 
239  XERCES_CPP_NAMESPACE_USE
240 
241  // resize the vector of condition maps
242  // the number of condition chips should be correctly set before calling parseXmlFile
243  m_conditionMap.resize(m_numberConditionChips);
244 
245  m_vecMuonTemplate.resize(m_numberConditionChips);
246  m_vecCaloTemplate.resize(m_numberConditionChips);
247  m_vecEnergySumTemplate.resize(m_numberConditionChips);
248  m_vecJetCountsTemplate.resize(m_numberConditionChips);
249  m_vecCastorTemplate.resize(m_numberConditionChips);
250  m_vecHfBitCountsTemplate.resize(m_numberConditionChips);
251  m_vecHfRingEtSumsTemplate.resize(m_numberConditionChips);
252  m_vecBptxTemplate.resize(m_numberConditionChips);
253  m_vecExternalTemplate.resize(m_numberConditionChips);
254 
255  m_vecCorrelationTemplate.resize(m_numberConditionChips);
256  m_corMuonTemplate.resize(m_numberConditionChips);
257  m_corCaloTemplate.resize(m_numberConditionChips);
258  m_corEnergySumTemplate.resize(m_numberConditionChips);
259 
260  // set the name of the trigger menu name:
261  // defXmlFile, stripped of absolute path and .xml
262  // will be overwritten by the value read from the xml file, with a warning if
263  // they are not the same
264  m_triggerMenuName = defXmlFile;
265  size_t xmlPos = m_triggerMenuName.find_last_of("/");
266  m_triggerMenuName.erase(m_triggerMenuName.begin(), m_triggerMenuName.begin()
267  + xmlPos + 1);
268 
269  xmlPos = m_triggerMenuName.find_last_of(".");
270  m_triggerMenuName.erase(m_triggerMenuName.begin() + xmlPos, m_triggerMenuName.end());
271 
272  // error handler for xml-parser
273  m_xmlErrHandler = 0;
274 
275  std::auto_ptr<l1t::L1TriggerMenu> tm(l1t::l1TriggerMenu(defXmlFile));
276 
277  LogTrace("TriggerMenuXmlParser") << "\nOpening XML-File: \n " << defXmlFile << std::endl;
278 
279  l1t::ConditionList conditions = tm->conditions();
280 
281  workXML( tm );
282 
283 // if ((parser = initXML(defXmlFile)) != 0) {
284 // workXML(parser);
285 // }
286 // cleanupXML(parser);
287 
288 }
289 
290 //
291 
293 
294  m_triggerMenuInterfaceDate = val;
295 
296 }
297 
299 
300  m_triggerMenuInterfaceAuthor = val;
301 
302 }
303 
305 
306  m_triggerMenuInterfaceDescription = val;
307 
308 }
309 
310 
312 
313  m_triggerMenuDate = val;
314 
315 }
316 
318 
319  m_triggerMenuAuthor = val;
320 
321 }
322 
324 
325  m_triggerMenuDescription = val;
326 
327 }
328 
330 
331  m_algorithmImplementation = val;
332 
333 }
334 
335 // private methods
336 
337 
338 
348 XERCES_CPP_NAMESPACE::XercesDOMParser* l1t::TriggerMenuXmlParser::initXML(const std::string &xmlFile) {
349 
350  XERCES_CPP_NAMESPACE_USE
351 
352  // try to initialize
353  try {
354  XMLPlatformUtils::Initialize();
355  }
356  catch (const XMLException& toCatch) {
357  char* message = XMLString::transcode(toCatch.getMessage());
358 
359  edm::LogError("TriggerMenuXmlParser")
360  << "Error during Xerces-c initialization! :"
361  << message << std::endl;
362 
363  XMLString::release(&message);
364  return 0;
365  }
366 
367  XercesDOMParser* parser = new XercesDOMParser();
368  parser->setValidationScheme(XercesDOMParser::Val_Always);
369  parser->setDoNamespaces(false); // we got no dtd
370 
371  if (m_xmlErrHandler == 0) { // redundant check
372  m_xmlErrHandler = (ErrorHandler*) new HandlerBase();
373  }
374  else {
375  // TODO ASSERTION
376  }
377  parser->setErrorHandler(m_xmlErrHandler);
378 
379  // try to parse the file
380  try {
381  parser->parse(xmlFile.c_str());
382  }
383  catch(const XMLException &toCatch) {
384  char* message = XMLString::transcode(toCatch.getMessage());
385 
386  edm::LogError("TriggerMenuXmlParser")
387  << "Exception while parsing XML: \n"
388  << message << std::endl;
389 
390  XMLString::release(&message);
391  delete parser;
392  delete m_xmlErrHandler;
393  m_xmlErrHandler = 0;
394  return 0;
395  }
396  catch (const DOMException &toCatch) {
397  char *message = XMLString::transcode(toCatch.msg);
398 
399  edm::LogError("TriggerMenuXmlParser")
400  << "DOM-Exception while parsing XML: \n"
401  << message << std::endl;
402 
403  XMLString::release(&message);
404  delete parser;
405  delete m_xmlErrHandler;
406  m_xmlErrHandler = 0;
407  return 0;
408  }
409  catch (...) {
410 
411  edm::LogError("TriggerMenuXmlParser")
412  << "Unexpected Exception while parsing XML!"
413  << std::endl;
414 
415  delete parser;
416  delete m_xmlErrHandler;
417  m_xmlErrHandler = 0;
418  return 0;
419  }
420 
421  return parser;
422 }
423 
424 // find a named child of a xml node
425 XERCES_CPP_NAMESPACE::DOMNode* l1t::TriggerMenuXmlParser::findXMLChild(
426  XERCES_CPP_NAMESPACE::DOMNode* startChild, const std::string& tagName, bool beginOnly,
427  std::string* rest) {
428 
429  XERCES_CPP_NAMESPACE_USE
430 
431  char* nodeName = 0;
432 
433  DOMNode *n1 = startChild;
434  if (n1 == 0) {
435  return 0;
436  }
437 
438  if ( !tagName.empty() ) {
439  nodeName = XMLString::transcode(n1->getNodeName());
440 
441  if (!beginOnly) {
442  //match the whole tag
443  while (XMLString::compareIString(nodeName, tagName.c_str())) {
444 
445  XMLString::release(&nodeName);
446  n1 = n1->getNextSibling();
447  if (n1 == 0) {
448  break;
449  }
450 
451  nodeName = XMLString::transcode(n1->getNodeName());
452  }
453  }
454  else {
455  // match only the beginning
456  while (XMLString::compareNIString(nodeName, tagName.c_str(), tagName.length())) {
457  XMLString::release(&nodeName);
458  n1 = n1->getNextSibling();
459  if (n1 == 0) {
460  break;
461  }
462 
463  nodeName = XMLString::transcode(n1->getNodeName());
464  }
465  if (n1 != 0 && rest != 0) {
466  *rest = std::string(nodeName).substr(tagName.length(), strlen(nodeName) - tagName.length());
467  }
468  }
469  }
470  else { // empty string given
471  while (n1->getNodeType() != DOMNode::ELEMENT_NODE) {
472  n1 = n1->getNextSibling();
473  if (n1 == 0) {
474  break;
475  }
476 
477  }
478  if (n1 != 0 && rest != 0) {
479  nodeName = XMLString::transcode(n1->getNodeName());
480  *rest = std::string(nodeName);
481  }
482  }
483 
484  XMLString::release(&nodeName);
485 
486  return n1;
487 
488 }
489 
499 std::string l1t::TriggerMenuXmlParser::getXMLAttribute(const XERCES_CPP_NAMESPACE::DOMNode* node,
500  const std::string& name) {
501 
502  XERCES_CPP_NAMESPACE_USE
503 
505 
506  // get attributes list
507  DOMNamedNodeMap* attributes = node->getAttributes();
508  if (attributes == 0) {
509  return ret;
510  }
511 
512  // get attribute node
513  XMLCh* attrName = XMLString::transcode(name.c_str());
514  DOMNode* attribNode = attributes->getNamedItem(attrName);
515 
516  XMLString::release(&attrName);
517  if (attribNode == 0) {
518  return ret;
519  }
520 
521  char* retCstr = XMLString::transcode(attribNode->getNodeValue());
522  ret = retCstr;
523  XMLString::release(&retCstr);
524 
525  return ret;
526 }
527 
537 
538  XERCES_CPP_NAMESPACE_USE
539 
541 
542  DOMNode* n1 = node;
543  if (n1 == 0) {
544  return ret;
545  }
546 
547  const XMLCh* retXmlCh = n1->getTextContent();
548  if (retXmlCh == 0) {
549  return ret;
550  }
551 
552  char* retCstr = XMLString::transcode(retXmlCh);
553  XMLString::trim(retCstr); // trim spaces
554 
555  ret = retCstr;
556  XMLString::release(&retCstr);
557 
558  return ret;
559 }
560 
572  boost::uint64_t& dstL, boost::uint64_t& dstH) {
573 
574  // string to determine start of hex value, do not ignore leading zeros
575  static const std::string valid_hex_start("0123456789ABCDEFabcdef");
576 
577  // string to determine end of hex value
578  static const std::string valid_hex_end("0123456789ABCDEFabcdef");
579 
580  std::string tempStr = hexString;
581 
582  // start / end position of the hex value in the string
583  unsigned int hexStart = tempStr.find_first_of(valid_hex_start);
584  unsigned int hexEnd = tempStr.find_first_not_of(valid_hex_end, hexStart);
585 
586  if (hexStart == hexEnd) {
587 
588  LogDebug("TriggerMenuXmlParser") << "No hex value found in: " << tempStr << std::endl;
589 
590  return false;
591  }
592 
593  tempStr = tempStr.substr(hexStart, hexEnd - hexStart);
594 
595  if (tempStr.empty() ) {
596 
597  LogDebug("TriggerMenuXmlParser") << "Empty value in " << __PRETTY_FUNCTION__
598  << std::endl;
599 
600  return false;
601  }
602 
603  // split the string
604  std::string tempStrH, tempStrL;
605 
606  if (tempStr.length() > 16) { // more than 64 bit
607  tempStrL = tempStr.substr(tempStr.length()-16, 16);
608  tempStrH = tempStr.substr(0, tempStr.length()-16);
609  }
610  else {
611  tempStrL = tempStr;
612  tempStrH = "0";
613  }
614 
615  // convert lower 64bit
616  char* endPtr = (char*) tempStrL.c_str();
617  boost::uint64_t tempUIntL = strtoull(tempStrL.c_str(), &endPtr, 16);
618 
619  if (*endPtr != 0) {
620 
621  LogDebug("TriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex."
622  << std::endl;
623 
624  return false;
625  }
626 
627  // convert higher64 bit
628  endPtr = (char*) tempStrH.c_str();
629  boost::uint64_t tempUIntH = strtoull(tempStrH.c_str(), &endPtr, 16);
630 
631  if (*endPtr != 0) {
632 
633  LogDebug("TriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex."
634  << std::endl;
635 
636  return false;
637  }
638 
639  dstL = tempUIntL;
640  dstH = tempUIntH;
641 
642  return true;
643 }
644 
655 bool l1t::TriggerMenuXmlParser::getXMLHexTextValue128Old(XERCES_CPP_NAMESPACE::DOMNode* node,
656  boost::uint64_t& dstL, boost::uint64_t& dstH) {
657 
658  if (node == 0) {
659 
660  LogDebug("TriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
661 
662  return false;
663  }
664 
665  boost::uint64_t tempUIntH, tempUIntL;
666 
667  std::string tempStr = getXMLTextValue(node);
668  if ( !hexString2UInt128(tempStr, tempUIntL, tempUIntH) ) {
669  return false;
670  }
671 
672  dstL = tempUIntL;
673  dstH = tempUIntH;
674 
675  return true;
676 }
677 
679  boost::uint64_t& dstL, boost::uint64_t& dstH) {
680 
681  boost::uint64_t tempUIntH, tempUIntL;
682 
683  std::string tempStr = childName;
684  if ( !hexString2UInt128(tempStr, tempUIntL, tempUIntH) ) {
685  return false;
686  }
687 
688  dstL = tempUIntL;
689  dstH = tempUIntH;
690 
691  return true;
692 }
693 
705 bool l1t::TriggerMenuXmlParser::getXMLHexTextValueOld(XERCES_CPP_NAMESPACE::DOMNode* node,
706  boost::uint64_t& dst) {
707 
708  boost::uint64_t dummyH; // dummy for eventual higher 64bit
709  boost::uint64_t tempUInt; // temporary unsigned integer
710 
711  if ( !getXMLHexTextValue128Old(node, tempUInt, dummyH) ) {
712  return false;
713  }
714 
715  if (dummyH != 0) {
716  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
717  return false;
718  }
719 
720  dst = tempUInt;
721 
722  return true;
723 }
724 
726  boost::uint64_t& dst) {
727 
728  boost::uint64_t dummyH; // dummy for eventual higher 64bit
729  boost::uint64_t tempUInt; // temporary unsigned integer
730 
731  if ( !getXMLHexTextValue128( childName, tempUInt, dummyH) ) {
732  return false;
733  }
734 
735  if (dummyH != 0) {
736  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
737  return false;
738  }
739 
740  dst = tempUInt;
741 
742  return true;
743 }
744 
756  unsigned int& dst) {
757 
758  XERCES_CPP_NAMESPACE_USE
759 
760  // should never happen...
761  // first try direct
762  std::string maxString = childName; // string for the maxbits
763 
764  // do the hex conversion
765 
766  boost::uint64_t maxBitsL, maxBitsH;
767  if ( !hexString2UInt128(maxString, maxBitsL, maxBitsH) ) {
768  return false;
769  }
770 
771  // count the bits
772  //LogTrace("TriggerMenuXmlParser")
773  //<< std::dec
774  //<< " words: dec: high (MSB) word = " << maxBitsH << " low word = " << maxBitsL
775  //<< std::hex << "\n"
776  //<< " words: hex: high (MSB) word = " << maxBitsH << " low word = " << maxBitsL
777  //<< std::dec
778  //<< std::endl;
779 
780  unsigned int counter = 0;
781 
782  while (maxBitsL != 0) {
783  // check if bits set countinously
784  if ( (maxBitsL & 1) == 0) {
785 
786  edm::LogError("TriggerMenuXmlParser")
787  << " Confused by not continous set bits for max value " << maxString
788  << std::endl;
789 
790  return false;
791  }
792 
793  maxBitsL >>= 1;
794  counter++;
795  }
796 
797  if ( (maxBitsH != 0) && (counter != 64)) {
798 
799  edm::LogError("TriggerMenuXmlParser")
800  << " Confused by not continous set bits for max value " << maxString
801  << std::endl;
802 
803  return false;
804  }
805 
806  while (maxBitsH != 0) {
807  //check if bits set countinously
808  if ( (maxBitsH & 1) == 0) {
809 
810  edm::LogError("TriggerMenuXmlParser")
811  << " Confused by not continous set bits for max value " << maxString
812  << std::endl;
813 
814  return false;
815  }
816 
817  maxBitsH >>= 1;
818  counter++;
819  }
820 
821  dst = counter;
822  return true;
823 
824 }
825 
826 
839  const std::string& childName, unsigned int num, std::vector<boost::uint64_t>& dst) {
840 
841  XERCES_CPP_NAMESPACE_USE
842 
843  if (node == 0) {
844 
845  LogDebug("TriggerMenuXmlParser")
846  << "node == 0 in " << __PRETTY_FUNCTION__
847  << std::endl;
848 
849  return false;
850  }
851 
852  DOMNode* n1 = findXMLChild(node->getFirstChild(), childName);
853 
854  // if child not found
855  if (n1 == 0) {
856 
857  LogDebug("TriggerMenuXmlParser") << "Child of condition not found ( " << childName
858  << ")" << std::endl;
859 
860  return false;
861  }
862 
863  // no values are sucessfull
864  if (num == 0) {
865  return true;
866  }
867 
868  //
869  dst.reserve(num);
870 
871  //
872  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
873  for (unsigned int i = 0; i < num; i++) {
874  if (n1 == 0) {
875 
876  LogDebug("TriggerMenuXmlParser") << "Not enough values in condition child ( "
877  << childName << ")" << std::endl;
878 
879  return false;
880  }
881 
882  if ( !getXMLHexTextValueOld(n1, dst[i]) ) {
883 
884  edm::LogError("TriggerMenuXmlParser") << "Error converting condition child ( "
885  << childName << ") value." << std::endl;
886 
887  return false;
888  }
889 
890  n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue); // next child
891  }
892 
893  return true;
894 }
895 
903 void l1t::TriggerMenuXmlParser::cleanupXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
904 
905  XERCES_CPP_NAMESPACE_USE
906 
907  if (parser != 0) {
908  delete parser;
909  }
910 
911  if (m_xmlErrHandler != 0) {
912  delete m_xmlErrHandler;
913  m_xmlErrHandler = 0;
914  }
915 
916  XMLPlatformUtils::Terminate();
917 
918 }
919 
920 
921 // methods for the VME file
922 
923 
933 bool l1t::TriggerMenuXmlParser::parseVmeXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
934 
935  XERCES_CPP_NAMESPACE_USE
936 
937  DOMDocument* doc = parser->getDocument();
938  DOMNode* n1 = doc->getFirstChild();
939 
940  if (n1 == 0) {
941 
942  edm::LogError("TriggerMenuXmlParser") << "Error: Found no XML child" << std::endl;
943 
944  return false;
945  }
946 
947  // find "vme"-tag
948  n1 = findXMLChild(n1, m_xmlTagVme);
949  if (n1 == 0) {
950 
951  edm::LogError("TriggerMenuXmlParser") << "Error: No vme tag found." << std::endl;
952  return false;
953  }
954 
955  n1 = n1->getFirstChild();
956 
957  unsigned int chipCounter = 0; // count chips
958 
959  while (chipCounter < m_numberConditionChips) {
960 
961  n1 = findXMLChild(n1, m_xmlTagChip, true);
962  if (n1 == 0) {
963  // just break if no more chips found
964  break;
965  }
966 
967  // node for a particle
968  //DOMNode* particleNode = n1->getFirstChild(); // FIXME un-comment
969 
970  // FIXME parse vme.xml, modify the menu
971 
972  n1 = n1->getNextSibling();
973  chipCounter++;
974  } // end while chipCounter
975 
976  return true;
977 
978 }
979 
980 // methods for conditions and algorithms
981 
982 // clearMaps - delete all conditions and algorithms in
983 // the maps and clear the maps.
985 
986  // loop over condition maps (one map per condition chip)
987  // then loop over conditions in the map
988  for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip
989  != m_conditionMap.end(); itCondOnChip++) {
990 
991  // the conditions in the maps are deleted in L1uGtTriggerMenu, not here
992 
993  itCondOnChip->clear();
994 
995  }
996 
997  // the algorithms in the maps are deleted in L1uGtTriggerMenu, not here
998  m_algorithmMap.clear();
999 
1000 }
1001 
1002 // insertConditionIntoMap - safe insert of condition into condition map.
1003 // if the condition name already exists, do not insert it and return false
1005 
1006  std::string cName = cond.condName();
1007  //LogTrace("TriggerMenuXmlParser")
1008  //<< " Trying to insert condition \"" << cName << "\" in the condition map." ;
1009 
1010  // no condition name has to appear twice!
1011  if ((m_conditionMap[chipNr]).count(cName) != 0) {
1012  LogTrace("TriggerMenuXmlParser") << " Condition " << cName
1013  << " already exists - not inserted!" << std::endl;
1014  return false;
1015  }
1016 
1017  (m_conditionMap[chipNr])[cName] = &cond;
1018  //LogTrace("TriggerMenuXmlParser")
1019  //<< " OK - condition inserted!"
1020  //<< std::endl;
1021 
1022 
1023  return true;
1024 
1025 }
1026 
1027 // insert an algorithm into algorithm map
1029 
1030  std::string algName = alg.algoName();
1031  std::string algAlias = alg.algoAlias();
1032  //LogTrace("TriggerMenuXmlParser")
1033  //<< " Trying to insert algorithm \"" << algName << "\" in the algorithm map." ;
1034 
1035  // no algorithm name has to appear twice!
1036  if (m_algorithmMap.count(algName) != 0) {
1037  LogTrace("TriggerMenuXmlParser") << " Algorithm \"" << algName
1038  << "\"already exists in the algorithm map- not inserted!" << std::endl;
1039  return false;
1040  }
1041 
1042  if (m_algorithmAliasMap.count(algAlias) != 0) {
1043  LogTrace("TriggerMenuXmlParser") << " Algorithm alias \"" << algAlias
1044  << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
1045  return false;
1046  }
1047 
1048  // bit number less than zero or greater than maximum number of algorithms
1049  int bitNumber = alg.algoBitNumber();
1050  if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
1051  LogTrace("TriggerMenuXmlParser") << " Bit number " << bitNumber
1052  << " outside allowed range [0, " << m_numberPhysTriggers
1053  << ") - algorithm not inserted!" << std::endl;
1054  return false;
1055  }
1056 
1057  // maximum number of algorithms
1058  if (m_algorithmMap.size() >= m_numberPhysTriggers) {
1059  LogTrace("TriggerMenuXmlParser") << " More than maximum allowed "
1060  << m_numberPhysTriggers << " algorithms in the algorithm map - not inserted!"
1061  << std::endl;
1062  return false;
1063  }
1064 
1065  // chip number outside allowed values
1066  int chipNr = alg.algoChipNumber(static_cast<int>(m_numberConditionChips),
1067  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1068 
1069  if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
1070  LogTrace("TriggerMenuXmlParser") << " Chip number " << chipNr
1071  << " outside allowed range [0, " << m_numberConditionChips
1072  << ") - algorithm not inserted!" << std::endl;
1073  return false;
1074  }
1075 
1076  // output pin outside allowed values
1077  int outputPin = alg.algoOutputPin(static_cast<int>(m_numberConditionChips),
1078  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1079 
1080  if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
1081  LogTrace("TriggerMenuXmlParser") << " Output pin " << outputPin
1082  << " outside allowed range [0, " << m_pinsOnConditionChip
1083  << "] - algorithm not inserted!" << std::endl;
1084  return false;
1085  }
1086 
1087  // no two algorithms on the same chip can have the same output pin
1088  for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
1089 
1090  int iPin = (itAlgo->second).algoOutputPin( static_cast<int>(m_numberConditionChips),
1091  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1092  std::string iName = itAlgo->first;
1093  int iChip = (itAlgo->second).algoChipNumber(static_cast<int>(m_numberConditionChips),
1094  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1095 
1096  if ( (outputPin == iPin) && (chipNr == iChip)) {
1097  LogTrace("TriggerMenuXmlParser") << " Output pin " << outputPin
1098  << " is the same as for algorithm " << iName
1099  << "\n from the same chip number " << chipNr << " - algorithm not inserted!"
1100  << std::endl;
1101  return false;
1102  }
1103 
1104  }
1105 
1106  // insert algorithm
1107  m_algorithmMap[algName] = alg;
1108  m_algorithmAliasMap[algAlias] = alg;
1109 
1110  //LogTrace("TriggerMenuXmlParser")
1111  //<< " OK - algorithm inserted!"
1112  //<< std::endl;
1113 
1114  return true;
1115 
1116 }
1117 
1118 // insert a technical trigger into technical trigger map
1120 
1121  std::string algName = alg.algoName();
1122  //LogTrace("TriggerMenuXmlParser")
1123  //<< " Trying to insert technical trigger \"" << algName
1124  //<< "\" in the technical trigger map." ;
1125 
1126  // no technical trigger name has to appear twice!
1127  if (m_technicalTriggerMap.count(algName) != 0) {
1128  LogTrace("TriggerMenuXmlParser") << " Technical trigger \""
1129  << algName
1130  << "\"already exists in the technical trigger map- not inserted!"
1131  << std::endl;
1132  return false;
1133  }
1134 
1135  // bit number less than zero or greater than maximum number of technical triggers
1136  int bitNumber = alg.algoBitNumber();
1137  if ((bitNumber < 0)
1138  || (bitNumber >= static_cast<int>(m_numberTechTriggers))) {
1139  LogTrace("TriggerMenuXmlParser") << " Bit number "
1140  << bitNumber << " outside allowed range [0, "
1141  << m_numberTechTriggers
1142  << ") - technical trigger not inserted!" << std::endl;
1143  return false;
1144  }
1145 
1146  // no two technical triggers can have the same bit number
1147  for (CItAlgo itAlgo = m_technicalTriggerMap.begin(); itAlgo
1148  != m_technicalTriggerMap.end(); itAlgo++) {
1149 
1150  int iBitNumber = (itAlgo->second).algoBitNumber();
1151  std::string iName = itAlgo->first;
1152 
1153  if ((iBitNumber == bitNumber)) {
1154  LogTrace("TriggerMenuXmlParser") << " Bit number "
1155  << iBitNumber << " is the same as for technical trigger "
1156  << iName << " - technical trigger not inserted!"
1157  << std::endl;
1158  return false;
1159  }
1160 
1161  }
1162 
1163  // maximum number of technical triggers
1164  if (m_technicalTriggerMap.size() >= m_numberTechTriggers) {
1165  LogTrace("TriggerMenuXmlParser")
1166  << " More than maximum allowed " << m_numberTechTriggers
1167  << " technical triggers in the technical trigger map - not inserted!"
1168  << std::endl;
1169  return false;
1170  }
1171 
1172  // insert technical trigger
1173  m_technicalTriggerMap[algName] = alg;
1174 
1175  //LogTrace("TriggerMenuXmlParser")
1176  //<< " OK - technical trigger inserted!"
1177  //<< std::endl;
1178 
1179  return true;
1180 
1181 }
1182 
1183 
1184 
1185 // get the type of the condition, as defined in enum, from the condition type
1186 // as defined in the XML file
1188 
1189  if (type == m_xmlConditionAttrType1s) {
1190  return l1t::Type1s;
1191  }
1192 
1193  if (type == m_xmlConditionAttrType2s) {
1194  return l1t::Type2s;
1195  }
1196 
1197  if (type == m_xmlConditionAttrType3s) {
1198  return l1t::Type3s;
1199  }
1200 
1201  if (type == m_xmlConditionAttrType4s) {
1202  return l1t::Type4s;
1203  }
1204 
1205  if (type == m_xmlConditionAttrType2wsc) {
1206  return l1t::Type2wsc;
1207  }
1208 
1209  if (type == m_xmlConditionAttrType2cor) {
1210  return l1t::Type2cor;
1211  }
1212 
1213  return l1t::TypeNull;
1214 }
1215 
1226 
1227  if (type == m_xmlConditionAttrType1s) {
1228  return 1;
1229  }
1230 
1231  if (type == m_xmlConditionAttrType2s) {
1232  return 2;
1233  }
1234 
1235  if (type == m_xmlConditionAttrType3s) {
1236  return 3;
1237  }
1238 
1239  if (type == m_xmlConditionAttrType4s) {
1240  return 4;
1241  }
1242 
1243  if (type == m_xmlConditionAttrType2wsc) {
1244  return 2;
1245  }
1246 
1247  if (type == m_xmlConditionAttrType2cor) {
1248  return 2;
1249  }
1250 
1251  return -1;
1252 }
1253 
1262 int l1t::TriggerMenuXmlParser::getBitFromNode(XERCES_CPP_NAMESPACE::DOMNode* node) {
1263 
1264  if (getXMLAttribute(node, m_xmlAttrMode) != m_xmlAttrModeBit) {
1265 
1266  edm::LogError("TriggerMenuXmlParser") << "Invalid mode for single bit" << std::endl;
1267 
1268  return -1;
1269  }
1270 
1271  std::string tmpStr = getXMLTextValue(node);
1272  if (tmpStr == "0") {
1273  return 0;
1274  }
1275  else if (tmpStr == "1") {
1276  return 1;
1277  }
1278  else {
1279  edm::LogError("TriggerMenuXmlParser") << "Bad bit value (" << tmpStr << ")"
1280  << std::endl;
1281  return -1;
1282  }
1283 }
1284 
1294 int l1t::TriggerMenuXmlParser::getGEqFlag(XERCES_CPP_NAMESPACE::DOMNode* node,
1295  const std::string& nodeName) {
1296 
1297  XERCES_CPP_NAMESPACE_USE
1298 
1299  if (node == 0) {
1300 
1301  LogDebug("TriggerMenuXmlParser")
1302  << "node == 0 in " << __PRETTY_FUNCTION__
1303  << std::endl;
1304 
1305  return -1;
1306  }
1307 
1308  // usually the GEq flag is a child of the first child (the first element node)
1309  DOMNode* n1 = node->getFirstChild();
1310  n1 = findXMLChild(n1, nodeName);
1311 
1312  if (n1 != 0) {
1313  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagGEq);
1314  if (n1 == 0) {
1315 
1316  LogDebug("TriggerMenuXmlParser") << "No \"greater or equal\" tag found"
1317  << std::endl;
1318 
1319  return -1;
1320  }
1321 
1322  return getBitFromNode(n1);
1323  }
1324  else {
1325 
1326  return -1;
1327 
1328  }
1329 
1330 }
1331 
1344 bool l1t::TriggerMenuXmlParser::getMuonMipIsoBits(XERCES_CPP_NAMESPACE::DOMNode* node,
1345  unsigned int num, std::vector<bool>& mipDst, std::vector<bool>& isoEnDst,
1346  std::vector<bool>& isoReqDst) {
1347 
1348  XERCES_CPP_NAMESPACE_USE
1349 
1350  if (node == 0) {
1351  return false;
1352  }
1353 
1354  // find ptLowThreshold child
1355  DOMNode* n1 = findXMLChild(node->getFirstChild(), m_xmlTagPtLowThreshold);
1356 
1357  if (n1 == 0) {
1358  return false;
1359  }
1360 
1361  // get first value tag
1362  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
1363 
1364  for (unsigned int i = 0; i < num; i++) {
1365 
1366  if (n1 == 0) {
1367  return false;
1368  }
1369 
1370  // MIP bit
1371 
1372  DOMNode* bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableMip);
1373  if (bitnode == 0) {
1374  return true;
1375  }
1376 
1377  int tmpint = getBitFromNode(bitnode);
1378  if (tmpint < 0) {
1379  return false;
1380  }
1381 
1382  mipDst[i] = (tmpint != 0);
1383 
1384  //LogTrace("TriggerMenuXmlParser")
1385  //<< " MIP bit value for muon " << i << " = " << mipDst[i]
1386  //<< std::endl;
1387 
1388 
1389  // enable iso bit
1390  bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableIso);
1391  if (bitnode == 0) {
1392  return true;
1393  }
1394 
1395  tmpint = getBitFromNode(bitnode);
1396  if (tmpint < 0) {
1397  return false;
1398  }
1399 
1400  isoEnDst[i] = (tmpint != 0);
1401 
1402  //LogTrace("TriggerMenuXmlParser")
1403  //<< " Enabled iso bit value for muon " << i << " = " << isoEnDst[i]
1404  //<< std::endl;
1405 
1406  // request iso bit
1407  bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagRequestIso);
1408  if (bitnode == 0) {
1409  return true;
1410  }
1411 
1412  tmpint = getBitFromNode(bitnode);
1413  if (tmpint < 0) {
1414  return false;
1415  }
1416 
1417  isoReqDst[i] = (tmpint != 0);
1418 
1419  //LogTrace("TriggerMenuXmlParser")
1420  //<< " Request iso bit value for muon " << i << " = " << isoReqDst[i]
1421  //<< std::endl;
1422 
1423  //
1424  n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue); // next value
1425  }
1426 
1427  return true;
1428 }
1429 
1430 
1432  std::stringstream ss;
1433  ss << data;
1434  return ss.str();
1435 }
1437  std::stringstream ss;
1438  ss << data;
1439  return ss.str();
1440 }
1442  std::stringstream ss;
1443  ss << data;
1444  return ss.str();
1445 }
1447  std::stringstream ss;
1448  ss << std::setfill('0');
1449  ss << std::setw(4) << date.year() << "-" << std::setw(2) << date.month() << "-" << std::setw(2) << date.day() << "T";
1450  ss << std::setw(2) << date.hours() << ":" << std::setw(2) << date.minutes() << ":" << std::setw(2) << date.seconds();
1451  //ss << data;
1452  return ss.str();
1453 }
1455  std::stringstream ss;
1456  ss << data;
1457  return ss.str();
1458 }
1460  std::stringstream ss;
1461  ss << data;
1462  return ss.str();
1463 }
1465  std::stringstream ss;
1466  ss << data;
1467  return ss.str();
1468 }
1470  std::stringstream ss;
1471  ss << data;
1472  return ss.str();
1473 }
1475  std::stringstream ss;
1476  ss << data;
1477  return ss.str();
1478 }
1480  std::stringstream ss;
1481  ss << data;
1482  return ss.str();
1483 }
1485  std::stringstream ss;
1486  ss << data;
1487  return ss.str();
1488 }
1490  std::stringstream ss;
1491  ss << data;
1492  return ss.str();
1493 }
1495  std::stringstream ss;
1496  ss << data;
1497  return ss.str();
1498 }
1500  std::stringstream ss;
1501  ss << data;
1502  return ss.str();
1503 }
1505  std::stringstream ss;
1506  ss << data;
1507  int value;
1508  ss >> value;
1509  return value;
1510 }
1511 
1512 
1513 
1525 bool l1t::TriggerMenuXmlParser::parseMuon(l1t::MuonCondition condMu,
1526  unsigned int chipNr, const bool corrFlag) {
1527 
1528  XERCES_CPP_NAMESPACE_USE
1529 
1530  // get condition, particle name (must be muon) and type name
1531  std::string condition = "muon";
1532  std::string particle = "mu";//l1t2string( condMu.objectType() );
1533  std::string type = "single";//l1t2string( condMu.type() );
1534  std::string name = l1t2string( condMu.name() );
1535 
1536  if( particle=="mu" ) particle = "muon";
1537  if( type=="single" ) type = "1_s";
1538 
1539  LogDebug("l1t|Global")
1540  << "\n ****************************************** "
1541  << "\n parseMuon "
1542  << "\n condition = " << condition
1543  << "\n particle = " << particle
1544  << "\n type = " << type
1545  << "\n name = " << name
1546  << std::endl;
1547 
1548  if (particle != m_xmlConditionAttrObjectMu) {
1549  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for muon-condition ("
1550  << particle << ")" << std::endl;
1551  return false;
1552  }
1553 
1554  // get greater equal flag
1555  std::string str_etComparison = l1t2string( condMu.etComparison() );
1556 
1557  int nrObj = getNumFromType(type);
1558  if (nrObj < 0) {
1559  edm::LogError("TriggerMenuXmlParser") << "Unknown type for calo-condition (" << type
1560  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1561  return false;
1562  }
1563 
1564  // get greater equal flag
1565  int intGEq = ( str_etComparison=="ge" ) ? 1 : 0;
1566  if (intGEq < 0) {
1567  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
1568  << std::endl;
1569  return false;
1570  }
1571  // set the boolean value for the ge_eq mode
1572  bool gEq = (intGEq != 0);
1573 
1574 // // get values
1575 
1576  // temporary storage of the parameters
1577  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1578  MuonTemplate::CorrelationParameter corrParameter;
1579 
1580  // need at least two values for deltaPhi
1581  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1582 
1583  boost::uint64_t dst;
1584 
1585  // need this for future DP
1586 // // get ptHighThreshold values and fill into structure
1587 // if ( !getConditionChildValuesOld(node, m_xmlTagPtHighThreshold, nrObj, tmpValues) ) {
1588 // return false;
1589 // }
1590 
1591  for (int i = 0; i < nrObj; i++) {
1592  getXMLHexTextValue("0a", dst);
1593 
1594  objParameter[i].ptHighThreshold = dst;//tmpValues[i];
1595 
1596 // LogTrace("TriggerMenuXmlParser")
1597 // << " Muon pT high threshold (hex) for muon " << i << " = "
1598 // << std::hex << objParameter[i].ptHighThreshold << std::dec
1599 // << std::endl;
1600  }
1601 
1602  // need this for future DP
1603 // // get ptLowThreshold values and fill into structure
1604 // if ( !getConditionChildValuesOld(node, m_xmlTagPtLowThreshold, nrObj, tmpValues) ) {
1605 // return false;
1606 // }
1607 
1608  for (int i = 0; i < nrObj; i++) {
1609  //LogTrace("TriggerMenuXmlParser")
1610  //<< " Muon pT low threshold word (hex) for muon " << i << " = "
1611  //<< std::hex << tmpValues[i] << std::dec
1612  //<< std::endl;
1613 
1614  // TODO FIXME stupid format in def.xml...
1615  // one takes mip bit also, therefore one divide by 16
1616  // need this for future DP
1617  //tmpValues[i] = (tmpValues[i])/16;
1618 
1619  // need this for future DP
1620  getXMLHexTextValue("0a", dst);
1621  objParameter[i].ptLowThreshold = dst;//tmpValues[i];
1622 
1623  //LogTrace("TriggerMenuXmlParser")
1624  //<< " Muon pT low threshold (hex) for muon " << i << " = "
1625  //<< std::hex << objParameter[i].ptLowThreshold << std::dec
1626  //<< std::endl;
1627  }
1628 
1629  // need this for future DP
1630 // // get qualityRange and fill into structure
1631 // if ( !getConditionChildValuesOld(node, m_xmlTagQuality, nrObj, tmpValues) ) {
1632 // return false;
1633 // }
1634 
1635  for (int i = 0; i < nrObj; i++) {
1636  // need this for future DP
1637  getXMLHexTextValue("f0", dst);
1638  objParameter[i].qualityRange = dst;//tmpValues[i];
1639 
1640  //LogTrace("TriggerMenuXmlParser")
1641  //<< " qualityRange mask (hex) for muon " << i << " = "
1642  //<< std::hex << objParameter[i].qualityRange << std::dec
1643  //<< std::endl;
1644  }
1645 
1646  // need this for future DP
1647 // // get etaRange and fill into structure
1648 // if ( !getConditionChildValuesOld(node, m_xmlTagEta, nrObj, tmpValues) ) {
1649 // return false;
1650 // }
1651 
1652  for (int i = 0; i < nrObj; i++) {
1653 
1654  getXMLHexTextValue("FFFFFFFFFFFFFFFF", dst);
1655  objParameter[i].etaRange = dst;//tmpValues[i];
1656 
1657  //LogTrace("TriggerMenuXmlParser")
1658  //<< " etaRange (hex) for muon " << i << " = "
1659  //<< std::hex << objParameter[i].etaRange << std::dec
1660  //<< std::endl;
1661  }
1662 
1663  // need this for future DP
1664 // // get phiHigh values and fill into structure
1665 // if ( !getConditionChildValuesOld(node, m_xmlTagPhiHigh, nrObj, tmpValues) ) {
1666 // return false;
1667 // }
1668 
1669  for (int i = 0; i < nrObj; i++) {
1670  getXMLHexTextValue("8f", dst);
1671  objParameter[i].phiHigh = dst;//tmpValues[i];
1672 
1673  //LogTrace("TriggerMenuXmlParser")
1674  //<< " phiHigh (hex) for muon " << i << " = "
1675  //<< std::hex << objParameter[i].phiHigh << std::dec
1676  //<< std::endl;
1677  }
1678 
1679  // need this for future DP
1680 // // get phiLow values and fill into structure
1681 // if ( !getConditionChildValuesOld(node, m_xmlTagPhiLow, nrObj, tmpValues) ) {
1682 // return false;
1683 // }
1684 
1685  for (int i = 0; i < nrObj; i++) {
1686  getXMLHexTextValue("00", dst);
1687  objParameter[i].phiLow = dst;//tmpValues[i];
1688 
1689  //LogTrace("TriggerMenuXmlParser")
1690  //<< " phiLow (hex) for muon " << i << " = "
1691  //<< std::hex << objParameter[i].phiLow << std::dec
1692  //<< std::endl;
1693  }
1694 
1695  // need this for future DP
1696 // // get charge correlation and fill into structure
1697 // if ( !getXMLHexTextValueOld(findXMLChild(node->getFirstChild(), m_xmlTagChargeCorrelation),
1698 // tmpValues[0]) ) {
1699 
1700 // LogDebug("TriggerMenuXmlParser")
1701 // << " Error getting charge correlation from muon condition (" << name << ")"
1702 // << std::endl;
1703 // return false;
1704 // }
1705 
1706  getXMLHexTextValue("1", dst);
1707  corrParameter.chargeCorrelation = dst;//tmpValues[0];
1708 
1709 // //LogTrace("TriggerMenuXmlParser")
1710 // //<< " charge correlation" << " = "
1711 // //<< std::hex << corrParameter.chargeCorrelation << std::dec
1712 // //<< std::endl;
1713 
1714  // get mip and iso bits and fill into structure
1715 
1716  std::vector<bool> tmpMip(nrObj);
1717  std::vector<bool> tmpEnableIso(nrObj);
1718  std::vector<bool> tmpRequestIso(nrObj);
1719 
1720  // need this for future DP
1721 // if ( !getMuonMipIsoBits(node, nrObj, tmpMip, tmpEnableIso, tmpRequestIso) ) {
1722 // edm::LogError("TriggerMenuXmlParser")
1723 // << " Could not get mip and iso bits from muon condition (" << name << ")"
1724 // << std::endl;
1725 // return false;
1726 // }
1727 
1728  for (int i = 0; i < nrObj; i++) {
1729  objParameter[i].enableMip = false;//tmpMip[i];
1730  objParameter[i].enableIso = false;//tmpEnableIso[i];
1731  objParameter[i].requestIso = false;//tmpRequestIso[i];
1732  }
1733 
1734  // indicates if a correlation is used
1735  bool wscVal = (type == m_xmlConditionAttrType2wsc );
1736 
1737  if (wscVal) {
1738  // need this for future DP
1739 // // get deltaEtaRange
1740 // if ( !getConditionChildValuesOld(node, m_xmlTagDeltaEta, 1, tmpValues) ) {
1741 // return false;
1742 // }
1743 
1744 // corrParameter.deltaEtaRange = tmpValues[0];
1745 
1746 // // deltaPhi is larger than 64bit
1747 // if ( !getXMLHexTextValue128Old(findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi),
1748 // tmpValues[0], tmpValues[1])) {
1749 // edm::LogError("TriggerMenuXmlParser")
1750 // << " Could not get deltaPhi for muon condition with wsc (" << name << ")"
1751 // << std::endl;
1752 // return false;
1753 // }
1754 
1755 // corrParameter.deltaPhiRange0Word = tmpValues[0];
1756 // corrParameter.deltaPhiRange1Word = tmpValues[1];
1757 
1758 // // get maximum number of bits for delta phi
1759 // //LogTrace("TriggerMenuXmlParser")
1760 // //<< " Counting deltaPhiMaxbits"
1761 // //<< std::endl;
1762 
1763 // unsigned int maxbits;
1764 
1765 // if ( !countConditionChildMaxBits2(node, m_xmlTagDeltaPhi, maxbits) ) {
1766 // return false;
1767 // }
1768 
1769 // corrParameter.deltaPhiMaxbits = maxbits;
1770 // //LogTrace("TriggerMenuXmlParser")
1771 // //<< " deltaPhiMaxbits (dec) = " << maxbits
1772 // //<< std::endl;
1773  }
1774 
1775  // get the type of the condition, as defined in enum, from the condition type
1776  // as defined in the XML file
1777  GtConditionType cType = getTypeFromType(type);
1778  //LogTrace("TriggerMenuXmlParser")
1779  //<< " Condition type (enum value) = " << cType
1780  //<< std::endl;
1781 
1782  if (cType == l1t::TypeNull) {
1783  edm::LogError("TriggerMenuXmlParser")
1784  << "Type for muon condition id l1t::TypeNull - it means not defined in the XML file."
1785  << "\nNumber of trigger objects is set to zero. " << std::endl;
1786  return false;
1787  }
1788 
1789  // object types - all muons
1790  std::vector<L1GtObject> objType(nrObj, Mu);
1791 
1793 
1794  int relativeBx = l1t2int( condMu.relativeBx() );
1795 
1797  // now create a new CondMuonition
1798 
1799  MuonTemplate muonCond(name);
1800 
1801  muonCond.setCondType(cType);
1802  muonCond.setObjectType(objType);
1803  muonCond.setCondGEq(gEq);
1804  muonCond.setCondChipNr(chipNr);
1805  muonCond.setCondRelativeBx(relativeBx);
1806 
1807  muonCond.setConditionParameter(objParameter, corrParameter);
1808 
1809  if (edm::isDebugEnabled()) {
1810  std::ostringstream myCoutStream;
1811  muonCond.print(myCoutStream);
1812  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
1813  }
1814 
1815  // insert condition into the map and into muon template vector
1816  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1817  edm::LogError("TriggerMenuXmlParser")
1818  << " Error: duplicate condition (" << name << ")"
1819  << std::endl;
1820  return false;
1821  }
1822  else {
1823  if (corrFlag) {
1824  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1825  }
1826  else {
1827  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1828  }
1829 
1830  }
1831 
1832  //
1833  return true;
1834 }
1835 
1847 bool l1t::TriggerMenuXmlParser::parseCalo(l1t::CalorimeterCondition condCalo,
1848  unsigned int chipNr, const bool corrFlag) {
1849 
1850  XERCES_CPP_NAMESPACE_USE
1851 
1852  // get condition, particle name and type name
1853 
1854  std::string condition = "calo";
1855  std::string particle = l1t2string( condCalo.objectType() );
1856  std::string type = l1t2string( condCalo.type() );
1857  std::string name = l1t2string( condCalo.name() );
1858 
1859  LogDebug("l1t|Global")
1860  << "\n ****************************************** "
1861  << "\n DARRENS TEST OUTPUT (in parseCalo) "
1862  << "\n condition = " << condition
1863  << "\n particle = " << particle
1864  << "\n type = " << type
1865  << "\n name = " << name
1866  << std::endl;
1867 
1868 
1869  // determine object type type
1870  L1GtObject caloObjType;
1871 
1872  if (particle == m_xmlConditionAttrObjectNoIsoEG) {
1873  caloObjType = NoIsoEG;
1874  }
1875  else if (particle == m_xmlConditionAttrObjectIsoEG) {
1876  caloObjType = IsoEG;
1877  }
1878  else if (particle == m_xmlConditionAttrObjectCenJet) {
1879  caloObjType = CenJet;
1880  }
1881  else if (particle == m_xmlConditionAttrObjectTauJet) {
1882  caloObjType = TauJet;
1883  }
1884  else if (particle == m_xmlConditionAttrObjectForJet) {
1885  caloObjType = ForJet;
1886  }
1887  else {
1888  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for calo-condition ("
1889  << particle << ")" << std::endl;
1890  return false;
1891  }
1892 
1893  if( type=="double_wsc" ) type = "2_wsc";
1894  else if( type=="single" ) type = "1_s";
1895  else if( type=="double" ) type = "2_s";
1896  else if( type=="triple" ) type = "3";
1897  else if( type=="quad" ) type = "4";
1898 
1899 
1900  std::string str_etComparison = l1t2string( condCalo.etComparison() );
1901 
1902  int nrObj = getNumFromType(type);
1903  if (nrObj < 0) {
1904  edm::LogError("TriggerMenuXmlParser") << "Unknown type for calo-condition (" << type
1905  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1906  return false;
1907  }
1908 
1909  // get greater equal flag
1910  int intGEq = ( str_etComparison=="ge" ) ? 1 : 0;
1911  if (intGEq < 0) {
1912  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
1913  << std::endl;
1914  return false;
1915  }
1916  // set the boolean value for the ge_eq mode
1917  bool gEq = (intGEq != 0);
1918 
1919  // get values
1920 
1921  // temporary storage of the parameters
1922  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1923  CaloTemplate::CorrelationParameter corrParameter;
1924 
1925  // need at least one value for deltaPhiRange
1926  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1927  tmpValues.reserve( nrObj );
1928 
1929  if( int(condCalo.objectRequirements().objectRequirement().size())!=nrObj ){
1930  edm::LogError("TriggerMenuXmlParser") << " condCalo objects: nrObj = " << nrObj
1931  << "condCalo.objectRequirements().objectRequirement().size() = "
1932  << condCalo.objectRequirements().objectRequirement().size()
1933  << std::endl;
1934  return false;
1935  }
1936 
1937 
1938  std::string str_condCalo = "";
1939  boost::uint64_t tempUIntH, tempUIntL;
1940  boost::uint64_t dst;
1941  int cnt = 0;
1942  for( l1t::CalorimeterObjectRequirements::objectRequirement_const_iterator objPar = condCalo.objectRequirements().objectRequirement().begin();
1943  objPar != condCalo.objectRequirements().objectRequirement().end(); ++objPar ){
1944 
1945  // ET Threshold
1946  str_condCalo = l1t2string( objPar->etThreshold() );
1947  if( !getXMLHexTextValue(str_condCalo, dst) ) return false;
1948  //if( cnt<nrObj ) objParameter[cnt].etThreshold = dst;
1950  if( cnt<nrObj ) objParameter[cnt].etThreshold = objPar->etThreshold();
1951 
1952  // Eta Range
1953  //str_condCalo = "ffff";
1954  str_condCalo = "7f7f";
1955  //str_condCalo = "0f0f";
1956  if( !getXMLHexTextValue(str_condCalo, dst) ) return false;
1957  if( cnt<nrObj ) objParameter[cnt].etaRange = dst;
1958 
1959  // Phi Range
1960  str_condCalo = "3ffff";
1961  if( !getXMLHexTextValue(str_condCalo, dst) ) return false;
1962  if( cnt<nrObj ) objParameter[cnt].phiRange = dst;
1963 
1964 
1965 
1966  int cntEta=0;
1967  unsigned int etaWindowLower=-1, etaWindowUpper=-1, etaWindowVetoLower=-1, etaWindowVetoUpper=-1;
1968  // Temporary before translation
1969  for( l1t::CalorimeterObjectRequirement::etaWindow_const_iterator etaWindow =objPar->etaWindow().begin();
1970  etaWindow != objPar->etaWindow().end(); ++etaWindow ){
1971 
1972  LogDebug("l1t|Global")
1973  << "\n etaWindow lower = " << etaWindow->lower()
1974  << "\n etaWindow upper = " << etaWindow->upper()
1975  << std::endl;
1976  if( cntEta==0 ){ etaWindowLower = etaWindow->lower(); etaWindowUpper = etaWindow->upper(); }
1977  else if( cntEta==1 ){ etaWindowVetoLower = etaWindow->lower(); etaWindowVetoUpper = etaWindow->upper(); }
1978  cntEta++;
1979  }
1980 
1981  int cntPhi=0;
1982  unsigned int phiWindowLower=-1, phiWindowUpper=-1, phiWindowVetoLower=-1, phiWindowVetoUpper=-1;
1983  for( l1t::CalorimeterObjectRequirement::phiWindow_const_iterator phiWindow =objPar->phiWindow().begin();
1984  phiWindow != objPar->phiWindow().end(); ++phiWindow ){
1985 
1986  LogDebug("l1t|Global")
1987  << "\n phiWindow begin = " << phiWindow->lower()
1988  << "\n phiWindow end = " << phiWindow->upper()
1989  << std::endl;
1990 
1991  if( cntPhi==0 ){ phiWindowLower = phiWindow->lower(); phiWindowUpper = phiWindow->upper(); }
1992  else if( cntPhi==1 ){ phiWindowVetoLower = phiWindow->lower(); phiWindowVetoUpper = phiWindow->upper(); }
1993  cntPhi++;
1994  }
1995 
1996  objParameter[cnt].etaWindowLower = etaWindowLower;
1997  objParameter[cnt].etaWindowUpper = etaWindowUpper;
1998  objParameter[cnt].etaWindowVetoLower = etaWindowVetoLower;
1999  objParameter[cnt].etaWindowVetoUpper = etaWindowVetoUpper;
2000 
2001  objParameter[cnt].phiWindowLower = phiWindowLower;
2002  objParameter[cnt].phiWindowUpper = phiWindowUpper;
2003  objParameter[cnt].phiWindowVetoLower = phiWindowVetoLower;
2004  objParameter[cnt].phiWindowVetoUpper = phiWindowVetoUpper;
2005 
2006 
2007  // Output for debugging
2008  LogDebug("l1t|Global")
2009  << "\n Calo ET high threshold (hex) for calo object " << cnt << " = "
2010  << std::hex << objParameter[cnt].etThreshold << std::dec
2011  << "\n etaWindow (hex) for calo object " << cnt << " = "
2012  << std::hex << objParameter[cnt].etaRange << std::dec
2013  << "\n phiRange (hex) for calo object " << cnt << " = "
2014  << std::hex << objParameter[cnt].phiRange << std::dec
2015  << "\n etaWindow Lower / Upper for calo object " << cnt << " = "
2016  << objParameter[cnt].etaWindowLower << " / " << objParameter[cnt].etaWindowUpper
2017  << "\n etaWindowVeto Lower / Upper for calo object " << cnt << " = "
2018  << objParameter[cnt].etaWindowVetoLower << " / " << objParameter[cnt].etaWindowVetoUpper
2019  << "\n phiWindow Lower / Upper for calo object " << cnt << " = "
2020  << objParameter[cnt].phiWindowLower << " / " << objParameter[cnt].phiWindowUpper
2021  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = "
2022  << objParameter[cnt].phiWindowVetoLower << " / " << objParameter[cnt].phiWindowVetoUpper
2023  << std::endl;
2024 
2025  cnt++;
2026  }
2027 
2028 
2029 
2030  // indicates if a correlation is used
2031  bool wscVal = (type == m_xmlConditionAttrType2wsc );
2032 
2033  if( wscVal ){
2034 
2035  xsd::cxx::tree::optional<l1t::DeltaRequirement> condRanges = condCalo.deltaRequirement();
2036  LogDebug("l1t|Global")
2037  << "\t condRanges->deltaEtaRange().lower() = " << condRanges->deltaEtaRange().lower()
2038  << "\n\t condRanges->deltaEtaRange().upper() = " << condRanges->deltaEtaRange().upper()
2039  << "\n\t condRanges->deltaPhiRange().lower() = " << condRanges->deltaPhiRange().lower()
2040  << "\n\t condRanges->deltaPhiRange().upper() = " << condRanges->deltaPhiRange().upper()
2041  << std::endl;
2042 
2043  corrParameter.deltaEtaRangeLower = condRanges->deltaEtaRange().lower();
2044  corrParameter.deltaEtaRangeUpper = condRanges->deltaEtaRange().upper();
2045 
2046  corrParameter.deltaPhiRangeLower = condRanges->deltaPhiRange().lower();
2047  corrParameter.deltaPhiRangeUpper = condRanges->deltaPhiRange().upper();
2048 
2049  //
2051  //
2052 
2053  // Eta Range
2054  str_condCalo = "0003";
2055  if ( !hexString2UInt128(str_condCalo, tempUIntL, tempUIntH) ) {
2056  return false;
2057  }
2058  if( tempUIntH != 0 ){
2059  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
2060  return false;
2061  }
2062  corrParameter.deltaEtaRange = tempUIntL;
2063 
2064  // Phi Range
2065  str_condCalo = "003";
2066  if ( !hexString2UInt128(str_condCalo, tempUIntL, tempUIntH) ) {
2067  return false;
2068  }
2069  if( tempUIntH != 0 ){
2070  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
2071  return false;
2072  }
2073  corrParameter.deltaPhiRange = tempUIntL;
2074 
2075 
2076 
2077  // Max Phi Range
2078  std::string maxString = "3FF";
2079 
2080  unsigned int maxbits = 0;
2081 
2082  if ( !countConditionChildMaxBits(maxString, maxbits) ) {
2083  return false;
2084  }
2085 
2086  corrParameter.deltaPhiMaxbits = maxbits;
2087  LogTrace("TriggerMenuXmlParser")
2088  << " deltaPhiMaxbits (dec) = " << maxbits
2089  << std::endl;
2090  }
2091 
2092 
2093 
2094  // get the type of the condition, as defined in enum, from the condition type
2095  // as defined in the XML file
2096  GtConditionType cType = getTypeFromType(type);
2097  LogTrace("TriggerMenuXmlParser")
2098  << " Condition type (enum value) = " << cType
2099  << std::endl;
2100 
2101  if (cType == l1t::TypeNull) {
2102  edm::LogError("TriggerMenuXmlParser")
2103  << "Type for calo condition id l1t::TypeNull - it means not defined in the XML file."
2104  << "\nNumber of trigger objects is set to zero. " << std::endl;
2105  return false;
2106  }
2107 
2108  // object types - all same caloObjType
2109  std::vector<L1GtObject> objType(nrObj, caloObjType);
2110 
2111 
2112  int relativeBx = l1t2int( condCalo.relativeBx() );
2113 
2114  // now create a new calo condition
2115  CaloTemplate caloCond(name);
2116 
2117  caloCond.setCondType(cType);
2118  caloCond.setObjectType(objType);
2119  caloCond.setCondGEq(gEq);
2120  caloCond.setCondChipNr(chipNr);
2121  caloCond.setCondRelativeBx(relativeBx);
2122 
2123  caloCond.setConditionParameter(objParameter, corrParameter);
2124 
2125  if (edm::isDebugEnabled() ) {
2126 
2127  std::ostringstream myCoutStream;
2128  caloCond.print(myCoutStream);
2129  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2130 
2131  }
2132 
2133  // insert condition into the map
2134  if ( !insertConditionIntoMap(caloCond, chipNr)) {
2135 
2136  edm::LogError("TriggerMenuXmlParser")
2137  << " Error: duplicate condition (" << name << ")"
2138  << std::endl;
2139 
2140  return false;
2141  }
2142  else {
2143 
2144  if (corrFlag) {
2145  (m_corCaloTemplate[chipNr]).push_back(caloCond);
2146  }
2147  else {
2148  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
2149  }
2150 
2151  }
2152 
2153  LogDebug("l1t|Global")
2154  << "\n intGEq = " << intGEq
2155  << " nrObj = " << nrObj
2156  << "\n ****************************************** "
2157  << std::endl;
2158 
2159 
2160  //
2161  return true;
2162 }
2163 
2176  XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& name,
2177  unsigned int chipNr, const bool corrFlag) {
2178 
2179  XERCES_CPP_NAMESPACE_USE
2180 
2181  /*
2182  // get condition, particle name and type name
2183  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2184  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2185  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2186 
2187  // determine object type type
2188  L1GtObject energySumObjType;
2189  GtConditionType cType;
2190 
2191  if ((particle == m_xmlConditionAttrObjectETM) && (type == m_xmlConditionAttrObjectETM)) {
2192 
2193  energySumObjType = ETM;
2194  cType = TypeETM;
2195 
2196  }
2197  else if ((particle == m_xmlConditionAttrObjectETT) && (type == m_xmlConditionAttrObjectETT)) {
2198 
2199  energySumObjType = ETT;
2200  cType = TypeETT;
2201 
2202  }
2203  else if ((particle == m_xmlConditionAttrObjectHTT) && (type == m_xmlConditionAttrObjectHTT)) {
2204 
2205  energySumObjType = HTT;
2206  cType = TypeHTT;
2207 
2208  }
2209  else if ((particle == m_xmlConditionAttrObjectHTM) && (type == m_xmlConditionAttrObjectHTM)) {
2210 
2211  energySumObjType = HTM;
2212  cType = TypeHTM;
2213 
2214  }
2215  else {
2216  edm::LogError("TriggerMenuXmlParser")
2217  << "Wrong particle or type for energy-sum condition (" << particle << ", " << type
2218  << ")" << std::endl;
2219  return false;
2220  }
2221 
2222  // global object
2223  int nrObj = 1;
2224 
2225  // get greater equal flag
2226 
2227  int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
2228  if (intGEq < 0) {
2229  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2230  << std::endl;
2231  return false;
2232  }
2233  // set the boolean value for the ge_eq mode
2234  bool gEq = (intGEq != 0);
2235 
2236  // get values
2237 
2238  // temporary storage of the parameters
2239  std::vector<L1GtEnergySumTemplate::ObjectParameter> objParameter(nrObj);
2240 
2241  // need at least two values for phi
2242  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
2243 
2244  // get etThreshold values and fill into structure
2245  if ( !getConditionChildValuesOld(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
2246  return false;
2247  }
2248 
2249  for (int i = 0; i < nrObj; i++) {
2250  objParameter[i].etThreshold = tmpValues[i];
2251 
2252  //LogTrace("TriggerMenuXmlParser")
2253  //<< " EnergySum ET high threshold (hex) for energySum object " << i << " = "
2254  //<< std::hex << objParameter[i].etThreshold << std::dec
2255  //<< std::endl;
2256 
2257  // for ETM and HTM read phi value
2258  // phi is larger than 64 bits for ETM - it needs two 64bits words
2259  // phi is less than 64 bits for HTM - it needs one 64bits word
2260  if (energySumObjType == ETM) {
2261 
2262  if (!getXMLHexTextValue128Old(
2263  findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0], tmpValues[1])) {
2264  edm::LogError("TriggerMenuXmlParser")
2265  << " Could not get phi for ETM condition (" << name << ")" << std::endl;
2266  return false;
2267  }
2268 
2269  objParameter[i].phiRange0Word = tmpValues[0];
2270  objParameter[i].phiRange1Word = tmpValues[1];
2271 
2272  } else if (energySumObjType == HTM) {
2273 
2274  if (!getXMLHexTextValueOld(findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0])) {
2275  edm::LogError("TriggerMenuXmlParser")
2276  << " Could not get phi for HTM condition (" << name << ")" << std::endl;
2277  return false;
2278  }
2279 
2280  objParameter[i].phiRange0Word = tmpValues[0];
2281 
2282  }
2283 
2284  // get energyOverflow logical flag and fill into structure
2285  DOMNode* n1;
2286  if ( (n1 = findXMLChild(node->getFirstChild(), m_xmlTagEtThreshold)) == 0) {
2287  edm::LogError("TriggerMenuXmlParser")
2288  << " Could not get energyOverflow for EnergySum condition (" << name << ")"
2289  << std::endl;
2290  return false;
2291  }
2292  if ( (n1 = findXMLChild(n1->getFirstChild(), m_xmlTagEnergyOverflow)) == 0) {
2293  edm::LogError("TriggerMenuXmlParser")
2294  << " Could not get energyOverflow for EnergySum condition (" << name << ")"
2295  << std::endl;
2296  return false;
2297  }
2298 
2299  int tmpInt = getBitFromNode(n1);
2300  if (tmpInt == 0) {
2301  objParameter[i].energyOverflow = false;
2302 
2303  //LogTrace("TriggerMenuXmlParser")
2304  //<< " EnergySum energyOverflow logical flag (hex) = "
2305  //<< std::hex << objParameter[i].energyOverflow << std::dec
2306  //<< std::endl;
2307  }
2308  else if (tmpInt == 1) {
2309  objParameter[i].energyOverflow = true;
2310 
2311  //LogTrace("TriggerMenuXmlParser")
2312  //<< " EnergySum energyOverflow logical flag (hex) = "
2313  //<< std::hex << objParameter[i].energyOverflow << std::dec
2314  //<< std::endl;
2315  }
2316  else {
2317  LogTrace("TriggerMenuXmlParser")
2318  << " EnergySum energyOverflow logical flag (hex) = " << std::hex << tmpInt
2319  << std::dec << " - wrong value! " << std::endl;
2320  return false;
2321  }
2322 
2323  }
2324 
2325  // object types - all same energySumObjType
2326  std::vector<L1GtObject> objType(nrObj, energySumObjType);
2327 
2328  // now create a new energySum condition
2329 
2330  L1GtEnergySumTemplate energySumCond(name);
2331 
2332  energySumCond.setCondType(cType);
2333  energySumCond.setObjectType(objType);
2334  energySumCond.setCondGEq(gEq);
2335  energySumCond.setCondChipNr(chipNr);
2336 
2337  energySumCond.setConditionParameter(objParameter);
2338 
2339  if (edm::isDebugEnabled() ) {
2340 
2341  std::ostringstream myCoutStream;
2342  energySumCond.print(myCoutStream);
2343  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2344 
2345  }
2346 
2347  // insert condition into the map
2348  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2349 
2350  edm::LogError("TriggerMenuXmlParser")
2351  << " Error: duplicate condition (" << name << ")"
2352  << std::endl;
2353 
2354  return false;
2355  }
2356  else {
2357 
2358  if (corrFlag) {
2359  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2360 
2361  }
2362  else {
2363  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
2364  }
2365 
2366  }
2367  */
2368 
2369  //
2370  return true;
2371 }
2372 
2385 bool l1t::TriggerMenuXmlParser::parseJetCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
2386  const std::string& name, unsigned int chipNr) {
2387 
2388  XERCES_CPP_NAMESPACE_USE
2389 
2390  /*
2391  // get condition, particle name and type name
2392  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2393  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2394  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2395 
2396  if (particle != m_xmlConditionAttrObjectJetCounts) {
2397  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for JetCounts condition ("
2398  << particle << ")" << std::endl;
2399  return false;
2400  }
2401 
2402  // object type and condition type
2403  L1GtObject jetCountsObjType = JetCounts;
2404  GtConditionType cType = TypeJetCounts;
2405 
2406  // global object
2407  int nrObj = 1;
2408 
2409  // get greater equal flag
2410 
2411  int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
2412  if (intGEq < 0) {
2413  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2414  << std::endl;
2415  return false;
2416  }
2417  // set the boolean value for the ge_eq mode
2418  bool gEq = (intGEq != 0);
2419 
2420  // get values
2421 
2422  // temporary storage of the parameters
2423  std::vector<L1GtJetCountsTemplate::ObjectParameter> objParameter(nrObj);
2424 
2425  // get countIndex value and fill into structure
2426  // they are expressed in base 10 (values: 0 - m_numberL1JetCounts)
2427  char* endPtr = const_cast<char*>(type.c_str());
2428  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2429 
2430  if (*endPtr != 0) {
2431 
2432  LogDebug("TriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
2433  << std::endl;
2434 
2435  return false;
2436  }
2437 
2438  // test if count index is out of range
2439  if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1JetCounts))) {
2440  LogDebug("TriggerMenuXmlParser") << "Count index " << typeInt
2441  << " outside range [0, " << m_numberL1JetCounts << "]" << std::endl;
2442 
2443  return false;
2444  }
2445 
2446  objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
2447 
2448  // get count threshold values and fill into structure
2449  std::vector<boost::uint64_t> tmpValues(nrObj);
2450 
2451  if ( !getConditionChildValuesOld(node, m_xmlTagCountThreshold, nrObj, tmpValues) ) {
2452  return false;
2453  }
2454 
2455  for (int i = 0; i < nrObj; i++) {
2456  objParameter[i].countThreshold = tmpValues[i];
2457 
2458  //LogTrace("TriggerMenuXmlParser")
2459  //<< " JetCounts count threshold (hex) for JetCounts object " << i << " = "
2460  //<< std::hex << objParameter[i].countThreshold << std::dec
2461  //<< std::endl;
2462 
2463  // TODO FIXME un-comment when tag available in XML file
2464 
2465  // // get countOverflow logical flag and fill into structure
2466  // DOMNode* n1;
2467  // if ( (n1 = findXMLChild(node->getFirstChild(), m_xmlTagCountThreshold)) == 0) {
2468  // edm::LogError("TriggerMenuXmlParser")
2469  // << " Could not get countOverflow for JetCounts condition ("
2470  // << name << ")"
2471  // << std::endl;
2472  // return false;
2473  // }
2474  // if ( (n1 = findXMLChild(n1->getFirstChild(), m_xmlTagCountThreshold)) == 0) {
2475  // edm::LogError("TriggerMenuXmlParser")
2476  // << " Could not get countOverflow for JetCounts condition ("
2477  // << name << ")"
2478  // << std::endl;
2479  // return false;
2480  // }
2481  //
2482  // int tmpInt = getBitFromNode(n1);
2483  // if (tmpInt == 0) {
2484  // objParameter[i].countOverflow = false;
2485  //
2486  // LogTrace("TriggerMenuXmlParser")
2487  // << " JetCounts countOverflow logical flag (hex) = "
2488  // << std::hex << objParameter[i].countOverflow << std::dec
2489  // << std::endl;
2490  // } else if (tmpInt == 1) {
2491  // objParameter[i].countOverflow = true;
2492  //
2493  // LogTrace("TriggerMenuXmlParser")
2494  // << " JetCounts countOverflow logical flag (hex) = "
2495  // << std::hex << objParameter[i].countOverflow << std::dec
2496  // << std::endl;
2497  // } else {
2498  // LogTrace("TriggerMenuXmlParser")
2499  // << " JetCounts countOverflow logical flag (hex) = "
2500  // << std::hex << tmpInt << std::dec << " - wrong value! "
2501  // << std::endl;
2502  // return false;
2503  // }
2504 
2505  }
2506 
2507  // object types - all same objType
2508  std::vector<L1GtObject> objType(nrObj, jetCountsObjType);
2509 
2510  // now create a new JetCounts condition
2511 
2512  L1GtJetCountsTemplate jetCountsCond(name);
2513 
2514  jetCountsCond.setCondType(cType);
2515  jetCountsCond.setObjectType(objType);
2516  jetCountsCond.setCondGEq(gEq);
2517  jetCountsCond.setCondChipNr(chipNr);
2518 
2519  jetCountsCond.setConditionParameter(objParameter);
2520 
2521  if (edm::isDebugEnabled() ) {
2522 
2523  std::ostringstream myCoutStream;
2524  jetCountsCond.print(myCoutStream);
2525  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2526 
2527  }
2528 
2529  // insert condition into the map
2530  if ( !insertConditionIntoMap(jetCountsCond, chipNr)) {
2531 
2532  edm::LogError("TriggerMenuXmlParser") << " Error: duplicate condition (" << name
2533  << ")" << std::endl;
2534 
2535  return false;
2536  } else {
2537 
2538  (m_vecJetCountsTemplate[chipNr]).push_back(jetCountsCond);
2539 
2540  }
2541 
2542  */
2543  //
2544  return true;
2545 }
2546 
2559 bool l1t::TriggerMenuXmlParser::parseCastor(XERCES_CPP_NAMESPACE::DOMNode* node,
2560  const std::string& name, unsigned int chipNr) {
2561 
2562  XERCES_CPP_NAMESPACE_USE
2563 
2564  /*
2565  // get condition, particle name and type name
2566  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2567  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2568  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2569 
2570  if (particle != m_xmlConditionAttrObjectCastor) {
2571  edm::LogError("TriggerMenuXmlParser")
2572  << "\nError: wrong particle for Castor condition ("
2573  << particle << ")" << std::endl;
2574  return false;
2575  }
2576 
2577  // object type and condition type
2578  // object type - irrelevant for CASTOR conditions
2579  GtConditionType cType = TypeCastor;
2580 
2581  // no objects for CASTOR conditions
2582 
2583  // set the boolean value for the ge_eq mode - irrelevant for CASTOR conditions
2584  bool gEq = false;
2585 
2586  // now create a new CASTOR condition
2587 
2588  L1GtCastorTemplate castorCond(name);
2589 
2590  castorCond.setCondType(cType);
2591  castorCond.setCondGEq(gEq);
2592  castorCond.setCondChipNr(chipNr);
2593 
2594 
2595  if (edm::isDebugEnabled() ) {
2596 
2597  std::ostringstream myCoutStream;
2598  castorCond.print(myCoutStream);
2599  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2600 
2601  }
2602 
2603  // insert condition into the map
2604  if ( !insertConditionIntoMap(castorCond, chipNr)) {
2605 
2606  edm::LogError("TriggerMenuXmlParser")
2607  << " Error: duplicate condition (" << name
2608  << ")" << std::endl;
2609 
2610  return false;
2611  } else {
2612 
2613  (m_vecCastorTemplate[chipNr]).push_back(castorCond);
2614 
2615  }
2616  */
2617 
2618  //
2619  return true;
2620 }
2621 
2622 
2635 bool l1t::TriggerMenuXmlParser::parseHfBitCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
2636  const std::string& name, unsigned int chipNr) {
2637 
2638  XERCES_CPP_NAMESPACE_USE
2639 
2640  /*
2641  // get condition, particle name and type name
2642  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2643  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2644  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2645 
2646  if (particle != m_xmlConditionAttrObjectHfBitCounts) {
2647  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for HfBitCounts condition ("
2648  << particle << ")" << std::endl;
2649  return false;
2650  }
2651 
2652  // object type and condition type
2653  L1GtObject hfBitCountsObjType = HfBitCounts;
2654  GtConditionType cType = TypeHfBitCounts;
2655 
2656  // global object
2657  int nrObj = 1;
2658 
2659  // get greater equal flag
2660 
2661  int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
2662  if (intGEq < 0) {
2663  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2664  << std::endl;
2665  return false;
2666  }
2667  // set the boolean value for the ge_eq mode
2668  bool gEq = (intGEq != 0);
2669 
2670  // get values
2671 
2672  // temporary storage of the parameters
2673  std::vector<L1GtHfBitCountsTemplate::ObjectParameter> objParameter(nrObj);
2674 
2675  // get countIndex value and fill into structure
2676  // they are expressed in base 10
2677  char* endPtr = const_cast<char*>(type.c_str());
2678  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2679 
2680  if (*endPtr != 0) {
2681 
2682  LogDebug("TriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
2683  << std::endl;
2684 
2685  return false;
2686  }
2687 
2688  // test if count index is out of range FIXME introduce m_numberL1HfBitCounts?
2689  //if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1HfBitCounts))) {
2690  // LogDebug("TriggerMenuXmlParser") << "Count index " << typeInt
2691  // << " outside range [0, " << m_numberL1HfBitCounts << "]" << std::endl;
2692  //
2693  // return false;
2694  //}
2695 
2696  objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
2697 
2698  // get count threshold values and fill into structure
2699  std::vector<boost::uint64_t> tmpValues(nrObj);
2700 
2701  if ( !getConditionChildValuesOld(node, m_xmlTagCountThreshold, nrObj, tmpValues) ) {
2702  return false;
2703  }
2704 
2705  for (int i = 0; i < nrObj; i++) {
2706  objParameter[i].countThreshold = tmpValues[i];
2707 
2708  //LogTrace("TriggerMenuXmlParser")
2709  //<< " HfBitCounts count threshold (hex) for HfBitCounts object " << i << " = "
2710  //<< std::hex << objParameter[i].countThreshold << std::dec
2711  //<< std::endl;
2712 
2713  }
2714 
2715  // object types - all same objType
2716  std::vector<L1GtObject> objType(nrObj, hfBitCountsObjType);
2717 
2718  // now create a new HfBitCounts condition
2719 
2720  L1GtHfBitCountsTemplate hfBitCountsCond(name);
2721 
2722  hfBitCountsCond.setCondType(cType);
2723  hfBitCountsCond.setObjectType(objType);
2724  hfBitCountsCond.setCondGEq(gEq);
2725  hfBitCountsCond.setCondChipNr(chipNr);
2726 
2727  hfBitCountsCond.setConditionParameter(objParameter);
2728 
2729  if (edm::isDebugEnabled() ) {
2730 
2731  std::ostringstream myCoutStream;
2732  hfBitCountsCond.print(myCoutStream);
2733  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2734 
2735  }
2736 
2737  // insert condition into the map
2738  if ( !insertConditionIntoMap(hfBitCountsCond, chipNr)) {
2739 
2740  edm::LogError("TriggerMenuXmlParser") << " Error: duplicate condition (" << name
2741  << ")" << std::endl;
2742 
2743  return false;
2744  } else {
2745 
2746  (m_vecHfBitCountsTemplate[chipNr]).push_back(hfBitCountsCond);
2747 
2748  }
2749 
2750  */
2751  //
2752  return true;
2753 }
2754 
2755 
2768 bool l1t::TriggerMenuXmlParser::parseHfRingEtSums(XERCES_CPP_NAMESPACE::DOMNode* node,
2769  const std::string& name, unsigned int chipNr) {
2770 
2771  XERCES_CPP_NAMESPACE_USE
2772 
2773  /*
2774  // get condition, particle name and type name
2775  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2776  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2777  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2778 
2779  if (particle != m_xmlConditionAttrObjectHfRingEtSums) {
2780  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for HfRingEtSums condition ("
2781  << particle << ")" << std::endl;
2782  return false;
2783  }
2784 
2785  // object type and condition type
2786  L1GtObject hfRingEtSumsObjType = HfRingEtSums;
2787  GtConditionType cType = TypeHfRingEtSums;
2788 
2789  // global object
2790  int nrObj = 1;
2791 
2792  // get greater equal flag
2793 
2794  int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
2795  if (intGEq < 0) {
2796  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2797  << std::endl;
2798  return false;
2799  }
2800  // set the boolean value for the ge_eq mode
2801  bool gEq = (intGEq != 0);
2802 
2803  // get values
2804 
2805  // temporary storage of the parameters
2806  std::vector<L1GtHfRingEtSumsTemplate::ObjectParameter> objParameter(nrObj);
2807 
2808  // get etSumIndex value and fill into structure
2809  // they are expressed in base 10
2810  char* endPtr = const_cast<char*>(type.c_str());
2811  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2812 
2813  if (*endPtr != 0) {
2814 
2815  LogDebug("TriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
2816  << std::endl;
2817 
2818  return false;
2819  }
2820 
2821  // test if ET sum index is out of range FIXME introduce m_numberL1HfRingEtSums?
2822  //if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1HfRingEtSums))) {
2823  // LogDebug("TriggerMenuXmlParser") << "Count index " << typeInt
2824  // << " outside range [0, " << m_numberL1HfRingEtSums << "]" << std::endl;
2825  //
2826  // return false;
2827  //}
2828 
2829  objParameter[0].etSumIndex = static_cast<unsigned int>(typeInt);
2830 
2831  // get ET sum threshold values and fill into structure
2832  std::vector<boost::uint64_t> tmpValues(nrObj);
2833 
2834  if ( !getConditionChildValuesOld(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
2835  return false;
2836  }
2837 
2838  for (int i = 0; i < nrObj; i++) {
2839  objParameter[i].etSumThreshold = tmpValues[i];
2840 
2841  //LogTrace("TriggerMenuXmlParser")
2842  //<< " HfRingEtSums count threshold (hex) for HfRingEtSums object " << i << " = "
2843  //<< std::hex << objParameter[i].etSumThreshold << std::dec
2844  //<< std::endl;
2845 
2846  }
2847 
2848  // object types - all same objType
2849  std::vector<L1GtObject> objType(nrObj, hfRingEtSumsObjType);
2850 
2851  // now create a new HfRingEtSums condition
2852 
2853  L1GtHfRingEtSumsTemplate hfRingEtSumsCond(name);
2854 
2855  hfRingEtSumsCond.setCondType(cType);
2856  hfRingEtSumsCond.setObjectType(objType);
2857  hfRingEtSumsCond.setCondGEq(gEq);
2858  hfRingEtSumsCond.setCondChipNr(chipNr);
2859 
2860  hfRingEtSumsCond.setConditionParameter(objParameter);
2861 
2862  if (edm::isDebugEnabled() ) {
2863 
2864  std::ostringstream myCoutStream;
2865  hfRingEtSumsCond.print(myCoutStream);
2866  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2867 
2868  }
2869 
2870  // insert condition into the map
2871  if ( !insertConditionIntoMap(hfRingEtSumsCond, chipNr)) {
2872 
2873  edm::LogError("TriggerMenuXmlParser") << " Error: duplicate condition (" << name
2874  << ")" << std::endl;
2875 
2876  return false;
2877  } else {
2878 
2879  (m_vecHfRingEtSumsTemplate[chipNr]).push_back(hfRingEtSumsCond);
2880 
2881  }
2882  */
2883 
2884  //
2885  return true;
2886 }
2887 
2900 bool l1t::TriggerMenuXmlParser::parseBptx(XERCES_CPP_NAMESPACE::DOMNode* node,
2901  const std::string& name, unsigned int chipNr) {
2902 
2903  XERCES_CPP_NAMESPACE_USE
2904 
2905  /*
2906  // get condition, particle name and type name
2907  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2908  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2909  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2910 
2911  if (particle != m_xmlConditionAttrObjectBptx) {
2912  edm::LogError("TriggerMenuXmlParser")
2913  << "\nError: wrong particle for Bptx condition ("
2914  << particle << ")" << std::endl;
2915  return false;
2916  }
2917 
2918  // object type and condition type
2919  // object type - irrelevant for BPTX conditions
2920  GtConditionType cType = TypeBptx;
2921 
2922  // no objects for BPTX conditions
2923 
2924  // set the boolean value for the ge_eq mode - irrelevant for BPTX conditions
2925  bool gEq = false;
2926 
2927  // now create a new BPTX condition
2928 
2929  L1GtBptxTemplate bptxCond(name);
2930 
2931  bptxCond.setCondType(cType);
2932  bptxCond.setCondGEq(gEq);
2933  bptxCond.setCondChipNr(chipNr);
2934 
2935  LogTrace("TriggerMenuXmlParser") << bptxCond << "\n" << std::endl;
2936 
2937  // insert condition into the map
2938  if ( !insertConditionIntoMap(bptxCond, chipNr)) {
2939 
2940  edm::LogError("TriggerMenuXmlParser")
2941  << " Error: duplicate condition (" << name
2942  << ")" << std::endl;
2943 
2944  return false;
2945  } else {
2946 
2947  (m_vecBptxTemplate[chipNr]).push_back(bptxCond);
2948 
2949  }
2950  */
2951 
2952  //
2953  return true;
2954 }
2955 
2956 
2969 bool l1t::TriggerMenuXmlParser::parseExternal(XERCES_CPP_NAMESPACE::DOMNode* node,
2970  const std::string& name, unsigned int chipNr) {
2971 
2972  XERCES_CPP_NAMESPACE_USE
2973 
2974  /*
2975  // get condition, particle name and type name
2976  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2977  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2978  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2979 
2980  if (particle != m_xmlConditionAttrObjectGtExternal) {
2981  edm::LogError("TriggerMenuXmlParser")
2982  << "\nError: wrong particle for External condition ("
2983  << particle << ")" << std::endl;
2984  return false;
2985  }
2986 
2987  // object type and condition type
2988  // object type - irrelevant for External conditions
2989  GtConditionType cType = TypeExternal;
2990 
2991  // no objects for External conditions
2992 
2993  // set the boolean value for the ge_eq mode - irrelevant for External conditions
2994  bool gEq = false;
2995 
2996  // now create a new External condition
2997 
2998  L1GtExternalTemplate externalCond(name);
2999 
3000  externalCond.setCondType(cType);
3001  externalCond.setCondGEq(gEq);
3002  externalCond.setCondChipNr(chipNr);
3003 
3004  LogTrace("TriggerMenuXmlParser") << externalCond << "\n" << std::endl;
3005 
3006  // insert condition into the map
3007  if ( !insertConditionIntoMap(externalCond, chipNr)) {
3008 
3009  edm::LogError("TriggerMenuXmlParser")
3010  << " Error: duplicate condition (" << name
3011  << ")" << std::endl;
3012 
3013  return false;
3014  } else {
3015 
3016  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
3017 
3018  }
3019  */
3020 
3021  //
3022  return true;
3023 }
3024 
3025 
3039  XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& name,
3040  unsigned int chipNr) {
3041 
3042  XERCES_CPP_NAMESPACE_USE
3043 
3044  // create a new correlation condition
3045  CorrelationTemplate correlationCond(name);
3046 
3047  // check that the condition does not exist already in the map
3048  if ( !insertConditionIntoMap(correlationCond, chipNr)) {
3049 
3050  edm::LogError("TriggerMenuXmlParser")
3051  << " Error: duplicate correlation condition (" << name << ")"
3052  << std::endl;
3053 
3054  return false;
3055  }
3056 
3057  /*
3058  // get condition, particle name and type name
3059  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
3060  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
3061  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
3062 
3063  std::cout << " ****************************************** " << std::endl;
3064  std::cout << " DARRENS TEST OUTPUT (in parseCorrelation) " << std::endl;
3065  std::cout << " condition = " << condition << std::endl;
3066  std::cout << " particle = " << particle << std::endl;
3067  std::cout << " type = " << type << std::endl;
3068  std::cout << " name = " << name << std::endl;
3069 
3070  LogTrace("TriggerMenuXmlParser") << " Condition category: "
3071  << condition << ", particle: " << particle << ", type: " << type
3072  << "\n" << std::endl;
3073 
3074  // condition type
3075  GtConditionType cType = l1t::Type2cor;
3076 
3077  // two objects (for sure)
3078  const int nrObj = 2;
3079 
3080  // object types and greater equal flag - filled in the loop
3081  int intGEq[nrObj] = { -1, -1 };
3082  std::vector<L1GtObject> objType(nrObj);
3083  std::vector<GtConditionCategory> condCateg(nrObj);
3084 
3085  // correlation flag and index in the cor*vector
3086  const bool corrFlag = true;
3087  int corrIndexVal[nrObj] = { -1, -1 };
3088 
3089  // get the subconditions
3090 
3091  DOMNode* conditionsNode = node->getFirstChild();
3092  std::string conditionNameNodeName;
3093  conditionsNode = findXMLChild(conditionsNode, "", true,
3094  &conditionNameNodeName);
3095 
3096 
3097  for (int iSubCond = 0; iSubCond < nrObj; ++iSubCond) {
3098 
3099  // get for sub-condition: category, object name and type name and condition name
3100  condition = getXMLAttribute(conditionsNode, m_xmlConditionAttrCondition);
3101  particle = getXMLAttribute(conditionsNode, m_xmlConditionAttrObject);
3102  type = getXMLAttribute(conditionsNode, m_xmlConditionAttrType);
3103 
3104  LogTrace("TriggerMenuXmlParser") << " Sub-condition category: "
3105  << condition << ", particle: " << particle << ", type: "
3106  << type << ", name: " << conditionNameNodeName << "\n"
3107  << std::endl;
3108 
3109  // call the appropriate function for this condition
3110  if (condition == m_xmlConditionAttrConditionMuon) {
3111  if (!parseMuon(conditionsNode, conditionNameNodeName, chipNr,
3112  corrFlag)) {
3113  edm::LogError("TriggerMenuXmlParser")
3114  << "Error parsing sub-condition " << condition << ")"
3115  << " with name " << conditionNameNodeName << std::endl;
3116 
3117  }
3118 
3119  // get greater equal flag
3120  intGEq[iSubCond] = getGEqFlag(conditionsNode,
3121  m_xmlTagPtHighThreshold);
3122  if (intGEq[iSubCond] < 0) {
3123  edm::LogError("TriggerMenuXmlParser")
3124  << "Error getting \"greater or equal\" flag"
3125  << " for sub-condition " << conditionNameNodeName
3126  << " for the correlation condition " << name
3127  << std::endl;
3128  return false;
3129  }
3130 
3131  // set object type and sub-condition category
3132  objType[iSubCond] = Mu;
3133  condCateg[iSubCond] = CondMuon;
3134  corrIndexVal[iSubCond] = (m_corMuonTemplate[chipNr]).size() - 1;
3135 
3136  }
3137  else if (condition == m_xmlConditionAttrConditionCalo) {
3138  if (!parseCalo(conditionsNode, conditionNameNodeName, chipNr,
3139  corrFlag)) {
3140  edm::LogError("TriggerMenuXmlParser")
3141  << "Error parsing sub-condition " << condition << ")"
3142  << " with name " << conditionNameNodeName << std::endl;
3143 
3144  }
3145 
3146  // get greater equal flag
3147  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
3148  if (intGEq[iSubCond] < 0) {
3149  edm::LogError("TriggerMenuXmlParser")
3150  << "Error getting \"greater or equal\" flag"
3151  << " for sub-condition " << conditionNameNodeName
3152  << " for the correlation condition " << name
3153  << std::endl;
3154  return false;
3155  }
3156 
3157  // set object type and sub-condition category
3158  if (particle == m_xmlConditionAttrObjectNoIsoEG) {
3159  objType[iSubCond] = NoIsoEG;
3160  }
3161  else if (particle == m_xmlConditionAttrObjectIsoEG) {
3162  objType[iSubCond] = IsoEG;
3163  }
3164  else if (particle == m_xmlConditionAttrObjectCenJet) {
3165  objType[iSubCond] = CenJet;
3166  }
3167  else if (particle == m_xmlConditionAttrObjectTauJet) {
3168  objType[iSubCond] = TauJet;
3169  }
3170  else if (particle == m_xmlConditionAttrObjectForJet) {
3171  objType[iSubCond] = ForJet;
3172  }
3173  else {
3174  edm::LogError("TriggerMenuXmlParser")
3175  << "Wrong object type " << particle
3176  << " for sub-condition " << conditionNameNodeName
3177  << " from the correlation condition " << name
3178  << std::endl;
3179  return false;
3180  }
3181 
3182  condCateg[iSubCond] = CondCalo;
3183  corrIndexVal[iSubCond] = (m_corCaloTemplate[chipNr]).size() - 1;
3184 
3185  }
3186  else if (condition == m_xmlConditionAttrConditionEnergySum) {
3187  if (!parseEnergySum(conditionsNode, conditionNameNodeName, chipNr,
3188  corrFlag)) {
3189  edm::LogError("TriggerMenuXmlParser")
3190  << "Error parsing sub-condition " << condition << ")"
3191  << " with name " << conditionNameNodeName << std::endl;
3192 
3193  }
3194 
3195  // get greater equal flag
3196  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
3197  if (intGEq[iSubCond] < 0) {
3198  edm::LogError("TriggerMenuXmlParser")
3199  << "Error getting \"greater or equal\" flag"
3200  << " for sub-condition " << conditionNameNodeName
3201  << " for the correlation condition " << name
3202  << std::endl;
3203  return false;
3204  }
3205 
3206  // set object type and sub-condition category
3207  if (particle == m_xmlConditionAttrObjectETM) {
3208  objType[iSubCond] = ETM;
3209  }
3210  else if (particle == m_xmlConditionAttrObjectETT) {
3211  objType[iSubCond] = ETT;
3212  }
3213  else if (particle == m_xmlConditionAttrObjectHTT) {
3214  objType[iSubCond] = HTT;
3215  }
3216  else if (particle == m_xmlConditionAttrObjectHTM) {
3217  objType[iSubCond] = HTM;
3218  }
3219  else {
3220  edm::LogError("TriggerMenuXmlParser")
3221  << "Wrong object type " << particle
3222  << " for sub-condition " << conditionNameNodeName
3223  << " from the correlation condition " << name
3224  << std::endl;
3225  return false;
3226  }
3227 
3228  condCateg[iSubCond] = CondEnergySum;
3229  corrIndexVal[iSubCond] = (m_corEnergySumTemplate[chipNr]).size() - 1;
3230 
3231  }
3232  else {
3233  edm::LogError("TriggerMenuXmlParser")
3234  << "Unknown or un-adequate sub-condition (" << condition
3235  << ")" << " with name " << conditionNameNodeName
3236  << " for the correlation condition " << name << std::endl;
3237 
3238  return false;
3239  }
3240 
3241  conditionsNode = findXMLChild(conditionsNode->getNextSibling(), "",
3242  true, &conditionNameNodeName);
3243 
3244  }
3245 
3246  // get greater equal flag for the correlation condition
3247  bool gEq = true;
3248  if (intGEq[0] != intGEq[1]) {
3249  edm::LogError("TriggerMenuXmlParser")
3250  << "Inconsistent GEq flags for sub-conditions (" << condition
3251  << ")" << " with name " << conditionNameNodeName
3252  << " for the correlation condition " << name << std::endl;
3253  return false;
3254 
3255  }
3256  else {
3257  gEq = (intGEq[0] != 0);
3258 
3259  }
3260 
3261  // correlation parameters
3262 
3263  // temporary storage of the parameters
3264  CorrelationTemplate::CorrelationParameter corrParameter;
3265  std::vector<boost::uint64_t> tmpValues(nrObj);
3266 
3267  // get deltaEtaRange
3268 // if ( !getConditionChildValuesOld(node, m_xmlTagDeltaEta, 1, tmpValues) ) {
3269 // return false;
3270 // }
3271 //
3272 // corrParameter.deltaEtaRange = tmpValues[0];
3273 
3274  XERCES_CPP_NAMESPACE::DOMNode* node1 = findXMLChild(node->getFirstChild(),
3275  m_xmlTagDeltaEta);
3276 
3277  std::string valString;
3278 
3279  if (node1 == 0) {
3280  edm::LogError("TriggerMenuXmlParser")
3281  << " Could not get deltaEta for correlation condition "
3282  << name << ". " << std::endl;
3283  return false;
3284  }
3285  else {
3286  valString = getXMLTextValue(node1);
3287  }
3288 
3289  corrParameter.deltaEtaRange = valString;
3290 
3291 // // deltaPhi is larger than 64bit
3292 // if ( !getXMLHexTextValue128Old(findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi),
3293 // tmpValues[0], tmpValues[1])) {
3294 // edm::LogError("TriggerMenuXmlParser")
3295 // << " Could not get deltaPhi for correlation condition " << name << ". "
3296 // << std::endl;
3297 // return false;
3298 // }
3299 //
3300 // corrParameter.deltaPhiRange = tmpValues[0];
3301 
3302  node1 = findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi);
3303 
3304  if (node1 == 0) {
3305  return false;
3306  edm::LogError("TriggerMenuXmlParser")
3307  << " Could not get deltaPhi for correlation condition "
3308  << name << ". " << std::endl;
3309  }
3310  else {
3311  valString = getXMLTextValue(node1);
3312  }
3313 
3314  corrParameter.deltaPhiRange = valString;
3315 
3316  // get maximum number of bits for delta phi
3317  //LogTrace("TriggerMenuXmlParser")
3318  //<< " Counting deltaPhiMaxbits"
3319  //<< std::endl;
3320 
3321  unsigned int maxbits;
3322 
3323  if ( !countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits) ) {
3324  return false;
3325  }
3326 
3327  corrParameter.deltaPhiMaxbits = maxbits;
3328  //LogTrace("TriggerMenuXmlParser")
3329  //<< " deltaPhiMaxbits (dec) = " << maxbits
3330  //<< std::endl;
3331 
3332 
3333  // fill the correlation condition
3334  correlationCond.setCondType(cType);
3335  correlationCond.setObjectType(objType);
3336  correlationCond.setCondGEq(gEq);
3337  correlationCond.setCondChipNr(chipNr);
3338 
3339  correlationCond.setCond0Category(condCateg[0]);
3340  correlationCond.setCond1Category(condCateg[1]);
3341 
3342  correlationCond.setCond0Index(corrIndexVal[0]);
3343  correlationCond.setCond1Index(corrIndexVal[1]);
3344 
3345  correlationCond.setCorrelationParameter(corrParameter);
3346 
3347  if (edm::isDebugEnabled() ) {
3348 
3349  std::ostringstream myCoutStream;
3350  correlationCond.print(myCoutStream);
3351  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n"
3352  << std::endl;
3353 
3354  }
3355 
3356  // insert condition into the map
3357  // condition is not duplicate, check was done at the beginning
3358 
3359  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
3360 
3361  */
3362  //
3363  return true;
3364 }
3365 
3374 bool l1t::TriggerMenuXmlParser::parseId( l1t::Meta meta ) {
3375 
3376  XERCES_CPP_NAMESPACE_USE
3377 
3378 // DOMNode* doc = parser->getDocument();
3379 // DOMNode* n1 = doc->getFirstChild();
3380 
3381 // // we assume that the first child is m_xmlTagDef because it was checked in workXML
3382 
3383 // DOMNode* headerNode = n1->getFirstChild();
3384 // if (headerNode == 0) {
3385 // edm::LogError("TriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef
3386 // << "> tag found." << std::endl;
3387 // return false;
3388 // }
3389 
3390 // headerNode = findXMLChild(headerNode, m_xmlTagHeader);
3391 // if (headerNode == 0) {
3392 
3393 // LogDebug("TriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagHeader
3394 // << "> tag" << "\n - No header information." << std::endl;
3395 
3396 // } else {
3397 
3398 // DOMNode* idNode = headerNode->getFirstChild();
3399 
3400 // // find menu interface name
3401 // idNode = findXMLChild(idNode, m_xmlTagMenuInterface);
3402 // if (idNode == 0) {
3403 
3404 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3405 // << m_xmlTagMenuInterface << "> tag"
3406 // << "\n - Trigger menu interface name derived from file name." << std::endl;
3407 
3408 // // set the name of the trigger menu interface: from beginning of file names
3409 // // until beginning of "_L1T_Scales"
3410 // size_t xmlPos = m_triggerMenuName.find("_L1T_Scales", 0);
3411 // if (xmlPos == std::string::npos) {
3412 // LogTrace("TriggerMenuXmlParser")
3413 // << "\n Warning: Could not find \"_L1T_Scales\" " << "string in file name"
3414 // << "\n - Trigger menu interface name set to file name." << std::endl;
3415 // m_triggerMenuInterface = m_triggerMenuName;
3416 
3417 // } else {
3418 // m_triggerMenuInterface = m_triggerMenuName;
3419 // m_triggerMenuInterface.erase(
3420 // m_triggerMenuInterface.begin(), m_triggerMenuInterface.begin() + xmlPos);
3421 // }
3422 
3423 // } else {
3424 // m_triggerMenuInterface = getXMLTextValue(idNode);
3425 // }
3426 
3427 // // find menu interface creation date
3428 // idNode = headerNode->getFirstChild();
3429 // idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDate);
3430 
3431 // if (idNode == 0) {
3432 
3433 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3434 // << m_xmlTagMenuInterfaceDate << "> tag" << "\n - No creation date."
3435 // << m_triggerMenuInterfaceDate << std::endl;
3436 
3437 // } else {
3438 
3439 // m_triggerMenuInterfaceDate = getXMLTextValue(idNode);
3440 // }
3441 
3442 // // find menu interface creation author
3443 // idNode = headerNode->getFirstChild();
3444 // idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceAuthor);
3445 
3446 // if (idNode == 0) {
3447 
3448 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3449 // << m_xmlTagMenuInterfaceAuthor << "> tag" << "\n - No creation author."
3450 // << m_triggerMenuInterfaceAuthor << std::endl;
3451 
3452 // } else {
3453 
3454 // m_triggerMenuInterfaceAuthor = getXMLTextValue(idNode);
3455 // }
3456 
3457 // // find menu interface description
3458 // idNode = headerNode->getFirstChild();
3459 // idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDescription);
3460 
3461 // if (idNode == 0) {
3462 
3463 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3464 // << m_xmlTagMenuInterfaceDescription << "> tag" << "\n - No description."
3465 // << m_triggerMenuInterfaceDescription << std::endl;
3466 
3467 // } else {
3468 
3469 // m_triggerMenuInterfaceDescription = getXMLTextValue(idNode);
3470 // }
3471 
3472 // // find menu creation date
3473 // idNode = headerNode->getFirstChild();
3474 // idNode = findXMLChild(idNode, m_xmlTagMenuDate);
3475 
3476 // if (idNode == 0) {
3477 
3478 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3479 // << m_xmlTagMenuDate << "> tag" << "\n - No creation date."
3480 // << m_triggerMenuDate << std::endl;
3481 
3482 // } else {
3483 
3484 // m_triggerMenuDate = getXMLTextValue(idNode);
3485 // }
3486 
3487 // // find menu creation author
3488 // idNode = headerNode->getFirstChild();
3489 // idNode = findXMLChild(idNode, m_xmlTagMenuAuthor);
3490 
3491 // if (idNode == 0) {
3492 
3493 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3494 // << m_xmlTagMenuAuthor << "> tag" << "\n - No creation author."
3495 // << m_triggerMenuAuthor << std::endl;
3496 
3497 // } else {
3498 
3499 // m_triggerMenuAuthor = getXMLTextValue(idNode);
3500 // }
3501 
3502 // // find menu description
3503 // idNode = headerNode->getFirstChild();
3504 // idNode = findXMLChild(idNode, m_xmlTagMenuDescription);
3505 
3506 // if (idNode == 0) {
3507 
3508 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3509 // << m_xmlTagMenuDescription << "> tag" << "\n - No description."
3510 // << m_triggerMenuDescription << std::endl;
3511 
3512 // } else {
3513 
3514 // m_triggerMenuDescription = getXMLTextValue(idNode);
3515 // }
3516 
3517 // // find algorithm implementation tag
3518 
3519 // idNode = headerNode->getFirstChild();
3520 
3521 // idNode = findXMLChild(idNode, m_xmlTagMenuAlgImpl);
3522 // if (idNode == 0) {
3523 
3524 // m_algorithmImplementation = "";
3525 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3526 // << m_xmlTagMenuAlgImpl << "> tag"
3527 // << "\n - Algorithm implementation tag set to empty string." << std::endl;
3528 
3529 // } else {
3530 
3531 // m_algorithmImplementation = getXMLTextValue(idNode);
3532 // }
3533 
3534 // // find DB key for L1 scales
3535 
3536 // idNode = headerNode->getFirstChild();
3537 
3538 // idNode = findXMLChild(idNode, m_xmlTagScaleDbKey);
3539 // if (idNode == 0) {
3540 
3541 // m_scaleDbKey = "NULL";
3542 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3543 // << m_xmlTagScaleDbKey << "> tag" << "\n - Scale key set to " << m_scaleDbKey
3544 // << " string." << std::endl;
3545 
3546 // } else {
3547 // m_scaleDbKey = getXMLTextValue(idNode);
3548 // }
3549 
3550 // }
3551 
3552 
3553 
3554  m_triggerMenuInterface = l1t2string( meta.name() );
3555  m_triggerMenuInterfaceDate = "2013-010-24T15:33:24";
3556  m_triggerMenuInterfaceAuthor = "Darren Puigh";
3557  m_triggerMenuInterfaceDescription = l1t2string( meta.description() );
3558 // m_algorithmImplementation = l1t2string( meta.firmwareVersion() );
3559 // m_triggerMenuDate = l1t2string( meta.changesDate() );
3560 // m_triggerMenuAuthor = l1t2string( meta.changesAuthor() );
3561  m_triggerMenuDescription = l1t2string( meta.description() );
3562  m_scaleDbKey = l1t2string( meta.scalesKey() );
3563 
3564 
3565  int cnt = 0;
3566  for( l1t::History::revision_const_iterator revision = meta.history().revision().begin();
3567  revision != meta.history().revision().end(); ++revision ){
3568 
3569  LogDebug("l1t|Global")
3570  << "\t Revision " << cnt
3571  << "\t\t author = " << l1t2string( revision->author() )
3572  << "\t\t datetime = " << l1t2string( revision->datetime() )
3573  << std::endl;
3574 
3575  if( cnt==0 ){
3576  m_triggerMenuDate = l1t2string( revision->datetime() );
3577  m_triggerMenuAuthor = l1t2string( revision->author() );
3578  }
3579  cnt++;
3580  }
3581 
3582  //LogDebug("TriggerMenuXmlParser")
3583  LogDebug("l1t|Global")
3584  << "\n Parsed values from XML file DRULES"
3585  << "\nL1 MenuInterface: " << m_triggerMenuInterface
3586  << "\nL1 MenuInterface - Creation date: " << m_triggerMenuInterfaceDate
3587  << "\nL1 MenuInterface - Creation author: " << m_triggerMenuInterfaceAuthor
3588  << "\nL1 MenuInterface - Description: " << m_triggerMenuInterfaceDescription
3589  << "\n"
3590  << "\nAlgorithm implementation tag: " << m_algorithmImplementation
3591  << "\n"
3592  << "\nL1 Menu - Creation date: " << m_triggerMenuDate
3593  << "\nL1 Menu - Creation author: " << m_triggerMenuAuthor
3594  << "\nL1 Menu - Description: " << m_triggerMenuDescription
3595  << std::endl;
3596 
3597 
3598  // set the trigger menu name
3599  // format:
3600  // L1MenuInterface/ScaleDbKey/AlgorithmImplementationTag
3601 
3602  std::string menuName = m_triggerMenuInterface + "/" + m_scaleDbKey + "/" + m_algorithmImplementation;
3603 
3604  if (menuName != m_triggerMenuName) {
3605 
3606  LogDebug("TriggerMenuXmlParser") << "\n Warning: Inconsistent L1 menu name:"
3607  << "\n from XML file name: " << m_triggerMenuName
3608  << "\n from XML tag: " << menuName << std::endl;
3609 
3610  if (m_triggerMenuInterface != "") {
3611  if (m_scaleDbKey == "NULL") {
3612  m_triggerMenuName = m_triggerMenuInterface;
3613  } else {
3614  m_triggerMenuName = menuName;
3615  }
3616 
3617  LogTrace("TriggerMenuXmlParser") << "\n L1 menu name set to value from XML tag!"
3618  << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
3619 
3620  } else {
3621  LogTrace("TriggerMenuXmlParser") << "\n L1 menu name set to file name!"
3622  << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
3623 
3624  }
3625  }
3626 
3627  //
3628  return true;
3629 }
3630 
3642 bool l1t::TriggerMenuXmlParser::workCondition(XERCES_CPP_NAMESPACE::DOMNode* node,
3643  const std::string& name, unsigned int chipNr) {
3644 
3645  XERCES_CPP_NAMESPACE_USE
3646 
3647  // get condition, particle name and type name
3648  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
3649  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
3650  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
3651 
3652  LogDebug("l1t|Global")
3653  << "\n ****************************************** "
3654  << "\n workCondition "
3655  << "\n condition = " << condition
3656  << "\n particle = " << particle
3657  << "\n type = " << type
3658  << "\n name = " << name
3659  << std::endl;
3660 
3661  if (condition.empty() || particle.empty() || type.empty() ) {
3662 
3663  edm::LogError("TriggerMenuXmlParser") << "Missing attributes for condition " << name
3664  << std::endl;
3665 
3666  return false;
3667  }
3668 
3669  //LogTrace("TriggerMenuXmlParser")
3670  //<< " condition: " << condition << ", particle: " << particle
3671  //<< ", type: " << type << std::endl;
3672 
3673  // call the appropiate function for this condition
3674 
3675  /*
3676  if (condition == m_xmlConditionAttrConditionMuon) {
3677  return parseMuon(node, name, chipNr);
3678  }
3679  else if (condition == m_xmlConditionAttrConditionCalo) {
3680  return parseCalo(node, name, chipNr);
3681  }
3682  else if (condition == m_xmlConditionAttrConditionEnergySum) {
3683  return parseEnergySum(node, name, chipNr);
3684  }
3685  else if (condition == m_xmlConditionAttrConditionJetCounts) {
3686  return parseJetCounts(node, name, chipNr);
3687  }
3688  else if (condition == m_xmlConditionAttrConditionCastor) {
3689  return parseCastor(node, name, chipNr);
3690  }
3691  else if (condition == m_xmlConditionAttrConditionHfBitCounts) {
3692  return parseHfBitCounts(node, name, chipNr);
3693  }
3694  else if (condition == m_xmlConditionAttrConditionHfRingEtSums) {
3695  return parseHfRingEtSums(node, name, chipNr);
3696  }
3697  else if (condition == m_xmlConditionAttrConditionBptx) {
3698  return parseBptx(node, name, chipNr);
3699  }
3700  else if (condition == m_xmlConditionAttrConditionExternal) {
3701  return parseExternal(node, name, chipNr);
3702  }
3703  else if (condition == m_xmlConditionAttrConditionCorrelation) {
3704  return parseCorrelation(node, name, chipNr);
3705  }
3706  else {
3707  edm::LogError("TriggerMenuXmlParser")
3708  << "\n Error: unknown condition (" << condition << ")"
3709  << std::endl;
3710 
3711  return false;
3712  }
3713 
3714  */
3715  return true;
3716 
3717 }
3718 
3729 bool l1t::TriggerMenuXmlParser::parseConditions( l1t::ConditionList conditions ){
3730 
3731  XERCES_CPP_NAMESPACE_USE
3732 
3733  LogTrace("TriggerMenuXmlParser") << "\nParsing conditions" << std::endl;
3734 
3735  int chipNr = 1;
3736  LogDebug("l1t|Global") << " ====> condCalorimeter" << std::endl;
3737  for (l1t::ConditionList::condCalorimeter_const_iterator condCalo = conditions.condCalorimeter().begin();
3738  condCalo != conditions.condCalorimeter().end(); ++condCalo ){
3739 
3740  LogDebug("l1t|Global")
3741  << condCalo->name() << " {"
3742  << " description: " << condCalo->description()
3743  << " locked: " << condCalo->locked()
3744  << "}"
3745  << std::endl;
3746 
3747  l1t::CalorimeterCondition condition = (*condCalo);
3748 
3749  parseCalo( condition, chipNr );
3750  }
3751 
3752  LogDebug("l1t|Global") << " ====> condMuon " << std::endl;
3753  for (l1t::ConditionList::condMuon_const_iterator condMu = conditions.condMuon().begin();
3754  condMu != conditions.condMuon().end(); ++condMu ){
3755 
3756  LogDebug("l1t|Global")
3757  << condMu->name() << " {"
3758  << " description: " << condMu->description()
3759  << " locked: " << condMu->locked()
3760  << "}"
3761  << std::endl;
3762 
3763  l1t::MuonCondition condition = (*condMu);
3764 
3765  parseMuon( condition, chipNr );
3766  }
3767 
3768 
3769  return true;
3770 }
3771 
3784  unsigned int chipNr) {
3785 
3786  XERCES_CPP_NAMESPACE_USE
3787 
3788 // if (node == 0) {
3789 // LogDebug("TriggerMenuXmlParser")
3790 // << " Node is 0 in " << __PRETTY_FUNCTION__
3791 // << " can not parse the algorithm " << algName
3792 // << std::endl;
3793 // return false;
3794 // }
3795 
3796  // get alias
3797  std::string algAlias = l1t2string( algorithm.name() );
3798  std::string algName = l1t2string( algorithm.name() );
3799 
3800  if (algAlias == "") {
3801  algAlias = algName;
3802  LogDebug("TriggerMenuXmlParser")
3803  << "\n No alias defined for algorithm. Alias set to algorithm name."
3804  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3805  << std::endl;
3806  } else {
3807  //LogDebug("TriggerMenuXmlParser")
3808  LogDebug("l1t|Global") << "\n Alias defined for algorithm."
3809  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3810  << std::endl;
3811  }
3812 
3813  // get the logical expression
3814  std::string logExpression = l1t2string( algorithm.equation() );
3815 
3816  LogDebug("l1t|Global")
3817  << " Logical expression: " << logExpression
3818  << " Chip number: " << chipNr
3819  << std::endl;
3820 
3821  // determine output pin
3822  std::string pinString = l1t2string( algorithm.index() );
3823  int outputPin = 0;
3824 
3825  std::istringstream opStream(pinString);
3826 
3827  if ((opStream >> outputPin).fail()) {
3828  LogDebug("TriggerMenuXmlParser")
3829  << " Unable to convert pin string " << pinString
3830  << " to int for algorithm : " << algName
3831  << std::endl;
3832 
3833  return false;
3834  }
3835 
3836 
3837  //LogTrace("TriggerMenuXmlParser")
3838  LogDebug("l1t|Global") << " Output pin: " << outputPin
3839  << std::endl;
3840 
3841 
3842  // compute the bit number from chip number, output pin and order of the chips
3843  // pin numbering start with 1, bit numbers with 0
3844  int bitNumber = outputPin;// + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
3845 
3846  //LogTrace("TriggerMenuXmlParser")
3847  LogDebug("l1t|Global") << " Bit number: " << bitNumber
3848  << std::endl;
3849 
3850  // create a new algorithm and insert it into algorithm map
3851  L1GtAlgorithm alg(algName, logExpression, bitNumber);
3852  alg.setAlgoChipNumber(static_cast<int>(chipNr));
3853  alg.setAlgoAlias(algAlias);
3854 
3855  if (edm::isDebugEnabled() ) {
3856 
3857  std::ostringstream myCoutStream;
3858  alg.print(myCoutStream);
3859  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3860 
3861  }
3862 
3863  // insert algorithm into the map
3864  if ( !insertAlgorithmIntoMap(alg)) {
3865 
3866  return false;
3867  }
3868 
3869  return true;
3870 
3871 }
3872 
3873 /*
3874  * parseAlgorithms Parse the algorithms
3875  * NOTE: the algorithms used here are equivalent to "prealgo" from XML file
3876  * for the VERSION_FINAL
3877  * The "VERSION_PROTOTYPE algo" will be phased out later in the XML file
3878  * See L1GlobalTriggerConfig.h (in the attic)
3879  *
3880  * @param parser A reference to the XercesDOMParser to use.
3881  *
3882  * @return "true" if succeeded, "false" if an error occurred.
3883  *
3884  */
3885 
3886 bool l1t::TriggerMenuXmlParser::parseAlgorithms( l1t::AlgorithmList algorithms ) {
3887 
3888  XERCES_CPP_NAMESPACE_USE
3889 
3890  LogTrace("TriggerMenuXmlParser") << "\nParsing algorithms" << std::endl;
3891 
3892  int chipNr = 1;
3893  LogDebug("l1t|Global") << " ====> algorithms " << std::endl;
3894  for( l1t::AlgorithmList::algorithm_const_iterator i = algorithms.algorithm().begin();
3895  i != algorithms.algorithm().end(); ++i ){
3896 
3897  l1t::Algorithm algorithm = (*i);
3898  LogDebug("l1t|Global")
3899  << algorithm.name() << " {"
3900  << " index: " << algorithm.index()
3901  << " equation: " << algorithm.equation()
3902  << " description: " << algorithm.description()
3903  << " locked: " << algorithm.locked()
3904  << "}"
3905  << std::endl;
3906 
3907 
3908  workAlgorithm( algorithm, chipNr );
3909  }
3910 
3911 
3912  return true;
3913 }
3914 
3925 bool l1t::TriggerMenuXmlParser::workTechTrigger(XERCES_CPP_NAMESPACE::DOMNode* node,
3926  const std::string& algName) {
3927 
3928  XERCES_CPP_NAMESPACE_USE
3929 
3930  if (node == 0) {
3931  LogDebug("TriggerMenuXmlParser")
3932  << " Node is 0 in " << __PRETTY_FUNCTION__
3933  << " can not parse the technical trigger " << algName
3934  << std::endl;
3935  return false;
3936  }
3937 
3938  // get the logical expression from the node
3939  std::string logExpression = getXMLTextValue(node);
3940 
3941  //LogTrace("TriggerMenuXmlParser")
3942  //<< " Logical expression: " << logExpression
3943  //<< std::endl;
3944 
3945  // determine bit number (use output pin tag)
3946  DOMNode* pinNode = findXMLChild(node->getFirstChild(), m_xmlTagOutput);
3947  std::string pinString;
3948  int outputPin = 0;
3949 
3950  pinNode = node->getFirstChild();
3951  if ( (pinNode = findXMLChild(pinNode, m_xmlTagOutputPin) ) != 0) {
3952  pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
3953 
3954  // convert pinString to integer
3955  std::istringstream opStream(pinString);
3956 
3957  if ((opStream >> outputPin).fail()) {
3958  LogDebug("TriggerMenuXmlParser")
3959  << " Unable to convert pin string " << pinString
3960  << " to int for technical trigger : " << algName
3961  << std::endl;
3962 
3963  return false;
3964  }
3965 
3966  }
3967 
3968  if (pinNode == 0) {
3969  LogTrace("TriggerMenuXmlParser")
3970  << " Warning: No pin number found for technical trigger: "
3971  << algName << std::endl;
3972 
3973  return false;
3974  }
3975 
3976  // set the bit number
3977  int bitNumber = outputPin;
3978 
3979  //LogTrace("TriggerMenuXmlParser")
3980  //<< " Bit number: " << bitNumber
3981  //<< std::endl;
3982 
3983  // create a new technical trigger and insert it into technical trigger map
3984  // alias set automatically to name
3985  L1GtAlgorithm alg(algName, logExpression, bitNumber);
3986  alg.setAlgoAlias(algName);
3987 
3988  if (edm::isDebugEnabled() ) {
3989 
3990  std::ostringstream myCoutStream;
3991  alg.print(myCoutStream);
3992  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3993 
3994  }
3995 
3996  // insert technical trigger into the map
3997  if ( !insertTechTriggerIntoMap(alg)) {
3998 
3999  return false;
4000  }
4001 
4002  return true;
4003 
4004 }
4005 
4006 /*
4007  * parseTechTriggers Parse the technical triggers
4008  *
4009  * @param parser A reference to the XercesDOMParser to use.
4010  *
4011  * @return "true" if succeeded, "false" if an error occurred.
4012  *
4013  */
4014 
4015 bool l1t::TriggerMenuXmlParser::parseTechTriggers(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
4016 
4017  XERCES_CPP_NAMESPACE_USE
4018 
4019  //LogTrace("TriggerMenuXmlParser") << "\nParsing technical triggers" << std::endl;
4020 
4021  DOMNode* doc = parser->getDocument();
4022  DOMNode* node = doc->getFirstChild();
4023 
4024  DOMNode* algNode = node->getFirstChild();
4025  if (algNode == 0) {
4026  edm::LogError("TriggerMenuXmlParser")
4027  << " Error: No child found for " << m_xmlTagDef << std::endl;
4028  return false;
4029  }
4030 
4031  algNode = findXMLChild(algNode, m_xmlTagTechTriggers);
4032  if (algNode == 0) {
4033  edm::LogError("TriggerMenuXmlParser") << " Error: No <"
4034  << m_xmlTagTechTriggers << "> child found."
4035  << std::endl;
4036  return false;
4037  }
4038 
4039  // walk through technical triggers
4040  DOMNode* algNameNode = algNode->getFirstChild();
4041  std::string algNameNodeName;
4042  algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
4043 
4044  while (algNameNode != 0) {
4045  //LogTrace("TriggerMenuXmlParser")
4046  //<< " Found an technical trigger with name: " << algNameNodeName
4047  //<< std::endl;
4048 
4049  if ( !workTechTrigger(algNameNode, algNameNodeName)) {
4050  return false;
4051  }
4052 
4053  algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true,
4054  &algNameNodeName);
4055 
4056  }
4057 
4058  return true;
4059 }
4060 
4061 
4070 //bool TriggerMenuXmlParser::workXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
4071 bool l1t::TriggerMenuXmlParser::workXML( std::auto_ptr<l1t::L1TriggerMenu> tm ) {
4072 
4073  XERCES_CPP_NAMESPACE_USE
4074 
4075 
4076  // clear possible old maps
4077  clearMaps();
4078 
4079  l1t::Meta meta = tm->meta();
4080  l1t::ConditionList conditions = tm->conditions();
4081  l1t::AlgorithmList algorithms = tm->algorithms();
4082 
4083  if ( !parseId( meta ) ) {
4084  clearMaps();
4085  return false;
4086  }
4087 
4088  if ( !parseConditions( conditions ) ) {
4089  clearMaps();
4090  return false;
4091  }
4092 
4093  if ( !parseAlgorithms( algorithms ) ) {
4094  clearMaps();
4095  return false;
4096  }
4097 
4098 // if ( !parseTechTriggers(parser) ) {
4099 // clearMaps();
4100 // return false;
4101 // }
4102 
4103  return true;
4104 
4105 }
4106 
4107 
4108 // static class members
4109 
#define LogDebug(id)
type
Definition: HCALResponse.h:21
bool isDebugEnabled()
int i
Definition: DBlmapReader.cc:9
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
bool workXML(std::auto_ptr< l1t::L1TriggerMenu > tm)
do all the steps for filling a trigger menu
bool parseJetCounts(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a &quot;jet counts&quot; condition
bool insertConditionIntoMap(GtCondition &cond, const int chipNr)
bool workAlgorithm(l1t::Algorithm algorithm, unsigned int chipNr)
parse an algorithm and insert it into algorithm map.
GtConditionType
Definition: GtDefinitions.h:99
void setGtAlgorithmAliasMap(const AlgorithmMap &)
void setGtNumberL1JetCounts(const unsigned int &)
std::string l1t2string(l1t::MenuName)
bool insertTechTriggerIntoMap(const L1GtAlgorithm &alg)
insert a technical trigger into technical trigger map
void setAlgoAlias(const std::string &algoAliasValue)
Definition: L1GtAlgorithm.h:72
bool parseConditions(l1t::ConditionList conditions)
parse all conditions
bool parseVmeXML(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
parse the vme xml file
virtual void print(std::ostream &myCout) const
print condition
void setVecEnergySumTemplate(const std::vector< std::vector< L1GtEnergySumTemplate > > &)
unsigned long long deltaEtaRange
Definition: CaloTemplate.h:79
const std::string algoName() const
get / set algorithm name
Definition: L1GtAlgorithm.h:56
unsigned long long deltaPhiRange
Definition: CaloTemplate.h:81
void setGtAlgorithmMap(const AlgorithmMap &)
bool parseCalo(l1t::CalorimeterCondition condCalo, unsigned int chipNr=0, const bool corrFlag=false)
parse a calorimeter condition
void setGtTechnicalTriggerMap(const AlgorithmMap &)
void setGtOrderConditionChip(const std::vector< int > &)
void setGtTriggerMenuImplementation(const std::string &)
tuple node
Definition: Node.py:50
std::string const & algoAlias() const
get / set algorithm alias
Definition: L1GtAlgorithm.h:67
bool insertAlgorithmIntoMap(const L1GtAlgorithm &alg)
insert an algorithm into algorithm map
void setVecHfRingEtSumsTemplate(const std::vector< std::vector< L1GtHfRingEtSumsTemplate > > &)
bool parseId(std::auto_ptr< l1t::L1TriggerMenu > tm)
parse all parse all identification attributes (trigger menu names, scale DB key, etc) ...
bool parseExternal(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse an External condition
void setAlgoChipNumber(const int algoChipNumberValue)
void setGtNumberPhysTriggers(const unsigned int &)
void setVecHfBitCountsTemplate(const std::vector< std::vector< L1GtHfBitCountsTemplate > > &)
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
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 setGtTriggerMenuInterfaceDescription(const std::string &)
bool getXMLHexTextValue(const std::string &childName, boost::uint64_t &dst)
void parseXmlFile(const std::string &defXmlFile, const std::string &vmeXmlFile)
parse def.xml and vme.xml files
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
void setGtTriggerMenuName(const std::string &)
void setVecBptxTemplate(const std::vector< std::vector< L1GtBptxTemplate > > &)
void setGtScaleDbKey(const std::string &)
void setVecJetCountsTemplate(const std::vector< std::vector< L1GtJetCountsTemplate > > &)
int getBitFromNode(XERCES_CPP_NAMESPACE::DOMNode *node)
get bit from a bit node
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
void setGtTriggerMenuInterfaceAuthor(const std::string &)
list attributes
Definition: asciidump.py:415
bool parseMuon(l1t::MuonCondition condMu, unsigned int chipNr=0, const bool corrFlag=false)
parse a muon condition
void setVecExternalTemplate(const std::vector< std::vector< L1GtExternalTemplate > > &)
std::string getXMLAttribute(const XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name)
get a named attribute for an xml node as string
tuple doc
Definition: asciidump.py:381
int algoBitNumber() const
get / set algorithm bit number
Definition: L1GtAlgorithm.h:94
bool getXMLHexTextValue128Old(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
void setVecMuonTemplate(const std::vector< std::vector< MuonTemplate > > &)
bool workCondition(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr)
choose the parser for a particular condition
#define LogTrace(id)
bool parseHfRingEtSums(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a HfRingEtSums condition
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
bool getXMLHexTextValue128(const std::string &childName, boost::uint64_t &dstL, boost::uint64_t &dstH)
void setVecCastorTemplate(const std::vector< std::vector< L1GtCastorTemplate > > &)
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
bool getConditionChildValuesOld(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
l1t::GtConditionType getTypeFromType(const std::string &type)
const std::string & condName() const
get / set condition name
Definition: GtCondition.h:56
Definition: L1GtObject.h:30
void setGtConditionMap(const std::vector< ConditionMap > &)
unsigned long long uint64_t
Definition: Time.h:15
bool countConditionChildMaxBits(const std::string &childName, unsigned int &dst)
get the number of bits in the max attribute of a condition child
void setGtTriggerMenuDescription(const std::string &)
bool xmlFile(const std::string fParam)
bool parseTechTriggers(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
parse all algorithms
bool parseHfBitCounts(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a HfBitCounts condition
void setGtPinsOnConditionChip(const unsigned int &)
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
typedef for correlation parameters
Definition: CaloTemplate.h:77
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const int algoChipNumber() const
get / set algorithm bit number
static std::atomic< unsigned int > counter
void setGtTriggerMenuInterfaceDate(const std::string &)
void setVecCaloTemplate(const std::vector< std::vector< CaloTemplate > > &)
bool workTechTrigger(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name)
parse an algorithm and insert it into algorithm map.
virtual ~TriggerMenuXmlParser()
destructor
void setGtNumberConditionChips(const unsigned int &)
void setGtAlgorithmImplementation(const std::string &)
void cleanupXML(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
shutdown the xml utils and deallocate parser and error handler
XERCES_CPP_NAMESPACE::XercesDOMParser * initXML(const std::string &xmlFile)
init xml system
bool parseCorrelation(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a correlation condition
std::string getXMLTextValue(XERCES_CPP_NAMESPACE::DOMNode *node)
get the text value of a xml node as string
bool parseAlgorithms(l1t::AlgorithmList algorithms)
parse all algorithms
void setCorCaloTemplate(const std::vector< std::vector< CaloTemplate > > &)
void setCorMuonTemplate(const std::vector< std::vector< MuonTemplate > > &)
void setVecCorrelationTemplate(const std::vector< std::vector< CorrelationTemplate > > &)
void setGtTriggerMenuInterface(const std::string &)
void setCorEnergySumTemplate(const std::vector< std::vector< L1GtEnergySumTemplate > > &)
void setGtTriggerMenuDate(const std::string &)
void setGtNumberTechTriggers(const unsigned int &)
void setGtTriggerMenuAuthor(const std::string &)
bool getXMLHexTextValueOld(XERCES_CPP_NAMESPACE::DOMNode *node, boost::uint64_t &dst)
get a hexadecimal value of a xml node containing text
int getGEqFlag(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &nodeName)
getGEqFlag - get the &quot;greater or equal flag&quot; from a condition
int getNumFromType(const std::string &type)
get number of particles from condition type
bool parseCastor(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a CASTOR condition
bool parseBptx(XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name, unsigned int chipNr=0)
parse a Bptx condition