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 #include "tmEventSetup/tmEventSetup.hh"
43 #include "tmEventSetup/esTriggerMenu.hh"
44 #include "tmEventSetup/esAlgorithm.hh"
45 #include "tmEventSetup/esCondition.hh"
46 #include "tmEventSetup/esObject.hh"
47 #include "tmEventSetup/esCut.hh"
48 #include "tmEventSetup/esScale.hh"
49 #include "tmGrammar/Algorithm.hh"
50 
51 
52 
53 // constructor
55  L1GtXmlParserTags(), m_xmlErrHandler(0), m_triggerMenuInterface("NULL"),
56  m_triggerMenuName("NULL"), m_triggerMenuImplementation("NULL"), m_scaleDbKey("NULL")
57 
58 {
59 
60  // menu names, scale key initialized to NULL due to ORACLE treatment of strings
61 
62  // empty
63 
64 }
65 
66 // destructor
68 
69  clearMaps();
70 
71 }
72 
73 // set the number of condition chips in GTL
75  const unsigned int& numberConditionChipsValue) {
76 
77  m_numberConditionChips = numberConditionChipsValue;
78 
79 }
80 
81 // set the number of pins on the GTL condition chips
82 void l1t::TriggerMenuXmlParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
83 
84  m_pinsOnConditionChip = pinsOnConditionChipValue;
85 
86 }
87 
88 // set the correspondence "condition chip - GTL algorithm word"
89 // in the hardware
91  const std::vector<int>& orderConditionChipValue) {
92 
93  m_orderConditionChip = orderConditionChipValue;
94 
95 }
96 
97 // set the number of physics trigger algorithms
99  const unsigned int& numberPhysTriggersValue) {
100 
101  m_numberPhysTriggers = numberPhysTriggersValue;
102 
103 }
104 
105 // set the number of technical triggers
106 /*
107 void l1t::TriggerMenuXmlParser::setGtNumberTechTriggers(
108  const unsigned int& numberTechTriggersValue) {
109 
110  m_numberTechTriggers = numberTechTriggersValue;
111 
112 }
113 */
114 
115 
116 // set the condition maps
117 void l1t::TriggerMenuXmlParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) {
118  m_conditionMap = condMap;
119 }
120 
121 // set the trigger menu name
123  m_triggerMenuInterface = menuInterface;
124 }
125 
127  m_triggerMenuName = menuName;
128 }
129 
131  m_triggerMenuImplementation = menuImplementation;
132 }
133 
134 // set menu associated scale key
136  m_scaleDbKey = scaleKey;
137 }
138 
139 // set the vectors containing the conditions
141  const std::vector<std::vector<MuonTemplate> >& vecMuonTempl) {
142 
143  m_vecMuonTemplate = vecMuonTempl;
144 }
145 
147  const std::vector<std::vector<CaloTemplate> >& vecCaloTempl) {
148 
149  m_vecCaloTemplate = vecCaloTempl;
150 }
151 
153  const std::vector<std::vector<EnergySumTemplate> >& vecEnergySumTempl) {
154 
155  m_vecEnergySumTemplate = vecEnergySumTempl;
156 }
157 
158 
159 
161  const std::vector<std::vector<ExternalTemplate> >& vecExternalTempl) {
162 
163  m_vecExternalTemplate = vecExternalTempl;
164 }
165 
166 
168  const std::vector<std::vector<CorrelationTemplate> >& vecCorrelationTempl) {
169 
170  m_vecCorrelationTemplate = vecCorrelationTempl;
171 }
172 
173 // set the vectors containing the conditions for correlation templates
174 //
176  const std::vector<std::vector<MuonTemplate> >& corMuonTempl) {
177 
178  m_corMuonTemplate = corMuonTempl;
179 }
180 
182  const std::vector<std::vector<CaloTemplate> >& corCaloTempl) {
183 
184  m_corCaloTemplate = corCaloTempl;
185 }
186 
188  const std::vector<std::vector<EnergySumTemplate> >& corEnergySumTempl) {
189 
190  m_corEnergySumTemplate = corEnergySumTempl;
191 }
192 
193 
194 
195 
196 // set the algorithm map (by algorithm names)
198  m_algorithmMap = algoMap;
199 }
200 
201 // set the algorithm map (by algorithm aliases)
203  m_algorithmAliasMap = algoMap;
204 }
205 
206 /*
207 // set the technical trigger map
208 void l1t::TriggerMenuXmlParser::setGtTechnicalTriggerMap(const AlgorithmMap& ttMap) {
209  m_technicalTriggerMap = ttMap;
210 }
211 */
212 
213 //
214 
215 
216 // parse def.xml and vme.xml files
218  const std::string& vmeXmlFile) {
219 
220  XERCES_CPP_NAMESPACE_USE
221 
222  // resize the vector of condition maps
223  // the number of condition chips should be correctly set before calling parseXmlFile
224  m_conditionMap.resize(m_numberConditionChips);
225 
226  m_vecMuonTemplate.resize(m_numberConditionChips);
227  m_vecCaloTemplate.resize(m_numberConditionChips);
228  m_vecEnergySumTemplate.resize(m_numberConditionChips);
229  m_vecExternalTemplate.resize(m_numberConditionChips);
230 
231  m_vecCorrelationTemplate.resize(m_numberConditionChips);
232  m_corMuonTemplate.resize(m_numberConditionChips);
233  m_corCaloTemplate.resize(m_numberConditionChips);
234  m_corEnergySumTemplate.resize(m_numberConditionChips);
235 
236 
237  // set the name of the trigger menu name:
238  // defXmlFile, stripped of absolute path and .xml
239  // will be overwritten by the value read from the xml file, with a warning if
240  // they are not the same
241  m_triggerMenuName = defXmlFile;
242  size_t xmlPos = m_triggerMenuName.find_last_of("/");
243  m_triggerMenuName.erase(m_triggerMenuName.begin(), m_triggerMenuName.begin()
244  + xmlPos + 1);
245 
246  xmlPos = m_triggerMenuName.find_last_of(".");
247  m_triggerMenuName.erase(m_triggerMenuName.begin() + xmlPos, m_triggerMenuName.end());
248 
249  // error handler for xml-parser
250  m_xmlErrHandler = 0;
251 
252  std::auto_ptr<l1t::L1TriggerMenu> tm(l1t::l1TriggerMenu(defXmlFile));
253 
254  LogTrace("TriggerMenuXmlParser") << "\nOpening XML-File: \n " << defXmlFile << std::endl;
255 
256  l1t::ConditionList conditions = tm->conditions();
257 
258  workXML( tm );
259 
260 // if ((parser = initXML(defXmlFile)) != 0) {
261 // workXML(parser);
262 // }
263 // cleanupXML(parser);
264 
265 }
266 
267 
268 // parse def.xml file
270 
271 
272  // resize the vector of condition maps
273  // the number of condition chips should be correctly set before calling parseXmlFile
274  m_conditionMap.resize(m_numberConditionChips);
275 
276  m_vecMuonTemplate.resize(m_numberConditionChips);
277  m_vecCaloTemplate.resize(m_numberConditionChips);
278  m_vecEnergySumTemplate.resize(m_numberConditionChips);
279  m_vecExternalTemplate.resize(m_numberConditionChips);
280 
281  m_vecCorrelationTemplate.resize(m_numberConditionChips);
282  m_corMuonTemplate.resize(m_numberConditionChips);
283  m_corCaloTemplate.resize(m_numberConditionChips);
284  m_corEnergySumTemplate.resize(m_numberConditionChips);
285 
286  // set the name of the trigger menu name:
287  // defXmlFile, stripped of absolute path and .xml
288  // will be overwritten by the value read from the xml file, with a warning if
289  // they are not the same
290  m_triggerMenuName = defXmlFile;
291  size_t xmlPos = m_triggerMenuName.find_last_of("/");
292  m_triggerMenuName.erase(m_triggerMenuName.begin(), m_triggerMenuName.begin()
293  + xmlPos + 1);
294 
295  xmlPos = m_triggerMenuName.find_last_of(".");
296  m_triggerMenuName.erase(m_triggerMenuName.begin() + xmlPos, m_triggerMenuName.end());
297 
298  // error handler for xml-parser
299  m_xmlErrHandler = 0;
300 
301  // LogTrace("TriggerMenuXmlParser") << "\nOpening XML-File V2: \n " << defXmlFile << std::endl;
302 
303  LogDebug("TriggerMenuXmlParser") << "\nOpening XML-File V2: \n " << defXmlFile << std::endl;
304 
305  using namespace tmeventsetup;
306  using namespace Algorithm;
307 
308  const esTriggerMenu* menu = tmeventsetup::getTriggerMenu(defXmlFile);
309 
310 
311  //get the meta data
312  m_triggerMenuDescription = menu->getComment();
313  m_triggerMenuDate = menu->getDatetime();
314  m_triggerMenuImplementation = menu->getFirmwareUuid(); //BLW: correct descriptor?
315  m_triggerMenuName = menu->getName();
316  m_triggerMenuInterface = menu->getVersion(); //BLW: correct descriptor?
317 
318  const std::map<std::string, esAlgorithm>& algoMap = menu->getAlgorithmMap();
319  const std::map<std::string, esCondition>& condMap = menu->getConditionMap();
320  const std::map<std::string, esScale>& scaleMap = menu->getScaleMap();
321 
322  // parse the scales
323  m_gtScales.setScalesName( menu->getScaleSetName() );
324  parseScales(scaleMap);
325 
326 
327  //loop over the algorithms
328  for (std::map<std::string, esAlgorithm>::const_iterator cit = algoMap.begin();
329  cit != algoMap.end(); cit++)
330  {
331  //condition chip (artifact) TO DO: Update
332  int chipNr = 0;
333 
334  //get algorithm
335  const esAlgorithm& algo = cit->second;
336 
337  //parse the algorithm
338  parseAlgorithmV2(algo,chipNr); //blw
339 
340  //get conditions for this algorithm
341  const std::vector<std::string>& rpn_vec = algo.getRpnVector();
342  for (size_t ii = 0; ii < rpn_vec.size(); ii++)
343  {
344  const std::string& token = rpn_vec.at(ii);
345  if (isGate(token)) continue;
346 // long hash = getHash(token);
347  const esCondition& condition = condMap.find(token)->second;
348 
349  //check to see if this condtion already exists
350  if ((m_conditionMap[chipNr]).count(condition.getName()) == 0) {
351 
352  // parse Calo Conditions (EG, Jets, Taus)
353  if(condition.getType() == esConditionType::SingleEgamma ||
354  condition.getType() == esConditionType::DoubleEgamma ||
355  condition.getType() == esConditionType::TripleEgamma ||
356  condition.getType() == esConditionType::QuadEgamma ||
357  condition.getType() == esConditionType::SingleTau ||
358  condition.getType() == esConditionType::DoubleTau ||
359  condition.getType() == esConditionType::TripleTau ||
360  condition.getType() == esConditionType::QuadTau ||
361  condition.getType() == esConditionType::SingleJet ||
362  condition.getType() == esConditionType::DoubleJet ||
363  condition.getType() == esConditionType::TripleJet ||
364  condition.getType() == esConditionType::QuadJet )
365  {
366  parseCaloV2(condition,chipNr,false); //blw
367 
368  // parse Energy Sums
369  } else if(condition.getType() == esConditionType::TotalEt ||
370  condition.getType() == esConditionType::TotalHt ||
371  condition.getType() == esConditionType::MissingEt ||
372  condition.getType() == esConditionType::MissingHt )
373  {
374  parseEnergySumV2(condition,chipNr,false);
375 
376  //parse Muons
377  } else if(condition.getType() == esConditionType::SingleMuon ||
378  condition.getType() == esConditionType::DoubleMuon ||
379  condition.getType() == esConditionType::TripleMuon ||
380  condition.getType() == esConditionType::QuadMuon )
381  {
382  parseMuonV2(condition,chipNr,false);
383 
384 
385  //parse Correlation Conditions
386  } else if(condition.getType() == esConditionType::MuonMuonCorrelation ||
387  condition.getType() == esConditionType::MuonEsumCorrelation ||
388  condition.getType() == esConditionType::CaloMuonCorrelation ||
389  condition.getType() == esConditionType::CaloCaloCorrelation ||
390  condition.getType() == esConditionType::CaloEsumCorrelation ||
391  condition.getType() == esConditionType::InvariantMass )
392  {
393  parseCorrelationV2(condition,chipNr);
394 
395  //parse Muons
396  } else if(condition.getType() == esConditionType::Externals )
397  {
398  parseExternalV2(condition,chipNr);
399 
400  }
401 
402  }//if condition is a new one
403  }//loop over conditions
404  }//loop over algorithms
405 
406  return;
407 
408 
409 }
410 
411 
412 
413 //
414 
416 
417  m_triggerMenuInterfaceDate = val;
418 
419 }
420 
422 
423  m_triggerMenuInterfaceAuthor = val;
424 
425 }
426 
428 
429  m_triggerMenuInterfaceDescription = val;
430 
431 }
432 
433 
435 
436  m_triggerMenuDate = val;
437 
438 }
439 
441 
442  m_triggerMenuAuthor = val;
443 
444 }
445 
447 
448  m_triggerMenuDescription = val;
449 
450 }
451 
453 
454  m_algorithmImplementation = val;
455 
456 }
457 
458 // private methods
459 
460 
461 
471 XERCES_CPP_NAMESPACE::XercesDOMParser* l1t::TriggerMenuXmlParser::initXML(const std::string &xmlFile) {
472 
473  XERCES_CPP_NAMESPACE_USE
474 
475  // try to initialize
476  try {
477  XMLPlatformUtils::Initialize();
478  }
479  catch (const XMLException& toCatch) {
480  char* message = XMLString::transcode(toCatch.getMessage());
481 
482  edm::LogError("TriggerMenuXmlParser")
483  << "Error during Xerces-c initialization! :"
484  << message << std::endl;
485 
486  XMLString::release(&message);
487  return 0;
488  }
489 
490  XercesDOMParser* parser = new XercesDOMParser();
491  parser->setValidationScheme(XercesDOMParser::Val_Always);
492  parser->setDoNamespaces(false); // we got no dtd
493 
494  if (m_xmlErrHandler == 0) { // redundant check
495  m_xmlErrHandler = (ErrorHandler*) new HandlerBase();
496  }
497  else {
498  // TODO ASSERTION
499  }
500  parser->setErrorHandler(m_xmlErrHandler);
501 
502  // try to parse the file
503  try {
504  parser->parse(xmlFile.c_str());
505  }
506  catch(const XMLException &toCatch) {
507  char* message = XMLString::transcode(toCatch.getMessage());
508 
509  edm::LogError("TriggerMenuXmlParser")
510  << "Exception while parsing XML: \n"
511  << message << std::endl;
512 
513  XMLString::release(&message);
514  delete parser;
515  delete m_xmlErrHandler;
516  m_xmlErrHandler = 0;
517  return 0;
518  }
519  catch (const DOMException &toCatch) {
520  char *message = XMLString::transcode(toCatch.msg);
521 
522  edm::LogError("TriggerMenuXmlParser")
523  << "DOM-Exception while parsing XML: \n"
524  << message << std::endl;
525 
526  XMLString::release(&message);
527  delete parser;
528  delete m_xmlErrHandler;
529  m_xmlErrHandler = 0;
530  return 0;
531  }
532  catch (...) {
533 
534  edm::LogError("TriggerMenuXmlParser")
535  << "Unexpected Exception while parsing XML!"
536  << std::endl;
537 
538  delete parser;
539  delete m_xmlErrHandler;
540  m_xmlErrHandler = 0;
541  return 0;
542  }
543 
544  return parser;
545 }
546 
547 // find a named child of a xml node
548 XERCES_CPP_NAMESPACE::DOMNode* l1t::TriggerMenuXmlParser::findXMLChild(
549  XERCES_CPP_NAMESPACE::DOMNode* startChild, const std::string& tagName, bool beginOnly,
550  std::string* rest) {
551 
552  XERCES_CPP_NAMESPACE_USE
553 
554  char* nodeName = 0;
555 
556  DOMNode *n1 = startChild;
557  if (n1 == 0) {
558  return 0;
559  }
560 
561  if ( !tagName.empty() ) {
562  nodeName = XMLString::transcode(n1->getNodeName());
563 
564  if (!beginOnly) {
565  //match the whole tag
566  while (XMLString::compareIString(nodeName, tagName.c_str())) {
567 
568  XMLString::release(&nodeName);
569  n1 = n1->getNextSibling();
570  if (n1 == 0) {
571  break;
572  }
573 
574  nodeName = XMLString::transcode(n1->getNodeName());
575  }
576  }
577  else {
578  // match only the beginning
579  while (XMLString::compareNIString(nodeName, tagName.c_str(), tagName.length())) {
580  XMLString::release(&nodeName);
581  n1 = n1->getNextSibling();
582  if (n1 == 0) {
583  break;
584  }
585 
586  nodeName = XMLString::transcode(n1->getNodeName());
587  }
588  if (n1 != 0 && rest != 0) {
589  *rest = std::string(nodeName).substr(tagName.length(), strlen(nodeName) - tagName.length());
590  }
591  }
592  }
593  else { // empty string given
594  while (n1->getNodeType() != DOMNode::ELEMENT_NODE) {
595  n1 = n1->getNextSibling();
596  if (n1 == 0) {
597  break;
598  }
599 
600  }
601  if (n1 != 0 && rest != 0) {
602  nodeName = XMLString::transcode(n1->getNodeName());
603  *rest = std::string(nodeName);
604  }
605  }
606 
607  XMLString::release(&nodeName);
608 
609  return n1;
610 
611 }
612 
622 std::string l1t::TriggerMenuXmlParser::getXMLAttribute(const XERCES_CPP_NAMESPACE::DOMNode* node,
623  const std::string& name) {
624 
625  XERCES_CPP_NAMESPACE_USE
626 
628 
629  // get attributes list
630  DOMNamedNodeMap* attributes = node->getAttributes();
631  if (attributes == 0) {
632  return ret;
633  }
634 
635  // get attribute node
636  XMLCh* attrName = XMLString::transcode(name.c_str());
637  DOMNode* attribNode = attributes->getNamedItem(attrName);
638 
639  XMLString::release(&attrName);
640  if (attribNode == 0) {
641  return ret;
642  }
643 
644  char* retCstr = XMLString::transcode(attribNode->getNodeValue());
645  ret = retCstr;
646  XMLString::release(&retCstr);
647 
648  return ret;
649 }
650 
659 std::string l1t::TriggerMenuXmlParser::getXMLTextValue(XERCES_CPP_NAMESPACE::DOMNode* node) {
660 
661  XERCES_CPP_NAMESPACE_USE
662 
664 
665  DOMNode* n1 = node;
666  if (n1 == 0) {
667  return ret;
668  }
669 
670  const XMLCh* retXmlCh = n1->getTextContent();
671  if (retXmlCh == 0) {
672  return ret;
673  }
674 
675  char* retCstr = XMLString::transcode(retXmlCh);
676  XMLString::trim(retCstr); // trim spaces
677 
678  ret = retCstr;
679  XMLString::release(&retCstr);
680 
681  return ret;
682 }
683 
695  boost::uint64_t& dstL, boost::uint64_t& dstH) {
696 
697  // string to determine start of hex value, do not ignore leading zeros
698  static const std::string valid_hex_start("0123456789ABCDEFabcdef");
699 
700  // string to determine end of hex value
701  static const std::string valid_hex_end("0123456789ABCDEFabcdef");
702 
703  std::string tempStr = hexString;
704 
705  // start / end position of the hex value in the string
706  unsigned int hexStart = tempStr.find_first_of(valid_hex_start);
707  unsigned int hexEnd = tempStr.find_first_not_of(valid_hex_end, hexStart);
708 
709  if (hexStart == hexEnd) {
710 
711  LogDebug("TriggerMenuXmlParser") << "No hex value found in: " << tempStr << std::endl;
712 
713  return false;
714  }
715 
716  tempStr = tempStr.substr(hexStart, hexEnd - hexStart);
717 
718  if (tempStr.empty() ) {
719 
720  LogDebug("TriggerMenuXmlParser") << "Empty value in " << __PRETTY_FUNCTION__
721  << std::endl;
722 
723  return false;
724  }
725 
726  // split the string
727  std::string tempStrH, tempStrL;
728 
729  if (tempStr.length() > 16) { // more than 64 bit
730  tempStrL = tempStr.substr(tempStr.length()-16, 16);
731  tempStrH = tempStr.substr(0, tempStr.length()-16);
732  }
733  else {
734  tempStrL = tempStr;
735  tempStrH = "0";
736  }
737 
738  // convert lower 64bit
739  char* endPtr = (char*) tempStrL.c_str();
740  boost::uint64_t tempUIntL = strtoull(tempStrL.c_str(), &endPtr, 16);
741 
742  if (*endPtr != 0) {
743 
744  LogDebug("TriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex."
745  << std::endl;
746 
747  return false;
748  }
749 
750  // convert higher64 bit
751  endPtr = (char*) tempStrH.c_str();
752  boost::uint64_t tempUIntH = strtoull(tempStrH.c_str(), &endPtr, 16);
753 
754  if (*endPtr != 0) {
755 
756  LogDebug("TriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex."
757  << std::endl;
758 
759  return false;
760  }
761 
762  dstL = tempUIntL;
763  dstH = tempUIntH;
764 
765  return true;
766 }
767 
778 bool l1t::TriggerMenuXmlParser::getXMLHexTextValue128Old(XERCES_CPP_NAMESPACE::DOMNode* node,
779  boost::uint64_t& dstL, boost::uint64_t& dstH) {
780 
781  if (node == 0) {
782 
783  LogDebug("TriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
784 
785  return false;
786  }
787 
788  boost::uint64_t tempUIntH, tempUIntL;
789 
790  std::string tempStr = getXMLTextValue(node);
791  if ( !hexString2UInt128(tempStr, tempUIntL, tempUIntH) ) {
792  return false;
793  }
794 
795  dstL = tempUIntL;
796  dstH = tempUIntH;
797 
798  return true;
799 }
800 
802  boost::uint64_t& dstL, boost::uint64_t& dstH) {
803 
804  boost::uint64_t tempUIntH, tempUIntL;
805 
806  std::string tempStr = childName;
807  if ( !hexString2UInt128(tempStr, tempUIntL, tempUIntH) ) {
808  return false;
809  }
810 
811  dstL = tempUIntL;
812  dstH = tempUIntH;
813 
814  return true;
815 }
816 
828 bool l1t::TriggerMenuXmlParser::getXMLHexTextValueOld(XERCES_CPP_NAMESPACE::DOMNode* node,
829  boost::uint64_t& dst) {
830 
831  boost::uint64_t dummyH; // dummy for eventual higher 64bit
832  boost::uint64_t tempUInt; // temporary unsigned integer
833 
834  if ( !getXMLHexTextValue128Old(node, tempUInt, dummyH) ) {
835  return false;
836  }
837 
838  if (dummyH != 0) {
839  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
840  return false;
841  }
842 
843  dst = tempUInt;
844 
845  return true;
846 }
847 
849  boost::uint64_t& dst) {
850 
851  boost::uint64_t dummyH; // dummy for eventual higher 64bit
852  boost::uint64_t tempUInt; // temporary unsigned integer
853 
854  if ( !getXMLHexTextValue128( childName, tempUInt, dummyH) ) {
855  return false;
856  }
857 
858  if (dummyH != 0) {
859  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
860  return false;
861  }
862 
863  dst = tempUInt;
864 
865  return true;
866 }
867 
879  unsigned int& dst) {
880 
881  XERCES_CPP_NAMESPACE_USE
882 
883  // should never happen...
884  // first try direct
885  std::string maxString = childName; // string for the maxbits
886 
887  // do the hex conversion
888 
889  boost::uint64_t maxBitsL, maxBitsH;
890  if ( !hexString2UInt128(maxString, maxBitsL, maxBitsH) ) {
891  return false;
892  }
893 
894  // count the bits
895  //LogTrace("TriggerMenuXmlParser")
896  //<< std::dec
897  //<< " words: dec: high (MSB) word = " << maxBitsH << " low word = " << maxBitsL
898  //<< std::hex << "\n"
899  //<< " words: hex: high (MSB) word = " << maxBitsH << " low word = " << maxBitsL
900  //<< std::dec
901  //<< std::endl;
902 
903  unsigned int counter = 0;
904 
905  while (maxBitsL != 0) {
906  // check if bits set countinously
907  if ( (maxBitsL & 1) == 0) {
908 
909  edm::LogError("TriggerMenuXmlParser")
910  << " Confused by not continous set bits for max value " << maxString
911  << std::endl;
912 
913  return false;
914  }
915 
916  maxBitsL >>= 1;
917  counter++;
918  }
919 
920  if ( (maxBitsH != 0) && (counter != 64)) {
921 
922  edm::LogError("TriggerMenuXmlParser")
923  << " Confused by not continous set bits for max value " << maxString
924  << std::endl;
925 
926  return false;
927  }
928 
929  while (maxBitsH != 0) {
930  //check if bits set countinously
931  if ( (maxBitsH & 1) == 0) {
932 
933  edm::LogError("TriggerMenuXmlParser")
934  << " Confused by not continous set bits for max value " << maxString
935  << std::endl;
936 
937  return false;
938  }
939 
940  maxBitsH >>= 1;
941  counter++;
942  }
943 
944  dst = counter;
945  return true;
946 
947 }
948 
949 
961 bool l1t::TriggerMenuXmlParser::getConditionChildValuesOld(XERCES_CPP_NAMESPACE::DOMNode* node,
962  const std::string& childName, unsigned int num, std::vector<boost::uint64_t>& dst) {
963 
964  XERCES_CPP_NAMESPACE_USE
965 
966  if (node == 0) {
967 
968  LogDebug("TriggerMenuXmlParser")
969  << "node == 0 in " << __PRETTY_FUNCTION__
970  << std::endl;
971 
972  return false;
973  }
974 
975  DOMNode* n1 = findXMLChild(node->getFirstChild(), childName);
976 
977  // if child not found
978  if (n1 == 0) {
979 
980  LogDebug("TriggerMenuXmlParser") << "Child of condition not found ( " << childName
981  << ")" << std::endl;
982 
983  return false;
984  }
985 
986  // no values are sucessfull
987  if (num == 0) {
988  return true;
989  }
990 
991  //
992  dst.reserve(num);
993 
994  //
995  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
996  for (unsigned int i = 0; i < num; i++) {
997  if (n1 == 0) {
998 
999  LogDebug("TriggerMenuXmlParser") << "Not enough values in condition child ( "
1000  << childName << ")" << std::endl;
1001 
1002  return false;
1003  }
1004 
1005  if ( !getXMLHexTextValueOld(n1, dst[i]) ) {
1006 
1007  edm::LogError("TriggerMenuXmlParser") << "Error converting condition child ( "
1008  << childName << ") value." << std::endl;
1009 
1010  return false;
1011  }
1012 
1013  n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue); // next child
1014  }
1015 
1016  return true;
1017 }
1018 
1026 void l1t::TriggerMenuXmlParser::cleanupXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
1027 
1028  XERCES_CPP_NAMESPACE_USE
1029 
1030  if (parser != 0) {
1031  delete parser;
1032  }
1033 
1034  if (m_xmlErrHandler != 0) {
1035  delete m_xmlErrHandler;
1036  m_xmlErrHandler = 0;
1037  }
1038 
1039  XMLPlatformUtils::Terminate();
1040 
1041 }
1042 
1043 
1044 // methods for the VME file
1045 
1046 
1056 bool l1t::TriggerMenuXmlParser::parseVmeXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
1057 
1058  XERCES_CPP_NAMESPACE_USE
1059 
1060  DOMDocument* doc = parser->getDocument();
1061  DOMNode* n1 = doc->getFirstChild();
1062 
1063  if (n1 == 0) {
1064 
1065  edm::LogError("TriggerMenuXmlParser") << "Error: Found no XML child" << std::endl;
1066 
1067  return false;
1068  }
1069 
1070  // find "vme"-tag
1071  n1 = findXMLChild(n1, m_xmlTagVme);
1072  if (n1 == 0) {
1073 
1074  edm::LogError("TriggerMenuXmlParser") << "Error: No vme tag found." << std::endl;
1075  return false;
1076  }
1077 
1078  n1 = n1->getFirstChild();
1079 
1080  unsigned int chipCounter = 0; // count chips
1081 
1082  while (chipCounter < m_numberConditionChips) {
1083 
1084  n1 = findXMLChild(n1, m_xmlTagChip, true);
1085  if (n1 == 0) {
1086  // just break if no more chips found
1087  break;
1088  }
1089 
1090  // node for a particle
1091  //DOMNode* particleNode = n1->getFirstChild(); // FIXME un-comment
1092 
1093  // FIXME parse vme.xml, modify the menu
1094 
1095  n1 = n1->getNextSibling();
1096  chipCounter++;
1097  } // end while chipCounter
1098 
1099  return true;
1100 
1101 }
1102 
1103 // methods for conditions and algorithms
1104 
1105 // clearMaps - delete all conditions and algorithms in
1106 // the maps and clear the maps.
1108 
1109  // loop over condition maps (one map per condition chip)
1110  // then loop over conditions in the map
1111  for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip
1112  != m_conditionMap.end(); itCondOnChip++) {
1113 
1114  // the conditions in the maps are deleted in L1uGtTriggerMenu, not here
1115 
1116  itCondOnChip->clear();
1117 
1118  }
1119 
1120  // the algorithms in the maps are deleted in L1uGtTriggerMenu, not here
1121  m_algorithmMap.clear();
1122 
1123 }
1124 
1125 // insertConditionIntoMap - safe insert of condition into condition map.
1126 // if the condition name already exists, do not insert it and return false
1128 
1129  std::string cName = cond.condName();
1130  LogTrace("TriggerMenuXmlParser")
1131  << " Trying to insert condition \"" << cName << "\" in the condition map." ;
1132 
1133  // no condition name has to appear twice!
1134  if ((m_conditionMap[chipNr]).count(cName) != 0) {
1135  LogTrace("TriggerMenuXmlParser") << " Condition " << cName
1136  << " already exists - not inserted!" << std::endl;
1137  return false;
1138  }
1139 
1140  (m_conditionMap[chipNr])[cName] = &cond;
1141  LogTrace("TriggerMenuXmlParser")
1142  << " OK - condition inserted!"
1143  << std::endl;
1144 
1145 
1146  return true;
1147 
1148 }
1149 
1150 // insert an algorithm into algorithm map
1152 
1153  std::string algName = alg.algoName();
1154  std::string algAlias = alg.algoAlias();
1155  //LogTrace("TriggerMenuXmlParser")
1156  //<< " Trying to insert algorithm \"" << algName << "\" in the algorithm map." ;
1157 
1158  // no algorithm name has to appear twice!
1159  if (m_algorithmMap.count(algName) != 0) {
1160  LogTrace("TriggerMenuXmlParser") << " Algorithm \"" << algName
1161  << "\"already exists in the algorithm map- not inserted!" << std::endl;
1162  return false;
1163  }
1164 
1165  if (m_algorithmAliasMap.count(algAlias) != 0) {
1166  LogTrace("TriggerMenuXmlParser") << " Algorithm alias \"" << algAlias
1167  << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
1168  return false;
1169  }
1170 
1171  // bit number less than zero or greater than maximum number of algorithms
1172  int bitNumber = alg.algoBitNumber();
1173  if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
1174  LogTrace("TriggerMenuXmlParser") << " Bit number " << bitNumber
1175  << " outside allowed range [0, " << m_numberPhysTriggers
1176  << ") - algorithm not inserted!" << std::endl;
1177  return false;
1178  }
1179 
1180  // maximum number of algorithms
1181  if (m_algorithmMap.size() >= m_numberPhysTriggers) {
1182  LogTrace("TriggerMenuXmlParser") << " More than maximum allowed "
1183  << m_numberPhysTriggers << " algorithms in the algorithm map - not inserted!"
1184  << std::endl;
1185  return false;
1186  }
1187 
1188  // chip number outside allowed values
1189  int chipNr = alg.algoChipNumber(static_cast<int>(m_numberConditionChips),
1190  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1191 
1192  if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
1193  LogTrace("TriggerMenuXmlParser") << " Chip number " << chipNr
1194  << " outside allowed range [0, " << m_numberConditionChips
1195  << ") - algorithm not inserted!" << std::endl;
1196  return false;
1197  }
1198 
1199  // output pin outside allowed values
1200  int outputPin = alg.algoOutputPin(static_cast<int>(m_numberConditionChips),
1201  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1202 
1203  if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
1204  LogTrace("TriggerMenuXmlParser") << " Output pin " << outputPin
1205  << " outside allowed range [0, " << m_pinsOnConditionChip
1206  << "] - algorithm not inserted!" << std::endl;
1207  return false;
1208  }
1209 
1210  // no two algorithms on the same chip can have the same output pin
1211  for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
1212 
1213  int iPin = (itAlgo->second).algoOutputPin( static_cast<int>(m_numberConditionChips),
1214  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1215  std::string iName = itAlgo->first;
1216  int iChip = (itAlgo->second).algoChipNumber(static_cast<int>(m_numberConditionChips),
1217  static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
1218 
1219  if ( (outputPin == iPin) && (chipNr == iChip)) {
1220  LogTrace("TriggerMenuXmlParser") << " Output pin " << outputPin
1221  << " is the same as for algorithm " << iName
1222  << "\n from the same chip number " << chipNr << " - algorithm not inserted!"
1223  << std::endl;
1224  return false;
1225  }
1226 
1227  }
1228 
1229  // insert algorithm
1230  m_algorithmMap[algName] = alg;
1231  m_algorithmAliasMap[algAlias] = alg;
1232 
1233  //LogTrace("TriggerMenuXmlParser")
1234  //<< " OK - algorithm inserted!"
1235  //<< std::endl;
1236 
1237  return true;
1238 
1239 }
1240 /*
1241 // insert a technical trigger into technical trigger map
1242 bool l1t::TriggerMenuXmlParser::insertTechTriggerIntoMap(const L1GtAlgorithm& alg) {
1243 
1244  std::string algName = alg.algoName();
1245  //LogTrace("TriggerMenuXmlParser")
1246  //<< " Trying to insert technical trigger \"" << algName
1247  //<< "\" in the technical trigger map." ;
1248 
1249  // no technical trigger name has to appear twice!
1250  if (m_technicalTriggerMap.count(algName) != 0) {
1251  LogTrace("TriggerMenuXmlParser") << " Technical trigger \""
1252  << algName
1253  << "\"already exists in the technical trigger map- not inserted!"
1254  << std::endl;
1255  return false;
1256  }
1257 
1258  // bit number less than zero or greater than maximum number of technical triggers
1259  int bitNumber = alg.algoBitNumber();
1260  if ((bitNumber < 0)
1261  || (bitNumber >= static_cast<int>(m_numberTechTriggers))) {
1262  LogTrace("TriggerMenuXmlParser") << " Bit number "
1263  << bitNumber << " outside allowed range [0, "
1264  << m_numberTechTriggers
1265  << ") - technical trigger not inserted!" << std::endl;
1266  return false;
1267  }
1268 
1269  // no two technical triggers can have the same bit number
1270  for (CItAlgo itAlgo = m_technicalTriggerMap.begin(); itAlgo
1271  != m_technicalTriggerMap.end(); itAlgo++) {
1272 
1273  int iBitNumber = (itAlgo->second).algoBitNumber();
1274  std::string iName = itAlgo->first;
1275 
1276  if ((iBitNumber == bitNumber)) {
1277  LogTrace("TriggerMenuXmlParser") << " Bit number "
1278  << iBitNumber << " is the same as for technical trigger "
1279  << iName << " - technical trigger not inserted!"
1280  << std::endl;
1281  return false;
1282  }
1283 
1284  }
1285 
1286  // maximum number of technical triggers
1287  if (m_technicalTriggerMap.size() >= m_numberTechTriggers) {
1288  LogTrace("TriggerMenuXmlParser")
1289  << " More than maximum allowed " << m_numberTechTriggers
1290  << " technical triggers in the technical trigger map - not inserted!"
1291  << std::endl;
1292  return false;
1293  }
1294 
1295  // insert technical trigger
1296  m_technicalTriggerMap[algName] = alg;
1297 
1298  //LogTrace("TriggerMenuXmlParser")
1299  //<< " OK - technical trigger inserted!"
1300  //<< std::endl;
1301 
1302  return true;
1303 
1304 }
1305 
1306 */
1307 
1308 // get the type of the condition, as defined in enum, from the condition type
1309 // as defined in the XML file
1311 
1312  if (type == m_xmlConditionAttrType1s) {
1313  return l1t::Type1s;
1314  }
1315 
1316  if (type == m_xmlConditionAttrType2s) {
1317  return l1t::Type2s;
1318  }
1319 
1320  if (type == m_xmlConditionAttrType3s) {
1321  return l1t::Type3s;
1322  }
1323 
1324  if (type == m_xmlConditionAttrType4s) {
1325  return l1t::Type4s;
1326  }
1327 
1328  if (type == m_xmlConditionAttrType2wsc) {
1329  return l1t::Type2wsc;
1330  }
1331 
1332  if (type == m_xmlConditionAttrType2cor) {
1333  return l1t::Type2cor;
1334  }
1335 
1336  return l1t::TypeNull;
1337 }
1338 
1349 
1350  if (type == m_xmlConditionAttrType1s) {
1351  return 1;
1352  }
1353 
1354  if (type == m_xmlConditionAttrType2s) {
1355  return 2;
1356  }
1357 
1358  if (type == m_xmlConditionAttrType3s) {
1359  return 3;
1360  }
1361 
1362  if (type == m_xmlConditionAttrType4s) {
1363  return 4;
1364  }
1365 
1366  if (type == m_xmlConditionAttrType2wsc) {
1367  return 2;
1368  }
1369 
1370  if (type == m_xmlConditionAttrType2cor) {
1371  return 2;
1372  }
1373 
1374  return -1;
1375 }
1376 
1385 int l1t::TriggerMenuXmlParser::getBitFromNode(XERCES_CPP_NAMESPACE::DOMNode* node) {
1386 
1387  if (getXMLAttribute(node, m_xmlAttrMode) != m_xmlAttrModeBit) {
1388 
1389  edm::LogError("TriggerMenuXmlParser") << "Invalid mode for single bit" << std::endl;
1390 
1391  return -1;
1392  }
1393 
1394  std::string tmpStr = getXMLTextValue(node);
1395  if (tmpStr == "0") {
1396  return 0;
1397  }
1398  else if (tmpStr == "1") {
1399  return 1;
1400  }
1401  else {
1402  edm::LogError("TriggerMenuXmlParser") << "Bad bit value (" << tmpStr << ")"
1403  << std::endl;
1404  return -1;
1405  }
1406 }
1407 
1417 int l1t::TriggerMenuXmlParser::getGEqFlag(XERCES_CPP_NAMESPACE::DOMNode* node,
1418  const std::string& nodeName) {
1419 
1420  XERCES_CPP_NAMESPACE_USE
1421 
1422  if (node == 0) {
1423 
1424  LogDebug("TriggerMenuXmlParser")
1425  << "node == 0 in " << __PRETTY_FUNCTION__
1426  << std::endl;
1427 
1428  return -1;
1429  }
1430 
1431  // usually the GEq flag is a child of the first child (the first element node)
1432  DOMNode* n1 = node->getFirstChild();
1433  n1 = findXMLChild(n1, nodeName);
1434 
1435  if (n1 != 0) {
1436  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagGEq);
1437  if (n1 == 0) {
1438 
1439  LogDebug("TriggerMenuXmlParser") << "No \"greater or equal\" tag found"
1440  << std::endl;
1441 
1442  return -1;
1443  }
1444 
1445  return getBitFromNode(n1);
1446  }
1447  else {
1448 
1449  return -1;
1450 
1451  }
1452 
1453 }
1454 
1467 bool l1t::TriggerMenuXmlParser::getMuonMipIsoBits(XERCES_CPP_NAMESPACE::DOMNode* node,
1468  unsigned int num, std::vector<bool>& mipDst, std::vector<bool>& isoEnDst,
1469  std::vector<bool>& isoReqDst) {
1470 
1471  XERCES_CPP_NAMESPACE_USE
1472 
1473  if (node == 0) {
1474  return false;
1475  }
1476 
1477  // find ptLowThreshold child
1478  DOMNode* n1 = findXMLChild(node->getFirstChild(), m_xmlTagPtLowThreshold);
1479 
1480  if (n1 == 0) {
1481  return false;
1482  }
1483 
1484  // get first value tag
1485  n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
1486 
1487  for (unsigned int i = 0; i < num; i++) {
1488 
1489  if (n1 == 0) {
1490  return false;
1491  }
1492 
1493  // MIP bit
1494 
1495  DOMNode* bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableMip);
1496  if (bitnode == 0) {
1497  return true;
1498  }
1499 
1500  int tmpint = getBitFromNode(bitnode);
1501  if (tmpint < 0) {
1502  return false;
1503  }
1504 
1505  mipDst[i] = (tmpint != 0);
1506 
1507  //LogTrace("TriggerMenuXmlParser")
1508  //<< " MIP bit value for muon " << i << " = " << mipDst[i]
1509  //<< std::endl;
1510 
1511 
1512  // enable iso bit
1513  bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableIso);
1514  if (bitnode == 0) {
1515  return true;
1516  }
1517 
1518  tmpint = getBitFromNode(bitnode);
1519  if (tmpint < 0) {
1520  return false;
1521  }
1522 
1523  isoEnDst[i] = (tmpint != 0);
1524 
1525  //LogTrace("TriggerMenuXmlParser")
1526  //<< " Enabled iso bit value for muon " << i << " = " << isoEnDst[i]
1527  //<< std::endl;
1528 
1529  // request iso bit
1530  bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagRequestIso);
1531  if (bitnode == 0) {
1532  return true;
1533  }
1534 
1535  tmpint = getBitFromNode(bitnode);
1536  if (tmpint < 0) {
1537  return false;
1538  }
1539 
1540  isoReqDst[i] = (tmpint != 0);
1541 
1542  //LogTrace("TriggerMenuXmlParser")
1543  //<< " Request iso bit value for muon " << i << " = " << isoReqDst[i]
1544  //<< std::endl;
1545 
1546  //
1547  n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue); // next value
1548  }
1549 
1550  return true;
1551 }
1552 
1553 
1555  std::stringstream ss;
1556  ss << data;
1557  return ss.str();
1558 }
1560  std::stringstream ss;
1561  ss << std::setfill('0');
1562  ss << std::setw(4) << date.year() << "-" << std::setw(2) << date.month() << "-" << std::setw(2) << date.day() << "T";
1563  ss << std::setw(2) << date.hours() << ":" << std::setw(2) << date.minutes() << ":" << std::setw(2) << date.seconds();
1564  //ss << data;
1565  return ss.str();
1566 }
1567 int l1t::TriggerMenuXmlParser::l1t2int( l1t::RelativeBx data ){ //l1t::RelativeBx
1568  std::stringstream ss;
1569  ss << data;
1570  int value;
1571  ss >> value;
1572  return value;
1573 }
1575  std::stringstream ss;
1576  ss << data;
1577  int value;
1578  ss >> value;
1579  return value;
1580 }
1581 
1582 
1590 bool l1t::TriggerMenuXmlParser::parseScales(std::map<std::string, tmeventsetup::esScale> scaleMap) {
1591 
1592  using namespace tmeventsetup;
1593 
1594 // Setup ScaleParameter to hold information from parsing
1603 
1604 // Start by parsing the Scale Map
1605  for (std::map<std::string, esScale>::const_iterator cit = scaleMap.begin();
1606  cit != scaleMap.end(); cit++)
1607  {
1608  const esScale& scale = cit->second;
1609 
1611  if (scale.getObjectType() == esObjectType::Muon) scaleParam = &muScales;
1612  else if (scale.getObjectType() == esObjectType::Egamma) scaleParam = &egScales;
1613  else if (scale.getObjectType() == esObjectType::Tau) scaleParam = &tauScales;
1614  else if (scale.getObjectType() == esObjectType::Jet) scaleParam = &jetScales;
1615  else if (scale.getObjectType() == esObjectType::ETT) scaleParam = &ettScales;
1616  else if (scale.getObjectType() == esObjectType::ETM) scaleParam = &etmScales;
1617  else if (scale.getObjectType() == esObjectType::HTT) scaleParam = &httScales;
1618  else if (scale.getObjectType() == esObjectType::HTM) scaleParam = &htmScales;
1619  else scaleParam = 0;
1620 
1621  if(scaleParam != 0) {
1622  switch(scale.getScaleType()) {
1623  case esScaleType::EtScale: {
1624  scaleParam->etMin = scale.getMinimum();
1625  scaleParam->etMax = scale.getMaximum();
1626  scaleParam->etStep = scale.getStep();
1627 
1628  //Get bin edges
1629  const std::vector<esBin> binsV = scale.getBins();
1630  for(unsigned int i=0; i<binsV.size(); i++) {
1631  const esBin& bin = binsV.at(i);
1632  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
1633  scaleParam->etBins.push_back(binLimits);
1634  }
1635 
1636  // If this is an energy sum fill dummy values for eta and phi
1637  // There are no scales for these in the XML so the other case statements will not be seen....do it here.
1638  if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT ||
1639  scale.getObjectType() == esObjectType::ETM || scale.getObjectType() == esObjectType::HTM ) {
1640 
1641  scaleParam->etaMin = -1.;
1642  scaleParam->etaMax = -1.;
1643  scaleParam->etaStep = -1.;
1644  if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT) {
1645  scaleParam->phiMin = -1.;
1646  scaleParam->phiMax = -1.;
1647  scaleParam->phiStep = -1.;
1648  }
1649  }
1650  }
1651  break;
1652  case esScaleType::EtaScale: {
1653  scaleParam->etaMin = scale.getMinimum();
1654  scaleParam->etaMax = scale.getMaximum();
1655  scaleParam->etaStep = scale.getStep();
1656 
1657  //Get bin edges
1658  const std::vector<esBin> binsV = scale.getBins();
1659  for(unsigned int i=0; i<binsV.size(); i++) {
1660  const esBin& bin = binsV.at(i);
1661  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
1662  scaleParam->etaBins.push_back(binLimits);
1663  }
1664  }
1665  break;
1666  case esScaleType::PhiScale: {
1667  scaleParam->phiMin = scale.getMinimum();
1668  scaleParam->phiMax = scale.getMaximum();
1669  scaleParam->phiStep = scale.getStep();
1670 
1671  //Get bin edges
1672  const std::vector<esBin> binsV = scale.getBins();
1673  for(unsigned int i=0; i<binsV.size(); i++) {
1674  const esBin& bin = binsV.at(i);
1675  std::pair<double, double> binLimits(bin.minimum, bin.maximum);
1676  scaleParam->phiBins.push_back(binLimits);
1677  }
1678  }
1679  break;
1680  default:
1681 
1682  break;
1683  } //end switch
1684  } //end valid scale
1685  } //end loop over scaleMap
1686 
1687  // put the ScaleParameters into the class
1688  m_gtScales.setMuonScales(muScales);
1689  m_gtScales.setEGScales(egScales);
1690  m_gtScales.setTauScales(tauScales);
1691  m_gtScales.setJetScales(jetScales);
1692  m_gtScales.setETTScales(ettScales);
1693  m_gtScales.setETMScales(etmScales);
1694  m_gtScales.setHTTScales(httScales);
1695  m_gtScales.setHTMScales(htmScales);
1696 
1697 
1698 
1699  return true;
1700 }
1701 
1713 bool l1t::TriggerMenuXmlParser::parseMuon(l1t::MuonCondition condMu,
1714  unsigned int chipNr, const bool corrFlag) {
1715 
1716  XERCES_CPP_NAMESPACE_USE
1717 
1718  // get condition, particle name (must be muon) and type name
1719  std::string condition = "muon";
1720  std::string particle = "muon";//l1t2string( condMu.objectType() );
1721  std::string type = l1t2string( condMu.type() );
1722  std::string name = l1t2string( condMu.name() );
1723 
1724  if( particle=="mu" ) particle = "muon";
1725 
1726  if( type=="double_wsc" ) type = "2_wsc";
1727  else if( type=="single" ) type = "1_s";
1728  else if( type=="double" ) type = "2_s";
1729  else if( type=="triple" ) type = "3";
1730  else if( type=="quad" ) type = "4";
1731 
1732  LogDebug("TriggerMenuXmlParser")
1733  << "\n ****************************************** "
1734  << "\n parseMuon "
1735  << "\n condition = " << condition
1736  << "\n particle = " << particle
1737  << "\n type = " << type
1738  << "\n name = " << name
1739  << std::endl;
1740 
1741  if (particle != m_xmlConditionAttrObjectMu) {
1742  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for muon-condition ("
1743  << particle << ")" << std::endl;
1744  return false;
1745  }
1746 
1747  // get greater equal flag
1748  std::string str_etComparison = l1t2string( condMu.comparison_operator() );
1749 
1750  int nrObj = getNumFromType(type);
1751  if (nrObj < 0) {
1752  edm::LogError("TriggerMenuXmlParser") << "Unknown type for muon-condition (" << type
1753  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
1754  return false;
1755  }
1756 
1757  // get greater equal flag
1758  int intGEq = ( str_etComparison=="ge" ) ? 1 : 0;
1759  if (intGEq < 0) {
1760  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
1761  << std::endl;
1762  return false;
1763  }
1764  // set the boolean value for the ge_eq mode
1765  bool gEq = (intGEq != 0);
1766 
1767 // // get values
1768 
1769  // temporary storage of the parameters
1770  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1771  MuonTemplate::CorrelationParameter corrParameter;
1772 
1773  // need at least two values for deltaPhi
1774  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1775  tmpValues.reserve( nrObj );
1776 
1777  if( int(condMu.objectRequirements().objectRequirement().size())!=nrObj ){
1778  edm::LogError("TriggerMenuXmlParser") << " condMu objects: nrObj = " << nrObj
1779  << "condMu.objectRequirements().objectRequirement().size() = "
1780  << condMu.objectRequirements().objectRequirement().size()
1781  << std::endl;
1782  return false;
1783  }
1784 
1785 
1786  std::string str_chargeCorrelation = l1t2string( condMu.requestedChargeCorr() );
1787 
1788  unsigned int chargeCorrelation = 0;
1789  if( str_chargeCorrelation=="ig" ) chargeCorrelation = 1;
1790  else if( str_chargeCorrelation=="ls" ) chargeCorrelation = 2;
1791  else if( str_chargeCorrelation=="os" ) chargeCorrelation = 4;
1792 
1793  //getXMLHexTextValue("1", dst);
1794  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
1795 
1796  std::string str_condMu = "";
1797  boost::uint64_t tempUIntH, tempUIntL;
1798  boost::uint64_t dst;
1799  int cnt = 0;
1800  for( l1t::MuonObjectRequirements::objectRequirement_const_iterator objPar = condMu.objectRequirements().objectRequirement().begin();
1801  objPar != condMu.objectRequirements().objectRequirement().end(); ++objPar ){
1802 
1803  // ET Threshold
1804  str_condMu = l1t2string( objPar->ptThreshold() );
1805  if( !getXMLHexTextValue(str_condMu, dst) ) return false;
1806  //if( cnt<nrObj ) objParameter[cnt].etThreshold = dst;
1808  if( cnt<nrObj ){
1809  objParameter[cnt].ptHighThreshold = objPar->ptThreshold();
1810  objParameter[cnt].ptLowThreshold = objPar->ptThreshold();
1811  }
1812 
1813  // Eta Range
1814  //str_condMu = "ffff";
1815  str_condMu = "7f7f";
1816  //str_condMu = "0f0f";
1817  if( !getXMLHexTextValue(str_condMu, dst) ) return false;
1818  if( cnt<nrObj ) objParameter[cnt].etaRange = dst;
1819 
1820  // Phi Range
1821  str_condMu = "3ffff";
1822  if( !getXMLHexTextValue(str_condMu, dst) ) return false;
1823  //if( cnt<nrObj ) objParameter[cnt].phiRange = dst;
1824  getXMLHexTextValue("8f", dst);
1825  objParameter[cnt].phiHigh = dst;//tmpValues[i];
1826  objParameter[cnt].phiLow = dst;//tmpValues[i];
1827 
1828  objParameter[cnt].enableMip = false;//tmpMip[i];
1829  objParameter[cnt].enableIso = false;//tmpEnableIso[i];
1830  objParameter[cnt].requestIso = false;//tmpRequestIso[i];
1831 
1832  std::string str_charge = l1t2string( objPar->requestedCharge() );
1833  int charge = 0;
1834  if( str_charge=="ign" ) charge = -1;
1835  else if( str_charge=="pos" ) charge = 0;
1836  else if( str_charge=="neg" ) charge = 1;
1837 
1838  objParameter[cnt].charge = charge;
1839 
1840  int cntQual=0;
1841  int qualityLUT = 0;
1842  for( l1t::MuonQualityLUT::quality_const_iterator iQualFlag = objPar->qualityLut().quality().begin();
1843  iQualFlag != objPar->qualityLut().quality().end(); ++iQualFlag ){
1844 
1845  bool flag = (*iQualFlag);
1846 
1847  qualityLUT |= (flag << cntQual);
1848 
1849  LogDebug("TriggerMenuXmlParser")
1850  << "\n quality flag " << cntQual << " = " << flag
1851  << "\n qualityLUT = " << qualityLUT
1852  << std::endl;
1853 
1854  cntQual++;
1855  }
1856 
1857  objParameter[cnt].qualityLUT = qualityLUT;
1858 
1859 
1860  int cntIso=0;
1861  int isolationLUT = 0;
1862  for( l1t::MuonIsolationLUT::isolation_const_iterator iIsoFlag = objPar->isolationLut().isolation().begin();
1863  iIsoFlag != objPar->isolationLut().isolation().end(); ++iIsoFlag ){
1864 
1865  bool flag = (*iIsoFlag);
1866 
1867  isolationLUT |= (flag << cntIso);
1868 
1869  LogDebug("TriggerMenuXmlParser")
1870  << "\n isolation flag " << cntIso << " = " << flag
1871  << "\n isolationLUT = " << isolationLUT
1872  << std::endl;
1873 
1874  cntIso++;
1875  }
1876 
1877  objParameter[cnt].isolationLUT = isolationLUT;
1878 
1879 
1880  int cntEta=0;
1881  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
1882  // Temporary before translation
1883  for( l1t::MuonObjectRequirement::etaWindow_const_iterator etaWindow =objPar->etaWindow().begin();
1884  etaWindow != objPar->etaWindow().end(); ++etaWindow ){
1885 
1886  LogDebug("TriggerMenuXmlParser")
1887  << "\n etaWindow lower = " << etaWindow->lower()
1888  << "\n etaWindow upper = " << etaWindow->upper()
1889  << std::endl;
1890  if( cntEta==0 ){ etaWindow1Lower = etaWindow->lower(); etaWindow1Upper = etaWindow->upper(); }
1891  else if( cntEta==1 ){ etaWindow2Lower = etaWindow->lower(); etaWindow2Upper = etaWindow->upper(); }
1892  cntEta++;
1893  }
1894 
1895  int cntPhi=0;
1896  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
1897  for( l1t::MuonObjectRequirement::phiWindow_const_iterator phiWindow =objPar->phiWindow().begin();
1898  phiWindow != objPar->phiWindow().end(); ++phiWindow ){
1899 
1900  LogDebug("TriggerMenuXmlParser")
1901  << "\n phiWindow begin = " << phiWindow->lower()
1902  << "\n phiWindow end = " << phiWindow->upper()
1903  << std::endl;
1904 
1905  if( cntPhi==0 ){ phiWindow1Lower = phiWindow->lower(); phiWindow1Upper = phiWindow->upper(); }
1906  else if( cntPhi==1 ){ phiWindow2Lower = phiWindow->lower(); phiWindow2Upper = phiWindow->upper(); }
1907  cntPhi++;
1908  }
1909 
1910  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
1911  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
1912  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
1913  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
1914 
1915  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1916  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1917  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1918  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1919 
1920 
1921  // Output for debugging
1922  LogDebug("TriggerMenuXmlParser")
1923  << "\n Muon PT high threshold (hex) for muon object " << cnt << " = "
1924  << std::hex << objParameter[cnt].ptHighThreshold
1925  << "\n etaWindow Lower / Upper for muon object " << cnt << " = 0x"
1926  << objParameter[cnt].etaWindow1Lower << " / 0x" << objParameter[cnt].etaWindow1Upper
1927  << "\n etaWindowVeto Lower / Upper for muon object " << cnt << " = 0x"
1928  << objParameter[cnt].etaWindow2Lower << " / 0x" << objParameter[cnt].etaWindow2Upper
1929  << "\n phiWindow Lower / Upper for muon object " << cnt << " = 0x"
1930  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
1931  << "\n phiWindowVeto Lower / Upper for muon object " << cnt << " = 0x"
1932  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper << std::dec
1933  << std::endl;
1934 
1935  cnt++;
1936  }
1937 
1938 
1939 
1940  // indicates if a correlation is used
1941  bool wscVal = (type == m_xmlConditionAttrType2wsc );
1942 
1943  if( wscVal ){
1944 
1945  xsd::cxx::tree::optional<l1t::DeltaRequirement> condRanges = condMu.deltaRequirement();
1946  LogDebug("TriggerMenuXmlParser")
1947  << "\t condRanges->deltaEtaRange().lower() = " << condRanges->deltaEtaRange().lower()
1948  << "\n\t condRanges->deltaEtaRange().upper() = " << condRanges->deltaEtaRange().upper()
1949  << "\n\t condRanges->deltaPhiRange().lower() = " << condRanges->deltaPhiRange().lower()
1950  << "\n\t condRanges->deltaPhiRange().upper() = " << condRanges->deltaPhiRange().upper()
1951  << std::endl;
1952 
1953  corrParameter.deltaEtaRangeLower = condRanges->deltaEtaRange().lower();
1954  corrParameter.deltaEtaRangeUpper = condRanges->deltaEtaRange().upper();
1955 
1956  corrParameter.deltaPhiRangeLower = condRanges->deltaPhiRange().lower();
1957  corrParameter.deltaPhiRangeUpper = condRanges->deltaPhiRange().upper();
1958 
1959  //
1961  //
1962 
1963  // Eta Range
1964  str_condMu = "0003";
1965  if ( !hexString2UInt128(str_condMu, tempUIntL, tempUIntH) ) {
1966  return false;
1967  }
1968  if( tempUIntH != 0 ){
1969  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
1970  return false;
1971  }
1972  corrParameter.deltaEtaRange = tempUIntL;
1973 
1974  // Phi Range
1975  str_condMu = "003";
1976  if ( !hexString2UInt128(str_condMu, tempUIntL, tempUIntH) ) {
1977  return false;
1978  }
1979  if( tempUIntH != 0 ){
1980  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
1981  return false;
1982  }
1983  corrParameter.deltaPhiRange = tempUIntL;
1984 
1985 
1986 
1987  // Max Phi Range
1988  std::string maxString = "3FF";
1989 
1990  unsigned int maxbits = 0;
1991 
1992  if ( !countConditionChildMaxBits(maxString, maxbits) ) {
1993  return false;
1994  }
1995 
1996  corrParameter.deltaPhiMaxbits = maxbits;
1997  LogTrace("TriggerMenuXmlParser")
1998  << " deltaPhiMaxbits (dec) = " << maxbits
1999  << std::endl;
2000  }
2001 
2002 
2003  // get the type of the condition, as defined in enum, from the condition type
2004  // as defined in the XML file
2005  GtConditionType cType = getTypeFromType(type);
2006  //LogTrace("TriggerMenuXmlParser")
2007  //<< " Condition type (enum value) = " << cType
2008  //<< std::endl;
2009 
2010  if (cType == l1t::TypeNull) {
2011  edm::LogError("TriggerMenuXmlParser")
2012  << "Type for muon condition id l1t::TypeNull - it means not defined in the XML file."
2013  << "\nNumber of trigger objects is set to zero. " << std::endl;
2014  return false;
2015  }
2016 
2017  // object types - all muons
2018  std::vector<L1GtObject> objType(nrObj, Mu);
2019 
2021 
2022  int relativeBx = l1t2int( condMu.relativeBx() );
2023 
2025  // now create a new CondMuonition
2026 
2027  MuonTemplate muonCond(name);
2028 
2029  muonCond.setCondType(cType);
2030  muonCond.setObjectType(objType);
2031  muonCond.setCondGEq(gEq);
2032  muonCond.setCondChipNr(chipNr);
2033  muonCond.setCondRelativeBx(relativeBx);
2034 
2035  muonCond.setConditionParameter(objParameter, corrParameter);
2036 
2037  if (edm::isDebugEnabled()) {
2038  std::ostringstream myCoutStream;
2039  muonCond.print(myCoutStream);
2040  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2041  }
2042 
2043  // insert condition into the map and into muon template vector
2044  if ( !insertConditionIntoMap(muonCond, chipNr)) {
2045  edm::LogError("TriggerMenuXmlParser")
2046  << " Error: duplicate condition (" << name << ")"
2047  << std::endl;
2048  return false;
2049  }
2050  else {
2051  if (corrFlag) {
2052  (m_corMuonTemplate[chipNr]).push_back(muonCond);
2053  }
2054  else {
2055  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
2056  }
2057 
2058  }
2059 
2060 
2061  LogDebug("TriggerMenuXmlParser")
2062  << "\n intGEq = " << intGEq
2063  << " nrObj = " << nrObj
2064  << "\n ****************************************** "
2065  << std::endl;
2066 
2067  //
2068  return true;
2069 }
2070 
2082 bool l1t::TriggerMenuXmlParser::parseMuonV2(tmeventsetup::esCondition condMu,
2083  unsigned int chipNr, const bool corrFlag) {
2084 
2085 
2086 // XERCES_CPP_NAMESPACE_USE
2087  using namespace tmeventsetup;
2088 
2089  // get condition, particle name (must be muon) and type name
2090  std::string condition = "muon";
2091  std::string particle = "muon";//l1t2string( condMu.objectType() );
2092  std::string type = l1t2string( condMu.getType() );
2093  std::string name = l1t2string( condMu.getName() );
2094  int nrObj = -1;
2095 
2096  if (condMu.getType() == esConditionType::SingleMuon) {
2097  type = "1_s";
2098  nrObj = 1;
2099  } else if (condMu.getType() == esConditionType::DoubleMuon) {
2100  type = "2_s";
2101  nrObj = 2;
2102  } else if (condMu.getType() == esConditionType::TripleMuon) {
2103  type = "3";
2104  nrObj = 3;
2105  } else if (condMu.getType() == esConditionType::QuadMuon) {
2106  type = "4";
2107  nrObj = 4;
2108  } else {
2109  edm::LogError("TriggerMenuXmlParser") << "Wrong type for muon-condition ("
2110  << type << ")" << std::endl;
2111  return false;
2112  }
2113 
2114 
2115  if (nrObj < 0) {
2116  edm::LogError("TriggerMenuXmlParser") << "Unknown type for muon-condition (" << type
2117  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
2118  return false;
2119  }
2120 
2121  LogDebug("TriggerMenuXmlParser")
2122  << "\n ****************************************** "
2123  << "\n parseMuon "
2124  << "\n condition = " << condition
2125  << "\n particle = " << particle
2126  << "\n type = " << type
2127  << "\n name = " << name
2128  << std::endl;
2129 
2130 
2131 
2132 // // get values
2133 
2134  // temporary storage of the parameters
2135  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
2136 
2137  // Do we need this?
2138  MuonTemplate::CorrelationParameter corrParameter;
2139 
2140  // need at least two values for deltaPhi
2141  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
2142  tmpValues.reserve( nrObj );
2143 
2144  if( int(condMu.getObjects().size())!=nrObj ){
2145  edm::LogError("TriggerMenuXmlParser") << " condMu objects: nrObj = " << nrObj
2146  << "condMu.getObjects().size() = "
2147  << condMu.getObjects().size()
2148  << std::endl;
2149  return false;
2150  }
2151 
2152 
2153 // Look for cuts on the objects in the condition
2154  unsigned int chargeCorrelation = 1;
2155  const std::vector<esCut>& cuts = condMu.getCuts();
2156  for (size_t jj = 0; jj < cuts.size(); jj++)
2157  {
2158  const esCut cut = cuts.at(jj);
2159  if(cut.getCutType() == esCutType::ChargeCorrelation) {
2160  if( cut.getData()=="ls" ) chargeCorrelation = 2;
2161  else if( cut.getData()=="os" ) chargeCorrelation = 4;
2162  else chargeCorrelation = 1; //ignore correlation
2163  }
2164  }
2165 
2166  //set charge correlation parameter
2167  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
2168 
2169 
2170  int cnt = 0;
2171 
2172 
2173 // BLW TO DO: These needs to the added to the object rather than the whole condition.
2174  int relativeBx = 0;
2175  bool gEq = false;
2176 
2177 // Loop over objects and extract the cuts on the objects
2178  const std::vector<esObject>& objects = condMu.getObjects();
2179  for (size_t jj = 0; jj < objects.size(); jj++) {
2180 
2181  const esObject object = objects.at(jj);
2182  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
2183 
2184 // BLW TO DO: This needs to be added to the Object Parameters
2185  relativeBx = object.getBxOffset();
2186 
2187 // Loop over the cuts for this object
2188  int upperThresholdInd = -1;
2189  int lowerThresholdInd = 0;
2190  int cntEta = 0;
2191  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
2192  int cntPhi = 0;
2193  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
2194  int isolationLUT = 0xF; //default is to ignore unless specified.
2195  int charge = -1; //default value is to ignore unless specified
2196  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
2197 
2198  const std::vector<esCut>& cuts = object.getCuts();
2199  for (size_t kk = 0; kk < cuts.size(); kk++)
2200  {
2201  const esCut cut = cuts.at(kk);
2202 
2203  switch(cut.getCutType()){
2204  case esCutType::Threshold:
2205  lowerThresholdInd = cut.getMinimum().index;
2206  upperThresholdInd = cut.getMaximum().index;
2207  break;
2208 
2209  case esCutType::Eta: {
2210 
2211  if(cntEta == 0) {
2212  etaWindow1Lower = cut.getMinimum().index;
2213  etaWindow1Upper = cut.getMaximum().index;
2214  } else if(cntEta == 1) {
2215  etaWindow2Lower = cut.getMinimum().index;
2216  etaWindow2Upper = cut.getMaximum().index;
2217  } else {
2218  edm::LogError("TriggerMenuXmlParser") << "Too Many Eta Cuts for muon-condition ("
2219  << particle << ")" << std::endl;
2220  return false;
2221  }
2222  cntEta++;
2223 
2224  } break;
2225 
2226  case esCutType::Phi: {
2227 
2228  if(cntPhi == 0) {
2229  phiWindow1Lower = cut.getMinimum().index;
2230  phiWindow1Upper = cut.getMaximum().index;
2231  } else if(cntPhi == 1) {
2232  phiWindow2Lower = cut.getMinimum().index;
2233  phiWindow2Upper = cut.getMaximum().index;
2234  } else {
2235  edm::LogError("TriggerMenuXmlParser") << "Too Many Phi Cuts for muon-condition ("
2236  << particle << ")" << std::endl;
2237  return false;
2238  }
2239  cntPhi++;
2240 
2241  }break;
2242 
2243  case esCutType::Charge:
2244  std::cout << "Found Charge Cut " << std::endl;
2245  if( cut.getData()=="positive" ) charge = 0;
2246  else if( cut.getData()=="negative" ) charge = 1;
2247  else charge = -1;
2248  break;
2249  case esCutType::Quality:
2250 
2251  qualityLUT = l1tstr2int(cut.getData());
2252 
2253  break;
2254  case esCutType::Isolation: {
2255 
2256  isolationLUT = l1tstr2int(cut.getData());
2257 
2258  } break;
2259  default:
2260  break;
2261  } //end switch
2262 
2263  } //end loop over cuts
2264 
2265 
2266 // Set the parameter cuts
2267  objParameter[cnt].ptHighThreshold = upperThresholdInd;
2268  objParameter[cnt].ptLowThreshold = lowerThresholdInd;
2269 
2270  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
2271  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
2272  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
2273  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
2274 
2275  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
2276  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
2277  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
2278  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
2279 
2280 // BLW TO DO: Do we need these anymore? Drop them?
2281  objParameter[cnt].enableMip = false;//tmpMip[i];
2282  objParameter[cnt].enableIso = false;//tmpEnableIso[i];
2283  objParameter[cnt].requestIso = false;//tmpRequestIso[i];
2284 
2285  objParameter[cnt].charge = charge;
2286  objParameter[cnt].qualityLUT = qualityLUT;
2287  objParameter[cnt].isolationLUT = isolationLUT;
2288 
2289 
2290  cnt++;
2291  } //end loop over objects
2292 
2293 
2294  // get the type of the condition, as defined in enum, from the condition type
2295  // as defined in the XML file
2296  // BLW TO DO: What the heck is this for?
2297  GtConditionType cType = getTypeFromType(type);
2298  //LogTrace("TriggerMenuXmlParser")
2299  //<< " Condition type (enum value) = " << cType
2300  //<< std::endl;
2301 
2302  if (cType == l1t::TypeNull) {
2303  edm::LogError("TriggerMenuXmlParser")
2304  << "Type for muon condition id l1t::TypeNull - it means not defined in the XML file."
2305  << "\nNumber of trigger objects is set to zero. " << std::endl;
2306  return false;
2307  }
2308 
2309  // object types - all muons
2310  std::vector<L1GtObject> objType(nrObj, Mu);
2311 
2312 
2313 
2314  // now create a new CondMuonition
2315  MuonTemplate muonCond(name);
2316 
2317  muonCond.setCondType(cType);
2318  muonCond.setObjectType(objType);
2319  muonCond.setCondGEq(gEq);
2320  muonCond.setCondChipNr(chipNr);
2321  muonCond.setCondRelativeBx(relativeBx);
2322 
2323  muonCond.setConditionParameter(objParameter, corrParameter);
2324 
2325  if (edm::isDebugEnabled()) {
2326  std::ostringstream myCoutStream;
2327  muonCond.print(myCoutStream);
2328  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2329  }
2330 
2331  // insert condition into the map and into muon template vector
2332  if ( !insertConditionIntoMap(muonCond, chipNr)) {
2333  edm::LogError("TriggerMenuXmlParser")
2334  << " Error: duplicate condition (" << name << ")"
2335  << std::endl;
2336  return false;
2337  }
2338  else {
2339  LogDebug("TriggerMenuXmlParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
2340  if (corrFlag) {
2341 
2342  (m_corMuonTemplate[chipNr]).push_back(muonCond);
2343  }
2344  else {
2345  LogDebug("TriggerMenuXmlParser") << "Added Condition " << name << " to the vecMuonTemplate vector" << std::endl;
2346  (m_vecMuonTemplate[chipNr]).push_back(muonCond);
2347  }
2348 
2349  }
2350 
2351  //
2352  return true;
2353 }
2354 
2355 
2356 bool l1t::TriggerMenuXmlParser::parseMuonCorr(const tmeventsetup::esObject* corrMu,
2357  unsigned int chipNr) {
2358 
2359 
2360 // XERCES_CPP_NAMESPACE_USE
2361  using namespace tmeventsetup;
2362 
2363  // get condition, particle name (must be muon) and type name
2364  std::string condition = "muon";
2365  std::string particle = "muon";//l1t2string( condMu.objectType() );
2366  std::string type = l1t2string( corrMu->getType() );
2367  std::string name = l1t2string( corrMu->getName() );
2368  int nrObj = 1;
2369  type = "1_s";
2370 
2371 
2372 
2373  if (nrObj < 0) {
2374  edm::LogError("TriggerMenuXmlParser") << "Unknown type for muon-condition (" << type
2375  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
2376  return false;
2377  }
2378 
2379  LogDebug("TriggerMenuXmlParser")
2380  << "\n ****************************************** "
2381  << "\n parseMuon "
2382  << "\n condition = " << condition
2383  << "\n particle = " << particle
2384  << "\n type = " << type
2385  << "\n name = " << name
2386  << std::endl;
2387 
2388 
2389 
2390 // // get values
2391 
2392  // temporary storage of the parameters
2393  std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
2394 
2395  // Do we need this?
2396  MuonTemplate::CorrelationParameter corrParameter;
2397 
2398  // need at least two values for deltaPhi
2399  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
2400  tmpValues.reserve( nrObj );
2401 
2402 
2403 // BLW TO DO: How do we deal with these in the new format
2404 // std::string str_chargeCorrelation = l1t2string( condMu.requestedChargeCorr() );
2405  std::string str_chargeCorrelation = "ig";
2406  unsigned int chargeCorrelation = 0;
2407  if( str_chargeCorrelation=="ig" ) chargeCorrelation = 1;
2408  else if( str_chargeCorrelation=="ls" ) chargeCorrelation = 2;
2409  else if( str_chargeCorrelation=="os" ) chargeCorrelation = 4;
2410 
2411  //getXMLHexTextValue("1", dst);
2412  corrParameter.chargeCorrelation = chargeCorrelation;//tmpValues[0];
2413 
2414 
2415 
2416  // BLW TO DO: These needs to the added to the object rather than the whole condition.
2417  int relativeBx = 0;
2418  bool gEq = false;
2419 
2420 
2421  //const esObject* object = condMu;
2422  gEq = (corrMu->getComparisonOperator() == esComparisonOperator::GE);
2423 
2424  // BLW TO DO: This needs to be added to the Object Parameters
2425  relativeBx = corrMu->getBxOffset();
2426 
2427  // Loop over the cuts for this object
2428  int upperThresholdInd = -1;
2429  int lowerThresholdInd = 0;
2430  int cntEta = 0;
2431  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
2432  int cntPhi = 0;
2433  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
2434  int isolationLUT = 0xF; //default is to ignore unless specified.
2435  int charge = -1; //defaut is to ignore unless specified
2436  int qualityLUT = 0xFFFF; //default is to ignore unless specified.
2437 
2438  const std::vector<esCut>& cuts = corrMu->getCuts();
2439  for (size_t kk = 0; kk < cuts.size(); kk++)
2440  {
2441  const esCut cut = cuts.at(kk);
2442 
2443  switch(cut.getCutType()){
2444  case esCutType::Threshold:
2445  lowerThresholdInd = cut.getMinimum().index;
2446  upperThresholdInd = cut.getMaximum().index;
2447  break;
2448 
2449  case esCutType::Eta: {
2450 
2451  if(cntEta == 0) {
2452  etaWindow1Lower = cut.getMinimum().index;
2453  etaWindow1Upper = cut.getMaximum().index;
2454  } else if(cntEta == 1) {
2455  etaWindow2Lower = cut.getMinimum().index;
2456  etaWindow2Upper = cut.getMaximum().index;
2457  } else {
2458  edm::LogError("TriggerMenuXmlParser") << "Too Many Eta Cuts for muon-condition ("
2459  << particle << ")" << std::endl;
2460  return false;
2461  }
2462  cntEta++;
2463 
2464  } break;
2465 
2466  case esCutType::Phi: {
2467 
2468  if(cntPhi == 0) {
2469  phiWindow1Lower = cut.getMinimum().index;
2470  phiWindow1Upper = cut.getMaximum().index;
2471  } else if(cntPhi == 1) {
2472  phiWindow2Lower = cut.getMinimum().index;
2473  phiWindow2Upper = cut.getMaximum().index;
2474  } else {
2475  edm::LogError("TriggerMenuXmlParser") << "Too Many Phi Cuts for muon-condition ("
2476  << particle << ")" << std::endl;
2477  return false;
2478  }
2479  cntPhi++;
2480 
2481  }break;
2482 
2483  case esCutType::Charge:
2484  std::cout << "Found Charge Cut " << std::endl;
2485  if( cut.getData()=="positive" ) charge = 0;
2486  else if( cut.getData()=="negative" ) charge = 1;
2487  else charge = -1;
2488  break;
2489  case esCutType::Quality:
2490 
2491  qualityLUT = l1tstr2int(cut.getData());
2492 
2493  break;
2494  case esCutType::Isolation: {
2495 
2496  isolationLUT = l1tstr2int(cut.getData());
2497 
2498  } break;
2499  default:
2500  break;
2501  } //end switch
2502 
2503  } //end loop over cuts
2504 
2505 
2506  // Set the parameter cuts
2507  objParameter[0].ptHighThreshold = upperThresholdInd;
2508  objParameter[0].ptLowThreshold = lowerThresholdInd;
2509 
2510  objParameter[0].etaWindow1Lower = etaWindow1Lower;
2511  objParameter[0].etaWindow1Upper = etaWindow1Upper;
2512  objParameter[0].etaWindow2Lower = etaWindow2Lower;
2513  objParameter[0].etaWindow2Upper = etaWindow2Upper;
2514 
2515  objParameter[0].phiWindow1Lower = phiWindow1Lower;
2516  objParameter[0].phiWindow1Upper = phiWindow1Upper;
2517  objParameter[0].phiWindow2Lower = phiWindow2Lower;
2518  objParameter[0].phiWindow2Upper = phiWindow2Upper;
2519 
2520  // BLW TO DO: Do we need these anymore? Drop them?
2521  objParameter[0].enableMip = false;//tmpMip[i];
2522  objParameter[0].enableIso = false;//tmpEnableIso[i];
2523  objParameter[0].requestIso = false;//tmpRequestIso[i];
2524 
2525  objParameter[0].charge = charge;
2526  objParameter[0].qualityLUT = qualityLUT;
2527  objParameter[0].isolationLUT = isolationLUT;
2528 
2529 
2530 
2531  // get the type of the condition, as defined in enum, from the condition type
2532  // as defined in the XML file
2533  // BLW TO DO: What the heck is this for?
2534  GtConditionType cType = getTypeFromType(type);
2535  //LogTrace("TriggerMenuXmlParser")
2536  //<< " Condition type (enum value) = " << cType
2537  //<< std::endl;
2538 
2539  if (cType == l1t::TypeNull) {
2540  edm::LogError("TriggerMenuXmlParser")
2541  << "Type for muon condition id l1t::TypeNull - it means not defined in the XML file."
2542  << "\nNumber of trigger objects is set to zero. " << std::endl;
2543  return false;
2544  }
2545 
2546  // object types - all muons
2547  std::vector<L1GtObject> objType(nrObj, Mu);
2548 
2549  // now create a new CondMuonition
2550  MuonTemplate muonCond(name);
2551 
2552  muonCond.setCondType(cType);
2553  muonCond.setObjectType(objType);
2554  muonCond.setCondGEq(gEq);
2555  muonCond.setCondChipNr(chipNr);
2556  muonCond.setCondRelativeBx(relativeBx);
2557  muonCond.setConditionParameter(objParameter, corrParameter);
2558 
2559  if (edm::isDebugEnabled()) {
2560  std::ostringstream myCoutStream;
2561  muonCond.print(myCoutStream);
2562  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2563  }
2564 
2565  // insert condition into the map and into muon template vector
2566  if ( !insertConditionIntoMap(muonCond, chipNr)) {
2567  edm::LogError("TriggerMenuXmlParser")
2568  << " Error: duplicate condition (" << name << ")"
2569  << std::endl;
2570  return false;
2571  }
2572  else {
2573  LogDebug("TriggerMenuXmlParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
2574  (m_corMuonTemplate[chipNr]).push_back(muonCond);
2575  }
2576 
2577  //
2578  return true;
2579 }
2580 
2581 
2582 
2594 bool l1t::TriggerMenuXmlParser::parseCalo(l1t::CalorimeterCondition condCalo,
2595  unsigned int chipNr, const bool corrFlag) {
2596 
2597  XERCES_CPP_NAMESPACE_USE
2598 
2599  // get condition, particle name and type name
2600 
2601  std::string condition = "calo";
2602  std::string particle = l1t2string( condCalo.objectType() );
2603  std::string type = l1t2string( condCalo.type() );
2604  std::string name = l1t2string( condCalo.name() );
2605 
2606  LogDebug("TriggerMenuXmlParser")
2607  << "\n ****************************************** "
2608  << "\n DARRENS TEST OUTPUT (in parseCalo) "
2609  << "\n condition = " << condition
2610  << "\n particle = " << particle
2611  << "\n type = " << type
2612  << "\n name = " << name
2613  << std::endl;
2614 
2615 
2616  // determine object type type
2617  L1GtObject caloObjType;
2618 
2619  if (particle == m_xmlConditionAttrObjectNoIsoEG) {
2620  caloObjType = NoIsoEG;
2621  }
2622  else if (particle == m_xmlConditionAttrObjectIsoEG) {
2623  caloObjType = IsoEG;
2624  }
2625  else if (particle == m_xmlConditionAttrObjectCenJet) {
2626  caloObjType = CenJet;
2627  }
2628  else if (particle == m_xmlConditionAttrObjectTauJet) {
2629  caloObjType = TauJet;
2630  }
2631  else if (particle == m_xmlConditionAttrObjectForJet) {
2632  caloObjType = ForJet;
2633  }
2634  else {
2635  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for calo-condition ("
2636  << particle << ")" << std::endl;
2637  return false;
2638  }
2639 
2640  if( type=="double_wsc" ) type = "2_wsc";
2641  else if( type=="single" ) type = "1_s";
2642  else if( type=="double" ) type = "2_s";
2643  else if( type=="triple" ) type = "3";
2644  else if( type=="quad" ) type = "4";
2645 
2646 
2647  std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
2648 
2649  int nrObj = getNumFromType(type);
2650  if (nrObj < 0) {
2651  edm::LogError("TriggerMenuXmlParser") << "Unknown type for calo-condition (" << type
2652  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
2653  return false;
2654  }
2655 
2656  // get greater equal flag
2657  int intGEq = ( str_etComparison=="ge" ) ? 1 : 0;
2658  if (intGEq < 0) {
2659  edm::LogError("TriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
2660  << std::endl;
2661  return false;
2662  }
2663  // set the boolean value for the ge_eq mode
2664  bool gEq = (intGEq != 0);
2665 
2666  // get values
2667 
2668  // temporary storage of the parameters
2669  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
2670  CaloTemplate::CorrelationParameter corrParameter;
2671 
2672  // need at least one value for deltaPhiRange
2673  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
2674  tmpValues.reserve( nrObj );
2675 
2676  if( int(condCalo.objectRequirements().objectRequirement().size())!=nrObj ){
2677  edm::LogError("TriggerMenuXmlParser") << " condCalo objects: nrObj = " << nrObj
2678  << "condCalo.objectRequirements().objectRequirement().size() = "
2679  << condCalo.objectRequirements().objectRequirement().size()
2680  << std::endl;
2681  return false;
2682  }
2683 
2684 
2685  std::string str_condCalo = "";
2686  boost::uint64_t tempUIntH, tempUIntL;
2687  boost::uint64_t dst;
2688  int cnt = 0;
2689  for( l1t::CalorimeterObjectRequirements::objectRequirement_const_iterator objPar = condCalo.objectRequirements().objectRequirement().begin();
2690  objPar != condCalo.objectRequirements().objectRequirement().end(); ++objPar ){
2691 
2692  // ET Threshold
2693  str_condCalo = l1t2string( objPar->etThreshold() );
2694  if( !getXMLHexTextValue(str_condCalo, dst) ) return false;
2695  //if( cnt<nrObj ) objParameter[cnt].etThreshold = dst;
2697  if( cnt<nrObj ) {
2698  objParameter[cnt].etLowThreshold = objPar->etThreshold();
2699  objParameter[cnt].etHighThreshold = 999; //not implemented in old grammar
2700  }
2701 
2702  // Eta Range
2703  //str_condCalo = "ffff";
2704  str_condCalo = "7f7f";
2705  //str_condCalo = "0f0f";
2706  if( !getXMLHexTextValue(str_condCalo, dst) ) return false;
2707  if( cnt<nrObj ) objParameter[cnt].etaRange = dst;
2708 
2709  // Phi Range
2710  str_condCalo = "3ffff";
2711  if( !getXMLHexTextValue(str_condCalo, dst) ) return false;
2712  if( cnt<nrObj ) objParameter[cnt].phiRange = dst;
2713 
2714 
2715  int cntIso=0;
2716  int isolationLUT = 0;
2717  for( l1t::CalorimeterIsolationLUT::isolation_const_iterator iIsoFlag = objPar->isolationLut().isolation().begin();
2718  iIsoFlag != objPar->isolationLut().isolation().end(); ++iIsoFlag ){
2719 
2720  bool flag = (*iIsoFlag);
2721 
2722  isolationLUT |= (flag << cntIso);
2723 
2724  LogDebug("TriggerMenuXmlParser")
2725  << "\n isolation flag " << cntIso << " = " << flag
2726  << "\n isolationLUT = " << isolationLUT
2727  << std::endl;
2728 
2729  cntIso++;
2730  }
2731 
2732  objParameter[cnt].isolationLUT = isolationLUT;
2733 
2734 
2735  int cntEta=0;
2736  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
2737  // Temporary before translation
2738  for( l1t::CalorimeterObjectRequirement::etaWindow_const_iterator etaWindow =objPar->etaWindow().begin();
2739  etaWindow != objPar->etaWindow().end(); ++etaWindow ){
2740 
2741  LogDebug("TriggerMenuXmlParser")
2742  << "\n etaWindow lower = " << etaWindow->lower()
2743  << "\n etaWindow upper = " << etaWindow->upper()
2744  << std::endl;
2745  if( cntEta==0 ){ etaWindow1Lower = etaWindow->lower(); etaWindow1Upper = etaWindow->upper(); }
2746  else if( cntEta==1 ){ etaWindow2Lower = etaWindow->lower(); etaWindow2Upper = etaWindow->upper(); }
2747  cntEta++;
2748  }
2749 
2750  int cntPhi=0;
2751  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
2752  for( l1t::CalorimeterObjectRequirement::phiWindow_const_iterator phiWindow =objPar->phiWindow().begin();
2753  phiWindow != objPar->phiWindow().end(); ++phiWindow ){
2754 
2755  LogDebug("TriggerMenuXmlParser")
2756  << "\n phiWindow begin = " << phiWindow->lower()
2757  << "\n phiWindow end = " << phiWindow->upper()
2758  << std::endl;
2759 
2760  if( cntPhi==0 ){ phiWindow1Lower = phiWindow->lower(); phiWindow1Upper = phiWindow->upper(); }
2761  else if( cntPhi==1 ){ phiWindow2Lower = phiWindow->lower(); phiWindow2Upper = phiWindow->upper(); }
2762  cntPhi++;
2763  }
2764 
2765  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
2766  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
2767  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
2768  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
2769 
2770  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
2771  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
2772  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
2773  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
2774 
2775 
2776  // Output for debugging
2777  LogDebug("TriggerMenuXmlParser")
2778  << "\n Calo ET high threshold (hex) for calo object " << cnt << " = "
2779  << std::hex << objParameter[cnt].etLowThreshold
2780  << "\n etaWindow Lower / Upper for calo object " << cnt << " = 0x"
2781  << objParameter[cnt].etaWindow1Lower << " / 0x" << objParameter[cnt].etaWindow1Upper
2782  << "\n etaWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2783  << objParameter[cnt].etaWindow2Lower << " / 0x" << objParameter[cnt].etaWindow2Upper
2784  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2785  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
2786  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2787  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper << std::dec
2788  << std::endl;
2789 
2790  cnt++;
2791  }
2792 
2793 
2794 
2795  // indicates if a correlation is used
2796  bool wscVal = (type == m_xmlConditionAttrType2wsc );
2797 
2798  if( wscVal ){
2799 
2800  xsd::cxx::tree::optional<l1t::DeltaRequirement> condRanges = condCalo.deltaRequirement();
2801  LogDebug("TriggerMenuXmlParser")
2802  << "\t condRanges->deltaEtaRange().lower() = " << condRanges->deltaEtaRange().lower()
2803  << "\n\t condRanges->deltaEtaRange().upper() = " << condRanges->deltaEtaRange().upper()
2804  << "\n\t condRanges->deltaPhiRange().lower() = " << condRanges->deltaPhiRange().lower()
2805  << "\n\t condRanges->deltaPhiRange().upper() = " << condRanges->deltaPhiRange().upper()
2806  << std::endl;
2807 
2808  corrParameter.deltaEtaRangeLower = condRanges->deltaEtaRange().lower();
2809  corrParameter.deltaEtaRangeUpper = condRanges->deltaEtaRange().upper();
2810 
2811  corrParameter.deltaPhiRangeLower = condRanges->deltaPhiRange().lower();
2812  corrParameter.deltaPhiRangeUpper = condRanges->deltaPhiRange().upper();
2813 
2814  //
2816  //
2817 
2818  // Eta Range
2819  str_condCalo = "0003";
2820  if ( !hexString2UInt128(str_condCalo, tempUIntL, tempUIntH) ) {
2821  return false;
2822  }
2823  if( tempUIntH != 0 ){
2824  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
2825  return false;
2826  }
2827  corrParameter.deltaEtaRange = tempUIntL;
2828 
2829  // Phi Range
2830  str_condCalo = "003";
2831  if ( !hexString2UInt128(str_condCalo, tempUIntL, tempUIntH) ) {
2832  return false;
2833  }
2834  if( tempUIntH != 0 ){
2835  edm::LogError("TriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
2836  return false;
2837  }
2838  corrParameter.deltaPhiRange = tempUIntL;
2839 
2840 
2841 
2842  // Max Phi Range
2843  std::string maxString = "3FF";
2844 
2845  unsigned int maxbits = 0;
2846 
2847  if ( !countConditionChildMaxBits(maxString, maxbits) ) {
2848  return false;
2849  }
2850 
2851  corrParameter.deltaPhiMaxbits = maxbits;
2852  LogTrace("TriggerMenuXmlParser")
2853  << " deltaPhiMaxbits (dec) = " << maxbits
2854  << std::endl;
2855  }
2856 
2857 
2858 
2859  // get the type of the condition, as defined in enum, from the condition type
2860  // as defined in the XML file
2861  GtConditionType cType = getTypeFromType(type);
2862  LogTrace("TriggerMenuXmlParser")
2863  << " Condition type (enum value) = " << cType
2864  << std::endl;
2865 
2866  if (cType == l1t::TypeNull) {
2867  edm::LogError("TriggerMenuXmlParser")
2868  << "Type for calo condition id l1t::TypeNull - it means not defined in the XML file."
2869  << "\nNumber of trigger objects is set to zero. " << std::endl;
2870  return false;
2871  }
2872 
2873  // object types - all same caloObjType
2874  std::vector<L1GtObject> objType(nrObj, caloObjType);
2875 
2876 
2877  int relativeBx = l1t2int( condCalo.relativeBx() );
2878 
2879  // now create a new calo condition
2880  CaloTemplate caloCond(name);
2881 
2882  caloCond.setCondType(cType);
2883  caloCond.setObjectType(objType);
2884  caloCond.setCondGEq(gEq);
2885  caloCond.setCondChipNr(chipNr);
2886  caloCond.setCondRelativeBx(relativeBx);
2887 
2888  caloCond.setConditionParameter(objParameter, corrParameter);
2889 
2890  if (edm::isDebugEnabled() ) {
2891 
2892  std::ostringstream myCoutStream;
2893  caloCond.print(myCoutStream);
2894  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2895 
2896  }
2897 
2898  // insert condition into the map
2899  if ( !insertConditionIntoMap(caloCond, chipNr)) {
2900 
2901  edm::LogError("TriggerMenuXmlParser")
2902  << " Error: duplicate condition (" << name << ")"
2903  << std::endl;
2904 
2905  return false;
2906  }
2907  else {
2908 
2909  if (corrFlag) {
2910  (m_corCaloTemplate[chipNr]).push_back(caloCond);
2911  }
2912  else {
2913  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
2914  }
2915 
2916  }
2917 
2918  LogDebug("TriggerMenuXmlParser")
2919  << "\n intGEq = " << intGEq
2920  << " nrObj = " << nrObj
2921  << "\n ****************************************** "
2922  << std::endl;
2923 
2924 
2925  //
2926  return true;
2927 }
2928 
2929 
2941 bool l1t::TriggerMenuXmlParser::parseCaloV2(tmeventsetup::esCondition condCalo,
2942  unsigned int chipNr, const bool corrFlag) {
2943 
2944 
2945 // XERCES_CPP_NAMESPACE_USE
2946  using namespace tmeventsetup;
2947 
2948  // get condition, particle name and type name
2949 
2950  std::string condition = "calo";
2951  std::string particle = "test-fix" ;
2952  std::string type = l1t2string( condCalo.getType() );
2953  std::string name = l1t2string( condCalo.getName() );
2954 
2955  LogDebug("TriggerMenuXmlParser")
2956  << "\n ****************************************** "
2957  << "\n (in parseCaloV2) "
2958  << "\n condition = " << condition
2959  << "\n particle = " << particle
2960  << "\n type = " << type
2961  << "\n name = " << name
2962  << std::endl;
2963 
2964 
2965  // determine object type type
2966  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
2967  L1GtObject caloObjType;
2968  int nrObj = -1;
2969 
2970  if (condCalo.getType() == esConditionType::SingleEgamma) {
2971  caloObjType = NoIsoEG;
2972  type = "1_s";
2973  nrObj = 1;
2974  } else if (condCalo.getType() == esConditionType::DoubleEgamma) {
2975  caloObjType = NoIsoEG;
2976  type = "2_s";
2977  nrObj = 2;
2978  } else if (condCalo.getType() == esConditionType::TripleEgamma) {
2979  caloObjType = NoIsoEG;
2980  type = "3";
2981  nrObj = 3;
2982  } else if (condCalo.getType() == esConditionType::QuadEgamma) {
2983  caloObjType = NoIsoEG;
2984  type = "4";
2985  nrObj = 4;
2986  } else if (condCalo.getType() == esConditionType::SingleJet) {
2987  caloObjType = CenJet;
2988  type = "1_s";
2989  nrObj = 1;
2990  } else if (condCalo.getType() == esConditionType::DoubleJet) {
2991  caloObjType = CenJet;
2992  type = "2_s";
2993  nrObj = 2;
2994  } else if (condCalo.getType() == esConditionType::TripleJet) {
2995  caloObjType = CenJet;
2996  type = "3";
2997  nrObj = 3;
2998  } else if (condCalo.getType() == esConditionType::QuadJet) {
2999  caloObjType = CenJet;
3000  type = "4";
3001  nrObj = 4;
3002  } else if (condCalo.getType() == esConditionType::SingleTau) {
3003  caloObjType = TauJet;
3004  type = "1_s";
3005  nrObj = 1;
3006  } else if (condCalo.getType() == esConditionType::DoubleTau) {
3007  caloObjType = TauJet;
3008  type = "2_s";
3009  nrObj = 2;
3010  } else if (condCalo.getType() == esConditionType::TripleTau) {
3011  caloObjType = TauJet;
3012  type = "3";
3013  nrObj = 3;
3014  } else if (condCalo.getType() == esConditionType::QuadTau) {
3015  caloObjType = TauJet;
3016  type = "4";
3017  nrObj = 4;
3018  } else {
3019  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for calo-condition ("
3020  << particle << ")" << std::endl;
3021  return false;
3022  }
3023 
3024 // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
3025 
3026  if (nrObj < 0) {
3027  edm::LogError("TriggerMenuXmlParser") << "Unknown type for calo-condition (" << type
3028  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
3029  return false;
3030  }
3031 
3032  // get values
3033 
3034  // temporary storage of the parameters
3035  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
3036 
3037  //BLW TO DO: Can this be dropped?
3038  CaloTemplate::CorrelationParameter corrParameter;
3039 
3040  // need at least one value for deltaPhiRange
3041  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
3042  tmpValues.reserve( nrObj );
3043 
3044 
3045  if( int(condCalo.getObjects().size())!=nrObj ){
3046  edm::LogError("TriggerMenuXmlParser") << " condCalo objects: nrObj = " << nrObj
3047  << "condCalo.getObjects().size() = "
3048  << condCalo.getObjects().size()
3049  << std::endl;
3050  return false;
3051  }
3052 
3053 
3054 // std::string str_condCalo = "";
3055 // boost::uint64_t tempUIntH, tempUIntL;
3056 // boost::uint64_t dst;
3057  int cnt = 0;
3058 
3059 // BLW TO DO: These needs to the added to the object rather than the whole condition.
3060  int relativeBx = 0;
3061  bool gEq = false;
3062 
3063 // Loop over objects and extract the cuts on the objects
3064  const std::vector<esObject>& objects = condCalo.getObjects();
3065  for (size_t jj = 0; jj < objects.size(); jj++) {
3066 
3067  const esObject object = objects.at(jj);
3068  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
3069 
3070 // BLW TO DO: This needs to be added to the Object Parameters
3071  relativeBx = object.getBxOffset();
3072 
3073 // Loop over the cuts for this object
3074  int upperThresholdInd = -1;
3075  int lowerThresholdInd = 0;
3076  int cntEta = 0;
3077  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
3078  int cntPhi = 0;
3079  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
3080  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
3081  int qualityLUT = 0xF; //default is to ignore quality unless specified.
3082 
3083 
3084  const std::vector<esCut>& cuts = object.getCuts();
3085  for (size_t kk = 0; kk < cuts.size(); kk++)
3086  {
3087  const esCut cut = cuts.at(kk);
3088 
3089  switch(cut.getCutType()){
3090  case esCutType::Threshold:
3091  lowerThresholdInd = cut.getMinimum().index;
3092  upperThresholdInd = cut.getMaximum().index;
3093  break;
3094  case esCutType::Eta: {
3095 
3096  if(cntEta == 0) {
3097  etaWindow1Lower = cut.getMinimum().index;
3098  etaWindow1Upper = cut.getMaximum().index;
3099  } else if(cntEta == 1) {
3100  etaWindow2Lower = cut.getMinimum().index;
3101  etaWindow2Upper = cut.getMaximum().index;
3102  } else {
3103  edm::LogError("TriggerMenuXmlParser") << "Too Many Eta Cuts for calo-condition ("
3104  << particle << ")" << std::endl;
3105  return false;
3106  }
3107  cntEta++;
3108 
3109  } break;
3110 
3111  case esCutType::Phi: {
3112 
3113  if(cntPhi == 0) {
3114  phiWindow1Lower = cut.getMinimum().index;
3115  phiWindow1Upper = cut.getMaximum().index;
3116  } else if(cntPhi == 1) {
3117  phiWindow2Lower = cut.getMinimum().index;
3118  phiWindow2Upper = cut.getMaximum().index;
3119  } else {
3120  edm::LogError("TriggerMenuXmlParser") << "Too Many Phi Cuts for calo-condition ("
3121  << particle << ")" << std::endl;
3122  return false;
3123  }
3124  cntPhi++;
3125 
3126  }break;
3127 
3128  case esCutType::Charge: {
3129 
3130  edm::LogError("TriggerMenuXmlParser") << "No charge cut for calo-condition ("
3131  << particle << ")" << std::endl;
3132  return false;
3133 
3134  }break;
3135  case esCutType::Quality: {
3136 
3137  qualityLUT = l1tstr2int(cut.getData());
3138 
3139  }break;
3140  case esCutType::Isolation: {
3141 
3142  isolationLUT = l1tstr2int(cut.getData());
3143 
3144  } break;
3145  default:
3146  break;
3147  } //end switch
3148 
3149  } //end loop over cuts
3150 
3151 // Fill the object parameters
3152  objParameter[cnt].etHighThreshold = upperThresholdInd;
3153  objParameter[cnt].etLowThreshold = lowerThresholdInd;
3154  objParameter[cnt].etaWindow1Lower = etaWindow1Lower;
3155  objParameter[cnt].etaWindow1Upper = etaWindow1Upper;
3156  objParameter[cnt].etaWindow2Lower = etaWindow2Lower;
3157  objParameter[cnt].etaWindow2Upper = etaWindow2Upper;
3158  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
3159  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
3160  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
3161  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
3162  objParameter[cnt].isolationLUT = isolationLUT;
3163  objParameter[cnt].qualityLUT = qualityLUT; //TO DO: Must add
3164 
3165  // Output for debugging
3166  LogDebug("TriggerMenuXmlParser")
3167  << "\n Calo ET high thresholds (hex) for calo object " << caloObjType << " " << cnt << " = "
3168  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold
3169  << "\n etaWindow Lower / Upper for calo object " << cnt << " = 0x"
3170  << objParameter[cnt].etaWindow1Lower << " / 0x" << objParameter[cnt].etaWindow1Upper
3171  << "\n etaWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
3172  << objParameter[cnt].etaWindow2Lower << " / 0x" << objParameter[cnt].etaWindow2Upper
3173  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
3174  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
3175  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
3176  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
3177  << "\n Isolation LUT for calo object " << cnt << " = 0x"
3178  << objParameter[cnt].isolationLUT
3179  << "\n Quality LUT for calo object " << cnt << " = 0x"
3180  << objParameter[cnt].qualityLUT << std::dec
3181  << std::endl;
3182 
3183  cnt++;
3184  } //end loop over objects
3185 
3186 
3187 
3188  // get the type of the condition, as defined in enum, from the condition type
3189  // as defined in the XML file
3190  GtConditionType cType = getTypeFromType(type);
3191  LogTrace("TriggerMenuXmlParser")
3192  << " Condition type (enum value) = " << cType
3193  << std::endl;
3194 
3195  if (cType == l1t::TypeNull) {
3196  edm::LogError("TriggerMenuXmlParser")
3197  << "Type for calo condition id l1t::TypeNull - it means not defined in the XML file."
3198  << "\nNumber of trigger objects is set to zero. " << std::endl;
3199  return false;
3200  }
3201 
3202  // object types - all same caloObjType
3203  std::vector<L1GtObject> objType(nrObj, caloObjType);
3204 
3205 
3206 
3207 
3208  // now create a new calo condition
3209  CaloTemplate caloCond(name);
3210 
3211  caloCond.setCondType(cType);
3212  caloCond.setObjectType(objType);
3213 
3214  //BLW TO DO: This needs to be added to the object rather than the whole condition
3215  caloCond.setCondGEq(gEq);
3216  caloCond.setCondChipNr(chipNr);
3217 
3218  //BLW TO DO: This needs to be added to the object rather than the whole condition
3219  caloCond.setCondRelativeBx(relativeBx);
3220 
3221  caloCond.setConditionParameter(objParameter, corrParameter);
3222 
3223  if (edm::isDebugEnabled() ) {
3224 
3225  std::ostringstream myCoutStream;
3226  caloCond.print(myCoutStream);
3227  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3228 
3229  }
3230 
3231 
3232  // insert condition into the map
3233  if ( !insertConditionIntoMap(caloCond, chipNr)) {
3234 
3235  edm::LogError("TriggerMenuXmlParser")
3236  << " Error: duplicate condition (" << name << ")"
3237  << std::endl;
3238 
3239  return false;
3240  }
3241  else {
3242 
3243  if (corrFlag) {
3244  (m_corCaloTemplate[chipNr]).push_back(caloCond);
3245  }
3246  else {
3247  (m_vecCaloTemplate[chipNr]).push_back(caloCond);
3248  }
3249 
3250  }
3251 
3252 
3253  //
3254  return true;
3255 }
3256 
3257 
3258 
3270 bool l1t::TriggerMenuXmlParser::parseCaloCorr(const tmeventsetup::esObject* corrCalo,
3271  unsigned int chipNr) {
3272 
3273 
3274 // XERCES_CPP_NAMESPACE_USE
3275  using namespace tmeventsetup;
3276 
3277  // get condition, particle name and type name
3278 
3279  std::string condition = "calo";
3280  std::string particle = "test-fix" ;
3281  std::string type = l1t2string( corrCalo->getType() );
3282  std::string name = l1t2string( corrCalo->getName() );
3283 
3284  LogDebug("TriggerMenuXmlParser")
3285  << "\n ****************************************** "
3286  << "\n (in parseCaloV2) "
3287  << "\n condition = " << condition
3288  << "\n particle = " << particle
3289  << "\n type = " << type
3290  << "\n name = " << name
3291  << std::endl;
3292 
3293 
3294  // determine object type type
3295  // BLW TO DO: Can this object type wait and be done later in the parsing. Or done differently completely..
3296  L1GtObject caloObjType;
3297  int nrObj = 1;
3298  type = "1_s";
3299 
3300 
3301  if (corrCalo->getType() == esObjectType::Egamma) {
3302  caloObjType = NoIsoEG;
3303  } else if (corrCalo->getType() == esObjectType::Jet) {
3304  caloObjType = CenJet;
3305  } else if (corrCalo->getType() == esObjectType::Tau) {
3306  caloObjType = TauJet;
3307  } else {
3308  edm::LogError("TriggerMenuXmlParser") << "Wrong particle for calo-condition ("
3309  << particle << ")" << std::endl;
3310  return false;
3311  }
3312 
3313 
3314 // std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
3315 
3316  if (nrObj < 0) {
3317  edm::LogError("TriggerMenuXmlParser") << "Unknown type for calo-condition (" << type
3318  << ")" << "\nCan not determine number of trigger objects. " << std::endl;
3319  return false;
3320  }
3321 
3322  // get values
3323 
3324  // temporary storage of the parameters
3325  std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
3326 
3327  //BLW TO DO: Can this be dropped?
3328  CaloTemplate::CorrelationParameter corrParameter;
3329 
3330  // need at least one value for deltaPhiRange
3331  std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
3332  tmpValues.reserve( nrObj );
3333 
3334 
3335 
3336 // BLW TO DO: These needs to the added to the object rather than the whole condition.
3337  int relativeBx = 0;
3338  bool gEq = false;
3339 
3340 
3341  gEq = (corrCalo->getComparisonOperator() == esComparisonOperator::GE);
3342 
3343 // BLW TO DO: This needs to be added to the Object Parameters
3344  relativeBx = corrCalo->getBxOffset();
3345 
3346 // Loop over the cuts for this object
3347  int upperThresholdInd = -1;
3348  int lowerThresholdInd = 0;
3349  int cntEta = 0;
3350  unsigned int etaWindow1Lower=-1, etaWindow1Upper=-1, etaWindow2Lower=-1, etaWindow2Upper=-1;
3351  int cntPhi = 0;
3352  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
3353  int isolationLUT = 0xF; //default is to ignore isolation unless specified.
3354  int qualityLUT = 0xF; //default is to ignore quality unless specified.
3355 
3356 
3357  const std::vector<esCut>& cuts = corrCalo->getCuts();
3358  for (size_t kk = 0; kk < cuts.size(); kk++)
3359  {
3360  const esCut cut = cuts.at(kk);
3361 
3362  switch(cut.getCutType()){
3363  case esCutType::Threshold:
3364  lowerThresholdInd = cut.getMinimum().index;
3365  upperThresholdInd = cut.getMaximum().index;
3366  break;
3367  case esCutType::Eta: {
3368 
3369  if(cntEta == 0) {
3370  etaWindow1Lower = cut.getMinimum().index;
3371  etaWindow1Upper = cut.getMaximum().index;
3372  } else if(cntEta == 1) {
3373  etaWindow2Lower = cut.getMinimum().index;
3374  etaWindow2Upper = cut.getMaximum().index;
3375  } else {
3376  edm::LogError("TriggerMenuXmlParser") << "Too Many Eta Cuts for calo-condition ("
3377  << particle << ")" << std::endl;
3378  return false;
3379  }
3380  cntEta++;
3381 
3382  } break;
3383 
3384  case esCutType::Phi: {
3385 
3386  if(cntPhi == 0) {
3387  phiWindow1Lower = cut.getMinimum().index;
3388  phiWindow1Upper = cut.getMaximum().index;
3389  } else if(cntPhi == 1) {
3390  phiWindow2Lower = cut.getMinimum().index;
3391  phiWindow2Upper = cut.getMaximum().index;
3392  } else {
3393  edm::LogError("TriggerMenuXmlParser") << "Too Many Phi Cuts for calo-condition ("
3394  << particle << ")" << std::endl;
3395  return false;
3396  }
3397  cntPhi++;
3398 
3399  }break;
3400 
3401  case esCutType::Charge: {
3402 
3403  edm::LogError("TriggerMenuXmlParser") << "No charge cut for calo-condition ("
3404  << particle << ")" << std::endl;
3405  return false;
3406 
3407  }break;
3408  case esCutType::Quality: {
3409 
3410  qualityLUT = l1tstr2int(cut.getData());
3411 
3412  }break;
3413  case esCutType::Isolation: {
3414 
3415  isolationLUT = l1tstr2int(cut.getData());
3416 
3417  } break;
3418  default:
3419  break;
3420  } //end switch
3421 
3422  } //end loop over cuts
3423 
3424 // Fill the object parameters
3425  objParameter[0].etLowThreshold = lowerThresholdInd;
3426  objParameter[0].etHighThreshold = upperThresholdInd;
3427  objParameter[0].etaWindow1Lower = etaWindow1Lower;
3428  objParameter[0].etaWindow1Upper = etaWindow1Upper;
3429  objParameter[0].etaWindow2Lower = etaWindow2Lower;
3430  objParameter[0].etaWindow2Upper = etaWindow2Upper;
3431  objParameter[0].phiWindow1Lower = phiWindow1Lower;
3432  objParameter[0].phiWindow1Upper = phiWindow1Upper;
3433  objParameter[0].phiWindow2Lower = phiWindow2Lower;
3434  objParameter[0].phiWindow2Upper = phiWindow2Upper;
3435  objParameter[0].isolationLUT = isolationLUT;
3436  objParameter[0].qualityLUT = qualityLUT; //TO DO: Must add
3437 
3438  // Output for debugging
3439  LogDebug("TriggerMenuXmlParser")
3440  << "\n Calo ET high threshold (hex) for calo object " << caloObjType << " " << " = "
3441  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etHighThreshold
3442  << "\n etaWindow Lower / Upper for calo object " << " = 0x"
3443  << objParameter[0].etaWindow1Lower << " / 0x" << objParameter[0].etaWindow1Upper
3444  << "\n etaWindowVeto Lower / Upper for calo object " << " = 0x"
3445  << objParameter[0].etaWindow2Lower << " / 0x" << objParameter[0].etaWindow2Upper
3446  << "\n phiWindow Lower / Upper for calo object " << " = 0x"
3447  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
3448  << "\n phiWindowVeto Lower / Upper for calo object " << " = 0x"
3449  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper
3450  << "\n Isolation LUT for calo object " << " = 0x"
3451  << objParameter[0].isolationLUT
3452  << "\n Quality LUT for calo object " << " = 0x"
3453  << objParameter[0].qualityLUT << std::dec
3454  << std::endl;
3455 
3456 
3457 
3458  // get the type of the condition, as defined in enum, from the condition type
3459  // as defined in the XML file
3460  GtConditionType cType = getTypeFromType(type);
3461  LogTrace("TriggerMenuXmlParser")
3462  << " Condition type (enum value) = " << cType
3463  << std::endl;
3464 
3465  if (cType == l1t::TypeNull) {
3466  edm::LogError("TriggerMenuXmlParser")
3467  << "Type for calo condition id l1t::TypeNull - it means not defined in the XML file."
3468  << "\nNumber of trigger objects is set to zero. " << std::endl;
3469  return false;
3470  }
3471 
3472  // object types - all same caloObjType
3473  std::vector<L1GtObject> objType(nrObj, caloObjType);
3474 
3475 
3476 
3477 
3478  // now create a new calo condition
3479  CaloTemplate caloCond(name);
3480 
3481  caloCond.setCondType(cType);
3482  caloCond.setObjectType(objType);
3483 
3484  //BLW TO DO: This needs to be added to the object rather than the whole condition
3485  caloCond.setCondGEq(gEq);
3486  caloCond.setCondChipNr(chipNr);
3487 
3488  //BLW TO DO: This needs to be added to the object rather than the whole condition
3489  caloCond.setCondRelativeBx(relativeBx);
3490 
3491  caloCond.setConditionParameter(objParameter, corrParameter);
3492 
3493  if (edm::isDebugEnabled() ) {
3494 
3495  std::ostringstream myCoutStream;
3496  caloCond.print(myCoutStream);
3497  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3498 
3499  }
3500 
3501 
3502  // insert condition into the map
3503  if ( !insertConditionIntoMap(caloCond, chipNr)) {
3504 
3505  edm::LogError("TriggerMenuXmlParser")
3506  << " Error: duplicate condition (" << name << ")"
3507  << std::endl;
3508 
3509  return false;
3510  }
3511  else {
3512  (m_corCaloTemplate[chipNr]).push_back(caloCond);
3513  }
3514 
3515 
3516  //
3517  return true;
3518 }
3519 
3520 
3521 
3533 bool l1t::TriggerMenuXmlParser::parseEnergySum(l1t::EnergySumsCondition condEnergySum,
3534  unsigned int chipNr, const bool corrFlag) {
3535 
3536  XERCES_CPP_NAMESPACE_USE
3537 
3538  // get condition, particle name and type name
3539 
3540  std::string condition = "calo";
3541  std::string type = l1t2string( condEnergySum.objectType() );
3542  std::string name = l1t2string( condEnergySum.name() );
3543 
3544  LogDebug("TriggerMenuXmlParser")
3545  << "\n ****************************************** "
3546  << "\n DARRENS TEST OUTPUT (in parseEnergySum) "
3547  << "\n condition = " << condition
3548  << "\n type = " << type
3549  << "\n name = " << name
3550  << std::endl;
3551 
3552  // determine object type type
3553  L1GtObject energySumObjType;
3554  GtConditionType cType;
3555 
3556  if( type == m_xmlConditionAttrObjectETM ){
3557  energySumObjType = ETM;
3558  cType = TypeETM;
3559  }
3560  else if( type == m_xmlConditionAttrObjectETT ){
3561  energySumObjType = ETT;
3562  cType = TypeETT;
3563  }
3564  else if( type == m_xmlConditionAttrObjectHTT ){
3565  energySumObjType = HTT;
3566  cType = TypeHTT;
3567  }
3568  else if( type == m_xmlConditionAttrObjectHTM ){
3569  energySumObjType = HTM;
3570  cType = TypeHTM;
3571  }
3572  else {
3573  edm::LogError("TriggerMenuXmlParser")
3574  << "Wrong type for energy-sum condition (" << type
3575  << ")" << std::endl;
3576  return false;
3577  }
3578 
3579 
3580 
3581  // global object
3582  int nrObj = 1;
3583 
3584  std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
3585 
3586  // get greater equal flag
3587  int intGEq = ( str_etComparison=="ge" ) ? 1 : 0;
3588  if( intGEq < 0 ){
3589  edm::LogError("TriggerMenuXmlParser")
3590  << "Error getting \"greater or equal\" flag"
3591  << std::endl;
3592  return false;
3593  }
3594  // set the boolean value for the ge_eq mode
3595  bool gEq = (intGEq != 0);
3596 
3597 
3598  // get values
3599 
3600  // temporary storage of the parameters
3601  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
3602 
3603 
3604  int cnt = 0;
3605 
3606  l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
3607 
3608  // ET Threshold
3609  objParameter[cnt].etLowThreshold = objPar.etThreshold();
3610  objParameter[cnt].etLowThreshold = 999; //not implemented in old grammar
3611 
3612  int cntPhi=0;
3613  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
3614  for( l1t::EnergySumsObjectRequirement::phiWindow_const_iterator phiWindow =objPar.phiWindow().begin();
3615  phiWindow != objPar.phiWindow().end(); ++phiWindow ){
3616 
3617  LogDebug("TriggerMenuXmlParser")
3618  << "\n phiWindow begin = " << phiWindow->lower()
3619  << "\n phiWindow end = " << phiWindow->upper()
3620  << std::endl;
3621 
3622  if( cntPhi==0 ){ phiWindow1Lower = phiWindow->lower(); phiWindow1Upper = phiWindow->upper(); }
3623  else if( cntPhi==1 ){ phiWindow2Lower = phiWindow->lower(); phiWindow2Upper = phiWindow->upper(); }
3624  cntPhi++;
3625  }
3626 
3627  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
3628  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
3629  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
3630  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
3631 
3632 
3633  // Output for debugging
3634  LogDebug("TriggerMenuXmlParser")
3635  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
3636  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold << std::hex
3637  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
3638  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
3639  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
3640  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper <<std::dec
3641  << std::endl;
3642 
3643 
3644 
3645 
3646  int relativeBx = l1t2int( condEnergySum.relativeBx() );
3647 
3648  // object types - all same energySumObjType
3649  std::vector<L1GtObject> objType(nrObj, energySumObjType);
3650 
3651  // now create a new energySum condition
3652 
3653  EnergySumTemplate energySumCond(name);
3654 
3655  energySumCond.setCondType(cType);
3656  energySumCond.setObjectType(objType);
3657  energySumCond.setCondGEq(gEq);
3658  energySumCond.setCondChipNr(chipNr);
3659  energySumCond.setCondRelativeBx(relativeBx);
3660 
3661  energySumCond.setConditionParameter(objParameter);
3662 
3663  if (edm::isDebugEnabled() ) {
3664 
3665  std::ostringstream myCoutStream;
3666  energySumCond.print(myCoutStream);
3667  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3668 
3669  }
3670 
3671  // insert condition into the map
3672  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
3673 
3674  edm::LogError("TriggerMenuXmlParser")
3675  << " Error: duplicate condition (" << name << ")"
3676  << std::endl;
3677 
3678  return false;
3679  }
3680  else {
3681 
3682  if (corrFlag) {
3683  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
3684 
3685  }
3686  else {
3687  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
3688  }
3689 
3690  }
3691 
3692 
3693 
3694  /*
3695 
3696 
3697 
3698  // need at least two values for phi
3699  std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
3700 
3701  // get etThreshold values and fill into structure
3702  if ( !getConditionChildValuesOld(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
3703  return false;
3704  }
3705 
3706  for (int i = 0; i < nrObj; i++) {
3707  objParameter[i].etThreshold = tmpValues[i];
3708 
3709  //LogTrace("TriggerMenuXmlParser")
3710  //<< " EnergySum ET high threshold (hex) for energySum object " << i << " = "
3711  //<< std::hex << objParameter[i].etThreshold << std::dec
3712  //<< std::endl;
3713 
3714  // for ETM and HTM read phi value
3715  // phi is larger than 64 bits for ETM - it needs two 64bits words
3716  // phi is less than 64 bits for HTM - it needs one 64bits word
3717  if (energySumObjType == ETM) {
3718 
3719  if (!getXMLHexTextValue128Old(
3720  findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0], tmpValues[1])) {
3721  edm::LogError("TriggerMenuXmlParser")
3722  << " Could not get phi for ETM condition (" << name << ")" << std::endl;
3723  return false;
3724  }
3725 
3726  objParameter[i].phiRange0Word = tmpValues[0];
3727  objParameter[i].phiRange1Word = tmpValues[1];
3728 
3729  } else if (energySumObjType == HTM) {
3730 
3731  if (!getXMLHexTextValueOld(findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0])) {
3732  edm::LogError("TriggerMenuXmlParser")
3733  << " Could not get phi for HTM condition (" << name << ")" << std::endl;
3734  return false;
3735  }
3736 
3737  objParameter[i].phiRange0Word = tmpValues[0];
3738 
3739  }
3740 
3741  // get energyOverflow logical flag and fill into structure
3742  DOMNode* n1;
3743  if ( (n1 = findXMLChild(node->getFirstChild(), m_xmlTagEtThreshold)) == 0) {
3744  edm::LogError("TriggerMenuXmlParser")
3745  << " Could not get energyOverflow for EnergySum condition (" << name << ")"
3746  << std::endl;
3747  return false;
3748  }
3749  if ( (n1 = findXMLChild(n1->getFirstChild(), m_xmlTagEnergyOverflow)) == 0) {
3750  edm::LogError("TriggerMenuXmlParser")
3751  << " Could not get energyOverflow for EnergySum condition (" << name << ")"
3752  << std::endl;
3753  return false;
3754  }
3755 
3756  int tmpInt = getBitFromNode(n1);
3757  if (tmpInt == 0) {
3758  objParameter[i].energyOverflow = false;
3759 
3760  //LogTrace("TriggerMenuXmlParser")
3761  //<< " EnergySum energyOverflow logical flag (hex) = "
3762  //<< std::hex << objParameter[i].energyOverflow << std::dec
3763  //<< std::endl;
3764  }
3765  else if (tmpInt == 1) {
3766  objParameter[i].energyOverflow = true;
3767 
3768  //LogTrace("TriggerMenuXmlParser")
3769  //<< " EnergySum energyOverflow logical flag (hex) = "
3770  //<< std::hex << objParameter[i].energyOverflow << std::dec
3771  //<< std::endl;
3772  }
3773  else {
3774  LogTrace("TriggerMenuXmlParser")
3775  << " EnergySum energyOverflow logical flag (hex) = " << std::hex << tmpInt
3776  << std::dec << " - wrong value! " << std::endl;
3777  return false;
3778  }
3779 
3780  }
3781 
3782  */
3783 
3784  //
3785  return true;
3786 }
3787 
3799 bool l1t::TriggerMenuXmlParser::parseEnergySumV2(tmeventsetup::esCondition condEnergySum,
3800  unsigned int chipNr, const bool corrFlag) {
3801 
3802 
3803 // XERCES_CPP_NAMESPACE_USE
3804  using namespace tmeventsetup;
3805 
3806  // get condition, particle name and type name
3807 
3808  std::string condition = "calo";
3809  std::string type = l1t2string( condEnergySum.getType() );
3810  std::string name = l1t2string( condEnergySum.getName() );
3811 
3812  LogDebug("TriggerMenuXmlParser")
3813  << "\n ****************************************** "
3814  << "\n (in parseEnergySumV2) "
3815  << "\n condition = " << condition
3816  << "\n type = " << type
3817  << "\n name = " << name
3818  << std::endl;
3819 
3820 
3821 
3822  // determine object type type
3823  L1GtObject energySumObjType;
3824  GtConditionType cType;
3825 
3826  if( condEnergySum.getType() == esConditionType::MissingEt ){
3827  energySumObjType = L1GtObject::ETM;
3828  cType = TypeETM;
3829  }
3830  else if( condEnergySum.getType() == esConditionType::TotalEt ){
3831  energySumObjType = L1GtObject::ETT;
3832  cType = TypeETT;
3833  }
3834  else if( condEnergySum.getType() == esConditionType::TotalHt ){
3835  energySumObjType = L1GtObject::HTT;
3836  cType = TypeHTT;
3837  }
3838  else if( condEnergySum.getType() == esConditionType::MissingHt ){
3839  energySumObjType = L1GtObject::HTM;
3840  cType = TypeHTM;
3841  }
3842  else {
3843  edm::LogError("TriggerMenuXmlParser")
3844  << "Wrong type for energy-sum condition (" << type
3845  << ")" << std::endl;
3846  return false;
3847  }
3848 
3849 
3850 
3851  // global object
3852  int nrObj = 1;
3853 
3854 // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
3855 
3856  // get values
3857 
3858  // temporary storage of the parameters
3859  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
3860 
3861 
3862  int cnt = 0;
3863 
3864 // BLW TO DO: These needs to the added to the object rather than the whole condition.
3865  int relativeBx = 0;
3866  bool gEq = false;
3867 
3868 // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
3869 
3870 // Loop over objects and extract the cuts on the objects
3871  const std::vector<esObject>& objects = condEnergySum.getObjects();
3872  for (size_t jj = 0; jj < objects.size(); jj++) {
3873 
3874  const esObject object = objects.at(jj);
3875  gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
3876 
3877 // BLW TO DO: This needs to be added to the Object Parameters
3878  relativeBx = object.getBxOffset();
3879 
3880 // Loop over the cuts for this object
3881  int lowerThresholdInd = 0;
3882  int upperThresholdInd = -1;
3883  int cntPhi = 0;
3884  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
3885 
3886 
3887  const std::vector<esCut>& cuts = object.getCuts();
3888  for (size_t kk = 0; kk < cuts.size(); kk++)
3889  {
3890  const esCut cut = cuts.at(kk);
3891 
3892  switch(cut.getCutType()){
3893  case esCutType::Threshold:
3894  lowerThresholdInd = cut.getMinimum().index;
3895  upperThresholdInd = cut.getMaximum().index;
3896  break;
3897 
3898  case esCutType::Eta:
3899  break;
3900 
3901  case esCutType::Phi: {
3902 
3903  if(cntPhi == 0) {
3904  phiWindow1Lower = cut.getMinimum().index;
3905  phiWindow1Upper = cut.getMaximum().index;
3906  } else if(cntPhi == 1) {
3907  phiWindow2Lower = cut.getMinimum().index;
3908  phiWindow2Upper = cut.getMaximum().index;
3909  } else {
3910  edm::LogError("TriggerMenuXmlParser") << "Too Many Phi Cuts for esum-condition ("
3911  << type << ")" << std::endl;
3912  return false;
3913  }
3914  cntPhi++;
3915 
3916  }
3917  break;
3918 
3919  default:
3920  break;
3921  } //end switch
3922 
3923  } //end loop over cuts
3924 
3925 
3926 
3927  // Fill the object parameters
3928  objParameter[cnt].etLowThreshold = lowerThresholdInd;
3929  objParameter[cnt].etHighThreshold = upperThresholdInd;
3930  objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
3931  objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
3932  objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
3933  objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
3934 
3935 
3936  // Output for debugging
3937  LogDebug("TriggerMenuXmlParser")
3938  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
3939  << std::hex << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold
3940  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
3941  << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
3942  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
3943  << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper << std::dec
3944  << std::endl;
3945 
3946  cnt++;
3947  } //end loop over objects
3948 
3949  // object types - all same energySumObjType
3950  std::vector<L1GtObject> objType(nrObj, energySumObjType);
3951 
3952  // now create a new energySum condition
3953 
3954  EnergySumTemplate energySumCond(name);
3955 
3956  energySumCond.setCondType(cType);
3957  energySumCond.setObjectType(objType);
3958  energySumCond.setCondGEq(gEq);
3959  energySumCond.setCondChipNr(chipNr);
3960  energySumCond.setCondRelativeBx(relativeBx);
3961 
3962  energySumCond.setConditionParameter(objParameter);
3963 
3964  if (edm::isDebugEnabled() ) {
3965 
3966  std::ostringstream myCoutStream;
3967  energySumCond.print(myCoutStream);
3968  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3969 
3970  }
3971 
3972  // insert condition into the map
3973  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
3974 
3975  edm::LogError("TriggerMenuXmlParser")
3976  << " Error: duplicate condition (" << name << ")"
3977  << std::endl;
3978 
3979  return false;
3980  }
3981  else {
3982 
3983  if (corrFlag) {
3984  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
3985 
3986  }
3987  else {
3988  (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
3989  }
3990 
3991  }
3992 
3993 
3994 
3995  //
3996  return true;
3997 }
3998 
3999 
4011 bool l1t::TriggerMenuXmlParser::parseEnergySumCorr(const tmeventsetup::esObject* corrESum,
4012  unsigned int chipNr) {
4013 
4014 
4015 // XERCES_CPP_NAMESPACE_USE
4016  using namespace tmeventsetup;
4017 
4018  // get condition, particle name and type name
4019 
4020  std::string condition = "calo";
4021  std::string type = l1t2string( corrESum->getType() );
4022  std::string name = l1t2string( corrESum->getName() );
4023 
4024  LogDebug("TriggerMenuXmlParser")
4025  << "\n ****************************************** "
4026  << "\n (in parseEnergySumV2) "
4027  << "\n condition = " << condition
4028  << "\n type = " << type
4029  << "\n name = " << name
4030  << std::endl;
4031 
4032 
4033 
4034  // determine object type type
4035  L1GtObject energySumObjType;
4036  GtConditionType cType;
4037 
4038  if( corrESum->getType()== esObjectType::ETM ){
4039  energySumObjType = L1GtObject::ETM;
4040  cType = TypeETM;
4041  }
4042  else if( corrESum->getType()== esObjectType::HTM ){
4043  energySumObjType = L1GtObject::HTM;
4044  cType = TypeHTM;
4045  }
4046  else {
4047  edm::LogError("TriggerMenuXmlParser")
4048  << "Wrong type for energy-sum correclation condition (" << type
4049  << ")" << std::endl;
4050  return false;
4051  }
4052 
4053 
4054 
4055  // global object
4056  int nrObj = 1;
4057 
4058 // std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
4059 
4060  // get values
4061 
4062  // temporary storage of the parameters
4063  std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
4064 
4065 
4066  int cnt = 0;
4067 
4068 // BLW TO DO: These needs to the added to the object rather than the whole condition.
4069  int relativeBx = 0;
4070  bool gEq = false;
4071 
4072 // l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
4073 
4074 
4075  gEq = (corrESum->getComparisonOperator() == esComparisonOperator::GE);
4076 
4077 // BLW TO DO: This needs to be added to the Object Parameters
4078  relativeBx = corrESum->getBxOffset();
4079 
4080 // Loop over the cuts for this object
4081  int lowerThresholdInd = 0;
4082  int upperThresholdInd = -1;
4083  int cntPhi = 0;
4084  unsigned int phiWindow1Lower=-1, phiWindow1Upper=-1, phiWindow2Lower=-1, phiWindow2Upper=-1;
4085 
4086 
4087  const std::vector<esCut>& cuts = corrESum->getCuts();
4088  for (size_t kk = 0; kk < cuts.size(); kk++)
4089  {
4090  const esCut cut = cuts.at(kk);
4091 
4092  switch(cut.getCutType()){
4093  case esCutType::Threshold:
4094  lowerThresholdInd = cut.getMinimum().index;
4095  upperThresholdInd = cut.getMaximum().index;
4096  break;
4097 
4098  case esCutType::Eta:
4099  break;
4100 
4101  case esCutType::Phi: {
4102 
4103  if(cntPhi == 0) {
4104  phiWindow1Lower = cut.getMinimum().index;
4105  phiWindow1Upper = cut.getMaximum().index;
4106  } else if(cntPhi == 1) {
4107  phiWindow2Lower = cut.getMinimum().index;
4108  phiWindow2Upper = cut.getMaximum().index;
4109  } else {
4110  edm::LogError("TriggerMenuXmlParser") << "Too Many Phi Cuts for esum-condition ("
4111  << type << ")" << std::endl;
4112  return false;
4113  }
4114  cntPhi++;
4115 
4116  }
4117  break;
4118 
4119  default:
4120  break;
4121  } //end switch
4122 
4123  } //end loop over cuts
4124 
4125 
4126 
4127  // Fill the object parameters
4128  objParameter[0].etLowThreshold = lowerThresholdInd;
4129  objParameter[0].etHighThreshold = upperThresholdInd;
4130  objParameter[0].phiWindow1Lower = phiWindow1Lower;
4131  objParameter[0].phiWindow1Upper = phiWindow1Upper;
4132  objParameter[0].phiWindow2Lower = phiWindow2Lower;
4133  objParameter[0].phiWindow2Upper = phiWindow2Upper;
4134 
4135 
4136  // Output for debugging
4137  LogDebug("TriggerMenuXmlParser")
4138  << "\n EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
4139  << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etLowThreshold
4140  << "\n phiWindow Lower / Upper for calo object " << cnt << " = 0x"
4141  << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
4142  << "\n phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
4143  << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper << std::dec
4144  << std::endl;
4145 
4146 
4147  // object types - all same energySumObjType
4148  std::vector<L1GtObject> objType(nrObj, energySumObjType);
4149 
4150  // now create a new energySum condition
4151 
4152  EnergySumTemplate energySumCond(name);
4153 
4154  energySumCond.setCondType(cType);
4155  energySumCond.setObjectType(objType);
4156  energySumCond.setCondGEq(gEq);
4157  energySumCond.setCondChipNr(chipNr);
4158  energySumCond.setCondRelativeBx(relativeBx);
4159 
4160  energySumCond.setConditionParameter(objParameter);
4161 
4162  if (edm::isDebugEnabled() ) {
4163 
4164  std::ostringstream myCoutStream;
4165  energySumCond.print(myCoutStream);
4166  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
4167 
4168  }
4169 
4170  // insert condition into the map
4171  if ( !insertConditionIntoMap(energySumCond, chipNr)) {
4172 
4173  edm::LogError("TriggerMenuXmlParser")
4174  << " Error: duplicate condition (" << name << ")"
4175  << std::endl;
4176 
4177  return false;
4178  }
4179  else {
4180 
4181  (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
4182 
4183  }
4184 
4185 
4186 
4187  //
4188  return true;
4189 }
4190 
4191 
4192 
4205 bool l1t::TriggerMenuXmlParser::parseExternalV2(tmeventsetup::esCondition condExt,
4206  unsigned int chipNr) {
4207 
4208 
4209  using namespace tmeventsetup;
4210 
4211 
4212  // get condition, particle name and type name
4213  std::string condition = "ext";
4214  std::string particle = "test-fix";
4215  std::string type = l1t2string( condExt.getType() );
4216  std::string name = l1t2string( condExt.getName() );
4217 
4218 
4219  LogDebug("TriggerMenuXmlParser")
4220  << "\n ****************************************** "
4221  << "\n (in parseExternalV2) "
4222  << "\n condition = " << condition
4223  << "\n particle = " << particle
4224  << "\n type = " << type
4225  << "\n name = " << name
4226  << std::endl;
4227 
4228 
4229  // object type and condition type
4230  // object type - irrelevant for External conditions
4231  GtConditionType cType = TypeExternal;
4232 
4233  int relativeBx = 0;
4234  unsigned int channelID = 0;
4235 
4236  // Get object for External conditions
4237  const std::vector<esObject>& objects = condExt.getObjects();
4238  for (size_t jj = 0; jj < objects.size(); jj++) {
4239 
4240  const esObject object = objects.at(jj);
4241  if(object.getType() == esObjectType::EXT) {
4242  relativeBx = object.getBxOffset();
4243  channelID = object.getExternalChannelId();
4244  }
4245  }
4246 
4247 
4248  // set the boolean value for the ge_eq mode - irrelevant for External conditions
4249  bool gEq = false;
4250 
4251  // now create a new External condition
4252  ExternalTemplate externalCond(name);
4253 
4254  externalCond.setCondType(cType);
4255  externalCond.setCondGEq(gEq);
4256  externalCond.setCondChipNr(chipNr);
4257  externalCond.setCondRelativeBx(relativeBx);
4258  externalCond.setExternalChannel(channelID);
4259 
4260  LogTrace("TriggerMenuXmlParser")
4261  << externalCond << "\n" << std::endl;
4262 
4263  // insert condition into the map
4264  if ( !insertConditionIntoMap(externalCond, chipNr)) {
4265 
4266  edm::LogError("TriggerMenuXmlParser")
4267  << " Error: duplicate condition (" << name
4268  << ")" << std::endl;
4269 
4270  return false;
4271  } else {
4272 
4273  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
4274 
4275  }
4276 
4277  return true;
4278 }
4279 
4280 
4281 
4282 
4283 
4295 /*
4296 bool l1t::TriggerMenuXmlParser::parseExternal(XERCES_CPP_NAMESPACE::DOMNode* node,
4297  const std::string& name, unsigned int chipNr) {
4298 
4299  XERCES_CPP_NAMESPACE_USE
4300 */
4301  /*
4302  // get condition, particle name and type name
4303  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
4304  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
4305  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
4306 
4307  if (particle != m_xmlConditionAttrObjectGtExternal) {
4308  edm::LogError("TriggerMenuXmlParser")
4309  << "\nError: wrong particle for External condition ("
4310  << particle << ")" << std::endl;
4311  return false;
4312  }
4313 
4314  // object type and condition type
4315  // object type - irrelevant for External conditions
4316  GtConditionType cType = TypeExternal;
4317 
4318  // no objects for External conditions
4319 
4320  // set the boolean value for the ge_eq mode - irrelevant for External conditions
4321  bool gEq = false;
4322 
4323  // now create a new External condition
4324 
4325  L1GtExternalTemplate externalCond(name);
4326 
4327  externalCond.setCondType(cType);
4328  externalCond.setCondGEq(gEq);
4329  externalCond.setCondChipNr(chipNr);
4330 
4331  LogTrace("TriggerMenuXmlParser") << externalCond << "\n" << std::endl;
4332 
4333  // insert condition into the map
4334  if ( !insertConditionIntoMap(externalCond, chipNr)) {
4335 
4336  edm::LogError("TriggerMenuXmlParser")
4337  << " Error: duplicate condition (" << name
4338  << ")" << std::endl;
4339 
4340  return false;
4341  } else {
4342 
4343  (m_vecExternalTemplate[chipNr]).push_back(externalCond);
4344 
4345  }
4346  */
4347 
4348  //
4349 /*
4350  return true;
4351 }
4352 */
4353 
4367  XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& name,
4368  unsigned int chipNr) {
4369 
4370  XERCES_CPP_NAMESPACE_USE
4371 
4372  // create a new correlation condition
4373  CorrelationTemplate correlationCond(name);
4374 
4375  // check that the condition does not exist already in the map
4376  if ( !insertConditionIntoMap(correlationCond, chipNr)) {
4377 
4378  edm::LogError("TriggerMenuXmlParser")
4379  << " Error: duplicate correlation condition (" << name << ")"
4380  << std::endl;
4381 
4382  return false;
4383  }
4384 
4385  /*
4386  // get condition, particle name and type name
4387  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
4388  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
4389  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
4390 
4391  std::cout << " ****************************************** " << std::endl;
4392  std::cout << " DARRENS TEST OUTPUT (in parseCorrelation) " << std::endl;
4393  std::cout << " condition = " << condition << std::endl;
4394  std::cout << " particle = " << particle << std::endl;
4395  std::cout << " type = " << type << std::endl;
4396  std::cout << " name = " << name << std::endl;
4397 
4398  LogTrace("TriggerMenuXmlParser") << " Condition category: "
4399  << condition << ", particle: " << particle << ", type: " << type
4400  << "\n" << std::endl;
4401 
4402  // condition type
4403  GtConditionType cType = l1t::Type2cor;
4404 
4405  // two objects (for sure)
4406  const int nrObj = 2;
4407 
4408  // object types and greater equal flag - filled in the loop
4409  int intGEq[nrObj] = { -1, -1 };
4410  std::vector<L1GtObject> objType(nrObj);
4411  std::vector<GtConditionCategory> condCateg(nrObj);
4412 
4413  // correlation flag and index in the cor*vector
4414  const bool corrFlag = true;
4415  int corrIndexVal[nrObj] = { -1, -1 };
4416 
4417  // get the subconditions
4418 
4419  DOMNode* conditionsNode = node->getFirstChild();
4420  std::string conditionNameNodeName;
4421  conditionsNode = findXMLChild(conditionsNode, "", true,
4422  &conditionNameNodeName);
4423 
4424 
4425  for (int iSubCond = 0; iSubCond < nrObj; ++iSubCond) {
4426 
4427  // get for sub-condition: category, object name and type name and condition name
4428  condition = getXMLAttribute(conditionsNode, m_xmlConditionAttrCondition);
4429  particle = getXMLAttribute(conditionsNode, m_xmlConditionAttrObject);
4430  type = getXMLAttribute(conditionsNode, m_xmlConditionAttrType);
4431 
4432  LogTrace("TriggerMenuXmlParser") << " Sub-condition category: "
4433  << condition << ", particle: " << particle << ", type: "
4434  << type << ", name: " << conditionNameNodeName << "\n"
4435  << std::endl;
4436 
4437  // call the appropriate function for this condition
4438  if (condition == m_xmlConditionAttrConditionMuon) {
4439  if (!parseMuon(conditionsNode, conditionNameNodeName, chipNr,
4440  corrFlag)) {
4441  edm::LogError("TriggerMenuXmlParser")
4442  << "Error parsing sub-condition " << condition << ")"
4443  << " with name " << conditionNameNodeName << std::endl;
4444 
4445  }
4446 
4447  // get greater equal flag
4448  intGEq[iSubCond] = getGEqFlag(conditionsNode,
4449  m_xmlTagPtHighThreshold);
4450  if (intGEq[iSubCond] < 0) {
4451  edm::LogError("TriggerMenuXmlParser")
4452  << "Error getting \"greater or equal\" flag"
4453  << " for sub-condition " << conditionNameNodeName
4454  << " for the correlation condition " << name
4455  << std::endl;
4456  return false;
4457  }
4458 
4459  // set object type and sub-condition category
4460  objType[iSubCond] = Mu;
4461  condCateg[iSubCond] = CondMuon;
4462  corrIndexVal[iSubCond] = (m_corMuonTemplate[chipNr]).size() - 1;
4463 
4464  }
4465  else if (condition == m_xmlConditionAttrConditionCalo) {
4466  if (!parseCalo(conditionsNode, conditionNameNodeName, chipNr,
4467  corrFlag)) {
4468  edm::LogError("TriggerMenuXmlParser")
4469  << "Error parsing sub-condition " << condition << ")"
4470  << " with name " << conditionNameNodeName << std::endl;
4471 
4472  }
4473 
4474  // get greater equal flag
4475  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
4476  if (intGEq[iSubCond] < 0) {
4477  edm::LogError("TriggerMenuXmlParser")
4478  << "Error getting \"greater or equal\" flag"
4479  << " for sub-condition " << conditionNameNodeName
4480  << " for the correlation condition " << name
4481  << std::endl;
4482  return false;
4483  }
4484 
4485  // set object type and sub-condition category
4486  if (particle == m_xmlConditionAttrObjectNoIsoEG) {
4487  objType[iSubCond] = NoIsoEG;
4488  }
4489  else if (particle == m_xmlConditionAttrObjectIsoEG) {
4490  objType[iSubCond] = IsoEG;
4491  }
4492  else if (particle == m_xmlConditionAttrObjectCenJet) {
4493  objType[iSubCond] = CenJet;
4494  }
4495  else if (particle == m_xmlConditionAttrObjectTauJet) {
4496  objType[iSubCond] = TauJet;
4497  }
4498  else if (particle == m_xmlConditionAttrObjectForJet) {
4499  objType[iSubCond] = ForJet;
4500  }
4501  else {
4502  edm::LogError("TriggerMenuXmlParser")
4503  << "Wrong object type " << particle
4504  << " for sub-condition " << conditionNameNodeName
4505  << " from the correlation condition " << name
4506  << std::endl;
4507  return false;
4508  }
4509 
4510  condCateg[iSubCond] = CondCalo;
4511  corrIndexVal[iSubCond] = (m_corCaloTemplate[chipNr]).size() - 1;
4512 
4513  }
4514  else if (condition == m_xmlConditionAttrConditionEnergySum) {
4515  if (!parseEnergySum(conditionsNode, conditionNameNodeName, chipNr,
4516  corrFlag)) {
4517  edm::LogError("TriggerMenuXmlParser")
4518  << "Error parsing sub-condition " << condition << ")"
4519  << " with name " << conditionNameNodeName << std::endl;
4520 
4521  }
4522 
4523  // get greater equal flag
4524  intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
4525  if (intGEq[iSubCond] < 0) {
4526  edm::LogError("TriggerMenuXmlParser")
4527  << "Error getting \"greater or equal\" flag"
4528  << " for sub-condition " << conditionNameNodeName
4529  << " for the correlation condition " << name
4530  << std::endl;
4531  return false;
4532  }
4533 
4534  // set object type and sub-condition category
4535  if (particle == m_xmlConditionAttrObjectETM) {
4536  objType[iSubCond] = ETM;
4537  }
4538  else if (particle == m_xmlConditionAttrObjectETT) {
4539  objType[iSubCond] = ETT;
4540  }
4541  else if (particle == m_xmlConditionAttrObjectHTT) {
4542  objType[iSubCond] = HTT;
4543  }
4544  else if (particle == m_xmlConditionAttrObjectHTM) {
4545  objType[iSubCond] = HTM;
4546  }
4547  else {
4548  edm::LogError("TriggerMenuXmlParser")
4549  << "Wrong object type " << particle
4550  << " for sub-condition " << conditionNameNodeName
4551  << " from the correlation condition " << name
4552  << std::endl;
4553  return false;
4554  }
4555 
4556  condCateg[iSubCond] = CondEnergySum;
4557  corrIndexVal[iSubCond] = (m_corEnergySumTemplate[chipNr]).size() - 1;
4558 
4559  }
4560  else {
4561  edm::LogError("TriggerMenuXmlParser")
4562  << "Unknown or un-adequate sub-condition (" << condition
4563  << ")" << " with name " << conditionNameNodeName
4564  << " for the correlation condition " << name << std::endl;
4565 
4566  return false;
4567  }
4568 
4569  conditionsNode = findXMLChild(conditionsNode->getNextSibling(), "",
4570  true, &conditionNameNodeName);
4571 
4572  }
4573 
4574  // get greater equal flag for the correlation condition
4575  bool gEq = true;
4576  if (intGEq[0] != intGEq[1]) {
4577  edm::LogError("TriggerMenuXmlParser")
4578  << "Inconsistent GEq flags for sub-conditions (" << condition
4579  << ")" << " with name " << conditionNameNodeName
4580  << " for the correlation condition " << name << std::endl;
4581  return false;
4582 
4583  }
4584  else {
4585  gEq = (intGEq[0] != 0);
4586 
4587  }
4588 
4589  // correlation parameters
4590 
4591  // temporary storage of the parameters
4592  CorrelationTemplate::CorrelationParameter corrParameter;
4593  std::vector<boost::uint64_t> tmpValues(nrObj);
4594 
4595  // get deltaEtaRange
4596 // if ( !getConditionChildValuesOld(node, m_xmlTagDeltaEta, 1, tmpValues) ) {
4597 // return false;
4598 // }
4599 //
4600 // corrParameter.deltaEtaRange = tmpValues[0];
4601 
4602  XERCES_CPP_NAMESPACE::DOMNode* node1 = findXMLChild(node->getFirstChild(),
4603  m_xmlTagDeltaEta);
4604 
4605  std::string valString;
4606 
4607  if (node1 == 0) {
4608  edm::LogError("TriggerMenuXmlParser")
4609  << " Could not get deltaEta for correlation condition "
4610  << name << ". " << std::endl;
4611  return false;
4612  }
4613  else {
4614  valString = getXMLTextValue(node1);
4615  }
4616 
4617  corrParameter.deltaEtaRange = valString;
4618 
4619 // // deltaPhi is larger than 64bit
4620 // if ( !getXMLHexTextValue128Old(findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi),
4621 // tmpValues[0], tmpValues[1])) {
4622 // edm::LogError("TriggerMenuXmlParser")
4623 // << " Could not get deltaPhi for correlation condition " << name << ". "
4624 // << std::endl;
4625 // return false;
4626 // }
4627 //
4628 // corrParameter.deltaPhiRange = tmpValues[0];
4629 
4630  node1 = findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi);
4631 
4632  if (node1 == 0) {
4633  return false;
4634  edm::LogError("TriggerMenuXmlParser")
4635  << " Could not get deltaPhi for correlation condition "
4636  << name << ". " << std::endl;
4637  }
4638  else {
4639  valString = getXMLTextValue(node1);
4640  }
4641 
4642  corrParameter.deltaPhiRange = valString;
4643 
4644  // get maximum number of bits for delta phi
4645  //LogTrace("TriggerMenuXmlParser")
4646  //<< " Counting deltaPhiMaxbits"
4647  //<< std::endl;
4648 
4649  unsigned int maxbits;
4650 
4651  if ( !countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits) ) {
4652  return false;
4653  }
4654 
4655  corrParameter.deltaPhiMaxbits = maxbits;
4656  //LogTrace("TriggerMenuXmlParser")
4657  //<< " deltaPhiMaxbits (dec) = " << maxbits
4658  //<< std::endl;
4659 
4660 
4661  // fill the correlation condition
4662  correlationCond.setCondType(cType);
4663  correlationCond.setObjectType(objType);
4664  correlationCond.setCondGEq(gEq);
4665  correlationCond.setCondChipNr(chipNr);
4666 
4667  correlationCond.setCond0Category(condCateg[0]);
4668  correlationCond.setCond1Category(condCateg[1]);
4669 
4670  correlationCond.setCond0Index(corrIndexVal[0]);
4671  correlationCond.setCond1Index(corrIndexVal[1]);
4672 
4673  correlationCond.setCorrelationParameter(corrParameter);
4674 
4675  if (edm::isDebugEnabled() ) {
4676 
4677  std::ostringstream myCoutStream;
4678  correlationCond.print(myCoutStream);
4679  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n"
4680  << std::endl;
4681 
4682  }
4683 
4684  // insert condition into the map
4685  // condition is not duplicate, check was done at the beginning
4686 
4687  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
4688 
4689  */
4690  //
4691  return true;
4692 }
4693 
4694 
4708  tmeventsetup::esCondition corrCond,
4709  unsigned int chipNr) {
4710 
4711  using namespace tmeventsetup;
4712 
4713  std::string condition = "corr";
4714  std::string particle = "test-fix" ;
4715  std::string type = l1t2string( corrCond.getType() );
4716  std::string name = l1t2string( corrCond.getName() );
4717 
4718  LogDebug("TriggerMenuXmlParser") << " ****************************************** " << std::endl
4719  << " (in parseCorrelation) " << std::endl
4720  << " condition = " << condition << std::endl
4721  << " particle = " << particle << std::endl
4722  << " type = " << type << std::endl
4723  << " name = " << name << std::endl;
4724 
4725 
4726 
4727 
4728  // create a new correlation condition
4729  CorrelationTemplate correlationCond(name);
4730 
4731  // check that the condition does not exist already in the map
4732  if ( !insertConditionIntoMap(correlationCond, chipNr)) {
4733 
4734  edm::LogError("TriggerMenuXmlParser")
4735  << " Error: duplicate correlation condition (" << name << ")"
4736  << std::endl;
4737 
4738  return false;
4739  }
4740 
4741 
4742 // Define some of the quantities to store the parased information
4743 
4744  // condition type BLW (Do we change this to the type of correlation condition?)
4746 
4747  // two objects (for sure)
4748  const int nrObj = 2;
4749 
4750  // object types and greater equal flag - filled in the loop
4751  int intGEq[nrObj] = { -1, -1 };
4752  std::vector<L1GtObject> objType(nrObj); //BLW do we want to define these as a different type?
4753  std::vector<GtConditionCategory> condCateg(nrObj); //BLW do we want to change these categories
4754 
4755  // correlation flag and index in the cor*vector
4756  const bool corrFlag = true;
4757  int corrIndexVal[nrObj] = { -1, -1 };
4758 
4759 
4760  // Storage of the correlation selection
4762  corrParameter.chargeCorrelation = 1; //ignore charge correlation
4763 
4764 // Get the correlation Cuts on the legs
4765 
4766  const std::vector<esCut>& cuts = corrCond.getCuts();
4767  for (size_t jj = 0; jj < cuts.size(); jj++)
4768  {
4769  const esCut cut = cuts.at(jj);
4770  std::cout << " cut name = " << cut.getName() << "\n";
4771  std::cout << " cut target = " << cut.getObjectType() << "\n";
4772  std::cout << " cut type = " << cut.getCutType() << "\n";
4773  std::cout << " cut min. value index = " << cut.getMinimum().value << " " << cut.getMinimum().index << "\n";
4774  std::cout << " cut max. value index = " << cut.getMaximum().value << " " << cut.getMaximum().index << "\n";
4775  std::cout << " cut data = " << cut.getData() << "\n";
4776 
4777 
4778  if(cut.getCutType() == esCutType::ChargeCorrelation) {
4779  if( cut.getData()=="ls" ) corrParameter.chargeCorrelation = 2;
4780  else if( cut.getData()=="os" ) corrParameter.chargeCorrelation = 4;
4781  else corrParameter.chargeCorrelation = 1; //ignore charge correlation
4782  } else {
4783  //keep the type from what the correlation is.
4784  corrParameter.corrCutType = cut.getCutType();
4785  corrParameter.minCutValue = cut.getMinimum().value;
4786  corrParameter.maxCutValue = cut.getMaximum().value;
4787  }
4788 
4789  }
4790 
4791 
4792 // Get the two objects that form the legs
4793  const std::vector<esObject>& objects = corrCond.getObjects();
4794  if(objects.size() != 2) {
4795  edm::LogError("TriggerMenuXmlParser")
4796  << "incorrect number of objects for the correlation condition " << name << " corrFlag " << corrFlag << std::endl;
4797  return false;
4798  }
4799 
4800 // loop over legs
4801  for (size_t jj = 0; jj < objects.size(); jj++)
4802  {
4803  const esObject object = objects.at(jj);
4804 /* std::cout << " obj name = " << object->getName() << "\n";
4805  std::cout << " obj type = " << object->getType() << "\n";
4806  std::cout << " obj op = " << object->getComparisonOperator() << "\n";
4807  std::cout << " obj bx = " << object->getBxOffset() << "\n";
4808 */
4809 
4810 // check the leg type
4811  if(object.getType() == esObjectType::Muon) {
4812  // we have a muon
4813 
4814  //BLW Is there a problem here with not entering second instanance into the m_corMuonTemplate[]?
4815  if ((m_conditionMap[chipNr]).count(object.getName()) == 0) {
4816 
4817  parseMuonCorr(&object,chipNr);
4818 
4819  } else {
4820  LogDebug("TriggerMenuXmlParser") << "Not Adding Correlation Muon Condition." << std::endl;
4821  }
4822 
4823  //Now set some flags for this subCondition
4824  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
4825  objType[jj] = Mu;
4826  condCateg[jj] = CondMuon;
4827  corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
4828 
4829 
4830 
4831  } else if(object.getType() == esObjectType::Egamma ||
4832  object.getType() == esObjectType::Jet ||
4833  object.getType() == esObjectType::Tau ) {
4834  // we have an Calo object
4835 
4836  //BLW Is there a problem here with not entering second instanance into the m_corMuonTemplate[]?
4837  if ((m_conditionMap[chipNr]).count(object.getName()) == 0) {
4838 
4839  parseCaloCorr(&object,chipNr);
4840 
4841  } else {
4842  LogDebug("TriggerMenuXmlParser") << "Not Adding Correlation Calo Condition." << std::endl;
4843  }
4844 
4845 
4846  //Now set some flags for this subCondition
4847  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
4848  switch(object.getType()) {
4849  case esObjectType::Egamma: {
4850  objType[jj] = NoIsoEG;
4851  }
4852  break;
4853  case esObjectType::Jet: {
4854  objType[jj] = CenJet;
4855  }
4856  break;
4857  case esObjectType::Tau: {
4858  objType[jj] = TauJet;
4859  }
4860  break;
4861  default: {
4862  }
4863  break;
4864  }
4865  condCateg[jj] = CondCalo;
4866  corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
4867 
4868 
4869  } else if(object.getType() == esObjectType::ETM ||
4870  object.getType() == esObjectType::HTM ) {
4871  // we have Energy Sum
4872 
4873  //BLW Is there a problem here with not entering second instanance into the m_corMuonTemplate[]?
4874  if ((m_conditionMap[chipNr]).count(object.getName()) == 0) {
4875 
4876  parseEnergySumCorr(&object,chipNr);
4877 
4878  } else {
4879  LogDebug("TriggerMenuXmlParser") << "Not Adding Correlation EtSum Condition." << std::endl;
4880  }
4881 
4882 
4883  //Now set some flags for this subCondition
4884  intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
4885  switch(object.getType()) {
4886  case esObjectType::ETM: {
4887  objType[jj] = L1GtObject::ETM;
4888  }
4889  break;
4890  case esObjectType::HTM: {
4891  objType[jj] = L1GtObject::HTM;
4892  }
4893  break;
4894  default: {
4895  }
4896  break;
4897  }
4898  condCateg[jj] = CondEnergySum;
4899  corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
4900 
4901  } else {
4902 
4903  edm::LogError("TriggerMenuXmlParser")
4904  << "Illegal Object Type "
4905  << " for the correlation condition " << name << std::endl;
4906  return false;
4907 
4908  } //if block on leg types
4909 
4910  } //loop over legs
4911 
4912 
4913  // get greater equal flag for the correlation condition
4914  bool gEq = true;
4915  if (intGEq[0] != intGEq[1]) {
4916  edm::LogError("TriggerMenuXmlParser")
4917  << "Inconsistent GEq flags for sub-conditions "
4918  << " for the correlation condition " << name << std::endl;
4919  return false;
4920 
4921  }
4922  else {
4923  gEq = (intGEq[0] != 0);
4924 
4925  }
4926 
4927 
4928  // fill the correlation condition
4929  correlationCond.setCondType(cType);
4930  correlationCond.setObjectType(objType);
4931  correlationCond.setCondGEq(gEq);
4932  correlationCond.setCondChipNr(chipNr);
4933 
4934  correlationCond.setCond0Category(condCateg[0]);
4935  correlationCond.setCond1Category(condCateg[1]);
4936 
4937  correlationCond.setCond0Index(corrIndexVal[0]);
4938  correlationCond.setCond1Index(corrIndexVal[1]);
4939 
4940  correlationCond.setCorrelationParameter(corrParameter);
4941 
4942  if (edm::isDebugEnabled() ) {
4943 
4944  std::ostringstream myCoutStream;
4945  correlationCond.print(myCoutStream);
4946  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n"
4947  << std::endl;
4948 
4949  }
4950 
4951  // insert condition into the map
4952  // condition is not duplicate, check was done at the beginning
4953 
4954  (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
4955 
4956 
4957  //
4958  return true;
4959 }
4960 
4961 
4962 
4971 bool l1t::TriggerMenuXmlParser::parseId( l1t::Meta meta ) {
4972 
4973  XERCES_CPP_NAMESPACE_USE
4974 
4975 // DOMNode* doc = parser->getDocument();
4976 // DOMNode* n1 = doc->getFirstChild();
4977 
4978 // // we assume that the first child is m_xmlTagDef because it was checked in workXML
4979 
4980 // DOMNode* headerNode = n1->getFirstChild();
4981 // if (headerNode == 0) {
4982 // edm::LogError("TriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef
4983 // << "> tag found." << std::endl;
4984 // return false;
4985 // }
4986 
4987 // headerNode = findXMLChild(headerNode, m_xmlTagHeader);
4988 // if (headerNode == 0) {
4989 
4990 // LogDebug("TriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagHeader
4991 // << "> tag" << "\n - No header information." << std::endl;
4992 
4993 // } else {
4994 
4995 // DOMNode* idNode = headerNode->getFirstChild();
4996 
4997 // // find menu interface name
4998 // idNode = findXMLChild(idNode, m_xmlTagMenuInterface);
4999 // if (idNode == 0) {
5000 
5001 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
5002 // << m_xmlTagMenuInterface << "> tag"
5003 // << "\n - Trigger menu interface name derived from file name." << std::endl;
5004 
5005 // // set the name of the trigger menu interface: from beginning of file names
5006 // // until beginning of "_L1T_Scales"
5007 // size_t xmlPos = m_triggerMenuName.find("_L1T_Scales", 0);
5008 // if (xmlPos == std::string::npos) {
5009 // LogTrace("TriggerMenuXmlParser")
5010 // << "\n Warning: Could not find \"_L1T_Scales\" " << "string in file name"
5011 // << "\n - Trigger menu interface name set to file name." << std::endl;
5012 // m_triggerMenuInterface = m_triggerMenuName;
5013 
5014 // } else {
5015 // m_triggerMenuInterface = m_triggerMenuName;
5016 // m_triggerMenuInterface.erase(
5017 // m_triggerMenuInterface.begin(), m_triggerMenuInterface.begin() + xmlPos);
5018 // }
5019 
5020 // } else {
5021 // m_triggerMenuInterface = getXMLTextValue(idNode);
5022 // }
5023 
5024 // // find menu interface creation date
5025 // idNode = headerNode->getFirstChild();
5026 // idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDate);
5027 
5028 // if (idNode == 0) {
5029 
5030 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
5031 // << m_xmlTagMenuInterfaceDate << "> tag" << "\n - No creation date."
5032 // << m_triggerMenuInterfaceDate << std::endl;
5033 
5034 // } else {
5035 
5036 // m_triggerMenuInterfaceDate = getXMLTextValue(idNode);
5037 // }
5038 
5039 // // find menu interface creation author
5040 // idNode = headerNode->getFirstChild();
5041 // idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceAuthor);
5042 
5043 // if (idNode == 0) {
5044 
5045 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
5046 // << m_xmlTagMenuInterfaceAuthor << "> tag" << "\n - No creation author."
5047 // << m_triggerMenuInterfaceAuthor << std::endl;
5048 
5049 // } else {
5050 
5051 // m_triggerMenuInterfaceAuthor = getXMLTextValue(idNode);
5052 // }
5053 
5054 // // find menu interface description
5055 // idNode = headerNode->getFirstChild();
5056 // idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDescription);
5057 
5058 // if (idNode == 0) {
5059 
5060 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
5061 // << m_xmlTagMenuInterfaceDescription << "> tag" << "\n - No description."
5062 // << m_triggerMenuInterfaceDescription << std::endl;
5063 
5064 // } else {
5065 
5066 // m_triggerMenuInterfaceDescription = getXMLTextValue(idNode);
5067 // }
5068 
5069 // // find menu creation date
5070 // idNode = headerNode->getFirstChild();
5071 // idNode = findXMLChild(idNode, m_xmlTagMenuDate);
5072 
5073 // if (idNode == 0) {
5074 
5075 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
5076 // << m_xmlTagMenuDate << "> tag" << "\n - No creation date."
5077 // << m_triggerMenuDate << std::endl;
5078 
5079 // } else {
5080 
5081 // m_triggerMenuDate = getXMLTextValue(idNode);
5082 // }
5083 
5084 // // find menu creation author
5085 // idNode = headerNode->getFirstChild();
5086 // idNode = findXMLChild(idNode, m_xmlTagMenuAuthor);
5087 
5088 // if (idNode == 0) {
5089 
5090 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
5091 // << m_xmlTagMenuAuthor << "> tag" << "\n - No creation author."
5092 // << m_triggerMenuAuthor << std::endl;
5093 
5094 // } else {
5095 
5096 // m_triggerMenuAuthor = getXMLTextValue(idNode);
5097 // }
5098 
5099 // // find menu description
5100 // idNode = headerNode->getFirstChild();
5101 // idNode = findXMLChild(idNode, m_xmlTagMenuDescription);
5102 
5103 // if (idNode == 0) {
5104 
5105 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
5106 // << m_xmlTagMenuDescription << "> tag" << "\n - No description."
5107 // << m_triggerMenuDescription << std::endl;
5108 
5109 // } else {
5110 
5111 // m_triggerMenuDescription = getXMLTextValue(idNode);
5112 // }
5113 
5114 // // find algorithm implementation tag
5115 
5116 // idNode = headerNode->getFirstChild();
5117 
5118 // idNode = findXMLChild(idNode, m_xmlTagMenuAlgImpl);
5119 // if (idNode == 0) {
5120 
5121 // m_algorithmImplementation = "";
5122 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
5123 // << m_xmlTagMenuAlgImpl << "> tag"
5124 // << "\n - Algorithm implementation tag set to empty string." << std::endl;
5125 
5126 // } else {
5127 
5128 // m_algorithmImplementation = getXMLTextValue(idNode);
5129 // }
5130 
5131 // // find DB key for L1 scales
5132 
5133 // idNode = headerNode->getFirstChild();
5134 
5135 // idNode = findXMLChild(idNode, m_xmlTagScaleDbKey);
5136 // if (idNode == 0) {
5137 
5138 // m_scaleDbKey = "NULL";
5139 // LogTrace("TriggerMenuXmlParser") << "\n Warning: Could not find <"
5140 // << m_xmlTagScaleDbKey << "> tag" << "\n - Scale key set to " << m_scaleDbKey
5141 // << " string." << std::endl;
5142 
5143 // } else {
5144 // m_scaleDbKey = getXMLTextValue(idNode);
5145 // }
5146 
5147 // }
5148 
5149 
5150 
5151  m_triggerMenuInterface = l1t2string( meta.name() );
5152  m_triggerMenuInterfaceDate = "2013-010-24T15:33:24";
5153  m_triggerMenuInterfaceAuthor = "Darren Puigh";
5154  m_triggerMenuInterfaceDescription = l1t2string( meta.comment() );
5155 // m_algorithmImplementation = l1t2string( meta.firmwareVersion() );
5156 // m_triggerMenuDate = l1t2string( meta.changesDate() );
5157 // m_triggerMenuAuthor = l1t2string( meta.changesAuthor() );
5158  m_triggerMenuDescription = l1t2string( meta.comment() );
5159  m_scaleDbKey = l1t2string( meta.scale_set() );
5160 
5161 
5162  int cnt = 0;
5163  for( l1t::RevisionList::revision_const_iterator revision = meta.revisions().revision().begin();
5164  revision != meta.revisions().revision().end(); ++revision ){
5165 
5166  LogDebug("TriggerMenuXmlParser")
5167  << "\t Revision " << cnt
5168  << "\t\t author = " << l1t2string( revision->author() )
5169  << "\t\t datetime = " << l1tDateTime2string( revision->datetime() )
5170  << std::endl;
5171 
5172  if( cnt==0 ){
5173  m_triggerMenuDate = l1tDateTime2string( revision->datetime() );
5174  m_triggerMenuAuthor = l1t2string( revision->author() );
5175  }
5176  cnt++;
5177  }
5178 
5179  //LogDebug("TriggerMenuXmlParser")
5180  LogDebug("TriggerMenuXmlParser")
5181  << "\n Parsed values from XML file DRULES"
5182  << "\nL1 MenuInterface: " << m_triggerMenuInterface
5183  << "\nL1 MenuInterface - Creation date: " << m_triggerMenuInterfaceDate
5184  << "\nL1 MenuInterface - Creation author: " << m_triggerMenuInterfaceAuthor
5185  << "\nL1 MenuInterface - Description: " << m_triggerMenuInterfaceDescription
5186  << "\n"
5187  << "\nAlgorithm implementation tag: " << m_algorithmImplementation
5188  << "\n"
5189  << "\nL1 Menu - Creation date: " << m_triggerMenuDate
5190  << "\nL1 Menu - Creation author: " << m_triggerMenuAuthor
5191  << "\nL1 Menu - Description: " << m_triggerMenuDescription
5192  << std::endl;
5193 
5194 
5195  // set the trigger menu name
5196  // format:
5197  // L1MenuInterface/ScaleDbKey/AlgorithmImplementationTag
5198 
5199  std::string menuName = m_triggerMenuInterface + "/" + m_scaleDbKey + "/" + m_algorithmImplementation;
5200 
5201  if (menuName != m_triggerMenuName) {
5202 
5203  LogDebug("TriggerMenuXmlParser") << "\n Warning: Inconsistent L1 menu name:"
5204  << "\n from XML file name: " << m_triggerMenuName
5205  << "\n from XML tag: " << menuName << std::endl;
5206 
5207  if (m_triggerMenuInterface != "") {
5208  if (m_scaleDbKey == "NULL") {
5209  m_triggerMenuName = m_triggerMenuInterface;
5210  } else {
5211  m_triggerMenuName = menuName;
5212  }
5213 
5214  LogTrace("TriggerMenuXmlParser") << "\n L1 menu name set to value from XML tag!"
5215  << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
5216 
5217  } else {
5218  LogTrace("TriggerMenuXmlParser") << "\n L1 menu name set to file name!"
5219  << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
5220 
5221  }
5222  }
5223 
5224  //
5225  return true;
5226 }
5227 
5239 bool l1t::TriggerMenuXmlParser::workCondition(XERCES_CPP_NAMESPACE::DOMNode* node,
5240  const std::string& name, unsigned int chipNr) {
5241 
5242  XERCES_CPP_NAMESPACE_USE
5243 
5244  // get condition, particle name and type name
5245  std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
5246  std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
5247  std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
5248 
5249  LogDebug("TriggerMenuXmlParser")
5250  << "\n ****************************************** "
5251  << "\n workCondition "
5252  << "\n condition = " << condition
5253  << "\n particle = " << particle
5254  << "\n type = " << type
5255  << "\n name = " << name
5256  << std::endl;
5257 
5258  if (condition.empty() || particle.empty() || type.empty() ) {
5259 
5260  edm::LogError("TriggerMenuXmlParser") << "Missing attributes for condition " << name
5261  << std::endl;
5262 
5263  return false;
5264  }
5265 
5266  //LogTrace("TriggerMenuXmlParser")
5267  //<< " condition: " << condition << ", particle: " << particle
5268  //<< ", type: " << type << std::endl;
5269 
5270  // call the appropiate function for this condition
5271 
5272  /*
5273  if (condition == m_xmlConditionAttrConditionMuon) {
5274  return parseMuon(node, name, chipNr);
5275  }
5276  else if (condition == m_xmlConditionAttrConditionCalo) {
5277  return parseCalo(node, name, chipNr);
5278  }
5279  else if (condition == m_xmlConditionAttrConditionEnergySum) {
5280  return parseEnergySum(node, name, chipNr);
5281  }
5282  else if (condition == m_xmlConditionAttrConditionExternal) {
5283  return parseExternal(node, name, chipNr);
5284  }
5285  else if (condition == m_xmlConditionAttrConditionCorrelation) {
5286  return parseCorrelation(node, name, chipNr);
5287  }
5288  else {
5289  edm::LogError("TriggerMenuXmlParser")
5290  << "\n Error: unknown condition (" << condition << ")"
5291  << std::endl;
5292 
5293  return false;
5294  }
5295 
5296  */
5297  return true;
5298 
5299 }
5300 
5311 bool l1t::TriggerMenuXmlParser::parseConditions( l1t::ConditionList conditions ){
5312 
5313  XERCES_CPP_NAMESPACE_USE
5314 
5315  LogTrace("TriggerMenuXmlParser") << "\nParsing conditions" << std::endl;
5316 
5317  int chipNr = 1;
5318  LogDebug("TriggerMenuXmlParser") << " ====> condCalorimeter" << std::endl;
5319  for (l1t::ConditionList::condCalorimeter_const_iterator condCalo = conditions.condCalorimeter().begin();
5320  condCalo != conditions.condCalorimeter().end(); ++condCalo ){
5321 
5322  LogDebug("TriggerMenuXmlParser")
5323  << condCalo->name() << " {"
5324  << " comment: " << condCalo->comment()
5325  << " locked: " << condCalo->locked()
5326  << "}"
5327  << std::endl;
5328 
5329  l1t::CalorimeterCondition condition = (*condCalo);
5330 
5331  parseCalo( condition, chipNr );
5332  }
5333 
5334  LogDebug("TriggerMenuXmlParser") << " ====> condMuon " << std::endl;
5335  for (l1t::ConditionList::condMuon_const_iterator condMu = conditions.condMuon().begin();
5336  condMu != conditions.condMuon().end(); ++condMu ){
5337 
5338  LogDebug("TriggerMenuXmlParser")
5339  << condMu->name() << " {"
5340  << " comment: " << condMu->comment()
5341  << " locked: " << condMu->locked()
5342  << "}"
5343  << std::endl;
5344 
5345  l1t::MuonCondition condition = (*condMu);
5346 
5347  parseMuon( condition, chipNr );
5348  }
5349 
5350  LogDebug("TriggerMenuXmlParser") << " ====> condEnergySums " << std::endl;
5351  for (l1t::ConditionList::condEnergySums_const_iterator condEnergySums = conditions.condEnergySums().begin();
5352  condEnergySums != conditions.condEnergySums().end(); ++condEnergySums ){
5353 
5354  LogDebug("TriggerMenuXmlParser")
5355  << condEnergySums->name() << " {"
5356  << " comment: " << condEnergySums->comment()
5357  << " locked: " << condEnergySums->locked()
5358  << "}"
5359  << std::endl;
5360 
5361  l1t::EnergySumsCondition condition = (*condEnergySums);
5362 
5363  parseEnergySum( condition, chipNr );
5364  }
5365 
5366 
5367  return true;
5368 }
5369 
5370 
5383  unsigned int chipNr) {
5384 
5385 
5386  using namespace tmeventsetup;
5387  using namespace Algorithm;
5388 
5389 
5390  // get alias
5391  std::string algAlias = algorithm.getName();
5392  std::string algName = algorithm.getName();
5393 
5394  if (algAlias == "") {
5395  algAlias = algName;
5396  LogDebug("TriggerMenuXmlParser")
5397  << "\n No alias defined for algorithm. Alias set to algorithm name."
5398  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
5399  << std::endl;
5400  } else {
5401  //LogDebug("TriggerMenuXmlParser")
5402  LogDebug("TriggerMenuXmlParser") << "\n Alias defined for algorithm."
5403  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
5404  << std::endl;
5405  }
5406 
5407  // get the logical expression
5408  std::string logExpression = algorithm.getExpressionInCondition();
5409 
5410  LogDebug("TriggerMenuXmlParser")
5411  << " Logical expression: " << logExpression
5412  << " Chip number: " << chipNr
5413  << std::endl;
5414 
5415  // determine output pin
5416  int outputPin = algorithm.getIndex();
5417 
5418 
5419  //LogTrace("TriggerMenuXmlParser")
5420  LogDebug("TriggerMenuXmlParser") << " Output pin: " << outputPin
5421  << std::endl;
5422 
5423 
5424  // compute the bit number from chip number, output pin and order of the chips
5425  // pin numbering start with 1, bit numbers with 0
5426  int bitNumber = outputPin;// + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
5427 
5428  //LogTrace("TriggerMenuXmlParser")
5429  LogDebug("TriggerMenuXmlParser") << " Bit number: " << bitNumber
5430  << std::endl;
5431 
5432  // create a new algorithm and insert it into algorithm map
5433  L1GtAlgorithm alg(algName, logExpression, bitNumber);
5434  alg.setAlgoChipNumber(static_cast<int>(chipNr));
5435  alg.setAlgoAlias(algAlias);
5436 
5437  if (edm::isDebugEnabled() ) {
5438 
5439  std::ostringstream myCoutStream;
5440  alg.print(myCoutStream);
5441  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
5442 
5443  }
5444 
5445  // insert algorithm into the map
5446  if ( !insertAlgorithmIntoMap(alg)) {
5447  return false;
5448  }
5449 
5450  return true;
5451 
5452 }
5453 
5454 
5455 
5468  unsigned int chipNr) {
5469 
5470  XERCES_CPP_NAMESPACE_USE
5471 
5472 // if (node == 0) {
5473 // LogDebug("TriggerMenuXmlParser")
5474 // << " Node is 0 in " << __PRETTY_FUNCTION__
5475 // << " can not parse the algorithm " << algName
5476 // << std::endl;
5477 // return false;
5478 // }
5479 
5480  // get alias
5481  std::string algAlias = l1t2string( algorithm.name() );
5482  std::string algName = l1t2string( algorithm.name() );
5483 
5484  if (algAlias == "") {
5485  algAlias = algName;
5486  LogDebug("TriggerMenuXmlParser")
5487  << "\n No alias defined for algorithm. Alias set to algorithm name."
5488  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
5489  << std::endl;
5490  } else {
5491  //LogDebug("TriggerMenuXmlParser")
5492  LogDebug("TriggerMenuXmlParser") << "\n Alias defined for algorithm."
5493  << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
5494  << std::endl;
5495  }
5496 
5497  // get the logical expression
5498  std::string logExpression = l1t2string( algorithm.logical_expression() );
5499 
5500  LogDebug("TriggerMenuXmlParser")
5501  << " Logical expression: " << logExpression
5502  << " Chip number: " << chipNr
5503  << std::endl;
5504 
5505  // determine output pin
5506  std::string pinString = l1t2string( algorithm.index() );
5507  int outputPin = 0;
5508 
5509  std::istringstream opStream(pinString);
5510 
5511  if ((opStream >> outputPin).fail()) {
5512  LogDebug("TriggerMenuXmlParser")
5513  << " Unable to convert pin string " << pinString
5514  << " to int for algorithm : " << algName
5515  << std::endl;
5516 
5517  return false;
5518  }
5519 
5520 
5521  //LogTrace("TriggerMenuXmlParser")
5522  LogDebug("TriggerMenuXmlParser") << " Output pin: " << outputPin
5523  << std::endl;
5524 
5525 
5526  // compute the bit number from chip number, output pin and order of the chips
5527  // pin numbering start with 1, bit numbers with 0
5528  int bitNumber = outputPin;// + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
5529 
5530  //LogTrace("TriggerMenuXmlParser")
5531  LogDebug("TriggerMenuXmlParser") << " Bit number: " << bitNumber
5532  << std::endl;
5533 
5534  // create a new algorithm and insert it into algorithm map
5535  L1GtAlgorithm alg(algName, logExpression, bitNumber);
5536  alg.setAlgoChipNumber(static_cast<int>(chipNr));
5537  alg.setAlgoAlias(algAlias);
5538 
5539  if (edm::isDebugEnabled() ) {
5540 
5541  std::ostringstream myCoutStream;
5542  alg.print(myCoutStream);
5543  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
5544 
5545  }
5546 
5547  // insert algorithm into the map
5548  if ( !insertAlgorithmIntoMap(alg)) {
5549 
5550  return false;
5551  }
5552 
5553  return true;
5554 
5555 }
5556 
5557 /*
5558  * parseAlgorithms Parse the algorithms
5559  * NOTE: the algorithms used here are equivalent to "prealgo" from XML file
5560  * for the VERSION_FINAL
5561  * The "VERSION_PROTOTYPE algo" will be phased out later in the XML file
5562  * See L1GlobalTriggerConfig.h (in the attic)
5563  *
5564  * @param parser A reference to the XercesDOMParser to use.
5565  *
5566  * @return "true" if succeeded, "false" if an error occurred.
5567  *
5568  */
5569 
5570 bool l1t::TriggerMenuXmlParser::parseAlgorithms( l1t::AlgorithmList algorithms ) {
5571 
5572  XERCES_CPP_NAMESPACE_USE
5573 
5574  LogTrace("TriggerMenuXmlParser") << "\nParsing algorithms" << std::endl;
5575 
5576  int chipNr = 1;
5577  LogDebug("TriggerMenuXmlParser") << " ====> algorithms " << std::endl;
5578  for( l1t::AlgorithmList::algorithm_const_iterator i = algorithms.algorithm().begin();
5579  i != algorithms.algorithm().end(); ++i ){
5580 
5581  l1t::Algorithm algorithm = (*i);
5582  LogDebug("TriggerMenuXmlParser")
5583  << algorithm.name() << " {"
5584  << " index: " << algorithm.index()
5585  << " equation: " << algorithm.logical_expression()
5586  << " comment: " << algorithm.comment()
5587  << " locked: " << algorithm.locked()
5588  << "}"
5589  << std::endl;
5590 
5591 
5592  workAlgorithm( algorithm, chipNr );
5593  }
5594 
5595 
5596  return true;
5597 }
5598 
5608 /*
5609 bool l1t::TriggerMenuXmlParser::workTechTrigger(XERCES_CPP_NAMESPACE::DOMNode* node,
5610  const std::string& algName) {
5611 
5612  XERCES_CPP_NAMESPACE_USE
5613 
5614  if (node == 0) {
5615  LogDebug("TriggerMenuXmlParser")
5616  << " Node is 0 in " << __PRETTY_FUNCTION__
5617  << " can not parse the technical trigger " << algName
5618  << std::endl;
5619  return false;
5620  }
5621 
5622  // get the logical expression from the node
5623  std::string logExpression = getXMLTextValue(node);
5624 
5625  //LogTrace("TriggerMenuXmlParser")
5626  //<< " Logical expression: " << logExpression
5627  //<< std::endl;
5628 
5629  // determine bit number (use output pin tag)
5630  DOMNode* pinNode = findXMLChild(node->getFirstChild(), m_xmlTagOutput);
5631  std::string pinString;
5632  int outputPin = 0;
5633 
5634  pinNode = node->getFirstChild();
5635  if ( (pinNode = findXMLChild(pinNode, m_xmlTagOutputPin) ) != 0) {
5636  pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
5637 
5638  // convert pinString to integer
5639  std::istringstream opStream(pinString);
5640 
5641  if ((opStream >> outputPin).fail()) {
5642  LogDebug("TriggerMenuXmlParser")
5643  << " Unable to convert pin string " << pinString
5644  << " to int for technical trigger : " << algName
5645  << std::endl;
5646 
5647  return false;
5648  }
5649 
5650  }
5651 
5652  if (pinNode == 0) {
5653  LogTrace("TriggerMenuXmlParser")
5654  << " Warning: No pin number found for technical trigger: "
5655  << algName << std::endl;
5656 
5657  return false;
5658  }
5659 
5660  // set the bit number
5661  int bitNumber = outputPin;
5662 
5663  //LogTrace("TriggerMenuXmlParser")
5664  //<< " Bit number: " << bitNumber
5665  //<< std::endl;
5666 
5667  // create a new technical trigger and insert it into technical trigger map
5668  // alias set automatically to name
5669  L1GtAlgorithm alg(algName, logExpression, bitNumber);
5670  alg.setAlgoAlias(algName);
5671 
5672  if (edm::isDebugEnabled() ) {
5673 
5674  std::ostringstream myCoutStream;
5675  alg.print(myCoutStream);
5676  LogTrace("TriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
5677 
5678  }
5679 
5680  // insert technical trigger into the map
5681  if ( !insertTechTriggerIntoMap(alg)) {
5682 
5683  return false;
5684  }
5685 
5686  return true;
5687 
5688 }
5689 */
5690 /*
5691  * parseTechTriggers Parse the technical triggers
5692  *
5693  * @param parser A reference to the XercesDOMParser to use.
5694  *
5695  * @return "true" if succeeded, "false" if an error occurred.
5696  *
5697  */
5698 /*
5699 bool l1t::TriggerMenuXmlParser::parseTechTriggers(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
5700 
5701  XERCES_CPP_NAMESPACE_USE
5702 
5703  //LogTrace("TriggerMenuXmlParser") << "\nParsing technical triggers" << std::endl;
5704 
5705  DOMNode* doc = parser->getDocument();
5706  DOMNode* node = doc->getFirstChild();
5707 
5708  DOMNode* algNode = node->getFirstChild();
5709  if (algNode == 0) {
5710  edm::LogError("TriggerMenuXmlParser")
5711  << " Error: No child found for " << m_xmlTagDef << std::endl;
5712  return false;
5713  }
5714 
5715  algNode = findXMLChild(algNode, m_xmlTagTechTriggers);
5716  if (algNode == 0) {
5717  edm::LogError("TriggerMenuXmlParser") << " Error: No <"
5718  << m_xmlTagTechTriggers << "> child found."
5719  << std::endl;
5720  return false;
5721  }
5722 
5723  // walk through technical triggers
5724  DOMNode* algNameNode = algNode->getFirstChild();
5725  std::string algNameNodeName;
5726  algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
5727 
5728  while (algNameNode != 0) {
5729  //LogTrace("TriggerMenuXmlParser")
5730  //<< " Found an technical trigger with name: " << algNameNodeName
5731  //<< std::endl;
5732 
5733  if ( !workTechTrigger(algNameNode, algNameNodeName)) {
5734  return false;
5735  }
5736 
5737  algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true,
5738  &algNameNodeName);
5739 
5740  }
5741 
5742  return true;
5743 }
5744 */
5745 
5754 //bool TriggerMenuXmlParser::workXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
5755 bool l1t::TriggerMenuXmlParser::workXML( std::auto_ptr<l1t::L1TriggerMenu> tm ) {
5756 
5757  XERCES_CPP_NAMESPACE_USE
5758 
5759 
5760  // clear possible old maps
5761  clearMaps();
5762 
5763  l1t::Meta meta = tm->meta();
5764  l1t::ConditionList conditions = tm->conditions();
5765  l1t::AlgorithmList algorithms = tm->algorithms();
5766 
5767 
5768  if ( !parseId( meta ) ) {
5769  clearMaps();
5770  return false;
5771  }
5772 
5773  if ( !parseConditions( conditions ) ) {
5774  clearMaps();
5775  return false;
5776  }
5777 
5778  if ( !parseAlgorithms( algorithms ) ) {
5779  clearMaps();
5780  return false;
5781  }
5782 
5783 
5784 // if ( !parseTechTriggers(parser) ) {
5785 // clearMaps();
5786 // return false;
5787 // }
5788 
5789  return true;
5790 
5791 }
5792 
5793 
5794 // static class members
5795 
#define LogDebug(id)
type
Definition: HCALResponse.h:21
bool isDebugEnabled()
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< double, double > > phiBins
tuple ret
prodAgent to be discontinued
bool workXML(std::auto_ptr< l1t::L1TriggerMenu > tm)
parse an algorithm and insert it into algorithm map.
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 &)
Definition: L1GtObject.h:39
bool parseCaloV2(tmeventsetup::esCondition condCalo, unsigned int chipNr=0, const bool corrFlag=false)
parse a calorimeter condition
void setVecEnergySumTemplate(const std::vector< std::vector< EnergySumTemplate > > &)
bool parseEnergySum(l1t::EnergySumsCondition condEnergySums, unsigned int chipNr=0, const bool corrFlag=false)
parse an &quot;energy sum&quot; condition
void setCond0Index(const int &)
void setAlgoAlias(const std::string &algoAliasValue)
Definition: L1GtAlgorithm.h:72
std::string l1tDateTime2string(l1t::DateTime)
virtual void print(std::ostream &myCout) const
print the condition
Definition: MuonTemplate.cc:98
bool parseConditions(l1t::ConditionList conditions)
parse all conditions
bool parseVmeXML(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
parse the vme xml file
Definition: L1GtObject.h:36
virtual void print(std::ostream &myCout) const
print condition
void setCondType(const l1t::GtConditionType &cType)
Definition: GtCondition.h:84
unsigned long long deltaEtaRange
Definition: CaloTemplate.h:83
void setCorrelationParameter(const CorrelationParameter &corrParameter)
const std::string algoName() const
get / set algorithm name
Definition: L1GtAlgorithm.h:56
unsigned long long deltaPhiRange
Definition: CaloTemplate.h:85
void setGtAlgorithmMap(const AlgorithmMap &)
bool parseCalo(l1t::CalorimeterCondition condCalo, unsigned int chipNr=0, const bool corrFlag=false)
parse a calorimeter condition
void setCondGEq(const bool &cGEq)
Definition: GtCondition.h:106
void setGtOrderConditionChip(const std::vector< int > &)
bool parseMuonV2(tmeventsetup::esCondition condMu, unsigned int chipNr=0, const bool corrFlag=false)
parse a muon condition
virtual void print(std::ostream &myCout) const
print the condition
int ii
Definition: cuy.py:588
int l1tstr2int(const std::string data)
void setGtTriggerMenuImplementation(const std::string &)
virtual void print(std::ostream &myCout) const
print the condition
std::string const & algoAlias() const
get / set algorithm alias
Definition: L1GtAlgorithm.h:67
bool insertAlgorithmIntoMap(const L1GtAlgorithm &alg)
insert an algorithm into algorithm map
bool parseId(std::auto_ptr< l1t::L1TriggerMenu > tm)
parse all parse all identification attributes (trigger menu names, scale DB key, etc) ...
bool parseExternalV2(tmeventsetup::esCondition condExt, unsigned int chipNr=0)
parse an External condition
void setAlgoChipNumber(const int algoChipNumberValue)
void setGtNumberPhysTriggers(const unsigned int &)
Definition: L1GtObject.h:38
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:98
std::vector< std::pair< double, double > > etBins
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 setExternalChannel(unsigned int extCh)
set functions
void setGtTriggerMenuName(const std::string &)
void setGtScaleDbKey(const std::string &)
int getBitFromNode(XERCES_CPP_NAMESPACE::DOMNode *node)
get bit from a bit node
bool parseEnergySumCorr(const tmeventsetup::esObject *corrESum, unsigned int chipNr=0)
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 &)
void setCond1Category(const l1t::GtConditionCategory &)
XMLCh * transcode(const T &fInput)
bool parseMuon(l1t::MuonCondition condMu, unsigned int chipNr=0, const bool corrFlag=false)
parse a muon condition
bool parseMuonCorr(const tmeventsetup::esObject *condMu, unsigned int chipNr=0)
std::string getXMLAttribute(const XERCES_CPP_NAMESPACE::DOMNode *node, const std::string &name)
get a named attribute for an xml node as string
void setConditionParameter(const std::vector< ObjectParameter > &objParameter, const CorrelationParameter &corrParameter)
set functions
Definition: CaloTemplate.cc:87
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
bool parseScales(std::map< std::string, tmeventsetup::esScale > scaleMap)
parse scales
#define LogTrace(id)
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
bool getXMLHexTextValue128(const std::string &childName, boost::uint64_t &dstL, boost::uint64_t &dstH)
typedef for a single object template
bool parseCaloCorr(const tmeventsetup::esObject *corrCalo, unsigned int chipNr=0)
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)
insert a technical trigger into technical trigger map
const std::string & condName() const
get / set condition name
Definition: GtCondition.h:57
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 setCond0Category(const l1t::GtConditionCategory &)
void setGtTriggerMenuDescription(const std::string &)
bool xmlFile(const std::string fParam)
void setCondChipNr(const int &cChipNr)
Definition: GtCondition.h:117
void setVecExternalTemplate(const std::vector< std::vector< ExternalTemplate > > &)
void setGtPinsOnConditionChip(const unsigned int &)
void setConditionParameter(const std::vector< ObjectParameter > &objParameter, const CorrelationParameter &corrParameter)
set functions
Definition: MuonTemplate.cc:88
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
Definition: L1GtObject.h:37
typedef for correlation parameters
Definition: CaloTemplate.h:81
unsigned long long deltaEtaRange
Definition: MuonTemplate.h:96
void setObjectType(const std::vector< L1GtObject > &objType)
Definition: GtCondition.h:95
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 > > &)
virtual ~TriggerMenuXmlParser()
destructor
std::vector< std::pair< double, double > > etaBins
void setCorEnergySumTemplate(const std::vector< std::vector< EnergySumTemplate > > &)
void setGtNumberConditionChips(const unsigned int &)
void setGtAlgorithmImplementation(const std::string &)
void setCondRelativeBx(const int &cRelativeBx)
Definition: GtCondition.h:128
void cleanupXML(XERCES_CPP_NAMESPACE::XercesDOMParser *parser)
shutdown the xml utils and deallocate parser and error handler
tuple cout
Definition: gather_cfg.py:145
XERCES_CPP_NAMESPACE::XercesDOMParser * initXML(const std::string &xmlFile)
init xml system
bool parseAlgorithmV2(tmeventsetup::esAlgorithm algorithm, unsigned int chipNr=0)
parse all algorithms
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 parseEnergySumV2(tmeventsetup::esCondition condEnergySums, unsigned int chipNr=0, const bool corrFlag=false)
parse an &quot;energy sum&quot; condition
bool parseAlgorithms(l1t::AlgorithmList algorithms)
parse all algorithms
void setCorCaloTemplate(const std::vector< std::vector< CaloTemplate > > &)
typedef for correlation parameters
virtual void print(std::ostream &myCout) const
print the condition
Definition: CaloTemplate.cc:97
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 setGtTriggerMenuDate(const std::string &)
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
tuple size
Write out results.
void parseXmlFileV2(const std::string &defXmlFile)
void setConditionParameter(const std::vector< ObjectParameter > &)
set functions
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
void setCond1Index(const int &)
bool parseCorrelationV2(tmeventsetup::esCondition corrCond, unsigned int chipNr=0)
parse a correlation condition