File indexing completed on 2024-10-08 05:11:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtTriggerMenuXmlParser.h"
0017
0018
0019 #include <string>
0020 #include <vector>
0021
0022 #include <iostream>
0023 #include <fstream>
0024 #include <iomanip>
0025
0026
0027
0028 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtXmlParserTags.h"
0029
0030 #include "CondFormats/L1TObjects/interface/L1GtCondition.h"
0031 #include "CondFormats/L1TObjects/interface/L1GtAlgorithm.h"
0032
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0035 #include "Utilities/Xerces/interface/Xerces.h"
0036 #include <cstdint>
0037
0038
0039 L1GtTriggerMenuXmlParser::L1GtTriggerMenuXmlParser()
0040 : L1GtXmlParserTags(),
0041 m_xmlErrHandler(nullptr),
0042 m_triggerMenuInterface("NULL"),
0043 m_triggerMenuName("NULL"),
0044 m_triggerMenuImplementation("NULL"),
0045 m_scaleDbKey("NULL")
0046
0047 {
0048
0049
0050
0051 }
0052
0053
0054 L1GtTriggerMenuXmlParser::~L1GtTriggerMenuXmlParser() { clearMaps(); }
0055
0056
0057 void L1GtTriggerMenuXmlParser::setGtNumberConditionChips(const unsigned int& numberConditionChipsValue) {
0058 m_numberConditionChips = numberConditionChipsValue;
0059 }
0060
0061
0062 void L1GtTriggerMenuXmlParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
0063 m_pinsOnConditionChip = pinsOnConditionChipValue;
0064 }
0065
0066
0067
0068 void L1GtTriggerMenuXmlParser::setGtOrderConditionChip(const std::vector<int>& orderConditionChipValue) {
0069 m_orderConditionChip = orderConditionChipValue;
0070 }
0071
0072
0073 void L1GtTriggerMenuXmlParser::setGtNumberPhysTriggers(const unsigned int& numberPhysTriggersValue) {
0074 m_numberPhysTriggers = numberPhysTriggersValue;
0075 }
0076
0077
0078 void L1GtTriggerMenuXmlParser::setGtNumberTechTriggers(const unsigned int& numberTechTriggersValue) {
0079 m_numberTechTriggers = numberTechTriggersValue;
0080 }
0081
0082
0083 void L1GtTriggerMenuXmlParser::setGtNumberL1JetCounts(const unsigned int& numberL1JetCountsValue) {
0084 m_numberL1JetCounts = numberL1JetCountsValue;
0085 }
0086
0087
0088 void L1GtTriggerMenuXmlParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) { m_conditionMap = condMap; }
0089
0090
0091 void L1GtTriggerMenuXmlParser::setGtTriggerMenuInterface(const std::string& menuInterface) {
0092 m_triggerMenuInterface = menuInterface;
0093 }
0094
0095 void L1GtTriggerMenuXmlParser::setGtTriggerMenuName(const std::string& menuName) { m_triggerMenuName = menuName; }
0096
0097 void L1GtTriggerMenuXmlParser::setGtTriggerMenuImplementation(const std::string& menuImplementation) {
0098 m_triggerMenuImplementation = menuImplementation;
0099 }
0100
0101
0102 void L1GtTriggerMenuXmlParser::setGtScaleDbKey(const std::string& scaleKey) { m_scaleDbKey = scaleKey; }
0103
0104
0105 void L1GtTriggerMenuXmlParser::setVecMuonTemplate(const std::vector<std::vector<L1GtMuonTemplate> >& vecMuonTempl) {
0106 m_vecMuonTemplate = vecMuonTempl;
0107 }
0108
0109 void L1GtTriggerMenuXmlParser::setVecCaloTemplate(const std::vector<std::vector<L1GtCaloTemplate> >& vecCaloTempl) {
0110 m_vecCaloTemplate = vecCaloTempl;
0111 }
0112
0113 void L1GtTriggerMenuXmlParser::setVecEnergySumTemplate(
0114 const std::vector<std::vector<L1GtEnergySumTemplate> >& vecEnergySumTempl) {
0115 m_vecEnergySumTemplate = vecEnergySumTempl;
0116 }
0117
0118 void L1GtTriggerMenuXmlParser::setVecJetCountsTemplate(
0119 const std::vector<std::vector<L1GtJetCountsTemplate> >& vecJetCountsTempl) {
0120 m_vecJetCountsTemplate = vecJetCountsTempl;
0121 }
0122
0123 void L1GtTriggerMenuXmlParser::setVecCastorTemplate(
0124 const std::vector<std::vector<L1GtCastorTemplate> >& vecCastorTempl) {
0125 m_vecCastorTemplate = vecCastorTempl;
0126 }
0127
0128 void L1GtTriggerMenuXmlParser::setVecHfBitCountsTemplate(
0129 const std::vector<std::vector<L1GtHfBitCountsTemplate> >& vecHfBitCountsTempl) {
0130 m_vecHfBitCountsTemplate = vecHfBitCountsTempl;
0131 }
0132
0133 void L1GtTriggerMenuXmlParser::setVecHfRingEtSumsTemplate(
0134 const std::vector<std::vector<L1GtHfRingEtSumsTemplate> >& vecHfRingEtSumsTempl) {
0135 m_vecHfRingEtSumsTemplate = vecHfRingEtSumsTempl;
0136 }
0137
0138 void L1GtTriggerMenuXmlParser::setVecBptxTemplate(const std::vector<std::vector<L1GtBptxTemplate> >& vecBptxTempl) {
0139 m_vecBptxTemplate = vecBptxTempl;
0140 }
0141
0142 void L1GtTriggerMenuXmlParser::setVecExternalTemplate(
0143 const std::vector<std::vector<L1GtExternalTemplate> >& vecExternalTempl) {
0144 m_vecExternalTemplate = vecExternalTempl;
0145 }
0146
0147 void L1GtTriggerMenuXmlParser::setVecCorrelationTemplate(
0148 const std::vector<std::vector<L1GtCorrelationTemplate> >& vecCorrelationTempl) {
0149 m_vecCorrelationTemplate = vecCorrelationTempl;
0150 }
0151
0152
0153
0154 void L1GtTriggerMenuXmlParser::setCorMuonTemplate(const std::vector<std::vector<L1GtMuonTemplate> >& corMuonTempl) {
0155 m_corMuonTemplate = corMuonTempl;
0156 }
0157
0158 void L1GtTriggerMenuXmlParser::setCorCaloTemplate(const std::vector<std::vector<L1GtCaloTemplate> >& corCaloTempl) {
0159 m_corCaloTemplate = corCaloTempl;
0160 }
0161
0162 void L1GtTriggerMenuXmlParser::setCorEnergySumTemplate(
0163 const std::vector<std::vector<L1GtEnergySumTemplate> >& corEnergySumTempl) {
0164 m_corEnergySumTemplate = corEnergySumTempl;
0165 }
0166
0167
0168 void L1GtTriggerMenuXmlParser::setGtAlgorithmMap(const AlgorithmMap& algoMap) { m_algorithmMap = algoMap; }
0169
0170
0171 void L1GtTriggerMenuXmlParser::setGtAlgorithmAliasMap(const AlgorithmMap& algoMap) { m_algorithmAliasMap = algoMap; }
0172
0173
0174 void L1GtTriggerMenuXmlParser::setGtTechnicalTriggerMap(const AlgorithmMap& ttMap) { m_technicalTriggerMap = ttMap; }
0175
0176
0177
0178
0179 void L1GtTriggerMenuXmlParser::parseXmlFile(const std::string& defXmlFile, const std::string& vmeXmlFile) {
0180 XERCES_CPP_NAMESPACE_USE
0181
0182
0183
0184 m_conditionMap.resize(m_numberConditionChips);
0185
0186 m_vecMuonTemplate.resize(m_numberConditionChips);
0187 m_vecCaloTemplate.resize(m_numberConditionChips);
0188 m_vecEnergySumTemplate.resize(m_numberConditionChips);
0189 m_vecJetCountsTemplate.resize(m_numberConditionChips);
0190 m_vecCastorTemplate.resize(m_numberConditionChips);
0191 m_vecHfBitCountsTemplate.resize(m_numberConditionChips);
0192 m_vecHfRingEtSumsTemplate.resize(m_numberConditionChips);
0193 m_vecBptxTemplate.resize(m_numberConditionChips);
0194 m_vecExternalTemplate.resize(m_numberConditionChips);
0195
0196 m_vecCorrelationTemplate.resize(m_numberConditionChips);
0197 m_corMuonTemplate.resize(m_numberConditionChips);
0198 m_corCaloTemplate.resize(m_numberConditionChips);
0199 m_corEnergySumTemplate.resize(m_numberConditionChips);
0200
0201
0202
0203
0204
0205 m_triggerMenuName = defXmlFile;
0206 size_t xmlPos = m_triggerMenuName.find_last_of('/');
0207 m_triggerMenuName.erase(m_triggerMenuName.begin(), m_triggerMenuName.begin() + xmlPos + 1);
0208
0209 xmlPos = m_triggerMenuName.find_last_of('.');
0210 m_triggerMenuName.erase(m_triggerMenuName.begin() + xmlPos, m_triggerMenuName.end());
0211
0212
0213 m_xmlErrHandler = nullptr;
0214
0215 XercesDOMParser* parser;
0216
0217 LogTrace("L1GtTriggerMenuXmlParser") << "\nOpening XML-File: \n " << defXmlFile << std::endl;
0218
0219 if ((parser = initXML(defXmlFile)) != nullptr) {
0220 workXML(parser);
0221 }
0222 cleanupXML(parser);
0223 }
0224
0225
0226
0227 void L1GtTriggerMenuXmlParser::setGtTriggerMenuInterfaceDate(const std::string& val) {
0228 m_triggerMenuInterfaceDate = val;
0229 }
0230
0231 void L1GtTriggerMenuXmlParser::setGtTriggerMenuInterfaceAuthor(const std::string& val) {
0232 m_triggerMenuInterfaceAuthor = val;
0233 }
0234
0235 void L1GtTriggerMenuXmlParser::setGtTriggerMenuInterfaceDescription(const std::string& val) {
0236 m_triggerMenuInterfaceDescription = val;
0237 }
0238
0239 void L1GtTriggerMenuXmlParser::setGtTriggerMenuDate(const std::string& val) { m_triggerMenuDate = val; }
0240
0241 void L1GtTriggerMenuXmlParser::setGtTriggerMenuAuthor(const std::string& val) { m_triggerMenuAuthor = val; }
0242
0243 void L1GtTriggerMenuXmlParser::setGtTriggerMenuDescription(const std::string& val) { m_triggerMenuDescription = val; }
0244
0245 void L1GtTriggerMenuXmlParser::setGtAlgorithmImplementation(const std::string& val) { m_algorithmImplementation = val; }
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258 XERCES_CPP_NAMESPACE::XercesDOMParser* L1GtTriggerMenuXmlParser::initXML(const std::string& xmlFile) {
0259 XERCES_CPP_NAMESPACE_USE
0260
0261
0262 try {
0263 cms::concurrency::xercesInitialize();
0264 } catch (const XMLException& toCatch) {
0265 char* message = XMLString::transcode(toCatch.getMessage());
0266
0267 edm::LogError("L1GtTriggerMenuXmlParser") << "Error during Xerces-c initialization! :" << message << std::endl;
0268
0269 XMLString::release(&message);
0270 return nullptr;
0271 }
0272
0273 XercesDOMParser* parser = new XercesDOMParser();
0274 parser->setValidationScheme(XercesDOMParser::Val_Always);
0275 parser->setDoNamespaces(false);
0276
0277 if (m_xmlErrHandler == nullptr) {
0278 m_xmlErrHandler = (ErrorHandler*)new HandlerBase();
0279 } else {
0280
0281 }
0282 parser->setErrorHandler(m_xmlErrHandler);
0283
0284
0285 try {
0286 parser->parse(xmlFile.c_str());
0287 } catch (const XMLException& toCatch) {
0288 char* message = XMLString::transcode(toCatch.getMessage());
0289
0290 edm::LogError("L1GtTriggerMenuXmlParser") << "Exception while parsing XML: \n" << message << std::endl;
0291
0292 XMLString::release(&message);
0293 delete parser;
0294 delete m_xmlErrHandler;
0295 m_xmlErrHandler = nullptr;
0296 return nullptr;
0297 } catch (const DOMException& toCatch) {
0298 char* message = XMLString::transcode(toCatch.msg);
0299
0300 edm::LogError("L1GtTriggerMenuXmlParser") << "DOM-Exception while parsing XML: \n" << message << std::endl;
0301
0302 XMLString::release(&message);
0303 delete parser;
0304 delete m_xmlErrHandler;
0305 m_xmlErrHandler = nullptr;
0306 return nullptr;
0307 } catch (...) {
0308 edm::LogError("L1GtTriggerMenuXmlParser") << "Unexpected Exception while parsing XML!" << std::endl;
0309
0310 delete parser;
0311 delete m_xmlErrHandler;
0312 m_xmlErrHandler = nullptr;
0313 return nullptr;
0314 }
0315
0316 return parser;
0317 }
0318
0319
0320 XERCES_CPP_NAMESPACE::DOMNode* L1GtTriggerMenuXmlParser::findXMLChild(XERCES_CPP_NAMESPACE::DOMNode* startChild,
0321 const std::string& tagName,
0322 bool beginOnly,
0323 std::string* rest) {
0324 XERCES_CPP_NAMESPACE_USE
0325
0326 char* nodeName = nullptr;
0327
0328 DOMNode* n1 = startChild;
0329 if (n1 == nullptr) {
0330 return nullptr;
0331 }
0332
0333 if (!tagName.empty()) {
0334 nodeName = XMLString::transcode(n1->getNodeName());
0335
0336 if (!beginOnly) {
0337
0338 while (XMLString::compareIString(nodeName, tagName.c_str())) {
0339 XMLString::release(&nodeName);
0340 n1 = n1->getNextSibling();
0341 if (n1 == nullptr) {
0342 break;
0343 }
0344
0345 nodeName = XMLString::transcode(n1->getNodeName());
0346 }
0347 } else {
0348
0349 while (XMLString::compareNIString(nodeName, tagName.c_str(), tagName.length())) {
0350 XMLString::release(&nodeName);
0351 n1 = n1->getNextSibling();
0352 if (n1 == nullptr) {
0353 break;
0354 }
0355
0356 nodeName = XMLString::transcode(n1->getNodeName());
0357 }
0358 if (n1 != nullptr && rest != nullptr) {
0359 *rest = std::string(nodeName).substr(tagName.length(), strlen(nodeName) - tagName.length());
0360 }
0361 }
0362 } else {
0363 while (n1->getNodeType() != DOMNode::ELEMENT_NODE) {
0364 n1 = n1->getNextSibling();
0365 if (n1 == nullptr) {
0366 break;
0367 }
0368 }
0369 if (n1 != nullptr && rest != nullptr) {
0370 nodeName = XMLString::transcode(n1->getNodeName());
0371 *rest = std::string(nodeName);
0372 }
0373 }
0374
0375 XMLString::release(&nodeName);
0376
0377 return n1;
0378 }
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389 std::string L1GtTriggerMenuXmlParser::getXMLAttribute(const XERCES_CPP_NAMESPACE::DOMNode* node,
0390 const std::string& name) {
0391 XERCES_CPP_NAMESPACE_USE
0392
0393 std::string ret;
0394
0395
0396 DOMNamedNodeMap* attributes = node->getAttributes();
0397 if (attributes == nullptr) {
0398 return ret;
0399 }
0400
0401
0402 XMLCh* attrName = XMLString::transcode(name.c_str());
0403 DOMNode* attribNode = attributes->getNamedItem(attrName);
0404
0405 XMLString::release(&attrName);
0406 if (attribNode == nullptr) {
0407 return ret;
0408 }
0409
0410 char* retCstr = XMLString::transcode(attribNode->getNodeValue());
0411 ret = retCstr;
0412 XMLString::release(&retCstr);
0413
0414 return ret;
0415 }
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425 std::string L1GtTriggerMenuXmlParser::getXMLTextValue(XERCES_CPP_NAMESPACE::DOMNode* node) {
0426 XERCES_CPP_NAMESPACE_USE
0427
0428 std::string ret;
0429
0430 DOMNode* n1 = node;
0431 if (n1 == nullptr) {
0432 return ret;
0433 }
0434
0435 const XMLCh* retXmlCh = n1->getTextContent();
0436 if (retXmlCh == nullptr) {
0437 return ret;
0438 }
0439
0440 char* retCstr = XMLString::transcode(retXmlCh);
0441 XMLString::trim(retCstr);
0442
0443 ret = retCstr;
0444 XMLString::release(&retCstr);
0445
0446 return ret;
0447 }
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459 bool L1GtTriggerMenuXmlParser::hexString2UInt128(const std::string& hexString, uint64_t& dstL, uint64_t& dstH) {
0460
0461 static const std::string valid_hex_start("0123456789ABCDEFabcdef");
0462
0463
0464 static const std::string valid_hex_end("0123456789ABCDEFabcdef");
0465
0466 std::string tempStr = hexString;
0467
0468
0469 unsigned int hexStart = tempStr.find_first_of(valid_hex_start);
0470 unsigned int hexEnd = tempStr.find_first_not_of(valid_hex_end, hexStart);
0471
0472 if (hexStart == hexEnd) {
0473 LogDebug("L1GtTriggerMenuXmlParser") << "No hex value found in: " << tempStr << std::endl;
0474
0475 return false;
0476 }
0477
0478 tempStr = tempStr.substr(hexStart, hexEnd - hexStart);
0479
0480 if (tempStr.empty()) {
0481 LogDebug("L1GtTriggerMenuXmlParser") << "Empty value in " << __PRETTY_FUNCTION__ << std::endl;
0482
0483 return false;
0484 }
0485
0486
0487 std::string tempStrH, tempStrL;
0488
0489 if (tempStr.length() > 16) {
0490 tempStrL = tempStr.substr(tempStr.length() - 16, 16);
0491 tempStrH = tempStr.substr(0, tempStr.length() - 16);
0492 } else {
0493 tempStrL = tempStr;
0494 tempStrH = "0";
0495 }
0496
0497
0498 char* endPtr = (char*)tempStrL.c_str();
0499 uint64_t tempUIntL = strtoull(tempStrL.c_str(), &endPtr, 16);
0500
0501 if (*endPtr != 0) {
0502 LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex." << std::endl;
0503
0504 return false;
0505 }
0506
0507
0508 endPtr = (char*)tempStrH.c_str();
0509 uint64_t tempUIntH = strtoull(tempStrH.c_str(), &endPtr, 16);
0510
0511 if (*endPtr != 0) {
0512 LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << tempStr << " to hex." << std::endl;
0513
0514 return false;
0515 }
0516
0517 dstL = tempUIntL;
0518 dstH = tempUIntH;
0519
0520 return true;
0521 }
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533 bool L1GtTriggerMenuXmlParser::getXMLHexTextValue128(XERCES_CPP_NAMESPACE::DOMNode* node,
0534 uint64_t& dstL,
0535 uint64_t& dstH) {
0536 if (node == nullptr) {
0537 LogDebug("L1GtTriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
0538
0539 return false;
0540 }
0541
0542 uint64_t tempUIntH, tempUIntL;
0543
0544 std::string tempStr = getXMLTextValue(node);
0545 if (!hexString2UInt128(tempStr, tempUIntL, tempUIntH)) {
0546 return false;
0547 }
0548
0549 dstL = tempUIntL;
0550 dstH = tempUIntH;
0551
0552 return true;
0553 }
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566 bool L1GtTriggerMenuXmlParser::getXMLHexTextValue(XERCES_CPP_NAMESPACE::DOMNode* node, uint64_t& dst) {
0567 uint64_t dummyH;
0568 uint64_t tempUInt;
0569
0570 if (!getXMLHexTextValue128(node, tempUInt, dummyH)) {
0571 return false;
0572 }
0573
0574 if (dummyH != 0) {
0575 edm::LogError("L1GtTriggerMenuXmlParser") << "Too large hex-value!" << std::endl;
0576 return false;
0577 }
0578
0579 dst = tempUInt;
0580
0581 return true;
0582 }
0583
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595 bool L1GtTriggerMenuXmlParser::countConditionChildMaxBits(XERCES_CPP_NAMESPACE::DOMNode* node,
0596 const std::string& childName,
0597 unsigned int& dst) {
0598 XERCES_CPP_NAMESPACE_USE
0599
0600
0601 if (node == nullptr) {
0602 LogDebug("L1GtTriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
0603
0604 return false;
0605 }
0606
0607 DOMNode* n1 = findXMLChild(node->getFirstChild(), childName);
0608
0609 if (n1 == nullptr) {
0610 LogDebug("L1GtTriggerMenuXmlParser") << "Child of condition not found ( " << childName << ")" << std::endl;
0611
0612 return false;
0613 }
0614
0615 DOMNode* n2 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
0616
0617 if (n2 == nullptr) {
0618 LogDebug("L1GtTriggerMenuXmlParser") << "No value tag found for child " << childName << " in "
0619 << __PRETTY_FUNCTION__ << std::endl;
0620
0621 return false;
0622 }
0623
0624
0625 std::string maxString = getXMLAttribute(n1, m_xmlAttrMax);
0626
0627 if (maxString.empty()) {
0628 maxString = getXMLAttribute(n2, m_xmlAttrMax);
0629
0630 if (maxString.empty()) {
0631 LogDebug("L1GtTriggerMenuXmlParser") << "No Max value found for " << childName << std::endl;
0632
0633 return false;
0634 }
0635 }
0636
0637
0638
0639 uint64_t maxBitsL, maxBitsH;
0640 if (!hexString2UInt128(maxString, maxBitsL, maxBitsH)) {
0641 return false;
0642 }
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653 unsigned int counter = 0;
0654
0655 while (maxBitsL != 0) {
0656
0657 if ((maxBitsL & 1) == 0) {
0658 edm::LogError("L1GtTriggerMenuXmlParser") << " Confused by not continous set bits for max value "
0659 << maxString << "(child=" << childName << ")" << std::endl;
0660
0661 return false;
0662 }
0663
0664 maxBitsL >>= 1;
0665 counter++;
0666 }
0667
0668 if ((maxBitsH != 0) && (counter != 64)) {
0669 edm::LogError("L1GtTriggerMenuXmlParser") << " Confused by not continous set bits for max value " << maxString
0670 << "(child=" << childName << ")" << std::endl;
0671
0672 return false;
0673 }
0674
0675 while (maxBitsH != 0) {
0676
0677 if ((maxBitsH & 1) == 0) {
0678 edm::LogError("L1GtTriggerMenuXmlParser") << " Confused by not continous set bits for max value "
0679 << maxString << "(child=" << childName << ")" << std::endl;
0680
0681 return false;
0682 }
0683
0684 maxBitsH >>= 1;
0685 counter++;
0686 }
0687
0688 dst = counter;
0689 return true;
0690 }
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703 bool L1GtTriggerMenuXmlParser::getConditionChildValues(XERCES_CPP_NAMESPACE::DOMNode* node,
0704 const std::string& childName,
0705 unsigned int num,
0706 std::vector<uint64_t>& dst) {
0707 XERCES_CPP_NAMESPACE_USE
0708
0709 if (node == nullptr) {
0710 LogDebug("L1GtTriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
0711
0712 return false;
0713 }
0714
0715 DOMNode* n1 = findXMLChild(node->getFirstChild(), childName);
0716
0717
0718 if (n1 == nullptr) {
0719 LogDebug("L1GtTriggerMenuXmlParser") << "Child of condition not found ( " << childName << ")" << std::endl;
0720
0721 return false;
0722 }
0723
0724
0725 if (num == 0) {
0726 return true;
0727 }
0728
0729
0730 dst.reserve(num);
0731
0732
0733 n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
0734 for (unsigned int i = 0; i < num; i++) {
0735 if (n1 == nullptr) {
0736 LogDebug("L1GtTriggerMenuXmlParser")
0737 << "Not enough values in condition child ( " << childName << ")" << std::endl;
0738
0739 return false;
0740 }
0741
0742 if (!getXMLHexTextValue(n1, dst[i])) {
0743 edm::LogError("L1GtTriggerMenuXmlParser")
0744 << "Error converting condition child ( " << childName << ") value." << std::endl;
0745
0746 return false;
0747 }
0748
0749 n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue);
0750 }
0751
0752 return true;
0753 }
0754
0755
0756
0757
0758
0759
0760
0761
0762 void L1GtTriggerMenuXmlParser::cleanupXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
0763 XERCES_CPP_NAMESPACE_USE
0764
0765 if (parser != nullptr) {
0766 delete parser;
0767 }
0768
0769 if (m_xmlErrHandler != nullptr) {
0770 delete m_xmlErrHandler;
0771 m_xmlErrHandler = nullptr;
0772 }
0773
0774 cms::concurrency::xercesTerminate();
0775 }
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787
0788 bool L1GtTriggerMenuXmlParser::parseVmeXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
0789 XERCES_CPP_NAMESPACE_USE
0790
0791 DOMDocument* doc = parser->getDocument();
0792 DOMNode* n1 = doc->getFirstChild();
0793
0794 if (n1 == nullptr) {
0795 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: Found no XML child" << std::endl;
0796
0797 return false;
0798 }
0799
0800
0801 n1 = findXMLChild(n1, m_xmlTagVme);
0802 if (n1 == nullptr) {
0803 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No vme tag found." << std::endl;
0804 return false;
0805 }
0806
0807 n1 = n1->getFirstChild();
0808
0809 unsigned int chipCounter = 0;
0810
0811 while (chipCounter < m_numberConditionChips) {
0812 n1 = findXMLChild(n1, m_xmlTagChip, true);
0813 if (n1 == nullptr) {
0814
0815 break;
0816 }
0817
0818
0819
0820
0821
0822
0823 n1 = n1->getNextSibling();
0824 chipCounter++;
0825 }
0826
0827 return true;
0828 }
0829
0830
0831
0832
0833
0834 void L1GtTriggerMenuXmlParser::clearMaps() {
0835
0836
0837 for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip != m_conditionMap.end();
0838 itCondOnChip++) {
0839
0840
0841 itCondOnChip->clear();
0842 }
0843
0844
0845 m_algorithmMap.clear();
0846 }
0847
0848
0849
0850 bool L1GtTriggerMenuXmlParser::insertConditionIntoMap(L1GtCondition& cond, const int chipNr) {
0851 std::string cName = cond.condName();
0852
0853
0854
0855
0856 if ((m_conditionMap[chipNr]).count(cName) != 0) {
0857 LogTrace("L1GtTriggerMenuXmlParser") << " Condition " << cName << " already exists - not inserted!"
0858 << std::endl;
0859 return false;
0860 }
0861
0862 (m_conditionMap[chipNr])[cName] = &cond;
0863
0864
0865
0866
0867 return true;
0868 }
0869
0870
0871 bool L1GtTriggerMenuXmlParser::insertAlgorithmIntoMap(const L1GtAlgorithm& alg) {
0872 std::string algName = alg.algoName();
0873 const std::string& algAlias = alg.algoAlias();
0874
0875
0876
0877
0878 if (m_algorithmMap.count(algName) != 0) {
0879 LogTrace("L1GtTriggerMenuXmlParser") << " Algorithm \"" << algName
0880 << "\"already exists in the algorithm map- not inserted!" << std::endl;
0881 return false;
0882 }
0883
0884 if (m_algorithmAliasMap.count(algAlias) != 0) {
0885 LogTrace("L1GtTriggerMenuXmlParser") << " Algorithm alias \"" << algAlias
0886 << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
0887 return false;
0888 }
0889
0890
0891 int bitNumber = alg.algoBitNumber();
0892 if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
0893 LogTrace("L1GtTriggerMenuXmlParser") << " Bit number " << bitNumber << " outside allowed range [0, "
0894 << m_numberPhysTriggers << ") - algorithm not inserted!" << std::endl;
0895 return false;
0896 }
0897
0898
0899 if (m_algorithmMap.size() >= m_numberPhysTriggers) {
0900 LogTrace("L1GtTriggerMenuXmlParser") << " More than maximum allowed " << m_numberPhysTriggers
0901 << " algorithms in the algorithm map - not inserted!" << std::endl;
0902 return false;
0903 }
0904
0905
0906 int chipNr = alg.algoChipNumber(
0907 static_cast<int>(m_numberConditionChips), static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
0908
0909 if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
0910 LogTrace("L1GtTriggerMenuXmlParser") << " Chip number " << chipNr << " outside allowed range [0, "
0911 << m_numberConditionChips << ") - algorithm not inserted!" << std::endl;
0912 return false;
0913 }
0914
0915
0916 int outputPin = alg.algoOutputPin(
0917 static_cast<int>(m_numberConditionChips), static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
0918
0919 if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
0920 LogTrace("L1GtTriggerMenuXmlParser") << " Output pin " << outputPin << " outside allowed range [0, "
0921 << m_pinsOnConditionChip << "] - algorithm not inserted!" << std::endl;
0922 return false;
0923 }
0924
0925
0926 for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
0927 int iPin = (itAlgo->second)
0928 .algoOutputPin(static_cast<int>(m_numberConditionChips),
0929 static_cast<int>(m_pinsOnConditionChip),
0930 m_orderConditionChip);
0931 std::string iName = itAlgo->first;
0932 int iChip = (itAlgo->second)
0933 .algoChipNumber(static_cast<int>(m_numberConditionChips),
0934 static_cast<int>(m_pinsOnConditionChip),
0935 m_orderConditionChip);
0936
0937 if ((outputPin == iPin) && (chipNr == iChip)) {
0938 LogTrace("L1GtTriggerMenuXmlParser")
0939 << " Output pin " << outputPin << " is the same as for algorithm " << iName
0940 << "\n from the same chip number " << chipNr << " - algorithm not inserted!" << std::endl;
0941 return false;
0942 }
0943 }
0944
0945
0946 m_algorithmMap[algName] = alg;
0947 m_algorithmAliasMap[algAlias] = alg;
0948
0949
0950
0951
0952
0953 return true;
0954 }
0955
0956
0957 bool L1GtTriggerMenuXmlParser::insertTechTriggerIntoMap(const L1GtAlgorithm& alg) {
0958 std::string algName = alg.algoName();
0959
0960
0961
0962
0963
0964 if (m_technicalTriggerMap.count(algName) != 0) {
0965 LogTrace("L1GtTriggerMenuXmlParser") << " Technical trigger \"" << algName
0966 << "\"already exists in the technical trigger map- not inserted!" << std::endl;
0967 return false;
0968 }
0969
0970
0971 int bitNumber = alg.algoBitNumber();
0972 if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberTechTriggers))) {
0973 LogTrace("L1GtTriggerMenuXmlParser") << " Bit number " << bitNumber << " outside allowed range [0, "
0974 << m_numberTechTriggers << ") - technical trigger not inserted!" << std::endl;
0975 return false;
0976 }
0977
0978
0979 for (CItAlgo itAlgo = m_technicalTriggerMap.begin(); itAlgo != m_technicalTriggerMap.end(); itAlgo++) {
0980 int iBitNumber = (itAlgo->second).algoBitNumber();
0981 std::string iName = itAlgo->first;
0982
0983 if (iBitNumber == bitNumber) {
0984 LogTrace("L1GtTriggerMenuXmlParser")
0985 << " Bit number " << iBitNumber << " is the same as for technical trigger " << iName
0986 << " - technical trigger not inserted!" << std::endl;
0987 return false;
0988 }
0989 }
0990
0991
0992 if (m_technicalTriggerMap.size() >= m_numberTechTriggers) {
0993 LogTrace("L1GtTriggerMenuXmlParser") << " More than maximum allowed " << m_numberTechTriggers
0994 << " technical triggers in the technical trigger map - not inserted!"
0995 << std::endl;
0996 return false;
0997 }
0998
0999
1000 m_technicalTriggerMap[algName] = alg;
1001
1002
1003
1004
1005
1006 return true;
1007 }
1008
1009
1010
1011 L1GtConditionType L1GtTriggerMenuXmlParser::getTypeFromType(const std::string& type) {
1012 if (type == m_xmlConditionAttrType1s) {
1013 return Type1s;
1014 }
1015
1016 if (type == m_xmlConditionAttrType2s) {
1017 return Type2s;
1018 }
1019
1020 if (type == m_xmlConditionAttrType3s) {
1021 return Type3s;
1022 }
1023
1024 if (type == m_xmlConditionAttrType4s) {
1025 return Type4s;
1026 }
1027
1028 if (type == m_xmlConditionAttrType2wsc) {
1029 return Type2wsc;
1030 }
1031
1032 if (type == m_xmlConditionAttrType2cor) {
1033 return Type2cor;
1034 }
1035
1036 return TypeNull;
1037 }
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048 int L1GtTriggerMenuXmlParser::getNumFromType(const std::string& type) {
1049 if (type == m_xmlConditionAttrType1s) {
1050 return 1;
1051 }
1052
1053 if (type == m_xmlConditionAttrType2s) {
1054 return 2;
1055 }
1056
1057 if (type == m_xmlConditionAttrType3s) {
1058 return 3;
1059 }
1060
1061 if (type == m_xmlConditionAttrType4s) {
1062 return 4;
1063 }
1064
1065 if (type == m_xmlConditionAttrType2wsc) {
1066 return 2;
1067 }
1068
1069 if (type == m_xmlConditionAttrType2cor) {
1070 return 2;
1071 }
1072
1073 return -1;
1074 }
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084 int L1GtTriggerMenuXmlParser::getBitFromNode(XERCES_CPP_NAMESPACE::DOMNode* node) {
1085 if (getXMLAttribute(node, m_xmlAttrMode) != m_xmlAttrModeBit) {
1086 edm::LogError("L1GtTriggerMenuXmlParser") << "Invalid mode for single bit" << std::endl;
1087
1088 return -1;
1089 }
1090
1091 std::string tmpStr = getXMLTextValue(node);
1092 if (tmpStr == "0") {
1093 return 0;
1094 } else if (tmpStr == "1") {
1095 return 1;
1096 } else {
1097 edm::LogError("L1GtTriggerMenuXmlParser") << "Bad bit value (" << tmpStr << ")" << std::endl;
1098 return -1;
1099 }
1100 }
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111 int L1GtTriggerMenuXmlParser::getGEqFlag(XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& nodeName) {
1112 XERCES_CPP_NAMESPACE_USE
1113
1114 if (node == nullptr) {
1115 LogDebug("L1GtTriggerMenuXmlParser") << "node == 0 in " << __PRETTY_FUNCTION__ << std::endl;
1116
1117 return -1;
1118 }
1119
1120
1121 DOMNode* n1 = node->getFirstChild();
1122 n1 = findXMLChild(n1, nodeName);
1123
1124 if (n1 != nullptr) {
1125 n1 = findXMLChild(n1->getFirstChild(), m_xmlTagGEq);
1126 if (n1 == nullptr) {
1127 LogDebug("L1GtTriggerMenuXmlParser") << "No \"greater or equal\" tag found" << std::endl;
1128
1129 return -1;
1130 }
1131
1132 return getBitFromNode(n1);
1133 } else {
1134 return -1;
1135 }
1136 }
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150 bool L1GtTriggerMenuXmlParser::getMuonMipIsoBits(XERCES_CPP_NAMESPACE::DOMNode* node,
1151 unsigned int num,
1152 std::vector<bool>& mipDst,
1153 std::vector<bool>& isoEnDst,
1154 std::vector<bool>& isoReqDst) {
1155 XERCES_CPP_NAMESPACE_USE
1156
1157 if (node == nullptr) {
1158 return false;
1159 }
1160
1161
1162 DOMNode* n1 = findXMLChild(node->getFirstChild(), m_xmlTagPtLowThreshold);
1163
1164 if (n1 == nullptr) {
1165 return false;
1166 }
1167
1168
1169 n1 = findXMLChild(n1->getFirstChild(), m_xmlTagValue);
1170
1171 for (unsigned int i = 0; i < num; i++) {
1172 if (n1 == nullptr) {
1173 return false;
1174 }
1175
1176
1177
1178 DOMNode* bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableMip);
1179 if (bitnode == nullptr) {
1180 return true;
1181 }
1182
1183 int tmpint = getBitFromNode(bitnode);
1184 if (tmpint < 0) {
1185 return false;
1186 }
1187
1188 mipDst[i] = (tmpint != 0);
1189
1190
1191
1192
1193
1194
1195 bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagEnableIso);
1196 if (bitnode == nullptr) {
1197 return true;
1198 }
1199
1200 tmpint = getBitFromNode(bitnode);
1201 if (tmpint < 0) {
1202 return false;
1203 }
1204
1205 isoEnDst[i] = (tmpint != 0);
1206
1207
1208
1209
1210
1211
1212 bitnode = findXMLChild(n1->getFirstChild(), m_xmlTagRequestIso);
1213 if (bitnode == nullptr) {
1214 return true;
1215 }
1216
1217 tmpint = getBitFromNode(bitnode);
1218 if (tmpint < 0) {
1219 return false;
1220 }
1221
1222 isoReqDst[i] = (tmpint != 0);
1223
1224
1225
1226
1227
1228
1229 n1 = findXMLChild(n1->getNextSibling(), m_xmlTagValue);
1230 }
1231
1232 return true;
1233 }
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246 bool L1GtTriggerMenuXmlParser::parseMuon(XERCES_CPP_NAMESPACE::DOMNode* node,
1247 const std::string& name,
1248 unsigned int chipNr,
1249 const bool corrFlag) {
1250 XERCES_CPP_NAMESPACE_USE
1251
1252
1253 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
1254 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
1255 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
1256
1257 if (particle != m_xmlConditionAttrObjectMu) {
1258 edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for muon-condition (" << particle << ")" << std::endl;
1259 return false;
1260 }
1261
1262 int nrObj = getNumFromType(type);
1263 if (nrObj < 0) {
1264 edm::LogError("L1GtTriggerMenuXmlParser") << "Unknown type for muon-condition (" << type << ")"
1265 << "\nCan not determine number of trigger objects. " << std::endl;
1266 return false;
1267 }
1268
1269
1270
1271 int intGEq = getGEqFlag(node, m_xmlTagPtHighThreshold);
1272 if (intGEq < 0) {
1273 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
1274 return false;
1275 }
1276
1277 bool gEq = (intGEq != 0);
1278
1279
1280
1281
1282 std::vector<L1GtMuonTemplate::ObjectParameter> objParameter(nrObj);
1283 L1GtMuonTemplate::CorrelationParameter corrParameter;
1284
1285
1286 std::vector<uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1287
1288
1289 if (!getConditionChildValues(node, m_xmlTagPtHighThreshold, nrObj, tmpValues)) {
1290 return false;
1291 }
1292
1293 for (int i = 0; i < nrObj; i++) {
1294 objParameter[i].ptHighThreshold = tmpValues[i];
1295
1296
1297
1298
1299
1300 }
1301
1302
1303 if (!getConditionChildValues(node, m_xmlTagPtLowThreshold, nrObj, tmpValues)) {
1304 return false;
1305 }
1306
1307 for (int i = 0; i < nrObj; i++) {
1308
1309
1310
1311
1312
1313
1314
1315 tmpValues[i] = (tmpValues[i]) / 16;
1316
1317 objParameter[i].ptLowThreshold = tmpValues[i];
1318
1319
1320
1321
1322
1323 }
1324
1325
1326 if (!getConditionChildValues(node, m_xmlTagQuality, nrObj, tmpValues)) {
1327 return false;
1328 }
1329
1330 for (int i = 0; i < nrObj; i++) {
1331 objParameter[i].qualityRange = tmpValues[i];
1332
1333
1334
1335
1336
1337 }
1338
1339
1340 if (!getConditionChildValues(node, m_xmlTagEta, nrObj, tmpValues)) {
1341 return false;
1342 }
1343
1344 for (int i = 0; i < nrObj; i++) {
1345 objParameter[i].etaRange = tmpValues[i];
1346
1347
1348
1349
1350
1351 }
1352
1353
1354 if (!getConditionChildValues(node, m_xmlTagPhiHigh, nrObj, tmpValues)) {
1355 return false;
1356 }
1357
1358 for (int i = 0; i < nrObj; i++) {
1359 objParameter[i].phiHigh = tmpValues[i];
1360
1361
1362
1363
1364
1365 }
1366
1367
1368 if (!getConditionChildValues(node, m_xmlTagPhiLow, nrObj, tmpValues)) {
1369 return false;
1370 }
1371
1372 for (int i = 0; i < nrObj; i++) {
1373 objParameter[i].phiLow = tmpValues[i];
1374
1375
1376
1377
1378
1379 }
1380
1381
1382 if (!getXMLHexTextValue(findXMLChild(node->getFirstChild(), m_xmlTagChargeCorrelation), tmpValues[0])) {
1383 LogDebug("L1GtTriggerMenuXmlParser") << " Error getting charge correlation from muon condition (" << name << ")"
1384 << std::endl;
1385 return false;
1386 }
1387
1388 corrParameter.chargeCorrelation = tmpValues[0];
1389
1390
1391
1392
1393
1394
1395
1396
1397 std::vector<bool> tmpMip(nrObj);
1398 std::vector<bool> tmpEnableIso(nrObj);
1399 std::vector<bool> tmpRequestIso(nrObj);
1400
1401 if (!getMuonMipIsoBits(node, nrObj, tmpMip, tmpEnableIso, tmpRequestIso)) {
1402 edm::LogError("L1GtTriggerMenuXmlParser")
1403 << " Could not get mip and iso bits from muon condition (" << name << ")" << std::endl;
1404 return false;
1405 }
1406
1407 for (int i = 0; i < nrObj; i++) {
1408 objParameter[i].enableMip = tmpMip[i];
1409 objParameter[i].enableIso = tmpEnableIso[i];
1410 objParameter[i].requestIso = tmpRequestIso[i];
1411 }
1412
1413
1414 bool wscVal = (type == m_xmlConditionAttrType2wsc);
1415
1416 if (wscVal) {
1417
1418 if (!getConditionChildValues(node, m_xmlTagDeltaEta, 1, tmpValues)) {
1419 return false;
1420 }
1421
1422 corrParameter.deltaEtaRange = tmpValues[0];
1423
1424
1425 if (!getXMLHexTextValue128(findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi), tmpValues[0], tmpValues[1])) {
1426 edm::LogError("L1GtTriggerMenuXmlParser")
1427 << " Could not get deltaPhi for muon condition with wsc (" << name << ")" << std::endl;
1428 return false;
1429 }
1430
1431 corrParameter.deltaPhiRange0Word = tmpValues[0];
1432 corrParameter.deltaPhiRange1Word = tmpValues[1];
1433
1434
1435
1436
1437
1438
1439 unsigned int maxbits;
1440
1441 if (!countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits)) {
1442 return false;
1443 }
1444
1445 corrParameter.deltaPhiMaxbits = maxbits;
1446
1447
1448
1449 }
1450
1451
1452
1453 L1GtConditionType cType = getTypeFromType(type);
1454
1455
1456
1457
1458 if (cType == TypeNull) {
1459 edm::LogError("L1GtTriggerMenuXmlParser")
1460 << "Type for muon condition id TypeNull - it means not defined in the XML file."
1461 << "\nNumber of trigger objects is set to zero. " << std::endl;
1462 return false;
1463 }
1464
1465
1466 std::vector<L1GtObject> objType(nrObj, Mu);
1467
1468
1469
1470 L1GtMuonTemplate muonCond(name);
1471
1472 muonCond.setCondType(cType);
1473 muonCond.setObjectType(objType);
1474 muonCond.setCondGEq(gEq);
1475 muonCond.setCondChipNr(chipNr);
1476
1477 muonCond.setConditionParameter(objParameter, corrParameter);
1478
1479 if (edm::isDebugEnabled()) {
1480 std::ostringstream myCoutStream;
1481 muonCond.print(myCoutStream);
1482 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
1483 }
1484
1485
1486 if (!insertConditionIntoMap(muonCond, chipNr)) {
1487 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1488 return false;
1489 } else {
1490 if (corrFlag) {
1491 (m_corMuonTemplate[chipNr]).push_back(muonCond);
1492
1493 } else {
1494 (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1495 }
1496 }
1497
1498
1499 return true;
1500 }
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513 bool L1GtTriggerMenuXmlParser::parseCalo(XERCES_CPP_NAMESPACE::DOMNode* node,
1514 const std::string& name,
1515 unsigned int chipNr,
1516 const bool corrFlag) {
1517 XERCES_CPP_NAMESPACE_USE
1518
1519
1520 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
1521 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
1522 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
1523
1524
1525 L1GtObject caloObjType;
1526
1527 if (particle == m_xmlConditionAttrObjectNoIsoEG) {
1528 caloObjType = NoIsoEG;
1529 } else if (particle == m_xmlConditionAttrObjectIsoEG) {
1530 caloObjType = IsoEG;
1531 } else if (particle == m_xmlConditionAttrObjectCenJet) {
1532 caloObjType = CenJet;
1533 } else if (particle == m_xmlConditionAttrObjectTauJet) {
1534 caloObjType = TauJet;
1535 } else if (particle == m_xmlConditionAttrObjectForJet) {
1536 caloObjType = ForJet;
1537 } else {
1538 edm::LogError("L1GtTriggerMenuXmlParser") << "Wrong particle for calo-condition (" << particle << ")" << std::endl;
1539 return false;
1540 }
1541
1542 int nrObj = getNumFromType(type);
1543 if (nrObj < 0) {
1544 edm::LogError("L1GtTriggerMenuXmlParser") << "Unknown type for calo-condition (" << type << ")"
1545 << "\nCan not determine number of trigger objects. " << std::endl;
1546 return false;
1547 }
1548
1549
1550
1551 int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
1552 if (intGEq < 0) {
1553 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
1554 return false;
1555 }
1556
1557 bool gEq = (intGEq != 0);
1558
1559
1560
1561
1562 std::vector<L1GtCaloTemplate::ObjectParameter> objParameter(nrObj);
1563 L1GtCaloTemplate::CorrelationParameter corrParameter;
1564
1565
1566 std::vector<uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1567
1568
1569 if (!getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues)) {
1570 return false;
1571 }
1572
1573 for (int i = 0; i < nrObj; i++) {
1574 objParameter[i].etThreshold = tmpValues[i];
1575
1576
1577
1578
1579
1580 }
1581
1582
1583 if (!getConditionChildValues(node, m_xmlTagEta, nrObj, tmpValues)) {
1584 return false;
1585 }
1586
1587 for (int i = 0; i < nrObj; i++) {
1588 objParameter[i].etaRange = tmpValues[i];
1589
1590
1591
1592
1593
1594 }
1595
1596
1597 if (!getConditionChildValues(node, m_xmlTagPhi, nrObj, tmpValues)) {
1598 return false;
1599 }
1600
1601 for (int i = 0; i < nrObj; i++) {
1602 objParameter[i].phiRange = tmpValues[i];
1603
1604
1605
1606
1607
1608 }
1609
1610
1611 bool wscVal = (type == m_xmlConditionAttrType2wsc);
1612
1613 if (wscVal) {
1614
1615 if (!getConditionChildValues(node, m_xmlTagDeltaEta, 1, tmpValues)) {
1616 return false;
1617 }
1618
1619 corrParameter.deltaEtaRange = tmpValues[0];
1620
1621
1622 if (!getConditionChildValues(node, m_xmlTagDeltaPhi, 1, tmpValues)) {
1623 return false;
1624 }
1625
1626 corrParameter.deltaPhiRange = tmpValues[0];
1627
1628
1629
1630
1631
1632
1633 unsigned int maxbits;
1634
1635 if (!countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits)) {
1636 return false;
1637 }
1638
1639 corrParameter.deltaPhiMaxbits = maxbits;
1640
1641
1642
1643 }
1644
1645
1646
1647 L1GtConditionType cType = getTypeFromType(type);
1648
1649
1650
1651
1652 if (cType == TypeNull) {
1653 edm::LogError("L1GtTriggerMenuXmlParser")
1654 << "Type for calo condition id TypeNull - it means not defined in the XML file."
1655 << "\nNumber of trigger objects is set to zero. " << std::endl;
1656 return false;
1657 }
1658
1659
1660 std::vector<L1GtObject> objType(nrObj, caloObjType);
1661
1662
1663
1664 L1GtCaloTemplate caloCond(name);
1665
1666 caloCond.setCondType(cType);
1667 caloCond.setObjectType(objType);
1668 caloCond.setCondGEq(gEq);
1669 caloCond.setCondChipNr(chipNr);
1670
1671 caloCond.setConditionParameter(objParameter, corrParameter);
1672
1673 if (edm::isDebugEnabled()) {
1674 std::ostringstream myCoutStream;
1675 caloCond.print(myCoutStream);
1676 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
1677 }
1678
1679
1680 if (!insertConditionIntoMap(caloCond, chipNr)) {
1681 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1682
1683 return false;
1684 } else {
1685 if (corrFlag) {
1686 (m_corCaloTemplate[chipNr]).push_back(caloCond);
1687 } else {
1688 (m_vecCaloTemplate[chipNr]).push_back(caloCond);
1689 }
1690 }
1691
1692
1693 return true;
1694 }
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707 bool L1GtTriggerMenuXmlParser::parseEnergySum(XERCES_CPP_NAMESPACE::DOMNode* node,
1708 const std::string& name,
1709 unsigned int chipNr,
1710 const bool corrFlag) {
1711 XERCES_CPP_NAMESPACE_USE
1712
1713
1714 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
1715 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
1716 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
1717
1718
1719 L1GtObject energySumObjType;
1720 L1GtConditionType cType;
1721
1722 if ((particle == m_xmlConditionAttrObjectETM) && (type == m_xmlConditionAttrObjectETM)) {
1723 energySumObjType = ETM;
1724 cType = TypeETM;
1725
1726 } else if ((particle == m_xmlConditionAttrObjectETT) && (type == m_xmlConditionAttrObjectETT)) {
1727 energySumObjType = ETT;
1728 cType = TypeETT;
1729
1730 } else if ((particle == m_xmlConditionAttrObjectHTT) && (type == m_xmlConditionAttrObjectHTT)) {
1731 energySumObjType = HTT;
1732 cType = TypeHTT;
1733
1734 } else if ((particle == m_xmlConditionAttrObjectHTM) && (type == m_xmlConditionAttrObjectHTM)) {
1735 energySumObjType = HTM;
1736 cType = TypeHTM;
1737
1738 } else {
1739 edm::LogError("L1GtTriggerMenuXmlParser")
1740 << "Wrong particle or type for energy-sum condition (" << particle << ", " << type << ")" << std::endl;
1741 return false;
1742 }
1743
1744
1745 int nrObj = 1;
1746
1747
1748
1749 int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
1750 if (intGEq < 0) {
1751 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
1752 return false;
1753 }
1754
1755 bool gEq = (intGEq != 0);
1756
1757
1758
1759
1760 std::vector<L1GtEnergySumTemplate::ObjectParameter> objParameter(nrObj);
1761
1762
1763 std::vector<uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1764
1765
1766 if (!getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues)) {
1767 return false;
1768 }
1769
1770 for (int i = 0; i < nrObj; i++) {
1771 objParameter[i].etThreshold = tmpValues[i];
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781 if (energySumObjType == ETM) {
1782 if (!getXMLHexTextValue128(findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0], tmpValues[1])) {
1783 edm::LogError("L1GtTriggerMenuXmlParser")
1784 << " Could not get phi for ETM condition (" << name << ")" << std::endl;
1785 return false;
1786 }
1787
1788 objParameter[i].phiRange0Word = tmpValues[0];
1789 objParameter[i].phiRange1Word = tmpValues[1];
1790
1791 } else if (energySumObjType == HTM) {
1792 if (!getXMLHexTextValue(findXMLChild(node->getFirstChild(), m_xmlTagPhi), tmpValues[0])) {
1793 edm::LogError("L1GtTriggerMenuXmlParser")
1794 << " Could not get phi for HTM condition (" << name << ")" << std::endl;
1795 return false;
1796 }
1797
1798 objParameter[i].phiRange0Word = tmpValues[0];
1799 }
1800
1801
1802 DOMNode* n1;
1803 if ((n1 = findXMLChild(node->getFirstChild(), m_xmlTagEtThreshold)) == nullptr) {
1804 edm::LogError("L1GtTriggerMenuXmlParser")
1805 << " Could not get energyOverflow for EnergySum condition (" << name << ")" << std::endl;
1806 return false;
1807 }
1808 if ((n1 = findXMLChild(n1->getFirstChild(), m_xmlTagEnergyOverflow)) == nullptr) {
1809 edm::LogError("L1GtTriggerMenuXmlParser")
1810 << " Could not get energyOverflow for EnergySum condition (" << name << ")" << std::endl;
1811 return false;
1812 }
1813
1814 int tmpInt = getBitFromNode(n1);
1815 if (tmpInt == 0) {
1816 objParameter[i].energyOverflow = false;
1817
1818
1819
1820
1821
1822 } else if (tmpInt == 1) {
1823 objParameter[i].energyOverflow = true;
1824
1825
1826
1827
1828
1829 } else {
1830 LogTrace("L1GtTriggerMenuXmlParser") << " EnergySum energyOverflow logical flag (hex) = " << std::hex
1831 << tmpInt << std::dec << " - wrong value! " << std::endl;
1832 return false;
1833 }
1834 }
1835
1836
1837 std::vector<L1GtObject> objType(nrObj, energySumObjType);
1838
1839
1840
1841 L1GtEnergySumTemplate energySumCond(name);
1842
1843 energySumCond.setCondType(cType);
1844 energySumCond.setObjectType(objType);
1845 energySumCond.setCondGEq(gEq);
1846 energySumCond.setCondChipNr(chipNr);
1847
1848 energySumCond.setConditionParameter(objParameter);
1849
1850 if (edm::isDebugEnabled()) {
1851 std::ostringstream myCoutStream;
1852 energySumCond.print(myCoutStream);
1853 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
1854 }
1855
1856
1857 if (!insertConditionIntoMap(energySumCond, chipNr)) {
1858 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
1859
1860 return false;
1861 } else {
1862 if (corrFlag) {
1863 (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
1864
1865 } else {
1866 (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
1867 }
1868 }
1869
1870
1871 return true;
1872 }
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886 bool L1GtTriggerMenuXmlParser::parseJetCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
1887 const std::string& name,
1888 unsigned int chipNr) {
1889 XERCES_CPP_NAMESPACE_USE
1890
1891
1892 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
1893 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
1894 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
1895
1896 if (particle != m_xmlConditionAttrObjectJetCounts) {
1897 edm::LogError("L1GtTriggerMenuXmlParser")
1898 << "Wrong particle for JetCounts condition (" << particle << ")" << std::endl;
1899 return false;
1900 }
1901
1902
1903 L1GtObject jetCountsObjType = JetCounts;
1904 L1GtConditionType cType = TypeJetCounts;
1905
1906
1907 int nrObj = 1;
1908
1909
1910
1911 int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
1912 if (intGEq < 0) {
1913 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
1914 return false;
1915 }
1916
1917 bool gEq = (intGEq != 0);
1918
1919
1920
1921
1922 std::vector<L1GtJetCountsTemplate::ObjectParameter> objParameter(nrObj);
1923
1924
1925
1926 char* endPtr = nullptr;
1927 long int typeInt = strtol(type.c_str(), &endPtr, 10);
1928
1929 if (*endPtr != 0) {
1930 LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec." << std::endl;
1931
1932 return false;
1933 }
1934
1935
1936 if ((typeInt < 0) || (typeInt > static_cast<int>(m_numberL1JetCounts))) {
1937 LogDebug("L1GtTriggerMenuXmlParser") << "Count index " << typeInt << " outside range [0, " << m_numberL1JetCounts
1938 << "]" << std::endl;
1939
1940 return false;
1941 }
1942
1943 objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
1944
1945
1946 std::vector<uint64_t> tmpValues(nrObj);
1947
1948 if (!getConditionChildValues(node, m_xmlTagCountThreshold, nrObj, tmpValues)) {
1949 return false;
1950 }
1951
1952 for (int i = 0; i < nrObj; i++) {
1953 objParameter[i].countThreshold = tmpValues[i];
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001 }
2002
2003
2004 std::vector<L1GtObject> objType(nrObj, jetCountsObjType);
2005
2006
2007
2008 L1GtJetCountsTemplate jetCountsCond(name);
2009
2010 jetCountsCond.setCondType(cType);
2011 jetCountsCond.setObjectType(objType);
2012 jetCountsCond.setCondGEq(gEq);
2013 jetCountsCond.setCondChipNr(chipNr);
2014
2015 jetCountsCond.setConditionParameter(objParameter);
2016
2017 if (edm::isDebugEnabled()) {
2018 std::ostringstream myCoutStream;
2019 jetCountsCond.print(myCoutStream);
2020 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2021 }
2022
2023
2024 if (!insertConditionIntoMap(jetCountsCond, chipNr)) {
2025 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2026
2027 return false;
2028 } else {
2029 (m_vecJetCountsTemplate[chipNr]).push_back(jetCountsCond);
2030 }
2031
2032
2033 return true;
2034 }
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048 bool L1GtTriggerMenuXmlParser::parseCastor(XERCES_CPP_NAMESPACE::DOMNode* node,
2049 const std::string& name,
2050 unsigned int chipNr) {
2051 XERCES_CPP_NAMESPACE_USE
2052
2053
2054 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2055 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2056 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2057
2058 if (particle != m_xmlConditionAttrObjectCastor) {
2059 edm::LogError("L1GtTriggerMenuXmlParser")
2060 << "\nError: wrong particle for Castor condition (" << particle << ")" << std::endl;
2061 return false;
2062 }
2063
2064
2065
2066 L1GtConditionType cType = TypeCastor;
2067
2068
2069
2070
2071 bool gEq = false;
2072
2073
2074
2075 L1GtCastorTemplate castorCond(name);
2076
2077 castorCond.setCondType(cType);
2078 castorCond.setCondGEq(gEq);
2079 castorCond.setCondChipNr(chipNr);
2080
2081 if (edm::isDebugEnabled()) {
2082 std::ostringstream myCoutStream;
2083 castorCond.print(myCoutStream);
2084 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2085 }
2086
2087
2088 if (!insertConditionIntoMap(castorCond, chipNr)) {
2089 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2090
2091 return false;
2092 } else {
2093 (m_vecCastorTemplate[chipNr]).push_back(castorCond);
2094 }
2095
2096
2097 return true;
2098 }
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112 bool L1GtTriggerMenuXmlParser::parseHfBitCounts(XERCES_CPP_NAMESPACE::DOMNode* node,
2113 const std::string& name,
2114 unsigned int chipNr) {
2115 XERCES_CPP_NAMESPACE_USE
2116
2117
2118 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2119 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2120 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2121
2122 if (particle != m_xmlConditionAttrObjectHfBitCounts) {
2123 edm::LogError("L1GtTriggerMenuXmlParser")
2124 << "Wrong particle for HfBitCounts condition (" << particle << ")" << std::endl;
2125 return false;
2126 }
2127
2128
2129 L1GtObject hfBitCountsObjType = HfBitCounts;
2130 L1GtConditionType cType = TypeHfBitCounts;
2131
2132
2133 int nrObj = 1;
2134
2135
2136
2137 int intGEq = getGEqFlag(node, m_xmlTagCountThreshold);
2138 if (intGEq < 0) {
2139 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
2140 return false;
2141 }
2142
2143 bool gEq = (intGEq != 0);
2144
2145
2146
2147
2148 std::vector<L1GtHfBitCountsTemplate::ObjectParameter> objParameter(nrObj);
2149
2150
2151
2152 char* endPtr = nullptr;
2153 long int typeInt = strtol(type.c_str(), &endPtr, 10);
2154
2155 if (*endPtr != 0) {
2156 LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec." << std::endl;
2157
2158 return false;
2159 }
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169 objParameter[0].countIndex = static_cast<unsigned int>(typeInt);
2170
2171
2172 std::vector<uint64_t> tmpValues(nrObj);
2173
2174 if (!getConditionChildValues(node, m_xmlTagCountThreshold, nrObj, tmpValues)) {
2175 return false;
2176 }
2177
2178 for (int i = 0; i < nrObj; i++) {
2179 objParameter[i].countThreshold = tmpValues[i];
2180
2181
2182
2183
2184
2185 }
2186
2187
2188 std::vector<L1GtObject> objType(nrObj, hfBitCountsObjType);
2189
2190
2191
2192 L1GtHfBitCountsTemplate hfBitCountsCond(name);
2193
2194 hfBitCountsCond.setCondType(cType);
2195 hfBitCountsCond.setObjectType(objType);
2196 hfBitCountsCond.setCondGEq(gEq);
2197 hfBitCountsCond.setCondChipNr(chipNr);
2198
2199 hfBitCountsCond.setConditionParameter(objParameter);
2200
2201 if (edm::isDebugEnabled()) {
2202 std::ostringstream myCoutStream;
2203 hfBitCountsCond.print(myCoutStream);
2204 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2205 }
2206
2207
2208 if (!insertConditionIntoMap(hfBitCountsCond, chipNr)) {
2209 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2210
2211 return false;
2212 } else {
2213 (m_vecHfBitCountsTemplate[chipNr]).push_back(hfBitCountsCond);
2214 }
2215
2216
2217 return true;
2218 }
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232 bool L1GtTriggerMenuXmlParser::parseHfRingEtSums(XERCES_CPP_NAMESPACE::DOMNode* node,
2233 const std::string& name,
2234 unsigned int chipNr) {
2235 XERCES_CPP_NAMESPACE_USE
2236
2237
2238 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2239 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2240 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2241
2242 if (particle != m_xmlConditionAttrObjectHfRingEtSums) {
2243 edm::LogError("L1GtTriggerMenuXmlParser")
2244 << "Wrong particle for HfRingEtSums condition (" << particle << ")" << std::endl;
2245 return false;
2246 }
2247
2248
2249 L1GtObject hfRingEtSumsObjType = HfRingEtSums;
2250 L1GtConditionType cType = TypeHfRingEtSums;
2251
2252
2253 int nrObj = 1;
2254
2255
2256
2257 int intGEq = getGEqFlag(node, m_xmlTagEtThreshold);
2258 if (intGEq < 0) {
2259 edm::LogError("L1GtTriggerMenuXmlParser") << "Error getting \"greater or equal\" flag" << std::endl;
2260 return false;
2261 }
2262
2263 bool gEq = (intGEq != 0);
2264
2265
2266
2267
2268 std::vector<L1GtHfRingEtSumsTemplate::ObjectParameter> objParameter(nrObj);
2269
2270
2271
2272 char* endPtr = nullptr;
2273 long int typeInt = strtol(type.c_str(), &endPtr, 10);
2274
2275 if (*endPtr != 0) {
2276 LogDebug("L1GtTriggerMenuXmlParser") << "Unable to convert " << type << " to dec." << std::endl;
2277
2278 return false;
2279 }
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289 objParameter[0].etSumIndex = static_cast<unsigned int>(typeInt);
2290
2291
2292 std::vector<uint64_t> tmpValues(nrObj);
2293
2294 if (!getConditionChildValues(node, m_xmlTagEtThreshold, nrObj, tmpValues)) {
2295 return false;
2296 }
2297
2298 for (int i = 0; i < nrObj; i++) {
2299 objParameter[i].etSumThreshold = tmpValues[i];
2300
2301
2302
2303
2304
2305 }
2306
2307
2308 std::vector<L1GtObject> objType(nrObj, hfRingEtSumsObjType);
2309
2310
2311
2312 L1GtHfRingEtSumsTemplate hfRingEtSumsCond(name);
2313
2314 hfRingEtSumsCond.setCondType(cType);
2315 hfRingEtSumsCond.setObjectType(objType);
2316 hfRingEtSumsCond.setCondGEq(gEq);
2317 hfRingEtSumsCond.setCondChipNr(chipNr);
2318
2319 hfRingEtSumsCond.setConditionParameter(objParameter);
2320
2321 if (edm::isDebugEnabled()) {
2322 std::ostringstream myCoutStream;
2323 hfRingEtSumsCond.print(myCoutStream);
2324 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2325 }
2326
2327
2328 if (!insertConditionIntoMap(hfRingEtSumsCond, chipNr)) {
2329 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2330
2331 return false;
2332 } else {
2333 (m_vecHfRingEtSumsTemplate[chipNr]).push_back(hfRingEtSumsCond);
2334 }
2335
2336
2337 return true;
2338 }
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352 bool L1GtTriggerMenuXmlParser::parseBptx(XERCES_CPP_NAMESPACE::DOMNode* node,
2353 const std::string& name,
2354 unsigned int chipNr) {
2355 XERCES_CPP_NAMESPACE_USE
2356
2357
2358 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2359 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2360 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2361
2362 if (particle != m_xmlConditionAttrObjectBptx) {
2363 edm::LogError("L1GtTriggerMenuXmlParser")
2364 << "\nError: wrong particle for Bptx condition (" << particle << ")" << std::endl;
2365 return false;
2366 }
2367
2368
2369
2370 L1GtConditionType cType = TypeBptx;
2371
2372
2373
2374
2375 bool gEq = false;
2376
2377
2378
2379 L1GtBptxTemplate bptxCond(name);
2380
2381 bptxCond.setCondType(cType);
2382 bptxCond.setCondGEq(gEq);
2383 bptxCond.setCondChipNr(chipNr);
2384
2385 LogTrace("L1GtTriggerMenuXmlParser") << bptxCond << "\n" << std::endl;
2386
2387
2388 if (!insertConditionIntoMap(bptxCond, chipNr)) {
2389 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2390
2391 return false;
2392 } else {
2393 (m_vecBptxTemplate[chipNr]).push_back(bptxCond);
2394 }
2395
2396
2397 return true;
2398 }
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412 bool L1GtTriggerMenuXmlParser::parseExternal(XERCES_CPP_NAMESPACE::DOMNode* node,
2413 const std::string& name,
2414 unsigned int chipNr) {
2415 XERCES_CPP_NAMESPACE_USE
2416
2417
2418 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2419 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2420 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2421
2422 if (particle != m_xmlConditionAttrObjectGtExternal) {
2423 edm::LogError("L1GtTriggerMenuXmlParser")
2424 << "\nError: wrong particle for External condition (" << particle << ")" << std::endl;
2425 return false;
2426 }
2427
2428
2429
2430 L1GtConditionType cType = TypeExternal;
2431
2432
2433
2434
2435 bool gEq = false;
2436
2437
2438
2439 L1GtExternalTemplate externalCond(name);
2440
2441 externalCond.setCondType(cType);
2442 externalCond.setCondGEq(gEq);
2443 externalCond.setCondChipNr(chipNr);
2444
2445 LogTrace("L1GtTriggerMenuXmlParser") << externalCond << "\n" << std::endl;
2446
2447
2448 if (!insertConditionIntoMap(externalCond, chipNr)) {
2449 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: duplicate condition (" << name << ")" << std::endl;
2450
2451 return false;
2452 } else {
2453 (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2454 }
2455
2456
2457 return true;
2458 }
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472 bool L1GtTriggerMenuXmlParser::parseCorrelation(XERCES_CPP_NAMESPACE::DOMNode* node,
2473 const std::string& name,
2474 unsigned int chipNr) {
2475 XERCES_CPP_NAMESPACE_USE
2476
2477
2478 L1GtCorrelationTemplate correlationCond(name);
2479
2480
2481 if (!insertConditionIntoMap(correlationCond, chipNr)) {
2482 edm::LogError("L1GtTriggerMenuXmlParser")
2483 << " Error: duplicate correlation condition (" << name << ")" << std::endl;
2484
2485 return false;
2486 }
2487
2488
2489 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2490 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2491 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2492
2493 LogTrace("L1GtTriggerMenuXmlParser") << " Condition category: " << condition << ", particle: " << particle
2494 << ", type: " << type << "\n"
2495 << std::endl;
2496
2497
2498 L1GtConditionType cType = Type2cor;
2499
2500
2501 const int nrObj = 2;
2502
2503
2504 int intGEq[nrObj] = {-1, -1};
2505 std::vector<L1GtObject> objType(nrObj);
2506 std::vector<L1GtConditionCategory> condCateg(nrObj);
2507
2508
2509 const bool corrFlag = true;
2510 int corrIndexVal[nrObj] = {-1, -1};
2511
2512
2513
2514 DOMNode* conditionsNode = node->getFirstChild();
2515 std::string conditionNameNodeName;
2516 conditionsNode = findXMLChild(conditionsNode, "", true, &conditionNameNodeName);
2517
2518 for (int iSubCond = 0; iSubCond < nrObj; ++iSubCond) {
2519
2520 condition = getXMLAttribute(conditionsNode, m_xmlConditionAttrCondition);
2521 particle = getXMLAttribute(conditionsNode, m_xmlConditionAttrObject);
2522 type = getXMLAttribute(conditionsNode, m_xmlConditionAttrType);
2523
2524 LogTrace("L1GtTriggerMenuXmlParser") << " Sub-condition category: " << condition << ", particle: " << particle
2525 << ", type: " << type << ", name: " << conditionNameNodeName << "\n"
2526 << std::endl;
2527
2528
2529 if (condition == m_xmlConditionAttrConditionMuon) {
2530 if (!parseMuon(conditionsNode, conditionNameNodeName, chipNr, corrFlag)) {
2531 edm::LogError("L1GtTriggerMenuXmlParser") << "Error parsing sub-condition " << condition << ")"
2532 << " with name " << conditionNameNodeName << std::endl;
2533 }
2534
2535
2536 intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagPtHighThreshold);
2537 if (intGEq[iSubCond] < 0) {
2538 edm::LogError("L1GtTriggerMenuXmlParser")
2539 << "Error getting \"greater or equal\" flag"
2540 << " for sub-condition " << conditionNameNodeName << " for the correlation condition " << name << std::endl;
2541 return false;
2542 }
2543
2544
2545 objType[iSubCond] = Mu;
2546 condCateg[iSubCond] = CondMuon;
2547 corrIndexVal[iSubCond] = (m_corMuonTemplate[chipNr]).size() - 1;
2548
2549 } else if (condition == m_xmlConditionAttrConditionCalo) {
2550 if (!parseCalo(conditionsNode, conditionNameNodeName, chipNr, corrFlag)) {
2551 edm::LogError("L1GtTriggerMenuXmlParser") << "Error parsing sub-condition " << condition << ")"
2552 << " with name " << conditionNameNodeName << std::endl;
2553 }
2554
2555
2556 intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
2557 if (intGEq[iSubCond] < 0) {
2558 edm::LogError("L1GtTriggerMenuXmlParser")
2559 << "Error getting \"greater or equal\" flag"
2560 << " for sub-condition " << conditionNameNodeName << " for the correlation condition " << name << std::endl;
2561 return false;
2562 }
2563
2564
2565 if (particle == m_xmlConditionAttrObjectNoIsoEG) {
2566 objType[iSubCond] = NoIsoEG;
2567 } else if (particle == m_xmlConditionAttrObjectIsoEG) {
2568 objType[iSubCond] = IsoEG;
2569 } else if (particle == m_xmlConditionAttrObjectCenJet) {
2570 objType[iSubCond] = CenJet;
2571 } else if (particle == m_xmlConditionAttrObjectTauJet) {
2572 objType[iSubCond] = TauJet;
2573 } else if (particle == m_xmlConditionAttrObjectForJet) {
2574 objType[iSubCond] = ForJet;
2575 } else {
2576 edm::LogError("L1GtTriggerMenuXmlParser")
2577 << "Wrong object type " << particle << " for sub-condition " << conditionNameNodeName
2578 << " from the correlation condition " << name << std::endl;
2579 return false;
2580 }
2581
2582 condCateg[iSubCond] = CondCalo;
2583 corrIndexVal[iSubCond] = (m_corCaloTemplate[chipNr]).size() - 1;
2584
2585 } else if (condition == m_xmlConditionAttrConditionEnergySum) {
2586 if (!parseEnergySum(conditionsNode, conditionNameNodeName, chipNr, corrFlag)) {
2587 edm::LogError("L1GtTriggerMenuXmlParser") << "Error parsing sub-condition " << condition << ")"
2588 << " with name " << conditionNameNodeName << std::endl;
2589 }
2590
2591
2592 intGEq[iSubCond] = getGEqFlag(conditionsNode, m_xmlTagEtThreshold);
2593 if (intGEq[iSubCond] < 0) {
2594 edm::LogError("L1GtTriggerMenuXmlParser")
2595 << "Error getting \"greater or equal\" flag"
2596 << " for sub-condition " << conditionNameNodeName << " for the correlation condition " << name << std::endl;
2597 return false;
2598 }
2599
2600
2601 if (particle == m_xmlConditionAttrObjectETM) {
2602 objType[iSubCond] = ETM;
2603 } else if (particle == m_xmlConditionAttrObjectETT) {
2604 objType[iSubCond] = ETT;
2605 } else if (particle == m_xmlConditionAttrObjectHTT) {
2606 objType[iSubCond] = HTT;
2607 } else if (particle == m_xmlConditionAttrObjectHTM) {
2608 objType[iSubCond] = HTM;
2609 } else {
2610 edm::LogError("L1GtTriggerMenuXmlParser")
2611 << "Wrong object type " << particle << " for sub-condition " << conditionNameNodeName
2612 << " from the correlation condition " << name << std::endl;
2613 return false;
2614 }
2615
2616 condCateg[iSubCond] = CondEnergySum;
2617 corrIndexVal[iSubCond] = (m_corEnergySumTemplate[chipNr]).size() - 1;
2618
2619 } else {
2620 edm::LogError("L1GtTriggerMenuXmlParser")
2621 << "Unknown or un-adequate sub-condition (" << condition << ")"
2622 << " with name " << conditionNameNodeName << " for the correlation condition " << name << std::endl;
2623
2624 return false;
2625 }
2626
2627 conditionsNode = findXMLChild(conditionsNode->getNextSibling(), "", true, &conditionNameNodeName);
2628 }
2629
2630
2631 bool gEq = true;
2632 if (intGEq[0] != intGEq[1]) {
2633 edm::LogError("L1GtTriggerMenuXmlParser")
2634 << "Inconsistent GEq flags for sub-conditions (" << condition << ")"
2635 << " with name " << conditionNameNodeName << " for the correlation condition " << name << std::endl;
2636 return false;
2637
2638 } else {
2639 gEq = (intGEq[0] != 0);
2640 }
2641
2642
2643
2644
2645 L1GtCorrelationTemplate::CorrelationParameter corrParameter;
2646 std::vector<uint64_t> tmpValues(nrObj);
2647
2648
2649
2650
2651
2652
2653
2654
2655 XERCES_CPP_NAMESPACE::DOMNode* node1 = findXMLChild(node->getFirstChild(), m_xmlTagDeltaEta);
2656
2657 std::string valString;
2658
2659 if (node1 == nullptr) {
2660 edm::LogError("L1GtTriggerMenuXmlParser")
2661 << " Could not get deltaEta for correlation condition " << name << ". " << std::endl;
2662 return false;
2663 } else {
2664 valString = getXMLTextValue(node1);
2665 }
2666
2667 corrParameter.deltaEtaRange = valString;
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680 node1 = findXMLChild(node->getFirstChild(), m_xmlTagDeltaPhi);
2681
2682 if (node1 == nullptr) {
2683 return false;
2684 edm::LogError("L1GtTriggerMenuXmlParser")
2685 << " Could not get deltaPhi for correlation condition " << name << ". " << std::endl;
2686 } else {
2687 valString = getXMLTextValue(node1);
2688 }
2689
2690 corrParameter.deltaPhiRange = valString;
2691
2692
2693
2694
2695
2696
2697 unsigned int maxbits;
2698
2699 if (!countConditionChildMaxBits(node, m_xmlTagDeltaPhi, maxbits)) {
2700 return false;
2701 }
2702
2703 corrParameter.deltaPhiMaxbits = maxbits;
2704
2705
2706
2707
2708
2709 correlationCond.setCondType(cType);
2710 correlationCond.setObjectType(objType);
2711 correlationCond.setCondGEq(gEq);
2712 correlationCond.setCondChipNr(chipNr);
2713
2714 correlationCond.setCond0Category(condCateg[0]);
2715 correlationCond.setCond1Category(condCateg[1]);
2716
2717 correlationCond.setCond0Index(corrIndexVal[0]);
2718 correlationCond.setCond1Index(corrIndexVal[1]);
2719
2720 correlationCond.setCorrelationParameter(corrParameter);
2721
2722 if (edm::isDebugEnabled()) {
2723 std::ostringstream myCoutStream;
2724 correlationCond.print(myCoutStream);
2725 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
2726 }
2727
2728
2729
2730
2731 (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
2732
2733
2734 return true;
2735 }
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745 bool L1GtTriggerMenuXmlParser::parseId(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
2746 XERCES_CPP_NAMESPACE_USE
2747
2748 DOMNode* doc = parser->getDocument();
2749 DOMNode* n1 = doc->getFirstChild();
2750
2751
2752
2753 DOMNode* headerNode = n1->getFirstChild();
2754 if (headerNode == nullptr) {
2755 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef << "> tag found." << std::endl;
2756 return false;
2757 }
2758
2759 headerNode = findXMLChild(headerNode, m_xmlTagHeader);
2760 if (headerNode == nullptr) {
2761 LogDebug("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagHeader << "> tag"
2762 << "\n - No header information." << std::endl;
2763
2764 } else {
2765 DOMNode* idNode = headerNode->getFirstChild();
2766
2767
2768 idNode = findXMLChild(idNode, m_xmlTagMenuInterface);
2769 if (idNode == nullptr) {
2770 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuInterface << "> tag"
2771 << "\n - Trigger menu interface name derived from file name." << std::endl;
2772
2773
2774
2775 size_t xmlPos = m_triggerMenuName.find("_L1T_Scales", 0);
2776 if (xmlPos == std::string::npos) {
2777 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find \"_L1T_Scales\" "
2778 << "string in file name"
2779 << "\n - Trigger menu interface name set to file name." << std::endl;
2780 m_triggerMenuInterface = m_triggerMenuName;
2781
2782 } else {
2783 m_triggerMenuInterface = m_triggerMenuName;
2784 m_triggerMenuInterface.erase(m_triggerMenuInterface.begin(), m_triggerMenuInterface.begin() + xmlPos);
2785 }
2786
2787 } else {
2788 m_triggerMenuInterface = getXMLTextValue(idNode);
2789 }
2790
2791
2792 idNode = headerNode->getFirstChild();
2793 idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDate);
2794
2795 if (idNode == nullptr) {
2796 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuInterfaceDate << "> tag"
2797 << "\n - No creation date." << m_triggerMenuInterfaceDate << std::endl;
2798
2799 } else {
2800 m_triggerMenuInterfaceDate = getXMLTextValue(idNode);
2801 }
2802
2803
2804 idNode = headerNode->getFirstChild();
2805 idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceAuthor);
2806
2807 if (idNode == nullptr) {
2808 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuInterfaceAuthor << "> tag"
2809 << "\n - No creation author." << m_triggerMenuInterfaceAuthor << std::endl;
2810
2811 } else {
2812 m_triggerMenuInterfaceAuthor = getXMLTextValue(idNode);
2813 }
2814
2815
2816 idNode = headerNode->getFirstChild();
2817 idNode = findXMLChild(idNode, m_xmlTagMenuInterfaceDescription);
2818
2819 if (idNode == nullptr) {
2820 LogTrace("L1GtTriggerMenuXmlParser")
2821 << "\n Warning: Could not find <" << m_xmlTagMenuInterfaceDescription << "> tag"
2822 << "\n - No description." << m_triggerMenuInterfaceDescription << std::endl;
2823
2824 } else {
2825 m_triggerMenuInterfaceDescription = getXMLTextValue(idNode);
2826 }
2827
2828
2829 idNode = headerNode->getFirstChild();
2830 idNode = findXMLChild(idNode, m_xmlTagMenuDate);
2831
2832 if (idNode == nullptr) {
2833 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuDate << "> tag"
2834 << "\n - No creation date." << m_triggerMenuDate << std::endl;
2835
2836 } else {
2837 m_triggerMenuDate = getXMLTextValue(idNode);
2838 }
2839
2840
2841 idNode = headerNode->getFirstChild();
2842 idNode = findXMLChild(idNode, m_xmlTagMenuAuthor);
2843
2844 if (idNode == nullptr) {
2845 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuAuthor << "> tag"
2846 << "\n - No creation author." << m_triggerMenuAuthor << std::endl;
2847
2848 } else {
2849 m_triggerMenuAuthor = getXMLTextValue(idNode);
2850 }
2851
2852
2853 idNode = headerNode->getFirstChild();
2854 idNode = findXMLChild(idNode, m_xmlTagMenuDescription);
2855
2856 if (idNode == nullptr) {
2857 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuDescription << "> tag"
2858 << "\n - No description." << m_triggerMenuDescription << std::endl;
2859
2860 } else {
2861 m_triggerMenuDescription = getXMLTextValue(idNode);
2862 }
2863
2864
2865
2866 idNode = headerNode->getFirstChild();
2867
2868 idNode = findXMLChild(idNode, m_xmlTagMenuAlgImpl);
2869 if (idNode == nullptr) {
2870 m_algorithmImplementation = "";
2871 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagMenuAlgImpl << "> tag"
2872 << "\n - Algorithm implementation tag set to empty string." << std::endl;
2873
2874 } else {
2875 m_algorithmImplementation = getXMLTextValue(idNode);
2876 }
2877
2878
2879
2880 idNode = headerNode->getFirstChild();
2881
2882 idNode = findXMLChild(idNode, m_xmlTagScaleDbKey);
2883 if (idNode == nullptr) {
2884 m_scaleDbKey = "NULL";
2885 LogTrace("L1GtTriggerMenuXmlParser") << "\n Warning: Could not find <" << m_xmlTagScaleDbKey << "> tag"
2886 << "\n - Scale key set to " << m_scaleDbKey << " string." << std::endl;
2887
2888 } else {
2889 m_scaleDbKey = getXMLTextValue(idNode);
2890 }
2891 }
2892
2893 LogDebug("L1GtTriggerMenuXmlParser") << "\n Parsed values from XML file"
2894 << "\nL1 MenuInterface: " << m_triggerMenuInterface
2895 << "\nL1 MenuInterface - Creation date: " << m_triggerMenuInterfaceDate
2896 << "\nL1 MenuInterface - Creation author: " << m_triggerMenuInterfaceAuthor
2897 << "\nL1 MenuInterface - Description: " << m_triggerMenuInterfaceDescription
2898 << "\n"
2899 << "\nAlgorithm implementation tag: " << m_algorithmImplementation << "\n"
2900 << "\nL1 Menu - Creation date: " << m_triggerMenuDate
2901 << "\nL1 Menu - Creation author: " << m_triggerMenuAuthor
2902 << "\nL1 Menu - Description: " << m_triggerMenuDescription
2903 << std::endl;
2904
2905
2906
2907
2908
2909 std::string menuName = m_triggerMenuInterface + "/" + m_scaleDbKey + "/" + m_algorithmImplementation;
2910
2911 if (menuName != m_triggerMenuName) {
2912 LogDebug("L1GtTriggerMenuXmlParser") << "\n Warning: Inconsistent L1 menu name:"
2913 << "\n from XML file name: " << m_triggerMenuName
2914 << "\n from XML tag: " << menuName << std::endl;
2915
2916 if (!m_triggerMenuInterface.empty()) {
2917 if (m_scaleDbKey == "NULL") {
2918 m_triggerMenuName = m_triggerMenuInterface;
2919 } else {
2920 m_triggerMenuName = menuName;
2921 }
2922
2923 LogTrace("L1GtTriggerMenuXmlParser") << "\n L1 menu name set to value from XML tag!"
2924 << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
2925
2926 } else {
2927 LogTrace("L1GtTriggerMenuXmlParser") << "\n L1 menu name set to file name!"
2928 << "\n L1 Menu name: " << m_triggerMenuName << std::endl;
2929 }
2930 }
2931
2932
2933 return true;
2934 }
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947 bool L1GtTriggerMenuXmlParser::workCondition(XERCES_CPP_NAMESPACE::DOMNode* node,
2948 const std::string& name,
2949 unsigned int chipNr) {
2950 XERCES_CPP_NAMESPACE_USE
2951
2952
2953 std::string condition = getXMLAttribute(node, m_xmlConditionAttrCondition);
2954 std::string particle = getXMLAttribute(node, m_xmlConditionAttrObject);
2955 std::string type = getXMLAttribute(node, m_xmlConditionAttrType);
2956
2957 if (condition.empty() || particle.empty() || type.empty()) {
2958 edm::LogError("L1GtTriggerMenuXmlParser") << "Missing attributes for condition " << name << std::endl;
2959
2960 return false;
2961 }
2962
2963
2964
2965
2966
2967
2968
2969 if (condition == m_xmlConditionAttrConditionMuon) {
2970 return parseMuon(node, name, chipNr);
2971 } else if (condition == m_xmlConditionAttrConditionCalo) {
2972 return parseCalo(node, name, chipNr);
2973 } else if (condition == m_xmlConditionAttrConditionEnergySum) {
2974 return parseEnergySum(node, name, chipNr);
2975 } else if (condition == m_xmlConditionAttrConditionJetCounts) {
2976 return parseJetCounts(node, name, chipNr);
2977 } else if (condition == m_xmlConditionAttrConditionCastor) {
2978 return parseCastor(node, name, chipNr);
2979 } else if (condition == m_xmlConditionAttrConditionHfBitCounts) {
2980 return parseHfBitCounts(node, name, chipNr);
2981 } else if (condition == m_xmlConditionAttrConditionHfRingEtSums) {
2982 return parseHfRingEtSums(node, name, chipNr);
2983 } else if (condition == m_xmlConditionAttrConditionBptx) {
2984 return parseBptx(node, name, chipNr);
2985 } else if (condition == m_xmlConditionAttrConditionExternal) {
2986 return parseExternal(node, name, chipNr);
2987 } else if (condition == m_xmlConditionAttrConditionCorrelation) {
2988 return parseCorrelation(node, name, chipNr);
2989 } else {
2990 edm::LogError("L1GtTriggerMenuXmlParser") << "\n Error: unknown condition (" << condition << ")" << std::endl;
2991
2992 return false;
2993 }
2994
2995 return true;
2996 }
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008 bool L1GtTriggerMenuXmlParser::parseConditions(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3009 XERCES_CPP_NAMESPACE_USE
3010
3011 LogTrace("L1GtTriggerMenuXmlParser") << "\nParsing conditions" << std::endl;
3012
3013 DOMNode* doc = parser->getDocument();
3014 DOMNode* n1 = doc->getFirstChild();
3015
3016
3017
3018 DOMNode* chipNode = n1->getFirstChild();
3019 if (chipNode == nullptr) {
3020 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: No child of <" << m_xmlTagDef << "> tag found." << std::endl;
3021
3022 return false;
3023 }
3024
3025
3026
3027 std::string chipName;
3028 chipNode = findXMLChild(chipNode, m_xmlTagChip, true, &chipName);
3029 if (chipNode == nullptr) {
3030 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: Could not find <" << m_xmlTagChip << "> tag" << std::endl;
3031
3032 return false;
3033 }
3034
3035 unsigned int chipNr = 0;
3036 do {
3037
3038 DOMNode* conditionsNode = chipNode->getFirstChild();
3039 conditionsNode = findXMLChild(conditionsNode, m_xmlTagConditions);
3040 if (conditionsNode == nullptr) {
3041 edm::LogError("L1GtTriggerMenuXmlParser")
3042 << "Error: No <" << m_xmlTagConditions << "> child found in Chip " << chipName << std::endl;
3043
3044 return false;
3045 }
3046
3047 char* nodeName = XMLString::transcode(chipNode->getNodeName());
3048
3049
3050
3051
3052 XMLString::release(&nodeName);
3053
3054
3055 DOMNode* conditionNameNode = conditionsNode->getFirstChild();
3056 std::string conditionNameNodeName;
3057 conditionNameNode = findXMLChild(conditionNameNode, "", true, &conditionNameNodeName);
3058 while (conditionNameNode != nullptr) {
3059 LogTrace("L1GtTriggerMenuXmlParser")
3060 << "\n Found a condition with name: " << conditionNameNodeName << std::endl;
3061
3062 if (!workCondition(conditionNameNode, conditionNameNodeName, chipNr)) {
3063 return false;
3064 }
3065 conditionNameNode = findXMLChild(conditionNameNode->getNextSibling(), "", true, &conditionNameNodeName);
3066 }
3067
3068 chipNode = findXMLChild(chipNode->getNextSibling(), m_xmlTagChip, true, &chipName);
3069 chipNr++;
3070
3071 } while (chipNode != nullptr && chipNr < m_numberConditionChips);
3072
3073 return true;
3074 }
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087 bool L1GtTriggerMenuXmlParser::workAlgorithm(XERCES_CPP_NAMESPACE::DOMNode* node,
3088 const std::string& algName,
3089 unsigned int chipNr) {
3090 XERCES_CPP_NAMESPACE_USE
3091
3092 if (node == nullptr) {
3093 LogDebug("L1GtTriggerMenuXmlParser") << " Node is 0 in " << __PRETTY_FUNCTION__
3094 << " can not parse the algorithm " << algName << std::endl;
3095 return false;
3096 }
3097
3098
3099 std::string algAlias = getXMLAttribute(node, m_xmlAlgorithmAttrAlias);
3100
3101 if (algAlias.empty()) {
3102 algAlias = algName;
3103 LogDebug("L1GtTriggerMenuXmlParser") << "\n No alias defined for algorithm. Alias set to algorithm name."
3104 << "\n Algorithm name: " << algName
3105 << "\n Algorithm alias: " << algAlias << std::endl;
3106 } else {
3107 LogDebug("L1GtTriggerMenuXmlParser") << "\n Alias defined for algorithm."
3108 << "\n Algorithm name: " << algName
3109 << "\n Algorithm alias: " << algAlias << std::endl;
3110 }
3111
3112
3113 std::string logExpression = getXMLTextValue(node);
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124 std::string pinString;
3125 int outputPin = 0;
3126
3127 DOMNode* pinNode = node->getFirstChild();
3128 if ((pinNode = findXMLChild(pinNode, m_xmlTagOutputPin)) != nullptr) {
3129 pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
3130
3131
3132 std::istringstream opStream(pinString);
3133
3134 if ((opStream >> outputPin).fail()) {
3135 LogDebug("L1GtTriggerMenuXmlParser")
3136 << " Unable to convert pin string " << pinString << " to int for algorithm : " << algName << std::endl;
3137
3138 return false;
3139 }
3140 }
3141
3142 if (pinNode == nullptr) {
3143 LogTrace("L1GtTriggerMenuXmlParser") << " Warning: No pin number found for algorithm: " << algName << std::endl;
3144
3145 return false;
3146 }
3147
3148
3149
3150
3151
3152
3153
3154 int bitNumber = outputPin + (m_orderConditionChip[chipNr] - 1) * m_pinsOnConditionChip - 1;
3155
3156
3157
3158
3159
3160
3161 L1GtAlgorithm alg(algName, logExpression, bitNumber);
3162 alg.setAlgoChipNumber(static_cast<int>(chipNr));
3163 alg.setAlgoAlias(algAlias);
3164
3165 if (edm::isDebugEnabled()) {
3166 std::ostringstream myCoutStream;
3167 alg.print(myCoutStream);
3168 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3169 }
3170
3171
3172 if (!insertAlgorithmIntoMap(alg)) {
3173 return false;
3174 }
3175
3176 return true;
3177 }
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192 bool L1GtTriggerMenuXmlParser::parseAlgorithms(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3193 XERCES_CPP_NAMESPACE_USE
3194
3195
3196
3197 DOMNode* doc = parser->getDocument();
3198 DOMNode* node = doc->getFirstChild();
3199
3200 DOMNode* chipNode = node->getFirstChild();
3201 if (chipNode == nullptr) {
3202 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: No child found for " << m_xmlTagDef << std::endl;
3203 return false;
3204 }
3205
3206
3207 std::string chipName;
3208 chipNode = findXMLChild(chipNode, m_xmlTagChip, true, &chipName);
3209 if (chipNode == nullptr) {
3210 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: Could not find <" << m_xmlTagChip << std::endl;
3211 return false;
3212 }
3213
3214 unsigned int chipNr = 0;
3215 do {
3216
3217
3218 std::string nodeName = m_xmlTagChip + chipName;
3219
3220
3221
3222
3223
3224 DOMNode* algNode = chipNode->getFirstChild();
3225 algNode = findXMLChild(algNode, m_xmlTagAlgorithms);
3226 if (algNode == nullptr) {
3227 edm::LogError("L1GtTriggerMenuXmlParser")
3228 << " Error: No <" << m_xmlTagAlgorithms << "> child found in chip " << chipName << std::endl;
3229 return false;
3230 }
3231
3232
3233 DOMNode* algNameNode = algNode->getFirstChild();
3234 std::string algNameNodeName;
3235 algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
3236
3237 while (algNameNode != nullptr) {
3238
3239
3240
3241
3242 if (!workAlgorithm(algNameNode, algNameNodeName, chipNr)) {
3243 return false;
3244 }
3245
3246 algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true, &algNameNodeName);
3247 }
3248
3249
3250 chipNode = findXMLChild(chipNode->getNextSibling(), m_xmlTagChip, true, &chipName);
3251 chipNr++;
3252
3253 } while (chipNode != nullptr && chipNr < m_numberConditionChips);
3254
3255 return true;
3256 }
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268 bool L1GtTriggerMenuXmlParser::workTechTrigger(XERCES_CPP_NAMESPACE::DOMNode* node, const std::string& algName) {
3269 XERCES_CPP_NAMESPACE_USE
3270
3271 if (node == nullptr) {
3272 LogDebug("L1GtTriggerMenuXmlParser") << " Node is 0 in " << __PRETTY_FUNCTION__
3273 << " can not parse the technical trigger " << algName << std::endl;
3274 return false;
3275 }
3276
3277
3278 std::string logExpression = getXMLTextValue(node);
3279
3280
3281
3282
3283
3284
3285 std::string pinString;
3286 int outputPin = 0;
3287
3288 DOMNode* pinNode = node->getFirstChild();
3289 if ((pinNode = findXMLChild(pinNode, m_xmlTagOutputPin)) != nullptr) {
3290 pinString = getXMLAttribute(pinNode, m_xmlAttrNr);
3291
3292
3293 std::istringstream opStream(pinString);
3294
3295 if ((opStream >> outputPin).fail()) {
3296 LogDebug("L1GtTriggerMenuXmlParser") << " Unable to convert pin string " << pinString
3297 << " to int for technical trigger : " << algName << std::endl;
3298
3299 return false;
3300 }
3301 }
3302
3303 if (pinNode == nullptr) {
3304 LogTrace("L1GtTriggerMenuXmlParser") << " Warning: No pin number found for technical trigger: " << algName
3305 << std::endl;
3306
3307 return false;
3308 }
3309
3310
3311 int bitNumber = outputPin;
3312
3313
3314
3315
3316
3317
3318
3319 L1GtAlgorithm alg(algName, logExpression, bitNumber);
3320 alg.setAlgoAlias(algName);
3321
3322 if (edm::isDebugEnabled()) {
3323 std::ostringstream myCoutStream;
3324 alg.print(myCoutStream);
3325 LogTrace("L1GtTriggerMenuXmlParser") << myCoutStream.str() << "\n" << std::endl;
3326 }
3327
3328
3329 if (!insertTechTriggerIntoMap(alg)) {
3330 return false;
3331 }
3332
3333 return true;
3334 }
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345 bool L1GtTriggerMenuXmlParser::parseTechTriggers(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3346 XERCES_CPP_NAMESPACE_USE
3347
3348
3349
3350 DOMNode* doc = parser->getDocument();
3351 DOMNode* node = doc->getFirstChild();
3352
3353 DOMNode* algNode = node->getFirstChild();
3354 if (algNode == nullptr) {
3355 edm::LogError("L1GtTriggerMenuXmlParser") << " Error: No child found for " << m_xmlTagDef << std::endl;
3356 return false;
3357 }
3358
3359 algNode = findXMLChild(algNode, m_xmlTagTechTriggers);
3360 if (algNode == nullptr) {
3361 edm::LogError("L1GtTriggerMenuXmlParser")
3362 << " Error: No <" << m_xmlTagTechTriggers << "> child found." << std::endl;
3363 return false;
3364 }
3365
3366
3367 DOMNode* algNameNode = algNode->getFirstChild();
3368 std::string algNameNodeName;
3369 algNameNode = findXMLChild(algNameNode, "", true, &algNameNodeName);
3370
3371 while (algNameNode != nullptr) {
3372
3373
3374
3375
3376 if (!workTechTrigger(algNameNode, algNameNodeName)) {
3377 return false;
3378 }
3379
3380 algNameNode = findXMLChild(algNameNode->getNextSibling(), "", true, &algNameNodeName);
3381 }
3382
3383 return true;
3384 }
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394 bool L1GtTriggerMenuXmlParser::workXML(XERCES_CPP_NAMESPACE::XercesDOMParser* parser) {
3395 XERCES_CPP_NAMESPACE_USE
3396
3397 DOMDocument* doc = parser->getDocument();
3398 DOMNode* n1 = doc->getFirstChild();
3399
3400 if (n1 == nullptr) {
3401 edm::LogError("L1GtTriggerMenuXmlParser") << "Error: Found no XML child" << std::endl;
3402
3403 return false;
3404 }
3405
3406 char* nodeName = XMLString::transcode(n1->getNodeName());
3407
3408 if (XMLString::compareIString(nodeName, m_xmlTagDef.c_str())) {
3409 edm::LogError("L1GtTriggerMenuXmlParser")
3410 << "Error: First XML child is not \" " << m_xmlTagDef << "\" " << std::endl;
3411
3412 return false;
3413 }
3414
3415 LogTrace("L1GtTriggerMenuXmlParser") << "\nFirst node name is: " << nodeName << std::endl;
3416 XMLString::release(&nodeName);
3417
3418
3419 clearMaps();
3420
3421 if (!parseId(parser)) {
3422 clearMaps();
3423 return false;
3424 }
3425
3426 if (!parseConditions(parser)) {
3427 clearMaps();
3428 return false;
3429 }
3430
3431 if (!parseAlgorithms(parser)) {
3432 clearMaps();
3433 return false;
3434 }
3435
3436 if (!parseTechTriggers(parser)) {
3437 clearMaps();
3438 return false;
3439 }
3440
3441 return true;
3442 }
3443
3444