Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-28 23:48:45

0001 /**
0002  * \class L1GtTriggerMenuConfigOnlineProd
0003  *
0004  *
0005  * Description: online producer for L1GtTriggerMenu.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  * \author: Vasile Mihai Ghete - HEPHY Vienna
0011  *
0012  *
0013  */
0014 
0015 // this class header
0016 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtTriggerMenuConfigOnlineProd.h"
0017 
0018 // system include files
0019 #include <string>
0020 #include <vector>
0021 #include <map>
0022 #include <list>
0023 #include <utility>
0024 #include <algorithm>
0025 
0026 // user include files
0027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0028 
0029 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
0030 #include "CondFormats/L1TObjects/interface/L1GtFwd.h"
0031 
0032 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
0033 
0034 #include "CondFormats/L1TObjects/interface/L1GtCondition.h"
0035 #include "CondFormats/L1TObjects/interface/L1GtAlgorithm.h"
0036 
0037 // constructor
0038 L1GtTriggerMenuConfigOnlineProd::L1GtTriggerMenuConfigOnlineProd(const edm::ParameterSet& parSet)
0039     : L1ConfigOnlineProdBase<L1GtTriggerMenuRcd, L1GtTriggerMenu>(parSet), m_isDebugEnabled(edm::isDebugEnabled()) {
0040   // empty
0041 }
0042 
0043 // destructor
0044 L1GtTriggerMenuConfigOnlineProd::~L1GtTriggerMenuConfigOnlineProd() {
0045   // empty
0046 }
0047 
0048 // public methods
0049 
0050 // initialize the class (mainly reserve/resize)
0051 void L1GtTriggerMenuConfigOnlineProd::init(const int numberConditionChips) {
0052   // resize the vectors of condition maps
0053   // the number of condition chips should be correctly set
0054 
0055   m_vecMuonTemplate.resize(numberConditionChips);
0056   m_vecCaloTemplate.resize(numberConditionChips);
0057   m_vecEnergySumTemplate.resize(numberConditionChips);
0058   m_vecJetCountsTemplate.resize(numberConditionChips);
0059   m_vecCastorTemplate.resize(numberConditionChips);
0060   m_vecHfBitCountsTemplate.resize(numberConditionChips);
0061   m_vecHfRingEtSumsTemplate.resize(numberConditionChips);
0062   m_vecBptxTemplate.resize(numberConditionChips);
0063   m_vecExternalTemplate.resize(numberConditionChips);
0064 
0065   m_vecCorrelationTemplate.resize(numberConditionChips);
0066   m_corMuonTemplate.resize(numberConditionChips);
0067   m_corCaloTemplate.resize(numberConditionChips);
0068   m_corEnergySumTemplate.resize(numberConditionChips);
0069 }
0070 
0071 std::unique_ptr<L1GtTriggerMenu> L1GtTriggerMenuConfigOnlineProd::newObject(const std::string& objectKey) {
0072   // FIXME seems to not work anymore in constructor...
0073   m_isDebugEnabled = edm::isDebugEnabled();
0074 
0075   auto pL1GtTriggerMenuEmpty = std::make_unique<L1GtTriggerMenu>();
0076 
0077   // FIXME get it from L1GtStableParameters?
0078   //       initialize once, from outside
0079   const unsigned int numberConditionChips = 2;
0080   init(numberConditionChips);
0081 
0082   const std::string gtSchema = "CMS_GT";
0083 
0084   // l1GtTriggerMenu: parameters in table GTFE_SETUP_FK
0085   // the objectKey for the menu obtained from GT_SETUP is the L1T_MENU_IMPL key
0086 
0087   // SQL queries:
0088 
0089   // retrieve table with general menu parameters from DB, view L1T_MENU_GENERAL_VIEW
0090   if (!tableMenuGeneralFromDB(gtSchema, objectKey)) {
0091     return pL1GtTriggerMenuEmpty;
0092   }
0093 
0094   // build the menu name
0095   std::string menuName =
0096       m_tableMenuGeneral.menuInterface + "/" + m_tableMenuGeneral.scalesKey + "/" + m_tableMenuGeneral.algoImplTag;
0097 
0098   // retrieve table with physics algorithms from DB, view L1T_MENU_ALGO_VIEW
0099   if (!tableMenuAlgoFromDB(gtSchema, objectKey)) {
0100     return pL1GtTriggerMenuEmpty;
0101   }
0102 
0103   // retrieve table with conditions associated to physics algorithms from DB
0104   if (!tableMenuAlgoCondFromDB(gtSchema, objectKey)) {
0105     return pL1GtTriggerMenuEmpty;
0106   }
0107 
0108   // retrieve table with list of conditions in the menu
0109   if (!tableMenuCondFromDB(gtSchema, objectKey)) {
0110     return pL1GtTriggerMenuEmpty;
0111   }
0112 
0113   // retrieve table with object parameters from DB, view CMS_GT.L1T_MENU_OP_VIEW
0114   if (!tableMenuObjectParametersFromDB(gtSchema, objectKey)) {
0115     return pL1GtTriggerMenuEmpty;
0116   }
0117 
0118   // retrieve table with technical triggers from DB, view L1T_MENU_TECHTRIG_VIEW
0119   if (!tableMenuTechTrigFromDB(gtSchema, objectKey)) {
0120     return pL1GtTriggerMenuEmpty;
0121   }
0122 
0123   // build the algorithm map in the menu
0124   buildAlgorithmMap();
0125 
0126   // build the technical trigger map in the menu
0127   buildTechnicalTriggerMap();
0128 
0129   // add the conditions from a menu to the corresponding list
0130   addConditions();
0131 
0132   // fill the record
0133   auto pL1GtTriggerMenu = std::make_unique<L1GtTriggerMenu>(menuName,
0134                                                             numberConditionChips,
0135                                                             m_vecMuonTemplate,
0136                                                             m_vecCaloTemplate,
0137                                                             m_vecEnergySumTemplate,
0138                                                             m_vecJetCountsTemplate,
0139                                                             m_vecCastorTemplate,
0140                                                             m_vecHfBitCountsTemplate,
0141                                                             m_vecHfRingEtSumsTemplate,
0142                                                             m_vecBptxTemplate,
0143                                                             m_vecExternalTemplate,
0144                                                             m_vecCorrelationTemplate,
0145                                                             m_corMuonTemplate,
0146                                                             m_corCaloTemplate,
0147                                                             m_corEnergySumTemplate);
0148 
0149   pL1GtTriggerMenu->setGtTriggerMenuInterface(m_tableMenuGeneral.menuInterface);
0150   pL1GtTriggerMenu->setGtTriggerMenuImplementation(m_tableMenuGeneral.menuImplementation);
0151   pL1GtTriggerMenu->setGtScaleDbKey(m_tableMenuGeneral.scalesKey);
0152 
0153   pL1GtTriggerMenu->setGtAlgorithmMap(m_algorithmMap);
0154   pL1GtTriggerMenu->setGtAlgorithmAliasMap(m_algorithmAliasMap);
0155   pL1GtTriggerMenu->setGtTechnicalTriggerMap(m_technicalTriggerMap);
0156 
0157   if (m_isDebugEnabled) {
0158     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\nThe following L1GtTriggerMenu record was read from OMDS: \n"
0159                                                 << std::endl;
0160 
0161     std::ostringstream myCoutStream;
0162     int verbosity = 0;
0163     pL1GtTriggerMenu->print(myCoutStream, verbosity);
0164     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n" << std::endl;
0165 
0166     verbosity = 2;
0167     pL1GtTriggerMenu->print(myCoutStream, verbosity);
0168     LogTrace("L1GtTriggerMenuConfigOnlineProd") << myCoutStream.str() << "\n" << std::endl;
0169   }
0170 
0171   return pL1GtTriggerMenu;
0172 }
0173 
0174 // retrieve table with general menu parameters from DB
0175 bool L1GtTriggerMenuConfigOnlineProd::tableMenuGeneralFromDB(const std::string& gtSchema,
0176                                                              const std::string& objectKey) {
0177   // select * from CMS_GT.L1T_MENU_GENERAL_VIEW
0178   //     where L1T_MENU_GENERAL_VIEW.MENU_IMPLEMENTATION = objectKey
0179 
0180   const std::vector<std::string>& columns = m_omdsReader.columnNamesView(gtSchema, "L1T_MENU_GENERAL_VIEW");
0181 
0182   if (m_isDebugEnabled) {
0183     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n List of columns in L1T_MENU_GENERAL_VIEW:\n" << std::endl;
0184     for (std::vector<std::string>::const_iterator iter = columns.begin(); iter != columns.end(); iter++) {
0185       LogTrace("L1GtTriggerMenuConfigOnlineProd") << (*iter) << std::endl;
0186     }
0187     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
0188   }
0189 
0190   l1t::OMDSReader::QueryResults results = m_omdsReader.basicQueryView(columns,
0191                                                                       gtSchema,
0192                                                                       "L1T_MENU_GENERAL_VIEW",
0193                                                                       "L1T_MENU_GENERAL_VIEW.MENU_IMPLEMENTATION",
0194                                                                       m_omdsReader.singleAttribute(objectKey));
0195 
0196   // check if query was successful
0197   if (results.queryFailed()) {
0198     edm::LogError("L1-O2O")
0199         << "Problem to get content of L1T_MENU_GENERAL_VIEW for L1GtTriggerMenu implementation key: " << objectKey;
0200     return false;
0201   }
0202 
0203   // retrieve menu interface name, scales key, algorithm implementation tag
0204 
0205   for (std::vector<std::string>::const_iterator constIt = columns.begin(); constIt != columns.end(); ++constIt) {
0206     if ((*constIt) == "MENU_IMPLEMENTATION") {
0207       results.fillVariable(*constIt, m_tableMenuGeneral.menuImplementation);
0208 
0209     } else if ((*constIt) == "INTERFACE") {
0210       results.fillVariable(*constIt, m_tableMenuGeneral.menuInterface);
0211 
0212     } else if ((*constIt) == "SCALES_KEY") {
0213       results.fillVariable(*constIt, m_tableMenuGeneral.scalesKey);
0214 
0215     } else if ((*constIt) == "ALGO_IMPL_TAG") {
0216       results.fillVariable(*constIt, m_tableMenuGeneral.algoImplTag);
0217 
0218     } else {
0219       // do nothing
0220     }
0221   }
0222 
0223   // cross checks
0224   if (m_tableMenuGeneral.menuImplementation != objectKey) {
0225     LogTrace("L1GtTriggerMenuConfigOnlineProd")
0226         << "\n L1 trigger menu implementation read from querying view not identical"
0227         << "\n with menu key:"
0228         << "\n   from view: " << m_tableMenuGeneral.menuImplementation << "\n   from key:  " << objectKey
0229         << "\n Menu implementation name set from key." << std::endl;
0230     m_tableMenuGeneral.menuImplementation = objectKey;
0231   }
0232 
0233   //
0234   return true;
0235 }
0236 
0237 // retrieve table with physics algorithms from DB
0238 bool L1GtTriggerMenuConfigOnlineProd::tableMenuAlgoFromDB(const std::string& gtSchema, const std::string& objectKey) {
0239   // select * from CMS_GT.L1T_MENU_ALGO_VIEW
0240   //     where L1T_MENU_ALGO_VIEW.MENU_IMPLEMENTATION = objectKey
0241 
0242   const std::vector<std::string>& columnsMenuAlgo = m_omdsReader.columnNamesView(gtSchema, "L1T_MENU_ALGO_VIEW");
0243 
0244   if (m_isDebugEnabled) {
0245     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n List of columns in L1T_MENU_ALGO_VIEW:\n" << std::endl;
0246     for (std::vector<std::string>::const_iterator iter = columnsMenuAlgo.begin(); iter != columnsMenuAlgo.end();
0247          iter++) {
0248       LogTrace("L1GtTriggerMenuConfigOnlineProd") << (*iter) << std::endl;
0249     }
0250     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
0251   }
0252 
0253   l1t::OMDSReader::QueryResults resultsMenuAlgo = m_omdsReader.basicQueryView(columnsMenuAlgo,
0254                                                                               gtSchema,
0255                                                                               "L1T_MENU_ALGO_VIEW",
0256                                                                               "L1T_MENU_ALGO_VIEW.MENU_IMPLEMENTATION",
0257                                                                               m_omdsReader.singleAttribute(objectKey));
0258 
0259   // check if query was successful is based on size of returned list
0260   // BUT one can have menus w/o physics algorithms - no error for empty list, but a warning!
0261   if (resultsMenuAlgo.queryFailed()) {
0262     edm::LogWarning("L1-O2O") << "Warning: Content of L1T_MENU_ALGO_VIEW for L1GtTriggerMenu implementation key: "
0263                               << "\n  " << objectKey << "\nis empty!"
0264                               << "\nNo physics algorithms are found for this menu.";
0265   }
0266 
0267   TableMenuAlgo menuAlgo;
0268   int resultsMenuAlgoRows = resultsMenuAlgo.numberRows();
0269 
0270   for (int iRow = 0; iRow < resultsMenuAlgoRows; ++iRow) {
0271     for (std::vector<std::string>::const_iterator constIt = columnsMenuAlgo.begin(); constIt != columnsMenuAlgo.end();
0272          ++constIt) {
0273       if ((*constIt) == "ALGO_INDEX") {
0274         resultsMenuAlgo.fillVariableFromRow(*constIt, iRow, menuAlgo.bitNumberSh);
0275 
0276       } else if ((*constIt) == "NAME") {
0277         resultsMenuAlgo.fillVariableFromRow(*constIt, iRow, menuAlgo.algName);
0278 
0279       } else if ((*constIt) == "ALIAS") {
0280         resultsMenuAlgo.fillVariableFromRow(*constIt, iRow, menuAlgo.algAlias);
0281 
0282       } else if ((*constIt) == "LOGICEXPR") {
0283         resultsMenuAlgo.fillVariableFromRow(*constIt, iRow, menuAlgo.logExpression);
0284 
0285       } else {
0286         // do nothing
0287       }
0288     }
0289 
0290     LogTrace("L1GtTriggerMenuConfigOnlineProd")
0291         << "Row  " << iRow << ": index = " << menuAlgo.bitNumberSh << " algName = " << menuAlgo.algName
0292         << " algAlias = " << menuAlgo.algAlias << " logExpression = '" << menuAlgo.logExpression << "'" << std::endl;
0293 
0294     m_tableMenuAlgo.push_back(menuAlgo);
0295   }
0296 
0297   if (m_isDebugEnabled) {
0298     LogTrace("L1GtTriggerMenuConfigOnlineProd")
0299         << "\n Number of rows read from L1T_MENU_ALGO_VIEW: " << resultsMenuAlgoRows << std::endl;
0300   }
0301 
0302   return true;
0303 }
0304 
0305 // retrieve table with conditions associated to physics algorithms from DB
0306 bool L1GtTriggerMenuConfigOnlineProd::tableMenuAlgoCondFromDB(const std::string& gtSchema,
0307                                                               const std::string& objectKey) {
0308   // get list of conditions associated with the algorithms
0309 
0310   // select * from CMS_GT.L1T_MENU_ALGO_COND_VIEW
0311   //     where L1T_MENU_ALGO_COND_VIEW.MENU_IMPLEMENTATION = objectKey
0312 
0313   const std::vector<std::string>& columnsMenuAlgoCond =
0314       m_omdsReader.columnNamesView(gtSchema, "L1T_MENU_ALGO_COND_VIEW");
0315 
0316   if (m_isDebugEnabled) {
0317     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n List of columns in L1T_MENU_ALGO_COND_VIEW:\n" << std::endl;
0318     for (std::vector<std::string>::const_iterator iter = columnsMenuAlgoCond.begin(); iter != columnsMenuAlgoCond.end();
0319          iter++) {
0320       LogTrace("L1GtTriggerMenuConfigOnlineProd") << (*iter) << std::endl;
0321     }
0322     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
0323   }
0324 
0325   l1t::OMDSReader::QueryResults resultsMenuAlgoCond =
0326       m_omdsReader.basicQueryView(columnsMenuAlgoCond,
0327                                   gtSchema,
0328                                   "L1T_MENU_ALGO_COND_VIEW",
0329                                   "L1T_MENU_ALGO_COND_VIEW.MENU_IMPLEMENTATION",
0330                                   m_omdsReader.singleAttribute(objectKey));
0331 
0332   // check if query was successful is based on size of returned list
0333   // BUT one can have menus w/o algorithms and conditions - no error for empty list, but a warning!
0334   if (resultsMenuAlgoCond.queryFailed()) {
0335     edm::LogWarning("L1-O2O") << "Warning: Content of L1T_MENU_ALGO_COND_VIEW for L1GtTriggerMenu implementation key: "
0336                               << "\n  " << objectKey << "\nis empty!"
0337                               << "\nNo list of condition associated to each algorithm are found for this menu.";
0338   }
0339 
0340   //
0341   TableMenuAlgoCond menuAlgoCond;
0342   int resultsMenuAlgoCondRows = resultsMenuAlgoCond.numberRows();
0343 
0344   for (int iRow = 0; iRow < resultsMenuAlgoCondRows; ++iRow) {
0345     for (std::vector<std::string>::const_iterator constIt = columnsMenuAlgoCond.begin();
0346          constIt != columnsMenuAlgoCond.end();
0347          ++constIt) {
0348       if ((*constIt) == "ALGO_INDEX") {
0349         resultsMenuAlgoCond.fillVariableFromRow(*constIt, iRow, menuAlgoCond.bitNumberSh);
0350 
0351       } else if ((*constIt) == "COND_INDEX") {
0352         resultsMenuAlgoCond.fillVariableFromRow(*constIt, iRow, menuAlgoCond.condIndexF);
0353 
0354       } else if ((*constIt) == "COND_FK") {
0355         resultsMenuAlgoCond.fillVariableFromRow(*constIt, iRow, menuAlgoCond.condFK);
0356 
0357       } else {
0358         // do nothing
0359       }
0360     }
0361 
0362     LogTrace("L1GtTriggerMenuConfigOnlineProd")
0363         << "Row  " << iRow << ": ALGO_INDEX = " << menuAlgoCond.bitNumberSh
0364         << " COND_INDEX = " << menuAlgoCond.condIndexF << " COND_FK = " << menuAlgoCond.condFK << std::endl;
0365 
0366     m_tableMenuAlgoCond.push_back(menuAlgoCond);
0367   }
0368 
0369   if (m_isDebugEnabled) {
0370     LogTrace("L1GtTriggerMenuConfigOnlineProd")
0371         << "\n Number of rows read from L1T_MENU_ALGO_COND_VIEW: " << resultsMenuAlgoCondRows << std::endl;
0372   }
0373 
0374   return true;
0375 }
0376 
0377 // retrieve table with list of conditions in the menu
0378 bool L1GtTriggerMenuConfigOnlineProd::tableMenuCondFromDB(const std::string& gtSchema, const std::string& objectKey) {
0379   // select * from CMS_GT.L1T_MENU_COND_VIEW
0380   //     where L1T_MENU_COND_VIEW.MENU_IMPLEMENTATION = objectKey
0381 
0382   const std::vector<std::string>& columnsMenuCond = m_omdsReader.columnNamesView(gtSchema, "L1T_MENU_COND_VIEW");
0383 
0384   if (m_isDebugEnabled) {
0385     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n List of columns in L1T_MENU_COND_VIEW:\n" << std::endl;
0386     for (std::vector<std::string>::const_iterator iter = columnsMenuCond.begin(); iter != columnsMenuCond.end();
0387          iter++) {
0388       LogTrace("L1GtTriggerMenuConfigOnlineProd") << (*iter) << std::endl;
0389     }
0390     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
0391   }
0392 
0393   l1t::OMDSReader::QueryResults resultsMenuCond = m_omdsReader.basicQueryView(columnsMenuCond,
0394                                                                               gtSchema,
0395                                                                               "L1T_MENU_COND_VIEW",
0396                                                                               "L1T_MENU_COND_VIEW.MENU_IMPLEMENTATION",
0397                                                                               m_omdsReader.singleAttribute(objectKey));
0398 
0399   // check if query was successful is based on size of returned list
0400   // BUT one can have menus w/o conditions - no error for empty list, but a warning!
0401   if (resultsMenuCond.queryFailed()) {
0402     edm::LogWarning("L1-O2O") << "Warning: Content of L1T_MENU_COND_VIEW for L1GtTriggerMenu implementation key: "
0403                               << "\n  " << objectKey << "\nis empty!"
0404                               << "\nNo conditions associated to menu are found for this menu.";
0405   }
0406 
0407   //
0408   TableMenuCond menuCond;
0409   int resultsMenuCondRows = resultsMenuCond.numberRows();
0410 
0411   for (int iRow = 0; iRow < resultsMenuCondRows; ++iRow) {
0412     for (std::vector<std::string>::const_iterator constIt = columnsMenuCond.begin(); constIt != columnsMenuCond.end();
0413          ++constIt) {
0414       if ((*constIt) == "COND") {
0415         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.cond);
0416 
0417       } else if ((*constIt) == "COND_CATEGORY") {
0418         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.condCategory);
0419 
0420       } else if ((*constIt) == "COND_TYPE") {
0421         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.condType);
0422 
0423       } else if ((*constIt) == "GT_OBJECT_1") {
0424         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.gtObject1);
0425 
0426       } else if ((*constIt) == "GT_OBJECT_2") {
0427         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.gtObject2);
0428 
0429       } else if ((*constIt) == "COND_GEQ") {
0430         //float condGEqFloat = -1;
0431         //resultsMenuCond.fillVariableFromRow(*constIt, iRow, condGEqFloat);
0432         //menuCond.condGEq = (condGEqFloat > 0.5) ? true : false;
0433         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.condGEq);
0434 
0435       } else if ((*constIt) == "COUNT_INDEX") {
0436         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.countIndex);
0437 
0438       } else if ((*constIt) == "COUNT_THRESHOLD") {
0439         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.countThreshold);
0440 
0441       } else if ((*constIt) == "CHARGE_CORRELATION") {
0442         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.chargeCorrelation);
0443 
0444       } else if ((*constIt) == "OBJECT_PARAMETER_1_FK") {
0445         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.objectParameter1FK);
0446 
0447       } else if ((*constIt) == "OBJECT_PARAMETER_2_FK") {
0448         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.objectParameter2FK);
0449 
0450       } else if ((*constIt) == "OBJECT_PARAMETER_3_FK") {
0451         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.objectParameter3FK);
0452 
0453       } else if ((*constIt) == "OBJECT_PARAMETER_4_FK") {
0454         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.objectParameter4FK);
0455 
0456       } else if ((*constIt) == "DELTA_ETA_RANGE") {
0457         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.deltaEtaRange);
0458 
0459       } else if ((*constIt) == "DELTA_PHI_RANGE") {
0460         resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.deltaPhiRange);
0461 
0462       } else {
0463         // do nothing
0464       }
0465     }
0466 
0467     LogTrace("L1GtTriggerMenuConfigOnlineProd")
0468         << " COND " << menuCond.cond << " COND_CATEGORY " << menuCond.condCategory << " COND_TYPE " << menuCond.condType
0469         << " GT_OBJECT_1 " << menuCond.gtObject1 << " GT_OBJECT_2 " << menuCond.gtObject2 << " COND_GEQ "
0470         << menuCond.condGEq << "\n"
0471         << " COUNT_INDEX " << menuCond.countIndex << " COUNT_THRESHOLD " << menuCond.countThreshold << "\n"
0472         << " CHARGE_CORRELATION " << menuCond.chargeCorrelation << "\n"
0473         << " OBJECT_PARAMETER_1_FK " << menuCond.objectParameter1FK << " OBJECT_PARAMETER_2_FK "
0474         << menuCond.objectParameter2FK << " OBJECT_PARAMETER_3_FK " << menuCond.objectParameter3FK
0475         << " OBJECT_PARAMETER_4_FK " << menuCond.objectParameter4FK << "\n"
0476         << " DELTA_ETA_RANGE " << menuCond.deltaEtaRange << " DELTA_PHI_RANGE " << menuCond.deltaPhiRange;
0477 
0478     m_tableMenuCond.push_back(menuCond);
0479   }
0480 
0481   if (m_isDebugEnabled) {
0482     LogTrace("L1GtTriggerMenuConfigOnlineProd")
0483         << "\n Number of rows read from L1T_MENU_COND_VIEW: " << resultsMenuCondRows << std::endl;
0484   }
0485 
0486   return true;
0487 }
0488 
0489 // retrieve table with object parameters from DB
0490 bool L1GtTriggerMenuConfigOnlineProd::tableMenuObjectParametersFromDB(const std::string& gtSchema,
0491                                                                       const std::string& objectKey) {
0492   // get the list of object parameters in the menu
0493 
0494   // select * from CMS_GT.L1T_MENU_OP_VIEW
0495   //     where L1T_MENU_OP_VIEW.MENU_IMPLEMENTATION = objectKey
0496 
0497   const std::vector<std::string>& columnsMenuOp = m_omdsReader.columnNamesView(gtSchema, "L1T_MENU_OP_VIEW");
0498 
0499   if (m_isDebugEnabled) {
0500     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n List of columns in L1T_MENU_OP_VIEW:\n" << std::endl;
0501     for (std::vector<std::string>::const_iterator iter = columnsMenuOp.begin(); iter != columnsMenuOp.end(); iter++) {
0502       LogTrace("L1GtTriggerMenuConfigOnlineProd") << (*iter) << std::endl;
0503     }
0504     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
0505   }
0506 
0507   l1t::OMDSReader::QueryResults resultsMenuOp = m_omdsReader.basicQueryView(columnsMenuOp,
0508                                                                             gtSchema,
0509                                                                             "L1T_MENU_OP_VIEW",
0510                                                                             "L1T_MENU_OP_VIEW.MENU_IMPLEMENTATION",
0511                                                                             m_omdsReader.singleAttribute(objectKey));
0512 
0513   // check if query was successful is based on size of returned list
0514   // BUT one can have menus w/o object parameters - no error for empty list, but a warning!
0515   if (resultsMenuOp.queryFailed()) {
0516     edm::LogWarning("L1-O2O") << "Warning: Content of L1T_MENU_OP_VIEW for L1GtTriggerMenu implementation key: "
0517                               << "\n  " << objectKey << "\nis empty!"
0518                               << "\nNo object parameters associated to menu are found for this menu.";
0519   }
0520 
0521   TableMenuObjectParameters menuObjectParameters;
0522   int resultsMenuOpRows = resultsMenuOp.numberRows();
0523 
0524   for (int iRow = 0; iRow < resultsMenuOpRows; ++iRow) {
0525     for (std::vector<std::string>::const_iterator constIt = columnsMenuOp.begin(); constIt != columnsMenuOp.end();
0526          ++constIt) {
0527       if ((*constIt) == "ID") {
0528         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.opId);
0529 
0530       } else if ((*constIt) == "PT_HIGH_THRESHOLD") {
0531         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.ptHighThreshold);
0532 
0533       } else if ((*constIt) == "PT_LOW_THRESHOLD") {
0534         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.ptLowThreshold);
0535 
0536       } else if ((*constIt) == "ENABLE_MIP") {
0537         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.enableMip);
0538 
0539       } else if ((*constIt) == "ENABLE_ISO") {
0540         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.enableIso);
0541 
0542       } else if ((*constIt) == "REQUEST_ISO") {
0543         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.requestIso);
0544 
0545       } else if ((*constIt) == "ENERGY_OVERFLOW") {
0546         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.energyOverflow);
0547 
0548       } else if ((*constIt) == "ET_THRESHOLD") {
0549         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.etThreshold);
0550 
0551       } else if ((*constIt) == "ETA_RANGE") {
0552         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.etaRange);
0553 
0554       } else if ((*constIt) == "PHI_RANGE") {
0555         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.phiRange);
0556 
0557       } else if ((*constIt) == "PHI_LOW") {
0558         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.phiLow);
0559 
0560       } else if ((*constIt) == "PHI_HIGH") {
0561         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.phiHigh);
0562 
0563       } else if ((*constIt) == "QUALITY_RANGE") {
0564         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.qualityRange);
0565 
0566       } else if ((*constIt) == "CHARGE") {
0567         resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.charge);
0568 
0569       } else {
0570         // do nothing
0571       }
0572     }
0573 
0574     LogTrace("L1GtTriggerMenuConfigOnlineProd")
0575         << " ID " << menuObjectParameters.opId << " PT_HIGH_THRESHOLD " << menuObjectParameters.ptHighThreshold
0576         << " PT_LOW_THRESHOLD " << menuObjectParameters.ptLowThreshold << " ENABLE_MIP "
0577         << menuObjectParameters.enableMip << " ENABLE_ISO " << menuObjectParameters.enableIso << " REQUEST_ISO "
0578         << menuObjectParameters.requestIso << " ENERGY_OVERFLOW " << menuObjectParameters.energyOverflow
0579         << " ET_THRESHOLD " << menuObjectParameters.etThreshold << " ETA_RANGE " << menuObjectParameters.etaRange
0580         << " PHI_RANGE " << menuObjectParameters.phiRange << " PHI_LOW " << menuObjectParameters.phiLow << " PHI_HIGH "
0581         << menuObjectParameters.phiHigh << " QUALITY_RANGE " << menuObjectParameters.qualityRange << " CHARGE "
0582         << menuObjectParameters.charge << std::endl;
0583 
0584     m_tableMenuObjectParameters.push_back(menuObjectParameters);
0585   }
0586 
0587   if (m_isDebugEnabled) {
0588     LogTrace("L1GtTriggerMenuConfigOnlineProd")
0589         << "\n Number of rows read from L1T_MENU_OP_VIEW: " << resultsMenuOpRows << std::endl;
0590   }
0591 
0592   return true;
0593 }
0594 
0595 // retrieve table with technical triggers from DB
0596 bool L1GtTriggerMenuConfigOnlineProd::tableMenuTechTrigFromDB(const std::string& gtSchema,
0597                                                               const std::string& objectKey) {
0598   // select * from CMS_GT.L1T_MENU_TECHTRIG_VIEW
0599   //     where L1T_MENU_TECHTRIG_VIEW.MENU_IMPLEMENTATION = objectKey
0600 
0601   const std::vector<std::string>& columnsMenuTechTrig =
0602       m_omdsReader.columnNamesView(gtSchema, "L1T_MENU_TECHTRIG_VIEW");
0603 
0604   if (m_isDebugEnabled) {
0605     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n List of columns in L1T_MENU_TECHTRIG_VIEW:\n" << std::endl;
0606     for (std::vector<std::string>::const_iterator iter = columnsMenuTechTrig.begin(); iter != columnsMenuTechTrig.end();
0607          iter++) {
0608       LogTrace("L1GtTriggerMenuConfigOnlineProd") << (*iter) << std::endl;
0609     }
0610     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
0611   }
0612 
0613   l1t::OMDSReader::QueryResults resultsMenuTechTrig =
0614       m_omdsReader.basicQueryView(columnsMenuTechTrig,
0615                                   gtSchema,
0616                                   "L1T_MENU_TECHTRIG_VIEW",
0617                                   "L1T_MENU_TECHTRIG_VIEW.MENU_IMPLEMENTATION",
0618                                   m_omdsReader.singleAttribute(objectKey));
0619 
0620   // check if query was successful is based on size of returned list
0621   // BUT one can have menus w/o technical triggers - no error for empty list, but a warning!
0622   if (resultsMenuTechTrig.queryFailed()) {
0623     edm::LogWarning("L1-O2O") << "Warning: Content of L1T_MENU_TECHTRIG_VIEW for L1GtTriggerMenu implementation key: "
0624                               << "\n  " << objectKey << "\nis empty!"
0625                               << "\nNo technical triggers are found for this menu.";
0626   }
0627 
0628   TableMenuTechTrig menuTechTrig;
0629   int resultsMenuTechTrigRows = resultsMenuTechTrig.numberRows();
0630 
0631   for (int iRow = 0; iRow < resultsMenuTechTrigRows; ++iRow) {
0632     for (std::vector<std::string>::const_iterator constIt = columnsMenuTechTrig.begin();
0633          constIt != columnsMenuTechTrig.end();
0634          ++constIt) {
0635       if ((*constIt) == "TECHTRIG_INDEX") {
0636         resultsMenuTechTrig.fillVariableFromRow(*constIt, iRow, menuTechTrig.bitNumberSh);
0637 
0638       } else if ((*constIt) == "NAME") {
0639         resultsMenuTechTrig.fillVariableFromRow(*constIt, iRow, menuTechTrig.techName);
0640 
0641       } else {
0642         // do nothing
0643       }
0644     }
0645 
0646     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "Row  " << iRow << ": index = " << menuTechTrig.bitNumberSh
0647                                                 << " techName = " << menuTechTrig.techName << std::endl;
0648 
0649     m_tableMenuTechTrig.push_back(menuTechTrig);
0650   }
0651 
0652   if (m_isDebugEnabled) {
0653     LogTrace("L1GtTriggerMenuConfigOnlineProd")
0654         << "\n Number of rows read from L1T_MENU_TECHTRIG_VIEW: " << resultsMenuTechTrigRows << std::endl;
0655   }
0656 
0657   return true;
0658 }
0659 
0660 // return for an algorithm with bitNr the mapping between the integer index in logical expression
0661 // and the condition name (FK)
0662 const std::map<int, std::string> L1GtTriggerMenuConfigOnlineProd::condIndexNameMap(const short bitNr) const {
0663   std::map<int, std::string> mapIndexName;
0664 
0665   for (std::vector<TableMenuAlgoCond>::const_iterator constIt = m_tableMenuAlgoCond.begin();
0666        constIt != m_tableMenuAlgoCond.end();
0667        ++constIt) {
0668     if (bitNr == (*constIt).bitNumberSh) {
0669       mapIndexName[static_cast<int>((*constIt).condIndexF)] = (*constIt).condFK;
0670     }
0671   }
0672 
0673   if (m_isDebugEnabled) {
0674     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Bit number : " << bitNr << std::endl;
0675 
0676     for (std::map<int, std::string>::const_iterator constIt = mapIndexName.begin(); constIt != mapIndexName.end();
0677          ++constIt) {
0678       LogTrace("L1GtTriggerMenuConfigOnlineProd")
0679           << "  Condition index -> name: " << ((*constIt).first) << " " << ((*constIt).second) << std::endl;
0680     }
0681   }
0682 
0683   return mapIndexName;
0684 }
0685 
0686 // convert a logical expression with indices to a logical expression with names
0687 std::string L1GtTriggerMenuConfigOnlineProd::convertLogicalExpression(
0688     const std::string& expressionIndices, const std::map<int, std::string>& mapCondIndexName) const {
0689   std::string expressionNames;
0690 
0691   L1GtLogicParser parserIndices = L1GtLogicParser(expressionIndices);
0692   parserIndices.convertIntToNameLogicalExpression(mapCondIndexName);
0693   expressionNames = parserIndices.logicalExpression();
0694 
0695   return expressionNames;
0696 }
0697 
0698 // return the chip number for an algorithm with index bitNumberSh
0699 int L1GtTriggerMenuConfigOnlineProd::chipNumber(short bitNumberSh) const {
0700   // FIXME get it from Event Setup
0701   const unsigned numberConditionChips = 2;
0702   const unsigned pinsOnConditionChip = 96;
0703   std::vector<int> orderConditionChip;
0704   orderConditionChip.push_back(2);
0705   orderConditionChip.push_back(1);
0706 
0707   int posChip = (static_cast<unsigned>(bitNumberSh) / pinsOnConditionChip) + 1;
0708   for (unsigned int iChip = 0; iChip < numberConditionChips; ++iChip) {
0709     if (posChip == orderConditionChip[iChip]) {
0710       return static_cast<int>(iChip);
0711     }
0712   }
0713 
0714   // chip number not found
0715   return -1;
0716 }
0717 
0718 // build the algorithm map in the menu
0719 void L1GtTriggerMenuConfigOnlineProd::buildAlgorithmMap() {
0720   // temporary value
0721   int bitNumber = -1;
0722   std::string logicalExpression;
0723 
0724   // loop over m_tableMenuAlgo
0725   for (std::vector<TableMenuAlgo>::const_iterator constIt = m_tableMenuAlgo.begin(); constIt != m_tableMenuAlgo.end();
0726        constIt++) {
0727     bitNumber = static_cast<int>((*constIt).bitNumberSh);
0728 
0729     const std::map<int, std::string>& condIndexName = condIndexNameMap((*constIt).bitNumberSh);
0730     logicalExpression = convertLogicalExpression((*constIt).logExpression, condIndexName);
0731 
0732     // create a new algorithm and insert it into algorithm map
0733     L1GtAlgorithm alg((*constIt).algName, logicalExpression, bitNumber);
0734     alg.setAlgoAlias((*constIt).algAlias);
0735 
0736     // set algorithm chip number:
0737     int algChipNr = chipNumber((*constIt).bitNumberSh);
0738     alg.setAlgoChipNumber(algChipNr);
0739 
0740     // insert algorithm
0741     m_algorithmMap[(*constIt).algName] = alg;
0742     m_algorithmAliasMap[(*constIt).algAlias] = alg;
0743   }
0744 }
0745 
0746 // build the technical trigger map in the menu
0747 void L1GtTriggerMenuConfigOnlineProd::buildTechnicalTriggerMap() {
0748   // temporary value
0749   int bitNumber = -1;
0750   std::string logicalExpression;
0751 
0752   // loop over m_tableMenuTechTrig
0753   for (std::vector<TableMenuTechTrig>::const_iterator constIt = m_tableMenuTechTrig.begin();
0754        constIt != m_tableMenuTechTrig.end();
0755        constIt++) {
0756     bitNumber = static_cast<int>((*constIt).bitNumberSh);
0757 
0758     // create a new technical trigger and insert it into technical trigger map
0759     // technical triggers have L1GtAlgorithm class
0760     L1GtAlgorithm techTrig((*constIt).techName, logicalExpression, bitNumber);
0761 
0762     // chip number set in constructor to -1 - no meaning for technical triggers
0763 
0764     // insert technical trigger
0765     m_technicalTriggerMap[(*constIt).techName] = techTrig;
0766 
0767     // no alias is defined for technical triggers
0768   }
0769 }
0770 
0771 L1GtConditionCategory L1GtTriggerMenuConfigOnlineProd::strToEnumCondCategory(const std::string& strCategory) {
0772   if (strCategory == "CondMuon") {
0773     return CondMuon;
0774   } else if (strCategory == "CondCalo") {
0775     return CondCalo;
0776   } else if (strCategory == "CondEnergySum") {
0777     return CondEnergySum;
0778   } else if (strCategory == "CondJetCounts") {
0779     return CondJetCounts;
0780   } else if (strCategory == "CondCorrelation") {
0781     return CondCorrelation;
0782   } else if (strCategory == "CondCastor") {
0783     return CondCastor;
0784   } else if (strCategory == "CondHfBitCounts") {
0785     return CondHfBitCounts;
0786   } else if (strCategory == "CondHfRingEtSums") {
0787     return CondHfRingEtSums;
0788   } else if (strCategory == "CondBptx") {
0789     return CondBptx;
0790   } else if (strCategory == "CondExternal") {
0791     return CondExternal;
0792   } else if (strCategory == "CondNull") {
0793     return CondNull;
0794   } else {
0795     edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
0796         << "\n Warning: string " << strCategory << " not defined. Returning CondNull.\n"
0797         << std::endl;
0798     return CondNull;
0799   }
0800 
0801   return CondNull;
0802 }
0803 
0804 // string to enum L1GtConditionType conversion
0805 L1GtConditionType L1GtTriggerMenuConfigOnlineProd::strToEnumCondType(const std::string& strType) {
0806   if (strType == "1s") {
0807     return Type1s;
0808   } else if (strType == "2s") {
0809     return Type2s;
0810   } else if (strType == "2wsc") {
0811     return Type2wsc;
0812   } else if (strType == "2cor") {
0813     return Type2cor;
0814   } else if (strType == "3s") {
0815     return Type3s;
0816   } else if (strType == "4s") {
0817     return Type4s;
0818   } else if (strType == "ETM") {
0819     return TypeETM;
0820   } else if (strType == "ETT") {
0821     return TypeETT;
0822   } else if (strType == "HTT") {
0823     return TypeHTT;
0824   } else if (strType == "HTM") {
0825     return TypeHTM;
0826   } else if (strType == "JetCounts") {
0827     return TypeJetCounts;
0828   } else if (strType == "Castor") {
0829     return TypeCastor;
0830   } else if (strType == "HfBitCounts") {
0831     return TypeHfBitCounts;
0832   } else if (strType == "HfRingEtSums") {
0833     return TypeHfRingEtSums;
0834   } else if (strType == "Bptx") {
0835     return TypeBptx;
0836   } else if (strType == "TypeExternal") {
0837     return TypeExternal;
0838   } else {
0839     edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
0840         << "\n Warning: string " << strType << " not associated to any L1GtConditionType. Returning TypeNull.\n"
0841         << std::endl;
0842     return TypeNull;
0843   }
0844 
0845   return TypeNull;
0846 }
0847 
0848 // string to enum L1GtObject conversion
0849 L1GtObject L1GtTriggerMenuConfigOnlineProd::strToEnumL1GtObject(const std::string& strObject) {
0850   if (strObject == "Mu") {
0851     return Mu;
0852   } else if (strObject == "NoIsoEG") {
0853     return NoIsoEG;
0854   } else if (strObject == "IsoEG") {
0855     return IsoEG;
0856   } else if (strObject == "CenJet") {
0857     return CenJet;
0858   } else if (strObject == "ForJet") {
0859     return ForJet;
0860   } else if (strObject == "TauJet") {
0861     return TauJet;
0862   } else if (strObject == "ETM") {
0863     return ETM;
0864   } else if (strObject == "ETT") {
0865     return ETT;
0866   } else if (strObject == "HTT") {
0867     return HTT;
0868   } else if (strObject == "HTM") {
0869     return HTM;
0870   } else if (strObject == "JetCounts") {
0871     return JetCounts;
0872   } else if (strObject == "HfBitCounts") {
0873     return HfBitCounts;
0874   } else if (strObject == "HfRingEtSums") {
0875     return HfRingEtSums;
0876   } else if (strObject == "TechTrig") {
0877     return TechTrig;
0878   } else if (strObject == "Castor") {
0879     return Castor;
0880   } else if (strObject == "BPTX") {
0881     return BPTX;
0882   } else if (strObject == "GtExternal") {
0883     return GtExternal;
0884   } else {
0885     edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
0886         << "\n Warning: string " << strObject << " not associated to any L1GtObject. Returning Mu (no Null type).\n"
0887         << std::endl;
0888     return Mu;
0889   }
0890 
0891   // no null type, so returning Mu - should never arrive here
0892   return Mu;
0893 }
0894 
0895 void L1GtTriggerMenuConfigOnlineProd::splitHexStringInTwo64bitWords(const std::string& hexStr,
0896                                                                     std::string& hex0WordStr,
0897                                                                     std::string& hex1WordStr) {
0898   unsigned int lenHexStr = hexStr.length();
0899 
0900   if (lenHexStr < 3) {
0901     LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Warning: string " << hexStr << " has length less than 3."
0902                                                 << "\n Not possible to split it in two 64-bit words."
0903                                                 << "\n Return two zero strings." << std::endl;
0904     hex0WordStr = "0x0";
0905     hex1WordStr = "0x0";
0906 
0907     return;
0908   }
0909 
0910   unsigned int lenHex = lenHexStr - 2;
0911   unsigned int len0Word = lenHex > 16 ? 16 : lenHex;
0912   unsigned int len1Word = lenHex - len0Word;
0913 
0914   unsigned int pos0Word = lenHexStr - len0Word;
0915   hex0WordStr = "0x" + hexStr.substr(pos0Word, len0Word);
0916 
0917   if (len1Word > 0) {
0918     unsigned int pos1Word = pos0Word - len1Word;
0919     hex1WordStr = "0x" + hexStr.substr(pos1Word, len1Word);
0920   } else {
0921     hex1WordStr = "0x0";
0922   }
0923 }
0924 
0925 // get a list of chip numbers from the m_tableMenuAlgoCond table for a condition
0926 std::list<int> L1GtTriggerMenuConfigOnlineProd::listChipNumber(const std::string& condFK) {
0927   std::list<int> chipList;
0928 
0929   // loop over m_tableMenuAlgoCond
0930   for (std::vector<TableMenuAlgoCond>::const_iterator constIt = m_tableMenuAlgoCond.begin();
0931        constIt != m_tableMenuAlgoCond.end();
0932        constIt++) {
0933     if (condFK == (*constIt).condFK) {
0934       int chipNr = chipNumber((*constIt).bitNumberSh);
0935       chipList.push_back(chipNr);
0936     }
0937   }
0938 
0939   return chipList;
0940 }
0941 
0942 void L1GtTriggerMenuConfigOnlineProd::fillMuonObjectParameter(const std::string& opFK,
0943                                                               L1GtMuonTemplate::ObjectParameter& objPar) {
0944   // loop over m_tableMenuCond
0945   for (std::vector<TableMenuObjectParameters>::const_iterator constIt = m_tableMenuObjectParameters.begin();
0946        constIt != m_tableMenuObjectParameters.end();
0947        constIt++) {
0948     if (opFK == (*constIt).opId) {
0949       objPar.ptHighThreshold = static_cast<unsigned int>((*constIt).ptHighThreshold);
0950       objPar.ptLowThreshold = static_cast<unsigned int>((*constIt).ptLowThreshold);
0951       objPar.enableMip = static_cast<bool>((*constIt).enableMip);
0952       objPar.enableIso = static_cast<bool>((*constIt).enableIso);
0953       objPar.requestIso = static_cast<bool>((*constIt).requestIso);
0954       objPar.etaRange = lexical_cast_from_hex<unsigned long long>((*constIt).etaRange);
0955       objPar.phiHigh = static_cast<unsigned int>((*constIt).phiHigh);
0956       objPar.phiLow = static_cast<unsigned int>((*constIt).phiLow);
0957       objPar.qualityRange = lexical_cast_from_hex<unsigned int>((*constIt).qualityRange);
0958       //objPar.charge = static_cast<unsigned int> ( ( *constIt ).charge);
0959 
0960       // can break after it is found - DB consistency
0961       break;
0962     }
0963   }
0964 }
0965 
0966 void L1GtTriggerMenuConfigOnlineProd::addMuonCondition(const TableMenuCond& condDB) {
0967   L1GtMuonTemplate muonCond(condDB.cond);
0968   muonCond.setCondType(strToEnumCondType(condDB.condType));
0969 
0970   // object types - all muons
0971   int nrObj = muonCond.nrObjects();
0972   std::vector<L1GtObject> objType(nrObj, Mu);
0973   muonCond.setObjectType(objType);
0974 
0975   muonCond.setCondGEq(condDB.condGEq);
0976 
0977   // temporary storage of the parameters
0978   std::vector<L1GtMuonTemplate::ObjectParameter> objParameter(nrObj);
0979 
0980   for (int iObj = 0; iObj < nrObj; ++iObj) {
0981     if (iObj == 0) {
0982       fillMuonObjectParameter(condDB.objectParameter1FK, objParameter[iObj]);
0983     } else if (iObj == 1) {
0984       fillMuonObjectParameter(condDB.objectParameter2FK, objParameter[iObj]);
0985     } else if (iObj == 2) {
0986       fillMuonObjectParameter(condDB.objectParameter3FK, objParameter[iObj]);
0987     } else if (iObj == 3) {
0988       fillMuonObjectParameter(condDB.objectParameter4FK, objParameter[iObj]);
0989     } else {
0990       LogTrace("L1GtTriggerMenuConfigOnlineProd")
0991           << "\n Warning: number of objects requested " << nrObj << " not available in DB."
0992           << "\n Maximum 4 object parameters implemented. \n"
0993           << std::endl;
0994     }
0995   }
0996 
0997   L1GtMuonTemplate::CorrelationParameter corrParameter;
0998   corrParameter.chargeCorrelation = static_cast<unsigned int>(condDB.chargeCorrelation);
0999   if (muonCond.wsc()) {
1000     corrParameter.deltaEtaRange = lexical_cast_from_hex<unsigned long long>(condDB.deltaEtaRange);
1001 
1002     std::string word0;
1003     std::string word1;
1004     splitHexStringInTwo64bitWords(condDB.deltaPhiRange, word0, word1);
1005 
1006     corrParameter.deltaPhiRange0Word = lexical_cast_from_hex<unsigned long long>(word0);
1007     corrParameter.deltaPhiRange1Word = lexical_cast_from_hex<unsigned long long>(word1);
1008 
1009     corrParameter.deltaPhiMaxbits = 0;  // not used anymore
1010   }
1011 
1012   muonCond.setConditionParameter(objParameter, corrParameter);
1013 
1014   // get chip number list
1015   std::list<int> chipList = listChipNumber(condDB.cond);
1016 
1017   // eliminate duplicates
1018   chipList.sort();
1019   chipList.unique();
1020 
1021   // add the same condition once to every chip where required
1022   for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1023     muonCond.setCondChipNr(*itChip);
1024 
1025     // no check for uniqueness - done by DB
1026     (m_vecMuonTemplate[*itChip]).push_back(muonCond);
1027 
1028     if (m_isDebugEnabled) {
1029       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1030           << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1031 
1032       LogTrace("L1GtTriggerMenuConfigOnlineProd") << muonCond << "\n" << std::endl;
1033     }
1034   }
1035 }
1036 
1037 void L1GtTriggerMenuConfigOnlineProd::fillCaloObjectParameter(const std::string& opFK,
1038                                                               L1GtCaloTemplate::ObjectParameter& objPar) {
1039   // loop over m_tableMenuCond
1040   for (std::vector<TableMenuObjectParameters>::const_iterator constIt = m_tableMenuObjectParameters.begin();
1041        constIt != m_tableMenuObjectParameters.end();
1042        constIt++) {
1043     if (opFK == (*constIt).opId) {
1044       objPar.etThreshold = static_cast<unsigned int>((*constIt).etThreshold);
1045       objPar.etaRange = lexical_cast_from_hex<unsigned int>((*constIt).etaRange);
1046       objPar.phiRange = lexical_cast_from_hex<unsigned int>((*constIt).phiRange);
1047 
1048       // can break after it is found - DB consistency
1049       break;
1050     }
1051   }
1052 }
1053 
1054 void L1GtTriggerMenuConfigOnlineProd::addCaloCondition(const TableMenuCond& condDB) {
1055   L1GtCaloTemplate caloCond(condDB.cond);
1056   caloCond.setCondType(strToEnumCondType(condDB.condType));
1057 
1058   // object types - all have the same type, so reading it for first object is OK
1059   int nrObj = caloCond.nrObjects();
1060 
1061   L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
1062   std::vector<L1GtObject> objType(nrObj, obj);
1063   caloCond.setObjectType(objType);
1064 
1065   caloCond.setCondGEq(condDB.condGEq);
1066 
1067   // temporary storage of the parameters
1068   std::vector<L1GtCaloTemplate::ObjectParameter> objParameter(nrObj);
1069 
1070   for (int iObj = 0; iObj < nrObj; ++iObj) {
1071     if (iObj == 0) {
1072       fillCaloObjectParameter(condDB.objectParameter1FK, objParameter[iObj]);
1073     } else if (iObj == 1) {
1074       fillCaloObjectParameter(condDB.objectParameter2FK, objParameter[iObj]);
1075     } else if (iObj == 2) {
1076       fillCaloObjectParameter(condDB.objectParameter3FK, objParameter[iObj]);
1077     } else if (iObj == 3) {
1078       fillCaloObjectParameter(condDB.objectParameter4FK, objParameter[iObj]);
1079     } else {
1080       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1081           << "\n Warning: number of objects requested " << nrObj << " not available in DB."
1082           << "\n Maximum 4 object parameters implemented. \n"
1083           << std::endl;
1084     }
1085   }
1086 
1087   L1GtCaloTemplate::CorrelationParameter corrParameter;
1088   if (caloCond.wsc()) {
1089     corrParameter.deltaEtaRange = lexical_cast_from_hex<unsigned long long>(condDB.deltaEtaRange);
1090 
1091     corrParameter.deltaPhiRange = lexical_cast_from_hex<unsigned long long>(condDB.deltaPhiRange);
1092     corrParameter.deltaPhiMaxbits = 0;  // FIXME check correlations
1093   }
1094 
1095   caloCond.setConditionParameter(objParameter, corrParameter);
1096 
1097   // get chip number list
1098   std::list<int> chipList = listChipNumber(condDB.cond);
1099 
1100   // eliminate duplicates
1101   chipList.sort();
1102   chipList.unique();
1103 
1104   // add the same condition once to every chip where required
1105   for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1106     caloCond.setCondChipNr(*itChip);
1107 
1108     // no check for uniqueness - done by DB
1109     (m_vecCaloTemplate[*itChip]).push_back(caloCond);
1110 
1111     if (m_isDebugEnabled) {
1112       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1113           << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1114 
1115       LogTrace("L1GtTriggerMenuConfigOnlineProd") << caloCond << "\n" << std::endl;
1116     }
1117   }
1118 }
1119 
1120 void L1GtTriggerMenuConfigOnlineProd::fillEnergySumObjectParameter(const std::string& opFK,
1121                                                                    L1GtEnergySumTemplate::ObjectParameter& objPar,
1122                                                                    const L1GtObject& obj) {
1123   // loop over m_tableMenuCond
1124   for (std::vector<TableMenuObjectParameters>::const_iterator constIt = m_tableMenuObjectParameters.begin();
1125        constIt != m_tableMenuObjectParameters.end();
1126        constIt++) {
1127     if (opFK == (*constIt).opId) {
1128       objPar.etThreshold = static_cast<unsigned int>((*constIt).etThreshold);
1129       objPar.energyOverflow = static_cast<bool>((*constIt).energyOverflow);  // not used
1130 
1131       std::string word0;
1132       std::string word1;
1133       splitHexStringInTwo64bitWords((*constIt).phiRange, word0, word1);
1134 
1135       if (obj == ETM) {
1136         objPar.phiRange0Word = lexical_cast_from_hex<unsigned long long>(word0);
1137         objPar.phiRange1Word = lexical_cast_from_hex<unsigned long long>(word1);
1138 
1139       } else if (obj == HTM) {
1140         objPar.phiRange0Word = lexical_cast_from_hex<unsigned long long>(word0);
1141       }
1142 
1143       // can break after it is found - DB consistency
1144       break;
1145     }
1146   }
1147 }
1148 
1149 void L1GtTriggerMenuConfigOnlineProd::addEnergySumCondition(const TableMenuCond& condDB) {
1150   L1GtEnergySumTemplate esumCond(condDB.cond);
1151   esumCond.setCondType(strToEnumCondType(condDB.condType));
1152 
1153   // object types - all energy sums are global - so 1 object
1154   int nrObj = 1;
1155 
1156   L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
1157   std::vector<L1GtObject> objType(nrObj, obj);
1158   esumCond.setObjectType(objType);
1159 
1160   esumCond.setCondGEq(condDB.condGEq);
1161 
1162   // temporary storage of the parameters - no CorrelationParameter
1163   std::vector<L1GtEnergySumTemplate::ObjectParameter> objParameter(nrObj);
1164   fillEnergySumObjectParameter(condDB.objectParameter1FK, objParameter[0], objType[0]);
1165 
1166   esumCond.setConditionParameter(objParameter);
1167 
1168   // get chip number list
1169   std::list<int> chipList = listChipNumber(condDB.cond);
1170 
1171   // eliminate duplicates
1172   chipList.sort();
1173   chipList.unique();
1174 
1175   // add the same condition once to every chip where required
1176   for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1177     esumCond.setCondChipNr(*itChip);
1178 
1179     // no check for uniqueness - done by DB
1180     (m_vecEnergySumTemplate[*itChip]).push_back(esumCond);
1181 
1182     if (m_isDebugEnabled) {
1183       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1184           << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1185 
1186       LogTrace("L1GtTriggerMenuConfigOnlineProd") << esumCond << "\n" << std::endl;
1187     }
1188   }
1189 }
1190 
1191 void L1GtTriggerMenuConfigOnlineProd::addJetCountsCondition(const TableMenuCond& condDB) {
1192   L1GtJetCountsTemplate jcCond(condDB.cond);
1193   jcCond.setCondType(strToEnumCondType(condDB.condType));
1194 
1195   // object types - jet counts are "global"
1196   int nrObj = 1;
1197 
1198   L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
1199   std::vector<L1GtObject> objType(nrObj, obj);
1200   jcCond.setObjectType(objType);
1201 
1202   jcCond.setCondGEq(condDB.condGEq);
1203 
1204   // temporary storage of the parameters - no CorrelationParameter
1205   // for counts, the DB implementation is without OP, directly in TableMenuCond
1206   std::vector<L1GtJetCountsTemplate::ObjectParameter> objParameter(nrObj);
1207   objParameter.at(0).countIndex = static_cast<unsigned int>(condDB.countIndex);
1208   objParameter.at(0).countThreshold = static_cast<unsigned int>(condDB.countThreshold);
1209   objParameter.at(0).countOverflow = false;  // not used
1210 
1211   jcCond.setConditionParameter(objParameter);
1212 
1213   // get chip number list
1214   std::list<int> chipList = listChipNumber(condDB.cond);
1215 
1216   // eliminate duplicates
1217   chipList.sort();
1218   chipList.unique();
1219 
1220   // add the same condition once to every chip where required
1221   for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1222     jcCond.setCondChipNr(*itChip);
1223 
1224     // no check for uniqueness - done by DB
1225     (m_vecJetCountsTemplate[*itChip]).push_back(jcCond);
1226 
1227     if (m_isDebugEnabled) {
1228       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1229           << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1230 
1231       LogTrace("L1GtTriggerMenuConfigOnlineProd") << jcCond << "\n" << std::endl;
1232     }
1233   }
1234 }
1235 
1236 void L1GtTriggerMenuConfigOnlineProd::addHfBitCountsCondition(const TableMenuCond& condDB) {
1237   L1GtHfBitCountsTemplate countsCond(condDB.cond);
1238   countsCond.setCondType(strToEnumCondType(condDB.condType));
1239 
1240   // object types - HF bit counts are "global"
1241   int nrObj = 1;
1242 
1243   L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
1244   std::vector<L1GtObject> objType(nrObj, obj);
1245   countsCond.setObjectType(objType);
1246 
1247   countsCond.setCondGEq(condDB.condGEq);
1248 
1249   // temporary storage of the parameters - no CorrelationParameter
1250   // for counts, the DB implementation is without OP, directly in TableMenuCond
1251   std::vector<L1GtHfBitCountsTemplate::ObjectParameter> objParameter(nrObj);
1252   objParameter.at(0).countIndex = static_cast<unsigned int>(condDB.countIndex);
1253   objParameter.at(0).countThreshold = static_cast<unsigned int>(condDB.countThreshold);
1254 
1255   countsCond.setConditionParameter(objParameter);
1256 
1257   // get chip number list
1258   std::list<int> chipList = listChipNumber(condDB.cond);
1259 
1260   // eliminate duplicates
1261   chipList.sort();
1262   chipList.unique();
1263 
1264   // add the same condition once to every chip where required
1265   for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1266     countsCond.setCondChipNr(*itChip);
1267 
1268     // no check for uniqueness - done by DB
1269     (m_vecHfBitCountsTemplate[*itChip]).push_back(countsCond);
1270 
1271     if (m_isDebugEnabled) {
1272       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1273           << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1274 
1275       LogTrace("L1GtTriggerMenuConfigOnlineProd") << countsCond << "\n" << std::endl;
1276     }
1277   }
1278 }
1279 
1280 void L1GtTriggerMenuConfigOnlineProd::addHfRingEtSumsCondition(const TableMenuCond& condDB) {
1281   L1GtHfRingEtSumsTemplate esumCond(condDB.cond);
1282   esumCond.setCondType(strToEnumCondType(condDB.condType));
1283 
1284   // object types - HF energy sums are "global"
1285   int nrObj = 1;
1286 
1287   L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
1288   std::vector<L1GtObject> objType(nrObj, obj);
1289   esumCond.setObjectType(objType);
1290 
1291   esumCond.setCondGEq(condDB.condGEq);
1292 
1293   // temporary storage of the parameters - no CorrelationParameter
1294   // for HF energy sums, the DB implementation is without OP, directly in TableMenuCond
1295   std::vector<L1GtHfRingEtSumsTemplate::ObjectParameter> objParameter(nrObj);
1296   objParameter.at(0).etSumIndex = static_cast<unsigned int>(condDB.countIndex);
1297   objParameter.at(0).etSumThreshold = static_cast<unsigned int>(condDB.countThreshold);
1298 
1299   esumCond.setConditionParameter(objParameter);
1300 
1301   // get chip number list
1302   std::list<int> chipList = listChipNumber(condDB.cond);
1303 
1304   // eliminate duplicates
1305   chipList.sort();
1306   chipList.unique();
1307 
1308   // add the same condition once to every chip where required
1309   for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1310     esumCond.setCondChipNr(*itChip);
1311 
1312     // no check for uniqueness - done by DB
1313     (m_vecHfRingEtSumsTemplate[*itChip]).push_back(esumCond);
1314 
1315     if (m_isDebugEnabled) {
1316       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1317           << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1318 
1319       LogTrace("L1GtTriggerMenuConfigOnlineProd") << esumCond << "\n" << std::endl;
1320     }
1321   }
1322 }
1323 
1324 void L1GtTriggerMenuConfigOnlineProd::addCastorCondition(const TableMenuCond& condDB) {
1325   L1GtCastorTemplate castorCond(condDB.cond);
1326   castorCond.setCondType(strToEnumCondType(condDB.condType));
1327 
1328   // object types - logical conditions have no objects associated in GT
1329   // one put however a "Castor" object type
1330   int nrObj = 1;
1331 
1332   L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
1333   std::vector<L1GtObject> objType(nrObj, obj);
1334   castorCond.setObjectType(objType);
1335 
1336   // irrelevant, set to false for completeness
1337   castorCond.setCondGEq(false);
1338 
1339   // logical conditions have no ObjectParameter, no CorrelationParameter
1340 
1341   // get chip number list
1342   std::list<int> chipList = listChipNumber(condDB.cond);
1343 
1344   // eliminate duplicates
1345   chipList.sort();
1346   chipList.unique();
1347 
1348   // add the same condition once to every chip where required
1349   for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1350     castorCond.setCondChipNr(*itChip);
1351 
1352     // no check for uniqueness - done by DB
1353     (m_vecCastorTemplate[*itChip]).push_back(castorCond);
1354 
1355     if (m_isDebugEnabled) {
1356       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1357           << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1358 
1359       LogTrace("L1GtTriggerMenuConfigOnlineProd") << castorCond << "\n" << std::endl;
1360     }
1361   }
1362 }
1363 
1364 void L1GtTriggerMenuConfigOnlineProd::addBptxCondition(const TableMenuCond& condDB) {
1365   L1GtBptxTemplate bptxCond(condDB.cond);
1366   bptxCond.setCondType(strToEnumCondType(condDB.condType));
1367 
1368   // object types - logical conditions have no objects associated in GT
1369   // one put however a "Bptx" object type
1370   int nrObj = 1;
1371 
1372   L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
1373   std::vector<L1GtObject> objType(nrObj, obj);
1374   bptxCond.setObjectType(objType);
1375 
1376   // irrelevant, set to false for completeness
1377   bptxCond.setCondGEq(false);
1378 
1379   // logical conditions have no ObjectParameter, no CorrelationParameter
1380 
1381   // get chip number list
1382   std::list<int> chipList = listChipNumber(condDB.cond);
1383 
1384   // eliminate duplicates
1385   chipList.sort();
1386   chipList.unique();
1387 
1388   // add the same condition once to every chip where required
1389   for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1390     bptxCond.setCondChipNr(*itChip);
1391 
1392     // no check for uniqueness - done by DB
1393     (m_vecBptxTemplate[*itChip]).push_back(bptxCond);
1394 
1395     if (m_isDebugEnabled) {
1396       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1397           << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1398 
1399       LogTrace("L1GtTriggerMenuConfigOnlineProd") << bptxCond << "\n" << std::endl;
1400     }
1401   }
1402 }
1403 
1404 void L1GtTriggerMenuConfigOnlineProd::addExternalCondition(const TableMenuCond& condDB) {
1405   L1GtExternalTemplate externalCond(condDB.cond);
1406   externalCond.setCondType(strToEnumCondType(condDB.condType));
1407 
1408   // object types - logical conditions have no objects associated in GT
1409   // one put however a "External" object type
1410   int nrObj = 1;
1411 
1412   L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
1413   std::vector<L1GtObject> objType(nrObj, obj);
1414   externalCond.setObjectType(objType);
1415 
1416   // irrelevant, set to false for completeness
1417   externalCond.setCondGEq(false);
1418 
1419   // logical conditions have no ObjectParameter, no CorrelationParameter
1420 
1421   // get chip number list
1422   std::list<int> chipList = listChipNumber(condDB.cond);
1423 
1424   // eliminate duplicates
1425   chipList.sort();
1426   chipList.unique();
1427 
1428   // add the same condition once to every chip where required
1429   for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1430     externalCond.setCondChipNr(*itChip);
1431 
1432     // no check for uniqueness - done by DB
1433     (m_vecExternalTemplate[*itChip]).push_back(externalCond);
1434 
1435     if (m_isDebugEnabled) {
1436       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1437           << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1438 
1439       LogTrace("L1GtTriggerMenuConfigOnlineProd") << externalCond << "\n" << std::endl;
1440     }
1441   }
1442 }
1443 
1444 void L1GtTriggerMenuConfigOnlineProd::addCorrelationCondition(const TableMenuCond& condDB) {
1445   // create a new correlation condition
1446   L1GtCorrelationTemplate correlationCond(condDB.cond);
1447   correlationCond.setCondType(strToEnumCondType(condDB.condType));
1448 
1449   // two objects (for sure) - type taken from DB
1450   const int nrObj = 2;
1451 
1452   std::vector<L1GtObject> objType(nrObj);
1453   L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
1454   objType[0] = obj;
1455 
1456   obj = strToEnumL1GtObject(condDB.gtObject2);
1457   objType[1] = obj;
1458 
1459   correlationCond.setObjectType(objType);
1460 
1461   // irrelevant, it is set for each subcondition
1462   correlationCond.setCondGEq(condDB.condGEq);
1463 
1464   // get chip number list, eliminate duplicates
1465   std::list<int> chipList = listChipNumber(condDB.cond);
1466   chipList.sort();
1467   chipList.unique();
1468 
1469   // temporary vectors for sub-conditions
1470   std::vector<L1GtConditionCategory> subcondCategory(nrObj);
1471   std::vector<int> subcondIndex(nrObj);
1472 
1473   bool wrongSubcondition = false;
1474 
1475   for (int iObj = 0; iObj < nrObj; ++iObj) {
1476     L1GtObject gtObj = objType[iObj];
1477 
1478     // sub-conditions (all have the same condGEq as the correlation condition).
1479     switch (gtObj) {
1480       case Mu: {
1481         subcondCategory[iObj] = CondMuon;
1482 
1483         // temporary storage of the parameters
1484         std::vector<L1GtMuonTemplate::ObjectParameter> objParameter(1);
1485 
1486         std::string subcondName;
1487         if (iObj == 0) {
1488           fillMuonObjectParameter(condDB.objectParameter1FK, objParameter[0]);
1489           subcondName = condDB.objectParameter1FK;
1490         } else if (iObj == 1) {
1491           subcondName = condDB.objectParameter2FK;
1492           fillMuonObjectParameter(condDB.objectParameter2FK, objParameter[0]);
1493         }
1494 
1495         //  chargeCorrelation must be set for muons
1496         //  put it to ignore
1497         L1GtMuonTemplate::CorrelationParameter corrPar;
1498         corrPar.chargeCorrelation = 1;
1499 
1500         L1GtMuonTemplate subcond(subcondName, Type1s);
1501         subcond.setCondGEq(condDB.condGEq);
1502         subcond.setObjectType(std::vector<L1GtObject>(1, gtObj));
1503         subcond.setConditionParameter(objParameter, corrPar);
1504 
1505         // add the same sub-condition once to every chip where required
1506         for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1507           subcond.setCondChipNr(*itChip);
1508 
1509           // no check for uniqueness - done by DB
1510           (m_corMuonTemplate[*itChip]).push_back(subcond);
1511 
1512           // index
1513           subcondIndex[iObj] = (m_corMuonTemplate[*itChip]).size() - 1;
1514 
1515           if (m_isDebugEnabled) {
1516             LogTrace("L1GtTriggerMenuConfigOnlineProd")
1517                 << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1518 
1519             LogTrace("L1GtTriggerMenuConfigOnlineProd") << subcond << "\n" << std::endl;
1520           }
1521         }
1522 
1523       } break;
1524 
1525       case IsoEG:
1526       case NoIsoEG:
1527       case CenJet:
1528       case ForJet:
1529       case TauJet: {
1530         subcondCategory[iObj] = CondCalo;
1531 
1532         // temporary storage of the parameters
1533         std::vector<L1GtCaloTemplate::ObjectParameter> objParameter(1);
1534 
1535         std::string subcondName;
1536         if (iObj == 0) {
1537           fillCaloObjectParameter(condDB.objectParameter1FK, objParameter[0]);
1538           subcondName = condDB.objectParameter1FK;
1539         } else if (iObj == 1) {
1540           subcondName = condDB.objectParameter2FK;
1541           fillCaloObjectParameter(condDB.objectParameter2FK, objParameter[0]);
1542         }
1543 
1544         L1GtCaloTemplate::CorrelationParameter corrPar;  //  dummy
1545 
1546         L1GtCaloTemplate subcond(subcondName, Type1s);
1547         subcond.setCondGEq(condDB.condGEq);
1548         subcond.setObjectType(std::vector<L1GtObject>(1, gtObj));
1549         subcond.setConditionParameter(objParameter, corrPar);
1550 
1551         // add the same sub-condition once to every chip where required
1552         for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1553           subcond.setCondChipNr(*itChip);
1554 
1555           // no check for uniqueness - done by DB
1556           (m_corCaloTemplate[*itChip]).push_back(subcond);
1557 
1558           // index
1559           subcondIndex[iObj] = (m_corCaloTemplate[*itChip]).size() - 1;
1560 
1561           if (m_isDebugEnabled) {
1562             LogTrace("L1GtTriggerMenuConfigOnlineProd")
1563                 << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1564 
1565             LogTrace("L1GtTriggerMenuConfigOnlineProd") << subcond << "\n" << std::endl;
1566           }
1567         }
1568       } break;
1569 
1570       case ETM:
1571       case HTM: {
1572         subcondCategory[iObj] = CondEnergySum;
1573 
1574         // temporary storage of the parameters
1575         std::vector<L1GtEnergySumTemplate::ObjectParameter> objParameter(1);
1576 
1577         std::string subcondName;
1578         if (iObj == 0) {
1579           fillEnergySumObjectParameter(condDB.objectParameter1FK, objParameter[0], gtObj);
1580           subcondName = condDB.objectParameter1FK;
1581         } else if (iObj == 1) {
1582           subcondName = condDB.objectParameter2FK;
1583           fillEnergySumObjectParameter(condDB.objectParameter2FK, objParameter[0], gtObj);
1584         }
1585 
1586         L1GtConditionType condType;
1587 
1588         switch (gtObj) {
1589           case ETM: {
1590             condType = TypeETM;
1591           } break;
1592           case HTM: {
1593             condType = TypeHTM;
1594           } break;
1595           default: {
1596             edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
1597                 << "\n Warning: wrong L1GtConditionType " << gtObj << std::endl;
1598 
1599           } break;
1600         }
1601 
1602         L1GtEnergySumTemplate subcond(subcondName, condType);
1603         subcond.setCondGEq(condDB.condGEq);
1604         subcond.setObjectType(std::vector<L1GtObject>(1, gtObj));
1605         subcond.setConditionParameter(objParameter);
1606 
1607         // add the same sub-condition once to every chip where required
1608         for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1609           subcond.setCondChipNr(*itChip);
1610 
1611           // no check for uniqueness - done by DB
1612           (m_corEnergySumTemplate[*itChip]).push_back(subcond);
1613 
1614           // index
1615           subcondIndex[iObj] = (m_corEnergySumTemplate[*itChip]).size() - 1;
1616 
1617           if (m_isDebugEnabled) {
1618             LogTrace("L1GtTriggerMenuConfigOnlineProd")
1619                 << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1620 
1621             LogTrace("L1GtTriggerMenuConfigOnlineProd") << subcond << "\n" << std::endl;
1622           }
1623         }
1624       } break;
1625       case ETT:
1626       case HTT:
1627       case JetCounts:
1628       case HfBitCounts:
1629       case HfRingEtSums:
1630       case Castor:
1631       case BPTX:
1632       case GtExternal:
1633       case TechTrig: {
1634         wrongSubcondition = true;
1635         edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
1636             << "\n Warning: correlation condition " << (condDB.cond) << " with invalid sub-condition object type "
1637             << gtObj << "\n Condition ignored!" << std::endl;
1638       }
1639         [[fallthrough]];
1640       default: {
1641         wrongSubcondition = true;
1642         edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
1643             << "\n Warning: correlation condition " << (condDB.cond) << " with invalid sub-condition object type "
1644             << gtObj << "\n Condition ignored!" << std::endl;
1645 
1646         //
1647 
1648       } break;
1649     }
1650   }
1651 
1652   if (wrongSubcondition) {
1653     edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
1654         << "\n Warning: wrong sub-condition for correlation condition " << (condDB.cond)
1655         << "\n Condition not inserted in menu. \n A sub-condition may be left in the menu" << std::endl;
1656     return;
1657   }
1658 
1659   // get the correlation parameters for the correlation condition (std::string)
1660   L1GtCorrelationTemplate::CorrelationParameter corrParameter;
1661   corrParameter.deltaEtaRange = condDB.deltaEtaRange;
1662   corrParameter.deltaPhiRange = condDB.deltaPhiRange;
1663 
1664   // set condition categories
1665   correlationCond.setCond0Category(subcondCategory[0]);
1666   correlationCond.setCond1Category(subcondCategory[1]);
1667 
1668   // set condition indices in correlation vector
1669   correlationCond.setCond0Index(subcondIndex[0]);
1670   correlationCond.setCond1Index(subcondIndex[1]);
1671 
1672   // set correlation parameter
1673   corrParameter.deltaPhiMaxbits = 0;  //  TODO
1674   correlationCond.setCorrelationParameter(corrParameter);
1675 
1676   // add the same condition once to every chip where required
1677   for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
1678     correlationCond.setCondChipNr(*itChip);
1679 
1680     // no check for uniqueness - done by DB
1681     (m_vecCorrelationTemplate[*itChip]).push_back(correlationCond);
1682 
1683     if (m_isDebugEnabled) {
1684       LogTrace("L1GtTriggerMenuConfigOnlineProd")
1685           << "\n Adding condition " << (condDB.cond) << " on chip " << (*itChip) << "\n " << std::endl;
1686 
1687       LogTrace("L1GtTriggerMenuConfigOnlineProd") << correlationCond << "\n" << std::endl;
1688     }
1689   }
1690 }
1691 
1692 // add the conditions from a menu to the corresponding list
1693 void L1GtTriggerMenuConfigOnlineProd::addConditions() {
1694   // loop over m_tableMenuCond
1695   for (std::vector<TableMenuCond>::const_iterator constIt = m_tableMenuCond.begin(); constIt != m_tableMenuCond.end();
1696        constIt++) {
1697     L1GtConditionCategory conCategory = strToEnumCondCategory((*constIt).condCategory);
1698 
1699     switch (conCategory) {
1700       case CondMuon: {
1701         addMuonCondition(*constIt);
1702 
1703       } break;
1704       case CondCalo: {
1705         addCaloCondition(*constIt);
1706 
1707       } break;
1708       case CondEnergySum: {
1709         addEnergySumCondition(*constIt);
1710 
1711       } break;
1712       case CondJetCounts: {
1713         addJetCountsCondition(*constIt);
1714 
1715       } break;
1716       case CondHfBitCounts: {
1717         addHfBitCountsCondition(*constIt);
1718 
1719       } break;
1720       case CondHfRingEtSums: {
1721         addHfRingEtSumsCondition(*constIt);
1722 
1723       } break;
1724       case CondCastor: {
1725         addCastorCondition(*constIt);
1726 
1727       } break;
1728       case CondBptx: {
1729         addBptxCondition(*constIt);
1730 
1731       } break;
1732       case CondExternal: {
1733         addExternalCondition(*constIt);
1734 
1735       } break;
1736       case CondCorrelation: {
1737         addCorrelationCondition(*constIt);
1738 
1739       } break;
1740       case CondNull: {
1741         // do nothing
1742 
1743       } break;
1744       default: {
1745         // do nothing
1746 
1747       } break;
1748     }
1749   }
1750 }
1751 
1752 DEFINE_FWK_EVENTSETUP_MODULE(L1GtTriggerMenuConfigOnlineProd);