00001
00017
00018 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtTriggerMenuXmlParser.h"
00019
00020
00021 #include <string>
00022 #include <vector>
00023
00024 #include <iostream>
00025 #include <fstream>
00026 #include <iomanip>
00027
00028 #include <boost/cstdint.hpp>
00029
00030
00031
00032 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtXmlParserTags.h"
00033
00034 #include "CondFormats/L1TObjects/interface/L1GtCondition.h"
00035 #include "CondFormats/L1TObjects/interface/L1GtAlgorithm.h"
00036
00037 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00038 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00039
00040
00041 L1GtTriggerMenuXmlParser::L1GtTriggerMenuXmlParser() :
00042 L1GtXmlParserTags(), m_xmlErrHandler(0), m_triggerMenuInterface("NULL"),
00043 m_triggerMenuName("NULL"), m_triggerMenuImplementation("NULL"), m_scaleDbKey("NULL")
00044
00045 {
00046
00047
00048
00049
00050
00051 }
00052
00053
00054 L1GtTriggerMenuXmlParser::~L1GtTriggerMenuXmlParser() {
00055
00056 clearMaps();
00057
00058 }
00059
00060
00061 void L1GtTriggerMenuXmlParser::setGtNumberConditionChips(
00062 const unsigned int& numberConditionChipsValue) {
00063
00064 m_numberConditionChips = numberConditionChipsValue;
00065
00066 }
00067
00068
00069 void L1GtTriggerMenuXmlParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
00070
00071 m_pinsOnConditionChip = pinsOnConditionChipValue;
00072
00073 }
00074
00075
00076
00077 void L1GtTriggerMenuXmlParser::setGtOrderConditionChip(
00078 const std::vector<int>& orderConditionChipValue) {
00079
00080 m_orderConditionChip = orderConditionChipValue;
00081
00082 }
00083
00084
00085 void L1GtTriggerMenuXmlParser::setGtNumberPhysTriggers(
00086 const unsigned int& numberPhysTriggersValue) {
00087
00088 m_numberPhysTriggers = numberPhysTriggersValue;
00089
00090 }
00091
00092
00093 void L1GtTriggerMenuXmlParser::setGtNumberTechTriggers(
00094 const unsigned int& numberTechTriggersValue) {
00095
00096 m_numberTechTriggers = numberTechTriggersValue;
00097
00098 }
00099
00100
00101 void L1GtTriggerMenuXmlParser::setGtNumberL1JetCounts(const unsigned int& numberL1JetCountsValue) {
00102
00103 m_numberL1JetCounts = numberL1JetCountsValue;
00104
00105 }
00106
00107
00108
00109 void L1GtTriggerMenuXmlParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) {
00110 m_conditionMap = condMap;
00111 }
00112
00113
00114 void L1GtTriggerMenuXmlParser::setGtTriggerMenuInterface(const std::string& menuInterface) {
00115 m_triggerMenuInterface = menuInterface;
00116 }
00117
00118 void L1GtTriggerMenuXmlParser::setGtTriggerMenuName(const std::string& menuName) {
00119 m_triggerMenuName = menuName;
00120 }
00121
00122 void L1GtTriggerMenuXmlParser::setGtTriggerMenuImplementation(const std::string& menuImplementation) {
00123 m_triggerMenuImplementation = menuImplementation;
00124 }
00125
00126
00127 void L1GtTriggerMenuXmlParser::setGtScaleDbKey(const std::string& scaleKey) {
00128 m_scaleDbKey = scaleKey;
00129 }
00130
00131
00132 void L1GtTriggerMenuXmlParser::setVecMuonTemplate(
00133 const std::vector<std::vector<L1GtMuonTemplate> >& vecMuonTempl) {
00134
00135 m_vecMuonTemplate = vecMuonTempl;
00136 }
00137
00138 void L1GtTriggerMenuXmlParser::setVecCaloTemplate(
00139 const std::vector<std::vector<L1GtCaloTemplate> >& vecCaloTempl) {
00140
00141 m_vecCaloTemplate = vecCaloTempl;
00142 }
00143
00144 void L1GtTriggerMenuXmlParser::setVecEnergySumTemplate(
00145 const std::vector<std::vector<L1GtEnergySumTemplate> >& vecEnergySumTempl) {
00146
00147 m_vecEnergySumTemplate = vecEnergySumTempl;
00148 }
00149
00150 void L1GtTriggerMenuXmlParser::setVecJetCountsTemplate(
00151 const std::vector<std::vector<L1GtJetCountsTemplate> >& vecJetCountsTempl) {
00152
00153 m_vecJetCountsTemplate = vecJetCountsTempl;
00154 }
00155
00156 void L1GtTriggerMenuXmlParser::setVecCastorTemplate(
00157 const std::vector<std::vector<L1GtCastorTemplate> >& vecCastorTempl) {
00158
00159 m_vecCastorTemplate = vecCastorTempl;
00160 }
00161
00162 void L1GtTriggerMenuXmlParser::setVecHfBitCountsTemplate(
00163 const std::vector<std::vector<L1GtHfBitCountsTemplate> >& vecHfBitCountsTempl) {
00164
00165 m_vecHfBitCountsTemplate = vecHfBitCountsTempl;
00166 }
00167
00168 void L1GtTriggerMenuXmlParser::setVecHfRingEtSumsTemplate(
00169 const std::vector<std::vector<L1GtHfRingEtSumsTemplate> >& vecHfRingEtSumsTempl) {
00170
00171 m_vecHfRingEtSumsTemplate = vecHfRingEtSumsTempl;
00172 }
00173
00174 void L1GtTriggerMenuXmlParser::setVecBptxTemplate(
00175 const std::vector<std::vector<L1GtBptxTemplate> >& vecBptxTempl) {
00176
00177 m_vecBptxTemplate = vecBptxTempl;
00178 }
00179
00180 void L1GtTriggerMenuXmlParser::setVecExternalTemplate(
00181 const std::vector<std::vector<L1GtExternalTemplate> >& vecExternalTempl) {
00182
00183 m_vecExternalTemplate = vecExternalTempl;
00184 }
00185
00186 void L1GtTriggerMenuXmlParser::setVecCorrelationTemplate(
00187 const std::vector<std::vector<L1GtCorrelationTemplate> >& vecCorrelationTempl) {
00188
00189 m_vecCorrelationTemplate = vecCorrelationTempl;
00190 }
00191
00192
00193
00194 void L1GtTriggerMenuXmlParser::setCorMuonTemplate(
00195 const std::vector<std::vector<L1GtMuonTemplate> >& corMuonTempl) {
00196
00197 m_corMuonTemplate = corMuonTempl;
00198 }
00199
00200 void L1GtTriggerMenuXmlParser::setCorCaloTemplate(
00201 const std::vector<std::vector<L1GtCaloTemplate> >& corCaloTempl) {
00202
00203 m_corCaloTemplate = corCaloTempl;
00204 }
00205
00206 void L1GtTriggerMenuXmlParser::setCorEnergySumTemplate(
00207 const std::vector<std::vector<L1GtEnergySumTemplate> >& corEnergySumTempl) {
00208
00209 m_corEnergySumTemplate = corEnergySumTempl;
00210 }
00211
00212
00213
00214
00215
00216 void L1GtTriggerMenuXmlParser::setGtAlgorithmMap(const AlgorithmMap& algoMap) {
00217 m_algorithmMap = algoMap;
00218 }
00219
00220
00221 void L1GtTriggerMenuXmlParser::setGtAlgorithmAliasMap(const AlgorithmMap& algoMap) {
00222 m_algorithmAliasMap = algoMap;
00223 }
00224
00225
00226 void L1GtTriggerMenuXmlParser::setGtTechnicalTriggerMap(const AlgorithmMap& ttMap) {
00227 m_technicalTriggerMap = ttMap;
00228 }
00229
00230
00231
00232
00233
00234 void L1GtTriggerMenuXmlParser::parseXmlFile(const std::string& defXmlFile,
00235 const std::string& vmeXmlFile) {
00236
00237 XERCES_CPP_NAMESPACE_USE
00238
00239
00240
00241 m_conditionMap.resize(m_numberConditionChips);
00242
00243 m_vecMuonTemplate.resize(m_numberConditionChips);
00244 m_vecCaloTemplate.resize(m_numberConditionChips);
00245 m_vecEnergySumTemplate.resize(m_numberConditionChips);
00246 m_vecJetCountsTemplate.resize(m_numberConditionChips);
00247 m_vecCastorTemplate.resize(m_numberConditionChips);
00248 m_vecHfBitCountsTemplate.resize(m_numberConditionChips);
00249 m_vecHfRingEtSumsTemplate.resize(m_numberConditionChips);
00250 m_vecBptxTemplate.resize(m_numberConditionChips);
00251 m_vecExternalTemplate.resize(m_numberConditionChips);
00252
00253 m_vecCorrelationTemplate.resize(m_numberConditionChips);
00254 m_corMuonTemplate.resize(m_numberConditionChips);
00255 m_corCaloTemplate.resize(m_numberConditionChips);
00256 m_corEnergySumTemplate.resize(m_numberConditionChips);
00257
00258
00259
00260
00261
00262 m_triggerMenuName = defXmlFile;
00263 size_t xmlPos = m_triggerMenuName.find_last_of("/");
00264 m_triggerMenuName.erase(m_triggerMenuName.begin(), m_triggerMenuName.begin()
00265 + xmlPos + 1);
00266
00267 xmlPos = m_triggerMenuName.find_last_of(".");
00268 m_triggerMenuName.erase(m_triggerMenuName.begin() + xmlPos, m_triggerMenuName.end());
00269
00270
00271 m_xmlErrHandler = 0;
00272
00273 XercesDOMParser* parser;
00274
00275 LogTrace("L1GtTriggerMenuXmlParser") << "\nOpening XML-File: \n " << defXmlFile << std::endl;
00276
00277 if ((parser = initXML(defXmlFile)) != 0) {
00278 workXML(parser);
00279 }
00280 cleanupXML(parser);
00281
00282 }
00283
00284
00285
00286 void L1GtTriggerMenuXmlParser::setGtTriggerMenuInterfaceDate(const std::string& val) {
00287
00288 m_triggerMenuInterfaceDate = val;
00289
00290 }
00291
00292 void L1GtTriggerMenuXmlParser::setGtTriggerMenuInterfaceAuthor(const std::string& val) {
00293
00294 m_triggerMenuInterfaceAuthor = val;
00295
00296 }
00297
00298 void L1GtTriggerMenuXmlParser::setGtTriggerMenuInterfaceDescription(const std::string& val) {
00299
00300 m_triggerMenuInterfaceDescription = val;
00301
00302 }
00303
00304
00305 void L1GtTriggerMenuXmlParser::setGtTriggerMenuDate(const std::string& val) {
00306
00307 m_triggerMenuDate = val;
00308
00309 }
00310
00311 void L1GtTriggerMenuXmlParser::setGtTriggerMenuAuthor(const std::string& val) {
00312
00313 m_triggerMenuAuthor = val;
00314
00315 }
00316
00317 void L1GtTriggerMenuXmlParser::setGtTriggerMenuDescription(const std::string& val) {
00318
00319 m_triggerMenuDescription = val;
00320
00321 }
00322
00323 void L1GtTriggerMenuXmlParser::setGtAlgorithmImplementation(const std::string& val) {
00324
00325 m_algorithmImplementation = val;
00326
00327 }
00328
00329
00330
00331
00332
00342 XERCES_CPP_NAMESPACE::XercesDOMParser* L1GtTriggerMenuXmlParser::initXML(const std::string &xmlFile) {
00343
00344 XERCES_CPP_NAMESPACE_USE
00345
00346
00347 try {
00348 XMLPlatformUtils::Initialize();
00349 }
00350 catch (const XMLException& toCatch) {
00351 char* message = XMLString::transcode(toCatch.getMessage());
00352
00353 edm::LogError("L1GtTriggerMenuXmlParser")
00354 << "Error during Xerces-c initialization! :"
00355 << message << std::endl;
00356
00357 XMLString::release(&message);
00358 return 0;
00359 }
00360
00361 XercesDOMParser* parser = new XercesDOMParser();
00362 parser->setValidationScheme(XercesDOMParser::Val_Always);
00363 parser->setDoNamespaces(false);
00364
00365 if (m_xmlErrHandler == 0) {
00366 m_xmlErrHandler = (ErrorHandler*) new HandlerBase();
00367 }
00368 else {
00369
00370 }
00371 parser->setErrorHandler(m_xmlErrHandler);
00372
00373
00374 try {
00375 parser->parse(xmlFile.c_str());
00376 }
00377 catch(const XMLException &toCatch) {
00378 char* message = XMLString::transcode(toCatch.getMessage());
00379
00380 edm::LogError("L1GtTriggerMenuXmlParser")
00381 << "Exception while parsing XML: \n"
00382 << message << std::endl;
00383
00384 XMLString::release(&message);
00385 delete parser;
00386 delete m_xmlErrHandler;
00387 m_xmlErrHandler = 0;
00388 return 0;
00389 }
00390 catch (const DOMException &toCatch) {
00391 char *message = XMLString::transcode(toCatch.msg);
00392
00393 edm::LogError("L1GtTriggerMenuXmlParser")
00394 << "DOM-Exception while parsing XML: \n"
00395 << message << std::endl;
00396
00397 XMLString::release(&message);
00398 delete parser;
00399 delete m_xmlErrHandler;
00400 m_xmlErrHandler = 0;
00401 return 0;
00402 }
00403 catch (...) {
00404
00405 edm::LogError("L1GtTriggerMenuXmlParser")
00406 << "Unexpected Exception while parsing XML!"
00407 << std::endl;
00408
00409 delete parser;
00410 delete m_xmlErrHandler;
00411 m_xmlErrHandler = 0;
00412 return 0;
00413 }
00414
00415 return parser;
00416 }
00417
00418
00419 XERCES_CPP_NAMESPACE::DOMNode* L1GtTriggerMenuXmlParser::findXMLChild(
00420 XERCES_CPP_NAMESPACE::DOMNode* startChild, const std::string& tagName, bool beginOnly,
00421 std::string* rest) {
00422
00423 XERCES_CPP_NAMESPACE_USE
00424
00425 char* nodeName = 0;
00426
00427 DOMNode *n1 = startChild;
00428 if (n1 == 0) {
00429 return 0;
00430 }
00431
00432 if ( !tagName.empty() ) {
00433 nodeName = XMLString::transcode(n1->getNodeName());
00434
00435 if (!beginOnly) {
00436
00437 while (XMLString::compareIString(nodeName, tagName.c_str())) {
00438
00439 XMLString::release(&nodeName);
00440 n1 = n1->getNextSibling();
00441 if (n1 == 0) {
00442 break;
00443 }
00444
00445 nodeName = XMLString::transcode(n1->getNodeName());
00446 }
00447 }
00448 else {
00449
00450 while (XMLString::compareNIString(nodeName, tagName.c_str(), tagName.length())) {
00451 XMLString::release(&nodeName);
00452 n1 = n1->getNextSibling();
00453 if (n1 == 0) {
00454 break;
00455 }
00456
00457 nodeName = XMLString::transcode(n1->getNodeName());
00458 }
00459 if (n1 != 0 && rest != 0) {
00460 *rest = std::string(nodeName).substr(tagName.length(), strlen(nodeName) - tagName.length());
00461 }
00462 }
00463 }
00464 else {
00465 while (n1->getNodeType() != DOMNode::ELEMENT_NODE) {
00466 n1 = n1->getNextSibling();
00467 if (n1 == 0) {
00468 break;
00469 }
00470
00471 }
00472 if (n1 != 0 && rest != 0) {
00473 nodeName = XMLString::transcode(n1->getNodeName());
00474 *rest = std::string(nodeName);
00475 }
00476 }
00477
00478 XMLString::release(&nodeName);
00479
00480 return n1;
00481
00482 }
00483
00493 std::string L1GtTriggerMenuXmlParser::getXMLAttribute(const XERCES_CPP_NAMESPACE::DOMNode* node,
00494 const std::string& name) {
00495
00496 XERCES_CPP_NAMESPACE_USE
00497
00498 std::string ret;
00499
00500
00501 DOMNamedNodeMap* attributes = node->getAttributes();
00502 if (attributes == 0) {
00503 return ret;
00504 }
00505
00506
00507 XMLCh* attrName = XMLString::transcode(name.c_str());
00508 DOMNode* attribNode = attributes->getNamedItem(attrName);
00509
00510 XMLString::release(&attrName);
00511 if (attribNode == 0) {
00512 return ret;
00513 }
00514
00515 char* retCstr = XMLString::transcode(attribNode->getNodeValue());
00516 ret = retCstr;
00517 XMLString::release(&retCstr);
00518
00519 return ret;
00520 }
00521
00530 std::string L1GtTriggerMenuXmlParser::getXMLTextValue(XERCES_CPP_NAMESPACE::DOMNode* node) {
00531
00532 XERCES_CPP_NAMESPACE_USE
00533
00534 std::string ret;
00535
00536 DOMNode* n1 = node;
00537 if (n1 == 0) {
00538 return ret;
00539 }
00540
00541 const XMLCh* retXmlCh = n1->getTextContent();
00542 if (retXmlCh == 0) {
00543 return ret;
00544 }
00545
00546 char* retCstr = XMLString::transcode(retXmlCh);
00547 XMLString::trim(retCstr);
00548
00549 ret = retCstr;
00550 XMLString::release(&retCstr);
00551
00552 return ret;
00553 }
00554
00565 bool L1GtTriggerMenuXmlParser::hexString2UInt128(const std::string& hexString,
00566 boost::uint64_t& dstL, boost::uint64_t& dstH) {
00567
00568
00569 static const std::string valid_hex_start("0123456789ABCDEFabcdef");
00570
00571
00572 static const std::string valid_hex_end("0123456789ABCDEFabcdef");
00573
00574 std::string tempStr = hexString;
00575
00576
00577 unsigned int hexStart = tempStr.find_first_of(valid_hex_start);
00578 unsigned int hexEnd = tempStr.find_first_not_of(valid_hex_end, hexStart);
00579
00580 if (hexStart == hexEnd) {
00581
00582 LogDebug("L1GtTriggerMenuXmlParser") << "No hex value found in: " << tempStr << std::endl;
00583
00584 return false;
00585 }
00586
00587 tempStr = tempStr.substr(hexStart, hexEnd - hexStart);
00588
00589 if (tempStr.empty() ) {
00590
00591 LogDebug("L1GtTriggerMenuXmlParser") << "Empty value in " << __PRETTY_FUNCTION__
00592 << std::endl;
00593
00594 return false;
00595 }
00596
00597
00598 std::string tempStrH, tempStrL;
00599
00600 if (tempStr.length() > 16) {
00601 tempStrL = tempStr.substr(tempStr.length()-16, 16);
00602 tempStrH = tempStr.substr(0, tempStr.length()-16);
00603 }
00604 else {
00605 tempStrL = tempStr;
00606 tempStrH = "0";
00607 }
00608
00609
00610 char* endPtr = (char*) tempStrL.c_str();
00611 boost::uint64_t tempUIntL = strtoull(tempStrL.c_str(), &endPtr, 16);
00612
00613 if (*endPtr != 0) {
00614
00615 LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex."
00616 << std::endl;
00617
00618 return false;
00619 }
00620
00621
00622 endPtr = (char*) tempStrH.c_str();
00623 boost::uint64_t tempUIntH = strtoull(tempStrH.c_str(), &endPtr, 16);
00624
00625 if (*endPtr != 0) {
00626
00627 LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex."
00628 << std::endl;
00629
00630 return false;
00631 }
00632
00633 dstL = tempUIntL;
00634 dstH = tempUIntH;
00635
00636 return true;
00637 }
00638
00649 bool L1GtTriggerMenuXmlParser::getXMLHexTextValue128(XERCES_CPP_NAMESPACE::DOMNode* node,
00650 boost::uint64_t& dstL, boost::uint64_t& dstH) {
00651
00652 if (node == 0) {
00653
00654 LogDebug("L1GtTriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
00655
00656 return false;
00657 }
00658
00659 boost::uint64_t tempUIntH, tempUIntL;
00660
00661 std::string tempStr = getXMLTextValue(node);
00662 if ( !hexString2UInt128(tempStr, tempUIntL, tempUIntH) ) {
00663 return false;
00664 }
00665
00666 dstL = tempUIntL;
00667 dstH = tempUIntH;
00668
00669 return true;
00670 }
00671
00683 bool L1GtTriggerMenuXmlParser::getXMLHexTextValue(XERCES_CPP_NAMESPACE::DOMNode* node,
00684 boost::uint64_t& dst) {
00685
00686 boost::uint64_t dummyH;
00687 boost::uint64_t tempUInt;
00688
00689 if ( !getXMLHexTextValue128(node, tempUInt, dummyH) ) {
00690 return false;
00691 }
00692
00693 if (dummyH != 0) {
00694 edm::LogError("L1GtTriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
00695 return false;
00696 }
00697
00698 dst = tempUInt;
00699
00700 return true;
00701 }
00702
00714 bool L1GtTriggerMenuXmlParser::countConditionChildMaxBits(XERCES_CPP_NAMESPACE::DOMNode* node,
00715 const std::string& childName, unsigned int& dst) {
00716
00717 XERCES_CPP_NAMESPACE_USE
00718
00719
00720 if (node == 0) {
00721
00722 LogDebug("L1GtTriggerMenuXmlParser")
00723 << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
00724
00725 return false;
00726 }
00727
00728 DOMNode* n1 = findXMLChild(node->getFirstChild(), childName);
00729
00730 if (n1 == 0) {
00731
00732 LogDebug("L1GtTriggerMenuXmlParser") << "Child of condition not found ( " << childName
00733 << ")" << std::endl;
00734
00735 return false;
00736 }
00737
00738 DOMNode* n2 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
00739
00740 if (n2 == 0) {
00741
00742 LogDebug("L1GtTriggerMenuXmlParser") << "No value tag found for child " << childName
00743 << " in " << __PRETTY_FUNCTION__ << std::endl;
00744
00745 return false;
00746 }
00747
00748
00749 std::string maxString = getXMLAttribute(n1, m_xmlAttrMax);
00750
00751 if (maxString.empty() ) {
00752 maxString = getXMLAttribute(n2, m_xmlAttrMax);
00753
00754 if (maxString.empty() ) {
00755
00756 LogDebug("L1GtTriggerMenuXmlParser") << "No Max value found for " << childName
00757 << std::endl;
00758
00759 return false;
00760 }
00761 }
00762
00763
00764
00765 boost::uint64_t maxBitsL, maxBitsH;
00766 if ( !hexString2UInt128(maxString, maxBitsL, maxBitsH) ) {
00767 return false;
00768 }
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779 unsigned int counter = 0;
00780
00781 while (maxBitsL != 0) {
00782
00783 if ( (maxBitsL & 1) == 0) {
00784
00785 edm::LogError("L1GtTriggerMenuXmlParser")
00786 << " Confused by not continous set bits for max value " << maxString
00787 << "(child=" << childName << ")" << std::endl;
00788
00789 return false;
00790 }
00791
00792 maxBitsL >>= 1;
00793 counter++;
00794 }
00795
00796 if ( (maxBitsH != 0) && (counter != 64)) {
00797
00798 edm::LogError("L1GtTriggerMenuXmlParser")
00799 << " Confused by not continous set bits for max value " << maxString << "(child="
00800 << childName << ")" << std::endl;
00801
00802 return false;
00803 }
00804
00805 while (maxBitsH != 0) {
00806
00807 if ( (maxBitsH & 1) == 0) {
00808
00809 edm::LogError("L1GtTriggerMenuXmlParser")
00810 << " Confused by not continous set bits for max value " << maxString
00811 << "(child=" << childName << ")" << std::endl;
00812
00813 return false;
00814 }
00815
00816 maxBitsH >>= 1;
00817 counter++;
00818 }
00819
00820 dst = counter;
00821 return true;
00822
00823 }
00824
00836 bool L1GtTriggerMenuXmlParser::getConditionChildValues(XERCES_CPP_NAMESPACE::DOMNode* node,
00837 const std::string& childName, unsigned int num, std::vector<boost::uint64_t>& dst) {
00838
00839 XERCES_CPP_NAMESPACE_USE
00840
00841 if (node == 0) {
00842
00843 LogDebug("L1GtTriggerMenuXmlParser")
00844 << "node == 0 in " << __PRETTY_FUNCTION__
00845 << std::endl;
00846
00847 return false;
00848 }
00849
00850 DOMNode* n1 = findXMLChild(node->getFirstChild(), childName);
00851
00852
00853 if (n1 == 0) {
00854
00855 LogDebug("L1GtTriggerMenuXmlParser") << "Child of condition not found ( " << childName
00856 << ")" << std::endl;
00857
00858 return false;
00859 }
00860
00861
00862 if (num == 0) {
00863 return true;
00864 }
00865
00866
00867 dst.reserve(num);
00868
00869
00870 n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
00871 for (unsigned int i = 0; i < num; i++) {
00872 if (n1 == 0) {
00873
00874 LogDebug("L1GtTriggerMenuXmlParser") << "Not enough values in condition child ( "
00875 << childName << ")" << std::endl;
00876
00877 return false;
00878 }
00879
00880 if ( !getXMLHexTextValue(n1, dst[i]) ) {
00881
00882 edm::LogError("L1GtTriggerMenuXmlParser") << "Error converting condition child ( "
00883 << childName << ") value." << std::endl;
00884
00885 return false;
00886 }
00887
00888 n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue);
00889 }
00890
00891 return true;
00892 }
00893
00901 void L1GtTriggerMenuXmlParser::cleanupXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
00902
00903 XERCES_CPP_NAMESPACE_USE
00904
00905 if (parser != 0) {
00906 delete parser;
00907 }
00908
00909 if (m_xmlErrHandler != 0) {
00910 delete m_xmlErrHandler;
00911 m_xmlErrHandler = 0;
00912 }
00913
00914 XMLPlatformUtils::Terminate();
00915
00916 }
00917
00918
00919
00920
00921
00931 bool L1GtTriggerMenuXmlParser::parseVmeXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
00932
00933 XERCES_CPP_NAMESPACE_USE
00934
00935 DOMDocument* doc = parser->getDocument();
00936 DOMNode* n1 = doc->getFirstChild();
00937
00938 if (n1 == 0) {
00939
00940 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: Found no XML child" << std::endl;
00941
00942 return false;
00943 }
00944
00945
00946 n1 = findXMLChild(n1, m_xmlTagVme);
00947 if (n1 == 0) {
00948
00949 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No vme tag found." << std::endl;
00950 return false;
00951 }
00952
00953 n1 = n1->getFirstChild();
00954
00955 unsigned int chipCounter = 0;
00956
00957 while (chipCounter < m_numberConditionChips) {
00958
00959 n1 = findXMLChild(n1, m_xmlTagChip, true);
00960 if (n1 == 0) {
00961
00962 break;
00963 }
00964
00965
00966
00967
00968
00969
00970 n1 = n1->getNextSibling();
00971 chipCounter++;
00972 }
00973
00974 return true;
00975
00976 }
00977
00978
00979
00980
00981
00982 void L1GtTriggerMenuXmlParser::clearMaps() {
00983
00984
00985
00986 for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip
00987 != m_conditionMap.end(); itCondOnChip++) {
00988
00989
00990
00991 itCondOnChip->clear();
00992
00993 }
00994
00995
00996 m_algorithmMap.clear();
00997
00998 }
00999
01000
01001
01002 bool L1GtTriggerMenuXmlParser::insertConditionIntoMap(L1GtCondition& cond, const int chipNr) {
01003
01004 std::string cName = cond.condName();
01005
01006
01007
01008
01009 if ((m_conditionMap[chipNr]).count(cName) != 0) {
01010 LogTrace("L1GtTriggerMenuXmlParser") << " Condition " << cName
01011 << " already exists - not inserted!" << std::endl;
01012 return false;
01013 }
01014
01015 (m_conditionMap[chipNr])[cName] = &cond;
01016
01017
01018
01019
01020
01021 return true;
01022
01023 }
01024
01025
01026 bool L1GtTriggerMenuXmlParser::insertAlgorithmIntoMap(const L1GtAlgorithm& alg) {
01027
01028 std::string algName = alg.algoName();
01029 std::string algAlias = alg.algoAlias();
01030
01031
01032
01033
01034 if (m_algorithmMap.count(algName) != 0) {
01035 LogTrace("L1GtTriggerMenuXmlParser") << " Algorithm \"" << algName
01036 << "\"already exists in the algorithm map- not inserted!" << std::endl;
01037 return false;
01038 }
01039
01040 if (m_algorithmAliasMap.count(algAlias) != 0) {
01041 LogTrace("L1GtTriggerMenuXmlParser") << " Algorithm alias \"" << algAlias
01042 << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
01043 return false;
01044 }
01045
01046
01047 int bitNumber = alg.algoBitNumber();
01048 if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
01049 LogTrace("L1GtTriggerMenuXmlParser") << " Bit number " << bitNumber
01050 << " outside allowed range [0, " << m_numberPhysTriggers
01051 << ") - algorithm not inserted!" << std::endl;
01052 return false;
01053 }
01054
01055
01056 if (m_algorithmMap.size() >= m_numberPhysTriggers) {
01057 LogTrace("L1GtTriggerMenuXmlParser") << " More than maximum allowed "
01058 << m_numberPhysTriggers << " algorithms in the algorithm map - not inserted!"
01059 << std::endl;
01060 return false;
01061 }
01062
01063
01064 int chipNr = alg.algoChipNumber(static_cast<int>(m_numberConditionChips),
01065 static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
01066
01067 if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
01068 LogTrace("L1GtTriggerMenuXmlParser") << " Chip number " << chipNr
01069 << " outside allowed range [0, " << m_numberConditionChips
01070 << ") - algorithm not inserted!" << std::endl;
01071 return false;
01072 }
01073
01074
01075 int outputPin = alg.algoOutputPin(static_cast<int>(m_numberConditionChips),
01076 static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
01077
01078 if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
01079 LogTrace("L1GtTriggerMenuXmlParser") << " Output pin " << outputPin
01080 << " outside allowed range [0, " << m_pinsOnConditionChip
01081 << "] - algorithm not inserted!" << std::endl;
01082 return false;
01083 }
01084
01085
01086 for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
01087
01088 int iPin = (itAlgo->second).algoOutputPin( static_cast<int>(m_numberConditionChips),
01089 static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
01090 std::string iName = itAlgo->first;
01091 int iChip = (itAlgo->second).algoChipNumber(static_cast<int>(m_numberConditionChips),
01092 static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
01093
01094 if ( (outputPin == iPin) && (chipNr == iChip)) {
01095 LogTrace("L1GtTriggerMenuXmlParser") << " Output pin " << outputPin
01096 << " is the same as for algorithm " << iName
01097 << "\n from the same chip number " << chipNr << " - algorithm not inserted!"
01098 << std::endl;
01099 return false;
01100 }
01101
01102 }
01103
01104
01105 m_algorithmMap[algName] = alg;
01106 m_algorithmAliasMap[algAlias] = alg;
01107
01108
01109
01110
01111
01112 return true;
01113
01114 }
01115
01116
01117 bool L1GtTriggerMenuXmlParser::insertTechTriggerIntoMap(const L1GtAlgorithm& alg) {
01118
01119 std::string algName = alg.algoName();
01120
01121
01122
01123
01124
01125 if (m_technicalTriggerMap.count(algName) != 0) {
01126 LogTrace("L1GtTriggerMenuXmlParser") << " Technical trigger \""
01127 << algName
01128 << "\"already exists in the technical trigger map- not inserted!"
01129 << std::endl;
01130 return false;
01131 }
01132
01133
01134 int bitNumber = alg.algoBitNumber();
01135 if ((bitNumber < 0)
01136 || (bitNumber >= static_cast<int>(m_numberTechTriggers))) {
01137 LogTrace("L1GtTriggerMenuXmlParser") << " Bit number "
01138 << bitNumber << " outside allowed range [0, "
01139 << m_numberTechTriggers
01140 << ") - technical trigger not inserted!" << std::endl;
01141 return false;
01142 }
01143
01144
01145 for (CItAlgo itAlgo = m_technicalTriggerMap.begin(); itAlgo
01146 != m_technicalTriggerMap.end(); itAlgo++) {
01147
01148 int iBitNumber = (itAlgo->second).algoBitNumber();
01149 std::string iName = itAlgo->first;
01150
01151 if ((iBitNumber == bitNumber)) {
01152 LogTrace("L1GtTriggerMenuXmlParser") << " Bit number "
01153 << iBitNumber << " is the same as for technical trigger "
01154 << iName << " - technical trigger not inserted!"
01155 << std::endl;
01156 return false;
01157 }
01158
01159 }
01160
01161
01162 if (m_technicalTriggerMap.size() >= m_numberTechTriggers) {
01163 LogTrace("L1GtTriggerMenuXmlParser")
01164 << " More than maximum allowed " << m_numberTechTriggers
01165 << " technical triggers in the technical trigger map - not inserted!"
01166 << std::endl;
01167 return false;
01168 }
01169
01170
01171 m_technicalTriggerMap[algName] = alg;
01172
01173
01174
01175
01176
01177 return true;
01178
01179 }
01180
01181
01182
01183
01184
01185 L1GtConditionType L1GtTriggerMenuXmlParser::getTypeFromType(const std::string& type) {
01186
01187 if (type == m_xmlConditionAttrType1s) {
01188 return Type1s;
01189 }
01190
01191 if (type == m_xmlConditionAttrType2s) {
01192 return Type2s;
01193 }
01194
01195 if (type == m_xmlConditionAttrType3s) {
01196 return Type3s;
01197 }
01198
01199 if (type == m_xmlConditionAttrType4s) {
01200 return Type4s;
01201 }
01202
01203 if (type == m_xmlConditionAttrType2wsc) {
01204 return Type2wsc;
01205 }
01206
01207 if (type == m_xmlConditionAttrType2cor) {
01208 return Type2cor;
01209 }
01210
01211 return TypeNull;
01212 }
01213
01223 int L1GtTriggerMenuXmlParser::getNumFromType(const std::string &type) {
01224
01225 if (type == m_xmlConditionAttrType1s) {
01226 return 1;
01227 }
01228
01229 if (type == m_xmlConditionAttrType2s) {
01230 return 2;
01231 }
01232
01233 if (type == m_xmlConditionAttrType3s) {
01234 return 3;
01235 }
01236
01237 if (type == m_xmlConditionAttrType4s) {
01238 return 4;
01239 }
01240
01241 if (type == m_xmlConditionAttrType2wsc) {
01242 return 2;
01243 }
01244
01245 if (type == m_xmlConditionAttrType2cor) {
01246 return 2;
01247 }
01248
01249 return -1;
01250 }
01251
01260 int L1GtTriggerMenuXmlParser::getBitFromNode(XERCES_CPP_NAMESPACE::DOMNode* node) {
01261
01262 if (getXMLAttribute(node, m_xmlAttrMode) != m_xmlAttrModeBit) {
01263
01264 edm::LogError("L1GtTriggerMenuXmlParser") << "Invalid mode for single bit" << std::endl;
01265
01266 return -1;
01267 }
01268
01269 std::string tmpStr = getXMLTextValue(node);
01270 if (tmpStr == "0") {
01271 return 0;
01272 }
01273 else if (tmpStr == "1") {
01274 return 1;
01275 }
01276 else {
01277 edm::LogError("L1GtTriggerMenuXmlParser") << "Bad bit value (" << tmpStr << ")"
01278 << std::endl;
01279 return -1;
01280 }
01281 }
01282
01292 int L1GtTriggerMenuXmlParser::getGEqFlag(XERCES_CPP_NAMESPACE::DOMNode* node,
01293 const std::string& nodeName) {
01294
01295 XERCES_CPP_NAMESPACE_USE
01296
01297 if (node == 0) {
01298
01299 LogDebug("L1GtTriggerMenuXmlParser")
01300 << "node == 0 in " << __PRETTY_FUNCTION__
01301 << std::endl;
01302
01303 return -1;
01304 }
01305
01306
01307 DOMNode* n1 = node->getFirstChild();
01308 n1 = findXMLChild(n1, nodeName);
01309
01310 if (n1 != 0) {
01311 n1 = findXMLChild(n1->getFirstChild(), m_xmlTagGEq);
01312 if (n1 == 0) {
01313
01314 LogDebug("L1GtTriggerMenuXmlParser") << "No \"greater or equal\" tag found"
01315 << std::endl;
01316
01317 return -1;
01318 }
01319
01320 return getBitFromNode(n1);
01321 }
01322 else {
01323
01324 return -1;
01325
01326 }
01327
01328 }
01329
01342 bool L1GtTriggerMenuXmlParser::getMuonMipIsoBits(XERCES_CPP_NAMESPACE::DOMNode* node,
01343 unsigned int num, std::vector<bool>& mipDst, std::vector<bool>& isoEnDst,
01344 std::vector<bool>& isoReqDst) {
01345
01346 XERCES_CPP_NAMESPACE_USE
01347
01348 if (node == 0) {
01349 return false;
01350 }
01351
01352
01353 DOMNode* n1 = findXMLChild(node->getFirstChild(), m_xmlTagPtLowThreshold);
01354
01355 if (n1 == 0) {
01356 return false;
01357 }
01358
01359
01360 n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
01361
01362 for (unsigned int i = 0; i < num; i++) {
01363
01364 if (n1 == 0) {
01365 return false;
01366 }
01367
01368
01369
01370 DOMNode* bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableMip);
01371 if (bitnode == 0) {
01372 return true;
01373 }
01374
01375 int tmpint = getBitFromNode(bitnode);
01376 if (tmpint < 0) {
01377 return false;
01378 }
01379
01380 mipDst[i] = (tmpint != 0);
01381
01382
01383
01384
01385
01386
01387
01388 bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableIso);
01389 if (bitnode == 0) {
01390 return true;
01391 }
01392
01393 tmpint = getBitFromNode(bitnode);
01394 if (tmpint < 0) {
01395 return false;
01396 }
01397
01398 isoEnDst[i] = (tmpint != 0);
01399
01400
01401
01402
01403
01404
01405 bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagRequestIso);
01406 if (bitnode == 0) {
01407 return true;
01408 }
01409
01410 tmpint = getBitFromNode(bitnode);
01411 if (tmpint < 0) {
01412 return false;
01413 }
01414
01415 isoReqDst[i] = (tmpint != 0);
01416
01417
01418
01419
01420
01421
01422 n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue);
01423 }
01424
01425 return true;
01426 }
01427
01439 bool L1GtTriggerMenuXmlParser::parseMuon(XERCES_CPP_NAMESPACE::DOMNode* node,
01440 const std::string& name, unsigned int chipNr, const bool corrFlag) {
01441
01442 XERCES_CPP_NAMESPACE_USE
01443
01444
01445 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
01446 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
01447 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
01448
01449 if (particle != m_xmlConditionAttrObjectMu) {
01450 edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for muon-condition ("
01451 << particle << ")" << std::endl;
01452 return false;
01453 }
01454
01455 int nrObj = getNumFromType(type);
01456 if (nrObj < 0) {
01457 edm::LogError("L1GtTriggerMenuXmlParser") << "Unknown type for muon-condition (" << type
01458 << ")" << "\nCan not determine number of trigger objects. " << std::endl;
01459 return false;
01460 }
01461
01462
01463
01464 int intGEq = getGEqFlag(node, m_xmlTagPtHighThreshold);
01465 if (intGEq < 0) {
01466 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
01467 << std::endl;
01468 return false;
01469 }
01470
01471 bool gEq = (intGEq != 0);
01472
01473
01474
01475
01476 std::vector<L1GtMuonTemplate::ObjectParameter> objParameter(nrObj);
01477 L1GtMuonTemplate::CorrelationParameter corrParameter;
01478
01479
01480 std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
01481
01482
01483 if ( !getConditionChildValues(node, m_xmlTagPtHighThreshold, nrObj, tmpValues) ) {
01484 return false;
01485 }
01486
01487 for (int i = 0; i < nrObj; i++) {
01488 objParameter[i].ptHighThreshold = tmpValues[i];
01489
01490
01491
01492
01493
01494 }
01495
01496
01497 if ( !getConditionChildValues(node, m_xmlTagPtLowThreshold, nrObj, tmpValues) ) {
01498 return false;
01499 }
01500
01501 for (int i = 0; i < nrObj; i++) {
01502
01503
01504
01505
01506
01507
01508
01509 tmpValues[i] = (tmpValues[i])/16;
01510
01511 objParameter[i].ptLowThreshold = tmpValues[i];
01512
01513
01514
01515
01516
01517 }
01518
01519
01520 if ( !getConditionChildValues(node, m_xmlTagQuality, nrObj, tmpValues) ) {
01521 return false;
01522 }
01523
01524 for (int i = 0; i < nrObj; i++) {
01525 objParameter[i].qualityRange = tmpValues[i];
01526
01527
01528
01529
01530
01531 }
01532
01533
01534 if ( !getConditionChildValues(node, m_xmlTagEta, nrObj, tmpValues) ) {
01535 return false;
01536 }
01537
01538 for (int i = 0; i < nrObj; i++) {
01539
01540 objParameter[i].etaRange = tmpValues[i];
01541
01542
01543
01544
01545
01546 }
01547
01548
01549 if ( !getConditionChildValues(node, m_xmlTagPhiHigh, nrObj, tmpValues) ) {
01550 return false;
01551 }
01552
01553 for (int i = 0; i < nrObj; i++) {
01554 objParameter[i].phiHigh = tmpValues[i];
01555
01556
01557
01558
01559
01560 }
01561
01562
01563 if ( !getConditionChildValues(node, m_xmlTagPhiLow, nrObj, tmpValues) ) {
01564 return false;
01565 }
01566
01567 for (int i = 0; i < nrObj; i++) {
01568 objParameter[i].phiLow = tmpValues[i];
01569
01570
01571
01572
01573
01574 }
01575
01576
01577 if ( !getXMLHexTextValue(findXMLChild(node->getFirstChild(), m_xmlTagChargeCorrelation),
01578 tmpValues[0]) ) {
01579
01580 LogDebug("L1GtTriggerMenuXmlParser")
01581 << " Error getting charge correlation from muon condition (" << name << ")"
01582 << std::endl;
01583 return false;
01584 }
01585
01586 corrParameter.chargeCorrelation = tmpValues[0];
01587
01588
01589
01590
01591
01592
01593
01594
01595 std::vector<bool> tmpMip(nrObj);
01596 std::vector<bool> tmpEnableIso(nrObj);
01597 std::vector<bool> tmpRequestIso(nrObj);
01598
01599 if ( !getMuonMipIsoBits(node, nrObj, tmpMip, tmpEnableIso, tmpRequestIso) ) {
01600 edm::LogError("L1GtTriggerMenuXmlParser")
01601 << " Could not get mip and iso bits from muon condition (" << name << ")"
01602 << std::endl;
01603 return false;
01604 }
01605
01606 for (int i = 0; i < nrObj; i++) {
01607 objParameter[i].enableMip = tmpMip[i];
01608 objParameter[i].enableIso = tmpEnableIso[i];
01609 objParameter[i].requestIso = tmpRequestIso[i];
01610 }
01611
01612
01613 bool wscVal = (type == m_xmlConditionAttrType2wsc );
01614
01615 if (wscVal) {
01616
01617 if ( !getConditionChildValues(node, m_xmlTagDeltaEta, 1, tmpValues) ) {
01618 return false;
01619 }
01620
01621 corrParameter.deltaEtaRange = tmpValues[0];
01622
01623
01624 if ( !getXMLHexTextValue128(findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi),
01625 tmpValues[0], tmpValues[1])) {
01626 edm::LogError("L1GtTriggerMenuXmlParser")
01627 << " Could not get deltaPhi for muon condition with wsc (" << name << ")"
01628 << std::endl;
01629 return false;
01630 }
01631
01632 corrParameter.deltaPhiRange0Word = tmpValues[0];
01633 corrParameter.deltaPhiRange1Word = tmpValues[1];
01634
01635
01636
01637
01638
01639
01640 unsigned int maxbits;
01641
01642 if ( !countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits) ) {
01643 return false;
01644 }
01645
01646 corrParameter.deltaPhiMaxbits = maxbits;
01647
01648
01649
01650 }
01651
01652
01653
01654 L1GtConditionType cType = getTypeFromType(type);
01655
01656
01657
01658
01659 if (cType == TypeNull) {
01660 edm::LogError("L1GtTriggerMenuXmlParser")
01661 << "Type for muon condition id TypeNull - it means not defined in the XML file."
01662 << "\nNumber of trigger objects is set to zero. " << std::endl;
01663 return false;
01664 }
01665
01666
01667 std::vector<L1GtObject> objType(nrObj, Mu);
01668
01669
01670
01671 L1GtMuonTemplate muonCond(name);
01672
01673 muonCond.setCondType(cType);
01674 muonCond.setObjectType(objType);
01675 muonCond.setCondGEq(gEq);
01676 muonCond.setCondChipNr(chipNr);
01677
01678 muonCond.setConditionParameter(objParameter, corrParameter);
01679
01680 if (edm::isDebugEnabled() ) {
01681 std::ostringstream myCoutStream;
01682 muonCond.print(myCoutStream);
01683 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
01684 }
01685
01686
01687 if ( !insertConditionIntoMap(muonCond, chipNr)) {
01688
01689 edm::LogError("L1GtTriggerMenuXmlParser")
01690 << " Error: duplicate condition (" << name << ")"
01691 << std::endl;
01692 return false;
01693 }
01694 else {
01695 if (corrFlag) {
01696 (m_corMuonTemplate[chipNr]).push_back(muonCond);
01697
01698 }
01699 else {
01700 (m_vecMuonTemplate[chipNr]).push_back(muonCond);
01701 }
01702
01703 }
01704
01705
01706 return true;
01707 }
01708
01720 bool L1GtTriggerMenuXmlParser::parseCalo(XERCES_CPP_NAMESPACE::DOMNode* node,
01721 const std::string& name, unsigned int chipNr, const bool corrFlag) {
01722
01723 XERCES_CPP_NAMESPACE_USE
01724
01725
01726 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
01727 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
01728 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
01729
01730
01731 L1GtObject caloObjType;
01732
01733 if (particle == m_xmlConditionAttrObjectNoIsoEG) {
01734 caloObjType = NoIsoEG;
01735 }
01736 else if (particle == m_xmlConditionAttrObjectIsoEG) {
01737 caloObjType = IsoEG;
01738 }
01739 else if (particle == m_xmlConditionAttrObjectCenJet) {
01740 caloObjType = CenJet;
01741 }
01742 else if (particle == m_xmlConditionAttrObjectTauJet) {
01743 caloObjType = TauJet;
01744 }
01745 else if (particle == m_xmlConditionAttrObjectForJet) {
01746 caloObjType = ForJet;
01747 }
01748 else {
01749 edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for calo-condition ("
01750 << particle << ")" << std::endl;
01751 return false;
01752 }
01753
01754 int nrObj = getNumFromType(type);
01755 if (nrObj < 0) {
01756 edm::LogError("L1GtTriggerMenuXmlParser") << "Unknown type for calo-condition (" << type
01757 << ")" << "\nCan not determine number of trigger objects. " << std::endl;
01758 return false;
01759 }
01760
01761
01762
01763 int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
01764 if (intGEq < 0) {
01765 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
01766 << std::endl;
01767 return false;
01768 }
01769
01770 bool gEq = (intGEq != 0);
01771
01772
01773
01774
01775 std::vector<L1GtCaloTemplate::ObjectParameter> objParameter(nrObj);
01776 L1GtCaloTemplate::CorrelationParameter corrParameter;
01777
01778
01779 std::vector<boost::uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
01780
01781
01782 if ( !getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
01783 return false;
01784 }
01785
01786 for (int i = 0; i < nrObj; i++) {
01787 objParameter[i].etThreshold = tmpValues[i];
01788
01789
01790
01791
01792
01793 }
01794
01795
01796 if ( !getConditionChildValues(node, m_xmlTagEta, nrObj, tmpValues) ) {
01797 return false;
01798 }
01799
01800
01801 for (int i = 0; i < nrObj; i++) {
01802
01803 objParameter[i].etaRange = tmpValues[i];
01804
01805
01806
01807
01808
01809 }
01810
01811
01812 if ( !getConditionChildValues(node, m_xmlTagPhi, nrObj, tmpValues) ) {
01813 return false;
01814 }
01815
01816 for (int i = 0; i < nrObj; i++) {
01817 objParameter[i].phiRange = tmpValues[i];
01818
01819
01820
01821
01822
01823 }
01824
01825
01826 bool wscVal = (type == m_xmlConditionAttrType2wsc );
01827
01828 if (wscVal) {
01829
01830 if ( !getConditionChildValues(node, m_xmlTagDeltaEta, 1, tmpValues) ) {
01831 return false;
01832 }
01833
01834 corrParameter.deltaEtaRange = tmpValues[0];
01835
01836
01837 if ( !getConditionChildValues(node, m_xmlTagDeltaPhi, 1, tmpValues) ) {
01838 return false;
01839 }
01840
01841 corrParameter.deltaPhiRange = tmpValues[0];
01842
01843
01844
01845
01846
01847
01848 unsigned int maxbits;
01849
01850 if ( !countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits) ) {
01851 return false;
01852 }
01853
01854 corrParameter.deltaPhiMaxbits = maxbits;
01855
01856
01857
01858 }
01859
01860
01861
01862 L1GtConditionType cType = getTypeFromType(type);
01863
01864
01865
01866
01867 if (cType == TypeNull) {
01868 edm::LogError("L1GtTriggerMenuXmlParser")
01869 << "Type for calo condition id TypeNull - it means not defined in the XML file."
01870 << "\nNumber of trigger objects is set to zero. " << std::endl;
01871 return false;
01872 }
01873
01874
01875 std::vector<L1GtObject> objType(nrObj, caloObjType);
01876
01877
01878
01879 L1GtCaloTemplate caloCond(name);
01880
01881 caloCond.setCondType(cType);
01882 caloCond.setObjectType(objType);
01883 caloCond.setCondGEq(gEq);
01884 caloCond.setCondChipNr(chipNr);
01885
01886 caloCond.setConditionParameter(objParameter, corrParameter);
01887
01888 if (edm::isDebugEnabled() ) {
01889
01890 std::ostringstream myCoutStream;
01891 caloCond.print(myCoutStream);
01892 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
01893
01894 }
01895
01896
01897 if ( !insertConditionIntoMap(caloCond, chipNr)) {
01898
01899 edm::LogError("L1GtTriggerMenuXmlParser")
01900 << " Error: duplicate condition (" << name << ")"
01901 << std::endl;
01902
01903 return false;
01904 }
01905 else {
01906
01907 if (corrFlag) {
01908 (m_corCaloTemplate[chipNr]).push_back(caloCond);
01909 }
01910 else {
01911 (m_vecCaloTemplate[chipNr]).push_back(caloCond);
01912 }
01913
01914 }
01915
01916
01917
01918 return true;
01919 }
01920
01932 bool L1GtTriggerMenuXmlParser::parseEnergySum(
01933 XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& name,
01934 unsigned int chipNr, const bool corrFlag) {
01935
01936 XERCES_CPP_NAMESPACE_USE
01937
01938
01939 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
01940 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
01941 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
01942
01943
01944 L1GtObject energySumObjType;
01945 L1GtConditionType cType;
01946
01947 if ((particle == m_xmlConditionAttrObjectETM) && (type == m_xmlConditionAttrObjectETM)) {
01948
01949 energySumObjType = ETM;
01950 cType = TypeETM;
01951
01952 }
01953 else if ((particle == m_xmlConditionAttrObjectETT) && (type == m_xmlConditionAttrObjectETT)) {
01954
01955 energySumObjType = ETT;
01956 cType = TypeETT;
01957
01958 }
01959 else if ((particle == m_xmlConditionAttrObjectHTT) && (type == m_xmlConditionAttrObjectHTT)) {
01960
01961 energySumObjType = HTT;
01962 cType = TypeHTT;
01963
01964 }
01965 else if ((particle == m_xmlConditionAttrObjectHTM) && (type == m_xmlConditionAttrObjectHTM)) {
01966
01967 energySumObjType = HTM;
01968 cType = TypeHTM;
01969
01970 }
01971 else {
01972 edm::LogError("L1GtTriggerMenuXmlParser")
01973 << "Wrong particle or type for energy-sum condition (" << particle << ", " << type
01974 << ")" << std::endl;
01975 return false;
01976 }
01977
01978
01979 int nrObj = 1;
01980
01981
01982
01983 int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
01984 if (intGEq < 0) {
01985 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
01986 << std::endl;
01987 return false;
01988 }
01989
01990 bool gEq = (intGEq != 0);
01991
01992
01993
01994
01995 std::vector<L1GtEnergySumTemplate::ObjectParameter> objParameter(nrObj);
01996
01997
01998 std::vector<boost::uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
01999
02000
02001 if ( !getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
02002 return false;
02003 }
02004
02005 for (int i = 0; i < nrObj; i++) {
02006 objParameter[i].etThreshold = tmpValues[i];
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016 if (energySumObjType == ETM) {
02017
02018 if (!getXMLHexTextValue128(
02019 findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0], tmpValues[1])) {
02020 edm::LogError("L1GtTriggerMenuXmlParser")
02021 << " Could not get phi for ETM condition (" << name << ")" << std::endl;
02022 return false;
02023 }
02024
02025 objParameter[i].phiRange0Word = tmpValues[0];
02026 objParameter[i].phiRange1Word = tmpValues[1];
02027
02028 } else if (energySumObjType == HTM) {
02029
02030 if (!getXMLHexTextValue(findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0])) {
02031 edm::LogError("L1GtTriggerMenuXmlParser")
02032 << " Could not get phi for HTM condition (" << name << ")" << std::endl;
02033 return false;
02034 }
02035
02036 objParameter[i].phiRange0Word = tmpValues[0];
02037
02038 }
02039
02040
02041 DOMNode* n1;
02042 if ( (n1 = findXMLChild(node->getFirstChild(), m_xmlTagEtThreshold)) == 0) {
02043 edm::LogError("L1GtTriggerMenuXmlParser")
02044 << " Could not get energyOverflow for EnergySum condition (" << name << ")"
02045 << std::endl;
02046 return false;
02047 }
02048 if ( (n1 = findXMLChild(n1->getFirstChild(), m_xmlTagEnergyOverflow)) == 0) {
02049 edm::LogError("L1GtTriggerMenuXmlParser")
02050 << " Could not get energyOverflow for EnergySum condition (" << name << ")"
02051 << std::endl;
02052 return false;
02053 }
02054
02055 int tmpInt = getBitFromNode(n1);
02056 if (tmpInt == 0) {
02057 objParameter[i].energyOverflow = false;
02058
02059
02060
02061
02062
02063 }
02064 else if (tmpInt == 1) {
02065 objParameter[i].energyOverflow = true;
02066
02067
02068
02069
02070
02071 }
02072 else {
02073 LogTrace("L1GtTriggerMenuXmlParser")
02074 << " EnergySum energyOverflow logical flag (hex) = " << std::hex << tmpInt
02075 << std::dec << " - wrong value! " << std::endl;
02076 return false;
02077 }
02078
02079 }
02080
02081
02082 std::vector<L1GtObject> objType(nrObj, energySumObjType);
02083
02084
02085
02086 L1GtEnergySumTemplate energySumCond(name);
02087
02088 energySumCond.setCondType(cType);
02089 energySumCond.setObjectType(objType);
02090 energySumCond.setCondGEq(gEq);
02091 energySumCond.setCondChipNr(chipNr);
02092
02093 energySumCond.setConditionParameter(objParameter);
02094
02095 if (edm::isDebugEnabled() ) {
02096
02097 std::ostringstream myCoutStream;
02098 energySumCond.print(myCoutStream);
02099 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
02100
02101 }
02102
02103
02104 if ( !insertConditionIntoMap(energySumCond, chipNr)) {
02105
02106 edm::LogError("L1GtTriggerMenuXmlParser")
02107 << " Error: duplicate condition (" << name << ")"
02108 << std::endl;
02109
02110 return false;
02111 }
02112 else {
02113
02114 if (corrFlag) {
02115 (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
02116
02117 }
02118 else {
02119 (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
02120 }
02121
02122 }
02123
02124
02125
02126 return true;
02127 }
02128
02141 bool L1GtTriggerMenuXmlParser::parseJetCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
02142 const std::string& name, unsigned int chipNr) {
02143
02144 XERCES_CPP_NAMESPACE_USE
02145
02146
02147 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
02148 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
02149 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
02150
02151 if (particle != m_xmlConditionAttrObjectJetCounts) {
02152 edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for JetCounts condition ("
02153 << particle << ")" << std::endl;
02154 return false;
02155 }
02156
02157
02158 L1GtObject jetCountsObjType = JetCounts;
02159 L1GtConditionType cType = TypeJetCounts;
02160
02161
02162 int nrObj = 1;
02163
02164
02165
02166 int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
02167 if (intGEq < 0) {
02168 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
02169 << std::endl;
02170 return false;
02171 }
02172
02173 bool gEq = (intGEq != 0);
02174
02175
02176
02177
02178 std::vector<L1GtJetCountsTemplate::ObjectParameter> objParameter(nrObj);
02179
02180
02181
02182 char* endPtr = const_cast<char*>(type.c_str());
02183 long int typeInt = strtol(type.c_str(), &endPtr, 10);
02184
02185 if (*endPtr != 0) {
02186
02187 LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
02188 << std::endl;
02189
02190 return false;
02191 }
02192
02193
02194 if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1JetCounts))) {
02195 LogDebug("L1GtTriggerMenuXmlParser") << "Count index " << typeInt
02196 << " outside range [0, " << m_numberL1JetCounts << "]" << std::endl;
02197
02198 return false;
02199 }
02200
02201 objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
02202
02203
02204 std::vector<boost::uint64_t> tmpValues(nrObj);
02205
02206 if ( !getConditionChildValues(node, m_xmlTagCountThreshold, nrObj, tmpValues) ) {
02207 return false;
02208 }
02209
02210 for (int i = 0; i < nrObj; i++) {
02211 objParameter[i].countThreshold = tmpValues[i];
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260 }
02261
02262
02263 std::vector<L1GtObject> objType(nrObj, jetCountsObjType);
02264
02265
02266
02267 L1GtJetCountsTemplate jetCountsCond(name);
02268
02269 jetCountsCond.setCondType(cType);
02270 jetCountsCond.setObjectType(objType);
02271 jetCountsCond.setCondGEq(gEq);
02272 jetCountsCond.setCondChipNr(chipNr);
02273
02274 jetCountsCond.setConditionParameter(objParameter);
02275
02276 if (edm::isDebugEnabled() ) {
02277
02278 std::ostringstream myCoutStream;
02279 jetCountsCond.print(myCoutStream);
02280 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
02281
02282 }
02283
02284
02285 if ( !insertConditionIntoMap(jetCountsCond, chipNr)) {
02286
02287 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name
02288 << ")" << std::endl;
02289
02290 return false;
02291 } else {
02292
02293 (m_vecJetCountsTemplate[chipNr]).push_back(jetCountsCond);
02294
02295 }
02296
02297
02298
02299 return true;
02300 }
02301
02314 bool L1GtTriggerMenuXmlParser::parseCastor(XERCES_CPP_NAMESPACE::DOMNode* node,
02315 const std::string& name, unsigned int chipNr) {
02316
02317 XERCES_CPP_NAMESPACE_USE
02318
02319
02320 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
02321 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
02322 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
02323
02324 if (particle != m_xmlConditionAttrObjectCastor) {
02325 edm::LogError("L1GtTriggerMenuXmlParser")
02326 << "\nError: wrong particle for Castor condition ("
02327 << particle << ")" << std::endl;
02328 return false;
02329 }
02330
02331
02332
02333 L1GtConditionType cType = TypeCastor;
02334
02335
02336
02337
02338 bool gEq = false;
02339
02340
02341
02342 L1GtCastorTemplate castorCond(name);
02343
02344 castorCond.setCondType(cType);
02345 castorCond.setCondGEq(gEq);
02346 castorCond.setCondChipNr(chipNr);
02347
02348
02349 if (edm::isDebugEnabled() ) {
02350
02351 std::ostringstream myCoutStream;
02352 castorCond.print(myCoutStream);
02353 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
02354
02355 }
02356
02357
02358 if ( !insertConditionIntoMap(castorCond, chipNr)) {
02359
02360 edm::LogError("L1GtTriggerMenuXmlParser")
02361 << " Error: duplicate condition (" << name
02362 << ")" << std::endl;
02363
02364 return false;
02365 } else {
02366
02367 (m_vecCastorTemplate[chipNr]).push_back(castorCond);
02368
02369 }
02370
02371
02372
02373 return true;
02374 }
02375
02376
02389 bool L1GtTriggerMenuXmlParser::parseHfBitCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
02390 const std::string& name, unsigned int chipNr) {
02391
02392 XERCES_CPP_NAMESPACE_USE
02393
02394
02395 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
02396 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
02397 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
02398
02399 if (particle != m_xmlConditionAttrObjectHfBitCounts) {
02400 edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for HfBitCounts condition ("
02401 << particle << ")" << std::endl;
02402 return false;
02403 }
02404
02405
02406 L1GtObject hfBitCountsObjType = HfBitCounts;
02407 L1GtConditionType cType = TypeHfBitCounts;
02408
02409
02410 int nrObj = 1;
02411
02412
02413
02414 int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
02415 if (intGEq < 0) {
02416 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
02417 << std::endl;
02418 return false;
02419 }
02420
02421 bool gEq = (intGEq != 0);
02422
02423
02424
02425
02426 std::vector<L1GtHfBitCountsTemplate::ObjectParameter> objParameter(nrObj);
02427
02428
02429
02430 char* endPtr = const_cast<char*>(type.c_str());
02431 long int typeInt = strtol(type.c_str(), &endPtr, 10);
02432
02433 if (*endPtr != 0) {
02434
02435 LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
02436 << std::endl;
02437
02438 return false;
02439 }
02440
02441
02442
02443
02444
02445
02446
02447
02448
02449 objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
02450
02451
02452 std::vector<boost::uint64_t> tmpValues(nrObj);
02453
02454 if ( !getConditionChildValues(node, m_xmlTagCountThreshold, nrObj, tmpValues) ) {
02455 return false;
02456 }
02457
02458 for (int i = 0; i < nrObj; i++) {
02459 objParameter[i].countThreshold = tmpValues[i];
02460
02461
02462
02463
02464
02465
02466 }
02467
02468
02469 std::vector<L1GtObject> objType(nrObj, hfBitCountsObjType);
02470
02471
02472
02473 L1GtHfBitCountsTemplate hfBitCountsCond(name);
02474
02475 hfBitCountsCond.setCondType(cType);
02476 hfBitCountsCond.setObjectType(objType);
02477 hfBitCountsCond.setCondGEq(gEq);
02478 hfBitCountsCond.setCondChipNr(chipNr);
02479
02480 hfBitCountsCond.setConditionParameter(objParameter);
02481
02482 if (edm::isDebugEnabled() ) {
02483
02484 std::ostringstream myCoutStream;
02485 hfBitCountsCond.print(myCoutStream);
02486 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
02487
02488 }
02489
02490
02491 if ( !insertConditionIntoMap(hfBitCountsCond, chipNr)) {
02492
02493 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name
02494 << ")" << std::endl;
02495
02496 return false;
02497 } else {
02498
02499 (m_vecHfBitCountsTemplate[chipNr]).push_back(hfBitCountsCond);
02500
02501 }
02502
02503
02504
02505 return true;
02506 }
02507
02508
02521 bool L1GtTriggerMenuXmlParser::parseHfRingEtSums(XERCES_CPP_NAMESPACE::DOMNode* node,
02522 const std::string& name, unsigned int chipNr) {
02523
02524 XERCES_CPP_NAMESPACE_USE
02525
02526
02527 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
02528 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
02529 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
02530
02531 if (particle != m_xmlConditionAttrObjectHfRingEtSums) {
02532 edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for HfRingEtSums condition ("
02533 << particle << ")" << std::endl;
02534 return false;
02535 }
02536
02537
02538 L1GtObject hfRingEtSumsObjType = HfRingEtSums;
02539 L1GtConditionType cType = TypeHfRingEtSums;
02540
02541
02542 int nrObj = 1;
02543
02544
02545
02546 int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
02547 if (intGEq < 0) {
02548 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag"
02549 << std::endl;
02550 return false;
02551 }
02552
02553 bool gEq = (intGEq != 0);
02554
02555
02556
02557
02558 std::vector<L1GtHfRingEtSumsTemplate::ObjectParameter> objParameter(nrObj);
02559
02560
02561
02562 char* endPtr = const_cast<char*>(type.c_str());
02563 long int typeInt = strtol(type.c_str(), &endPtr, 10);
02564
02565 if (*endPtr != 0) {
02566
02567 LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec."
02568 << std::endl;
02569
02570 return false;
02571 }
02572
02573
02574
02575
02576
02577
02578
02579
02580
02581 objParameter[0].etSumIndex = static_cast<unsigned int>(typeInt);
02582
02583
02584 std::vector<boost::uint64_t> tmpValues(nrObj);
02585
02586 if ( !getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues) ) {
02587 return false;
02588 }
02589
02590 for (int i = 0; i < nrObj; i++) {
02591 objParameter[i].etSumThreshold = tmpValues[i];
02592
02593
02594
02595
02596
02597
02598 }
02599
02600
02601 std::vector<L1GtObject> objType(nrObj, hfRingEtSumsObjType);
02602
02603
02604
02605 L1GtHfRingEtSumsTemplate hfRingEtSumsCond(name);
02606
02607 hfRingEtSumsCond.setCondType(cType);
02608 hfRingEtSumsCond.setObjectType(objType);
02609 hfRingEtSumsCond.setCondGEq(gEq);
02610 hfRingEtSumsCond.setCondChipNr(chipNr);
02611
02612 hfRingEtSumsCond.setConditionParameter(objParameter);
02613
02614 if (edm::isDebugEnabled() ) {
02615
02616 std::ostringstream myCoutStream;
02617 hfRingEtSumsCond.print(myCoutStream);
02618 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
02619
02620 }
02621
02622
02623 if ( !insertConditionIntoMap(hfRingEtSumsCond, chipNr)) {
02624
02625 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name
02626 << ")" << std::endl;
02627
02628 return false;
02629 } else {
02630
02631 (m_vecHfRingEtSumsTemplate[chipNr]).push_back(hfRingEtSumsCond);
02632
02633 }
02634
02635
02636
02637 return true;
02638 }
02639
02652 bool L1GtTriggerMenuXmlParser::parseBptx(XERCES_CPP_NAMESPACE::DOMNode* node,
02653 const std::string& name, unsigned int chipNr) {
02654
02655 XERCES_CPP_NAMESPACE_USE
02656
02657
02658 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
02659 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
02660 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
02661
02662 if (particle != m_xmlConditionAttrObjectBptx) {
02663 edm::LogError("L1GtTriggerMenuXmlParser")
02664 << "\nError: wrong particle for Bptx condition ("
02665 << particle << ")" << std::endl;
02666 return false;
02667 }
02668
02669
02670
02671 L1GtConditionType cType = TypeBptx;
02672
02673
02674
02675
02676 bool gEq = false;
02677
02678
02679
02680 L1GtBptxTemplate bptxCond(name);
02681
02682 bptxCond.setCondType(cType);
02683 bptxCond.setCondGEq(gEq);
02684 bptxCond.setCondChipNr(chipNr);
02685
02686 LogTrace("L1GtTriggerMenuXmlParser") << bptxCond << "\n" << std::endl;
02687
02688
02689 if ( !insertConditionIntoMap(bptxCond, chipNr)) {
02690
02691 edm::LogError("L1GtTriggerMenuXmlParser")
02692 << " Error: duplicate condition (" << name
02693 << ")" << std::endl;
02694
02695 return false;
02696 } else {
02697
02698 (m_vecBptxTemplate[chipNr]).push_back(bptxCond);
02699
02700 }
02701
02702
02703
02704 return true;
02705 }
02706
02707
02720 bool L1GtTriggerMenuXmlParser::parseExternal(XERCES_CPP_NAMESPACE::DOMNode* node,
02721 const std::string& name, unsigned int chipNr) {
02722
02723 XERCES_CPP_NAMESPACE_USE
02724
02725
02726 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
02727 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
02728 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
02729
02730 if (particle != m_xmlConditionAttrObjectGtExternal) {
02731 edm::LogError("L1GtTriggerMenuXmlParser")
02732 << "\nError: wrong particle for External condition ("
02733 << particle << ")" << std::endl;
02734 return false;
02735 }
02736
02737
02738
02739 L1GtConditionType cType = TypeExternal;
02740
02741
02742
02743
02744 bool gEq = false;
02745
02746
02747
02748 L1GtExternalTemplate externalCond(name);
02749
02750 externalCond.setCondType(cType);
02751 externalCond.setCondGEq(gEq);
02752 externalCond.setCondChipNr(chipNr);
02753
02754 LogTrace("L1GtTriggerMenuXmlParser") << externalCond << "\n" << std::endl;
02755
02756
02757 if ( !insertConditionIntoMap(externalCond, chipNr)) {
02758
02759 edm::LogError("L1GtTriggerMenuXmlParser")
02760 << " Error: duplicate condition (" << name
02761 << ")" << std::endl;
02762
02763 return false;
02764 } else {
02765
02766 (m_vecExternalTemplate[chipNr]).push_back(externalCond);
02767
02768 }
02769
02770
02771
02772 return true;
02773 }
02774
02775
02788 bool L1GtTriggerMenuXmlParser::parseCorrelation(
02789 XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& name,
02790 unsigned int chipNr) {
02791
02792 XERCES_CPP_NAMESPACE_USE
02793
02794
02795 L1GtCorrelationTemplate correlationCond(name);
02796
02797
02798 if ( !insertConditionIntoMap(correlationCond, chipNr)) {
02799
02800 edm::LogError("L1GtTriggerMenuXmlParser")
02801 << " Error: duplicate correlation condition (" << name << ")"
02802 << std::endl;
02803
02804 return false;
02805 }
02806
02807
02808 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
02809 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
02810 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
02811
02812 LogTrace("L1GtTriggerMenuXmlParser") << " Condition category: "
02813 << condition << ", particle: " << particle << ", type: " << type
02814 << "\n" << std::endl;
02815
02816
02817 L1GtConditionType cType = Type2cor;
02818
02819
02820 const int nrObj = 2;
02821
02822
02823 int intGEq[nrObj] = { -1, -1 };
02824 std::vector<L1GtObject> objType(nrObj);
02825 std::vector<L1GtConditionCategory> condCateg(nrObj);
02826
02827
02828 const bool corrFlag = true;
02829 int corrIndexVal[nrObj] = { -1, -1 };
02830
02831
02832
02833 DOMNode* conditionsNode = node->getFirstChild();
02834 std::string conditionNameNodeName;
02835 conditionsNode = findXMLChild(conditionsNode, "", true,
02836 &conditionNameNodeName);
02837
02838
02839 for (int iSubCond = 0; iSubCond < nrObj; ++iSubCond) {
02840
02841
02842 condition = getXMLAttribute(conditionsNode, m_xmlConditionAttrCondition);
02843 particle = getXMLAttribute(conditionsNode, m_xmlConditionAttrObject);
02844 type = getXMLAttribute(conditionsNode, m_xmlConditionAttrType);
02845
02846 LogTrace("L1GtTriggerMenuXmlParser") << " Sub-condition category: "
02847 << condition << ", particle: " << particle << ", type: "
02848 << type << ", name: " << conditionNameNodeName << "\n"
02849 << std::endl;
02850
02851
02852 if (condition == m_xmlConditionAttrConditionMuon) {
02853 if (!parseMuon(conditionsNode, conditionNameNodeName, chipNr,
02854 corrFlag)) {
02855 edm::LogError("L1GtTriggerMenuXmlParser")
02856 << "Error parsing sub-condition " << condition << ")"
02857 << " with name " << conditionNameNodeName << std::endl;
02858
02859 }
02860
02861
02862 intGEq[iSubCond] = getGEqFlag(conditionsNode,
02863 m_xmlTagPtHighThreshold);
02864 if (intGEq[iSubCond] < 0) {
02865 edm::LogError("L1GtTriggerMenuXmlParser")
02866 << "Error getting \"greater or equal\" flag"
02867 << " for sub-condition " << conditionNameNodeName
02868 << " for the correlation condition " << name
02869 << std::endl;
02870 return false;
02871 }
02872
02873
02874 objType[iSubCond] = Mu;
02875 condCateg[iSubCond] = CondMuon;
02876 corrIndexVal[iSubCond] = (m_corMuonTemplate[chipNr]).size() - 1;
02877
02878 }
02879 else if (condition == m_xmlConditionAttrConditionCalo) {
02880 if (!parseCalo(conditionsNode, conditionNameNodeName, chipNr,
02881 corrFlag)) {
02882 edm::LogError("L1GtTriggerMenuXmlParser")
02883 << "Error parsing sub-condition " << condition << ")"
02884 << " with name " << conditionNameNodeName << std::endl;
02885
02886 }
02887
02888
02889 intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
02890 if (intGEq[iSubCond] < 0) {
02891 edm::LogError("L1GtTriggerMenuXmlParser")
02892 << "Error getting \"greater or equal\" flag"
02893 << " for sub-condition " << conditionNameNodeName
02894 << " for the correlation condition " << name
02895 << std::endl;
02896 return false;
02897 }
02898
02899
02900 if (particle == m_xmlConditionAttrObjectNoIsoEG) {
02901 objType[iSubCond] = NoIsoEG;
02902 }
02903 else if (particle == m_xmlConditionAttrObjectIsoEG) {
02904 objType[iSubCond] = IsoEG;
02905 }
02906 else if (particle == m_xmlConditionAttrObjectCenJet) {
02907 objType[iSubCond] = CenJet;
02908 }
02909 else if (particle == m_xmlConditionAttrObjectTauJet) {
02910 objType[iSubCond] = TauJet;
02911 }
02912 else if (particle == m_xmlConditionAttrObjectForJet) {
02913 objType[iSubCond] = ForJet;
02914 }
02915 else {
02916 edm::LogError("L1GtTriggerMenuXmlParser")
02917 << "Wrong object type " << particle
02918 << " for sub-condition " << conditionNameNodeName
02919 << " from the correlation condition " << name
02920 << std::endl;
02921 return false;
02922 }
02923
02924 condCateg[iSubCond] = CondCalo;
02925 corrIndexVal[iSubCond] = (m_corCaloTemplate[chipNr]).size() - 1;
02926
02927 }
02928 else if (condition == m_xmlConditionAttrConditionEnergySum) {
02929 if (!parseEnergySum(conditionsNode, conditionNameNodeName, chipNr,
02930 corrFlag)) {
02931 edm::LogError("L1GtTriggerMenuXmlParser")
02932 << "Error parsing sub-condition " << condition << ")"
02933 << " with name " << conditionNameNodeName << std::endl;
02934
02935 }
02936
02937
02938 intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
02939 if (intGEq[iSubCond] < 0) {
02940 edm::LogError("L1GtTriggerMenuXmlParser")
02941 << "Error getting \"greater or equal\" flag"
02942 << " for sub-condition " << conditionNameNodeName
02943 << " for the correlation condition " << name
02944 << std::endl;
02945 return false;
02946 }
02947
02948
02949 if (particle == m_xmlConditionAttrObjectETM) {
02950 objType[iSubCond] = ETM;
02951 }
02952 else if (particle == m_xmlConditionAttrObjectETT) {
02953 objType[iSubCond] = ETT;
02954 }
02955 else if (particle == m_xmlConditionAttrObjectHTT) {
02956 objType[iSubCond] = HTT;
02957 }
02958 else if (particle == m_xmlConditionAttrObjectHTM) {
02959 objType[iSubCond] = HTM;
02960 }
02961 else {
02962 edm::LogError("L1GtTriggerMenuXmlParser")
02963 << "Wrong object type " << particle
02964 << " for sub-condition " << conditionNameNodeName
02965 << " from the correlation condition " << name
02966 << std::endl;
02967 return false;
02968 }
02969
02970 condCateg[iSubCond] = CondEnergySum;
02971 corrIndexVal[iSubCond] = (m_corEnergySumTemplate[chipNr]).size() - 1;
02972
02973 }
02974 else {
02975 edm::LogError("L1GtTriggerMenuXmlParser")
02976 << "Unknown or un-adequate sub-condition (" << condition
02977 << ")" << " with name " << conditionNameNodeName
02978 << " for the correlation condition " << name << std::endl;
02979
02980 return false;
02981 }
02982
02983 conditionsNode = findXMLChild(conditionsNode->getNextSibling(), "",
02984 true, &conditionNameNodeName);
02985
02986 }
02987
02988
02989 bool gEq = true;
02990 if (intGEq[0] != intGEq[1]) {
02991 edm::LogError("L1GtTriggerMenuXmlParser")
02992 << "Inconsistent GEq flags for sub-conditions (" << condition
02993 << ")" << " with name " << conditionNameNodeName
02994 << " for the correlation condition " << name << std::endl;
02995 return false;
02996
02997 }
02998 else {
02999 gEq = (intGEq[0] != 0);
03000
03001 }
03002
03003
03004
03005
03006 L1GtCorrelationTemplate::CorrelationParameter corrParameter;
03007 std::vector<boost::uint64_t> tmpValues(nrObj);
03008
03009
03010
03011
03012
03013
03014
03015
03016 XERCES_CPP_NAMESPACE::DOMNode* node1 = findXMLChild(node->getFirstChild(),
03017 m_xmlTagDeltaEta);
03018
03019 std::string valString;
03020
03021 if (node1 == 0) {
03022 edm::LogError("L1GtTriggerMenuXmlParser")
03023 << " Could not get deltaEta for correlation condition "
03024 << name << ". " << std::endl;
03025 return false;
03026 }
03027 else {
03028 valString = getXMLTextValue(node1);
03029 }
03030
03031 corrParameter.deltaEtaRange = valString;
03032
03033
03034
03035
03036
03037
03038
03039
03040
03041
03042
03043
03044 node1 = findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi);
03045
03046 if (node1 == 0) {
03047 return false;
03048 edm::LogError("L1GtTriggerMenuXmlParser")
03049 << " Could not get deltaPhi for correlation condition "
03050 << name << ". " << std::endl;
03051 }
03052 else {
03053 valString = getXMLTextValue(node1);
03054 }
03055
03056 corrParameter.deltaPhiRange = valString;
03057
03058
03059
03060
03061
03062
03063 unsigned int maxbits;
03064
03065 if ( !countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits) ) {
03066 return false;
03067 }
03068
03069 corrParameter.deltaPhiMaxbits = maxbits;
03070
03071
03072
03073
03074
03075
03076 correlationCond.setCondType(cType);
03077 correlationCond.setObjectType(objType);
03078 correlationCond.setCondGEq(gEq);
03079 correlationCond.setCondChipNr(chipNr);
03080
03081 correlationCond.setCond0Category(condCateg[0]);
03082 correlationCond.setCond1Category(condCateg[1]);
03083
03084 correlationCond.setCond0Index(corrIndexVal[0]);
03085 correlationCond.setCond1Index(corrIndexVal[1]);
03086
03087 correlationCond.setCorrelationParameter(corrParameter);
03088
03089 if (edm::isDebugEnabled() ) {
03090
03091 std::ostringstream myCoutStream;
03092 correlationCond.print(myCoutStream);
03093 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n"
03094 << std::endl;
03095
03096 }
03097
03098
03099
03100
03101 (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
03102
03103
03104 return true;
03105 }
03106
03115 bool L1GtTriggerMenuXmlParser::parseId(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
03116
03117 XERCES_CPP_NAMESPACE_USE
03118
03119 DOMNode* doc = parser->getDocument();
03120 DOMNode* n1 = doc->getFirstChild();
03121
03122
03123
03124 DOMNode* headerNode = n1->getFirstChild();
03125 if (headerNode == 0) {
03126 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef
03127 << "> tag found." << std::endl;
03128 return false;
03129 }
03130
03131 headerNode = findXMLChild(headerNode, m_xmlTagHeader);
03132 if (headerNode == 0) {
03133
03134 LogDebug("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagHeader
03135 << "> tag" << "\n - No header information." << std::endl;
03136
03137 } else {
03138
03139 DOMNode* idNode = headerNode->getFirstChild();
03140
03141
03142 idNode = findXMLChild(idNode, m_xmlTagMenuInterface);
03143 if (idNode == 0) {
03144
03145 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
03146 << m_xmlTagMenuInterface << "> tag"
03147 << "\n - Trigger menu interface name derived from file name." << std::endl;
03148
03149
03150
03151 size_t xmlPos = m_triggerMenuName.find("_L1T_Scales", 0);
03152 if (xmlPos == std::string::npos) {
03153 LogTrace("L1GtTriggerMenuXmlParser")
03154 << "\n Warning: Could not find \"_L1T_Scales\" " << "string in file name"
03155 << "\n - Trigger menu interface name set to file name." << std::endl;
03156 m_triggerMenuInterface = m_triggerMenuName;
03157
03158 } else {
03159 m_triggerMenuInterface = m_triggerMenuName;
03160 m_triggerMenuInterface.erase(
03161 m_triggerMenuInterface.begin(), m_triggerMenuInterface.begin() + xmlPos);
03162 }
03163
03164 } else {
03165 m_triggerMenuInterface = getXMLTextValue(idNode);
03166 }
03167
03168
03169 idNode = headerNode->getFirstChild();
03170 idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDate);
03171
03172 if (idNode == 0) {
03173
03174 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
03175 << m_xmlTagMenuInterfaceDate << "> tag" << "\n - No creation date."
03176 << m_triggerMenuInterfaceDate << std::endl;
03177
03178 } else {
03179
03180 m_triggerMenuInterfaceDate = getXMLTextValue(idNode);
03181 }
03182
03183
03184 idNode = headerNode->getFirstChild();
03185 idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceAuthor);
03186
03187 if (idNode == 0) {
03188
03189 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
03190 << m_xmlTagMenuInterfaceAuthor << "> tag" << "\n - No creation author."
03191 << m_triggerMenuInterfaceAuthor << std::endl;
03192
03193 } else {
03194
03195 m_triggerMenuInterfaceAuthor = getXMLTextValue(idNode);
03196 }
03197
03198
03199 idNode = headerNode->getFirstChild();
03200 idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDescription);
03201
03202 if (idNode == 0) {
03203
03204 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
03205 << m_xmlTagMenuInterfaceDescription << "> tag" << "\n - No description."
03206 << m_triggerMenuInterfaceDescription << std::endl;
03207
03208 } else {
03209
03210 m_triggerMenuInterfaceDescription = getXMLTextValue(idNode);
03211 }
03212
03213
03214 idNode = headerNode->getFirstChild();
03215 idNode = findXMLChild(idNode, m_xmlTagMenuDate);
03216
03217 if (idNode == 0) {
03218
03219 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
03220 << m_xmlTagMenuDate << "> tag" << "\n - No creation date."
03221 << m_triggerMenuDate << std::endl;
03222
03223 } else {
03224
03225 m_triggerMenuDate = getXMLTextValue(idNode);
03226 }
03227
03228
03229 idNode = headerNode->getFirstChild();
03230 idNode = findXMLChild(idNode, m_xmlTagMenuAuthor);
03231
03232 if (idNode == 0) {
03233
03234 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
03235 << m_xmlTagMenuAuthor << "> tag" << "\n - No creation author."
03236 << m_triggerMenuAuthor << std::endl;
03237
03238 } else {
03239
03240 m_triggerMenuAuthor = getXMLTextValue(idNode);
03241 }
03242
03243
03244 idNode = headerNode->getFirstChild();
03245 idNode = findXMLChild(idNode, m_xmlTagMenuDescription);
03246
03247 if (idNode == 0) {
03248
03249 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
03250 << m_xmlTagMenuDescription << "> tag" << "\n - No description."
03251 << m_triggerMenuDescription << std::endl;
03252
03253 } else {
03254
03255 m_triggerMenuDescription = getXMLTextValue(idNode);
03256 }
03257
03258
03259
03260 idNode = headerNode->getFirstChild();
03261
03262 idNode = findXMLChild(idNode, m_xmlTagMenuAlgImpl);
03263 if (idNode == 0) {
03264
03265 m_algorithmImplementation = "";
03266 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
03267 << m_xmlTagMenuAlgImpl << "> tag"
03268 << "\n - Algorithm implementation tag set to empty string." << std::endl;
03269
03270 } else {
03271
03272 m_algorithmImplementation = getXMLTextValue(idNode);
03273 }
03274
03275
03276
03277 idNode = headerNode->getFirstChild();
03278
03279 idNode = findXMLChild(idNode, m_xmlTagScaleDbKey);
03280 if (idNode == 0) {
03281
03282 m_scaleDbKey = "NULL";
03283 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <"
03284 << m_xmlTagScaleDbKey << "> tag" << "\n - Scale key set to " << m_scaleDbKey
03285 << " string." << std::endl;
03286
03287 } else {
03288 m_scaleDbKey = getXMLTextValue(idNode);
03289 }
03290
03291 }
03292
03293 LogDebug("L1GtTriggerMenuXmlParser")
03294 << "\n Parsed values from XML file"
03295 << "\nL1 MenuInterface: " << m_triggerMenuInterface
03296 << "\nL1 MenuInterface - Creation date: " << m_triggerMenuInterfaceDate
03297 << "\nL1 MenuInterface - Creation author: " << m_triggerMenuInterfaceAuthor
03298 << "\nL1 MenuInterface - Description: " << m_triggerMenuInterfaceDescription
03299 << "\n"
03300 << "\nAlgorithm implementation tag: " << m_algorithmImplementation
03301 << "\n"
03302 << "\nL1 Menu - Creation date: " << m_triggerMenuDate
03303 << "\nL1 Menu - Creation author: " << m_triggerMenuAuthor
03304 << "\nL1 Menu - Description: " << m_triggerMenuDescription
03305 << std::endl;
03306
03307
03308
03309
03310
03311
03312 std::string menuName = m_triggerMenuInterface + "/" + m_scaleDbKey + "/" + m_algorithmImplementation;
03313
03314 if (menuName != m_triggerMenuName) {
03315
03316 LogDebug("L1GtTriggerMenuXmlParser") << "\n Warning: Inconsistent L1 menu name:"
03317 << "\n from XML file name: " << m_triggerMenuName
03318 << "\n from XML tag: " << menuName << std::endl;
03319
03320 if (m_triggerMenuInterface != "") {
03321 if (m_scaleDbKey == "NULL") {
03322 m_triggerMenuName = m_triggerMenuInterface;
03323 } else {
03324 m_triggerMenuName = menuName;
03325 }
03326
03327 LogTrace("L1GtTriggerMenuXmlParser") << "\n L1 menu name set to value from XML tag!"
03328 << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
03329
03330 } else {
03331 LogTrace("L1GtTriggerMenuXmlParser") << "\n L1 menu name set to file name!"
03332 << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
03333
03334 }
03335 }
03336
03337
03338 return true;
03339 }
03340
03352 bool L1GtTriggerMenuXmlParser::workCondition(XERCES_CPP_NAMESPACE::DOMNode* node,
03353 const std::string& name, unsigned int chipNr) {
03354
03355 XERCES_CPP_NAMESPACE_USE
03356
03357
03358 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
03359 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
03360 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
03361
03362 if (condition.empty() || particle.empty() || type.empty() ) {
03363
03364 edm::LogError("L1GtTriggerMenuXmlParser") << "Missing attributes for condition " << name
03365 << std::endl;
03366
03367 return false;
03368 }
03369
03370
03371
03372
03373
03374
03375
03376 if (condition == m_xmlConditionAttrConditionMuon) {
03377 return parseMuon(node, name, chipNr);
03378 }
03379 else if (condition == m_xmlConditionAttrConditionCalo) {
03380 return parseCalo(node, name, chipNr);
03381 }
03382 else if (condition == m_xmlConditionAttrConditionEnergySum) {
03383 return parseEnergySum(node, name, chipNr);
03384 }
03385 else if (condition == m_xmlConditionAttrConditionJetCounts) {
03386 return parseJetCounts(node, name, chipNr);
03387 }
03388 else if (condition == m_xmlConditionAttrConditionCastor) {
03389 return parseCastor(node, name, chipNr);
03390 }
03391 else if (condition == m_xmlConditionAttrConditionHfBitCounts) {
03392 return parseHfBitCounts(node, name, chipNr);
03393 }
03394 else if (condition == m_xmlConditionAttrConditionHfRingEtSums) {
03395 return parseHfRingEtSums(node, name, chipNr);
03396 }
03397 else if (condition == m_xmlConditionAttrConditionBptx) {
03398 return parseBptx(node, name, chipNr);
03399 }
03400 else if (condition == m_xmlConditionAttrConditionExternal) {
03401 return parseExternal(node, name, chipNr);
03402 }
03403 else if (condition == m_xmlConditionAttrConditionCorrelation) {
03404 return parseCorrelation(node, name, chipNr);
03405 }
03406 else {
03407 edm::LogError("L1GtTriggerMenuXmlParser")
03408 << "\n Error: unknown condition (" << condition << ")"
03409 << std::endl;
03410
03411 return false;
03412 }
03413
03414 return true;
03415
03416 }
03417
03428 bool L1GtTriggerMenuXmlParser::parseConditions(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
03429
03430 XERCES_CPP_NAMESPACE_USE
03431
03432 LogTrace("L1GtTriggerMenuXmlParser") << "\nParsing conditions" << std::endl;
03433
03434 DOMNode* doc = parser->getDocument();
03435 DOMNode* n1 = doc->getFirstChild();
03436
03437
03438
03439 DOMNode* chipNode = n1->getFirstChild();
03440 if (chipNode == 0) {
03441
03442 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef
03443 << "> tag found." << std::endl;
03444
03445 return false;
03446 }
03447
03448
03449
03450 std::string chipName;
03451 chipNode = findXMLChild(chipNode, m_xmlTagChip, true, &chipName);
03452 if (chipNode == 0) {
03453
03454 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: Could not find <" << m_xmlTagChip
03455 << "> tag" << std::endl;
03456
03457 return false;
03458 }
03459
03460 unsigned int chipNr = 0;
03461 do {
03462
03463
03464 DOMNode* conditionsNode = chipNode->getFirstChild();
03465 conditionsNode = findXMLChild(conditionsNode, m_xmlTagConditions);
03466 if (conditionsNode == 0) {
03467
03468 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No <" << m_xmlTagConditions
03469 << "> child found in Chip " << chipName << std::endl;
03470
03471 return false;
03472 }
03473
03474 char* nodeName = XMLString::transcode(chipNode->getNodeName());
03475
03476
03477
03478
03479 XMLString::release(&nodeName);
03480
03481
03482 DOMNode* conditionNameNode = conditionsNode->getFirstChild();
03483 std::string conditionNameNodeName;
03484 conditionNameNode = findXMLChild(conditionNameNode, "", true, &conditionNameNodeName);
03485 while (conditionNameNode != 0) {
03486
03487 LogTrace("L1GtTriggerMenuXmlParser")
03488 << "\n Found a condition with name: " << conditionNameNodeName
03489 << std::endl;
03490
03491 if ( !workCondition(conditionNameNode, conditionNameNodeName, chipNr) ) {
03492 return false;
03493 }
03494 conditionNameNode = findXMLChild(conditionNameNode->getNextSibling(), "", true,
03495 &conditionNameNodeName);
03496
03497 }
03498
03499 chipNode = findXMLChild(chipNode->getNextSibling(), m_xmlTagChip, true, &chipName);
03500 chipNr++;
03501
03502 } while (chipNode != 0 && chipNr < m_numberConditionChips);
03503
03504 return true;
03505 }
03506
03518 bool L1GtTriggerMenuXmlParser::workAlgorithm(XERCES_CPP_NAMESPACE::DOMNode* node,
03519 const std::string& algName, unsigned int chipNr) {
03520
03521 XERCES_CPP_NAMESPACE_USE
03522
03523 if (node == 0) {
03524 LogDebug("L1GtTriggerMenuXmlParser")
03525 << " Node is 0 in " << __PRETTY_FUNCTION__
03526 << " can not parse the algorithm " << algName
03527 << std::endl;
03528 return false;
03529 }
03530
03531
03532 std::string algAlias = getXMLAttribute(node, m_xmlAlgorithmAttrAlias);
03533
03534 if (algAlias == "") {
03535 algAlias = algName;
03536 LogDebug("L1GtTriggerMenuXmlParser")
03537 << "\n No alias defined for algorithm. Alias set to algorithm name."
03538 << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
03539 << std::endl;
03540 } else {
03541 LogDebug("L1GtTriggerMenuXmlParser") << "\n Alias defined for algorithm."
03542 << "\n Algorithm name: " << algName << "\n Algorithm alias: " << algAlias
03543 << std::endl;
03544 }
03545
03546
03547 std::string logExpression = getXMLTextValue(node);
03548
03549
03550
03551
03552
03553
03554
03555
03556
03557
03558 DOMNode* pinNode = findXMLChild(node->getFirstChild(), m_xmlTagOutput);
03559 std::string pinString;
03560 int outputPin = 0;
03561
03562 pinNode = node->getFirstChild();
03563 if ( (pinNode = findXMLChild(pinNode, m_xmlTagOutputPin) ) != 0) {
03564 pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
03565
03566
03567 std::istringstream opStream(pinString);
03568
03569 if ((opStream >> outputPin).fail()) {
03570 LogDebug("L1GtTriggerMenuXmlParser")
03571 << " Unable to convert pin string " << pinString
03572 << " to int for algorithm : " << algName
03573 << std::endl;
03574
03575 return false;
03576 }
03577
03578 }
03579
03580 if (pinNode == 0) {
03581 LogTrace("L1GtTriggerMenuXmlParser") << " Warning: No pin number found for algorithm: "
03582 << algName << std::endl;
03583
03584 return false;
03585 }
03586
03587
03588
03589
03590
03591
03592
03593
03594 int bitNumber = outputPin + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
03595
03596
03597
03598
03599
03600
03601 L1GtAlgorithm alg(algName, logExpression, bitNumber);
03602 alg.setAlgoChipNumber(static_cast<int>(chipNr));
03603 alg.setAlgoAlias(algAlias);
03604
03605 if (edm::isDebugEnabled() ) {
03606
03607 std::ostringstream myCoutStream;
03608 alg.print(myCoutStream);
03609 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
03610
03611 }
03612
03613
03614 if ( !insertAlgorithmIntoMap(alg)) {
03615
03616 return false;
03617 }
03618
03619 return true;
03620
03621 }
03622
03623
03624
03625
03626
03627
03628
03629
03630
03631
03632
03633
03634
03635
03636 bool L1GtTriggerMenuXmlParser::parseAlgorithms(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
03637
03638 XERCES_CPP_NAMESPACE_USE
03639
03640
03641
03642 DOMNode* doc = parser->getDocument();
03643 DOMNode* node = doc->getFirstChild();
03644
03645 DOMNode* chipNode = node->getFirstChild();
03646 if (chipNode == 0) {
03647 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: No child found for " << m_xmlTagDef
03648 << std::endl;
03649 return false;
03650 }
03651
03652
03653 std::string chipName;
03654 chipNode = findXMLChild(chipNode, m_xmlTagChip, true, &chipName);
03655 if (chipNode == 0) {
03656 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: Could not find <" << m_xmlTagChip
03657 << std::endl;
03658 return false;
03659 }
03660
03661 unsigned int chipNr = 0;
03662 do {
03663
03664
03665
03666 std::string nodeName = m_xmlTagChip + chipName;
03667
03668
03669
03670
03671
03672 DOMNode* algNode = chipNode->getFirstChild();
03673 algNode = findXMLChild(algNode, m_xmlTagAlgorithms);
03674 if (algNode == 0) {
03675 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: No <" << m_xmlTagAlgorithms
03676 << "> child found in chip " << chipName << std::endl;
03677 return false;
03678 }
03679
03680
03681 DOMNode* algNameNode = algNode->getFirstChild();
03682 std::string algNameNodeName;
03683 algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
03684
03685 while (algNameNode != 0) {
03686
03687
03688
03689
03690 if ( !workAlgorithm(algNameNode, algNameNodeName, chipNr)) {
03691 return false;
03692 }
03693
03694 algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true, &algNameNodeName);
03695
03696 }
03697
03698
03699 chipNode = findXMLChild(chipNode->getNextSibling(), m_xmlTagChip, true, &chipName);
03700 chipNr++;
03701
03702 } while (chipNode != 0 && chipNr < m_numberConditionChips);
03703
03704 return true;
03705 }
03706
03717 bool L1GtTriggerMenuXmlParser::workTechTrigger(XERCES_CPP_NAMESPACE::DOMNode* node,
03718 const std::string& algName) {
03719
03720 XERCES_CPP_NAMESPACE_USE
03721
03722 if (node == 0) {
03723 LogDebug("L1GtTriggerMenuXmlParser")
03724 << " Node is 0 in " << __PRETTY_FUNCTION__
03725 << " can not parse the technical trigger " << algName
03726 << std::endl;
03727 return false;
03728 }
03729
03730
03731 std::string logExpression = getXMLTextValue(node);
03732
03733
03734
03735
03736
03737
03738 DOMNode* pinNode = findXMLChild(node->getFirstChild(), m_xmlTagOutput);
03739 std::string pinString;
03740 int outputPin = 0;
03741
03742 pinNode = node->getFirstChild();
03743 if ( (pinNode = findXMLChild(pinNode, m_xmlTagOutputPin) ) != 0) {
03744 pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
03745
03746
03747 std::istringstream opStream(pinString);
03748
03749 if ((opStream >> outputPin).fail()) {
03750 LogDebug("L1GtTriggerMenuXmlParser")
03751 << " Unable to convert pin string " << pinString
03752 << " to int for technical trigger : " << algName
03753 << std::endl;
03754
03755 return false;
03756 }
03757
03758 }
03759
03760 if (pinNode == 0) {
03761 LogTrace("L1GtTriggerMenuXmlParser")
03762 << " Warning: No pin number found for technical trigger: "
03763 << algName << std::endl;
03764
03765 return false;
03766 }
03767
03768
03769 int bitNumber = outputPin;
03770
03771
03772
03773
03774
03775
03776
03777 L1GtAlgorithm alg(algName, logExpression, bitNumber);
03778 alg.setAlgoAlias(algName);
03779
03780 if (edm::isDebugEnabled() ) {
03781
03782 std::ostringstream myCoutStream;
03783 alg.print(myCoutStream);
03784 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
03785
03786 }
03787
03788
03789 if ( !insertTechTriggerIntoMap(alg)) {
03790
03791 return false;
03792 }
03793
03794 return true;
03795
03796 }
03797
03798
03799
03800
03801
03802
03803
03804
03805
03806
03807 bool L1GtTriggerMenuXmlParser::parseTechTriggers(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
03808
03809 XERCES_CPP_NAMESPACE_USE
03810
03811
03812
03813 DOMNode* doc = parser->getDocument();
03814 DOMNode* node = doc->getFirstChild();
03815
03816 DOMNode* algNode = node->getFirstChild();
03817 if (algNode == 0) {
03818 edm::LogError("L1GtTriggerMenuXmlParser")
03819 << " Error: No child found for " << m_xmlTagDef << std::endl;
03820 return false;
03821 }
03822
03823 algNode = findXMLChild(algNode, m_xmlTagTechTriggers);
03824 if (algNode == 0) {
03825 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: No <"
03826 << m_xmlTagTechTriggers << "> child found."
03827 << std::endl;
03828 return false;
03829 }
03830
03831
03832 DOMNode* algNameNode = algNode->getFirstChild();
03833 std::string algNameNodeName;
03834 algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
03835
03836 while (algNameNode != 0) {
03837
03838
03839
03840
03841 if ( !workTechTrigger(algNameNode, algNameNodeName)) {
03842 return false;
03843 }
03844
03845 algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true,
03846 &algNameNodeName);
03847
03848 }
03849
03850 return true;
03851 }
03852
03853
03862 bool L1GtTriggerMenuXmlParser::workXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
03863
03864 XERCES_CPP_NAMESPACE_USE
03865
03866 DOMDocument* doc = parser->getDocument();
03867 DOMNode* n1 = doc->getFirstChild();
03868
03869 if (n1 == 0) {
03870
03871 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: Found no XML child" << std::endl;
03872
03873 return false;
03874 }
03875
03876 char* nodeName = XMLString::transcode(n1->getNodeName());
03877
03878 if (XMLString::compareIString(nodeName, m_xmlTagDef.c_str())) {
03879
03880 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: First XML child is not \" "
03881 << m_xmlTagDef << "\" " << std::endl;
03882
03883 return false;
03884 }
03885
03886 LogTrace("L1GtTriggerMenuXmlParser")
03887 << "\nFirst node name is: " << nodeName
03888 << std::endl;
03889 XMLString::release(&nodeName);
03890
03891
03892 clearMaps();
03893
03894 if ( !parseId(parser) ) {
03895 clearMaps();
03896 return false;
03897 }
03898
03899
03900 if ( !parseConditions(parser) ) {
03901 clearMaps();
03902 return false;
03903 }
03904
03905 if ( !parseAlgorithms(parser) ) {
03906 clearMaps();
03907 return false;
03908 }
03909
03910 if ( !parseTechTriggers(parser) ) {
03911 clearMaps();
03912 return false;
03913 }
03914
03915 return true;
03916
03917 }
03918
03919
03920
03921