Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:55:06

0001 /**
0002  * \class TriggerMenuParser
0003  *
0004  *
0005  * Description: Xerces-C XML parser for the L1 Trigger menu.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  * \orig author: Vasile Mihai Ghete - HEPHY Vienna
0011  *
0012  * \new features: Vladimir Rekovic
0013  *                - indexing
0014  *                - correlations with overlap object removal
0015  * \new features: Richard Cavanaugh
0016  *                - LLP displaced muons
0017  *                - LLP displaced jets
0018  * \new features: Elisa Fontanesi
0019  *                - extended for three-body correlation conditions
0020  * \new features: Dragana Pilipovic
0021  *                - updated for invariant mass over delta R condition
0022  * \new features: Bernhard Arnold, Elisa Fontanesi
0023  *                - extended for muon track finder index feature (used for Run 3 muon monitoring seeds)
0024  *                - checkRangeEta function allows to use up to five eta cuts in L1 algorithms
0025  * \new features: Elisa Fontanesi
0026  *                - extended for Zero Degree Calorimeter triggers (used for Run 3 HI data-taking)
0027  * \new features: Melissa Quinnan, Elisa Fontanesi
0028  *                - extended for AXOL1TL anomaly detection triggers (used for Run 3 data-taking)
0029  *
0030  * $Date$
0031  * $Revision$
0032  *
0033  */
0034 
0035 // this class header
0036 #include "TriggerMenuParser.h"
0037 
0038 // system include files
0039 #include <string>
0040 #include <vector>
0041 
0042 #include <iostream>
0043 #include <fstream>
0044 #include <iomanip>
0045 #include <cmath>
0046 
0047 #include "L1Trigger/L1TGlobal/interface/GlobalCondition.h"
0048 
0049 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0050 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0051 
0052 #include "tmEventSetup/tmEventSetup.hh"
0053 #include "tmEventSetup/esTypes.hh"
0054 
0055 #include "CondFormats/L1TObjects/interface/L1TUtmTriggerMenu.h"
0056 #include "CondFormats/L1TObjects/interface/L1TUtmAlgorithm.h"
0057 #include "CondFormats/L1TObjects/interface/L1TUtmCondition.h"
0058 #include "CondFormats/L1TObjects/interface/L1TUtmObject.h"
0059 #include "CondFormats/L1TObjects/interface/L1TUtmCut.h"
0060 #include "CondFormats/L1TObjects/interface/L1TUtmScale.h"
0061 #include "tmGrammar/Algorithm.hh"
0062 
0063 #include <cstdint>
0064 
0065 // constructor
0066 l1t::TriggerMenuParser::TriggerMenuParser()
0067     : m_triggerMenuInterface("NULL"),
0068       m_triggerMenuName("NULL"),
0069       m_triggerMenuImplementation(0x0),
0070       m_scaleDbKey("NULL")
0071 
0072 {
0073   // menu names, scale key initialized to NULL due to ORACLE treatment of strings
0074 
0075   // empty
0076 }
0077 
0078 // destructor
0079 l1t::TriggerMenuParser::~TriggerMenuParser() { clearMaps(); }
0080 
0081 // set the number of condition chips in GTL
0082 void l1t::TriggerMenuParser::setGtNumberConditionChips(const unsigned int& numberConditionChipsValue) {
0083   m_numberConditionChips = numberConditionChipsValue;
0084 }
0085 
0086 // set the number of pins on the GTL condition chips
0087 void l1t::TriggerMenuParser::setGtPinsOnConditionChip(const unsigned int& pinsOnConditionChipValue) {
0088   m_pinsOnConditionChip = pinsOnConditionChipValue;
0089 }
0090 
0091 // set the correspondence "condition chip - GTL algorithm word"
0092 // in the hardware
0093 void l1t::TriggerMenuParser::setGtOrderConditionChip(const std::vector<int>& orderConditionChipValue) {
0094   m_orderConditionChip = orderConditionChipValue;
0095 }
0096 
0097 // set the number of physics trigger algorithms
0098 void l1t::TriggerMenuParser::setGtNumberPhysTriggers(const unsigned int& numberPhysTriggersValue) {
0099   m_numberPhysTriggers = numberPhysTriggersValue;
0100 }
0101 
0102 // set the condition maps
0103 void l1t::TriggerMenuParser::setGtConditionMap(const std::vector<ConditionMap>& condMap) { m_conditionMap = condMap; }
0104 
0105 // set the trigger menu name
0106 void l1t::TriggerMenuParser::setGtTriggerMenuInterface(const std::string& menuInterface) {
0107   m_triggerMenuInterface = menuInterface;
0108 }
0109 
0110 // set the trigger menu uuid
0111 void l1t::TriggerMenuParser::setGtTriggerMenuUUID(const int uuid) { m_triggerMenuUUID = uuid; }
0112 
0113 void l1t::TriggerMenuParser::setGtTriggerMenuName(const std::string& menuName) { m_triggerMenuName = menuName; }
0114 
0115 void l1t::TriggerMenuParser::setGtTriggerMenuImplementation(const unsigned long& menuImplementation) {
0116   m_triggerMenuImplementation = menuImplementation;
0117 }
0118 
0119 // set menu associated scale key
0120 void l1t::TriggerMenuParser::setGtScaleDbKey(const std::string& scaleKey) { m_scaleDbKey = scaleKey; }
0121 
0122 // set the vectors containing the conditions
0123 void l1t::TriggerMenuParser::setVecMuonTemplate(const std::vector<std::vector<MuonTemplate> >& vecMuonTempl) {
0124   m_vecMuonTemplate = vecMuonTempl;
0125 }
0126 
0127 void l1t::TriggerMenuParser::setVecMuonShowerTemplate(
0128     const std::vector<std::vector<MuonShowerTemplate> >& vecMuonShowerTempl) {
0129   m_vecMuonShowerTemplate = vecMuonShowerTempl;
0130 }
0131 
0132 void l1t::TriggerMenuParser::setVecCaloTemplate(const std::vector<std::vector<CaloTemplate> >& vecCaloTempl) {
0133   m_vecCaloTemplate = vecCaloTempl;
0134 }
0135 
0136 void l1t::TriggerMenuParser::setVecEnergySumTemplate(
0137     const std::vector<std::vector<EnergySumTemplate> >& vecEnergySumTempl) {
0138   m_vecEnergySumTemplate = vecEnergySumTempl;
0139 }
0140 
0141 void l1t::TriggerMenuParser::setVecEnergySumZdcTemplate(
0142     const std::vector<std::vector<EnergySumZdcTemplate> >& vecEnergySumZdcTempl) {
0143   m_vecEnergySumZdcTemplate = vecEnergySumZdcTempl;
0144 }
0145 
0146 void l1t::TriggerMenuParser::setVecAXOL1TLTemplate(const std::vector<std::vector<AXOL1TLTemplate> >& vecAXOL1TLTempl) {
0147   m_vecAXOL1TLTemplate = vecAXOL1TLTempl;
0148 }
0149 
0150 void l1t::TriggerMenuParser::setVecExternalTemplate(
0151     const std::vector<std::vector<ExternalTemplate> >& vecExternalTempl) {
0152   m_vecExternalTemplate = vecExternalTempl;
0153 }
0154 
0155 void l1t::TriggerMenuParser::setVecCorrelationTemplate(
0156     const std::vector<std::vector<CorrelationTemplate> >& vecCorrelationTempl) {
0157   m_vecCorrelationTemplate = vecCorrelationTempl;
0158 }
0159 
0160 void l1t::TriggerMenuParser::setVecCorrelationThreeBodyTemplate(
0161     const std::vector<std::vector<CorrelationThreeBodyTemplate> >& vecCorrelationThreeBodyTempl) {
0162   m_vecCorrelationThreeBodyTemplate = vecCorrelationThreeBodyTempl;
0163 }
0164 
0165 void l1t::TriggerMenuParser::setVecCorrelationWithOverlapRemovalTemplate(
0166     const std::vector<std::vector<CorrelationWithOverlapRemovalTemplate> >& vecCorrelationWithOverlapRemovalTempl) {
0167   m_vecCorrelationWithOverlapRemovalTemplate = vecCorrelationWithOverlapRemovalTempl;
0168 }
0169 
0170 // set the vectors containing the conditions for correlation templates
0171 //
0172 void l1t::TriggerMenuParser::setCorMuonTemplate(const std::vector<std::vector<MuonTemplate> >& corMuonTempl) {
0173   m_corMuonTemplate = corMuonTempl;
0174 }
0175 
0176 void l1t::TriggerMenuParser::setCorCaloTemplate(const std::vector<std::vector<CaloTemplate> >& corCaloTempl) {
0177   m_corCaloTemplate = corCaloTempl;
0178 }
0179 
0180 void l1t::TriggerMenuParser::setCorEnergySumTemplate(
0181     const std::vector<std::vector<EnergySumTemplate> >& corEnergySumTempl) {
0182   m_corEnergySumTemplate = corEnergySumTempl;
0183 }
0184 
0185 // set the algorithm map (by algorithm names)
0186 void l1t::TriggerMenuParser::setGtAlgorithmMap(const AlgorithmMap& algoMap) { m_algorithmMap = algoMap; }
0187 
0188 // set the algorithm map (by algorithm aliases)
0189 void l1t::TriggerMenuParser::setGtAlgorithmAliasMap(const AlgorithmMap& algoMap) { m_algorithmAliasMap = algoMap; }
0190 
0191 std::map<std::string, unsigned int> l1t::TriggerMenuParser::getExternalSignals(const L1TUtmTriggerMenu* utmMenu) {
0192   using namespace tmeventsetup;
0193   const std::map<std::string, L1TUtmCondition>& condMap = utmMenu->getConditionMap();
0194 
0195   std::map<std::string, unsigned int> extBitMap;
0196 
0197   //loop over the algorithms
0198   for (const auto& cit : condMap) {
0199     const L1TUtmCondition& condition = cit.second;
0200     if (condition.getType() == esConditionType::Externals) {
0201       // Get object for External conditions
0202       const std::vector<L1TUtmObject>& objects = condition.getObjects();
0203       for (const auto& object : objects) {
0204         if (object.getType() == esObjectType::EXT) {
0205           unsigned int channelID = object.getExternalChannelId();
0206           std::string name = object.getExternalSignalName();
0207 
0208           if (extBitMap.count(name) == 0)
0209             extBitMap.insert(std::map<std::string, unsigned int>::value_type(name, channelID));
0210         }
0211       }
0212     }
0213   }
0214 
0215   return extBitMap;
0216 }
0217 
0218 // parse def.xml file
0219 void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu) {
0220   // resize the vector of condition maps
0221   // the number of condition chips should be correctly set before calling parseXmlFile
0222   m_conditionMap.resize(m_numberConditionChips);
0223 
0224   m_vecMuonTemplate.resize(m_numberConditionChips);
0225   m_vecMuonShowerTemplate.resize(m_numberConditionChips);
0226   m_vecCaloTemplate.resize(m_numberConditionChips);
0227   m_vecEnergySumTemplate.resize(m_numberConditionChips);
0228   m_vecEnergySumZdcTemplate.resize(m_numberConditionChips);
0229   m_vecAXOL1TLTemplate.resize(m_numberConditionChips);
0230   m_vecExternalTemplate.resize(m_numberConditionChips);
0231 
0232   m_vecCorrelationTemplate.resize(m_numberConditionChips);
0233   m_vecCorrelationThreeBodyTemplate.resize(m_numberConditionChips);
0234   m_vecCorrelationWithOverlapRemovalTemplate.resize(m_numberConditionChips);
0235   m_corMuonTemplate.resize(m_numberConditionChips);
0236   m_corCaloTemplate.resize(m_numberConditionChips);
0237   m_corEnergySumTemplate.resize(m_numberConditionChips);
0238 
0239   using namespace tmeventsetup;
0240   using namespace Algorithm;
0241 
0242   //get the meta data
0243   m_triggerMenuDescription = utmMenu->getComment();
0244   m_triggerMenuDate = utmMenu->getDatetime();
0245   m_triggerMenuImplementation = (getMmHashN(utmMenu->getFirmwareUuid()) & 0xFFFFFFFF);  //make sure we only have 32 bits
0246   m_triggerMenuName = utmMenu->getName();
0247   m_triggerMenuInterface = utmMenu->getVersion();                     //BLW: correct descriptor?
0248   m_triggerMenuUUID = (getMmHashN(utmMenu->getName()) & 0xFFFFFFFF);  //make sure we only have 32 bits
0249 
0250   const std::map<std::string, L1TUtmAlgorithm>& algoMap = utmMenu->getAlgorithmMap();
0251   const std::map<std::string, L1TUtmCondition>& condMap = utmMenu->getConditionMap();
0252   //We use es types for scale map to use auxiliary functions without having to duplicate code
0253   const std::map<std::string, tmeventsetup::esScale> scaleMap(std::begin(utmMenu->getScaleMap()),
0254                                                               std::end(utmMenu->getScaleMap()));
0255 
0256   // parse the scales
0257   m_gtScales.setScalesName(utmMenu->getScaleSetName());
0258   parseScales(scaleMap);
0259 
0260   //loop over the algorithms
0261   for (const auto& cit : algoMap) {
0262     //condition chip (artifact)  TO DO: Update
0263     int chipNr = 0;
0264 
0265     //get algorithm
0266     const L1TUtmAlgorithm& algo = cit.second;
0267 
0268     //parse the algorithm
0269     parseAlgorithm(algo, chipNr);  //blw
0270 
0271     //get conditions for this algorithm
0272     const std::vector<std::string>& rpn_vec = algo.getRpnVector();
0273     for (size_t ii = 0; ii < rpn_vec.size(); ii++) {
0274       const std::string& token = rpn_vec.at(ii);
0275       if (isGate(token))
0276         continue;
0277       //      long hash = getHash(token);
0278       const L1TUtmCondition& condition = condMap.find(token)->second;
0279 
0280       //check to see if this condtion already exists
0281       if ((m_conditionMap[chipNr]).count(condition.getName()) == 0) {
0282         // parse Calo Conditions (EG, Jets, Taus)
0283         if (condition.getType() == esConditionType::SingleEgamma ||
0284             condition.getType() == esConditionType::DoubleEgamma ||
0285             condition.getType() == esConditionType::TripleEgamma ||
0286             condition.getType() == esConditionType::QuadEgamma || condition.getType() == esConditionType::SingleTau ||
0287             condition.getType() == esConditionType::DoubleTau || condition.getType() == esConditionType::TripleTau ||
0288             condition.getType() == esConditionType::QuadTau || condition.getType() == esConditionType::SingleJet ||
0289             condition.getType() == esConditionType::DoubleJet || condition.getType() == esConditionType::TripleJet ||
0290             condition.getType() == esConditionType::QuadJet) {
0291           parseCalo(condition, chipNr, false);
0292 
0293           // parse Energy Sums (and HI trigger objects, treated as energy sums or counters)
0294         } else if (condition.getType() == esConditionType::TotalEt ||
0295                    condition.getType() == esConditionType::TotalEtEM ||
0296                    condition.getType() == esConditionType::TotalHt ||
0297                    condition.getType() == esConditionType::MissingEt ||
0298                    condition.getType() == esConditionType::MissingHt ||
0299                    condition.getType() == esConditionType::MissingEtHF ||
0300                    condition.getType() == esConditionType::TowerCount ||
0301                    condition.getType() == esConditionType::MinBiasHFP0 ||
0302                    condition.getType() == esConditionType::MinBiasHFM0 ||
0303                    condition.getType() == esConditionType::MinBiasHFP1 ||
0304                    condition.getType() == esConditionType::MinBiasHFM1 ||
0305                    condition.getType() == esConditionType::AsymmetryEt ||
0306                    condition.getType() == esConditionType::AsymmetryHt ||
0307                    condition.getType() == esConditionType::AsymmetryEtHF ||
0308                    condition.getType() == esConditionType::AsymmetryHtHF ||
0309                    condition.getType() == esConditionType::Centrality0 ||
0310                    condition.getType() == esConditionType::Centrality1 ||
0311                    condition.getType() == esConditionType::Centrality2 ||
0312                    condition.getType() == esConditionType::Centrality3 ||
0313                    condition.getType() == esConditionType::Centrality4 ||
0314                    condition.getType() == esConditionType::Centrality5 ||
0315                    condition.getType() == esConditionType::Centrality6 ||
0316                    condition.getType() == esConditionType::Centrality7) {
0317           parseEnergySum(condition, chipNr, false);
0318 
0319           // parse ZDC Energy Sums (NOTE: HI trigger objects are treated as energy sums or counters)
0320         } else if (condition.getType() == esConditionType::ZDCPlus ||
0321                    condition.getType() == esConditionType::ZDCMinus) {
0322           parseEnergySumZdc(condition, chipNr, false);
0323 
0324           //parse AXOL1TL
0325         } else if (condition.getType() == esConditionType::AnomalyDetectionTrigger) {
0326           parseAXOL1TL(condition, chipNr);
0327 
0328           //parse Muons
0329         } else if (condition.getType() == esConditionType::SingleMuon ||
0330                    condition.getType() == esConditionType::DoubleMuon ||
0331                    condition.getType() == esConditionType::TripleMuon ||
0332                    condition.getType() == esConditionType::QuadMuon) {
0333           parseMuon(condition, chipNr, false);
0334 
0335         } else if (condition.getType() == esConditionType::MuonShower0 ||
0336                    condition.getType() == esConditionType::MuonShower1 ||
0337                    condition.getType() == esConditionType::MuonShower2 ||
0338                    condition.getType() == esConditionType::MuonShowerOutOfTime0 ||
0339                    condition.getType() == esConditionType::MuonShowerOutOfTime1) {
0340           parseMuonShower(condition, chipNr, false);
0341 
0342           //parse Correlation Conditions
0343         } else if (condition.getType() == esConditionType::MuonMuonCorrelation ||
0344                    condition.getType() == esConditionType::MuonEsumCorrelation ||
0345                    condition.getType() == esConditionType::CaloMuonCorrelation ||
0346                    condition.getType() == esConditionType::CaloCaloCorrelation ||
0347                    condition.getType() == esConditionType::CaloEsumCorrelation ||
0348                    condition.getType() == esConditionType::InvariantMass ||
0349                    condition.getType() == esConditionType::InvariantMassDeltaR ||
0350                    condition.getType() == esConditionType::TransverseMass ||
0351                    condition.getType() == esConditionType::InvariantMassUpt) {  // Added for displaced muons
0352           parseCorrelation(condition, chipNr);
0353 
0354           //parse three-body Correlation Conditions
0355         } else if (condition.getType() == esConditionType::InvariantMass3) {
0356           parseCorrelationThreeBody(condition, chipNr);
0357 
0358           //parse Externals
0359         } else if (condition.getType() == esConditionType::Externals) {
0360           parseExternal(condition, chipNr);
0361 
0362           //parse CorrelationWithOverlapRemoval
0363         } else if (condition.getType() == esConditionType::CaloCaloCorrelationOvRm ||
0364                    condition.getType() == esConditionType::InvariantMassOvRm ||
0365                    condition.getType() == esConditionType::TransverseMassOvRm ||
0366                    condition.getType() == esConditionType::DoubleJetOvRm ||
0367                    condition.getType() == esConditionType::DoubleTauOvRm) {
0368           parseCorrelationWithOverlapRemoval(condition, chipNr);
0369 
0370         } else if (condition.getType() == esConditionType::SingleEgammaOvRm ||
0371                    condition.getType() == esConditionType::DoubleEgammaOvRm ||
0372                    condition.getType() == esConditionType::TripleEgammaOvRm ||
0373                    condition.getType() == esConditionType::QuadEgammaOvRm ||
0374                    condition.getType() == esConditionType::SingleTauOvRm ||
0375                    condition.getType() == esConditionType::TripleTauOvRm ||
0376                    condition.getType() == esConditionType::QuadTauOvRm ||
0377                    condition.getType() == esConditionType::SingleJetOvRm ||
0378                    condition.getType() == esConditionType::TripleJetOvRm ||
0379                    condition.getType() == esConditionType::QuadJetOvRm) {
0380           edm::LogError("TriggerMenuParser") << std::endl
0381                                              << "\n SingleEgammaOvRm"
0382                                              << "\n DoubleEgammaOvRm"
0383                                              << "\n TripleEgammaOvRm"
0384                                              << "\n QuadEgammaOvRm"
0385                                              << "\n SingleTauOvRm"
0386                                              << "\n TripleTauOvRm"
0387                                              << "\n QuadTauOvRm"
0388                                              << "\n SingleJetOvRm"
0389                                              << "\n TripleJetOvRm"
0390                                              << "\n QuadJetOvRm"
0391                                              << "\n The above conditions types OvRm are not implemented yet in the "
0392                                                 "parser. Please remove alogrithms that "
0393                                                 "use this type of condtion from L1T Menu!"
0394                                              << std::endl;
0395         }
0396 
0397       }  //if condition is a new one
0398     }    //loop over conditions
0399   }      //loop over algorithms
0400 
0401   return;
0402 }
0403 
0404 //
0405 
0406 void l1t::TriggerMenuParser::setGtTriggerMenuInterfaceDate(const std::string& val) { m_triggerMenuInterfaceDate = val; }
0407 
0408 void l1t::TriggerMenuParser::setGtTriggerMenuInterfaceAuthor(const std::string& val) {
0409   m_triggerMenuInterfaceAuthor = val;
0410 }
0411 
0412 void l1t::TriggerMenuParser::setGtTriggerMenuInterfaceDescription(const std::string& val) {
0413   m_triggerMenuInterfaceDescription = val;
0414 }
0415 
0416 void l1t::TriggerMenuParser::setGtTriggerMenuDate(const std::string& val) { m_triggerMenuDate = val; }
0417 
0418 void l1t::TriggerMenuParser::setGtTriggerMenuAuthor(const std::string& val) { m_triggerMenuAuthor = val; }
0419 
0420 void l1t::TriggerMenuParser::setGtTriggerMenuDescription(const std::string& val) { m_triggerMenuDescription = val; }
0421 
0422 void l1t::TriggerMenuParser::setGtAlgorithmImplementation(const std::string& val) { m_algorithmImplementation = val; }
0423 
0424 // methods for conditions and algorithms
0425 
0426 // clearMaps - delete all conditions and algorithms in
0427 // the maps and clear the maps.
0428 void l1t::TriggerMenuParser::clearMaps() {
0429   // loop over condition maps (one map per condition chip)
0430   // then loop over conditions in the map
0431   for (std::vector<ConditionMap>::iterator itCondOnChip = m_conditionMap.begin(); itCondOnChip != m_conditionMap.end();
0432        itCondOnChip++) {
0433     // the conditions in the maps are deleted in L1uGtTriggerMenu, not here
0434 
0435     itCondOnChip->clear();
0436   }
0437 
0438   // the algorithms in the maps are deleted in L1uGtTriggerMenu, not here
0439   m_algorithmMap.clear();
0440 }
0441 
0442 // insertConditionIntoMap - safe insert of condition into condition map.
0443 // if the condition name already exists, do not insert it and return false
0444 bool l1t::TriggerMenuParser::insertConditionIntoMap(GlobalCondition& cond, const int chipNr) {
0445   std::string cName = cond.condName();
0446   LogTrace("TriggerMenuParser") << "    Trying to insert condition \"" << cName << "\" in the condition map."
0447                                 << std::endl;
0448 
0449   // no condition name has to appear twice!
0450   if ((m_conditionMap[chipNr]).count(cName) != 0) {
0451     LogTrace("TriggerMenuParser") << "      Condition " << cName << " already exists - not inserted!" << std::endl;
0452     return false;
0453   }
0454 
0455   (m_conditionMap[chipNr])[cName] = &cond;
0456   LogTrace("TriggerMenuParser") << "      OK - condition inserted!" << std::endl;
0457 
0458   return true;
0459 }
0460 
0461 // insert an algorithm into algorithm map
0462 bool l1t::TriggerMenuParser::insertAlgorithmIntoMap(const GlobalAlgorithm& alg) {
0463   std::string algName = alg.algoName();
0464   const std::string& algAlias = alg.algoAlias();
0465   //LogTrace("TriggerMenuParser")
0466   //<< "    Trying to insert algorithm \"" << algName << "\" in the algorithm map." ;
0467 
0468   // no algorithm name has to appear twice!
0469   if (m_algorithmMap.count(algName) != 0) {
0470     LogTrace("TriggerMenuParser") << "      Algorithm \"" << algName
0471                                   << "\"already exists in the algorithm map- not inserted!" << std::endl;
0472     return false;
0473   }
0474 
0475   if (m_algorithmAliasMap.count(algAlias) != 0) {
0476     LogTrace("TriggerMenuParser") << "      Algorithm alias \"" << algAlias
0477                                   << "\"already exists in the algorithm alias map- not inserted!" << std::endl;
0478     return false;
0479   }
0480 
0481   // bit number less than zero or greater than maximum number of algorithms
0482   int bitNumber = alg.algoBitNumber();
0483   if ((bitNumber < 0) || (bitNumber >= static_cast<int>(m_numberPhysTriggers))) {
0484     LogTrace("TriggerMenuParser") << "      Bit number " << bitNumber << " outside allowed range [0, "
0485                                   << m_numberPhysTriggers << ") - algorithm not inserted!" << std::endl;
0486     return false;
0487   }
0488 
0489   // maximum number of algorithms
0490   if (m_algorithmMap.size() >= m_numberPhysTriggers) {
0491     LogTrace("TriggerMenuParser") << "      More than maximum allowed " << m_numberPhysTriggers
0492                                   << " algorithms in the algorithm map - not inserted!" << std::endl;
0493     return false;
0494   }
0495 
0496   // chip number outside allowed values
0497   int chipNr = alg.algoChipNumber(
0498       static_cast<int>(m_numberConditionChips), static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
0499 
0500   if ((chipNr < 0) || (chipNr > static_cast<int>(m_numberConditionChips))) {
0501     LogTrace("TriggerMenuParser") << "      Chip number " << chipNr << " outside allowed range [0, "
0502                                   << m_numberConditionChips << ") - algorithm not inserted!" << std::endl;
0503     return false;
0504   }
0505 
0506   // output pin outside allowed values
0507   int outputPin = alg.algoOutputPin(
0508       static_cast<int>(m_numberConditionChips), static_cast<int>(m_pinsOnConditionChip), m_orderConditionChip);
0509 
0510   if ((outputPin < 0) || (outputPin > static_cast<int>(m_pinsOnConditionChip))) {
0511     LogTrace("TriggerMenuParser") << "      Output pin " << outputPin << " outside allowed range [0, "
0512                                   << m_pinsOnConditionChip << "] - algorithm not inserted!" << std::endl;
0513     return false;
0514   }
0515 
0516   // no two algorithms on the same chip can have the same output pin
0517   for (CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
0518     int iPin = (itAlgo->second)
0519                    .algoOutputPin(static_cast<int>(m_numberConditionChips),
0520                                   static_cast<int>(m_pinsOnConditionChip),
0521                                   m_orderConditionChip);
0522     std::string iName = itAlgo->first;
0523     int iChip = (itAlgo->second)
0524                     .algoChipNumber(static_cast<int>(m_numberConditionChips),
0525                                     static_cast<int>(m_pinsOnConditionChip),
0526                                     m_orderConditionChip);
0527 
0528     if ((outputPin == iPin) && (chipNr == iChip)) {
0529       LogTrace("TriggerMenuParser") << "      Output pin " << outputPin << " is the same as for algorithm " << iName
0530                                     << "\n      from the same chip number " << chipNr << " - algorithm not inserted!"
0531                                     << std::endl;
0532       return false;
0533     }
0534   }
0535 
0536   // insert algorithm
0537   m_algorithmMap[algName] = alg;
0538   m_algorithmAliasMap[algAlias] = alg;
0539 
0540   //LogTrace("TriggerMenuParser")
0541   //<< "      OK - algorithm inserted!"
0542   //<< std::endl;
0543 
0544   return true;
0545 }
0546 
0547 template <typename T>
0548 std::string l1t::TriggerMenuParser::l1t2string(T data) {
0549   std::stringstream ss;
0550   ss << data;
0551   return ss.str();
0552 }
0553 int l1t::TriggerMenuParser::l1tstr2int(const std::string data) {
0554   std::stringstream ss;
0555   ss << data;
0556   int value;
0557   ss >> value;
0558   return value;
0559 }
0560 
0561 /**
0562  * parseScales Parse Et, Eta, and Phi Scales
0563  *
0564  * @return "true" if succeeded, "false" if an error occurred.
0565  *
0566  */
0567 
0568 bool l1t::TriggerMenuParser::parseScales(std::map<std::string, tmeventsetup::esScale> scaleMap) {
0569   using namespace tmeventsetup;
0570 
0571   //  Setup ScaleParameter to hold information from parsing
0572   GlobalScales::ScaleParameters muScales;
0573   GlobalScales::ScaleParameters egScales;
0574   GlobalScales::ScaleParameters tauScales;
0575   GlobalScales::ScaleParameters jetScales;
0576   GlobalScales::ScaleParameters ettScales;
0577   GlobalScales::ScaleParameters ettEmScales;
0578   GlobalScales::ScaleParameters etmScales;
0579   GlobalScales::ScaleParameters etmHfScales;
0580   GlobalScales::ScaleParameters httScales;
0581   GlobalScales::ScaleParameters htmScales;
0582   GlobalScales::ScaleParameters zdcScales;
0583 
0584   // Start by parsing the Scale Map
0585   for (std::map<std::string, tmeventsetup::esScale>::const_iterator cit = scaleMap.begin(); cit != scaleMap.end();
0586        cit++) {
0587     const tmeventsetup::esScale& scale = cit->second;
0588 
0589     GlobalScales::ScaleParameters* scaleParam;
0590     if (scale.getObjectType() == esObjectType::Muon)
0591       scaleParam = &muScales;
0592     else if (scale.getObjectType() == esObjectType::Egamma)
0593       scaleParam = &egScales;
0594     else if (scale.getObjectType() == esObjectType::Tau)
0595       scaleParam = &tauScales;
0596     else if (scale.getObjectType() == esObjectType::Jet)
0597       scaleParam = &jetScales;
0598     else if (scale.getObjectType() == esObjectType::ETT)
0599       scaleParam = &ettScales;
0600     else if (scale.getObjectType() == esObjectType::ETTEM)
0601       scaleParam = &ettEmScales;
0602     else if (scale.getObjectType() == esObjectType::ETM)
0603       scaleParam = &etmScales;
0604     else if (scale.getObjectType() == esObjectType::ETMHF)
0605       scaleParam = &etmHfScales;
0606     else if (scale.getObjectType() == esObjectType::HTT)
0607       scaleParam = &httScales;
0608     else if (scale.getObjectType() == esObjectType::HTM)
0609       scaleParam = &htmScales;
0610     else if (scale.getObjectType() == esObjectType::ZDCP || scale.getObjectType() == esObjectType::ZDCM)
0611       scaleParam = &zdcScales;
0612     else
0613       scaleParam = nullptr;
0614 
0615     if (scaleParam != nullptr) {
0616       switch (scale.getScaleType()) {
0617         case esScaleType::EtScale: {
0618           scaleParam->etMin = scale.getMinimum();
0619           scaleParam->etMax = scale.getMaximum();
0620           scaleParam->etStep = scale.getStep();
0621 
0622           //Get bin edges
0623           const std::vector<tmeventsetup::esBin>& binsV = scale.getBins();
0624           for (unsigned int i = 0; i < binsV.size(); i++) {
0625             const tmeventsetup::esBin& bin = binsV.at(i);
0626             std::pair<double, double> binLimits(bin.minimum, bin.maximum);
0627             scaleParam->etBins.push_back(binLimits);
0628           }
0629 
0630           // If this is an energy sum fill dummy values for eta and phi
0631           // There are no scales for these in the XML so the other case statements will not be seen....do it here.
0632           if (scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT ||
0633               scale.getObjectType() == esObjectType::ETM || scale.getObjectType() == esObjectType::HTM ||
0634               scale.getObjectType() == esObjectType::ETTEM || scale.getObjectType() == esObjectType::ETMHF) {
0635             scaleParam->etaMin = -1.;
0636             scaleParam->etaMax = -1.;
0637             scaleParam->etaStep = -1.;
0638             if (scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT ||
0639                 scale.getObjectType() == esObjectType::ETTEM) {
0640               //           if(scale.getObjectType() == esObjectType::ETT || scale.getObjectType() == esObjectType::HTT) {
0641               scaleParam->phiMin = -1.;
0642               scaleParam->phiMax = -1.;
0643               scaleParam->phiStep = -1.;
0644             }
0645           }
0646         } break;
0647         case esScaleType::UnconstrainedPtScale: {  // Added for displaced muons
0648           scaleParam->uptMin = scale.getMinimum();
0649           scaleParam->uptMax = scale.getMaximum();
0650           scaleParam->uptStep = scale.getStep();
0651 
0652           //Get bin edges
0653           const std::vector<tmeventsetup::esBin>& binsV = scale.getBins();
0654           for (unsigned int i = 0; i < binsV.size(); i++) {
0655             const tmeventsetup::esBin& bin = binsV.at(i);
0656             std::pair<double, double> binLimits(bin.minimum, bin.maximum);
0657             scaleParam->uptBins.push_back(binLimits);
0658           }
0659         } break;
0660         case esScaleType::EtaScale: {
0661           scaleParam->etaMin = scale.getMinimum();
0662           scaleParam->etaMax = scale.getMaximum();
0663           scaleParam->etaStep = scale.getStep();
0664 
0665           //Get bin edges
0666           const std::vector<tmeventsetup::esBin>& binsV = scale.getBins();
0667           scaleParam->etaBins.resize(pow(2, scale.getNbits()));
0668           for (unsigned int i = 0; i < binsV.size(); i++) {
0669             const tmeventsetup::esBin& bin = binsV.at(i);
0670             std::pair<double, double> binLimits(bin.minimum, bin.maximum);
0671             scaleParam->etaBins.at(bin.hw_index) = binLimits;
0672           }
0673         } break;
0674         case esScaleType::PhiScale: {
0675           scaleParam->phiMin = scale.getMinimum();
0676           scaleParam->phiMax = scale.getMaximum();
0677           scaleParam->phiStep = scale.getStep();
0678 
0679           //Get bin edges
0680           const std::vector<tmeventsetup::esBin>& binsV = scale.getBins();
0681           scaleParam->phiBins.resize(pow(2, scale.getNbits()));
0682           for (unsigned int i = 0; i < binsV.size(); i++) {
0683             const tmeventsetup::esBin& bin = binsV.at(i);
0684             std::pair<double, double> binLimits(bin.minimum, bin.maximum);
0685             scaleParam->phiBins.at(bin.hw_index) = binLimits;
0686           }
0687         } break;
0688         default:
0689 
0690           break;
0691       }  //end switch
0692     }    //end valid scale
0693   }      //end loop over scaleMap
0694 
0695   // put the ScaleParameters into the class
0696   m_gtScales.setMuonScales(muScales);
0697   m_gtScales.setEGScales(egScales);
0698   m_gtScales.setTauScales(tauScales);
0699   m_gtScales.setJetScales(jetScales);
0700   m_gtScales.setETTScales(ettScales);
0701   m_gtScales.setETTEmScales(ettEmScales);
0702   m_gtScales.setETMScales(etmScales);
0703   m_gtScales.setETMHfScales(etmHfScales);
0704   m_gtScales.setHTTScales(httScales);
0705   m_gtScales.setHTMScales(htmScales);
0706   m_gtScales.setHTMScales(zdcScales);
0707 
0708   // Setup the LUT for the Scale Conversions
0709   bool hasPrecision = false;
0710   std::map<std::string, unsigned int> precisions;
0711   getPrecisions(precisions, scaleMap);
0712   for (std::map<std::string, unsigned int>::const_iterator cit = precisions.begin(); cit != precisions.end(); cit++) {
0713     hasPrecision = true;
0714   }
0715 
0716   if (hasPrecision) {
0717     //Start with the Cal - Muon Eta LUTS
0718     //----------------------------------
0719     parseCalMuEta_LUTS(scaleMap, "EG", "MU");
0720     parseCalMuEta_LUTS(scaleMap, "JET", "MU");
0721     parseCalMuEta_LUTS(scaleMap, "TAU", "MU");
0722 
0723     //Now the Cal - Muon Phi LUTS
0724     //-------------------------------------
0725     parseCalMuPhi_LUTS(scaleMap, "EG", "MU");
0726     parseCalMuPhi_LUTS(scaleMap, "JET", "MU");
0727     parseCalMuPhi_LUTS(scaleMap, "TAU", "MU");
0728     parseCalMuPhi_LUTS(scaleMap, "HTM", "MU");
0729     parseCalMuPhi_LUTS(scaleMap, "ETM", "MU");
0730     parseCalMuPhi_LUTS(scaleMap, "ETMHF", "MU");
0731 
0732     // Now the Pt LUTs  (??? more combinations needed ??)
0733     // ---------------
0734     parsePt_LUTS(scaleMap, "Mass", "EG", precisions["PRECISION-EG-MU-MassPt"]);
0735     parsePt_LUTS(scaleMap, "Mass", "MU", precisions["PRECISION-EG-MU-MassPt"]);
0736     parseUpt_LUTS(scaleMap, "Mass", "MU", precisions["PRECISION-EG-MU-MassPt"]);  // Added for displaced muons
0737     parsePt_LUTS(scaleMap, "Mass", "JET", precisions["PRECISION-EG-JET-MassPt"]);
0738     parsePt_LUTS(scaleMap, "Mass", "TAU", precisions["PRECISION-EG-TAU-MassPt"]);
0739     parsePt_LUTS(scaleMap, "Mass", "ETM", precisions["PRECISION-EG-ETM-MassPt"]);
0740     parsePt_LUTS(scaleMap, "Mass", "ETMHF", precisions["PRECISION-EG-ETMHF-MassPt"]);
0741     parsePt_LUTS(scaleMap, "Mass", "HTM", precisions["PRECISION-EG-HTM-MassPt"]);
0742 
0743     // Now the Pt LUTs  for TBPT calculation (??? CCLA following what was done for MASS pt LUTs for now ??)
0744     // ---------------
0745     parsePt_LUTS(scaleMap, "TwoBody", "EG", precisions["PRECISION-EG-MU-TwoBodyPt"]);
0746     parsePt_LUTS(scaleMap, "TwoBody", "MU", precisions["PRECISION-EG-MU-TwoBodyPt"]);
0747     parsePt_LUTS(scaleMap, "TwoBody", "JET", precisions["PRECISION-EG-JET-TwoBodyPt"]);
0748     parsePt_LUTS(scaleMap, "TwoBody", "TAU", precisions["PRECISION-EG-TAU-TwoBodyPt"]);
0749     parsePt_LUTS(scaleMap, "TwoBody", "ETM", precisions["PRECISION-EG-ETM-TwoBodyPt"]);
0750     parsePt_LUTS(scaleMap, "TwoBody", "ETMHF", precisions["PRECISION-EG-ETMHF-TwoBodyPt"]);
0751     parsePt_LUTS(scaleMap, "TwoBody", "HTM", precisions["PRECISION-EG-HTM-TwoBodyPt"]);
0752 
0753     // Now the Delta Eta/Cosh LUTs (must be done in groups)
0754     // ----------------------------------------------------
0755     parseDeltaEta_Cosh_LUTS(
0756         scaleMap, "EG", "EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
0757     parseDeltaEta_Cosh_LUTS(
0758         scaleMap, "EG", "JET", precisions["PRECISION-EG-JET-Delta"], precisions["PRECISION-EG-JET-Math"]);
0759     parseDeltaEta_Cosh_LUTS(
0760         scaleMap, "EG", "TAU", precisions["PRECISION-EG-TAU-Delta"], precisions["PRECISION-EG-TAU-Math"]);
0761     parseDeltaEta_Cosh_LUTS(
0762         scaleMap, "EG", "MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
0763 
0764     parseDeltaEta_Cosh_LUTS(
0765         scaleMap, "JET", "JET", precisions["PRECISION-JET-JET-Delta"], precisions["PRECISION-JET-JET-Math"]);
0766     parseDeltaEta_Cosh_LUTS(
0767         scaleMap, "JET", "TAU", precisions["PRECISION-JET-TAU-Delta"], precisions["PRECISION-JET-TAU-Math"]);
0768     parseDeltaEta_Cosh_LUTS(
0769         scaleMap, "JET", "MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
0770 
0771     parseDeltaEta_Cosh_LUTS(
0772         scaleMap, "TAU", "TAU", precisions["PRECISION-TAU-TAU-Delta"], precisions["PRECISION-TAU-TAU-Math"]);
0773     parseDeltaEta_Cosh_LUTS(
0774         scaleMap, "TAU", "MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
0775 
0776     parseDeltaEta_Cosh_LUTS(
0777         scaleMap, "MU", "MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
0778 
0779     // Now the Delta Phi/Cos LUTs (must be done in groups)
0780     // ----------------------------------------------------
0781     parseDeltaPhi_Cos_LUTS(
0782         scaleMap, "EG", "EG", precisions["PRECISION-EG-EG-Delta"], precisions["PRECISION-EG-EG-Math"]);
0783     parseDeltaPhi_Cos_LUTS(
0784         scaleMap, "EG", "JET", precisions["PRECISION-EG-JET-Delta"], precisions["PRECISION-EG-JET-Math"]);
0785     parseDeltaPhi_Cos_LUTS(
0786         scaleMap, "EG", "TAU", precisions["PRECISION-EG-TAU-Delta"], precisions["PRECISION-EG-TAU-Math"]);
0787     parseDeltaPhi_Cos_LUTS(
0788         scaleMap, "EG", "ETM", precisions["PRECISION-EG-ETM-Delta"], precisions["PRECISION-EG-ETM-Math"]);
0789     parseDeltaPhi_Cos_LUTS(
0790         scaleMap, "EG", "ETMHF", precisions["PRECISION-EG-ETMHF-Delta"], precisions["PRECISION-EG-ETMHF-Math"]);
0791     parseDeltaPhi_Cos_LUTS(
0792         scaleMap, "EG", "HTM", precisions["PRECISION-EG-HTM-Delta"], precisions["PRECISION-EG-HTM-Math"]);
0793     parseDeltaPhi_Cos_LUTS(
0794         scaleMap, "EG", "MU", precisions["PRECISION-EG-MU-Delta"], precisions["PRECISION-EG-MU-Math"]);
0795 
0796     parseDeltaPhi_Cos_LUTS(
0797         scaleMap, "JET", "JET", precisions["PRECISION-JET-JET-Delta"], precisions["PRECISION-JET-JET-Math"]);
0798     parseDeltaPhi_Cos_LUTS(
0799         scaleMap, "JET", "TAU", precisions["PRECISION-JET-TAU-Delta"], precisions["PRECISION-JET-TAU-Math"]);
0800     parseDeltaPhi_Cos_LUTS(
0801         scaleMap, "JET", "ETM", precisions["PRECISION-JET-ETM-Delta"], precisions["PRECISION-JET-ETM-Math"]);
0802     parseDeltaPhi_Cos_LUTS(
0803         scaleMap, "JET", "ETMHF", precisions["PRECISION-JET-ETMHF-Delta"], precisions["PRECISION-JET-ETMHF-Math"]);
0804     parseDeltaPhi_Cos_LUTS(
0805         scaleMap, "JET", "HTM", precisions["PRECISION-JET-HTM-Delta"], precisions["PRECISION-JET-HTM-Math"]);
0806     parseDeltaPhi_Cos_LUTS(
0807         scaleMap, "JET", "MU", precisions["PRECISION-JET-MU-Delta"], precisions["PRECISION-JET-MU-Math"]);
0808 
0809     parseDeltaPhi_Cos_LUTS(
0810         scaleMap, "TAU", "TAU", precisions["PRECISION-TAU-TAU-Delta"], precisions["PRECISION-TAU-TAU-Math"]);
0811     parseDeltaPhi_Cos_LUTS(
0812         scaleMap, "TAU", "ETM", precisions["PRECISION-TAU-ETM-Delta"], precisions["PRECISION-TAU-ETM-Math"]);
0813     parseDeltaPhi_Cos_LUTS(
0814         scaleMap, "TAU", "ETMHF", precisions["PRECISION-TAU-ETMHF-Delta"], precisions["PRECISION-TAU-ETMHF-Math"]);
0815     parseDeltaPhi_Cos_LUTS(
0816         scaleMap, "TAU", "HTM", precisions["PRECISION-TAU-HTM-Delta"], precisions["PRECISION-TAU-HTM-Math"]);
0817     parseDeltaPhi_Cos_LUTS(
0818         scaleMap, "TAU", "MU", precisions["PRECISION-TAU-MU-Delta"], precisions["PRECISION-TAU-MU-Math"]);
0819 
0820     parseDeltaPhi_Cos_LUTS(
0821         scaleMap, "MU", "ETM", precisions["PRECISION-MU-ETM-Delta"], precisions["PRECISION-MU-ETM-Math"]);
0822     parseDeltaPhi_Cos_LUTS(
0823         scaleMap, "MU", "ETMHF", precisions["PRECISION-MU-ETMHF-Delta"], precisions["PRECISION-MU-ETMHF-Math"]);
0824     parseDeltaPhi_Cos_LUTS(
0825         scaleMap, "MU", "HTM", precisions["PRECISION-MU-HTM-Delta"], precisions["PRECISION-MU-HTM-Math"]);
0826     parseDeltaPhi_Cos_LUTS(
0827         scaleMap, "MU", "MU", precisions["PRECISION-MU-MU-Delta"], precisions["PRECISION-MU-MU-Math"]);
0828 
0829     parsePhi_Trig_LUTS(scaleMap, "EG", l1t::COS, precisions["PRECISION-EG-EG-Math"]);
0830     parsePhi_Trig_LUTS(scaleMap, "JET", l1t::COS, precisions["PRECISION-JET-JET-Math"]);
0831     parsePhi_Trig_LUTS(scaleMap, "TAU", l1t::COS, precisions["PRECISION-TAU-TAU-Math"]);
0832     parsePhi_Trig_LUTS(scaleMap, "MU", l1t::COS, precisions["PRECISION-MU-MU-Math"]);
0833 
0834     parsePhi_Trig_LUTS(scaleMap, "EG", l1t::SIN, precisions["PRECISION-EG-EG-Math"]);
0835     parsePhi_Trig_LUTS(scaleMap, "JET", l1t::SIN, precisions["PRECISION-JET-JET-Math"]);
0836     parsePhi_Trig_LUTS(scaleMap, "TAU", l1t::SIN, precisions["PRECISION-TAU-TAU-Math"]);
0837     parsePhi_Trig_LUTS(scaleMap, "MU", l1t::SIN, precisions["PRECISION-MU-MU-Math"]);
0838 
0839     //CCLA
0840     //m_gtScales.dumpAllLUTs(std::cout);
0841     //m_gtScales.print(std::cout);
0842   }
0843 
0844   return true;
0845 }
0846 
0847 void l1t::TriggerMenuParser::parseCalMuEta_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0848                                                 std::string obj1,
0849                                                 std::string obj2) {
0850   using namespace tmeventsetup;
0851 
0852   // First Delta Eta for this set
0853   std::string scLabel1 = obj1;
0854   scLabel1 += "-ETA";
0855   std::string scLabel2 = obj2;
0856   scLabel2 += "-ETA";
0857 
0858   //This LUT does not exist in L1 Menu file, don't fill it
0859   if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
0860     return;
0861 
0862   const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
0863   const tmeventsetup::esScale* scale2 = &scaleMap.find(scLabel2)->second;
0864 
0865   std::vector<long long> lut_cal_2_mu_eta;
0866   getCaloMuonEtaConversionLut(lut_cal_2_mu_eta, scale1, scale2);
0867 
0868   std::string lutName = obj1;
0869   lutName += "-";
0870   lutName += obj2;
0871   m_gtScales.setLUT_CalMuEta(lutName, lut_cal_2_mu_eta);
0872 }
0873 
0874 void l1t::TriggerMenuParser::parseCalMuPhi_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0875                                                 std::string obj1,
0876                                                 std::string obj2) {
0877   using namespace tmeventsetup;
0878 
0879   // First Delta Eta for this set
0880   std::string scLabel1 = obj1;
0881   scLabel1 += "-PHI";
0882   std::string scLabel2 = obj2;
0883   scLabel2 += "-PHI";
0884 
0885   //This LUT does not exist in L1 Menu file, don't fill it
0886   if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
0887     return;
0888 
0889   const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
0890   const tmeventsetup::esScale* scale2 = &scaleMap.find(scLabel2)->second;
0891 
0892   std::vector<long long> lut_cal_2_mu_phi;
0893   getCaloMuonPhiConversionLut(lut_cal_2_mu_phi, scale1, scale2);
0894 
0895   std::string lutName = obj1;
0896   lutName += "-";
0897   lutName += obj2;
0898   m_gtScales.setLUT_CalMuPhi(lutName, lut_cal_2_mu_phi);
0899 }
0900 
0901 void l1t::TriggerMenuParser::parsePt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0902                                           std::string lutpfx,
0903                                           std::string obj1,
0904                                           unsigned int prec) {
0905   using namespace tmeventsetup;
0906 
0907   // First Delta Eta for this set
0908   std::string scLabel1 = obj1;
0909   scLabel1 += "-ET";
0910 
0911   //This LUT does not exist in L1 Menu file, don't fill it
0912   if (scaleMap.find(scLabel1) == scaleMap.end())
0913     return;
0914 
0915   const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
0916 
0917   std::vector<long long> lut_pt;
0918   getLut(lut_pt, scale1, prec);
0919 
0920   m_gtScales.setLUT_Pt(lutpfx + "_" + scLabel1, lut_pt, prec);
0921 }
0922 
0923 // Added for displaced muons
0924 void l1t::TriggerMenuParser::parseUpt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0925                                            std::string lutpfx,
0926                                            std::string obj1,
0927                                            unsigned int prec) {
0928   using namespace tmeventsetup;
0929 
0930   // First Delta Eta for this set
0931   std::string scLabel1 = obj1;
0932   scLabel1 += "-UPT";
0933 
0934   //This LUT does not exist in L1 Menu file, don't fill it
0935   if (scaleMap.find(scLabel1) == scaleMap.end())
0936     return;
0937 
0938   const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
0939 
0940   std::vector<long long> lut_pt;
0941   getLut(lut_pt, scale1, prec);
0942 
0943   m_gtScales.setLUT_Upt(lutpfx + "_" + scLabel1, lut_pt, prec);
0944 }
0945 
0946 void l1t::TriggerMenuParser::parseDeltaEta_Cosh_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
0947                                                      std::string obj1,
0948                                                      std::string obj2,
0949                                                      unsigned int prec1,
0950                                                      unsigned int prec2) {
0951   using namespace tmeventsetup;
0952 
0953   // First Delta Eta for this set
0954   std::string scLabel1 = obj1;
0955   scLabel1 += "-ETA";
0956   std::string scLabel2 = obj2;
0957   scLabel2 += "-ETA";
0958 
0959   //This LUT does not exist in L1 Menu file, don't fill it
0960   if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
0961     return;
0962 
0963   const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
0964   const tmeventsetup::esScale* scale2 = &scaleMap.find(scLabel2)->second;
0965   std::vector<double> val_delta_eta;
0966   std::vector<long long> lut_delta_eta;
0967   size_t n = getDeltaVector(val_delta_eta, scale1, scale2);
0968   setLut(lut_delta_eta, val_delta_eta, prec1);
0969   std::string lutName = obj1;
0970   lutName += "-";
0971   lutName += obj2;
0972   m_gtScales.setLUT_DeltaEta(lutName, lut_delta_eta, prec1);
0973 
0974   // Second Get the Cosh for this delta Eta Set
0975   std::vector<long long> lut_cosh;
0976   applyCosh(val_delta_eta, n);
0977   setLut(lut_cosh, val_delta_eta, prec2);
0978   m_gtScales.setLUT_Cosh(lutName, lut_cosh, prec2);
0979 }
0980 
0981 void l1t::TriggerMenuParser::parseDeltaPhi_Cos_LUTS(const std::map<std::string, tmeventsetup::esScale>& scaleMap,
0982                                                     const std::string& obj1,
0983                                                     const std::string& obj2,
0984                                                     unsigned int prec1,
0985                                                     unsigned int prec2) {
0986   using namespace tmeventsetup;
0987 
0988   // First Delta phi for this set
0989   std::string scLabel1 = obj1;
0990   scLabel1 += "-PHI";
0991   std::string scLabel2 = obj2;
0992   scLabel2 += "-PHI";
0993 
0994   //This LUT does not exist in L1 Menu file, don't fill it
0995   if (scaleMap.find(scLabel1) == scaleMap.end() || scaleMap.find(scLabel2) == scaleMap.end())
0996     return;
0997 
0998   const tmeventsetup::esScale* scale1 = &scaleMap.find(scLabel1)->second;
0999   const tmeventsetup::esScale* scale2 = &scaleMap.find(scLabel2)->second;
1000   std::vector<double> val_delta_phi;
1001   std::vector<long long> lut_delta_phi;
1002   size_t n = getDeltaVector(val_delta_phi, scale1, scale2);
1003   setLut(lut_delta_phi, val_delta_phi, prec1);
1004   std::string lutName = obj1;
1005   lutName += "-";
1006   lutName += obj2;
1007   m_gtScales.setLUT_DeltaPhi(lutName, lut_delta_phi, prec1);
1008 
1009   // Second Get the Cosh for this delta phi Set
1010   std::vector<long long> lut_cos;
1011   applyCos(val_delta_phi, n);
1012   setLut(lut_cos, val_delta_phi, prec2);
1013   m_gtScales.setLUT_Cos(lutName, lut_cos, prec2);
1014 }
1015 
1016 void l1t::TriggerMenuParser::parsePhi_Trig_LUTS(const std::map<std::string, tmeventsetup::esScale>& scaleMap,
1017                                                 const std::string& obj,
1018                                                 l1t::TrigFunc_t func,
1019                                                 unsigned int prec) {
1020   using namespace tmeventsetup;
1021 
1022   std::string scLabel = obj;
1023   scLabel += "-PHI";
1024 
1025   //This LUT does not exist in L1 Menu file, don't fill it
1026   if (scaleMap.find(scLabel) == scaleMap.end())
1027     return;
1028   if (func != l1t::SIN and func != l1t::COS)
1029     return;
1030 
1031   const tmeventsetup::esScale* scale = &scaleMap.find(scLabel)->second;
1032 
1033   const double step = scale->getStep();
1034   const double range = scale->getMaximum() - scale->getMinimum();
1035   const size_t n = std::ceil(range / step);
1036   const size_t bitwidth = std::ceil(std::log10(n) / std::log10(2));
1037 
1038   std::vector<double> array(std::pow(2, bitwidth), 0);
1039 
1040   for (size_t ii = 0; ii < n; ii++) {
1041     array.at(ii) = step * ii;
1042   }
1043 
1044   const std::string& lutName = obj;
1045   std::vector<long long> lut;
1046   if (func == l1t::SIN) {
1047     applySin(array, n);
1048     setLut(lut, array, prec);
1049     m_gtScales.setLUT_Sin(lutName, lut, prec);
1050   } else if (func == l1t::COS) {
1051     applyCos(array, n);
1052     setLut(lut, array, prec);
1053     m_gtScales.setLUT_Cos(lutName, lut, prec);
1054   }
1055 }
1056 
1057 /**
1058  * parseMuon Parse a muon condition and insert an entry to the conditions map
1059  *
1060  * @param node The corresponding node.
1061  * @param name The name of the condition.
1062  * @param chipNr The number of the chip this condition is located.
1063  *
1064  * @return "true" if succeeded, "false" if an error occurred.
1065  *
1066  */
1067 
1068 bool l1t::TriggerMenuParser::parseMuon(L1TUtmCondition condMu, unsigned int chipNr, const bool corrFlag) {
1069   using namespace tmeventsetup;
1070   // get condition, particle name (must be muon) and type name
1071   std::string condition = "muon";
1072   std::string particle = "muon";  //l1t2string( condMu.objectType() );
1073   std::string type = l1t2string(condMu.getType());
1074   std::string name = l1t2string(condMu.getName());
1075   int nrObj = -1;
1076 
1077   GtConditionType cType = l1t::TypeNull;
1078 
1079   if (condMu.getType() == esConditionType::SingleMuon) {
1080     type = "1_s";
1081     cType = l1t::Type1s;
1082     nrObj = 1;
1083   } else if (condMu.getType() == esConditionType::DoubleMuon) {
1084     type = "2_s";
1085     cType = l1t::Type2s;
1086     nrObj = 2;
1087   } else if (condMu.getType() == esConditionType::TripleMuon) {
1088     type = "3";
1089     cType = l1t::Type3s;
1090     nrObj = 3;
1091   } else if (condMu.getType() == esConditionType::QuadMuon) {
1092     type = "4";
1093     cType = l1t::Type4s;
1094     nrObj = 4;
1095   } else {
1096     edm::LogError("TriggerMenuParser") << "Wrong type for muon-condition (" << type << ")" << std::endl;
1097     return false;
1098   }
1099 
1100   if (nrObj < 0) {
1101     edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type << ")"
1102                                        << "\nCan not determine number of trigger objects. " << std::endl;
1103     return false;
1104   }
1105 
1106   LogDebug("TriggerMenuParser") << "\n ****************************************** "
1107                                 << "\n      parseMuon  "
1108                                 << "\n condition = " << condition << "\n particle  = " << particle
1109                                 << "\n type      = " << type << "\n name      = " << name << std::endl;
1110 
1111   //     // get values
1112 
1113   // temporary storage of the parameters
1114   std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1115 
1116   // Do we need this?
1117   MuonTemplate::CorrelationParameter corrParameter;
1118 
1119   // need at least two values for deltaPhi
1120   std::vector<uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1121   tmpValues.reserve(nrObj);
1122 
1123   if (int(condMu.getObjects().size()) != nrObj) {
1124     edm::LogError("TriggerMenuParser") << " condMu objects: nrObj = " << nrObj
1125                                        << "condMu.getObjects().size() = " << condMu.getObjects().size() << std::endl;
1126     return false;
1127   }
1128 
1129   //  Look for cuts on the objects in the condition
1130   unsigned int chargeCorrelation = 1;
1131   const std::vector<L1TUtmCut>& cuts = condMu.getCuts();
1132   for (size_t jj = 0; jj < cuts.size(); jj++) {
1133     const L1TUtmCut& cut = cuts.at(jj);
1134     if (cut.getCutType() == esCutType::ChargeCorrelation) {
1135       if (cut.getData() == "ls")
1136         chargeCorrelation = 2;
1137       else if (cut.getData() == "os")
1138         chargeCorrelation = 4;
1139       else
1140         chargeCorrelation = 1;  //ignore correlation
1141     }
1142   }
1143 
1144   //set charge correlation parameter
1145   corrParameter.chargeCorrelation = chargeCorrelation;  //tmpValues[0];
1146 
1147   int cnt = 0;
1148 
1149   // BLW TO DO: These needs to the added to the object rather than the whole condition.
1150   int relativeBx = 0;
1151   bool gEq = false;
1152 
1153   // Loop over objects and extract the cuts on the objects
1154   const std::vector<L1TUtmObject>& objects = condMu.getObjects();
1155   for (size_t jj = 0; jj < objects.size(); jj++) {
1156     const L1TUtmObject& object = objects.at(jj);
1157     gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1158 
1159     //  BLW TO DO: This needs to be added to the Object Parameters
1160     relativeBx = object.getBxOffset();
1161 
1162     //  Loop over the cuts for this object
1163     int upperUnconstrainedPtInd = -1;
1164     int lowerUnconstrainedPtInd = 0;
1165     int upperImpactParameterInd = -1;
1166     int lowerImpactParameterInd = 0;
1167     int upperThresholdInd = -1;
1168     int lowerThresholdInd = 0;
1169     int upperIndexInd = -1;
1170     int lowerIndexInd = 0;
1171     int cntPhi = 0;
1172     unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
1173     int isolationLUT = 0xF;        //default is to ignore unless specified.
1174     int impactParameterLUT = 0xF;  //default is to ignore unless specified
1175     int charge = -1;               //default value is to ignore unless specified
1176     int qualityLUT = 0xFFFF;       //default is to ignore unless specified.
1177 
1178     std::vector<MuonTemplate::Window> etaWindows;
1179     std::vector<MuonTemplate::Window> tfMuonIndexWindows;
1180 
1181     const std::vector<L1TUtmCut>& cuts = object.getCuts();
1182     for (size_t kk = 0; kk < cuts.size(); kk++) {
1183       const L1TUtmCut& cut = cuts.at(kk);
1184 
1185       switch (cut.getCutType()) {
1186         case esCutType::UnconstrainedPt:
1187           lowerUnconstrainedPtInd = cut.getMinimum().index;
1188           upperUnconstrainedPtInd = cut.getMaximum().index;
1189           break;
1190 
1191         case esCutType::ImpactParameter:
1192           lowerImpactParameterInd = cut.getMinimum().index;
1193           upperImpactParameterInd = cut.getMaximum().index;
1194           impactParameterLUT = l1tstr2int(cut.getData());
1195           break;
1196 
1197         case esCutType::Threshold:
1198           lowerThresholdInd = cut.getMinimum().index;
1199           upperThresholdInd = cut.getMaximum().index;
1200           break;
1201 
1202         case esCutType::Slice:
1203           lowerIndexInd = int(cut.getMinimum().value);
1204           upperIndexInd = int(cut.getMaximum().value);
1205           break;
1206 
1207         case esCutType::Eta: {
1208           if (etaWindows.size() < 5) {
1209             etaWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
1210           } else {
1211             edm::LogError("TriggerMenuParser")
1212                 << "Too Many Eta Cuts for muon-condition (" << particle << ")" << std::endl;
1213             return false;
1214           }
1215         } break;
1216 
1217         case esCutType::Phi: {
1218           if (cntPhi == 0) {
1219             phiWindow1Lower = cut.getMinimum().index;
1220             phiWindow1Upper = cut.getMaximum().index;
1221           } else if (cntPhi == 1) {
1222             phiWindow2Lower = cut.getMinimum().index;
1223             phiWindow2Upper = cut.getMaximum().index;
1224           } else {
1225             edm::LogError("TriggerMenuParser")
1226                 << "Too Many Phi Cuts for muon-condition (" << particle << ")" << std::endl;
1227             return false;
1228           }
1229           cntPhi++;
1230 
1231         } break;
1232 
1233         case esCutType::Charge:
1234           if (cut.getData() == "positive")
1235             charge = 0;
1236           else if (cut.getData() == "negative")
1237             charge = 1;
1238           else
1239             charge = -1;
1240           break;
1241         case esCutType::Quality:
1242 
1243           qualityLUT = l1tstr2int(cut.getData());
1244 
1245           break;
1246         case esCutType::Isolation: {
1247           isolationLUT = l1tstr2int(cut.getData());
1248 
1249         } break;
1250 
1251         case esCutType::Index: {
1252           tfMuonIndexWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
1253         } break;
1254 
1255         default:
1256           break;
1257       }  //end switch
1258 
1259     }  //end loop over cuts
1260 
1261     // Set the parameter cuts
1262     objParameter[cnt].unconstrainedPtHigh = upperUnconstrainedPtInd;
1263     objParameter[cnt].unconstrainedPtLow = lowerUnconstrainedPtInd;
1264     objParameter[cnt].impactParameterHigh = upperImpactParameterInd;
1265     objParameter[cnt].impactParameterLow = lowerImpactParameterInd;
1266     objParameter[cnt].impactParameterLUT = impactParameterLUT;
1267 
1268     objParameter[cnt].ptHighThreshold = upperThresholdInd;
1269     objParameter[cnt].ptLowThreshold = lowerThresholdInd;
1270 
1271     objParameter[cnt].indexHigh = upperIndexInd;
1272     objParameter[cnt].indexLow = lowerIndexInd;
1273 
1274     objParameter[cnt].etaWindows = etaWindows;
1275 
1276     objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1277     objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1278     objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1279     objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1280 
1281     // BLW TO DO: Do we need these anymore?  Drop them?
1282     objParameter[cnt].enableMip = false;   //tmpMip[i];
1283     objParameter[cnt].enableIso = false;   //tmpEnableIso[i];
1284     objParameter[cnt].requestIso = false;  //tmpRequestIso[i];
1285 
1286     objParameter[cnt].charge = charge;
1287     objParameter[cnt].qualityLUT = qualityLUT;
1288     objParameter[cnt].isolationLUT = isolationLUT;
1289 
1290     objParameter[cnt].tfMuonIndexWindows = tfMuonIndexWindows;
1291 
1292     cnt++;
1293   }  //end loop over objects
1294 
1295   // object types - all muons
1296   std::vector<GlobalObject> objType(nrObj, gtMu);
1297 
1298   // now create a new CondMuonition
1299   MuonTemplate muonCond(name);
1300 
1301   muonCond.setCondType(cType);
1302   muonCond.setObjectType(objType);
1303   muonCond.setCondGEq(gEq);
1304   muonCond.setCondChipNr(chipNr);
1305   muonCond.setCondRelativeBx(relativeBx);
1306 
1307   muonCond.setConditionParameter(objParameter, corrParameter);
1308 
1309   if (edm::isDebugEnabled()) {
1310     std::ostringstream myCoutStream;
1311     muonCond.print(myCoutStream);
1312     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1313   }
1314 
1315   // insert condition into the map and into muon template vector
1316   if (!insertConditionIntoMap(muonCond, chipNr)) {
1317     edm::LogError("TriggerMenuParser") << "    Error: duplicate condition (" << name << ")" << std::endl;
1318     return false;
1319   } else {
1320     LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1321     if (corrFlag) {
1322       (m_corMuonTemplate[chipNr]).push_back(muonCond);
1323     } else {
1324       LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the vecMuonTemplate vector" << std::endl;
1325       (m_vecMuonTemplate[chipNr]).push_back(muonCond);
1326     }
1327   }
1328 
1329   //
1330   return true;
1331 }
1332 
1333 bool l1t::TriggerMenuParser::parseMuonCorr(const L1TUtmObject* corrMu, unsigned int chipNr) {
1334   //    XERCES_CPP_NAMESPACE_USE
1335   using namespace tmeventsetup;
1336 
1337   // get condition, particle name (must be muon) and type name
1338   std::string condition = "muon";
1339   std::string particle = "muon";  //l1t2string( condMu.objectType() );
1340   std::string type = l1t2string(corrMu->getType());
1341   std::string name = l1t2string(corrMu->getName());
1342   int nrObj = 1;
1343   type = "1_s";
1344   GtConditionType cType = l1t::Type1s;
1345 
1346   if (nrObj < 0) {
1347     edm::LogError("TriggerMenuParser") << "Unknown type for muon-condition (" << type << ")"
1348                                        << "\nCan not determine number of trigger objects. " << std::endl;
1349     return false;
1350   }
1351 
1352   LogDebug("TriggerMenuParser") << "\n ****************************************** "
1353                                 << "\n      parseMuon  "
1354                                 << "\n condition = " << condition << "\n particle  = " << particle
1355                                 << "\n type      = " << type << "\n name      = " << name << std::endl;
1356 
1357   //     // get values
1358 
1359   // temporary storage of the parameters
1360   std::vector<MuonTemplate::ObjectParameter> objParameter(nrObj);
1361 
1362   // Do we need this?
1363   MuonTemplate::CorrelationParameter corrParameter;
1364 
1365   // need at least two values for deltaPhi
1366   std::vector<uint64_t> tmpValues((nrObj > 2) ? nrObj : 2);
1367   tmpValues.reserve(nrObj);
1368 
1369   // BLW TO DO: How do we deal with these in the new format
1370   //    std::string str_chargeCorrelation = l1t2string( condMu.requestedChargeCorr() );
1371   std::string str_chargeCorrelation = "ig";
1372   unsigned int chargeCorrelation = 0;
1373   if (str_chargeCorrelation == "ig")
1374     chargeCorrelation = 1;
1375   else if (str_chargeCorrelation == "ls")
1376     chargeCorrelation = 2;
1377   else if (str_chargeCorrelation == "os")
1378     chargeCorrelation = 4;
1379 
1380   //getXMLHexTextValue("1", dst);
1381   corrParameter.chargeCorrelation = chargeCorrelation;  //tmpValues[0];
1382 
1383   // BLW TO DO: These needs to the added to the object rather than the whole condition.
1384   int relativeBx = 0;
1385   bool gEq = false;
1386 
1387   //const esObject* object = condMu;
1388   gEq = (corrMu->getComparisonOperator() == esComparisonOperator::GE);
1389 
1390   //  BLW TO DO: This needs to be added to the Object Parameters
1391   relativeBx = corrMu->getBxOffset();
1392 
1393   //  Loop over the cuts for this object
1394   int upperUnconstrainedPtInd = -1;  // Added for displaced muons
1395   int lowerUnconstrainedPtInd = 0;   // Added for displaced muons
1396   int upperImpactParameterInd = -1;  // Added for displaced muons
1397   int lowerImpactParameterInd = 0;   // Added for displaced muons
1398   int impactParameterLUT = 0xF;      // Added for displaced muons, default is to ignore unless specified
1399   int upperThresholdInd = -1;
1400   int lowerThresholdInd = 0;
1401   int upperIndexInd = -1;
1402   int lowerIndexInd = 0;
1403   int cntPhi = 0;
1404   unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
1405   int isolationLUT = 0xF;   //default is to ignore unless specified.
1406   int charge = -1;          //defaut is to ignore unless specified
1407   int qualityLUT = 0xFFFF;  //default is to ignore unless specified.
1408 
1409   std::vector<MuonTemplate::Window> etaWindows;
1410   std::vector<MuonTemplate::Window> tfMuonIndexWindows;
1411 
1412   const std::vector<L1TUtmCut>& cuts = corrMu->getCuts();
1413   for (size_t kk = 0; kk < cuts.size(); kk++) {
1414     const L1TUtmCut& cut = cuts.at(kk);
1415 
1416     switch (cut.getCutType()) {
1417       case esCutType::UnconstrainedPt:  // Added for displaced muons
1418         lowerUnconstrainedPtInd = cut.getMinimum().index;
1419         upperUnconstrainedPtInd = cut.getMaximum().index;
1420         break;
1421 
1422       case esCutType::ImpactParameter:  // Added for displaced muons
1423         lowerImpactParameterInd = cut.getMinimum().index;
1424         upperImpactParameterInd = cut.getMaximum().index;
1425         impactParameterLUT = l1tstr2int(cut.getData());
1426         break;
1427 
1428       case esCutType::Threshold:
1429         lowerThresholdInd = cut.getMinimum().index;
1430         upperThresholdInd = cut.getMaximum().index;
1431         break;
1432 
1433       case esCutType::Slice:
1434         lowerIndexInd = int(cut.getMinimum().value);
1435         upperIndexInd = int(cut.getMaximum().value);
1436         break;
1437 
1438       case esCutType::Eta: {
1439         if (etaWindows.size() < 5) {
1440           etaWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
1441         } else {
1442           edm::LogError("TriggerMenuParser")
1443               << "Too Many Eta Cuts for muon-condition (" << particle << ")" << std::endl;
1444           return false;
1445         }
1446       } break;
1447 
1448       case esCutType::Phi: {
1449         if (cntPhi == 0) {
1450           phiWindow1Lower = cut.getMinimum().index;
1451           phiWindow1Upper = cut.getMaximum().index;
1452         } else if (cntPhi == 1) {
1453           phiWindow2Lower = cut.getMinimum().index;
1454           phiWindow2Upper = cut.getMaximum().index;
1455         } else {
1456           edm::LogError("TriggerMenuParser")
1457               << "Too Many Phi Cuts for muon-condition (" << particle << ")" << std::endl;
1458           return false;
1459         }
1460         cntPhi++;
1461 
1462       } break;
1463 
1464       case esCutType::Charge:
1465         if (cut.getData() == "positive")
1466           charge = 0;
1467         else if (cut.getData() == "negative")
1468           charge = 1;
1469         else
1470           charge = -1;
1471         break;
1472       case esCutType::Quality:
1473 
1474         qualityLUT = l1tstr2int(cut.getData());
1475 
1476         break;
1477       case esCutType::Isolation: {
1478         isolationLUT = l1tstr2int(cut.getData());
1479 
1480       } break;
1481 
1482       case esCutType::Index: {
1483         tfMuonIndexWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
1484       } break;
1485 
1486       default:
1487         break;
1488     }  //end switch
1489 
1490   }  //end loop over cuts
1491 
1492   // Set the parameter cuts
1493   objParameter[0].unconstrainedPtHigh = upperUnconstrainedPtInd;  // Added for displacd muons
1494   objParameter[0].unconstrainedPtLow = lowerUnconstrainedPtInd;   // Added for displacd muons
1495   objParameter[0].impactParameterHigh = upperImpactParameterInd;  // Added for displacd muons
1496   objParameter[0].impactParameterLow = lowerImpactParameterInd;   // Added for displacd muons
1497   objParameter[0].impactParameterLUT = impactParameterLUT;        // Added for displacd muons
1498 
1499   objParameter[0].ptHighThreshold = upperThresholdInd;
1500   objParameter[0].ptLowThreshold = lowerThresholdInd;
1501 
1502   objParameter[0].indexHigh = upperIndexInd;
1503   objParameter[0].indexLow = lowerIndexInd;
1504 
1505   objParameter[0].etaWindows = etaWindows;
1506 
1507   objParameter[0].phiWindow1Lower = phiWindow1Lower;
1508   objParameter[0].phiWindow1Upper = phiWindow1Upper;
1509   objParameter[0].phiWindow2Lower = phiWindow2Lower;
1510   objParameter[0].phiWindow2Upper = phiWindow2Upper;
1511 
1512   // BLW TO DO: Do we need these anymore?  Drop them?
1513   objParameter[0].enableMip = false;   //tmpMip[i];
1514   objParameter[0].enableIso = false;   //tmpEnableIso[i];
1515   objParameter[0].requestIso = false;  //tmpRequestIso[i];
1516 
1517   objParameter[0].charge = charge;
1518   objParameter[0].qualityLUT = qualityLUT;
1519   objParameter[0].isolationLUT = isolationLUT;
1520 
1521   objParameter[0].tfMuonIndexWindows = tfMuonIndexWindows;
1522 
1523   // object types - all muons
1524   std::vector<GlobalObject> objType(nrObj, gtMu);
1525 
1526   // now create a new CondMuonition
1527   MuonTemplate muonCond(name);
1528 
1529   muonCond.setCondType(cType);
1530   muonCond.setObjectType(objType);
1531   muonCond.setCondGEq(gEq);
1532   muonCond.setCondChipNr(chipNr);
1533   muonCond.setCondRelativeBx(relativeBx);
1534   muonCond.setConditionParameter(objParameter, corrParameter);
1535 
1536   if (edm::isDebugEnabled()) {
1537     std::ostringstream myCoutStream;
1538     muonCond.print(myCoutStream);
1539     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1540   }
1541 
1542   /*
1543     // insert condition into the map and into muon template vector
1544     if ( !insertConditionIntoMap(muonCond, chipNr)) {
1545         edm::LogError("TriggerMenuParser")
1546                 << "    Error: duplicate condition (" << name << ")"
1547                 << std::endl;
1548         return false;
1549     }
1550     else {
1551         LogDebug("TriggerMenuParser") << "Added Condition " << name << " to the ConditionMap" << std::endl;
1552             (m_corMuonTemplate[chipNr]).push_back(muonCond);
1553     }
1554 */
1555   (m_corMuonTemplate[chipNr]).push_back(muonCond);
1556 
1557   //
1558   return true;
1559 }
1560 
1561 /**
1562  * parseMuonShower Parse a muonShower condition and insert an entry to the conditions map
1563  *
1564  * @param node The corresponding node.
1565  * @param name The name of the condition.
1566  * @param chipNr The number of the chip this condition is located.
1567  *
1568  * @return "true" if succeeded, "false" if an error occurred.
1569  *
1570  */
1571 
1572 bool l1t::TriggerMenuParser::parseMuonShower(L1TUtmCondition condMu, unsigned int chipNr, const bool corrFlag) {
1573   using namespace tmeventsetup;
1574 
1575   // get condition, particle name (must be muon) and type name
1576   std::string condition = "muonShower";
1577   std::string particle = "muonShower";  //l1t2string( condMu.objectType() );
1578   std::string type = l1t2string(condMu.getType());
1579   std::string name = l1t2string(condMu.getName());
1580   // the number of muon shower objects is always 1
1581   int nrObj = 1;
1582 
1583   // condition type is always 1 particle, thus Type1s
1584   GtConditionType cType = l1t::Type1s;
1585 
1586   // temporary storage of the parameters
1587   std::vector<MuonShowerTemplate::ObjectParameter> objParameter(nrObj);
1588 
1589   if (int(condMu.getObjects().size()) != nrObj) {
1590     edm::LogError("TriggerMenuParser") << " condMu objects: nrObj = " << nrObj
1591                                        << "condMu.getObjects().size() = " << condMu.getObjects().size() << std::endl;
1592     return false;
1593   }
1594 
1595   // Get the muon shower object
1596   L1TUtmObject object = condMu.getObjects().at(0);
1597   int relativeBx = object.getBxOffset();
1598 
1599   if (condMu.getType() == esConditionType::MuonShower0) {
1600     objParameter[0].MuonShower0 = true;
1601   } else if (condMu.getType() == esConditionType::MuonShower1) {
1602     objParameter[0].MuonShower1 = true;
1603   } else if (condMu.getType() == esConditionType::MuonShower2) {
1604     objParameter[0].MuonShower2 = true;
1605   } else if (condMu.getType() == esConditionType::MuonShowerOutOfTime0) {
1606     objParameter[0].MuonShowerOutOfTime0 = true;
1607   } else if (condMu.getType() == esConditionType::MuonShowerOutOfTime1) {
1608     objParameter[0].MuonShowerOutOfTime1 = true;
1609   }
1610 
1611   // object types - all muons
1612   std::vector<GlobalObject> objType(nrObj, gtMuShower);
1613 
1614   // now create a new CondMuonition
1615   MuonShowerTemplate muonShowerCond(name);
1616   muonShowerCond.setCondType(cType);
1617   muonShowerCond.setObjectType(objType);
1618   muonShowerCond.setCondChipNr(chipNr);
1619   muonShowerCond.setCondRelativeBx(relativeBx);
1620 
1621   muonShowerCond.setConditionParameter(objParameter);
1622 
1623   if (edm::isDebugEnabled()) {
1624     std::ostringstream myCoutStream;
1625     muonShowerCond.print(myCoutStream);
1626   }
1627 
1628   // insert condition into the map and into muon template vector
1629   if (!insertConditionIntoMap(muonShowerCond, chipNr)) {
1630     edm::LogError("TriggerMenuParser") << "    Error: duplicate condition (" << name << ")" << std::endl;
1631     return false;
1632   } else {
1633     (m_vecMuonShowerTemplate[chipNr]).push_back(muonShowerCond);
1634   }
1635 
1636   return true;
1637 }
1638 
1639 /**
1640  * parseCalo Parse a calo condition and insert an entry to the conditions map
1641  *
1642  * @param node The corresponding node.
1643  * @param name The name of the condition.
1644  * @param chipNr The number of the chip this condition is located.
1645  *
1646  * @return "true" if succeeded, "false" if an error occurred.
1647  *
1648  */
1649 
1650 bool l1t::TriggerMenuParser::parseCalo(L1TUtmCondition condCalo, unsigned int chipNr, const bool corrFlag) {
1651   //    XERCES_CPP_NAMESPACE_USE
1652   using namespace tmeventsetup;
1653 
1654   // get condition, particle name and type name
1655 
1656   std::string condition = "calo";
1657   std::string particle = "test-fix";
1658   std::string type = l1t2string(condCalo.getType());
1659   std::string name = l1t2string(condCalo.getName());
1660 
1661   LogDebug("TriggerMenuParser") << "\n ****************************************** "
1662                                 << "\n      (in parseCalo) "
1663                                 << "\n condition = " << condition << "\n particle  = " << particle
1664                                 << "\n type      = " << type << "\n name      = " << name << std::endl;
1665 
1666   GtConditionType cType = l1t::TypeNull;
1667 
1668   // determine object type type
1669   // BLW TO DO:  Can this object type wait and be done later in the parsing. Or done differently completely..
1670   GlobalObject caloObjType;
1671   int nrObj = -1;
1672 
1673   if (condCalo.getType() == esConditionType::SingleEgamma) {
1674     caloObjType = gtEG;
1675     type = "1_s";
1676     cType = l1t::Type1s;
1677     nrObj = 1;
1678   } else if (condCalo.getType() == esConditionType::DoubleEgamma) {
1679     caloObjType = gtEG;
1680     type = "2_s";
1681     cType = l1t::Type2s;
1682     nrObj = 2;
1683   } else if (condCalo.getType() == esConditionType::TripleEgamma) {
1684     caloObjType = gtEG;
1685     cType = l1t::Type3s;
1686     type = "3";
1687     nrObj = 3;
1688   } else if (condCalo.getType() == esConditionType::QuadEgamma) {
1689     caloObjType = gtEG;
1690     cType = l1t::Type4s;
1691     type = "4";
1692     nrObj = 4;
1693   } else if (condCalo.getType() == esConditionType::SingleJet) {
1694     caloObjType = gtJet;
1695     cType = l1t::Type1s;
1696     type = "1_s";
1697     nrObj = 1;
1698   } else if (condCalo.getType() == esConditionType::DoubleJet) {
1699     caloObjType = gtJet;
1700     cType = l1t::Type2s;
1701     type = "2_s";
1702     nrObj = 2;
1703   } else if (condCalo.getType() == esConditionType::TripleJet) {
1704     caloObjType = gtJet;
1705     cType = l1t::Type3s;
1706     type = "3";
1707     nrObj = 3;
1708   } else if (condCalo.getType() == esConditionType::QuadJet) {
1709     caloObjType = gtJet;
1710     cType = l1t::Type4s;
1711     type = "4";
1712     nrObj = 4;
1713   } else if (condCalo.getType() == esConditionType::SingleTau) {
1714     caloObjType = gtTau;
1715     cType = l1t::Type1s;
1716     type = "1_s";
1717     nrObj = 1;
1718   } else if (condCalo.getType() == esConditionType::DoubleTau) {
1719     caloObjType = gtTau;
1720     cType = l1t::Type2s;
1721     type = "2_s";
1722     nrObj = 2;
1723   } else if (condCalo.getType() == esConditionType::TripleTau) {
1724     caloObjType = gtTau;
1725     cType = l1t::Type3s;
1726     type = "3";
1727     nrObj = 3;
1728   } else if (condCalo.getType() == esConditionType::QuadTau) {
1729     caloObjType = gtTau;
1730     cType = l1t::Type4s;
1731     type = "4";
1732     nrObj = 4;
1733   } else {
1734     edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition (" << particle << ")" << std::endl;
1735     return false;
1736   }
1737 
1738   //    std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1739 
1740   if (nrObj < 0) {
1741     edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type << ")"
1742                                        << "\nCan not determine number of trigger objects. " << std::endl;
1743     return false;
1744   }
1745 
1746   // get values
1747 
1748   // temporary storage of the parameters
1749   std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1750 
1751   //BLW TO DO:  Can this be dropped?
1752   CaloTemplate::CorrelationParameter corrParameter;
1753 
1754   // need at least one value for deltaPhiRange
1755   std::vector<uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1756   tmpValues.reserve(nrObj);
1757 
1758   if (int(condCalo.getObjects().size()) != nrObj) {
1759     edm::LogError("TriggerMenuParser") << " condCalo objects: nrObj = " << nrObj
1760                                        << "condCalo.getObjects().size() = " << condCalo.getObjects().size()
1761                                        << std::endl;
1762     return false;
1763   }
1764 
1765   //    std::string str_condCalo = "";
1766   //    uint64_t tempUIntH, tempUIntL;
1767   //    uint64_t dst;
1768   int cnt = 0;
1769 
1770   // BLW TO DO: These needs to the added to the object rather than the whole condition.
1771   int relativeBx = 0;
1772   bool gEq = false;
1773 
1774   // Loop over objects and extract the cuts on the objects
1775   const std::vector<L1TUtmObject>& objects = condCalo.getObjects();
1776   for (size_t jj = 0; jj < objects.size(); jj++) {
1777     const L1TUtmObject& object = objects.at(jj);
1778     gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
1779 
1780     //  BLW TO DO: This needs to be added to the Object Parameters
1781     relativeBx = object.getBxOffset();
1782 
1783     //  Loop over the cuts for this object
1784     int upperThresholdInd = -1;
1785     int lowerThresholdInd = 0;
1786     int upperIndexInd = -1;
1787     int lowerIndexInd = 0;
1788     int cntPhi = 0;
1789     unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
1790     int isolationLUT = 0xF;  //default is to ignore isolation unless specified.
1791     int qualityLUT = 0xF;    //default is to ignore quality unless specified.
1792     int displacedLUT = 0x0;  // Added for LLP Jets: single bit LUT: { 0 = noLLP default, 1 = LLP }
1793                              // Note: Currently assumes that the LSB from hwQual() getter in L1Candidate provides the
1794                              // (single bit) information for the displacedLUT
1795 
1796     std::vector<CaloTemplate::Window> etaWindows;
1797 
1798     const std::vector<L1TUtmCut>& cuts = object.getCuts();
1799     for (size_t kk = 0; kk < cuts.size(); kk++) {
1800       const L1TUtmCut& cut = cuts.at(kk);
1801 
1802       switch (cut.getCutType()) {
1803         case esCutType::Threshold:
1804           lowerThresholdInd = cut.getMinimum().index;
1805           upperThresholdInd = cut.getMaximum().index;
1806           break;
1807         case esCutType::Slice:
1808           lowerIndexInd = int(cut.getMinimum().value);
1809           upperIndexInd = int(cut.getMaximum().value);
1810           break;
1811         case esCutType::Eta: {
1812           if (etaWindows.size() < 5) {
1813             etaWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
1814           } else {
1815             edm::LogError("TriggerMenuParser")
1816                 << "Too Many Eta Cuts for calo-condition (" << particle << ")" << std::endl;
1817             return false;
1818           }
1819         } break;
1820 
1821         case esCutType::Phi: {
1822           if (cntPhi == 0) {
1823             phiWindow1Lower = cut.getMinimum().index;
1824             phiWindow1Upper = cut.getMaximum().index;
1825           } else if (cntPhi == 1) {
1826             phiWindow2Lower = cut.getMinimum().index;
1827             phiWindow2Upper = cut.getMaximum().index;
1828           } else {
1829             edm::LogError("TriggerMenuParser")
1830                 << "Too Many Phi Cuts for calo-condition (" << particle << ")" << std::endl;
1831             return false;
1832           }
1833           cntPhi++;
1834 
1835         } break;
1836 
1837         case esCutType::Charge: {
1838           edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition (" << particle << ")" << std::endl;
1839           return false;
1840 
1841         } break;
1842         case esCutType::Quality: {
1843           qualityLUT = l1tstr2int(cut.getData());
1844 
1845         } break;
1846         case esCutType::Displaced: {  // Added for LLP Jets
1847           displacedLUT = l1tstr2int(cut.getData());
1848 
1849         } break;
1850         case esCutType::Isolation: {
1851           isolationLUT = l1tstr2int(cut.getData());
1852 
1853         } break;
1854         default:
1855           break;
1856       }  //end switch
1857 
1858     }  //end loop over cuts
1859 
1860     // Fill the object parameters
1861     objParameter[cnt].etHighThreshold = upperThresholdInd;
1862     objParameter[cnt].etLowThreshold = lowerThresholdInd;
1863     objParameter[cnt].indexHigh = upperIndexInd;
1864     objParameter[cnt].indexLow = lowerIndexInd;
1865     objParameter[cnt].etaWindows = etaWindows;
1866     objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
1867     objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
1868     objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
1869     objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
1870     objParameter[cnt].isolationLUT = isolationLUT;
1871     objParameter[cnt].qualityLUT = qualityLUT;      //TO DO: Must add
1872     objParameter[cnt].displacedLUT = displacedLUT;  // Added for LLP Jets
1873 
1874     // Output for debugging
1875     {
1876       std::ostringstream oss;
1877       oss << "\n      Calo ET high thresholds (hex) for calo object " << caloObjType << " " << cnt << " = " << std::hex
1878           << objParameter[cnt].etLowThreshold << " - " << objParameter[cnt].etHighThreshold;
1879       for (const auto& window : objParameter[cnt].etaWindows) {
1880         oss << "\n      etaWindow Lower / Upper for calo object " << cnt << " = 0x" << window.lower << " / 0x"
1881             << window.upper;
1882       }
1883       oss << "\n      phiWindow Lower / Upper for calo object " << cnt << " = 0x" << objParameter[cnt].phiWindow1Lower
1884           << " / 0x" << objParameter[cnt].phiWindow1Upper << "\n      phiWindowVeto Lower / Upper for calo object "
1885           << cnt << " = 0x" << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
1886           << "\n      Isolation LUT for calo object " << cnt << " = 0x" << objParameter[cnt].isolationLUT
1887           << "\n      Quality LUT for calo object " << cnt << " = 0x" << objParameter[cnt].qualityLUT
1888           << "\n      LLP DISP LUT for calo object " << cnt << " = 0x" << objParameter[cnt].displacedLUT;
1889       LogDebug("TriggerMenuParser") << oss.str() << std::endl;
1890     }
1891 
1892     cnt++;
1893   }  //end loop over objects
1894 
1895   // object types - all same caloObjType
1896   std::vector<GlobalObject> objType(nrObj, caloObjType);
1897 
1898   // now create a new calo condition
1899   CaloTemplate caloCond(name);
1900 
1901   caloCond.setCondType(cType);
1902   caloCond.setObjectType(objType);
1903 
1904   //BLW TO DO: This needs to be added to the object rather than the whole condition
1905   caloCond.setCondGEq(gEq);
1906   caloCond.setCondChipNr(chipNr);
1907 
1908   //BLW TO DO: This needs to be added to the object rather than the whole condition
1909   caloCond.setCondRelativeBx(relativeBx);
1910 
1911   caloCond.setConditionParameter(objParameter, corrParameter);
1912 
1913   if (edm::isDebugEnabled()) {
1914     std::ostringstream myCoutStream;
1915     caloCond.print(myCoutStream);
1916     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
1917   }
1918 
1919   // insert condition into the map
1920   if (!insertConditionIntoMap(caloCond, chipNr)) {
1921     edm::LogError("TriggerMenuParser") << "    Error: duplicate condition (" << name << ")" << std::endl;
1922 
1923     return false;
1924   } else {
1925     if (corrFlag) {
1926       (m_corCaloTemplate[chipNr]).push_back(caloCond);
1927     } else {
1928       (m_vecCaloTemplate[chipNr]).push_back(caloCond);
1929     }
1930   }
1931 
1932   //
1933   return true;
1934 }
1935 
1936 /**
1937  * parseCalo Parse a calo condition and insert an entry to the conditions map
1938  *
1939  * @param node The corresponding node.
1940  * @param name The name of the condition.
1941  * @param chipNr The number of the chip this condition is located.
1942  *
1943  * @return "true" if succeeded, "false" if an error occurred.
1944  *
1945  */
1946 
1947 bool l1t::TriggerMenuParser::parseCaloCorr(const L1TUtmObject* corrCalo, unsigned int chipNr) {
1948   //    XERCES_CPP_NAMESPACE_USE
1949   using namespace tmeventsetup;
1950 
1951   // get condition, particle name and type name
1952 
1953   std::string condition = "calo";
1954   std::string particle = "test-fix";
1955   std::string type = l1t2string(corrCalo->getType());
1956   std::string name = l1t2string(corrCalo->getName());
1957 
1958   LogDebug("TriggerMenuParser") << "\n ****************************************** "
1959                                 << "\n      (in parseCalo) "
1960                                 << "\n condition = " << condition << "\n particle  = " << particle
1961                                 << "\n type      = " << type << "\n name      = " << name << std::endl;
1962 
1963   // determine object type type
1964   // BLW TO DO:  Can this object type wait and be done later in the parsing. Or done differently completely..
1965   GlobalObject caloObjType;
1966   int nrObj = 1;
1967   type = "1_s";
1968   GtConditionType cType = l1t::Type1s;
1969 
1970   if (corrCalo->getType() == esObjectType::Egamma) {
1971     caloObjType = gtEG;
1972   } else if (corrCalo->getType() == esObjectType::Jet) {
1973     caloObjType = gtJet;
1974   } else if (corrCalo->getType() == esObjectType::Tau) {
1975     caloObjType = gtTau;
1976   } else {
1977     edm::LogError("TriggerMenuParser") << "Wrong particle for calo-condition (" << particle << ")" << std::endl;
1978     return false;
1979   }
1980 
1981   //    std::string str_etComparison = l1t2string( condCalo.comparison_operator() );
1982 
1983   if (nrObj < 0) {
1984     edm::LogError("TriggerMenuParser") << "Unknown type for calo-condition (" << type << ")"
1985                                        << "\nCan not determine number of trigger objects. " << std::endl;
1986     return false;
1987   }
1988 
1989   // get values
1990 
1991   // temporary storage of the parameters
1992   std::vector<CaloTemplate::ObjectParameter> objParameter(nrObj);
1993 
1994   //BLW TO DO:  Can this be dropped?
1995   CaloTemplate::CorrelationParameter corrParameter;
1996 
1997   // need at least one value for deltaPhiRange
1998   std::vector<uint64_t> tmpValues((nrObj > 1) ? nrObj : 1);
1999   tmpValues.reserve(nrObj);
2000 
2001   // BLW TO DO: These needs to the added to the object rather than the whole condition.
2002   int relativeBx = 0;
2003   bool gEq = false;
2004 
2005   gEq = (corrCalo->getComparisonOperator() == esComparisonOperator::GE);
2006 
2007   //  BLW TO DO: This needs to be added to the Object Parameters
2008   relativeBx = corrCalo->getBxOffset();
2009 
2010   //  Loop over the cuts for this object
2011   int upperThresholdInd = -1;
2012   int lowerThresholdInd = 0;
2013   int upperIndexInd = -1;
2014   int lowerIndexInd = 0;
2015   int cntPhi = 0;
2016   unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
2017   int isolationLUT = 0xF;  //default is to ignore isolation unless specified.
2018   int qualityLUT = 0xF;    //default is to ignore quality unless specified.
2019   int displacedLUT = 0x0;  // Added for LLP Jets:  single bit LUT:  { 0 = noLLP default, 1 = LLP }
2020                            // Note:  Currently assume that the hwQual() getter in L1Candidate provides the
2021                            //        (single bit) information for the displacedLUT
2022 
2023   std::vector<CaloTemplate::Window> etaWindows;
2024 
2025   const std::vector<L1TUtmCut>& cuts = corrCalo->getCuts();
2026   for (size_t kk = 0; kk < cuts.size(); kk++) {
2027     const L1TUtmCut& cut = cuts.at(kk);
2028 
2029     switch (cut.getCutType()) {
2030       case esCutType::Threshold:
2031         lowerThresholdInd = cut.getMinimum().index;
2032         upperThresholdInd = cut.getMaximum().index;
2033         break;
2034       case esCutType::Slice:
2035         lowerIndexInd = int(cut.getMinimum().value);
2036         upperIndexInd = int(cut.getMaximum().value);
2037         break;
2038       case esCutType::Eta: {
2039         if (etaWindows.size() < 5) {
2040           etaWindows.push_back({cut.getMinimum().index, cut.getMaximum().index});
2041         } else {
2042           edm::LogError("TriggerMenuParser")
2043               << "Too Many Eta Cuts for calo-condition (" << particle << ")" << std::endl;
2044           return false;
2045         }
2046       } break;
2047 
2048       case esCutType::Phi: {
2049         if (cntPhi == 0) {
2050           phiWindow1Lower = cut.getMinimum().index;
2051           phiWindow1Upper = cut.getMaximum().index;
2052         } else if (cntPhi == 1) {
2053           phiWindow2Lower = cut.getMinimum().index;
2054           phiWindow2Upper = cut.getMaximum().index;
2055         } else {
2056           edm::LogError("TriggerMenuParser")
2057               << "Too Many Phi Cuts for calo-condition (" << particle << ")" << std::endl;
2058           return false;
2059         }
2060         cntPhi++;
2061 
2062       } break;
2063 
2064       case esCutType::Charge: {
2065         edm::LogError("TriggerMenuParser") << "No charge cut for calo-condition (" << particle << ")" << std::endl;
2066         return false;
2067 
2068       } break;
2069       case esCutType::Quality: {
2070         qualityLUT = l1tstr2int(cut.getData());
2071 
2072       } break;
2073       case esCutType::Displaced: {  // Added for LLP Jets
2074         displacedLUT = l1tstr2int(cut.getData());
2075 
2076       } break;
2077       case esCutType::Isolation: {
2078         isolationLUT = l1tstr2int(cut.getData());
2079 
2080       } break;
2081       default:
2082         break;
2083     }  //end switch
2084 
2085   }  //end loop over cuts
2086 
2087   // Fill the object parameters
2088   objParameter[0].etLowThreshold = lowerThresholdInd;
2089   objParameter[0].etHighThreshold = upperThresholdInd;
2090   objParameter[0].indexHigh = upperIndexInd;
2091   objParameter[0].indexLow = lowerIndexInd;
2092   objParameter[0].etaWindows = etaWindows;
2093   objParameter[0].phiWindow1Lower = phiWindow1Lower;
2094   objParameter[0].phiWindow1Upper = phiWindow1Upper;
2095   objParameter[0].phiWindow2Lower = phiWindow2Lower;
2096   objParameter[0].phiWindow2Upper = phiWindow2Upper;
2097   objParameter[0].isolationLUT = isolationLUT;
2098   objParameter[0].qualityLUT = qualityLUT;      //TO DO: Must add
2099   objParameter[0].displacedLUT = displacedLUT;  // Added for LLP Jets
2100 
2101   // Output for debugging
2102   {
2103     std::ostringstream oss;
2104     oss << "\n      Calo ET high threshold (hex) for calo object " << caloObjType << " "
2105         << " = " << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etHighThreshold;
2106     for (const auto& window : objParameter[0].etaWindows) {
2107       oss << "\n      etaWindow Lower / Upper for calo object "
2108           << " = 0x" << window.lower << " / 0x" << window.upper;
2109     }
2110     oss << "\n      phiWindow Lower / Upper for calo object "
2111         << " = 0x" << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
2112         << "\n      phiWindowVeto Lower / Upper for calo object "
2113         << " = 0x" << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper
2114         << "\n      Isolation LUT for calo object "
2115         << " = 0x" << objParameter[0].isolationLUT << "\n      Quality LUT for calo object "
2116         << " = 0x" << objParameter[0].qualityLUT << "\n      LLP DISP LUT for calo object "
2117         << " = 0x" << objParameter[0].displacedLUT;
2118     LogDebug("TriggerMenuParser") << oss.str() << std::endl;
2119   }
2120 
2121   // object types - all same caloObjType
2122   std::vector<GlobalObject> objType(nrObj, caloObjType);
2123 
2124   // now create a new calo condition
2125   CaloTemplate caloCond(name);
2126 
2127   caloCond.setCondType(cType);
2128   caloCond.setObjectType(objType);
2129 
2130   //BLW TO DO: This needs to be added to the object rather than the whole condition
2131   caloCond.setCondGEq(gEq);
2132   caloCond.setCondChipNr(chipNr);
2133 
2134   //BLW TO DO: This needs to be added to the object rather than the whole condition
2135   caloCond.setCondRelativeBx(relativeBx);
2136 
2137   caloCond.setConditionParameter(objParameter, corrParameter);
2138 
2139   if (edm::isDebugEnabled()) {
2140     std::ostringstream myCoutStream;
2141     caloCond.print(myCoutStream);
2142     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2143   }
2144 
2145   /*
2146     // insert condition into the map
2147     if ( !insertConditionIntoMap(caloCond, chipNr)) {
2148 
2149         edm::LogError("TriggerMenuParser")
2150                 << "    Error: duplicate condition (" << name << ")"
2151                 << std::endl;
2152 
2153         return false;
2154     }
2155     else {
2156             (m_corCaloTemplate[chipNr]).push_back(caloCond);
2157     }
2158 */
2159   (m_corCaloTemplate[chipNr]).push_back(caloCond);
2160 
2161   //
2162   return true;
2163 }
2164 
2165 /**
2166  * parseEnergySum Parse an "energy sum" condition and insert an entry to the conditions map
2167  *
2168  * @param node The corresponding node.
2169  * @param name The name of the condition.
2170  * @param chipNr The number of the chip this condition is located.
2171  *
2172  * @return "true" if succeeded, "false" if an error occurred.
2173  *
2174  */
2175 
2176 bool l1t::TriggerMenuParser::parseEnergySum(L1TUtmCondition condEnergySum, unsigned int chipNr, const bool corrFlag) {
2177   //    XERCES_CPP_NAMESPACE_USE
2178   using namespace tmeventsetup;
2179 
2180   // get condition, particle name and type name
2181 
2182   std::string condition = "calo";
2183   std::string type = l1t2string(condEnergySum.getType());
2184   std::string name = l1t2string(condEnergySum.getName());
2185 
2186   LogDebug("TriggerMenuParser") << "\n ****************************************** "
2187                                 << "\n      (in parseEnergySum) "
2188                                 << "\n condition = " << condition << "\n type      = " << type
2189                                 << "\n name      = " << name << std::endl;
2190 
2191   // determine object type type
2192   GlobalObject energySumObjType;
2193   GtConditionType cType;
2194 
2195   if (condEnergySum.getType() == esConditionType::MissingEt) {
2196     energySumObjType = GlobalObject::gtETM;
2197     cType = TypeETM;
2198   } else if (condEnergySum.getType() == esConditionType::TotalEt) {
2199     energySumObjType = GlobalObject::gtETT;
2200     cType = TypeETT;
2201   } else if (condEnergySum.getType() == esConditionType::TotalEtEM) {
2202     energySumObjType = GlobalObject::gtETTem;
2203     cType = TypeETTem;
2204   } else if (condEnergySum.getType() == esConditionType::TotalHt) {
2205     energySumObjType = GlobalObject::gtHTT;
2206     cType = TypeHTT;
2207   } else if (condEnergySum.getType() == esConditionType::MissingHt) {
2208     energySumObjType = GlobalObject::gtHTM;
2209     cType = TypeHTM;
2210   } else if (condEnergySum.getType() == esConditionType::MissingEtHF) {
2211     energySumObjType = GlobalObject::gtETMHF;
2212     cType = TypeETMHF;
2213   } else if (condEnergySum.getType() == esConditionType::TowerCount) {
2214     energySumObjType = GlobalObject::gtTowerCount;
2215     cType = TypeTowerCount;
2216   } else if (condEnergySum.getType() == esConditionType::MinBiasHFP0) {
2217     energySumObjType = GlobalObject::gtMinBiasHFP0;
2218     cType = TypeMinBiasHFP0;
2219   } else if (condEnergySum.getType() == esConditionType::MinBiasHFM0) {
2220     energySumObjType = GlobalObject::gtMinBiasHFM0;
2221     cType = TypeMinBiasHFM0;
2222   } else if (condEnergySum.getType() == esConditionType::MinBiasHFP1) {
2223     energySumObjType = GlobalObject::gtMinBiasHFP1;
2224     cType = TypeMinBiasHFP1;
2225   } else if (condEnergySum.getType() == esConditionType::MinBiasHFM1) {
2226     energySumObjType = GlobalObject::gtMinBiasHFM1;
2227     cType = TypeMinBiasHFM1;
2228   } else if (condEnergySum.getType() == esConditionType::AsymmetryEt) {
2229     energySumObjType = GlobalObject::gtAsymmetryEt;
2230     cType = TypeAsymEt;
2231   } else if (condEnergySum.getType() == esConditionType::AsymmetryHt) {
2232     energySumObjType = GlobalObject::gtAsymmetryHt;
2233     cType = TypeAsymHt;
2234   } else if (condEnergySum.getType() == esConditionType::AsymmetryEtHF) {
2235     energySumObjType = GlobalObject::gtAsymmetryEtHF;
2236     cType = TypeAsymEtHF;
2237   } else if (condEnergySum.getType() == esConditionType::AsymmetryHtHF) {
2238     energySumObjType = GlobalObject::gtAsymmetryHtHF;
2239     cType = TypeAsymHtHF;
2240   } else if (condEnergySum.getType() == esConditionType::Centrality0) {
2241     energySumObjType = GlobalObject::gtCentrality0;
2242     cType = TypeCent0;
2243   } else if (condEnergySum.getType() == esConditionType::Centrality1) {
2244     energySumObjType = GlobalObject::gtCentrality1;
2245     cType = TypeCent1;
2246   } else if (condEnergySum.getType() == esConditionType::Centrality2) {
2247     energySumObjType = GlobalObject::gtCentrality2;
2248     cType = TypeCent2;
2249   } else if (condEnergySum.getType() == esConditionType::Centrality3) {
2250     energySumObjType = GlobalObject::gtCentrality3;
2251     cType = TypeCent3;
2252   } else if (condEnergySum.getType() == esConditionType::Centrality4) {
2253     energySumObjType = GlobalObject::gtCentrality4;
2254     cType = TypeCent4;
2255   } else if (condEnergySum.getType() == esConditionType::Centrality5) {
2256     energySumObjType = GlobalObject::gtCentrality5;
2257     cType = TypeCent5;
2258   } else if (condEnergySum.getType() == esConditionType::Centrality6) {
2259     energySumObjType = GlobalObject::gtCentrality6;
2260     cType = TypeCent6;
2261   } else if (condEnergySum.getType() == esConditionType::Centrality7) {
2262     energySumObjType = GlobalObject::gtCentrality7;
2263     cType = TypeCent7;
2264   } else {
2265     edm::LogError("TriggerMenuParser") << "Wrong type for energy-sum condition (" << type << ")" << std::endl;
2266     return false;
2267   }
2268 
2269   // global object
2270   int nrObj = 1;
2271 
2272   //    std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
2273 
2274   // get values
2275 
2276   // temporary storage of the parameters
2277   std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2278 
2279   int cnt = 0;
2280 
2281   // BLW TO DO: These needs to the added to the object rather than the whole condition.
2282   int relativeBx = 0;
2283   bool gEq = false;
2284 
2285   //    l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2286 
2287   // Loop over objects and extract the cuts on the objects
2288   const std::vector<L1TUtmObject>& objects = condEnergySum.getObjects();
2289   for (size_t jj = 0; jj < objects.size(); jj++) {
2290     const L1TUtmObject& object = objects.at(jj);
2291     gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
2292 
2293     //  BLW TO DO: This needs to be added to the Object Parameters
2294     relativeBx = object.getBxOffset();
2295 
2296     //  Loop over the cuts for this object
2297     int lowerThresholdInd = 0;
2298     int upperThresholdInd = -1;
2299     int cntPhi = 0;
2300     unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
2301 
2302     const std::vector<L1TUtmCut>& cuts = object.getCuts();
2303     for (size_t kk = 0; kk < cuts.size(); kk++) {
2304       const L1TUtmCut& cut = cuts.at(kk);
2305 
2306       switch (cut.getCutType()) {
2307         case esCutType::Threshold:
2308           lowerThresholdInd = cut.getMinimum().index;
2309           upperThresholdInd = cut.getMaximum().index;
2310           break;
2311 
2312         case esCutType::Eta:
2313           break;
2314 
2315         case esCutType::Phi: {
2316           if (cntPhi == 0) {
2317             phiWindow1Lower = cut.getMinimum().index;
2318             phiWindow1Upper = cut.getMaximum().index;
2319           } else if (cntPhi == 1) {
2320             phiWindow2Lower = cut.getMinimum().index;
2321             phiWindow2Upper = cut.getMaximum().index;
2322           } else {
2323             edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition (" << type << ")" << std::endl;
2324             return false;
2325           }
2326           cntPhi++;
2327 
2328         } break;
2329 
2330         case esCutType::Count:
2331           lowerThresholdInd = cut.getMinimum().index;
2332           upperThresholdInd = 0xffffff;
2333           break;
2334 
2335         default:
2336           break;
2337       }  //end switch
2338 
2339     }  //end loop over cuts
2340 
2341     // Fill the object parameters
2342     objParameter[cnt].etLowThreshold = lowerThresholdInd;
2343     objParameter[cnt].etHighThreshold = upperThresholdInd;
2344     objParameter[cnt].phiWindow1Lower = phiWindow1Lower;
2345     objParameter[cnt].phiWindow1Upper = phiWindow1Upper;
2346     objParameter[cnt].phiWindow2Lower = phiWindow2Lower;
2347     objParameter[cnt].phiWindow2Upper = phiWindow2Upper;
2348 
2349     // Output for debugging
2350     LogDebug("TriggerMenuParser") << "\n      EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2351                                   << std::hex << objParameter[cnt].etLowThreshold << " - "
2352                                   << objParameter[cnt].etHighThreshold
2353                                   << "\n      phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2354                                   << objParameter[cnt].phiWindow1Lower << " / 0x" << objParameter[cnt].phiWindow1Upper
2355                                   << "\n      phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2356                                   << objParameter[cnt].phiWindow2Lower << " / 0x" << objParameter[cnt].phiWindow2Upper
2357                                   << std::dec << std::endl;
2358 
2359     cnt++;
2360   }  //end loop over objects
2361 
2362   // object types - all same energySumObjType
2363   std::vector<GlobalObject> objType(nrObj, energySumObjType);
2364 
2365   // now create a new energySum condition
2366 
2367   EnergySumTemplate energySumCond(name);
2368 
2369   energySumCond.setCondType(cType);
2370   energySumCond.setObjectType(objType);
2371   energySumCond.setCondGEq(gEq);
2372   energySumCond.setCondChipNr(chipNr);
2373   energySumCond.setCondRelativeBx(relativeBx);
2374 
2375   energySumCond.setConditionParameter(objParameter);
2376 
2377   if (edm::isDebugEnabled()) {
2378     std::ostringstream myCoutStream;
2379     energySumCond.print(myCoutStream);
2380     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2381   }
2382 
2383   // insert condition into the map
2384   if (!insertConditionIntoMap(energySumCond, chipNr)) {
2385     edm::LogError("TriggerMenuParser") << "    Error: duplicate condition (" << name << ")" << std::endl;
2386 
2387     return false;
2388   } else {
2389     if (corrFlag) {
2390       (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2391 
2392     } else {
2393       (m_vecEnergySumTemplate[chipNr]).push_back(energySumCond);
2394     }
2395   }
2396 
2397   //
2398   return true;
2399 }
2400 
2401 /**
2402  * parseEnergySumZdc Parse an "energy sum" condition from the ZDC subsystem and insert an entry to the conditions map
2403  *
2404  * @param node The corresponding node.
2405  * @param name The name of the condition.
2406  * @param chipNr The number of the chip this condition is located.
2407  *
2408  * @return "true" if succeeded, "false" if an error occurred.
2409  *
2410  */
2411 
2412 bool l1t::TriggerMenuParser::parseEnergySumZdc(L1TUtmCondition condEnergySumZdc,
2413                                                unsigned int chipNr,
2414                                                const bool corrFlag) {
2415   //    XERCES_CPP_NAMESPACE_USE
2416   using namespace tmeventsetup;
2417 
2418   // get condition, particle name and type name
2419 
2420   std::string condition = "calo";
2421   std::string type = l1t2string(condEnergySumZdc.getType());
2422   std::string name = l1t2string(condEnergySumZdc.getName());
2423 
2424   LogDebug("TriggerMenuParser")
2425       << "\n ******************************************\n      (in parseEnergySumZdc)\n condition = " << condition
2426       << "\n type      = " << type << "\n name      = " << name;
2427 
2428   // determine object type
2429   GlobalObject energySumObjType;
2430   GtConditionType cType;
2431 
2432   if (condEnergySumZdc.getType() == esConditionType::ZDCPlus) {
2433     LogDebug("TriggerMenuParser") << "ZDC signals: esConditionType::ZDCPlus " << std::endl;
2434     energySumObjType = GlobalObject::gtZDCP;
2435     cType = TypeZDCP;
2436   } else if (condEnergySumZdc.getType() == esConditionType::ZDCMinus) {
2437     LogDebug("TriggerMenuParser") << "ZDC signals: esConditionType::ZDCMinus " << std::endl;
2438     energySumObjType = GlobalObject::gtZDCM;
2439     cType = TypeZDCM;
2440   } else {
2441     edm::LogError("TriggerMenuParser") << "Wrong type for ZDC energy-sum condition (" << type << ")" << std::endl;
2442     return false;
2443   }
2444 
2445   // global object
2446   int nrObj = 1;
2447 
2448   // temporary storage of the parameters
2449   std::vector<EnergySumZdcTemplate::ObjectParameter> objParameter(nrObj);
2450 
2451   //  Loop over the cuts for this object
2452   int lowerThresholdInd = 0;
2453   int upperThresholdInd = -1;
2454 
2455   int cnt = 0;
2456 
2457   // BLW TO DO: These needs to the added to the object rather than the whole condition.
2458   int relativeBx = 0;
2459   bool gEq = false;
2460 
2461   //    l1t::EnergySumsObjectRequirement objPar = condEnergySumZdc.objectRequirement();
2462 
2463   // Loop over objects and extract the cuts on the objects
2464   const std::vector<L1TUtmObject>& objects = condEnergySumZdc.getObjects();
2465   for (size_t jj = 0; jj < objects.size(); jj++) {
2466     const L1TUtmObject& object = objects.at(jj);
2467     gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
2468 
2469     //  BLW TO DO: This needs to be added to the Object Parameters
2470     relativeBx = object.getBxOffset();
2471 
2472     //  Loop over the cuts for this object
2473     const std::vector<L1TUtmCut>& cuts = object.getCuts();
2474     for (size_t kk = 0; kk < cuts.size(); kk++) {
2475       const L1TUtmCut& cut = cuts.at(kk);
2476 
2477       switch (cut.getCutType()) {
2478         case esCutType::Threshold:
2479           lowerThresholdInd = cut.getMinimum().index;
2480           upperThresholdInd = cut.getMaximum().index;
2481           break;
2482 
2483         case esCutType::Count:
2484           lowerThresholdInd = cut.getMinimum().index;
2485           upperThresholdInd = 0xffffff;
2486           break;
2487 
2488         default:
2489           break;
2490       }  //end switch
2491 
2492     }  //end loop over cuts
2493 
2494     // Fill the object parameters
2495     objParameter[cnt].etLowThreshold = lowerThresholdInd;
2496     objParameter[cnt].etHighThreshold = upperThresholdInd;
2497 
2498     // Output for debugging
2499     LogDebug("TriggerMenuParser") << "\n      EnergySumZdc ET high threshold (hex) for energy sum object " << cnt
2500                                   << " = " << std::hex << objParameter[cnt].etLowThreshold << " - "
2501                                   << objParameter[cnt].etHighThreshold << std::dec;
2502 
2503     cnt++;
2504   }  //end loop over objects
2505 
2506   // object types - all same energySumObjType
2507   std::vector<GlobalObject> objType(nrObj, energySumObjType);
2508 
2509   // now create a new energySum condition
2510 
2511   EnergySumZdcTemplate energySumCond(name);
2512 
2513   energySumCond.setCondType(cType);
2514   energySumCond.setObjectType(objType);
2515   energySumCond.setCondGEq(gEq);
2516   energySumCond.setCondChipNr(chipNr);
2517   energySumCond.setCondRelativeBx(relativeBx);
2518 
2519   energySumCond.setConditionParameter(objParameter);
2520 
2521   if (edm::isDebugEnabled()) {
2522     std::ostringstream myCoutStream;
2523     energySumCond.print(myCoutStream);
2524     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2525   }
2526 
2527   // insert condition into the map
2528   if (!insertConditionIntoMap(energySumCond, chipNr)) {
2529     edm::LogError("TriggerMenuParser") << "    Error: duplicate condition (" << name << ")" << std::endl;
2530 
2531     return false;
2532   } else {
2533     (m_vecEnergySumZdcTemplate[chipNr]).push_back(energySumCond);
2534   }
2535   //
2536   return true;
2537 }
2538 
2539 /**
2540  * parseEnergySumCorr Parse an "energy sum" correlation condition and insert an entry to the conditions map
2541  *
2542  * @param node The corresponding node.
2543  * @param name The name of the condition.
2544  * @param chipNr The number of the chip this condition is located.
2545  *
2546  * @return "true" if succeeded, "false" if an error occurred.
2547  *
2548  */
2549 
2550 bool l1t::TriggerMenuParser::parseEnergySumCorr(const L1TUtmObject* corrESum, unsigned int chipNr) {
2551   //    XERCES_CPP_NAMESPACE_USE
2552   using namespace tmeventsetup;
2553 
2554   // get condition, particle name and type name
2555 
2556   std::string condition = "calo";
2557   std::string type = l1t2string(corrESum->getType());
2558   std::string name = l1t2string(corrESum->getName());
2559 
2560   LogDebug("TriggerMenuParser") << "\n ****************************************** "
2561                                 << "\n      (in parseEnergySum) "
2562                                 << "\n condition = " << condition << "\n type      = " << type
2563                                 << "\n name      = " << name << std::endl;
2564 
2565   // determine object type type
2566   GlobalObject energySumObjType;
2567   GtConditionType cType;
2568 
2569   if (corrESum->getType() == esObjectType::ETM) {
2570     energySumObjType = GlobalObject::gtETM;
2571     cType = TypeETM;
2572   } else if (corrESum->getType() == esObjectType::HTM) {
2573     energySumObjType = GlobalObject::gtHTM;
2574     cType = TypeHTM;
2575   } else if (corrESum->getType() == esObjectType::ETMHF) {
2576     energySumObjType = GlobalObject::gtETMHF;
2577     cType = TypeETMHF;
2578   } else if (corrESum->getType() == esObjectType::TOWERCOUNT) {
2579     energySumObjType = GlobalObject::gtTowerCount;
2580     cType = TypeTowerCount;
2581   } else {
2582     edm::LogError("TriggerMenuParser") << "Wrong type for energy-sum correclation condition (" << type << ")"
2583                                        << std::endl;
2584     return false;
2585   }
2586 
2587   // global object
2588   int nrObj = 1;
2589 
2590   //    std::string str_etComparison = l1t2string( condEnergySum.comparison_operator() );
2591 
2592   // get values
2593 
2594   // temporary storage of the parameters
2595   std::vector<EnergySumTemplate::ObjectParameter> objParameter(nrObj);
2596 
2597   int cnt = 0;
2598 
2599   // BLW TO DO: These needs to the added to the object rather than the whole condition.
2600   int relativeBx = 0;
2601   bool gEq = false;
2602 
2603   //    l1t::EnergySumsObjectRequirement objPar = condEnergySum.objectRequirement();
2604 
2605   gEq = (corrESum->getComparisonOperator() == esComparisonOperator::GE);
2606 
2607   //  BLW TO DO: This needs to be added to the Object Parameters
2608   relativeBx = corrESum->getBxOffset();
2609 
2610   //  Loop over the cuts for this object
2611   int lowerThresholdInd = 0;
2612   int upperThresholdInd = -1;
2613   int cntPhi = 0;
2614   unsigned int phiWindow1Lower = -1, phiWindow1Upper = -1, phiWindow2Lower = -1, phiWindow2Upper = -1;
2615 
2616   const std::vector<L1TUtmCut>& cuts = corrESum->getCuts();
2617   for (size_t kk = 0; kk < cuts.size(); kk++) {
2618     const L1TUtmCut& cut = cuts.at(kk);
2619 
2620     switch (cut.getCutType()) {
2621       case esCutType::Threshold:
2622         lowerThresholdInd = cut.getMinimum().index;
2623         upperThresholdInd = cut.getMaximum().index;
2624         break;
2625 
2626       case esCutType::Eta:
2627         break;
2628 
2629       case esCutType::Phi: {
2630         if (cntPhi == 0) {
2631           phiWindow1Lower = cut.getMinimum().index;
2632           phiWindow1Upper = cut.getMaximum().index;
2633         } else if (cntPhi == 1) {
2634           phiWindow2Lower = cut.getMinimum().index;
2635           phiWindow2Upper = cut.getMaximum().index;
2636         } else {
2637           edm::LogError("TriggerMenuParser") << "Too Many Phi Cuts for esum-condition (" << type << ")" << std::endl;
2638           return false;
2639         }
2640         cntPhi++;
2641 
2642       } break;
2643 
2644       default:
2645         break;
2646     }  //end switch
2647 
2648   }  //end loop over cuts
2649 
2650   // Fill the object parameters
2651   objParameter[0].etLowThreshold = lowerThresholdInd;
2652   objParameter[0].etHighThreshold = upperThresholdInd;
2653   objParameter[0].phiWindow1Lower = phiWindow1Lower;
2654   objParameter[0].phiWindow1Upper = phiWindow1Upper;
2655   objParameter[0].phiWindow2Lower = phiWindow2Lower;
2656   objParameter[0].phiWindow2Upper = phiWindow2Upper;
2657 
2658   // Output for debugging
2659   LogDebug("TriggerMenuParser") << "\n      EnergySum ET high threshold (hex) for energy sum object " << cnt << " = "
2660                                 << std::hex << objParameter[0].etLowThreshold << " - " << objParameter[0].etLowThreshold
2661                                 << "\n      phiWindow Lower / Upper for calo object " << cnt << " = 0x"
2662                                 << objParameter[0].phiWindow1Lower << " / 0x" << objParameter[0].phiWindow1Upper
2663                                 << "\n      phiWindowVeto Lower / Upper for calo object " << cnt << " = 0x"
2664                                 << objParameter[0].phiWindow2Lower << " / 0x" << objParameter[0].phiWindow2Upper
2665                                 << std::dec << std::endl;
2666 
2667   // object types - all same energySumObjType
2668   std::vector<GlobalObject> objType(nrObj, energySumObjType);
2669 
2670   // now create a new energySum condition
2671 
2672   EnergySumTemplate energySumCond(name);
2673 
2674   energySumCond.setCondType(cType);
2675   energySumCond.setObjectType(objType);
2676   energySumCond.setCondGEq(gEq);
2677   energySumCond.setCondChipNr(chipNr);
2678   energySumCond.setCondRelativeBx(relativeBx);
2679 
2680   energySumCond.setConditionParameter(objParameter);
2681 
2682   if (edm::isDebugEnabled()) {
2683     std::ostringstream myCoutStream;
2684     energySumCond.print(myCoutStream);
2685     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2686   }
2687   /*
2688     // insert condition into the map
2689     if ( !insertConditionIntoMap(energySumCond, chipNr)) {
2690 
2691         edm::LogError("TriggerMenuParser")
2692                 << "    Error: duplicate condition (" << name << ")"
2693                 << std::endl;
2694 
2695         return false;
2696     }
2697     else {
2698 
2699        (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2700 
2701     }
2702 */
2703   (m_corEnergySumTemplate[chipNr]).push_back(energySumCond);
2704 
2705   //
2706   return true;
2707 }
2708 
2709 /**                                                                                                                                                            
2710  * parseEnergySumCorr Parse an "energy sum" correlation condition and insert an entry to the conditions map                                                    
2711  *                                                                                                                                                             
2712  * @param node The corresponding node.                                                                                                                        
2713  * @param name The name of the condition.                                                                                                                      
2714  * @param chipNr The number of the chip this condition is located.                                                                                             
2715  *                                                                                                                                                             
2716  * @return "true" if succeeded, "false" if an error occurred.                                                                                                  
2717  *                                                                                                                                                             
2718  */
2719 
2720 bool l1t::TriggerMenuParser::parseAXOL1TL(L1TUtmCondition condAXOL1TL, unsigned int chipNr) {
2721   using namespace tmeventsetup;
2722 
2723   // get condition, particle name and particle type
2724   std::string condition = "axol1tl";
2725   std::string type = l1t2string(condAXOL1TL.getType());
2726   std::string name = l1t2string(condAXOL1TL.getName());
2727 
2728   LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
2729                                 << "     (in parseAXOL1TL) " << std::endl
2730                                 << " condition = " << condition << std::endl
2731                                 << " type      = " << type << std::endl
2732                                 << " name      = " << name << std::endl;
2733 
2734   const int nrObj = 1;
2735   GtConditionType cType = TypeAXOL1TL;
2736 
2737   std::vector<AXOL1TLTemplate::ObjectParameter> objParameter(nrObj);
2738 
2739   if (int(condAXOL1TL.getObjects().size()) != nrObj) {
2740     edm::LogError("TriggerMenuParser") << " condAXOL1TL objects: nrObj = " << nrObj
2741                                        << "condAXOL1TL.getObjects().size() = " << condAXOL1TL.getObjects().size()
2742                                        << std::endl;
2743     return false;
2744   }
2745 
2746   // Get the axol1tl object
2747   L1TUtmObject object = condAXOL1TL.getObjects().at(0);
2748   int relativeBx = object.getBxOffset();
2749   bool gEq = (object.getComparisonOperator() == esComparisonOperator::GE);
2750 
2751   //Loop over cuts for this  object
2752   int lowerThresholdInd = 0;
2753   int upperThresholdInd = -1;
2754 
2755   const std::vector<L1TUtmCut>& cuts = object.getCuts();
2756   for (size_t kk = 0; kk < cuts.size(); kk++) {
2757     const L1TUtmCut& cut = cuts.at(kk);
2758 
2759     switch (cut.getCutType()) {
2760       case esCutType::AnomalyScore:
2761         lowerThresholdInd = cut.getMinimum().value;
2762         upperThresholdInd = cut.getMaximum().value;
2763         break;
2764       default:
2765         break;
2766     }  //end switch
2767   }    //end cut loop
2768 
2769   //fill object params
2770   objParameter[0].minAXOL1TLThreshold = lowerThresholdInd;
2771   objParameter[0].maxAXOL1TLThreshold = upperThresholdInd;
2772 
2773   // create a new AXOL1TL  condition
2774   AXOL1TLTemplate axol1tlCond(name);
2775   axol1tlCond.setCondType(cType);
2776   axol1tlCond.setCondGEq(gEq);
2777   axol1tlCond.setCondChipNr(chipNr);
2778   axol1tlCond.setCondRelativeBx(relativeBx);
2779   axol1tlCond.setConditionParameter(objParameter);
2780 
2781   if (edm::isDebugEnabled()) {
2782     std::ostringstream myCoutStream;
2783     axol1tlCond.print(myCoutStream);
2784     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
2785   }
2786 
2787   // check that the condition does not exist already in the map
2788   if (!insertConditionIntoMap(axol1tlCond, chipNr)) {
2789     edm::LogError("TriggerMenuParser") << "    Error: duplicate AXOL1TL condition (" << name << ")" << std::endl;
2790     return false;
2791   }
2792 
2793   (m_vecAXOL1TLTemplate[chipNr]).push_back(axol1tlCond);
2794 
2795   return true;
2796 }
2797 
2798 /**
2799  * parseExternal Parse an External condition and
2800  * insert an entry to the conditions map
2801  *
2802  * @param node The corresponding node.
2803  * @param name The name of the condition.
2804  * @param chipNr The number of the chip this condition is located.
2805  *
2806  * @return "true" if succeeded, "false" if an error occurred.
2807  *
2808  */
2809 
2810 bool l1t::TriggerMenuParser::parseExternal(L1TUtmCondition condExt, unsigned int chipNr) {
2811   using namespace tmeventsetup;
2812   // get condition, particle name and type name
2813   std::string condition = "ext";
2814   std::string particle = "test-fix";
2815   std::string type = l1t2string(condExt.getType());
2816   std::string name = l1t2string(condExt.getName());
2817 
2818   LogDebug("TriggerMenuParser") << "\n ****************************************** "
2819                                 << "\n      (in parseExternal) "
2820                                 << "\n condition = " << condition << "\n particle  = " << particle
2821                                 << "\n type      = " << type << "\n name      = " << name << std::endl;
2822 
2823   // object type and condition type
2824   // object type - irrelevant for External conditions
2825   GtConditionType cType = TypeExternal;
2826   GlobalObject extSignalType = GlobalObject::gtExternal;
2827   int nrObj = 1;  //only one object for these conditions
2828 
2829   int relativeBx = 0;
2830   unsigned int channelID = 0;
2831 
2832   // Get object for External conditions
2833   const std::vector<L1TUtmObject>& objects = condExt.getObjects();
2834   for (size_t jj = 0; jj < objects.size(); jj++) {
2835     const L1TUtmObject& object = objects.at(jj);
2836     if (object.getType() == esObjectType::EXT) {
2837       relativeBx = object.getBxOffset();
2838       channelID = object.getExternalChannelId();
2839     }
2840   }
2841 
2842   // set the boolean value for the ge_eq mode - irrelevant for External conditions
2843   bool gEq = false;
2844 
2845   //object types - all same for external conditions
2846   std::vector<GlobalObject> objType(nrObj, extSignalType);
2847 
2848   // now create a new External condition
2849   ExternalTemplate externalCond(name);
2850 
2851   externalCond.setCondType(cType);
2852   externalCond.setObjectType(objType);
2853   externalCond.setCondGEq(gEq);
2854   externalCond.setCondChipNr(chipNr);
2855   externalCond.setCondRelativeBx(relativeBx);
2856   externalCond.setExternalChannel(channelID);
2857 
2858   LogTrace("TriggerMenuParser") << externalCond << "\n" << std::endl;
2859 
2860   // insert condition into the map
2861   if (!insertConditionIntoMap(externalCond, chipNr)) {
2862     edm::LogError("TriggerMenuParser") << "    Error: duplicate condition (" << name << ")" << std::endl;
2863 
2864     return false;
2865   } else {
2866     (m_vecExternalTemplate[chipNr]).push_back(externalCond);
2867   }
2868 
2869   return true;
2870 }
2871 
2872 /**
2873  * parseCorrelation Parse a correlation condition and
2874  * insert an entry to the conditions map
2875  *
2876  * @param node The corresponding node.
2877  * @param name The name of the condition.
2878  * @param chipNr The number of the chip this condition is located.
2879  *
2880  * @return "true" if succeeded, "false" if an error occurred.
2881  *
2882  */
2883 
2884 bool l1t::TriggerMenuParser::parseCorrelation(L1TUtmCondition corrCond, unsigned int chipNr) {
2885   using namespace tmeventsetup;
2886   std::string condition = "corr";
2887   std::string particle = "test-fix";
2888   std::string type = l1t2string(corrCond.getType());
2889   std::string name = l1t2string(corrCond.getName());
2890 
2891   LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
2892                                 << "     (in parseCorrelation) " << std::endl
2893                                 << " condition = " << condition << std::endl
2894                                 << " particle  = " << particle << std::endl
2895                                 << " type      = " << type << std::endl
2896                                 << " name      = " << name << std::endl;
2897 
2898   // create a new correlation condition
2899   CorrelationTemplate correlationCond(name);
2900 
2901   // check that the condition does not exist already in the map
2902   if (!insertConditionIntoMap(correlationCond, chipNr)) {
2903     edm::LogError("TriggerMenuParser") << "    Error: duplicate correlation condition (" << name << ")" << std::endl;
2904 
2905     return false;
2906   }
2907 
2908   // Define some of the quantities to store the parased information
2909 
2910   // condition type BLW  (Do we change this to the type of correlation condition?)
2911   GtConditionType cType = l1t::Type2cor;
2912 
2913   // two objects (for sure)
2914   const int nrObj = 2;
2915 
2916   // object types and greater equal flag - filled in the loop
2917   int intGEq[nrObj] = {-1, -1};
2918   std::vector<GlobalObject> objType(nrObj);           //BLW do we want to define these as a different type?
2919   std::vector<GtConditionCategory> condCateg(nrObj);  //BLW do we want to change these categories
2920 
2921   // correlation flag and index in the cor*vector
2922   const bool corrFlag = true;
2923   int corrIndexVal[nrObj] = {-1, -1};
2924 
2925   // Storage of the correlation selection
2926   CorrelationTemplate::CorrelationParameter corrParameter;
2927   corrParameter.chargeCorrelation = 1;  //ignore charge correlation
2928 
2929   // Get the correlation Cuts on the legs
2930   int cutType = 0;
2931   const std::vector<L1TUtmCut>& cuts = corrCond.getCuts();
2932   for (size_t jj = 0; jj < cuts.size(); jj++) {
2933     const L1TUtmCut& cut = cuts.at(jj);
2934 
2935     if (cut.getCutType() == esCutType::ChargeCorrelation) {
2936       if (cut.getData() == "ls")
2937         corrParameter.chargeCorrelation = 2;
2938       else if (cut.getData() == "os")
2939         corrParameter.chargeCorrelation = 4;
2940       else
2941         corrParameter.chargeCorrelation = 1;  //ignore charge correlation
2942     } else {
2943       //
2944       //  Until utm has method to calculate these, do the integer value calculation with precision.
2945       //
2946       double minV = cut.getMinimum().value;
2947       double maxV = cut.getMaximum().value;
2948 
2949       //Scale down very large numbers out of xml
2950       if (maxV > 1.0e8)
2951         maxV = 1.0e8;
2952 
2953       if (cut.getCutType() == esCutType::DeltaEta) {
2954         LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaEta Cut minV = " << minV
2955                                       << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2956                                       << " precMax = " << cut.getMaximum().index << std::endl;
2957         corrParameter.minEtaCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2958         corrParameter.maxEtaCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2959         corrParameter.precEtaCut = cut.getMinimum().index;
2960         cutType = cutType | 0x1;
2961       } else if (cut.getCutType() == esCutType::DeltaPhi) {
2962         LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaPhi Cut minV = " << minV
2963                                       << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2964                                       << " precMax = " << cut.getMaximum().index << std::endl;
2965         corrParameter.minPhiCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2966         corrParameter.maxPhiCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2967         corrParameter.precPhiCut = cut.getMinimum().index;
2968         cutType = cutType | 0x2;
2969       } else if (cut.getCutType() == esCutType::DeltaR) {
2970         LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tDeltaR Cut minV = " << minV
2971                                       << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2972                                       << " precMax = " << cut.getMaximum().index << std::endl;
2973         corrParameter.minDRCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2974         corrParameter.maxDRCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2975         corrParameter.precDRCut = cut.getMinimum().index;
2976         cutType = cutType | 0x4;
2977       } else if (cut.getCutType() == esCutType::TwoBodyPt) {
2978         corrParameter.minTBPTCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2979         corrParameter.maxTBPTCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2980         corrParameter.precTBPTCut = cut.getMinimum().index;
2981         LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tTPBT Cut minV = " << minV
2982                                       << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2983                                       << " precMax = " << cut.getMaximum().index << std::endl;
2984         cutType = cutType | 0x20;
2985       } else if ((cut.getCutType() == esCutType::Mass) ||
2986                  (cut.getCutType() == esCutType::MassDeltaR)) {  //Invariant Mass, MassOverDeltaR
2987         LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV
2988                                       << " Max = " << maxV << " precMin = " << cut.getMinimum().index
2989                                       << " precMax = " << cut.getMaximum().index << std::endl;
2990         corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
2991         corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
2992         corrParameter.precMassCut = cut.getMinimum().index;
2993         // cutType = cutType | 0x8;
2994         if (corrCond.getType() == esConditionType::TransverseMass) {
2995           cutType = cutType | 0x10;
2996         } else if (corrCond.getType() == esConditionType::InvariantMassDeltaR) {
2997           cutType = cutType | 0x80;
2998         } else {
2999           cutType = cutType | 0x8;
3000         }
3001       } else if (cut.getCutType() == esCutType::MassUpt) {  // Added for displaced muons
3002         LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV
3003                                       << " Max = " << maxV << " precMin = " << cut.getMinimum().index
3004                                       << " precMax = " << cut.getMaximum().index << std::endl;
3005         corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3006         corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3007         corrParameter.precMassCut = cut.getMinimum().index;
3008         cutType = cutType | 0x40;  // Note:    0x40 (MassUpt) is next available bit after 0x20 (TwoBodyPt)
3009       }                            // Careful: cutType carries same info as esCutType, but is hard coded!!
3010     }                              //          This seems like a historical hack, which may be error prone.
3011   }                                //          cutType is defined here, for use later in CorrCondition.cc
3012   corrParameter.corrCutType = cutType;
3013 
3014   // Get the two objects that form the legs
3015   const std::vector<L1TUtmObject>& objects = corrCond.getObjects();
3016   if (objects.size() != 2) {
3017     edm::LogError("TriggerMenuParser") << "incorrect number of objects for the correlation condition " << name
3018                                        << " corrFlag " << corrFlag << std::endl;
3019     return false;
3020   }
3021 
3022   // loop over legs
3023   for (size_t jj = 0; jj < objects.size(); jj++) {
3024     const L1TUtmObject& object = objects.at(jj);
3025     LogDebug("TriggerMenuParser") << "      obj name = " << object.getName() << "\n";
3026     LogDebug("TriggerMenuParser") << "      obj type = " << object.getType() << "\n";
3027     LogDebug("TriggerMenuParser") << "      obj op = " << object.getComparisonOperator() << "\n";
3028     LogDebug("TriggerMenuParser") << "      obj bx = " << object.getBxOffset() << "\n";
3029 
3030     // check the leg type
3031     if (object.getType() == esObjectType::Muon) {
3032       // we have a muon
3033 
3034       /*
3035           //BLW Hold on to this code we may need to go back to it at some point.
3036       // Now we are putting ALL leg conditions into the vector (so there are duplicates)
3037       // This is potentially a place to slim down the code.  Note: We currently evaluate the
3038       // conditions every time, so even if we put the condition in the vector once, we would
3039       // still evaluate it multiple times.  This is a place for optimization.
3040           {
3041 
3042               parseMuonCorr(&object,chipNr);
3043           corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
3044 
3045           } else {
3046          LogDebug("TriggerMenuParser") << "Not Adding Correlation Muon Condition to Map...looking for the condition in Muon Cor Vector" << std::endl;
3047          bool found = false;
3048          int index = 0;
3049          while(!found && index<(int)((m_corMuonTemplate[chipNr]).size()) ) {
3050              if( (m_corMuonTemplate[chipNr]).at(index).condName() == object.getName() ) {
3051             LogDebug("TriggerMenuParser") << "Found condition " << object.getName() << " in vector at index " << index << std::endl;
3052             found = true;
3053          } else {
3054             index++;
3055          }
3056          }
3057          if(found) {
3058             corrIndexVal[jj] = index;
3059          } else {
3060            edm::LogError("TriggerMenuParser") << "FAILURE: Condition " << object.getName() << " is in map but not in cor. vector " << std::endl;
3061          }
3062 
3063       }
3064 */
3065       parseMuonCorr(&object, chipNr);
3066       corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
3067 
3068       //Now set some flags for this subCondition
3069       intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3070       objType[jj] = gtMu;
3071       condCateg[jj] = CondMuon;
3072 
3073     } else if (object.getType() == esObjectType::Egamma || object.getType() == esObjectType::Jet ||
3074                object.getType() == esObjectType::Tau) {
3075       // we have an Calo object
3076       parseCaloCorr(&object, chipNr);
3077       corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
3078 
3079       //Now set some flags for this subCondition
3080       intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3081       switch (object.getType()) {
3082         case esObjectType::Egamma: {
3083           objType[jj] = gtEG;
3084         } break;
3085         case esObjectType::Jet: {
3086           objType[jj] = gtJet;
3087         } break;
3088         case esObjectType::Tau: {
3089           objType[jj] = gtTau;
3090         } break;
3091         default: {
3092         } break;
3093       }
3094       condCateg[jj] = CondCalo;
3095 
3096     } else if (object.getType() == esObjectType::ETM || object.getType() == esObjectType::ETMHF ||
3097                object.getType() == esObjectType::TOWERCOUNT || object.getType() == esObjectType::HTM) {
3098       // we have Energy Sum
3099       parseEnergySumCorr(&object, chipNr);
3100       corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
3101 
3102       //Now set some flags for this subCondition
3103       intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3104       switch (object.getType()) {
3105         case esObjectType::ETM: {
3106           objType[jj] = GlobalObject::gtETM;
3107         } break;
3108         case esObjectType::HTM: {
3109           objType[jj] = GlobalObject::gtHTM;
3110         } break;
3111         case esObjectType::ETMHF: {
3112           objType[jj] = GlobalObject::gtETMHF;
3113         } break;
3114         case esObjectType::TOWERCOUNT: {
3115           objType[jj] = GlobalObject::gtTowerCount;
3116         } break;
3117         default: {
3118         } break;
3119       }
3120       condCateg[jj] = CondEnergySum;
3121 
3122     } else {
3123       edm::LogError("TriggerMenuParser") << "Illegal Object Type " << object.getType()
3124                                          << " for the correlation condition " << name << std::endl;
3125       return false;
3126 
3127     }  //if block on leg types
3128 
3129   }  //loop over legs
3130 
3131   // get greater equal flag for the correlation condition
3132   bool gEq = true;
3133   if (intGEq[0] != intGEq[1]) {
3134     edm::LogError("TriggerMenuParser") << "Inconsistent GEq flags for sub-conditions "
3135                                        << " for the correlation condition " << name << std::endl;
3136     return false;
3137 
3138   } else {
3139     gEq = (intGEq[0] != 0);
3140   }
3141 
3142   // fill the correlation condition
3143   correlationCond.setCondType(cType);
3144   correlationCond.setObjectType(objType);
3145   correlationCond.setCondGEq(gEq);
3146   correlationCond.setCondChipNr(chipNr);
3147 
3148   correlationCond.setCond0Category(condCateg[0]);
3149   correlationCond.setCond1Category(condCateg[1]);
3150 
3151   correlationCond.setCond0Index(corrIndexVal[0]);
3152   correlationCond.setCond1Index(corrIndexVal[1]);
3153 
3154   correlationCond.setCorrelationParameter(corrParameter);
3155 
3156   if (edm::isDebugEnabled()) {
3157     std::ostringstream myCoutStream;
3158     correlationCond.print(myCoutStream);
3159     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3160   }
3161 
3162   // insert condition into the map
3163   // condition is not duplicate, check was done at the beginning
3164 
3165   (m_vecCorrelationTemplate[chipNr]).push_back(correlationCond);
3166 
3167   //
3168   return true;
3169 }
3170 
3171 //////////////////////////////////////////////////////////////////////////////////////
3172 /**
3173  * parseCorrelationThreeBody Parse a correlation condition between three objects and
3174  * insert an entry to the conditions map
3175  *
3176  * @param node The corresponding node.
3177  * @param name The name of the condition.
3178  * @param chipNr The number of the chip this condition is located.
3179  *
3180  * @return "true" if succeeded, "false" if an error occurred.
3181  *
3182  */
3183 
3184 bool l1t::TriggerMenuParser::parseCorrelationThreeBody(L1TUtmCondition corrCond, unsigned int chipNr) {
3185   using namespace tmeventsetup;
3186   std::string condition = "corrThreeBody";
3187   std::string particle = "muon";
3188   std::string type = l1t2string(corrCond.getType());
3189   std::string name = l1t2string(corrCond.getName());
3190 
3191   LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
3192                                 << "     (in parseCorrelationThreeBody) " << std::endl
3193                                 << " condition = " << condition << std::endl
3194                                 << " particle  = " << particle << std::endl
3195                                 << " type      = " << type << std::endl
3196                                 << " name      = " << name << std::endl;
3197 
3198   // create a new correlation condition
3199   CorrelationThreeBodyTemplate correlationThreeBodyCond(name);
3200 
3201   // check that the condition does not exist already in the map
3202   if (!insertConditionIntoMap(correlationThreeBodyCond, chipNr)) {
3203     edm::LogError("TriggerMenuParser") << "    Error: duplicate correlation condition (" << name << ")" << std::endl;
3204     return false;
3205   }
3206 
3207   // Define some of the quantities to store the parsed information
3208   GtConditionType cType = l1t::Type3s;
3209 
3210   // three objects (for sure)
3211   const int nrObj = 3;
3212 
3213   // object types and greater equal flag - filled in the loop
3214   std::vector<GlobalObject> objType(nrObj);
3215   std::vector<GtConditionCategory> condCateg(nrObj);
3216 
3217   // correlation flag and index in the cor*vector
3218   const bool corrFlag = true;
3219   int corrIndexVal[nrObj] = {-1, -1, -1};
3220 
3221   // Storage of the correlation selection
3222   CorrelationThreeBodyTemplate::CorrelationThreeBodyParameter corrThreeBodyParameter;
3223   // Set charge correlation parameter
3224   //corrThreeBodyParameter.chargeCorrelation = chargeCorrelation;  //tmpValues[0];
3225   //corrThreeBodyParameter.chargeCorrelation = 1;  //ignore charge correlation for corr-legs
3226 
3227   // Get the correlation cuts on the legs
3228   int cutType = 0;
3229   const std::vector<L1TUtmCut>& cuts = corrCond.getCuts();
3230   for (size_t lll = 0; lll < cuts.size(); lll++) {  // START esCut lll
3231     const L1TUtmCut& cut = cuts.at(lll);
3232 
3233     if (cut.getCutType() == esCutType::ChargeCorrelation) {
3234       if (cut.getData() == "ls")
3235         corrThreeBodyParameter.chargeCorrelation = 2;
3236       else if (cut.getData() == "os")
3237         corrThreeBodyParameter.chargeCorrelation = 4;
3238       else
3239         corrThreeBodyParameter.chargeCorrelation = 1;  //ignore charge correlation
3240     }
3241 
3242     //
3243     //  Until utm has method to calculate these, do the integer value calculation with precision.
3244     //
3245     double minV = cut.getMinimum().value;
3246     double maxV = cut.getMaximum().value;
3247     //Scale down very large numbers out of xml
3248     if (maxV > 1.0e8)
3249       maxV = 1.0e8;
3250 
3251     if (cut.getCutType() == esCutType::Mass) {
3252       LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV
3253                                     << "\tMass Cut maxV = " << maxV << " precMin = " << cut.getMinimum().index
3254                                     << " precMax = " << cut.getMaximum().index << std::endl;
3255       corrThreeBodyParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3256       corrThreeBodyParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3257       corrThreeBodyParameter.precMassCut = cut.getMinimum().index;
3258       cutType = cutType | 0x8;
3259     } else if (cut.getCutType() == esCutType::MassDeltaR) {
3260       corrThreeBodyParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3261       corrThreeBodyParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3262       corrThreeBodyParameter.precMassCut = cut.getMinimum().index;
3263       cutType = cutType | 0x80;
3264     }
3265   }  // END esCut lll
3266   corrThreeBodyParameter.corrCutType = cutType;
3267 
3268   // Get the three objects that form the legs
3269   const std::vector<L1TUtmObject>& objects = corrCond.getObjects();
3270   if (objects.size() != 3) {
3271     edm::LogError("TriggerMenuParser") << "incorrect number of objects for the correlation condition " << name
3272                                        << " corrFlag " << corrFlag << std::endl;
3273     return false;
3274   }
3275 
3276   // Loop over legs
3277   for (size_t lll = 0; lll < objects.size(); lll++) {
3278     const L1TUtmObject& object = objects.at(lll);
3279     LogDebug("TriggerMenuParser") << "      obj name = " << object.getName() << "\n";
3280     LogDebug("TriggerMenuParser") << "      obj type = " << object.getType() << "\n";
3281     LogDebug("TriggerMenuParser") << "      obj bx = " << object.getBxOffset() << "\n";
3282 
3283     // check the leg type
3284     if (object.getType() == esObjectType::Muon) {
3285       // we have a muon
3286       parseMuonCorr(&object, chipNr);
3287       corrIndexVal[lll] = (m_corMuonTemplate[chipNr]).size() - 1;
3288 
3289       //Now set some flags for this subCondition
3290       objType[lll] = gtMu;
3291       condCateg[lll] = CondMuon;
3292 
3293     } else {
3294       edm::LogError("TriggerMenuParser") << "Checked the object Type " << object.getType()
3295                                          << " for the correlation condition " << name
3296                                          << ": no three muons in the event!" << std::endl;
3297     }
3298   }  // End loop over legs
3299 
3300   // fill the three-body correlation condition
3301   correlationThreeBodyCond.setCondType(cType);
3302   correlationThreeBodyCond.setObjectType(objType);
3303   correlationThreeBodyCond.setCondChipNr(chipNr);
3304 
3305   correlationThreeBodyCond.setCond0Category(condCateg[0]);
3306   correlationThreeBodyCond.setCond1Category(condCateg[1]);
3307   correlationThreeBodyCond.setCond2Category(condCateg[2]);
3308 
3309   correlationThreeBodyCond.setCond0Index(corrIndexVal[0]);
3310   correlationThreeBodyCond.setCond1Index(corrIndexVal[1]);
3311   correlationThreeBodyCond.setCond2Index(corrIndexVal[2]);
3312 
3313   correlationThreeBodyCond.setCorrelationThreeBodyParameter(corrThreeBodyParameter);
3314 
3315   if (edm::isDebugEnabled()) {
3316     std::ostringstream myCoutStream;
3317     correlationThreeBodyCond.print(myCoutStream);
3318     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3319   }
3320 
3321   // insert condition into the map
3322   // condition is not duplicate, check was done at the beginning
3323 
3324   (m_vecCorrelationThreeBodyTemplate[chipNr]).push_back(correlationThreeBodyCond);
3325 
3326   //
3327   return true;
3328 }
3329 
3330 ////////////////////////////////////////////////////////////////////////////////////
3331 /**
3332  * parseCorrelationWithOverlapRemoval Parse a correlation condition and
3333  * insert an entry to the conditions map
3334  *
3335  * @param node The corresponding node.
3336  * @param name The name of the condition.
3337  * @param chipNr The number of the chip this condition is located.
3338  *
3339  * @return "true" if succeeded, "false" if an error occurred.
3340  *
3341  */
3342 
3343 bool l1t::TriggerMenuParser::parseCorrelationWithOverlapRemoval(const L1TUtmCondition& corrCond, unsigned int chipNr) {
3344   using namespace tmeventsetup;
3345   std::string condition = "corrWithOverlapRemoval";
3346   std::string particle = "test-fix";
3347   std::string type = l1t2string(corrCond.getType());
3348   std::string name = l1t2string(corrCond.getName());
3349 
3350   LogDebug("TriggerMenuParser") << " ****************************************** " << std::endl
3351                                 << "     (in parseCorrelationWithOverlapRemoval) " << std::endl
3352                                 << " condition = " << condition << std::endl
3353                                 << " particle  = " << particle << std::endl
3354                                 << " type      = " << type << std::endl
3355                                 << " name      = " << name << std::endl;
3356 
3357   // create a new correlation condition
3358   CorrelationWithOverlapRemovalTemplate correlationWORCond(name);
3359 
3360   // check that the condition does not exist already in the map
3361   if (!insertConditionIntoMap(correlationWORCond, chipNr)) {
3362     edm::LogError("TriggerMenuParser") << "    Error: duplicate correlation condition (" << name << ")" << std::endl;
3363 
3364     return false;
3365   }
3366 
3367   // Define some of the quantities to store the parased information
3368 
3369   // condition type BLW  (Do we change this to the type of correlation condition?)
3370   GtConditionType cType = l1t::Type2corWithOverlapRemoval;
3371 
3372   // three objects (for sure)
3373   const int nrObj = 3;
3374 
3375   // object types and greater equal flag - filled in the loop
3376   int intGEq[nrObj] = {-1, -1, -1};
3377   std::vector<GlobalObject> objType(nrObj);           //BLW do we want to define these as a different type?
3378   std::vector<GtConditionCategory> condCateg(nrObj);  //BLW do we want to change these categories
3379 
3380   // correlation flag and index in the cor*vector
3381   const bool corrFlag = true;
3382   int corrIndexVal[nrObj] = {-1, -1, -1};
3383 
3384   // Storage of the correlation selection
3385   CorrelationWithOverlapRemovalTemplate::CorrelationWithOverlapRemovalParameter corrParameter;
3386   corrParameter.chargeCorrelation = 1;  //ignore charge correlation for corr-legs
3387 
3388   // Get the correlation Cuts on the legs
3389   int cutType = 0;
3390   const std::vector<L1TUtmCut>& cuts = corrCond.getCuts();
3391   for (size_t jj = 0; jj < cuts.size(); jj++) {
3392     const L1TUtmCut& cut = cuts.at(jj);
3393 
3394     if (cut.getCutType() == esCutType::ChargeCorrelation) {
3395       if (cut.getData() == "ls")
3396         corrParameter.chargeCorrelation = 2;
3397       else if (cut.getData() == "os")
3398         corrParameter.chargeCorrelation = 4;
3399       else
3400         corrParameter.chargeCorrelation = 1;  //ignore charge correlation
3401     } else {
3402       //
3403       //  Unitl utm has method to calculate these, do the integer value calculation with precision.
3404       //
3405       double minV = cut.getMinimum().value;
3406       double maxV = cut.getMaximum().value;
3407 
3408       //Scale down very large numbers out of xml
3409       if (maxV > 1.0e8)
3410         maxV = 1.0e8;
3411 
3412       if (cut.getCutType() == esCutType::DeltaEta) {
3413         //std::cout << "DeltaEta Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3414         corrParameter.minEtaCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3415         corrParameter.maxEtaCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3416         corrParameter.precEtaCut = cut.getMinimum().index;
3417         cutType = cutType | 0x1;
3418       } else if (cut.getCutType() == esCutType::DeltaPhi) {
3419         //std::cout << "DeltaPhi Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3420         corrParameter.minPhiCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3421         corrParameter.maxPhiCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3422         corrParameter.precPhiCut = cut.getMinimum().index;
3423         cutType = cutType | 0x2;
3424       } else if (cut.getCutType() == esCutType::DeltaR) {
3425         //std::cout << "DeltaR Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3426         corrParameter.minDRCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3427         corrParameter.maxDRCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3428         corrParameter.precDRCut = cut.getMinimum().index;
3429         cutType = cutType | 0x4;
3430       } else if (cut.getCutType() == esCutType::Mass) {
3431         //std::cout << "Mass Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3432         corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3433         corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3434         corrParameter.precMassCut = cut.getMinimum().index;
3435         cutType = cutType | 0x8;
3436       } else if (cut.getCutType() == esCutType::MassDeltaR) {
3437         corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3438         corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3439         corrParameter.precMassCut = cut.getMinimum().index;
3440         cutType = cutType | 0x80;
3441       }
3442       if (cut.getCutType() == esCutType::OvRmDeltaEta) {
3443         //std::cout << "OverlapRemovalDeltaEta Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3444         corrParameter.minOverlapRemovalEtaCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3445         corrParameter.maxOverlapRemovalEtaCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3446         corrParameter.precOverlapRemovalEtaCut = cut.getMinimum().index;
3447         cutType = cutType | 0x10;
3448       } else if (cut.getCutType() == esCutType::OvRmDeltaPhi) {
3449         //std::cout << "OverlapRemovalDeltaPhi Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3450         corrParameter.minOverlapRemovalPhiCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3451         corrParameter.maxOverlapRemovalPhiCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3452         corrParameter.precOverlapRemovalPhiCut = cut.getMinimum().index;
3453         cutType = cutType | 0x20;
3454       } else if (cut.getCutType() == esCutType::OvRmDeltaR) {
3455         //std::cout << "DeltaR Cut minV = " << minV << " Max = " << maxV << " precMin = " << cut.getMinimum().index << " precMax = " << cut.getMaximum().index << std::endl;
3456         corrParameter.minOverlapRemovalDRCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
3457         corrParameter.maxOverlapRemovalDRCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
3458         corrParameter.precOverlapRemovalDRCut = cut.getMinimum().index;
3459         cutType = cutType | 0x40;
3460       }
3461     }
3462   }
3463   corrParameter.corrCutType = cutType;
3464 
3465   // Get the two objects that form the legs
3466   const std::vector<L1TUtmObject>& objects = corrCond.getObjects();
3467   if (objects.size() != 3) {
3468     edm::LogError("TriggerMenuParser")
3469         << "incorrect number of objects for the correlation condition with overlap removal " << name << " corrFlag "
3470         << corrFlag << std::endl;
3471     return false;
3472   }
3473 
3474   // Loop over legs
3475   for (size_t jj = 0; jj < objects.size(); jj++) {
3476     const L1TUtmObject& object = objects.at(jj);
3477     LogDebug("TriggerMenuParser") << "      obj name = " << object.getName() << "\n";
3478     LogDebug("TriggerMenuParser") << "      obj type = " << object.getType() << "\n";
3479     LogDebug("TriggerMenuParser") << "      obj op = " << object.getComparisonOperator() << "\n";
3480     LogDebug("TriggerMenuParser") << "      obj bx = " << object.getBxOffset() << "\n";
3481     LogDebug("TriggerMenuParser") << "type = done" << std::endl;
3482 
3483     // check the leg type
3484     if (object.getType() == esObjectType::Muon) {
3485       // we have a muon
3486 
3487       /*
3488           //BLW Hold on to this code we may need to go back to it at some point.
3489       // Now we are putting ALL leg conditions into the vector (so there are duplicates)
3490       // This is potentially a place to slim down the code.  Note: We currently evaluate the
3491       // conditions every time, so even if we put the condition in the vector once, we would
3492       // still evaluate it multiple times.  This is a place for optimization.
3493           {
3494 
3495               parseMuonCorr(&object,chipNr);
3496           corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
3497 
3498           } else {
3499          LogDebug("TriggerMenuParser") << "Not Adding Correlation Muon Condition to Map...looking for the condition in Muon Cor Vector" << std::endl;
3500          bool found = false;
3501          int index = 0;
3502          while(!found && index<(int)((m_corMuonTemplate[chipNr]).size()) ) {
3503              if( (m_corMuonTemplate[chipNr]).at(index).condName() == object.getName() ) {
3504             LogDebug("TriggerMenuParser") << "Found condition " << object.getName() << " in vector at index " << index << std::endl;
3505             found = true;
3506          } else {
3507             index++;
3508          }
3509          }
3510          if(found) {
3511             corrIndexVal[jj] = index;
3512          } else {
3513            edm::LogError("TriggerMenuParser") << "FAILURE: Condition " << object.getName() << " is in map but not in cor. vector " << std::endl;
3514          }
3515 
3516       }
3517 */
3518       parseMuonCorr(&object, chipNr);
3519       corrIndexVal[jj] = (m_corMuonTemplate[chipNr]).size() - 1;
3520 
3521       //Now set some flags for this subCondition
3522       intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3523       objType[jj] = gtMu;
3524       condCateg[jj] = CondMuon;
3525 
3526     } else if (object.getType() == esObjectType::Egamma || object.getType() == esObjectType::Jet ||
3527                object.getType() == esObjectType::Tau) {
3528       // we have an Calo object
3529       parseCaloCorr(&object, chipNr);
3530       corrIndexVal[jj] = (m_corCaloTemplate[chipNr]).size() - 1;
3531 
3532       //Now set some flags for this subCondition
3533       intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3534       switch (object.getType()) {
3535         case esObjectType::Egamma: {
3536           objType[jj] = gtEG;
3537         } break;
3538         case esObjectType::Jet: {
3539           objType[jj] = gtJet;
3540         } break;
3541         case esObjectType::Tau: {
3542           objType[jj] = gtTau;
3543         } break;
3544         default: {
3545         } break;
3546       }
3547       condCateg[jj] = CondCalo;
3548 
3549     } else if (object.getType() == esObjectType::ETM || object.getType() == esObjectType::ETMHF ||
3550                object.getType() == esObjectType::TOWERCOUNT || object.getType() == esObjectType::HTM) {
3551       // we have Energy Sum
3552       parseEnergySumCorr(&object, chipNr);
3553       corrIndexVal[jj] = (m_corEnergySumTemplate[chipNr]).size() - 1;
3554 
3555       //Now set some flags for this subCondition
3556       intGEq[jj] = (object.getComparisonOperator() == esComparisonOperator::GE);
3557       switch (object.getType()) {
3558         case esObjectType::ETM: {
3559           objType[jj] = GlobalObject::gtETM;
3560         } break;
3561         case esObjectType::HTM: {
3562           objType[jj] = GlobalObject::gtHTM;
3563         } break;
3564         case esObjectType::ETMHF: {
3565           objType[jj] = GlobalObject::gtETMHF;
3566         } break;
3567         case esObjectType::TOWERCOUNT: {
3568           objType[jj] = GlobalObject::gtTowerCount;
3569         } break;
3570         default: {
3571         } break;
3572       }
3573       condCateg[jj] = CondEnergySum;
3574 
3575     } else {
3576       edm::LogError("TriggerMenuParser") << "Illegal Object Type " << object.getType()
3577                                          << " for the correlation condition " << name << std::endl;
3578       return false;
3579 
3580     }  //if block on leg types
3581 
3582   }  //loop over legs
3583 
3584   // get greater equal flag for the correlation condition
3585   bool gEq = true;
3586   if (intGEq[0] != intGEq[1]) {
3587     edm::LogError("TriggerMenuParser") << "Inconsistent GEq flags for sub-conditions "
3588                                        << " for the correlation condition " << name << std::endl;
3589     return false;
3590 
3591   } else {
3592     gEq = (intGEq[0] != 0);
3593   }
3594 
3595   // fill the correlation condition
3596   correlationWORCond.setCondType(cType);
3597   correlationWORCond.setObjectType(objType);
3598   correlationWORCond.setCondGEq(gEq);
3599   correlationWORCond.setCondChipNr(chipNr);
3600 
3601   correlationWORCond.setCond0Category(condCateg[0]);
3602   correlationWORCond.setCond1Category(condCateg[1]);
3603   correlationWORCond.setCond2Category(condCateg[2]);
3604 
3605   correlationWORCond.setCond0Index(corrIndexVal[0]);
3606   correlationWORCond.setCond1Index(corrIndexVal[1]);
3607   correlationWORCond.setCond2Index(corrIndexVal[2]);
3608 
3609   correlationWORCond.setCorrelationWithOverlapRemovalParameter(corrParameter);
3610 
3611   if (edm::isDebugEnabled()) {
3612     std::ostringstream myCoutStream;
3613     correlationWORCond.print(myCoutStream);
3614     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3615   }
3616 
3617   // insert condition into the map
3618   // condition is not duplicate, check was done at the beginning
3619 
3620   (m_vecCorrelationWithOverlapRemovalTemplate[chipNr]).push_back(correlationWORCond);
3621 
3622   //
3623   return true;
3624 }
3625 
3626 /**
3627  * workAlgorithm - parse the algorithm and insert it into algorithm map.
3628  *
3629  * @param node The corresponding node to the algorithm.
3630  * @param name The name of the algorithm.
3631  * @param chipNr The number of the chip the conditions for that algorithm are located on.
3632  *
3633  * @return "true" on success, "false" if an error occurred.
3634  *
3635  */
3636 
3637 bool l1t::TriggerMenuParser::parseAlgorithm(L1TUtmAlgorithm algorithm, unsigned int chipNr) {
3638   // get alias
3639   std::string algAlias = algorithm.getName();
3640   const std::string& algName = algorithm.getName();
3641 
3642   if (algAlias.empty()) {
3643     algAlias = algName;
3644     LogDebug("TriggerMenuParser") << "\n    No alias defined for algorithm. Alias set to algorithm name."
3645                                   << "\n    Algorithm name:  " << algName << "\n    Algorithm alias: " << algAlias
3646                                   << std::endl;
3647   } else {
3648     //LogDebug("TriggerMenuParser")
3649     LogDebug("TriggerMenuParser") << "\n    Alias defined for algorithm."
3650                                   << "\n    Algorithm name:  " << algName << "\n    Algorithm alias: " << algAlias
3651                                   << std::endl;
3652   }
3653 
3654   // get the logical expression
3655   const std::string& logExpression = algorithm.getExpressionInCondition();
3656 
3657   LogDebug("TriggerMenuParser") << "      Logical expression: " << logExpression
3658                                 << "      Chip number:        " << chipNr << std::endl;
3659 
3660   // determine output pin
3661   int outputPin = algorithm.getIndex();
3662 
3663   //LogTrace("TriggerMenuParser")
3664   LogDebug("TriggerMenuParser") << "      Output pin:         " << outputPin << std::endl;
3665 
3666   // compute the bit number from chip number, output pin and order of the chips
3667   // pin numbering start with 1, bit numbers with 0
3668   int bitNumber = outputPin;  // + (m_orderConditionChip[chipNr] -1)*m_pinsOnConditionChip -1;
3669 
3670   //LogTrace("TriggerMenuParser")
3671   LogDebug("TriggerMenuParser") << "      Bit number:         " << bitNumber << std::endl;
3672 
3673   // create a new algorithm and insert it into algorithm map
3674   GlobalAlgorithm alg(algName, logExpression, bitNumber);
3675   alg.setAlgoChipNumber(static_cast<int>(chipNr));
3676   alg.setAlgoAlias(algAlias);
3677 
3678   if (edm::isDebugEnabled()) {
3679     std::ostringstream myCoutStream;
3680     alg.print(myCoutStream);
3681     LogTrace("TriggerMenuParser") << myCoutStream.str() << "\n" << std::endl;
3682   }
3683 
3684   // insert algorithm into the map
3685   if (!insertAlgorithmIntoMap(alg)) {
3686     return false;
3687   }
3688 
3689   return true;
3690 }
3691 // static class members