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 << std::setfill('0');
1439  ss << std::setw(4) << date.year() << "-" << std::setw(2) << date.month() << "-" << std::setw(2) << date.day() << "T";
1440  ss << std::setw(2) << date.hours() << ":" << std::setw(2) << date.minutes() << ":" << std::setw(2) << date.seconds();
1441  //ss << data;
1442  return ss.str();
1443 }
1445  std::stringstream ss;
1446  ss << data;
1447  int value;
1448  ss >> value;
1449  return value;
1450 }
1451 
1452 
1453 
1465 bool l1t::TriggerMenuXmlParser::parseMuon(l1t::MuonCondition condMu,
1466  unsigned int chipNr, const bool corrFlag) {
1467 
1468  XERCES_CPP_NAMESPACE_USE
1469 
1470  // get condition, particle name (must be muon) and type name
1471  std::string condition = "muon";
1472  std::string particle = "muon";//l1t2string( condMu.objectType() );
1473  std::string type = l1t2string( condMu.type() );
1474  std::string name = l1t2string( condMu.name() );
1475 
1476  if( particle=="mu" ) particle = "muon";
1477 
1478  if( type=="double_wsc" ) type = "2_wsc";
1479  else if( type=="single" ) type = "1_s";
1480  else if( type=="double" ) type = "2_s";
1481  else if( type=="triple" ) type = "3";
1482  else if( type=="quad" ) type = "4";
1483 
1484  LogDebug("l1t|Global")
1485  << "\n ****************************************** "
1486  << "\n parseMuon "
1487  << "\n condition = " << condition
1488  << "\n particle = " << particle
1489  << "\n type = " << type
1490  << "\n name = " << name
1491  << std::endl;
1492 
1493  if (particle != m_xmlConditionAttrObjectMu) {
1494  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for muon-condition ("
1495  << particle << ")" << std::endl;
1496  return false;
1497  }
1498 
1499  // get greater equal flag
1500  std::string str_etComparison = l1t2string( condMu.comparison_operator() );
1501 
1502  int nrObj = getNumFromType(type);
1503  if (nrObj < 0) {
1504  edm::LogError("TriggerMenuXmlParser") << "Unknown type for calo-condition (" << type
1505  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1506  return false;
1507  }
1508 
1509  // get greater equal flag
1510  int intGEq = ( str_etComparison=="ge" ) ? 1 : 0;
1511  if (intGEq < 0) {
1512  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
1513  << std::endl;
1514  return false;
1515  }
1516  // set the boolean value for the ge_eq mode
1517  bool gEq = (intGEq != 0);
1518 
1519 // // get values
1520 
1521  // temporary storage of the parameters
1522  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1523  MuonTemplate::CorrelationParameter corrParameter;
1524 
1525  // need at least two values for deltaPhi
1526  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1527  tmpValues.reserve( nrObj );
1528 
1529  if( int(condMu.objectRequirements().objectRequirement().size())!=nrObj ){
1530  edm::LogError("TriggerMenuXmlParser") << " condMu objects: nrObj = " << nrObj
1531  << "condMu.objectRequirements().objectRequirement().size() = "
1532  << condMu.objectRequirements().objectRequirement().size()
1533  << std::endl;
1534  return false;
1535  }
1536 
1537 
1538  std::string str_chargeCorrelation = l1t2string( condMu.requestedChargeCorr() );
1539 
1540  unsigned int chargeCorrelation = 0;
1541  if( str_chargeCorrelation=="ig" ) chargeCorrelation = 0;
1542  else if( str_chargeCorrelation=="ls" ) chargeCorrelation = 1;
1543  else if( str_chargeCorrelation=="os" ) chargeCorrelation = 2;
1544 
1545  //getXMLHexTextValue("1", dst);
1546  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
1547 
1548  std::string str_condMu = "";
1549  boost::uint64_t tempUIntH, tempUIntL;
1550  boost::uint64_t dst;
1551  int cnt = 0;
1552  for( l1t::MuonObjectRequirementList::objectRequirement_const_iterator objPar = condMu.objectRequirements().objectRequirement().begin();
1553  objPar != condMu.objectRequirements().objectRequirement().end(); ++objPar ){
1554 
1555  // ET Threshold
1556  str_condMu = l1t2string( objPar->ptThreshold() );
1557  if( !getXMLHexTextValue(str_condMu, dst) ) return false;
1558  //if( cnt<nrObj ) objParameter[cnt].etThreshold = dst;
1560  if( cnt<nrObj ){
1561  objParameter[cnt].ptHighThreshold = objPar->ptThreshold();
1562  objParameter[cnt].ptLowThreshold = objPar->ptThreshold();
1563  }
1564 
1565  // Eta Range
1566  //str_condMu = "ffff";
1567  str_condMu = "7f7f";
1568  //str_condMu = "0f0f";
1569  if( !getXMLHexTextValue(str_condMu, dst) ) return false;
1570  if( cnt<nrObj ) objParameter[cnt].etaRange = dst;
1571 
1572  // Phi Range
1573  str_condMu = "3ffff";
1574  if( !getXMLHexTextValue(str_condMu, dst) ) return false;
1575  //if( cnt<nrObj ) objParameter[cnt].phiRange = dst;
1576  getXMLHexTextValue("8f", dst);
1577  objParameter[cnt].phiHigh = dst;//tmpValues[i];
1578  objParameter[cnt].phiLow = dst;//tmpValues[i];
1579 
1580  objParameter[cnt].enableMip = false;//tmpMip[i];
1581  objParameter[cnt].enableIso = false;//tmpEnableIso[i];
1582  objParameter[cnt].requestIso = false;//tmpRequestIso[i];
1583 
1584  getXMLHexTextValue("f0", dst);
1585  objParameter[cnt].qualityRange = dst;//tmpValues[i];
1586 
1587 
1588  int cntEta=0;
1589  unsigned int etaWindowLower=-1, etaWindowUpper=-1, etaWindowVetoLower=-1, etaWindowVetoUpper=-1;
1590  // Temporary before translation
1591  for( l1t::CalorimeterObjectRequirement::etaWindow_const_iterator etaWindow =objPar->etaWindow().begin();
1592  etaWindow != objPar->etaWindow().end(); ++etaWindow ){
1593 
1594  LogDebug("l1t|Global")
1595  << "\n etaWindow lower = " << etaWindow->lower()
1596  << "\n etaWindow upper = " << etaWindow->upper()
1597  << std::endl;
1598  if( cntEta==0 ){ etaWindowLower = etaWindow->lower(); etaWindowUpper = etaWindow->upper(); }
1599  else if( cntEta==1 ){ etaWindowVetoLower = etaWindow->lower(); etaWindowVetoUpper = etaWindow->upper(); }
1600  cntEta++;
1601  }
1602 
1603  int cntPhi=0;
1604  unsigned int phiWindowLower=-1, phiWindowUpper=-1, phiWindowVetoLower=-1, phiWindowVetoUpper=-1;
1605  for( l1t::CalorimeterObjectRequirement::phiWindow_const_iterator phiWindow =objPar->phiWindow().begin();
1606  phiWindow != objPar->phiWindow().end(); ++phiWindow ){
1607 
1608  LogDebug("l1t|Global")
1609  << "\n phiWindow begin = " << phiWindow->lower()
1610  << "\n phiWindow end = " << phiWindow->upper()
1611  << std::endl;
1612 
1613  if( cntPhi==0 ){ phiWindowLower = phiWindow->lower(); phiWindowUpper = phiWindow->upper(); }
1614  else if( cntPhi==1 ){ phiWindowVetoLower = phiWindow->lower(); phiWindowVetoUpper = phiWindow->upper(); }
1615  cntPhi++;
1616  }
1617 
1618  objParameter[cnt].etaWindowLower = etaWindowLower;
1619  objParameter[cnt].etaWindowUpper = etaWindowUpper;
1620  objParameter[cnt].etaWindowVetoLower = etaWindowVetoLower;
1621  objParameter[cnt].etaWindowVetoUpper = etaWindowVetoUpper;
1622 
1623  objParameter[cnt].phiWindowLower = phiWindowLower;
1624  objParameter[cnt].phiWindowUpper = phiWindowUpper;
1625  objParameter[cnt].phiWindowVetoLower = phiWindowVetoLower;
1626  objParameter[cnt].phiWindowVetoUpper = phiWindowVetoUpper;
1627 
1628 
1629  // Output for debugging
1630  LogDebug("l1t|Global")
1631  << "\n Muon PT high threshold (hex) for muon object " << cnt << " = "
1632  << std::hex << objParameter[cnt].ptHighThreshold << std::dec
1633  << "\n etaWindow (hex) for muon object " << cnt << " = "
1634  << std::hex << objParameter[cnt].etaRange << std::dec
1635  // << "\n phiRange (hex) for muon object " << cnt << " = "
1636  // << std::hex << objParameter[cnt].phiRange << std::dec
1637  << "\n etaWindow Lower / Upper for muon object " << cnt << " = "
1638  << objParameter[cnt].etaWindowLower << " / " << objParameter[cnt].etaWindowUpper
1639  << "\n etaWindowVeto Lower / Upper for muon object " << cnt << " = "
1640  << objParameter[cnt].etaWindowVetoLower << " / " << objParameter[cnt].etaWindowVetoUpper
1641  << "\n phiWindow Lower / Upper for muon object " << cnt << " = "
1642  << objParameter[cnt].phiWindowLower << " / " << objParameter[cnt].phiWindowUpper
1643  << "\n phiWindowVeto Lower / Upper for muon object " << cnt << " = "
1644  << objParameter[cnt].phiWindowVetoLower << " / " << objParameter[cnt].phiWindowVetoUpper
1645  << std::endl;
1646 
1647  cnt++;
1648  }
1649 
1650 
1651 
1652  // indicates if a correlation is used
1653  bool wscVal = (type == m_xmlConditionAttrType2wsc );
1654 
1655  if( wscVal ){
1656 
1657  xsd::cxx::tree::optional<l1t::DeltaRequirement> condRanges = condMu.deltaRequirement();
1658  LogDebug("l1t|Global")
1659  << "\t condRanges->deltaEtaRange().lower() = " << condRanges->deltaEtaRange().lower()
1660  << "\n\t condRanges->deltaEtaRange().upper() = " << condRanges->deltaEtaRange().upper()
1661  << "\n\t condRanges->deltaPhiRange().lower() = " << condRanges->deltaPhiRange().lower()
1662  << "\n\t condRanges->deltaPhiRange().upper() = " << condRanges->deltaPhiRange().upper()
1663  << std::endl;
1664 
1665  corrParameter.deltaEtaRangeLower = condRanges->deltaEtaRange().lower();
1666  corrParameter.deltaEtaRangeUpper = condRanges->deltaEtaRange().upper();
1667 
1668  corrParameter.deltaPhiRangeLower = condRanges->deltaPhiRange().lower();
1669  corrParameter.deltaPhiRangeUpper = condRanges->deltaPhiRange().upper();
1670 
1671  //
1673  //
1674 
1675  // Eta Range
1676  str_condMu = "0003";
1677  if ( !hexString2UInt128(str_condMu, tempUIntL, tempUIntH) ) {
1678  return false;
1679  }
1680  if( tempUIntH != 0 ){
1681  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
1682  return false;
1683  }
1684  corrParameter.deltaEtaRange = tempUIntL;
1685 
1686  // Phi Range
1687  str_condMu = "003";
1688  if ( !hexString2UInt128(str_condMu, tempUIntL, tempUIntH) ) {
1689  return false;
1690  }
1691  if( tempUIntH != 0 ){
1692  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
1693  return false;
1694  }
1695  corrParameter.deltaPhiRange = tempUIntL;
1696 
1697 
1698 
1699  // Max Phi Range
1700  std::string maxString = "3FF";
1701 
1702  unsigned int maxbits = 0;
1703 
1704  if ( !countConditionChildMaxBits(maxString, maxbits) ) {
1705  return false;
1706  }
1707 
1708  corrParameter.deltaPhiMaxbits = maxbits;
1709  LogTrace("TriggerMenuXmlParser")
1710  << " deltaPhiMaxbits (dec) = " << maxbits
1711  << std::endl;
1712  }
1713 
1714 
1715  // get the type of the condition, as defined in enum, from the condition type
1716  // as defined in the XML file
1717  GtConditionType cType = getTypeFromType(type);
1718  //LogTrace("TriggerMenuXmlParser")
1719  //<< " Condition type (enum value) = " << cType
1720  //<< std::endl;
1721 
1722  if (cType == l1t::TypeNull) {
1723  edm::LogError("TriggerMenuXmlParser")
1724  << "Type for muon condition id l1t::TypeNull - it means not defined in the XML file."
1725  << "\nNumber of trigger objects is set to zero. " << std::endl;
1726  return false;
1727  }
1728 
1729  // object types - all muons
1730  std::vector<L1GtObject> objType(nrObj, Mu);
1731 
1733 
1734  int relativeBx = l1t2int( condMu.relativeBx() );
1735 
1737  // now create a new CondMuonition
1738 
1739  MuonTemplate muonCond(name);
1740 
1741  muonCond.setCondType(cType);
1742  muonCond.setObjectType(objType);
1743  muonCond.setCondGEq(gEq);
1744  muonCond.setCondChipNr(chipNr);
1745  muonCond.setCondRelativeBx(relativeBx);
1746 
1747  muonCond.setConditionParameter(objParameter, corrParameter);
1748 
1749  if (edm::isDebugEnabled()) {
1750  std::ostringstream myCoutStream;
1751  muonCond.print(myCoutStream);
1752  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
1753  }
1754 
1755  // insert condition into the map and into muon template vector
1756  if ( !insertConditionIntoMap(muonCond, chipNr)) {
1757  edm::LogError("TriggerMenuXmlParser")
1758  << " Error: duplicate condition (" << name << ")"
1759  << std::endl;
1760  return false;
1761  }
1762  else {
1763  if (corrFlag) {
1764  (m_corMuonTemplate[chipNr]).push_back(muonCond);
1765  }
1766  else {
1767  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1768  }
1769 
1770  }
1771 
1772 
1773  LogDebug("l1t|Global")
1774  << "\n intGEq = " << intGEq
1775  << " nrObj = " << nrObj
1776  << "\n ****************************************** "
1777  << std::endl;
1778 
1779  //
1780  return true;
1781 }
1782 
1794 bool l1t::TriggerMenuXmlParser::parseCalo(l1t::CalorimeterCondition condCalo,
1795  unsigned int chipNr, const bool corrFlag) {
1796 
1797  XERCES_CPP_NAMESPACE_USE
1798 
1799  // get condition, particle name and type name
1800 
1801  std::string condition = "calo";
1802  std::string particle = l1t2string( condCalo.objectType() );
1803  std::string type = l1t2string( condCalo.type() );
1804  std::string name = l1t2string( condCalo.name() );
1805 
1806  LogDebug("l1t|Global")
1807  << "\n ****************************************** "
1808  << "\n DARRENS TEST OUTPUT (in parseCalo) "
1809  << "\n condition = " << condition
1810  << "\n particle = " << particle
1811  << "\n type = " << type
1812  << "\n name = " << name
1813  << std::endl;
1814 
1815 
1816  // determine object type type
1817  L1GtObject caloObjType;
1818 
1819  if (particle == m_xmlConditionAttrObjectNoIsoEG) {
1820  caloObjType = NoIsoEG;
1821  }
1822  else if (particle == m_xmlConditionAttrObjectIsoEG) {
1823  caloObjType = IsoEG;
1824  }
1825  else if (particle == m_xmlConditionAttrObjectCenJet) {
1826  caloObjType = CenJet;
1827  }
1828  else if (particle == m_xmlConditionAttrObjectTauJet) {
1829  caloObjType = TauJet;
1830  }
1831  else if (particle == m_xmlConditionAttrObjectForJet) {
1832  caloObjType = ForJet;
1833  }
1834  else {
1835  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for calo-condition ("
1836  << particle << ")" << std::endl;
1837  return false;
1838  }
1839 
1840  if( type=="double_wsc" ) type = "2_wsc";
1841  else if( type=="single" ) type = "1_s";
1842  else if( type=="double" ) type = "2_s";
1843  else if( type=="triple" ) type = "3";
1844  else if( type=="quad" ) type = "4";
1845 
1846 
1847  std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1848 
1849  int nrObj = getNumFromType(type);
1850  if (nrObj < 0) {
1851  edm::LogError("TriggerMenuXmlParser") << "Unknown type for calo-condition (" << type
1852  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1853  return false;
1854  }
1855 
1856  // get greater equal flag
1857  int intGEq = ( str_etComparison=="ge" ) ? 1 : 0;
1858  if (intGEq < 0) {
1859  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
1860  << std::endl;
1861  return false;
1862  }
1863  // set the boolean value for the ge_eq mode
1864  bool gEq = (intGEq != 0);
1865 
1866  // get values
1867 
1868  // temporary storage of the parameters
1869  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1870  CaloTemplate::CorrelationParameter corrParameter;
1871 
1872  // need at least one value for deltaPhiRange
1873  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1874  tmpValues.reserve( nrObj );
1875 
1876  if( int(condCalo.objectRequirements().objectRequirement().size())!=nrObj ){
1877  edm::LogError("TriggerMenuXmlParser") << " condCalo objects: nrObj = " << nrObj
1878  << "condCalo.objectRequirements().objectRequirement().size() = "
1879  << condCalo.objectRequirements().objectRequirement().size()
1880  << std::endl;
1881  return false;
1882  }
1883 
1884 
1885  std::string str_condCalo = "";
1886  boost::uint64_t tempUIntH, tempUIntL;
1887  boost::uint64_t dst;
1888  int cnt = 0;
1889  for( l1t::CalorimeterObjectRequirements::objectRequirement_const_iterator objPar = condCalo.objectRequirements().objectRequirement().begin();
1890  objPar != condCalo.objectRequirements().objectRequirement().end(); ++objPar ){
1891 
1892  // ET Threshold
1893  str_condCalo = l1t2string( objPar->etThreshold() );
1894  if( !getXMLHexTextValue(str_condCalo, dst) ) return false;
1895  //if( cnt<nrObj ) objParameter[cnt].etThreshold = dst;
1897  if( cnt<nrObj ) objParameter[cnt].etThreshold = objPar->etThreshold();
1898 
1899  // Eta Range
1900  //str_condCalo = "ffff";
1901  str_condCalo = "7f7f";
1902  //str_condCalo = "0f0f";
1903  if( !getXMLHexTextValue(str_condCalo, dst) ) return false;
1904  if( cnt<nrObj ) objParameter[cnt].etaRange = dst;
1905 
1906  // Phi Range
1907  str_condCalo = "3ffff";
1908  if( !getXMLHexTextValue(str_condCalo, dst) ) return false;
1909  if( cnt<nrObj ) objParameter[cnt].phiRange = dst;
1910 
1911 
1912 
1913  int cntEta=0;
1914  unsigned int etaWindowLower=-1, etaWindowUpper=-1, etaWindowVetoLower=-1, etaWindowVetoUpper=-1;
1915  // Temporary before translation
1916  for( l1t::CalorimeterObjectRequirement::etaWindow_const_iterator etaWindow =objPar->etaWindow().begin();
1917  etaWindow != objPar->etaWindow().end(); ++etaWindow ){
1918 
1919  LogDebug("l1t|Global")
1920  << "\n etaWindow lower = " << etaWindow->lower()
1921  << "\n etaWindow upper = " << etaWindow->upper()
1922  << std::endl;
1923  if( cntEta==0 ){ etaWindowLower = etaWindow->lower(); etaWindowUpper = etaWindow->upper(); }
1924  else if( cntEta==1 ){ etaWindowVetoLower = etaWindow->lower(); etaWindowVetoUpper = etaWindow->upper(); }
1925  cntEta++;
1926  }
1927 
1928  int cntPhi=0;
1929  unsigned int phiWindowLower=-1, phiWindowUpper=-1, phiWindowVetoLower=-1, phiWindowVetoUpper=-1;
1930  for( l1t::CalorimeterObjectRequirement::phiWindow_const_iterator phiWindow =objPar->phiWindow().begin();
1931  phiWindow != objPar->phiWindow().end(); ++phiWindow ){
1932 
1933  LogDebug("l1t|Global")
1934  << "\n phiWindow begin = " << phiWindow->lower()
1935  << "\n phiWindow end = " << phiWindow->upper()
1936  << std::endl;
1937 
1938  if( cntPhi==0 ){ phiWindowLower = phiWindow->lower(); phiWindowUpper = phiWindow->upper(); }
1939  else if( cntPhi==1 ){ phiWindowVetoLower = phiWindow->lower(); phiWindowVetoUpper = phiWindow->upper(); }
1940  cntPhi++;
1941  }
1942 
1943  objParameter[cnt].etaWindowLower = etaWindowLower;
1944  objParameter[cnt].etaWindowUpper = etaWindowUpper;
1945  objParameter[cnt].etaWindowVetoLower = etaWindowVetoLower;
1946  objParameter[cnt].etaWindowVetoUpper = etaWindowVetoUpper;
1947 
1948  objParameter[cnt].phiWindowLower = phiWindowLower;
1949  objParameter[cnt].phiWindowUpper = phiWindowUpper;
1950  objParameter[cnt].phiWindowVetoLower = phiWindowVetoLower;
1951  objParameter[cnt].phiWindowVetoUpper = phiWindowVetoUpper;
1952 
1953 
1954  // Output for debugging
1955  LogDebug("l1t|Global")
1956  << "\n Calo ET high threshold (hex) for calo object " << cnt << " = "
1957  << std::hex << objParameter[cnt].etThreshold << std::dec
1958  << "\n etaWindow (hex) for calo object " << cnt << " = "
1959  << std::hex << objParameter[cnt].etaRange << std::dec
1960  << "\n phiRange (hex) for calo object " << cnt << " = "
1961  << std::hex << objParameter[cnt].phiRange << std::dec
1962  << "\n etaWindow Lower / Upper for calo object " << cnt << " = "
1963  << objParameter[cnt].etaWindowLower << " / " << objParameter[cnt].etaWindowUpper
1964  << "\n etaWindowVeto Lower / Upper for calo object " << cnt << " = "
1965  << objParameter[cnt].etaWindowVetoLower << " / " << objParameter[cnt].etaWindowVetoUpper
1966  << "\n phiWindow Lower / Upper for calo object " << cnt << " = "
1967  << objParameter[cnt].phiWindowLower << " / " << objParameter[cnt].phiWindowUpper
1968  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = "
1969  << objParameter[cnt].phiWindowVetoLower << " / " << objParameter[cnt].phiWindowVetoUpper
1970  << std::endl;
1971 
1972  cnt++;
1973  }
1974 
1975 
1976 
1977  // indicates if a correlation is used
1978  bool wscVal = (type == m_xmlConditionAttrType2wsc );
1979 
1980  if( wscVal ){
1981 
1982  xsd::cxx::tree::optional<l1t::DeltaRequirement> condRanges = condCalo.deltaRequirement();
1983  LogDebug("l1t|Global")
1984  << "\t condRanges->deltaEtaRange().lower() = " << condRanges->deltaEtaRange().lower()
1985  << "\n\t condRanges->deltaEtaRange().upper() = " << condRanges->deltaEtaRange().upper()
1986  << "\n\t condRanges->deltaPhiRange().lower() = " << condRanges->deltaPhiRange().lower()
1987  << "\n\t condRanges->deltaPhiRange().upper() = " << condRanges->deltaPhiRange().upper()
1988  << std::endl;
1989 
1990  corrParameter.deltaEtaRangeLower = condRanges->deltaEtaRange().lower();
1991  corrParameter.deltaEtaRangeUpper = condRanges->deltaEtaRange().upper();
1992 
1993  corrParameter.deltaPhiRangeLower = condRanges->deltaPhiRange().lower();
1994  corrParameter.deltaPhiRangeUpper = condRanges->deltaPhiRange().upper();
1995 
1996  //
1998  //
1999 
2000  // Eta Range
2001  str_condCalo = "0003";
2002  if ( !hexString2UInt128(str_condCalo, tempUIntL, tempUIntH) ) {
2003  return false;
2004  }
2005  if( tempUIntH != 0 ){
2006  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
2007  return false;
2008  }
2009  corrParameter.deltaEtaRange = tempUIntL;
2010 
2011  // Phi Range
2012  str_condCalo = "003";
2013  if ( !hexString2UInt128(str_condCalo, tempUIntL, tempUIntH) ) {
2014  return false;
2015  }
2016  if( tempUIntH != 0 ){
2017  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
2018  return false;
2019  }
2020  corrParameter.deltaPhiRange = tempUIntL;
2021 
2022 
2023 
2024  // Max Phi Range
2025  std::string maxString = "3FF";
2026 
2027  unsigned int maxbits = 0;
2028 
2029  if ( !countConditionChildMaxBits(maxString, maxbits) ) {
2030  return false;
2031  }
2032 
2033  corrParameter.deltaPhiMaxbits = maxbits;
2034  LogTrace("TriggerMenuXmlParser")
2035  << " deltaPhiMaxbits (dec) = " << maxbits
2036  << std::endl;
2037  }
2038 
2039 
2040 
2041  // get the type of the condition, as defined in enum, from the condition type
2042  // as defined in the XML file
2043  GtConditionType cType = getTypeFromType(type);
2044  LogTrace("TriggerMenuXmlParser")
2045  << " Condition type (enum value) = " << cType
2046  << std::endl;
2047 
2048  if (cType == l1t::TypeNull) {
2049  edm::LogError("TriggerMenuXmlParser")
2050  << "Type for calo condition id l1t::TypeNull - it means not defined in the XML file."
2051  << "\nNumber of trigger objects is set to zero. " << std::endl;
2052  return false;
2053  }
2054 
2055  // object types - all same caloObjType
2056  std::vector<L1GtObject> objType(nrObj, caloObjType);
2057 
2058 
2059  int relativeBx = l1t2int( condCalo.relativeBx() );
2060 
2061  // now create a new calo condition
2062  CaloTemplate caloCond(name);
2063 
2064  caloCond.setCondType(cType);
2065  caloCond.setObjectType(objType);
2066  caloCond.setCondGEq(gEq);
2067  caloCond.setCondChipNr(chipNr);
2068  caloCond.setCondRelativeBx(relativeBx);
2069 
2070  caloCond.setConditionParameter(objParameter, corrParameter);
2071 
2072  if (edm::isDebugEnabled() ) {
2073 
2074  std::ostringstream myCoutStream;
2075  caloCond.print(myCoutStream);
2076  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2077 
2078  }
2079 
2080  // insert condition into the map
2081  if ( !insertConditionIntoMap(caloCond, chipNr)) {
2082 
2083  edm::LogError("TriggerMenuXmlParser")
2084  << " Error: duplicate condition (" << name << ")"
2085  << std::endl;
2086 
2087  return false;
2088  }
2089  else {
2090 
2091  if (corrFlag) {
2092  (m_corCaloTemplate[chipNr]).push_back(caloCond);
2093  }
2094  else {
2095  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
2096  }
2097 
2098  }
2099 
2100  LogDebug("l1t|Global")
2101  << "\n intGEq = " << intGEq
2102  << " nrObj = " << nrObj
2103  << "\n ****************************************** "
2104  << std::endl;
2105 
2106 
2107  //
2108  return true;
2109 }
2110 
2123  XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& name,
2124  unsigned int chipNr, const bool corrFlag) {
2125 
2126  XERCES_CPP_NAMESPACE_USE
2127 
2128  /*
2129  // get condition, particle name and type name
2130  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2131  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2132  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2133 
2134  // determine object type type
2135  L1GtObject energySumObjType;
2136  GtConditionType cType;
2137 
2138  if ((particle == m_xmlConditionAttrObjectETM) && (type == m_xmlConditionAttrObjectETM)) {
2139 
2140  energySumObjType = ETM;
2141  cType = TypeETM;
2142 
2143  }
2144  else if ((particle == m_xmlConditionAttrObjectETT) && (type == m_xmlConditionAttrObjectETT)) {
2145 
2146  energySumObjType = ETT;
2147  cType = TypeETT;
2148 
2149  }
2150  else if ((particle == m_xmlConditionAttrObjectHTT) && (type == m_xmlConditionAttrObjectHTT)) {
2151 
2152  energySumObjType = HTT;
2153  cType = TypeHTT;
2154 
2155  }
2156  else if ((particle == m_xmlConditionAttrObjectHTM) && (type == m_xmlConditionAttrObjectHTM)) {
2157 
2158  energySumObjType = HTM;
2159  cType = TypeHTM;
2160 
2161  }
2162  else {
2163  edm::LogError("TriggerMenuXmlParser")
2164  << "Wrong particle or type for energy-sum condition (" << particle << ", " << type
2165  << ")" << std::endl;
2166  return false;
2167  }
2168 
2169  // global object
2170  int nrObj = 1;
2171 
2172  // get greater equal flag
2173 
2174  int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
2175  if (intGEq < 0) {
2176  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2177  << std::endl;
2178  return false;
2179  }
2180  // set the boolean value for the ge_eq mode
2181  bool gEq = (intGEq != 0);
2182 
2183  // get values
2184 
2185  // temporary storage of the parameters
2186  std::vector<L1GtEnergySumTemplate::ObjectParameter> objParameter(nrObj);
2187 
2188  // need at least two values for phi
2189  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
2190 
2191  // get etThreshold values and fill into structure
2192  if ( !getConditionChildValuesOld(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
2193  return false;
2194  }
2195 
2196  for (int i = 0; i < nrObj; i++) {
2197  objParameter[i].etThreshold = tmpValues[i];
2198 
2199  //LogTrace("TriggerMenuXmlParser")
2200  //<< " EnergySum ET high threshold (hex) for energySum object " << i << " = "
2201  //<< std::hex << objParameter[i].etThreshold << std::dec
2202  //<< std::endl;
2203 
2204  // for ETM and HTM read phi value
2205  // phi is larger than 64 bits for ETM - it needs two 64bits words
2206  // phi is less than 64 bits for HTM - it needs one 64bits word
2207  if (energySumObjType == ETM) {
2208 
2209  if (!getXMLHexTextValue128Old(
2210  findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0], tmpValues[1])) {
2211  edm::LogError("TriggerMenuXmlParser")
2212  << " Could not get phi for ETM condition (" << name << ")" << std::endl;
2213  return false;
2214  }
2215 
2216  objParameter[i].phiRange0Word = tmpValues[0];
2217  objParameter[i].phiRange1Word = tmpValues[1];
2218 
2219  } else if (energySumObjType == HTM) {
2220 
2221  if (!getXMLHexTextValueOld(findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0])) {
2222  edm::LogError("TriggerMenuXmlParser")
2223  << " Could not get phi for HTM condition (" << name << ")" << std::endl;
2224  return false;
2225  }
2226 
2227  objParameter[i].phiRange0Word = tmpValues[0];
2228 
2229  }
2230 
2231  // get energyOverflow logical flag and fill into structure
2232  DOMNode* n1;
2233  if ( (n1 = findXMLChild(node->getFirstChild(), m_xmlTagEtThreshold)) == 0) {
2234  edm::LogError("TriggerMenuXmlParser")
2235  << " Could not get energyOverflow for EnergySum condition (" << name << ")"
2236  << std::endl;
2237  return false;
2238  }
2239  if ( (n1 = findXMLChild(n1->getFirstChild(), m_xmlTagEnergyOverflow)) == 0) {
2240  edm::LogError("TriggerMenuXmlParser")
2241  << " Could not get energyOverflow for EnergySum condition (" << name << ")"
2242  << std::endl;
2243  return false;
2244  }
2245 
2246  int tmpInt = getBitFromNode(n1);
2247  if (tmpInt == 0) {
2248  objParameter[i].energyOverflow = false;
2249 
2250  //LogTrace("TriggerMenuXmlParser")
2251  //<< " EnergySum energyOverflow logical flag (hex) = "
2252  //<< std::hex << objParameter[i].energyOverflow << std::dec
2253  //<< std::endl;
2254  }
2255  else if (tmpInt == 1) {
2256  objParameter[i].energyOverflow = true;
2257 
2258  //LogTrace("TriggerMenuXmlParser")
2259  //<< " EnergySum energyOverflow logical flag (hex) = "
2260  //<< std::hex << objParameter[i].energyOverflow << std::dec
2261  //<< std::endl;
2262  }
2263  else {
2264  LogTrace("TriggerMenuXmlParser")
2265  << " EnergySum energyOverflow logical flag (hex) = " << std::hex << tmpInt
2266  << std::dec << " - wrong value! " << std::endl;
2267  return false;
2268  }
2269 
2270  }
2271 
2272  // object types - all same energySumObjType
2273  std::vector<L1GtObject> objType(nrObj, energySumObjType);
2274 
2275  // now create a new energySum condition
2276 
2277  L1GtEnergySumTemplate energySumCond(name);
2278 
2279  energySumCond.setCondType(cType);
2280  energySumCond.setObjectType(objType);
2281  energySumCond.setCondGEq(gEq);
2282  energySumCond.setCondChipNr(chipNr);
2283 
2284  energySumCond.setConditionParameter(objParameter);
2285 
2286  if (edm::isDebugEnabled() ) {
2287 
2288  std::ostringstream myCoutStream;
2289  energySumCond.print(myCoutStream);
2290  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2291 
2292  }
2293 
2294  // insert condition into the map
2295  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2296 
2297  edm::LogError("TriggerMenuXmlParser")
2298  << " Error: duplicate condition (" << name << ")"
2299  << std::endl;
2300 
2301  return false;
2302  }
2303  else {
2304 
2305  if (corrFlag) {
2306  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2307 
2308  }
2309  else {
2310  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
2311  }
2312 
2313  }
2314  */
2315 
2316  //
2317  return true;
2318 }
2319 
2332 bool l1t::TriggerMenuXmlParser::parseJetCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
2333  const std::string& name, unsigned int chipNr) {
2334 
2335  XERCES_CPP_NAMESPACE_USE
2336 
2337  /*
2338  // get condition, particle name and type name
2339  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2340  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2341  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2342 
2343  if (particle != m_xmlConditionAttrObjectJetCounts) {
2344  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for JetCounts condition ("
2345  << particle << ")" << std::endl;
2346  return false;
2347  }
2348 
2349  // object type and condition type
2350  L1GtObject jetCountsObjType = JetCounts;
2351  GtConditionType cType = TypeJetCounts;
2352 
2353  // global object
2354  int nrObj = 1;
2355 
2356  // get greater equal flag
2357 
2358  int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
2359  if (intGEq < 0) {
2360  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2361  << std::endl;
2362  return false;
2363  }
2364  // set the boolean value for the ge_eq mode
2365  bool gEq = (intGEq != 0);
2366 
2367  // get values
2368 
2369  // temporary storage of the parameters
2370  std::vector<L1GtJetCountsTemplate::ObjectParameter> objParameter(nrObj);
2371 
2372  // get countIndex value and fill into structure
2373  // they are expressed in base 10 (values: 0 - m_numberL1JetCounts)
2374  char* endPtr = const_cast<char*>(type.c_str());
2375  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2376 
2377  if (*endPtr != 0) {
2378 
2379  LogDebug("TriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
2380  << std::endl;
2381 
2382  return false;
2383  }
2384 
2385  // test if count index is out of range
2386  if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1JetCounts))) {
2387  LogDebug("TriggerMenuXmlParser") << "Count index " << typeInt
2388  << " outside range [0, " << m_numberL1JetCounts << "]" << std::endl;
2389 
2390  return false;
2391  }
2392 
2393  objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
2394 
2395  // get count threshold values and fill into structure
2396  std::vector<boost::uint64_t> tmpValues(nrObj);
2397 
2398  if ( !getConditionChildValuesOld(node, m_xmlTagCountThreshold, nrObj, tmpValues) ) {
2399  return false;
2400  }
2401 
2402  for (int i = 0; i < nrObj; i++) {
2403  objParameter[i].countThreshold = tmpValues[i];
2404 
2405  //LogTrace("TriggerMenuXmlParser")
2406  //<< " JetCounts count threshold (hex) for JetCounts object " << i << " = "
2407  //<< std::hex << objParameter[i].countThreshold << std::dec
2408  //<< std::endl;
2409 
2410  // TODO FIXME un-comment when tag available in XML file
2411 
2412  // // get countOverflow logical flag and fill into structure
2413  // DOMNode* n1;
2414  // if ( (n1 = findXMLChild(node->getFirstChild(), m_xmlTagCountThreshold)) == 0) {
2415  // edm::LogError("TriggerMenuXmlParser")
2416  // << " Could not get countOverflow for JetCounts condition ("
2417  // << name << ")"
2418  // << std::endl;
2419  // return false;
2420  // }
2421  // if ( (n1 = findXMLChild(n1->getFirstChild(), m_xmlTagCountThreshold)) == 0) {
2422  // edm::LogError("TriggerMenuXmlParser")
2423  // << " Could not get countOverflow for JetCounts condition ("
2424  // << name << ")"
2425  // << std::endl;
2426  // return false;
2427  // }
2428  //
2429  // int tmpInt = getBitFromNode(n1);
2430  // if (tmpInt == 0) {
2431  // objParameter[i].countOverflow = false;
2432  //
2433  // LogTrace("TriggerMenuXmlParser")
2434  // << " JetCounts countOverflow logical flag (hex) = "
2435  // << std::hex << objParameter[i].countOverflow << std::dec
2436  // << std::endl;
2437  // } else if (tmpInt == 1) {
2438  // objParameter[i].countOverflow = true;
2439  //
2440  // LogTrace("TriggerMenuXmlParser")
2441  // << " JetCounts countOverflow logical flag (hex) = "
2442  // << std::hex << objParameter[i].countOverflow << std::dec
2443  // << std::endl;
2444  // } else {
2445  // LogTrace("TriggerMenuXmlParser")
2446  // << " JetCounts countOverflow logical flag (hex) = "
2447  // << std::hex << tmpInt << std::dec << " - wrong value! "
2448  // << std::endl;
2449  // return false;
2450  // }
2451 
2452  }
2453 
2454  // object types - all same objType
2455  std::vector<L1GtObject> objType(nrObj, jetCountsObjType);
2456 
2457  // now create a new JetCounts condition
2458 
2459  L1GtJetCountsTemplate jetCountsCond(name);
2460 
2461  jetCountsCond.setCondType(cType);
2462  jetCountsCond.setObjectType(objType);
2463  jetCountsCond.setCondGEq(gEq);
2464  jetCountsCond.setCondChipNr(chipNr);
2465 
2466  jetCountsCond.setConditionParameter(objParameter);
2467 
2468  if (edm::isDebugEnabled() ) {
2469 
2470  std::ostringstream myCoutStream;
2471  jetCountsCond.print(myCoutStream);
2472  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2473 
2474  }
2475 
2476  // insert condition into the map
2477  if ( !insertConditionIntoMap(jetCountsCond, chipNr)) {
2478 
2479  edm::LogError("TriggerMenuXmlParser") << " Error: duplicate condition (" << name
2480  << ")" << std::endl;
2481 
2482  return false;
2483  } else {
2484 
2485  (m_vecJetCountsTemplate[chipNr]).push_back(jetCountsCond);
2486 
2487  }
2488 
2489  */
2490  //
2491  return true;
2492 }
2493 
2506 bool l1t::TriggerMenuXmlParser::parseCastor(XERCES_CPP_NAMESPACE::DOMNode* node,
2507  const std::string& name, unsigned int chipNr) {
2508 
2509  XERCES_CPP_NAMESPACE_USE
2510 
2511  /*
2512  // get condition, particle name and type name
2513  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2514  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2515  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2516 
2517  if (particle != m_xmlConditionAttrObjectCastor) {
2518  edm::LogError("TriggerMenuXmlParser")
2519  << "\nError: wrong particle for Castor condition ("
2520  << particle << ")" << std::endl;
2521  return false;
2522  }
2523 
2524  // object type and condition type
2525  // object type - irrelevant for CASTOR conditions
2526  GtConditionType cType = TypeCastor;
2527 
2528  // no objects for CASTOR conditions
2529 
2530  // set the boolean value for the ge_eq mode - irrelevant for CASTOR conditions
2531  bool gEq = false;
2532 
2533  // now create a new CASTOR condition
2534 
2535  L1GtCastorTemplate castorCond(name);
2536 
2537  castorCond.setCondType(cType);
2538  castorCond.setCondGEq(gEq);
2539  castorCond.setCondChipNr(chipNr);
2540 
2541 
2542  if (edm::isDebugEnabled() ) {
2543 
2544  std::ostringstream myCoutStream;
2545  castorCond.print(myCoutStream);
2546  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2547 
2548  }
2549 
2550  // insert condition into the map
2551  if ( !insertConditionIntoMap(castorCond, chipNr)) {
2552 
2553  edm::LogError("TriggerMenuXmlParser")
2554  << " Error: duplicate condition (" << name
2555  << ")" << std::endl;
2556 
2557  return false;
2558  } else {
2559 
2560  (m_vecCastorTemplate[chipNr]).push_back(castorCond);
2561 
2562  }
2563  */
2564 
2565  //
2566  return true;
2567 }
2568 
2569 
2582 bool l1t::TriggerMenuXmlParser::parseHfBitCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
2583  const std::string& name, unsigned int chipNr) {
2584 
2585  XERCES_CPP_NAMESPACE_USE
2586 
2587  /*
2588  // get condition, particle name and type name
2589  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2590  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2591  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2592 
2593  if (particle != m_xmlConditionAttrObjectHfBitCounts) {
2594  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for HfBitCounts condition ("
2595  << particle << ")" << std::endl;
2596  return false;
2597  }
2598 
2599  // object type and condition type
2600  L1GtObject hfBitCountsObjType = HfBitCounts;
2601  GtConditionType cType = TypeHfBitCounts;
2602 
2603  // global object
2604  int nrObj = 1;
2605 
2606  // get greater equal flag
2607 
2608  int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
2609  if (intGEq < 0) {
2610  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2611  << std::endl;
2612  return false;
2613  }
2614  // set the boolean value for the ge_eq mode
2615  bool gEq = (intGEq != 0);
2616 
2617  // get values
2618 
2619  // temporary storage of the parameters
2620  std::vector<L1GtHfBitCountsTemplate::ObjectParameter> objParameter(nrObj);
2621 
2622  // get countIndex value and fill into structure
2623  // they are expressed in base 10
2624  char* endPtr = const_cast<char*>(type.c_str());
2625  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2626 
2627  if (*endPtr != 0) {
2628 
2629  LogDebug("TriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
2630  << std::endl;
2631 
2632  return false;
2633  }
2634 
2635  // test if count index is out of range FIXME introduce m_numberL1HfBitCounts?
2636  //if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1HfBitCounts))) {
2637  // LogDebug("TriggerMenuXmlParser") << "Count index " << typeInt
2638  // << " outside range [0, " << m_numberL1HfBitCounts << "]" << std::endl;
2639  //
2640  // return false;
2641  //}
2642 
2643  objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
2644 
2645  // get count threshold values and fill into structure
2646  std::vector<boost::uint64_t> tmpValues(nrObj);
2647 
2648  if ( !getConditionChildValuesOld(node, m_xmlTagCountThreshold, nrObj, tmpValues) ) {
2649  return false;
2650  }
2651 
2652  for (int i = 0; i < nrObj; i++) {
2653  objParameter[i].countThreshold = tmpValues[i];
2654 
2655  //LogTrace("TriggerMenuXmlParser")
2656  //<< " HfBitCounts count threshold (hex) for HfBitCounts object " << i << " = "
2657  //<< std::hex << objParameter[i].countThreshold << std::dec
2658  //<< std::endl;
2659 
2660  }
2661 
2662  // object types - all same objType
2663  std::vector<L1GtObject> objType(nrObj, hfBitCountsObjType);
2664 
2665  // now create a new HfBitCounts condition
2666 
2667  L1GtHfBitCountsTemplate hfBitCountsCond(name);
2668 
2669  hfBitCountsCond.setCondType(cType);
2670  hfBitCountsCond.setObjectType(objType);
2671  hfBitCountsCond.setCondGEq(gEq);
2672  hfBitCountsCond.setCondChipNr(chipNr);
2673 
2674  hfBitCountsCond.setConditionParameter(objParameter);
2675 
2676  if (edm::isDebugEnabled() ) {
2677 
2678  std::ostringstream myCoutStream;
2679  hfBitCountsCond.print(myCoutStream);
2680  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2681 
2682  }
2683 
2684  // insert condition into the map
2685  if ( !insertConditionIntoMap(hfBitCountsCond, chipNr)) {
2686 
2687  edm::LogError("TriggerMenuXmlParser") << " Error: duplicate condition (" << name
2688  << ")" << std::endl;
2689 
2690  return false;
2691  } else {
2692 
2693  (m_vecHfBitCountsTemplate[chipNr]).push_back(hfBitCountsCond);
2694 
2695  }
2696 
2697  */
2698  //
2699  return true;
2700 }
2701 
2702 
2715 bool l1t::TriggerMenuXmlParser::parseHfRingEtSums(XERCES_CPP_NAMESPACE::DOMNode* node,
2716  const std::string& name, unsigned int chipNr) {
2717 
2718  XERCES_CPP_NAMESPACE_USE
2719 
2720  /*
2721  // get condition, particle name and type name
2722  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2723  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2724  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2725 
2726  if (particle != m_xmlConditionAttrObjectHfRingEtSums) {
2727  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for HfRingEtSums condition ("
2728  << particle << ")" << std::endl;
2729  return false;
2730  }
2731 
2732  // object type and condition type
2733  L1GtObject hfRingEtSumsObjType = HfRingEtSums;
2734  GtConditionType cType = TypeHfRingEtSums;
2735 
2736  // global object
2737  int nrObj = 1;
2738 
2739  // get greater equal flag
2740 
2741  int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
2742  if (intGEq < 0) {
2743  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2744  << std::endl;
2745  return false;
2746  }
2747  // set the boolean value for the ge_eq mode
2748  bool gEq = (intGEq != 0);
2749 
2750  // get values
2751 
2752  // temporary storage of the parameters
2753  std::vector<L1GtHfRingEtSumsTemplate::ObjectParameter> objParameter(nrObj);
2754 
2755  // get etSumIndex value and fill into structure
2756  // they are expressed in base 10
2757  char* endPtr = const_cast<char*>(type.c_str());
2758  long int typeInt = strtol(type.c_str(), &endPtr, 10); // base = 10
2759 
2760  if (*endPtr != 0) {
2761 
2762  LogDebug("TriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
2763  << std::endl;
2764 
2765  return false;
2766  }
2767 
2768  // test if ET sum index is out of range FIXME introduce m_numberL1HfRingEtSums?
2769  //if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1HfRingEtSums))) {
2770  // LogDebug("TriggerMenuXmlParser") << "Count index " << typeInt
2771  // << " outside range [0, " << m_numberL1HfRingEtSums << "]" << std::endl;
2772  //
2773  // return false;
2774  //}
2775 
2776  objParameter[0].etSumIndex = static_cast<unsigned int>(typeInt);
2777 
2778  // get ET sum threshold values and fill into structure
2779  std::vector<boost::uint64_t> tmpValues(nrObj);
2780 
2781  if ( !getConditionChildValuesOld(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
2782  return false;
2783  }
2784 
2785  for (int i = 0; i < nrObj; i++) {
2786  objParameter[i].etSumThreshold = tmpValues[i];
2787 
2788  //LogTrace("TriggerMenuXmlParser")
2789  //<< " HfRingEtSums count threshold (hex) for HfRingEtSums object " << i << " = "
2790  //<< std::hex << objParameter[i].etSumThreshold << std::dec
2791  //<< std::endl;
2792 
2793  }
2794 
2795  // object types - all same objType
2796  std::vector<L1GtObject> objType(nrObj, hfRingEtSumsObjType);
2797 
2798  // now create a new HfRingEtSums condition
2799 
2800  L1GtHfRingEtSumsTemplate hfRingEtSumsCond(name);
2801 
2802  hfRingEtSumsCond.setCondType(cType);
2803  hfRingEtSumsCond.setObjectType(objType);
2804  hfRingEtSumsCond.setCondGEq(gEq);
2805  hfRingEtSumsCond.setCondChipNr(chipNr);
2806 
2807  hfRingEtSumsCond.setConditionParameter(objParameter);
2808 
2809  if (edm::isDebugEnabled() ) {
2810 
2811  std::ostringstream myCoutStream;
2812  hfRingEtSumsCond.print(myCoutStream);
2813  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2814 
2815  }
2816 
2817  // insert condition into the map
2818  if ( !insertConditionIntoMap(hfRingEtSumsCond, chipNr)) {
2819 
2820  edm::LogError("TriggerMenuXmlParser") << " Error: duplicate condition (" << name
2821  << ")" << std::endl;
2822 
2823  return false;
2824  } else {
2825 
2826  (m_vecHfRingEtSumsTemplate[chipNr]).push_back(hfRingEtSumsCond);
2827 
2828  }
2829  */
2830 
2831  //
2832  return true;
2833 }
2834 
2847 bool l1t::TriggerMenuXmlParser::parseBptx(XERCES_CPP_NAMESPACE::DOMNode* node,
2848  const std::string& name, unsigned int chipNr) {
2849 
2850  XERCES_CPP_NAMESPACE_USE
2851 
2852  /*
2853  // get condition, particle name and type name
2854  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2855  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2856  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2857 
2858  if (particle != m_xmlConditionAttrObjectBptx) {
2859  edm::LogError("TriggerMenuXmlParser")
2860  << "\nError: wrong particle for Bptx condition ("
2861  << particle << ")" << std::endl;
2862  return false;
2863  }
2864 
2865  // object type and condition type
2866  // object type - irrelevant for BPTX conditions
2867  GtConditionType cType = TypeBptx;
2868 
2869  // no objects for BPTX conditions
2870 
2871  // set the boolean value for the ge_eq mode - irrelevant for BPTX conditions
2872  bool gEq = false;
2873 
2874  // now create a new BPTX condition
2875 
2876  L1GtBptxTemplate bptxCond(name);
2877 
2878  bptxCond.setCondType(cType);
2879  bptxCond.setCondGEq(gEq);
2880  bptxCond.setCondChipNr(chipNr);
2881 
2882  LogTrace("TriggerMenuXmlParser") << bptxCond << "\n" << std::endl;
2883 
2884  // insert condition into the map
2885  if ( !insertConditionIntoMap(bptxCond, chipNr)) {
2886 
2887  edm::LogError("TriggerMenuXmlParser")
2888  << " Error: duplicate condition (" << name
2889  << ")" << std::endl;
2890 
2891  return false;
2892  } else {
2893 
2894  (m_vecBptxTemplate[chipNr]).push_back(bptxCond);
2895 
2896  }
2897  */
2898 
2899  //
2900  return true;
2901 }
2902 
2903 
2916 bool l1t::TriggerMenuXmlParser::parseExternal(XERCES_CPP_NAMESPACE::DOMNode* node,
2917  const std::string& name, unsigned int chipNr) {
2918 
2919  XERCES_CPP_NAMESPACE_USE
2920 
2921  /*
2922  // get condition, particle name and type name
2923  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2924  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2925  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2926 
2927  if (particle != m_xmlConditionAttrObjectGtExternal) {
2928  edm::LogError("TriggerMenuXmlParser")
2929  << "\nError: wrong particle for External condition ("
2930  << particle << ")" << std::endl;
2931  return false;
2932  }
2933 
2934  // object type and condition type
2935  // object type - irrelevant for External conditions
2936  GtConditionType cType = TypeExternal;
2937 
2938  // no objects for External conditions
2939 
2940  // set the boolean value for the ge_eq mode - irrelevant for External conditions
2941  bool gEq = false;
2942 
2943  // now create a new External condition
2944 
2945  L1GtExternalTemplate externalCond(name);
2946 
2947  externalCond.setCondType(cType);
2948  externalCond.setCondGEq(gEq);
2949  externalCond.setCondChipNr(chipNr);
2950 
2951  LogTrace("TriggerMenuXmlParser") << externalCond << "\n" << std::endl;
2952 
2953  // insert condition into the map
2954  if ( !insertConditionIntoMap(externalCond, chipNr)) {
2955 
2956  edm::LogError("TriggerMenuXmlParser")
2957  << " Error: duplicate condition (" << name
2958  << ")" << std::endl;
2959 
2960  return false;
2961  } else {
2962 
2963  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2964 
2965  }
2966  */
2967 
2968  //
2969  return true;
2970 }
2971 
2972 
2986  XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& name,
2987  unsigned int chipNr) {
2988 
2989  XERCES_CPP_NAMESPACE_USE
2990 
2991  // create a new correlation condition
2992  CorrelationTemplate correlationCond(name);
2993 
2994  // check that the condition does not exist already in the map
2995  if ( !insertConditionIntoMap(correlationCond, chipNr)) {
2996 
2997  edm::LogError("TriggerMenuXmlParser")
2998  << " Error: duplicate correlation condition (" << name << ")"
2999  << std::endl;
3000 
3001  return false;
3002  }
3003 
3004  /*
3005  // get condition, particle name and type name
3006  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
3007  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
3008  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
3009 
3010  std::cout << " ****************************************** " << std::endl;
3011  std::cout << " DARRENS TEST OUTPUT (in parseCorrelation) " << std::endl;
3012  std::cout << " condition = " << condition << std::endl;
3013  std::cout << " particle = " << particle << std::endl;
3014  std::cout << " type = " << type << std::endl;
3015  std::cout << " name = " << name << std::endl;
3016 
3017  LogTrace("TriggerMenuXmlParser") << " Condition category: "
3018  << condition << ", particle: " << particle << ", type: " << type
3019  << "\n" << std::endl;
3020 
3021  // condition type
3022  GtConditionType cType = l1t::Type2cor;
3023 
3024  // two objects (for sure)
3025  const int nrObj = 2;
3026 
3027  // object types and greater equal flag - filled in the loop
3028  int intGEq[nrObj] = { -1, -1 };
3029  std::vector<L1GtObject> objType(nrObj);
3030  std::vector<GtConditionCategory> condCateg(nrObj);
3031 
3032  // correlation flag and index in the cor*vector
3033  const bool corrFlag = true;
3034  int corrIndexVal[nrObj] = { -1, -1 };
3035 
3036  // get the subconditions
3037 
3038  DOMNode* conditionsNode = node->getFirstChild();
3039  std::string conditionNameNodeName;
3040  conditionsNode = findXMLChild(conditionsNode, "", true,
3041  &conditionNameNodeName);
3042 
3043 
3044  for (int iSubCond = 0; iSubCond < nrObj; ++iSubCond) {
3045 
3046  // get for sub-condition: category, object name and type name and condition name
3047  condition = getXMLAttribute(conditionsNode, m_xmlConditionAttrCondition);
3048  particle = getXMLAttribute(conditionsNode, m_xmlConditionAttrObject);
3049  type = getXMLAttribute(conditionsNode, m_xmlConditionAttrType);
3050 
3051  LogTrace("TriggerMenuXmlParser") << " Sub-condition category: "
3052  << condition << ", particle: " << particle << ", type: "
3053  << type << ", name: " << conditionNameNodeName << "\n"
3054  << std::endl;
3055 
3056  // call the appropriate function for this condition
3057  if (condition == m_xmlConditionAttrConditionMuon) {
3058  if (!parseMuon(conditionsNode, conditionNameNodeName, chipNr,
3059  corrFlag)) {
3060  edm::LogError("TriggerMenuXmlParser")
3061  << "Error parsing sub-condition " << condition << ")"
3062  << " with name " << conditionNameNodeName << std::endl;
3063 
3064  }
3065 
3066  // get greater equal flag
3067  intGEq[iSubCond] = getGEqFlag(conditionsNode,
3068  m_xmlTagPtHighThreshold);
3069  if (intGEq[iSubCond] < 0) {
3070  edm::LogError("TriggerMenuXmlParser")
3071  << "Error getting \"greater or equal\" flag"
3072  << " for sub-condition " << conditionNameNodeName
3073  << " for the correlation condition " << name
3074  << std::endl;
3075  return false;
3076  }
3077 
3078  // set object type and sub-condition category
3079  objType[iSubCond] = Mu;
3080  condCateg[iSubCond] = CondMuon;
3081  corrIndexVal[iSubCond] = (m_corMuonTemplate[chipNr]).size() - 1;
3082 
3083  }
3084  else if (condition == m_xmlConditionAttrConditionCalo) {
3085  if (!parseCalo(conditionsNode, conditionNameNodeName, chipNr,
3086  corrFlag)) {
3087  edm::LogError("TriggerMenuXmlParser")
3088  << "Error parsing sub-condition " << condition << ")"
3089  << " with name " << conditionNameNodeName << std::endl;
3090 
3091  }
3092 
3093  // get greater equal flag
3094  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
3095  if (intGEq[iSubCond] < 0) {
3096  edm::LogError("TriggerMenuXmlParser")
3097  << "Error getting \"greater or equal\" flag"
3098  << " for sub-condition " << conditionNameNodeName
3099  << " for the correlation condition " << name
3100  << std::endl;
3101  return false;
3102  }
3103 
3104  // set object type and sub-condition category
3105  if (particle == m_xmlConditionAttrObjectNoIsoEG) {
3106  objType[iSubCond] = NoIsoEG;
3107  }
3108  else if (particle == m_xmlConditionAttrObjectIsoEG) {
3109  objType[iSubCond] = IsoEG;
3110  }
3111  else if (particle == m_xmlConditionAttrObjectCenJet) {
3112  objType[iSubCond] = CenJet;
3113  }
3114  else if (particle == m_xmlConditionAttrObjectTauJet) {
3115  objType[iSubCond] = TauJet;
3116  }
3117  else if (particle == m_xmlConditionAttrObjectForJet) {
3118  objType[iSubCond] = ForJet;
3119  }
3120  else {
3121  edm::LogError("TriggerMenuXmlParser")
3122  << "Wrong object type " << particle
3123  << " for sub-condition " << conditionNameNodeName
3124  << " from the correlation condition " << name
3125  << std::endl;
3126  return false;
3127  }
3128 
3129  condCateg[iSubCond] = CondCalo;
3130  corrIndexVal[iSubCond] = (m_corCaloTemplate[chipNr]).size() - 1;
3131 
3132  }
3133  else if (condition == m_xmlConditionAttrConditionEnergySum) {
3134  if (!parseEnergySum(conditionsNode, conditionNameNodeName, chipNr,
3135  corrFlag)) {
3136  edm::LogError("TriggerMenuXmlParser")
3137  << "Error parsing sub-condition " << condition << ")"
3138  << " with name " << conditionNameNodeName << std::endl;
3139 
3140  }
3141 
3142  // get greater equal flag
3143  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
3144  if (intGEq[iSubCond] < 0) {
3145  edm::LogError("TriggerMenuXmlParser")
3146  << "Error getting \"greater or equal\" flag"
3147  << " for sub-condition " << conditionNameNodeName
3148  << " for the correlation condition " << name
3149  << std::endl;
3150  return false;
3151  }
3152 
3153  // set object type and sub-condition category
3154  if (particle == m_xmlConditionAttrObjectETM) {
3155  objType[iSubCond] = ETM;
3156  }
3157  else if (particle == m_xmlConditionAttrObjectETT) {
3158  objType[iSubCond] = ETT;
3159  }
3160  else if (particle == m_xmlConditionAttrObjectHTT) {
3161  objType[iSubCond] = HTT;
3162  }
3163  else if (particle == m_xmlConditionAttrObjectHTM) {
3164  objType[iSubCond] = HTM;
3165  }
3166  else {
3167  edm::LogError("TriggerMenuXmlParser")
3168  << "Wrong object type " << particle
3169  << " for sub-condition " << conditionNameNodeName
3170  << " from the correlation condition " << name
3171  << std::endl;
3172  return false;
3173  }
3174 
3175  condCateg[iSubCond] = CondEnergySum;
3176  corrIndexVal[iSubCond] = (m_corEnergySumTemplate[chipNr]).size() - 1;
3177 
3178  }
3179  else {
3180  edm::LogError("TriggerMenuXmlParser")
3181  << "Unknown or un-adequate sub-condition (" << condition
3182  << ")" << " with name " << conditionNameNodeName
3183  << " for the correlation condition " << name << std::endl;
3184 
3185  return false;
3186  }
3187 
3188  conditionsNode = findXMLChild(conditionsNode->getNextSibling(), "",
3189  true, &conditionNameNodeName);
3190 
3191  }
3192 
3193  // get greater equal flag for the correlation condition
3194  bool gEq = true;
3195  if (intGEq[0] != intGEq[1]) {
3196  edm::LogError("TriggerMenuXmlParser")
3197  << "Inconsistent GEq flags for sub-conditions (" << condition
3198  << ")" << " with name " << conditionNameNodeName
3199  << " for the correlation condition " << name << std::endl;
3200  return false;
3201 
3202  }
3203  else {
3204  gEq = (intGEq[0] != 0);
3205 
3206  }
3207 
3208  // correlation parameters
3209 
3210  // temporary storage of the parameters
3211  CorrelationTemplate::CorrelationParameter corrParameter;
3212  std::vector<boost::uint64_t> tmpValues(nrObj);
3213 
3214  // get deltaEtaRange
3215 // if ( !getConditionChildValuesOld(node, m_xmlTagDeltaEta, 1, tmpValues) ) {
3216 // return false;
3217 // }
3218 //
3219 // corrParameter.deltaEtaRange = tmpValues[0];
3220 
3221  XERCES_CPP_NAMESPACE::DOMNode* node1 = findXMLChild(node->getFirstChild(),
3222  m_xmlTagDeltaEta);
3223 
3224  std::string valString;
3225 
3226  if (node1 == 0) {
3227  edm::LogError("TriggerMenuXmlParser")
3228  << " Could not get deltaEta for correlation condition "
3229  << name << ". " << std::endl;
3230  return false;
3231  }
3232  else {
3233  valString = getXMLTextValue(node1);
3234  }
3235 
3236  corrParameter.deltaEtaRange = valString;
3237 
3238 // // deltaPhi is larger than 64bit
3239 // if ( !getXMLHexTextValue128Old(findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi),
3240 // tmpValues[0], tmpValues[1])) {
3241 // edm::LogError("TriggerMenuXmlParser")
3242 // << " Could not get deltaPhi for correlation condition " << name << ". "
3243 // << std::endl;
3244 // return false;
3245 // }
3246 //
3247 // corrParameter.deltaPhiRange = tmpValues[0];
3248 
3249  node1 = findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi);
3250 
3251  if (node1 == 0) {
3252  return false;
3253  edm::LogError("TriggerMenuXmlParser")
3254  << " Could not get deltaPhi for correlation condition "
3255  << name << ". " << std::endl;
3256  }
3257  else {
3258  valString = getXMLTextValue(node1);
3259  }
3260 
3261  corrParameter.deltaPhiRange = valString;
3262 
3263  // get maximum number of bits for delta phi
3264  //LogTrace("TriggerMenuXmlParser")
3265  //<< " Counting deltaPhiMaxbits"
3266  //<< std::endl;
3267 
3268  unsigned int maxbits;
3269 
3270  if ( !countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits) ) {
3271  return false;
3272  }
3273 
3274  corrParameter.deltaPhiMaxbits = maxbits;
3275  //LogTrace("TriggerMenuXmlParser")
3276  //<< " deltaPhiMaxbits (dec) = " << maxbits
3277  //<< std::endl;
3278 
3279 
3280  // fill the correlation condition
3281  correlationCond.setCondType(cType);
3282  correlationCond.setObjectType(objType);
3283  correlationCond.setCondGEq(gEq);
3284  correlationCond.setCondChipNr(chipNr);
3285 
3286  correlationCond.setCond0Category(condCateg[0]);
3287  correlationCond.setCond1Category(condCateg[1]);
3288 
3289  correlationCond.setCond0Index(corrIndexVal[0]);
3290  correlationCond.setCond1Index(corrIndexVal[1]);
3291 
3292  correlationCond.setCorrelationParameter(corrParameter);
3293 
3294  if (edm::isDebugEnabled() ) {
3295 
3296  std::ostringstream myCoutStream;
3297  correlationCond.print(myCoutStream);
3298  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n"
3299  << std::endl;
3300 
3301  }
3302 
3303  // insert condition into the map
3304  // condition is not duplicate, check was done at the beginning
3305 
3306  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
3307 
3308  */
3309  //
3310  return true;
3311 }
3312 
3321 bool l1t::TriggerMenuXmlParser::parseId( l1t::Meta meta ) {
3322 
3323  XERCES_CPP_NAMESPACE_USE
3324 
3325 // DOMNode* doc = parser->getDocument();
3326 // DOMNode* n1 = doc->getFirstChild();
3327 
3328 // // we assume that the first child is m_xmlTagDef because it was checked in workXML
3329 
3330 // DOMNode* headerNode = n1->getFirstChild();
3331 // if (headerNode == 0) {
3332 // edm::LogError("TriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef
3333 // << "> tag found." << std::endl;
3334 // return false;
3335 // }
3336 
3337 // headerNode = findXMLChild(headerNode, m_xmlTagHeader);
3338 // if (headerNode == 0) {
3339 
3340 // LogDebug("TriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagHeader
3341 // << "> tag" << "\n - No header information." << std::endl;
3342 
3343 // } else {
3344 
3345 // DOMNode* idNode = headerNode->getFirstChild();
3346 
3347 // // find menu interface name
3348 // idNode = findXMLChild(idNode, m_xmlTagMenuInterface);
3349 // if (idNode == 0) {
3350 
3351 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3352 // << m_xmlTagMenuInterface << "> tag"
3353 // << "\n - Trigger menu interface name derived from file name." << std::endl;
3354 
3355 // // set the name of the trigger menu interface: from beginning of file names
3356 // // until beginning of "_L1T_Scales"
3357 // size_t xmlPos = m_triggerMenuName.find("_L1T_Scales", 0);
3358 // if (xmlPos == std::string::npos) {
3359 // LogTrace("TriggerMenuXmlParser")
3360 // << "\n Warning: Could not find \"_L1T_Scales\" " << "string in file name"
3361 // << "\n - Trigger menu interface name set to file name." << std::endl;
3362 // m_triggerMenuInterface = m_triggerMenuName;
3363 
3364 // } else {
3365 // m_triggerMenuInterface = m_triggerMenuName;
3366 // m_triggerMenuInterface.erase(
3367 // m_triggerMenuInterface.begin(), m_triggerMenuInterface.begin() + xmlPos);
3368 // }
3369 
3370 // } else {
3371 // m_triggerMenuInterface = getXMLTextValue(idNode);
3372 // }
3373 
3374 // // find menu interface creation date
3375 // idNode = headerNode->getFirstChild();
3376 // idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDate);
3377 
3378 // if (idNode == 0) {
3379 
3380 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3381 // << m_xmlTagMenuInterfaceDate << "> tag" << "\n - No creation date."
3382 // << m_triggerMenuInterfaceDate << std::endl;
3383 
3384 // } else {
3385 
3386 // m_triggerMenuInterfaceDate = getXMLTextValue(idNode);
3387 // }
3388 
3389 // // find menu interface creation author
3390 // idNode = headerNode->getFirstChild();
3391 // idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceAuthor);
3392 
3393 // if (idNode == 0) {
3394 
3395 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3396 // << m_xmlTagMenuInterfaceAuthor << "> tag" << "\n - No creation author."
3397 // << m_triggerMenuInterfaceAuthor << std::endl;
3398 
3399 // } else {
3400 
3401 // m_triggerMenuInterfaceAuthor = getXMLTextValue(idNode);
3402 // }
3403 
3404 // // find menu interface description
3405 // idNode = headerNode->getFirstChild();
3406 // idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDescription);
3407 
3408 // if (idNode == 0) {
3409 
3410 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3411 // << m_xmlTagMenuInterfaceDescription << "> tag" << "\n - No description."
3412 // << m_triggerMenuInterfaceDescription << std::endl;
3413 
3414 // } else {
3415 
3416 // m_triggerMenuInterfaceDescription = getXMLTextValue(idNode);
3417 // }
3418 
3419 // // find menu creation date
3420 // idNode = headerNode->getFirstChild();
3421 // idNode = findXMLChild(idNode, m_xmlTagMenuDate);
3422 
3423 // if (idNode == 0) {
3424 
3425 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3426 // << m_xmlTagMenuDate << "> tag" << "\n - No creation date."
3427 // << m_triggerMenuDate << std::endl;
3428 
3429 // } else {
3430 
3431 // m_triggerMenuDate = getXMLTextValue(idNode);
3432 // }
3433 
3434 // // find menu creation author
3435 // idNode = headerNode->getFirstChild();
3436 // idNode = findXMLChild(idNode, m_xmlTagMenuAuthor);
3437 
3438 // if (idNode == 0) {
3439 
3440 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3441 // << m_xmlTagMenuAuthor << "> tag" << "\n - No creation author."
3442 // << m_triggerMenuAuthor << std::endl;
3443 
3444 // } else {
3445 
3446 // m_triggerMenuAuthor = getXMLTextValue(idNode);
3447 // }
3448 
3449 // // find menu description
3450 // idNode = headerNode->getFirstChild();
3451 // idNode = findXMLChild(idNode, m_xmlTagMenuDescription);
3452 
3453 // if (idNode == 0) {
3454 
3455 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3456 // << m_xmlTagMenuDescription << "> tag" << "\n - No description."
3457 // << m_triggerMenuDescription << std::endl;
3458 
3459 // } else {
3460 
3461 // m_triggerMenuDescription = getXMLTextValue(idNode);
3462 // }
3463 
3464 // // find algorithm implementation tag
3465 
3466 // idNode = headerNode->getFirstChild();
3467 
3468 // idNode = findXMLChild(idNode, m_xmlTagMenuAlgImpl);
3469 // if (idNode == 0) {
3470 
3471 // m_algorithmImplementation = "";
3472 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3473 // << m_xmlTagMenuAlgImpl << "> tag"
3474 // << "\n - Algorithm implementation tag set to empty string." << std::endl;
3475 
3476 // } else {
3477 
3478 // m_algorithmImplementation = getXMLTextValue(idNode);
3479 // }
3480 
3481 // // find DB key for L1 scales
3482 
3483 // idNode = headerNode->getFirstChild();
3484 
3485 // idNode = findXMLChild(idNode, m_xmlTagScaleDbKey);
3486 // if (idNode == 0) {
3487 
3488 // m_scaleDbKey = "NULL";
3489 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
3490 // << m_xmlTagScaleDbKey << "> tag" << "\n - Scale key set to " << m_scaleDbKey
3491 // << " string." << std::endl;
3492 
3493 // } else {
3494 // m_scaleDbKey = getXMLTextValue(idNode);
3495 // }
3496 
3497 // }
3498 
3499 
3500 
3501  m_triggerMenuInterface = l1t2string( meta.name() );
3502  m_triggerMenuInterfaceDate = "2013-010-24T15:33:24";
3503  m_triggerMenuInterfaceAuthor = "Darren Puigh";
3504  m_triggerMenuInterfaceDescription = l1t2string( meta.comment() );
3505 // m_algorithmImplementation = l1t2string( meta.firmwareVersion() );
3506 // m_triggerMenuDate = l1t2string( meta.changesDate() );
3507 // m_triggerMenuAuthor = l1t2string( meta.changesAuthor() );
3508  m_triggerMenuDescription = l1t2string( meta.comment() );
3509  m_scaleDbKey = l1t2string( meta.scale_set() );
3510 
3511 
3512  int cnt = 0;
3513  for( l1t::RevisionList::revision_const_iterator revision = meta.revisions().revision().begin();
3514  revision != meta.revisions().revision().end(); ++revision ){
3515 
3516  LogDebug("l1t|Global")
3517  << "\t Revision " << cnt
3518  << "\t\t author = " << l1t2string( revision->author() )
3519  << "\t\t datetime = " << l1tDateTime2string( revision->datetime() )
3520  << std::endl;
3521 
3522  if( cnt==0 ){
3523  m_triggerMenuDate = l1tDateTime2string( revision->datetime() );
3524  m_triggerMenuAuthor = l1t2string( revision->author() );
3525  }
3526  cnt++;
3527  }
3528 
3529  //LogDebug("TriggerMenuXmlParser")
3530  LogDebug("l1t|Global")
3531  << "\n Parsed values from XML file DRULES"
3532  << "\nL1 MenuInterface: " << m_triggerMenuInterface
3533  << "\nL1 MenuInterface - Creation date: " << m_triggerMenuInterfaceDate
3534  << "\nL1 MenuInterface - Creation author: " << m_triggerMenuInterfaceAuthor
3535  << "\nL1 MenuInterface - Description: " << m_triggerMenuInterfaceDescription
3536  << "\n"
3537  << "\nAlgorithm implementation tag: " << m_algorithmImplementation
3538  << "\n"
3539  << "\nL1 Menu - Creation date: " << m_triggerMenuDate
3540  << "\nL1 Menu - Creation author: " << m_triggerMenuAuthor
3541  << "\nL1 Menu - Description: " << m_triggerMenuDescription
3542  << std::endl;
3543 
3544 
3545  // set the trigger menu name
3546  // format:
3547  // L1MenuInterface/ScaleDbKey/AlgorithmImplementationTag
3548 
3549  std::string menuName = m_triggerMenuInterface + "/" + m_scaleDbKey + "/" + m_algorithmImplementation;
3550 
3551  if (menuName != m_triggerMenuName) {
3552 
3553  LogDebug("TriggerMenuXmlParser") << "\n Warning: Inconsistent L1 menu name:"
3554  << "\n from XML file name: " << m_triggerMenuName
3555  << "\n from XML tag: " << menuName << std::endl;
3556 
3557  if (m_triggerMenuInterface != "") {
3558  if (m_scaleDbKey == "NULL") {
3559  m_triggerMenuName = m_triggerMenuInterface;
3560  } else {
3561  m_triggerMenuName = menuName;
3562  }
3563 
3564  LogTrace("TriggerMenuXmlParser") << "\n L1 menu name set to value from XML tag!"
3565  << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
3566 
3567  } else {
3568  LogTrace("TriggerMenuXmlParser") << "\n L1 menu name set to file name!"
3569  << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
3570 
3571  }
3572  }
3573 
3574  //
3575  return true;
3576 }
3577 
3589 bool l1t::TriggerMenuXmlParser::workCondition(XERCES_CPP_NAMESPACE::DOMNode* node,
3590  const std::string& name, unsigned int chipNr) {
3591 
3592  XERCES_CPP_NAMESPACE_USE
3593 
3594  // get condition, particle name and type name
3595  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
3596  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
3597  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
3598 
3599  LogDebug("l1t|Global")
3600  << "\n ****************************************** "
3601  << "\n workCondition "
3602  << "\n condition = " << condition
3603  << "\n particle = " << particle
3604  << "\n type = " << type
3605  << "\n name = " << name
3606  << std::endl;
3607 
3608  if (condition.empty() || particle.empty() || type.empty() ) {
3609 
3610  edm::LogError("TriggerMenuXmlParser") << "Missing attributes for condition " << name
3611  << std::endl;
3612 
3613  return false;
3614  }
3615 
3616  //LogTrace("TriggerMenuXmlParser")
3617  //<< " condition: " << condition << ", particle: " << particle
3618  //<< ", type: " << type << std::endl;
3619 
3620  // call the appropiate function for this condition
3621 
3622  /*
3623  if (condition == m_xmlConditionAttrConditionMuon) {
3624  return parseMuon(node, name, chipNr);
3625  }
3626  else if (condition == m_xmlConditionAttrConditionCalo) {
3627  return parseCalo(node, name, chipNr);
3628  }
3629  else if (condition == m_xmlConditionAttrConditionEnergySum) {
3630  return parseEnergySum(node, name, chipNr);
3631  }
3632  else if (condition == m_xmlConditionAttrConditionJetCounts) {
3633  return parseJetCounts(node, name, chipNr);
3634  }
3635  else if (condition == m_xmlConditionAttrConditionCastor) {
3636  return parseCastor(node, name, chipNr);
3637  }
3638  else if (condition == m_xmlConditionAttrConditionHfBitCounts) {
3639  return parseHfBitCounts(node, name, chipNr);
3640  }
3641  else if (condition == m_xmlConditionAttrConditionHfRingEtSums) {
3642  return parseHfRingEtSums(node, name, chipNr);
3643  }
3644  else if (condition == m_xmlConditionAttrConditionBptx) {
3645  return parseBptx(node, name, chipNr);
3646  }
3647  else if (condition == m_xmlConditionAttrConditionExternal) {
3648  return parseExternal(node, name, chipNr);
3649  }
3650  else if (condition == m_xmlConditionAttrConditionCorrelation) {
3651  return parseCorrelation(node, name, chipNr);
3652  }
3653  else {
3654  edm::LogError("TriggerMenuXmlParser")
3655  << "\n Error: unknown condition (" << condition << ")"
3656  << std::endl;
3657 
3658  return false;
3659  }
3660 
3661  */
3662  return true;
3663 
3664 }
3665 
3676 bool l1t::TriggerMenuXmlParser::parseConditions( l1t::ConditionList conditions ){
3677 
3678  XERCES_CPP_NAMESPACE_USE
3679 
3680  LogTrace("TriggerMenuXmlParser") << "\nParsing conditions" << std::endl;
3681 
3682  int chipNr = 1;
3683  LogDebug("l1t|Global") << " ====> condCalorimeter" << std::endl;
3684  for (l1t::ConditionList::condCalorimeter_const_iterator condCalo = conditions.condCalorimeter().begin();
3685  condCalo != conditions.condCalorimeter().end(); ++condCalo ){
3686 
3687  LogDebug("l1t|Global")
3688  << condCalo->name() << " {"
3689  << " comment: " << condCalo->comment()
3690  << " locked: " << condCalo->locked()
3691  << "}"
3692  << std::endl;
3693 
3694  l1t::CalorimeterCondition condition = (*condCalo);
3695 
3696  parseCalo( condition, chipNr );
3697  }
3698 
3699  LogDebug("l1t|Global") << " ====> condMuon " << std::endl;
3700  for (l1t::ConditionList::condMuon_const_iterator condMu = conditions.condMuon().begin();
3701  condMu != conditions.condMuon().end(); ++condMu ){
3702 
3703  LogDebug("l1t|Global")
3704  << condMu->name() << " {"
3705  << " comment: " << condMu->comment()
3706  << " locked: " << condMu->locked()
3707  << "}"
3708  << std::endl;
3709 
3710  l1t::MuonCondition condition = (*condMu);
3711 
3712  parseMuon( condition, chipNr );
3713  }
3714 
3715 
3716  return true;
3717 }
3718 
3731  unsigned int chipNr) {
3732 
3733  XERCES_CPP_NAMESPACE_USE
3734 
3735 // if (node == 0) {
3736 // LogDebug("TriggerMenuXmlParser")
3737 // << " Node is 0 in " << __PRETTY_FUNCTION__
3738 // << " can not parse the algorithm " << algName
3739 // << std::endl;
3740 // return false;
3741 // }
3742 
3743  // get alias
3744  std::string algAlias = l1t2string( algorithm.name() );
3745  std::string algName = l1t2string( algorithm.name() );
3746 
3747  if (algAlias == "") {
3748  algAlias = algName;
3749  LogDebug("TriggerMenuXmlParser")
3750  << "\n No alias defined for algorithm. Alias set to algorithm name."
3751  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3752  << std::endl;
3753  } else {
3754  //LogDebug("TriggerMenuXmlParser")
3755  LogDebug("l1t|Global") << "\n Alias defined for algorithm."
3756  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
3757  << std::endl;
3758  }
3759 
3760  // get the logical expression
3761  std::string logExpression = l1t2string( algorithm.logical_expression() );
3762 
3763  LogDebug("l1t|Global")
3764  << " Logical expression: " << logExpression
3765  << " Chip number: " << chipNr
3766  << std::endl;
3767 
3768  // determine output pin
3769  std::string pinString = l1t2string( algorithm.index() );
3770  int outputPin = 0;
3771 
3772  std::istringstream opStream(pinString);
3773 
3774  if ((opStream >> outputPin).fail()) {
3775  LogDebug("TriggerMenuXmlParser")
3776  << " Unable to convert pin string " << pinString
3777  << " to int for algorithm : " << algName
3778  << std::endl;
3779 
3780  return false;
3781  }
3782 
3783 
3784  //LogTrace("TriggerMenuXmlParser")
3785  LogDebug("l1t|Global") << " Output pin: " << outputPin
3786  << std::endl;
3787 
3788 
3789  // compute the bit number from chip number, output pin and order of the chips
3790  // pin numbering start with 1, bit numbers with 0
3791  int bitNumber = outputPin;// + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
3792 
3793  //LogTrace("TriggerMenuXmlParser")
3794  LogDebug("l1t|Global") << " Bit number: " << bitNumber
3795  << std::endl;
3796 
3797  // create a new algorithm and insert it into algorithm map
3798  L1GtAlgorithm alg(algName, logExpression, bitNumber);
3799  alg.setAlgoChipNumber(static_cast<int>(chipNr));
3800  alg.setAlgoAlias(algAlias);
3801 
3802  if (edm::isDebugEnabled() ) {
3803 
3804  std::ostringstream myCoutStream;
3805  alg.print(myCoutStream);
3806  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3807 
3808  }
3809 
3810  // insert algorithm into the map
3811  if ( !insertAlgorithmIntoMap(alg)) {
3812 
3813  return false;
3814  }
3815 
3816  return true;
3817 
3818 }
3819 
3820 /*
3821  * parseAlgorithms Parse the algorithms
3822  * NOTE: the algorithms used here are equivalent to "prealgo" from XML file
3823  * for the VERSION_FINAL
3824  * The "VERSION_PROTOTYPE algo" will be phased out later in the XML file
3825  * See L1GlobalTriggerConfig.h (in the attic)
3826  *
3827  * @param parser A reference to the XercesDOMParser to use.
3828  *
3829  * @return "true" if succeeded, "false" if an error occurred.
3830  *
3831  */
3832 
3833 bool l1t::TriggerMenuXmlParser::parseAlgorithms( l1t::AlgorithmList algorithms ) {
3834 
3835  XERCES_CPP_NAMESPACE_USE
3836 
3837  LogTrace("TriggerMenuXmlParser") << "\nParsing algorithms" << std::endl;
3838 
3839  int chipNr = 1;
3840  LogDebug("l1t|Global") << " ====> algorithms " << std::endl;
3841  for( l1t::AlgorithmList::algorithm_const_iterator i = algorithms.algorithm().begin();
3842  i != algorithms.algorithm().end(); ++i ){
3843 
3844  l1t::Algorithm algorithm = (*i);
3845  LogDebug("l1t|Global")
3846  << algorithm.name() << " {"
3847  << " index: " << algorithm.index()
3848  << " equation: " << algorithm.logical_expression()
3849  << " comment: " << algorithm.comment()
3850  << " locked: " << algorithm.locked()
3851  << "}"
3852  << std::endl;
3853 
3854 
3855  workAlgorithm( algorithm, chipNr );
3856  }
3857 
3858 
3859  return true;
3860 }
3861 
3872 bool l1t::TriggerMenuXmlParser::workTechTrigger(XERCES_CPP_NAMESPACE::DOMNode* node,
3873  const std::string& algName) {
3874 
3875  XERCES_CPP_NAMESPACE_USE
3876 
3877  if (node == 0) {
3878  LogDebug("TriggerMenuXmlParser")
3879  << " Node is 0 in " << __PRETTY_FUNCTION__
3880  << " can not parse the technical trigger " << algName
3881  << std::endl;
3882  return false;
3883  }
3884 
3885  // get the logical expression from the node
3886  std::string logExpression = getXMLTextValue(node);
3887 
3888  //LogTrace("TriggerMenuXmlParser")
3889  //<< " Logical expression: " << logExpression
3890  //<< std::endl;
3891 
3892  // determine bit number (use output pin tag)
3893  DOMNode* pinNode = findXMLChild(node->getFirstChild(), m_xmlTagOutput);
3894  std::string pinString;
3895  int outputPin = 0;
3896 
3897  pinNode = node->getFirstChild();
3898  if ( (pinNode = findXMLChild(pinNode, m_xmlTagOutputPin) ) != 0) {
3899  pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
3900 
3901  // convert pinString to integer
3902  std::istringstream opStream(pinString);
3903 
3904  if ((opStream >> outputPin).fail()) {
3905  LogDebug("TriggerMenuXmlParser")
3906  << " Unable to convert pin string " << pinString
3907  << " to int for technical trigger : " << algName
3908  << std::endl;
3909 
3910  return false;
3911  }
3912 
3913  }
3914 
3915  if (pinNode == 0) {
3916  LogTrace("TriggerMenuXmlParser")
3917  << " Warning: No pin number found for technical trigger: "
3918  << algName << std::endl;
3919 
3920  return false;
3921  }
3922 
3923  // set the bit number
3924  int bitNumber = outputPin;
3925 
3926  //LogTrace("TriggerMenuXmlParser")
3927  //<< " Bit number: " << bitNumber
3928  //<< std::endl;
3929 
3930  // create a new technical trigger and insert it into technical trigger map
3931  // alias set automatically to name
3932  L1GtAlgorithm alg(algName, logExpression, bitNumber);
3933  alg.setAlgoAlias(algName);
3934 
3935  if (edm::isDebugEnabled() ) {
3936 
3937  std::ostringstream myCoutStream;
3938  alg.print(myCoutStream);
3939  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3940 
3941  }
3942 
3943  // insert technical trigger into the map
3944  if ( !insertTechTriggerIntoMap(alg)) {
3945 
3946  return false;
3947  }
3948 
3949  return true;
3950 
3951 }
3952 
3953 /*
3954  * parseTechTriggers Parse the technical triggers
3955  *
3956  * @param parser A reference to the XercesDOMParser to use.
3957  *
3958  * @return "true" if succeeded, "false" if an error occurred.
3959  *
3960  */
3961 
3962 bool l1t::TriggerMenuXmlParser::parseTechTriggers(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3963 
3964  XERCES_CPP_NAMESPACE_USE
3965 
3966  //LogTrace("TriggerMenuXmlParser") << "\nParsing technical triggers" << std::endl;
3967 
3968  DOMNode* doc = parser->getDocument();
3969  DOMNode* node = doc->getFirstChild();
3970 
3971  DOMNode* algNode = node->getFirstChild();
3972  if (algNode == 0) {
3973  edm::LogError("TriggerMenuXmlParser")
3974  << " Error: No child found for " << m_xmlTagDef << std::endl;
3975  return false;
3976  }
3977 
3978  algNode = findXMLChild(algNode, m_xmlTagTechTriggers);
3979  if (algNode == 0) {
3980  edm::LogError("TriggerMenuXmlParser") << " Error: No <"
3981  << m_xmlTagTechTriggers << "> child found."
3982  << std::endl;
3983  return false;
3984  }
3985 
3986  // walk through technical triggers
3987  DOMNode* algNameNode = algNode->getFirstChild();
3988  std::string algNameNodeName;
3989  algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
3990 
3991  while (algNameNode != 0) {
3992  //LogTrace("TriggerMenuXmlParser")
3993  //<< " Found an technical trigger with name: " << algNameNodeName
3994  //<< std::endl;
3995 
3996  if ( !workTechTrigger(algNameNode, algNameNodeName)) {
3997  return false;
3998  }
3999 
4000  algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true,
4001  &algNameNodeName);
4002 
4003  }
4004 
4005  return true;
4006 }
4007 
4008 
4017 //bool TriggerMenuXmlParser::workXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
4018 bool l1t::TriggerMenuXmlParser::workXML( std::auto_ptr<l1t::L1TriggerMenu> tm ) {
4019 
4020  XERCES_CPP_NAMESPACE_USE
4021 
4022 
4023  // clear possible old maps
4024  clearMaps();
4025 
4026  l1t::Meta meta = tm->meta();
4027  l1t::ConditionList conditions = tm->conditions();
4028  l1t::AlgorithmList algorithms = tm->algorithms();
4029 
4030  if ( !parseId( meta ) ) {
4031  clearMaps();
4032  return false;
4033  }
4034 
4035  if ( !parseConditions( conditions ) ) {
4036  clearMaps();
4037  return false;
4038  }
4039 
4040  if ( !parseAlgorithms( algorithms ) ) {
4041  clearMaps();
4042  return false;
4043  }
4044 
4045 // if ( !parseTechTriggers(parser) ) {
4046 // clearMaps();
4047 // return false;
4048 // }
4049 
4050  return true;
4051 
4052 }
4053 
4054 
4055 // static class members
4056 
#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 &)
bool insertTechTriggerIntoMap(const L1GtAlgorithm &alg)
insert a technical trigger into technical trigger map
void setAlgoAlias(const std::string &algoAliasValue)
Definition: L1GtAlgorithm.h:72
std::string l1tDateTime2string(l1t::DateTime)
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
unsigned long long deltaPhiRange
Definition: MuonTemplate.h:95
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
unsigned long long deltaEtaRange
Definition: MuonTemplate.h:93
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 > > &)
long double T
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