Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-16 06:15:51

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