CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/L1TriggerConfig/L1GtConfigProducers/src/L1GtTriggerMenuConfigOnlineProd.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtTriggerMenuConfigOnlineProd.h"
00019 
00020 // system include files
00021 #include <string>
00022 #include <vector>
00023 #include <map>
00024 #include <list>
00025 #include <utility>
00026 #include <algorithm>
00027 
00028 #include "boost/lexical_cast.hpp"
00029 
00030 // user include files
00031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00032 
00033 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
00034 #include "CondFormats/L1TObjects/interface/L1GtFwd.h"
00035 
00036 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00037 
00038 #include "CondFormats/L1TObjects/interface/L1GtCondition.h"
00039 #include "CondFormats/L1TObjects/interface/L1GtAlgorithm.h"
00040 
00041 
00042 // constructor
00043 L1GtTriggerMenuConfigOnlineProd::L1GtTriggerMenuConfigOnlineProd(const edm::ParameterSet& parSet) :
00044     L1ConfigOnlineProdBase<L1GtTriggerMenuRcd, L1GtTriggerMenu> (parSet), m_isDebugEnabled(
00045             edm::isDebugEnabled()) {
00046 
00047     // empty
00048 
00049 }
00050 
00051 // destructor
00052 L1GtTriggerMenuConfigOnlineProd::~L1GtTriggerMenuConfigOnlineProd() {
00053 
00054     // empty
00055 
00056 }
00057 
00058 // public methods
00059 
00060 // initialize the class (mainly reserve/resize)
00061 void L1GtTriggerMenuConfigOnlineProd::init(const int numberConditionChips) {
00062 
00063     // resize the vectors of condition maps
00064     // the number of condition chips should be correctly set
00065 
00066     m_vecMuonTemplate.resize(numberConditionChips);
00067     m_vecCaloTemplate.resize(numberConditionChips);
00068     m_vecEnergySumTemplate.resize(numberConditionChips);
00069     m_vecJetCountsTemplate.resize(numberConditionChips);
00070     m_vecCastorTemplate.resize(numberConditionChips);
00071     m_vecHfBitCountsTemplate.resize(numberConditionChips);
00072     m_vecHfRingEtSumsTemplate.resize(numberConditionChips);
00073     m_vecBptxTemplate.resize(numberConditionChips);
00074     m_vecExternalTemplate.resize(numberConditionChips);
00075 
00076     m_vecCorrelationTemplate.resize(numberConditionChips);
00077     m_corMuonTemplate.resize(numberConditionChips);
00078     m_corCaloTemplate.resize(numberConditionChips);
00079     m_corEnergySumTemplate.resize(numberConditionChips);
00080 
00081 
00082 }
00083 
00084 boost::shared_ptr<L1GtTriggerMenu> L1GtTriggerMenuConfigOnlineProd::newObject(
00085         const std::string& objectKey) {
00086 
00087     // FIXME seems to not work anymore in constructor...
00088     m_isDebugEnabled = edm::isDebugEnabled();
00089 
00090     // shared pointer for L1GtTriggerMenu - empty menu
00091     boost::shared_ptr<L1GtTriggerMenu> pL1GtTriggerMenuEmpty =
00092             boost::shared_ptr<L1GtTriggerMenu>(new L1GtTriggerMenu());
00093 
00094     // FIXME get it from L1GtStableParameters?
00095     //       initialize once, from outside
00096     const unsigned int numberConditionChips = 2;
00097     init(numberConditionChips);
00098 
00099     const std::string gtSchema = "CMS_GT";
00100 
00101     // l1GtTriggerMenu: parameters in table GTFE_SETUP_FK
00102     // the objectKey for the menu obtained from GT_SETUP is the L1T_MENU_IMPL key
00103 
00104     // SQL queries:
00105 
00106     // retrieve table with general menu parameters from DB, view L1T_MENU_GENERAL_VIEW
00107     if (!tableMenuGeneralFromDB(gtSchema, objectKey)) {
00108         return pL1GtTriggerMenuEmpty;
00109 
00110     }
00111 
00112     // build the menu name
00113     std::string menuName = m_tableMenuGeneral.menuInterface + "/" + m_tableMenuGeneral.scalesKey
00114             + "/" + m_tableMenuGeneral.algoImplTag;
00115 
00116 
00117     // retrieve table with physics algorithms from DB, view L1T_MENU_ALGO_VIEW
00118     if (!tableMenuAlgoFromDB(gtSchema, objectKey)) {
00119         return pL1GtTriggerMenuEmpty;
00120 
00121     }
00122 
00123     // retrieve table with conditions associated to physics algorithms from DB
00124     if (!tableMenuAlgoCondFromDB(gtSchema, objectKey)) {
00125         return pL1GtTriggerMenuEmpty;
00126 
00127     }
00128 
00129     // retrieve table with list of conditions in the menu
00130     if (!tableMenuCondFromDB(gtSchema, objectKey)) {
00131         return pL1GtTriggerMenuEmpty;
00132 
00133     }
00134 
00135 
00136     // retrieve table with object parameters from DB, view CMS_GT.L1T_MENU_OP_VIEW
00137     if (!tableMenuObjectParametersFromDB(gtSchema, objectKey)) {
00138         return pL1GtTriggerMenuEmpty;
00139 
00140     }
00141 
00142     // retrieve table with technical triggers from DB, view L1T_MENU_TECHTRIG_VIEW
00143     if (!tableMenuTechTrigFromDB(gtSchema, objectKey)) {
00144         return pL1GtTriggerMenuEmpty;
00145 
00146     }
00147 
00148     // build the algorithm map in the menu
00149     buildAlgorithmMap();
00150 
00151     // build the technical trigger map in the menu
00152     buildTechnicalTriggerMap();
00153 
00154     // add the conditions from a menu to the corresponding list
00155     addConditions();
00156 
00157     // fill the record
00158     boost::shared_ptr<L1GtTriggerMenu> pL1GtTriggerMenu = boost::shared_ptr<L1GtTriggerMenu>(
00159                 new L1GtTriggerMenu(menuName, numberConditionChips,
00160                         m_vecMuonTemplate,
00161                         m_vecCaloTemplate,
00162                         m_vecEnergySumTemplate,
00163                         m_vecJetCountsTemplate,
00164                         m_vecCastorTemplate,
00165                         m_vecHfBitCountsTemplate,
00166                         m_vecHfRingEtSumsTemplate,
00167                         m_vecBptxTemplate,
00168                         m_vecExternalTemplate,
00169                         m_vecCorrelationTemplate,
00170                         m_corMuonTemplate,
00171                         m_corCaloTemplate,
00172                         m_corEnergySumTemplate) );
00173 
00174     pL1GtTriggerMenu->setGtTriggerMenuInterface(m_tableMenuGeneral.menuInterface);
00175     pL1GtTriggerMenu->setGtTriggerMenuImplementation(m_tableMenuGeneral.menuImplementation);
00176     pL1GtTriggerMenu->setGtScaleDbKey(m_tableMenuGeneral.scalesKey);
00177 
00178     pL1GtTriggerMenu->setGtAlgorithmMap(m_algorithmMap);
00179     pL1GtTriggerMenu->setGtAlgorithmAliasMap(m_algorithmAliasMap);
00180     pL1GtTriggerMenu->setGtTechnicalTriggerMap(m_technicalTriggerMap);
00181 
00182 
00183     if (m_isDebugEnabled) {
00184         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00185             << "\nThe following L1GtTriggerMenu record was read from OMDS: \n"
00186             << std::endl;
00187 
00188         std::ostringstream myCoutStream;
00189         int verbosity = 0;
00190         pL1GtTriggerMenu->print(myCoutStream, verbosity);
00191         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n" << std::endl;
00192 
00193         verbosity = 2;
00194         pL1GtTriggerMenu->print(myCoutStream, verbosity);
00195         LogTrace("L1GtTriggerMenuConfigOnlineProd") << myCoutStream.str() << "\n" << std::endl;
00196 
00197     }
00198 
00199     return pL1GtTriggerMenu;
00200 }
00201 
00202 // retrieve table with general menu parameters from DB
00203 bool L1GtTriggerMenuConfigOnlineProd::tableMenuGeneralFromDB(
00204         const std::string& gtSchema, const std::string& objectKey) {
00205 
00206     // select * from CMS_GT.L1T_MENU_GENERAL_VIEW
00207     //     where L1T_MENU_GENERAL_VIEW.MENU_IMPLEMENTATION = objectKey
00208 
00209     const std::vector<std::string>& columns = m_omdsReader.columnNamesView(
00210             gtSchema, "L1T_MENU_GENERAL_VIEW");
00211 
00212     if (m_isDebugEnabled) {
00213         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00214                 << "\n List of columns in L1T_MENU_GENERAL_VIEW:\n" << std::endl;
00215         for (std::vector<std::string>::const_iterator iter = columns.begin(); iter != columns.end(); iter++) {
00216             LogTrace("L1GtTriggerMenuConfigOnlineProd") << ( *iter ) << std::endl;
00217 
00218         }
00219         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
00220     }
00221 
00222     l1t::OMDSReader::QueryResults results = m_omdsReader.basicQueryView(
00223             columns, gtSchema, "L1T_MENU_GENERAL_VIEW",
00224             "L1T_MENU_GENERAL_VIEW.MENU_IMPLEMENTATION", m_omdsReader.singleAttribute(objectKey));
00225 
00226     // check if query was successful
00227     if (results.queryFailed()) {
00228         edm::LogError("L1-O2O")
00229                 << "Problem to get content of L1T_MENU_GENERAL_VIEW for L1GtTriggerMenu implementation key: "
00230                 << objectKey;
00231         return false;
00232     }
00233 
00234     // retrieve menu interface name, scales key, algorithm implementation tag
00235 
00236     for (std::vector<std::string>::const_iterator constIt = columns.begin(); constIt
00237             != columns.end(); ++constIt) {
00238 
00239         if ( ( *constIt ) == "MENU_IMPLEMENTATION") {
00240             results.fillVariable(*constIt, m_tableMenuGeneral.menuImplementation);
00241 
00242         } else if ( ( *constIt ) == "INTERFACE") {
00243             results.fillVariable(*constIt, m_tableMenuGeneral.menuInterface);
00244 
00245         } else if ( ( *constIt ) == "SCALES_KEY") {
00246             results.fillVariable(*constIt, m_tableMenuGeneral.scalesKey);
00247 
00248         } else if ( ( *constIt ) == "ALGO_IMPL_TAG") {
00249             results.fillVariable(*constIt, m_tableMenuGeneral.algoImplTag);
00250 
00251         } else {
00252             // do nothing
00253 
00254         }
00255 
00256     }
00257 
00258     // cross checks
00259     if (m_tableMenuGeneral.menuImplementation != objectKey)   {
00260 
00261         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00262                 << "\n L1 trigger menu implementation read from querying view not identical"
00263                 << "\n with menu key:"
00264                 << "\n   from view: " << m_tableMenuGeneral.menuImplementation
00265                 << "\n   from key:  " <<  objectKey
00266                 << "\n Menu implementation name set from key."
00267                 << std::endl;
00268         m_tableMenuGeneral.menuImplementation = objectKey;
00269     }
00270 
00271     //
00272     return true;
00273 
00274 }
00275 
00276 // retrieve table with physics algorithms from DB
00277 bool L1GtTriggerMenuConfigOnlineProd::tableMenuAlgoFromDB(
00278         const std::string& gtSchema, const std::string& objectKey) {
00279 
00280     // select * from CMS_GT.L1T_MENU_ALGO_VIEW
00281     //     where L1T_MENU_ALGO_VIEW.MENU_IMPLEMENTATION = objectKey
00282 
00283     const std::vector<std::string>& columnsMenuAlgo = m_omdsReader.columnNamesView(
00284             gtSchema, "L1T_MENU_ALGO_VIEW");
00285 
00286     if (m_isDebugEnabled) {
00287         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n List of columns in L1T_MENU_ALGO_VIEW:\n"
00288             << std::endl;
00289         for (std::vector<std::string>::const_iterator iter = columnsMenuAlgo.begin(); iter != columnsMenuAlgo.end(); iter++) {
00290             LogTrace("L1GtTriggerMenuConfigOnlineProd") << ( *iter ) << std::endl;
00291 
00292         }
00293         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
00294     }
00295 
00296     l1t::OMDSReader::QueryResults resultsMenuAlgo = m_omdsReader.basicQueryView(
00297             columnsMenuAlgo, gtSchema, "L1T_MENU_ALGO_VIEW", "L1T_MENU_ALGO_VIEW.MENU_IMPLEMENTATION",
00298             m_omdsReader.singleAttribute(objectKey));
00299 
00300 
00301     // check if query was successful is based on size of returned list
00302     // BUT one can have menus w/o physics algorithms - no error for empty list, but a warning!
00303     if (resultsMenuAlgo.queryFailed()) {
00304         edm::LogWarning("L1-O2O")
00305                 << "Warning: Content of L1T_MENU_ALGO_VIEW for L1GtTriggerMenu implementation key: "
00306                 << "\n  " << objectKey << "\nis empty!"
00307                 << "\nNo physics algorithms are found for this menu.";
00308 
00309     }
00310 
00311     TableMenuAlgo menuAlgo;
00312     int resultsMenuAlgoRows = resultsMenuAlgo.numberRows();
00313 
00314     for (int iRow = 0; iRow < resultsMenuAlgoRows; ++iRow) {
00315 
00316         for (std::vector<std::string>::const_iterator constIt = columnsMenuAlgo.begin(); constIt
00317                 != columnsMenuAlgo.end(); ++constIt) {
00318 
00319             if ( ( *constIt ) == "ALGO_INDEX") {
00320                 resultsMenuAlgo.fillVariableFromRow(*constIt, iRow, menuAlgo.bitNumberSh);
00321 
00322             } else if ( ( *constIt ) == "NAME") {
00323                 resultsMenuAlgo.fillVariableFromRow(*constIt, iRow, menuAlgo.algName);
00324 
00325             } else if ( ( *constIt ) == "ALIAS") {
00326                 resultsMenuAlgo.fillVariableFromRow(*constIt, iRow, menuAlgo.algAlias);
00327 
00328             } else if ( ( *constIt ) == "LOGICEXPR") {
00329                 resultsMenuAlgo.fillVariableFromRow(*constIt, iRow, menuAlgo.logExpression);
00330 
00331             } else {
00332                 // do nothing
00333 
00334             }
00335 
00336         }
00337 
00338         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00339             << "Row  " << iRow << ": index = " << menuAlgo.bitNumberSh << " algName = " << menuAlgo.algName
00340             << " algAlias = " << menuAlgo.algAlias << " logExpression = '" << menuAlgo.logExpression << "'"
00341             << std::endl;
00342 
00343         m_tableMenuAlgo.push_back(menuAlgo);
00344 
00345 
00346     }
00347 
00348     if (m_isDebugEnabled) {
00349         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00350             << "\n Number of rows read from L1T_MENU_ALGO_VIEW: " << resultsMenuAlgoRows
00351             << std::endl;
00352 
00353     }
00354 
00355     return true;
00356 
00357 }
00358 
00359 // retrieve table with conditions associated to physics algorithms from DB
00360 bool L1GtTriggerMenuConfigOnlineProd::tableMenuAlgoCondFromDB(
00361         const std::string& gtSchema, const std::string& objectKey) {
00362 
00363     // get list of conditions associated with the algorithms
00364 
00365     // select * from CMS_GT.L1T_MENU_ALGO_COND_VIEW
00366     //     where L1T_MENU_ALGO_COND_VIEW.MENU_IMPLEMENTATION = objectKey
00367 
00368     const std::vector<std::string>& columnsMenuAlgoCond = m_omdsReader.columnNamesView(
00369             gtSchema, "L1T_MENU_ALGO_COND_VIEW");
00370 
00371     if (m_isDebugEnabled) {
00372         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00373                 << "\n List of columns in L1T_MENU_ALGO_COND_VIEW:\n" << std::endl;
00374         for (std::vector<std::string>::const_iterator iter = columnsMenuAlgoCond.begin(); iter
00375                 != columnsMenuAlgoCond.end(); iter++) {
00376             LogTrace("L1GtTriggerMenuConfigOnlineProd") << ( *iter ) << std::endl;
00377 
00378         }
00379         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
00380     }
00381 
00382     l1t::OMDSReader::QueryResults resultsMenuAlgoCond = m_omdsReader.basicQueryView(
00383             columnsMenuAlgoCond, gtSchema, "L1T_MENU_ALGO_COND_VIEW",
00384             "L1T_MENU_ALGO_COND_VIEW.MENU_IMPLEMENTATION", m_omdsReader.singleAttribute(objectKey));
00385 
00386     // check if query was successful is based on size of returned list
00387     // BUT one can have menus w/o algorithms and conditions - no error for empty list, but a warning!
00388     if (resultsMenuAlgoCond.queryFailed()) {
00389         edm::LogWarning("L1-O2O")
00390                 << "Warning: Content of L1T_MENU_ALGO_COND_VIEW for L1GtTriggerMenu implementation key: "
00391                 << "\n  " << objectKey << "\nis empty!"
00392                 << "\nNo list of condition associated to each algorithm are found for this menu.";
00393 
00394     }
00395 
00396     //
00397     TableMenuAlgoCond menuAlgoCond;
00398     int resultsMenuAlgoCondRows = resultsMenuAlgoCond.numberRows();
00399 
00400     for (int iRow = 0; iRow < resultsMenuAlgoCondRows; ++iRow) {
00401 
00402         for (std::vector<std::string>::const_iterator constIt = columnsMenuAlgoCond.begin(); constIt
00403                 != columnsMenuAlgoCond.end(); ++constIt) {
00404 
00405             if ( ( *constIt ) == "ALGO_INDEX") {
00406                 resultsMenuAlgoCond.fillVariableFromRow(
00407                         *constIt, iRow, menuAlgoCond.bitNumberSh);
00408 
00409             } else if ( ( *constIt ) == "COND_INDEX") {
00410                 resultsMenuAlgoCond.fillVariableFromRow(
00411                         *constIt, iRow, menuAlgoCond.condIndexF);
00412 
00413             } else if ( ( *constIt ) == "COND_FK") {
00414                 resultsMenuAlgoCond.fillVariableFromRow(*constIt, iRow, menuAlgoCond.condFK);
00415 
00416             } else {
00417                 // do nothing
00418 
00419             }
00420 
00421         }
00422 
00423         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "Row  " << iRow << ": ALGO_INDEX = "
00424                 << menuAlgoCond.bitNumberSh << " COND_INDEX = " << menuAlgoCond.condIndexF
00425                 << " COND_FK = " << menuAlgoCond.condFK << std::endl;
00426 
00427         m_tableMenuAlgoCond.push_back(menuAlgoCond);
00428 
00429     }
00430 
00431     if (m_isDebugEnabled) {
00432         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00433                 << "\n Number of rows read from L1T_MENU_ALGO_COND_VIEW: "
00434                 << resultsMenuAlgoCondRows << std::endl;
00435     }
00436 
00437 
00438     return true;
00439 
00440 }
00441 
00442 // retrieve table with list of conditions in the menu
00443 bool L1GtTriggerMenuConfigOnlineProd::tableMenuCondFromDB(
00444         const std::string& gtSchema, const std::string& objectKey) {
00445 
00446     // select * from CMS_GT.L1T_MENU_COND_VIEW
00447     //     where L1T_MENU_COND_VIEW.MENU_IMPLEMENTATION = objectKey
00448 
00449     const std::vector<std::string>& columnsMenuCond = m_omdsReader.columnNamesView(
00450             gtSchema, "L1T_MENU_COND_VIEW");
00451 
00452     if (m_isDebugEnabled) {
00453         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00454                 << "\n List of columns in L1T_MENU_COND_VIEW:\n" << std::endl;
00455         for (std::vector<std::string>::const_iterator iter = columnsMenuCond.begin(); iter
00456                 != columnsMenuCond.end(); iter++) {
00457             LogTrace("L1GtTriggerMenuConfigOnlineProd") << ( *iter ) << std::endl;
00458 
00459         }
00460         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
00461     }
00462 
00463     l1t::OMDSReader::QueryResults resultsMenuCond = m_omdsReader.basicQueryView(
00464             columnsMenuCond, gtSchema, "L1T_MENU_COND_VIEW",
00465             "L1T_MENU_COND_VIEW.MENU_IMPLEMENTATION", m_omdsReader.singleAttribute(objectKey));
00466 
00467     // check if query was successful is based on size of returned list
00468     // BUT one can have menus w/o conditions - no error for empty list, but a warning!
00469     if (resultsMenuCond.queryFailed()) {
00470         edm::LogWarning("L1-O2O")
00471                 << "Warning: Content of L1T_MENU_COND_VIEW for L1GtTriggerMenu implementation key: "
00472                 << "\n  " << objectKey << "\nis empty!"
00473                 << "\nNo conditions associated to menu are found for this menu.";
00474 
00475     }
00476 
00477     //
00478     TableMenuCond menuCond;
00479     int resultsMenuCondRows = resultsMenuCond.numberRows();
00480 
00481     for (int iRow = 0; iRow < resultsMenuCondRows; ++iRow) {
00482 
00483         for (std::vector<std::string>::const_iterator constIt = columnsMenuCond.begin(); constIt
00484                 != columnsMenuCond.end(); ++constIt) {
00485 
00486             if ( ( *constIt ) == "COND") {
00487                 resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.cond);
00488 
00489             } else if ( ( *constIt ) == "COND_CATEGORY") {
00490                 resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.condCategory);
00491 
00492             } else if ( ( *constIt ) == "COND_TYPE") {
00493                 resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.condType);
00494 
00495             } else if ( ( *constIt ) == "GT_OBJECT_1") {
00496                 resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.gtObject1);
00497 
00498             } else if ( ( *constIt ) == "GT_OBJECT_2") {
00499                 resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.gtObject2);
00500 
00501             } else if ( ( *constIt ) == "COND_GEQ") {
00502                 float condGEqFloat = -1;
00503                 resultsMenuCond.fillVariableFromRow(*constIt, iRow, condGEqFloat);
00504                 menuCond.condGEq = (condGEqFloat > 0.5) ? true : false;
00505 
00506             } else if ( ( *constIt ) == "COUNT_INDEX") {
00507                 resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.countIndex);
00508 
00509             } else if ( ( *constIt ) == "COUNT_THRESHOLD") {
00510                 resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.countThreshold);
00511 
00512             } else if ( ( *constIt ) == "CHARGE_CORRELATION") {
00513                 resultsMenuCond.fillVariableFromRow(
00514                         *constIt, iRow, menuCond.chargeCorrelation);
00515 
00516             } else if ( ( *constIt ) == "OBJECT_PARAMETER_1_FK") {
00517                 resultsMenuCond.fillVariableFromRow(
00518                         *constIt, iRow, menuCond.objectParameter1FK);
00519 
00520             } else if ( ( *constIt ) == "OBJECT_PARAMETER_2_FK") {
00521                 resultsMenuCond.fillVariableFromRow(
00522                         *constIt, iRow, menuCond.objectParameter2FK);
00523 
00524             } else if ( ( *constIt ) == "OBJECT_PARAMETER_3_FK") {
00525                 resultsMenuCond.fillVariableFromRow(
00526                         *constIt, iRow, menuCond.objectParameter3FK);
00527 
00528             } else if ( ( *constIt ) == "OBJECT_PARAMETER_4_FK") {
00529                 resultsMenuCond.fillVariableFromRow(
00530                         *constIt, iRow, menuCond.objectParameter4FK);
00531 
00532             } else if ( ( *constIt ) == "DELTA_ETA_RANGE") {
00533                 resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.deltaEtaRange);
00534 
00535             } else if ( ( *constIt ) == "DELTA_PHI_RANGE") {
00536                 resultsMenuCond.fillVariableFromRow(*constIt, iRow, menuCond.deltaPhiRange);
00537 
00538             } else {
00539                 // do nothing
00540 
00541             }
00542 
00543         }
00544 
00545         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00546             << " COND " << menuCond.cond
00547             << " COND_CATEGORY " << menuCond.condCategory
00548             << " COND_TYPE " << menuCond.condType
00549             << " GT_OBJECT_1 " << menuCond.gtObject1
00550             << " GT_OBJECT_2 " << menuCond.gtObject2
00551             << " COND_GEQ " << menuCond.condGEq << "\n"
00552             << " COUNT_INDEX " << menuCond.countIndex
00553             << " COUNT_THRESHOLD " << menuCond.countThreshold << "\n"
00554             << " CHARGE_CORRELATION " << menuCond.chargeCorrelation << "\n"
00555             << " OBJECT_PARAMETER_1_FK " << menuCond.objectParameter1FK
00556             << " OBJECT_PARAMETER_2_FK " << menuCond.objectParameter2FK
00557             << " OBJECT_PARAMETER_3_FK " << menuCond.objectParameter3FK
00558             << " OBJECT_PARAMETER_4_FK " << menuCond.objectParameter4FK << "\n"
00559             << " DELTA_ETA_RANGE " << menuCond.deltaEtaRange
00560             << " DELTA_PHI_RANGE " << menuCond.deltaPhiRange;
00561 
00562         m_tableMenuCond.push_back(menuCond);
00563 
00564 
00565     }
00566 
00567     if (m_isDebugEnabled) {
00568         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00569             << "\n Number of rows read from L1T_MENU_COND_VIEW: " << resultsMenuCondRows
00570             << std::endl;
00571 
00572     }
00573 
00574     return true;
00575 
00576 }
00577 
00578 // retrieve table with object parameters from DB
00579 bool L1GtTriggerMenuConfigOnlineProd::tableMenuObjectParametersFromDB(
00580         const std::string& gtSchema, const std::string& objectKey) {
00581 
00582     // get the list of object parameters in the menu
00583 
00584     // select * from CMS_GT.L1T_MENU_OP_VIEW
00585     //     where L1T_MENU_OP_VIEW.MENU_IMPLEMENTATION = objectKey
00586 
00587     const std::vector<std::string>& columnsMenuOp = m_omdsReader.columnNamesView(
00588             gtSchema, "L1T_MENU_OP_VIEW");
00589 
00590     if (m_isDebugEnabled) {
00591         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n List of columns in L1T_MENU_OP_VIEW:\n"
00592                 << std::endl;
00593         for (std::vector<std::string>::const_iterator iter = columnsMenuOp.begin(); iter
00594                 != columnsMenuOp.end(); iter++) {
00595             LogTrace("L1GtTriggerMenuConfigOnlineProd") << ( *iter ) << std::endl;
00596 
00597         }
00598         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
00599     }
00600 
00601     l1t::OMDSReader::QueryResults resultsMenuOp = m_omdsReader.basicQueryView(
00602             columnsMenuOp, gtSchema, "L1T_MENU_OP_VIEW", "L1T_MENU_OP_VIEW.MENU_IMPLEMENTATION",
00603             m_omdsReader.singleAttribute(objectKey));
00604 
00605     // check if query was successful is based on size of returned list
00606     // BUT one can have menus w/o object parameters - no error for empty list, but a warning!
00607     if (resultsMenuOp.queryFailed()) {
00608         edm::LogWarning("L1-O2O")
00609                 << "Warning: Content of L1T_MENU_OP_VIEW for L1GtTriggerMenu implementation key: "
00610                 << "\n  " << objectKey << "\nis empty!"
00611                 << "\nNo object parameters associated to menu are found for this menu.";
00612 
00613     }
00614 
00615     TableMenuObjectParameters menuObjectParameters;
00616     int resultsMenuOpRows = resultsMenuOp.numberRows();
00617 
00618     for (int iRow = 0; iRow < resultsMenuOpRows; ++iRow) {
00619 
00620         for (std::vector<std::string>::const_iterator constIt = columnsMenuOp.begin(); constIt
00621                 != columnsMenuOp.end(); ++constIt) {
00622 
00623             if ( ( *constIt ) == "ID") {
00624                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.opId);
00625 
00626             } else if ( ( *constIt ) == "PT_HIGH_THRESHOLD") {
00627                 resultsMenuOp.fillVariableFromRow(
00628                         *constIt, iRow, menuObjectParameters.ptHighThreshold);
00629 
00630             } else if ( ( *constIt ) == "PT_LOW_THRESHOLD") {
00631                 resultsMenuOp.fillVariableFromRow(
00632                         *constIt, iRow, menuObjectParameters.ptLowThreshold);
00633 
00634             } else if ( ( *constIt ) == "ENABLE_MIP") {
00635                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.enableMip);
00636 
00637             } else if ( ( *constIt ) == "ENABLE_ISO") {
00638                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.enableIso);
00639 
00640             } else if ( ( *constIt ) == "REQUEST_ISO") {
00641                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.requestIso);
00642 
00643             } else if ( ( *constIt ) == "ENERGY_OVERFLOW") {
00644                 resultsMenuOp.fillVariableFromRow(
00645                         *constIt, iRow, menuObjectParameters.energyOverflow);
00646 
00647             } else if ( ( *constIt ) == "ET_THRESHOLD") {
00648                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.etThreshold);
00649 
00650             } else if ( ( *constIt ) == "ETA_RANGE") {
00651                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.etaRange);
00652 
00653             } else if ( ( *constIt ) == "PHI_RANGE") {
00654                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.phiRange);
00655 
00656             } else if ( ( *constIt ) == "PHI_LOW") {
00657                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.phiLow);
00658 
00659             } else if ( ( *constIt ) == "PHI_HIGH") {
00660                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.phiHigh);
00661 
00662             } else if ( ( *constIt ) == "QUALITY_RANGE") {
00663                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.qualityRange);
00664 
00665             } else if ( ( *constIt ) == "CHARGE") {
00666                 resultsMenuOp.fillVariableFromRow(*constIt, iRow, menuObjectParameters.charge);
00667 
00668             } else {
00669                 // do nothing
00670 
00671             }
00672 
00673         }
00674 
00675         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00676             << " ID " << menuObjectParameters.opId
00677             << " PT_HIGH_THRESHOLD " << menuObjectParameters.ptHighThreshold
00678             << " PT_LOW_THRESHOLD " << menuObjectParameters.ptLowThreshold
00679             << " ENABLE_MIP " << menuObjectParameters.enableMip
00680             << " ENABLE_ISO " << menuObjectParameters.enableIso
00681             << " REQUEST_ISO " << menuObjectParameters.requestIso
00682             << " ENERGY_OVERFLOW " << menuObjectParameters.energyOverflow
00683             << " ET_THRESHOLD " << menuObjectParameters.etThreshold
00684             << " ETA_RANGE " << menuObjectParameters.etaRange
00685             << " PHI_RANGE " << menuObjectParameters.phiRange
00686             << " PHI_LOW " << menuObjectParameters.phiLow
00687             << " PHI_HIGH " << menuObjectParameters.phiHigh
00688             << " QUALITY_RANGE " << menuObjectParameters.qualityRange
00689             << " CHARGE " << menuObjectParameters.charge
00690             << std::endl;
00691 
00692         m_tableMenuObjectParameters.push_back(menuObjectParameters);
00693     }
00694 
00695     if (m_isDebugEnabled) {
00696         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00697                 << "\n Number of rows read from L1T_MENU_OP_VIEW: " << resultsMenuOpRows
00698                 << std::endl;
00699 
00700     }
00701 
00702     return true;
00703 
00704 }
00705 
00706 // retrieve table with technical triggers from DB
00707 bool L1GtTriggerMenuConfigOnlineProd::tableMenuTechTrigFromDB(
00708         const std::string& gtSchema, const std::string& objectKey) {
00709 
00710     // select * from CMS_GT.L1T_MENU_TECHTRIG_VIEW
00711     //     where L1T_MENU_TECHTRIG_VIEW.MENU_IMPLEMENTATION = objectKey
00712 
00713     const std::vector<std::string>& columnsMenuTechTrig =
00714             m_omdsReader.columnNamesView(gtSchema, "L1T_MENU_TECHTRIG_VIEW");
00715 
00716     if (m_isDebugEnabled) {
00717         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00718                 << "\n List of columns in L1T_MENU_TECHTRIG_VIEW:\n"
00719                 << std::endl;
00720         for (std::vector<std::string>::const_iterator iter =
00721                 columnsMenuTechTrig.begin(); iter != columnsMenuTechTrig.end(); iter++) {
00722             LogTrace("L1GtTriggerMenuConfigOnlineProd") << (*iter) << std::endl;
00723 
00724         }
00725         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n\n" << std::endl;
00726     }
00727 
00728     l1t::OMDSReader::QueryResults resultsMenuTechTrig =
00729             m_omdsReader.basicQueryView(columnsMenuTechTrig, gtSchema,
00730                     "L1T_MENU_TECHTRIG_VIEW",
00731                     "L1T_MENU_TECHTRIG_VIEW.MENU_IMPLEMENTATION",
00732                     m_omdsReader.singleAttribute(objectKey));
00733 
00734     // check if query was successful is based on size of returned list
00735     // BUT one can have menus w/o technical triggers - no error for empty list, but a warning!
00736     if (resultsMenuTechTrig.queryFailed()) {
00737         edm::LogWarning("L1-O2O")
00738                 << "Warning: Content of L1T_MENU_TECHTRIG_VIEW for L1GtTriggerMenu implementation key: "
00739                 << "\n  " << objectKey << "\nis empty!"
00740                 << "\nNo technical triggers are found for this menu.";
00741 
00742     }
00743 
00744     TableMenuTechTrig menuTechTrig;
00745     int resultsMenuTechTrigRows = resultsMenuTechTrig.numberRows();
00746 
00747     for (int iRow = 0; iRow < resultsMenuTechTrigRows; ++iRow) {
00748 
00749         for (std::vector<std::string>::const_iterator constIt =
00750                 columnsMenuTechTrig.begin(); constIt
00751                 != columnsMenuTechTrig.end(); ++constIt) {
00752 
00753             if ((*constIt) == "TECHTRIG_INDEX") {
00754                 resultsMenuTechTrig.fillVariableFromRow(*constIt, iRow,
00755                         menuTechTrig.bitNumberSh);
00756 
00757             } else if ((*constIt) == "NAME") {
00758                 resultsMenuTechTrig.fillVariableFromRow(*constIt, iRow,
00759                         menuTechTrig.techName);
00760 
00761             } else {
00762                 // do nothing
00763 
00764             }
00765 
00766         }
00767 
00768         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "Row  " << iRow
00769                 << ": index = " << menuTechTrig.bitNumberSh << " techName = "
00770                 << menuTechTrig.techName << std::endl;
00771 
00772         m_tableMenuTechTrig.push_back(menuTechTrig);
00773 
00774     }
00775 
00776     if (m_isDebugEnabled) {
00777         LogTrace("L1GtTriggerMenuConfigOnlineProd")
00778                 << "\n Number of rows read from L1T_MENU_TECHTRIG_VIEW: "
00779                 << resultsMenuTechTrigRows << std::endl;
00780 
00781     }
00782 
00783     return true;
00784 
00785 }
00786 
00787 // return for an algorithm with bitNr the mapping between the integer index in logical expression
00788 // and the condition name (FK)
00789 const std::map<int, std::string> L1GtTriggerMenuConfigOnlineProd::condIndexNameMap(
00790         const short bitNr) const {
00791 
00792     std::map<int, std::string> mapIndexName;
00793 
00794     for (std::vector<TableMenuAlgoCond>::const_iterator constIt = m_tableMenuAlgoCond.begin(); constIt
00795             != m_tableMenuAlgoCond.end(); ++constIt) {
00796 
00797         if (bitNr == (*constIt).bitNumberSh) {
00798             mapIndexName[static_cast<int>((*constIt).condIndexF)] = (*constIt).condFK;
00799         }
00800 
00801     }
00802 
00803     if (m_isDebugEnabled) {
00804 
00805         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Bit number : " << bitNr << std::endl;
00806 
00807         for (std::map<int, std::string>::const_iterator constIt = mapIndexName.begin(); constIt
00808                 != mapIndexName.end(); ++constIt) {
00809 
00810             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "  Condition index -> name: "
00811                     << ( ( *constIt ).first ) << " " << ( ( *constIt ).second ) << std::endl;
00812 
00813         }
00814 
00815     }
00816 
00817 
00818     return mapIndexName;
00819 
00820 }
00821 
00822 // convert a logical expression with indices to a logical expression with names
00823 std::string L1GtTriggerMenuConfigOnlineProd::convertLogicalExpression(
00824         const std::string& expressionIndices, const std::map<int, std::string>& mapCondIndexName) const {
00825 
00826     std::string expressionNames;
00827 
00828     L1GtLogicParser parserIndices = L1GtLogicParser(expressionIndices);
00829     parserIndices.convertIntToNameLogicalExpression(mapCondIndexName);
00830     expressionNames = parserIndices.logicalExpression();
00831 
00832     return expressionNames;
00833 
00834 }
00835 
00836 // return the chip number for an algorithm with index bitNumberSh
00837 int L1GtTriggerMenuConfigOnlineProd::chipNumber(short bitNumberSh) const {
00838 
00839     // FIXME get it from Event Setup
00840     const unsigned numberConditionChips = 2;
00841     const unsigned pinsOnConditionChip = 96;
00842     std::vector<int> orderConditionChip;
00843     orderConditionChip.push_back(2);
00844     orderConditionChip.push_back(1);
00845 
00846     int posChip = ( static_cast<unsigned> (bitNumberSh) / pinsOnConditionChip ) + 1;
00847     for (unsigned int iChip = 0; iChip < numberConditionChips; ++iChip) {
00848         if (posChip == orderConditionChip[iChip]) {
00849             return static_cast<int>(iChip);
00850         }
00851     }
00852 
00853     // chip number not found
00854     return -1;
00855 
00856 }
00857 
00858 // build the algorithm map in the menu
00859 void L1GtTriggerMenuConfigOnlineProd::buildAlgorithmMap() {
00860 
00861 
00862      // temporary value
00863     int bitNumber = -1;
00864     std::string logicalExpression;
00865 
00866     // loop over m_tableMenuAlgo
00867     for (std::vector<TableMenuAlgo>::const_iterator constIt = m_tableMenuAlgo.begin(); constIt
00868             != m_tableMenuAlgo.end(); constIt++) {
00869 
00870         bitNumber = static_cast<int> ((*constIt).bitNumberSh);
00871 
00872         const std::map<int, std::string>& condIndexName = condIndexNameMap((*constIt).bitNumberSh);
00873         logicalExpression = convertLogicalExpression((*constIt).logExpression, condIndexName);
00874 
00875         // create a new algorithm and insert it into algorithm map
00876         L1GtAlgorithm alg((*constIt).algName, logicalExpression, bitNumber);
00877         alg.setAlgoAlias((*constIt).algAlias);
00878 
00879         // set algorithm chip number:
00880         int algChipNr = chipNumber((*constIt).bitNumberSh);
00881         alg.setAlgoChipNumber(algChipNr);
00882 
00883         // insert algorithm
00884         m_algorithmMap[(*constIt).algName] = alg;
00885         m_algorithmAliasMap[(*constIt).algAlias] = alg;
00886 
00887     }
00888 
00889 }
00890 
00891 // build the technical trigger map in the menu
00892 void L1GtTriggerMenuConfigOnlineProd::buildTechnicalTriggerMap() {
00893 
00894     // temporary value
00895     int bitNumber = -1;
00896     std::string logicalExpression;
00897 
00898     // loop over m_tableMenuTechTrig
00899     for (std::vector<TableMenuTechTrig>::const_iterator constIt =
00900             m_tableMenuTechTrig.begin(); constIt != m_tableMenuTechTrig.end(); constIt++) {
00901 
00902         bitNumber = static_cast<int> ((*constIt).bitNumberSh);
00903 
00904         // create a new technical trigger and insert it into technical trigger map
00905         // technical triggers have L1GtAlgorithm class
00906         L1GtAlgorithm techTrig((*constIt).techName, logicalExpression, bitNumber);
00907 
00908         // chip number set in constructor to -1 - no meaning for technical triggers
00909 
00910         // insert technical trigger
00911         m_technicalTriggerMap[(*constIt).techName] = techTrig;
00912 
00913         // no alias is defined for technical triggers
00914     }
00915 
00916 }
00917 
00918 
00919 L1GtConditionCategory L1GtTriggerMenuConfigOnlineProd::strToEnumCondCategory(
00920         const std::string& strCategory) {
00921 
00922     if (strCategory == "CondMuon") {
00923         return CondMuon;
00924     } else if (strCategory == "CondCalo") {
00925         return CondCalo;
00926     } else if (strCategory == "CondEnergySum") {
00927         return CondEnergySum;
00928     } else if (strCategory == "CondJetCounts") {
00929         return CondJetCounts;
00930     } else if (strCategory == "CondCorrelation") {
00931         return CondCorrelation;
00932     } else if (strCategory == "CondCastor") {
00933         return CondCastor;
00934     } else if (strCategory == "CondHfBitCounts") {
00935         return CondHfBitCounts;
00936     } else if (strCategory == "CondHfRingEtSums") {
00937         return CondHfRingEtSums;
00938     } else if (strCategory == "CondBptx") {
00939         return CondBptx;
00940     } else if (strCategory == "CondExternal") {
00941         return CondExternal;
00942     } else if (strCategory == "CondNull") {
00943         return CondNull;
00944     } else {
00945         edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
00946                 << "\n Warning: string " << strCategory
00947                 << " not defined. Returning CondNull.\n" << std::endl;
00948         return CondNull;
00949     }
00950 
00951     return CondNull;
00952 
00953 }
00954 
00955 // string to enum L1GtConditionType conversion
00956 L1GtConditionType L1GtTriggerMenuConfigOnlineProd::strToEnumCondType(const std::string& strType) {
00957 
00958     if (strType == "1s") {
00959         return Type1s;
00960     } else if (strType == "2s") {
00961         return Type2s;
00962     } else if (strType == "2wsc") {
00963         return Type2wsc;
00964     } else if (strType == "3s") {
00965         return Type3s;
00966     } else if (strType == "4s") {
00967         return Type4s;
00968     } else if (strType == "ETM") {
00969         return TypeETM;
00970     } else if (strType == "ETT") {
00971         return TypeETT;
00972     } else if (strType == "HTT") {
00973         return TypeHTT;
00974     } else if (strType == "HTM") {
00975         return TypeHTM;
00976     } else if (strType == "JetCounts") {
00977         return TypeJetCounts;
00978     } else if (strType == "Castor") {
00979         return TypeCastor;
00980     } else if (strType == "HfBitCounts") {
00981         return TypeHfBitCounts;
00982     } else if (strType == "HfRingEtSums") {
00983         return TypeHfRingEtSums;
00984     } else if (strType == "Bptx") {
00985         return TypeBptx;
00986     } else if (strType == "TypeExternal") {
00987         return TypeExternal;
00988     } else {
00989         edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
00990                 << "\n Warning: string " << strType
00991                 << " not associated to any L1GtConditionType. Returning TypeNull.\n"
00992                 << std::endl;
00993         return TypeNull;
00994     }
00995 
00996     return TypeNull;
00997 
00998 }
00999 
01000 // string to enum L1GtObject conversion
01001 L1GtObject L1GtTriggerMenuConfigOnlineProd::strToEnumL1GtObject(const std::string& strObject) {
01002 
01003     if (strObject == "Mu") {
01004         return Mu;
01005     } else if (strObject == "NoIsoEG") {
01006         return NoIsoEG;
01007     } else if (strObject == "IsoEG") {
01008         return IsoEG;
01009     } else if (strObject == "CenJet") {
01010         return CenJet;
01011     } else if (strObject == "ForJet") {
01012         return ForJet;
01013     } else if (strObject == "TauJet") {
01014         return TauJet;
01015     } else if (strObject == "ETM") {
01016         return ETM;
01017     } else if (strObject == "ETT") {
01018         return ETT;
01019     } else if (strObject == "HTT") {
01020         return HTT;
01021     } else if (strObject == "HTM") {
01022         return HTM;
01023     } else if (strObject == "JetCounts") {
01024         return JetCounts;
01025     } else if (strObject == "HfBitCounts") {
01026         return HfBitCounts;
01027     } else if (strObject == "HfRingEtSums") {
01028         return HfRingEtSums;
01029     } else if (strObject == "TechTrig") {
01030         return TechTrig;
01031     } else if (strObject == "Castor") {
01032         return Castor;
01033     } else if (strObject == "BPTX") {
01034         return BPTX;
01035     } else if (strObject == "GtExternal") {
01036         return GtExternal;
01037     } else {
01038         edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
01039                 << "\n Warning: string " << strObject
01040                 << " not associated to any L1GtObject. Returning Mu (no Null type).\n"
01041                 << std::endl;
01042         return Mu;
01043     }
01044 
01045     // no null type, so returning Mu - should never arrive here
01046     return Mu;
01047 
01048 }
01049 
01050 void L1GtTriggerMenuConfigOnlineProd::splitHexStringInTwo64bitWords(
01051         const std::string& hexStr, std::string& hex0WordStr, std::string& hex1WordStr) {
01052 
01053     unsigned int lenHexStr = hexStr.length();
01054 
01055     if (lenHexStr < 3) {
01056         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Warning: string " << hexStr
01057                 << " has length less than 3." << "\n Not possible to split it in two 64-bit words."
01058                 << "\n Return two zero strings." << std::endl;
01059         hex0WordStr = "0x0";
01060         hex1WordStr = "0x0";
01061 
01062         return;
01063     }
01064 
01065     unsigned int lenHex = lenHexStr - 2;
01066     unsigned int len0Word = lenHex > 16 ? 16 : lenHex;
01067     unsigned int len1Word = lenHex - len0Word;
01068 
01069     unsigned int pos0Word = lenHexStr - len0Word;
01070     hex0WordStr = "0x" + hexStr.substr(pos0Word, len0Word);
01071 
01072     if (len1Word > 0) {
01073         unsigned int pos1Word = pos0Word - len1Word;
01074         hex1WordStr = "0x" + hexStr.substr(pos1Word, len1Word);
01075     } else {
01076         hex1WordStr = "0x0";
01077     }
01078 }
01079 
01080 // get a list of chip numbers from the m_tableMenuAlgoCond table for a condition
01081 std::list<int> L1GtTriggerMenuConfigOnlineProd::listChipNumber(const std::string& condFK) {
01082 
01083     std::list<int> chipList;
01084 
01085     // loop over m_tableMenuAlgoCond
01086     for (std::vector<TableMenuAlgoCond>::const_iterator constIt = m_tableMenuAlgoCond.begin(); constIt
01087             != m_tableMenuAlgoCond.end(); constIt++) {
01088 
01089         if (condFK == ( *constIt ).condFK) {
01090             int chipNr = chipNumber( ( *constIt ).bitNumberSh);
01091             chipList.push_back(chipNr);
01092         }
01093     }
01094 
01095     return chipList;
01096 
01097 }
01098 
01099 void L1GtTriggerMenuConfigOnlineProd::fillMuonObjectParameter(
01100         const std::string& opFK, L1GtMuonTemplate::ObjectParameter& objPar) {
01101 
01102     // loop over m_tableMenuCond
01103     for (std::vector<TableMenuObjectParameters>::const_iterator constIt =
01104             m_tableMenuObjectParameters.begin(); constIt != m_tableMenuObjectParameters.end(); constIt++) {
01105 
01106         if (opFK == ( *constIt ).opId) {
01107             objPar.ptHighThreshold = static_cast<unsigned int> ( ( *constIt ).ptHighThreshold);
01108             objPar.ptLowThreshold = static_cast<unsigned int> ( ( *constIt ).ptLowThreshold);
01109             objPar.enableMip = static_cast<bool> ( ( *constIt ).enableMip);
01110             objPar.enableIso = static_cast<bool> ( ( *constIt ).enableIso);
01111             objPar.requestIso = static_cast<bool> ( ( *constIt ).requestIso);
01112             objPar.etaRange = lexical_cast_from_hex<unsigned long long>( ( *constIt ).etaRange);
01113             objPar.phiHigh = static_cast<unsigned int> ( ( *constIt ).phiHigh);
01114             objPar.phiLow = static_cast<unsigned int> ( ( *constIt ).phiLow);
01115             objPar.qualityRange = lexical_cast_from_hex<unsigned int>( ( *constIt ).qualityRange);
01116             //objPar.charge = static_cast<unsigned int> ( ( *constIt ).charge);
01117 
01118             // can break after it is found - DB consistency
01119             break;
01120         }
01121     }
01122 
01123 }
01124 
01125 void L1GtTriggerMenuConfigOnlineProd::addMuonCondition(const TableMenuCond& condDB) {
01126 
01127 
01128     L1GtMuonTemplate muonCond(condDB.cond);
01129     muonCond.setCondType(strToEnumCondType(condDB.condType));
01130 
01131     // object types - all muons
01132     int nrObj = muonCond.nrObjects();
01133     std::vector<L1GtObject> objType(nrObj, Mu);
01134     muonCond.setObjectType(objType);
01135 
01136     muonCond.setCondGEq(condDB.condGEq);
01137 
01138     // temporary storage of the parameters
01139     std::vector<L1GtMuonTemplate::ObjectParameter> objParameter(nrObj);
01140 
01141     for (int iObj = 0; iObj < nrObj; ++iObj) {
01142         if (iObj == 0) {
01143             fillMuonObjectParameter(condDB.objectParameter1FK, objParameter[iObj]);
01144         } else if (iObj == 1) {
01145             fillMuonObjectParameter(condDB.objectParameter2FK, objParameter[iObj]);
01146         } else if (iObj == 2) {
01147             fillMuonObjectParameter(condDB.objectParameter3FK, objParameter[iObj]);
01148         } else if (iObj == 3) {
01149             fillMuonObjectParameter(condDB.objectParameter4FK, objParameter[iObj]);
01150         } else {
01151             LogTrace("L1GtTriggerMenuConfigOnlineProd")
01152                     << "\n Warning: number of objects requested " << nrObj
01153                     << " not available in DB." << "\n Maximum 4 object parameters implemented. \n"
01154                     << std::endl;
01155         }
01156     }
01157 
01158     L1GtMuonTemplate::CorrelationParameter corrParameter;
01159     corrParameter.chargeCorrelation = static_cast<unsigned int> (condDB.chargeCorrelation);
01160     if (muonCond.wsc()) {
01161         corrParameter.deltaEtaRange = lexical_cast_from_hex<unsigned long long> (
01162                 condDB.deltaEtaRange);
01163 
01164         std::string word0;
01165         std::string word1;
01166         splitHexStringInTwo64bitWords(condDB.deltaPhiRange, word0, word1);
01167 
01168         corrParameter.deltaPhiRange0Word = lexical_cast_from_hex<unsigned long long> (word0);
01169         corrParameter.deltaPhiRange1Word = lexical_cast_from_hex<unsigned long long> (word1);
01170 
01171         corrParameter.deltaPhiMaxbits = 0; // FIXME check correlations
01172     }
01173 
01174     muonCond.setConditionParameter(objParameter, corrParameter);
01175 
01176     // get chip number list
01177     std::list<int> chipList = listChipNumber(condDB.cond);
01178 
01179     // eliminate duplicates
01180     chipList.sort();
01181     chipList.unique();
01182 
01183     // add the same condition once to every chip where required
01184     for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
01185 
01186         muonCond.setCondChipNr(*itChip);
01187 
01188         // no check for uniqueness - done by DB
01189         ( m_vecMuonTemplate[*itChip] ).push_back(muonCond);
01190 
01191         if (m_isDebugEnabled) {
01192             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition " << ( condDB.cond )
01193                     << " on chip " << ( *itChip ) << "\n " << std::endl;
01194 
01195             LogTrace("L1GtTriggerMenuConfigOnlineProd") << muonCond << "\n" << std::endl;
01196         }
01197     }
01198 
01199 }
01200 
01201 void L1GtTriggerMenuConfigOnlineProd::fillCaloObjectParameter(
01202         const std::string& opFK, L1GtCaloTemplate::ObjectParameter& objPar) {
01203 
01204     // loop over m_tableMenuCond
01205     for (std::vector<TableMenuObjectParameters>::const_iterator constIt =
01206             m_tableMenuObjectParameters.begin(); constIt != m_tableMenuObjectParameters.end(); constIt++) {
01207 
01208         if (opFK == ( *constIt ).opId) {
01209             objPar.etThreshold = static_cast<unsigned int> ( ( *constIt ).etThreshold);
01210             objPar.etaRange = lexical_cast_from_hex<unsigned int> ( ( *constIt ).etaRange);
01211             objPar.phiRange = lexical_cast_from_hex<unsigned int> ( ( *constIt ).phiRange);
01212 
01213             // can break after it is found - DB consistency
01214             break;
01215         }
01216     }
01217 
01218 }
01219 
01220 void L1GtTriggerMenuConfigOnlineProd::addCaloCondition(const TableMenuCond& condDB) {
01221 
01222     L1GtCaloTemplate caloCond(condDB.cond);
01223     caloCond.setCondType(strToEnumCondType(condDB.condType));
01224 
01225     // object types - all have the same type, so reading it for first object is OK
01226     int nrObj = caloCond.nrObjects();
01227 
01228     L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
01229     std::vector<L1GtObject> objType(nrObj, obj);
01230     caloCond.setObjectType(objType);
01231 
01232     caloCond.setCondGEq(condDB.condGEq);
01233 
01234     // temporary storage of the parameters
01235     std::vector<L1GtCaloTemplate::ObjectParameter> objParameter(nrObj);
01236 
01237     for (int iObj = 0; iObj < nrObj; ++iObj) {
01238         if (iObj == 0) {
01239             fillCaloObjectParameter(condDB.objectParameter1FK, objParameter[iObj]);
01240         } else if (iObj == 1) {
01241             fillCaloObjectParameter(condDB.objectParameter2FK, objParameter[iObj]);
01242         } else if (iObj == 2) {
01243             fillCaloObjectParameter(condDB.objectParameter3FK, objParameter[iObj]);
01244         } else if (iObj == 3) {
01245             fillCaloObjectParameter(condDB.objectParameter4FK, objParameter[iObj]);
01246         } else {
01247             LogTrace("L1GtTriggerMenuConfigOnlineProd")
01248                     << "\n Warning: number of objects requested " << nrObj
01249                     << " not available in DB." << "\n Maximum 4 object parameters implemented. \n"
01250                     << std::endl;
01251         }
01252     }
01253 
01254     L1GtCaloTemplate::CorrelationParameter corrParameter;
01255     if (caloCond.wsc()) {
01256         corrParameter.deltaEtaRange = lexical_cast_from_hex<unsigned long long> (
01257                 condDB.deltaEtaRange);
01258 
01259         corrParameter.deltaPhiRange = lexical_cast_from_hex<unsigned long long> (
01260                 condDB.deltaPhiRange);
01261         corrParameter.deltaPhiMaxbits = 0; // FIXME check correlations
01262     }
01263 
01264     caloCond.setConditionParameter(objParameter, corrParameter);
01265 
01266     // get chip number list
01267     std::list<int> chipList = listChipNumber(condDB.cond);
01268 
01269     // eliminate duplicates
01270     chipList.sort();
01271     chipList.unique();
01272 
01273     // add the same condition once to every chip where required
01274     for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
01275 
01276         caloCond.setCondChipNr(*itChip);
01277 
01278         // no check for uniqueness - done by DB
01279         ( m_vecCaloTemplate[*itChip] ).push_back(caloCond);
01280 
01281         if (m_isDebugEnabled) {
01282             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition " << ( condDB.cond )
01283                     << " on chip " << ( *itChip ) << "\n " << std::endl;
01284 
01285             LogTrace("L1GtTriggerMenuConfigOnlineProd") << caloCond << "\n" << std::endl;
01286         }
01287     }
01288 
01289 }
01290 
01291 void L1GtTriggerMenuConfigOnlineProd::fillEnergySumObjectParameter(
01292         const std::string& opFK, L1GtEnergySumTemplate::ObjectParameter& objPar,
01293         const L1GtObject& obj) {
01294 
01295     // loop over m_tableMenuCond
01296     for (std::vector<TableMenuObjectParameters>::const_iterator constIt =
01297             m_tableMenuObjectParameters.begin(); constIt != m_tableMenuObjectParameters.end(); constIt++) {
01298 
01299         if (opFK == ( *constIt ).opId) {
01300             objPar.etThreshold = static_cast<unsigned int> ( ( *constIt ).etThreshold);
01301             objPar.energyOverflow = static_cast<bool> ( ( *constIt ).energyOverflow); // not used
01302 
01303             std::string word0;
01304             std::string word1;
01305             splitHexStringInTwo64bitWords( ( *constIt ).phiRange, word0, word1);
01306 
01307             if (obj == ETM) {
01308                 objPar.phiRange0Word = lexical_cast_from_hex<unsigned long long> (word0);
01309                 objPar.phiRange1Word = lexical_cast_from_hex<unsigned long long> (word1);
01310 
01311             } else if (obj == HTM) {
01312                 objPar.phiRange0Word = lexical_cast_from_hex<unsigned long long> (word0);
01313             }
01314 
01315             // can break after it is found - DB consistency
01316             break;
01317         }
01318     }
01319 
01320 }
01321 
01322 void L1GtTriggerMenuConfigOnlineProd::addEnergySumCondition(const TableMenuCond& condDB) {
01323 
01324     L1GtEnergySumTemplate esumCond(condDB.cond);
01325     esumCond.setCondType(strToEnumCondType(condDB.condType));
01326 
01327     // object types - all energy sums are global - so 1 object
01328     int nrObj = 1;
01329 
01330     L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
01331     std::vector<L1GtObject> objType(nrObj, obj);
01332     esumCond.setObjectType(objType);
01333 
01334     esumCond.setCondGEq(condDB.condGEq);
01335 
01336     // temporary storage of the parameters - no CorrelationParameter
01337     std::vector<L1GtEnergySumTemplate::ObjectParameter> objParameter(nrObj);
01338     fillEnergySumObjectParameter(condDB.objectParameter1FK, objParameter[0], objType[0]);
01339 
01340     esumCond.setConditionParameter(objParameter);
01341 
01342     // get chip number list
01343     std::list<int> chipList = listChipNumber(condDB.cond);
01344 
01345     // eliminate duplicates
01346     chipList.sort();
01347     chipList.unique();
01348 
01349     // add the same condition once to every chip where required
01350     for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
01351 
01352         esumCond.setCondChipNr(*itChip);
01353 
01354         // no check for uniqueness - done by DB
01355         ( m_vecEnergySumTemplate[*itChip] ).push_back(esumCond);
01356 
01357         if (m_isDebugEnabled) {
01358             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition " << ( condDB.cond )
01359                     << " on chip " << ( *itChip ) << "\n " << std::endl;
01360 
01361             LogTrace("L1GtTriggerMenuConfigOnlineProd") << esumCond << "\n" << std::endl;
01362         }
01363     }
01364 
01365 }
01366 
01367 
01368 void L1GtTriggerMenuConfigOnlineProd::addJetCountsCondition(const TableMenuCond& condDB) {
01369 
01370     L1GtJetCountsTemplate jcCond(condDB.cond);
01371     jcCond.setCondType(strToEnumCondType(condDB.condType));
01372 
01373     // object types - jet counts are "global"
01374     int nrObj = 1;
01375 
01376     L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
01377     std::vector<L1GtObject> objType(nrObj, obj);
01378     jcCond.setObjectType(objType);
01379 
01380     jcCond.setCondGEq(condDB.condGEq);
01381 
01382     // temporary storage of the parameters - no CorrelationParameter
01383     // for counts, the DB implementation is without OP, directly in TableMenuCond
01384     std::vector<L1GtJetCountsTemplate::ObjectParameter> objParameter(nrObj);
01385     objParameter.at(0).countIndex = static_cast<unsigned int>(condDB.countIndex);
01386     objParameter.at(0).countThreshold = static_cast<unsigned int>(condDB.countThreshold);
01387     objParameter.at(0).countOverflow = false ; // not used
01388 
01389     jcCond.setConditionParameter(objParameter);
01390 
01391     // get chip number list
01392     std::list<int> chipList = listChipNumber(condDB.cond);
01393 
01394     // eliminate duplicates
01395     chipList.sort();
01396     chipList.unique();
01397 
01398     // add the same condition once to every chip where required
01399     for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
01400 
01401         jcCond.setCondChipNr(*itChip);
01402 
01403         // no check for uniqueness - done by DB
01404         ( m_vecJetCountsTemplate[*itChip] ).push_back(jcCond);
01405 
01406         if (m_isDebugEnabled) {
01407             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition " << ( condDB.cond )
01408                     << " on chip " << ( *itChip ) << "\n " << std::endl;
01409 
01410             LogTrace("L1GtTriggerMenuConfigOnlineProd") << jcCond << "\n" << std::endl;
01411         }
01412     }
01413 
01414 }
01415 
01416 void L1GtTriggerMenuConfigOnlineProd::addHfBitCountsCondition(const TableMenuCond& condDB) {
01417 
01418     L1GtHfBitCountsTemplate countsCond(condDB.cond);
01419     countsCond.setCondType(strToEnumCondType(condDB.condType));
01420 
01421     // object types - HF bit counts are "global"
01422     int nrObj = 1;
01423 
01424     L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
01425     std::vector<L1GtObject> objType(nrObj, obj);
01426     countsCond.setObjectType(objType);
01427 
01428     countsCond.setCondGEq(condDB.condGEq);
01429 
01430     // temporary storage of the parameters - no CorrelationParameter
01431     // for counts, the DB implementation is without OP, directly in TableMenuCond
01432     std::vector<L1GtHfBitCountsTemplate::ObjectParameter> objParameter(nrObj);
01433     objParameter.at(0).countIndex = static_cast<unsigned int>(condDB.countIndex);
01434     objParameter.at(0).countThreshold = static_cast<unsigned int>(condDB.countThreshold);
01435 
01436     countsCond.setConditionParameter(objParameter);
01437 
01438     // get chip number list
01439     std::list<int> chipList = listChipNumber(condDB.cond);
01440 
01441     // eliminate duplicates
01442     chipList.sort();
01443     chipList.unique();
01444 
01445     // add the same condition once to every chip where required
01446     for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
01447 
01448         countsCond.setCondChipNr(*itChip);
01449 
01450         // no check for uniqueness - done by DB
01451         ( m_vecHfBitCountsTemplate[*itChip] ).push_back(countsCond);
01452 
01453         if (m_isDebugEnabled) {
01454             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition " << ( condDB.cond )
01455                     << " on chip " << ( *itChip ) << "\n " << std::endl;
01456 
01457             LogTrace("L1GtTriggerMenuConfigOnlineProd") << countsCond << "\n" << std::endl;
01458         }
01459     }
01460 
01461 }
01462 
01463 void L1GtTriggerMenuConfigOnlineProd::addHfRingEtSumsCondition(const TableMenuCond& condDB) {
01464 
01465     L1GtHfRingEtSumsTemplate esumCond(condDB.cond);
01466     esumCond.setCondType(strToEnumCondType(condDB.condType));
01467 
01468     // object types - HF energy sums are "global"
01469     int nrObj = 1;
01470 
01471     L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
01472     std::vector<L1GtObject> objType(nrObj, obj);
01473     esumCond.setObjectType(objType);
01474 
01475     esumCond.setCondGEq(condDB.condGEq);
01476 
01477     // temporary storage of the parameters - no CorrelationParameter
01478     // for HF energy sums, the DB implementation is without OP, directly in TableMenuCond
01479     std::vector<L1GtHfRingEtSumsTemplate::ObjectParameter> objParameter(nrObj);
01480     objParameter.at(0).etSumIndex = static_cast<unsigned int>(condDB.countIndex);
01481     objParameter.at(0).etSumThreshold = static_cast<unsigned int>(condDB.countThreshold);
01482 
01483     esumCond.setConditionParameter(objParameter);
01484 
01485     // get chip number list
01486     std::list<int> chipList = listChipNumber(condDB.cond);
01487 
01488     // eliminate duplicates
01489     chipList.sort();
01490     chipList.unique();
01491 
01492     // add the same condition once to every chip where required
01493     for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
01494 
01495         esumCond.setCondChipNr(*itChip);
01496 
01497         // no check for uniqueness - done by DB
01498         ( m_vecHfRingEtSumsTemplate[*itChip] ).push_back(esumCond);
01499 
01500         if (m_isDebugEnabled) {
01501             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition " << ( condDB.cond )
01502                     << " on chip " << ( *itChip ) << "\n " << std::endl;
01503 
01504             LogTrace("L1GtTriggerMenuConfigOnlineProd") << esumCond << "\n" << std::endl;
01505         }
01506     }
01507 
01508 }
01509 
01510 void L1GtTriggerMenuConfigOnlineProd::addCastorCondition(const TableMenuCond& condDB) {
01511 
01512     L1GtCastorTemplate castorCond(condDB.cond);
01513     castorCond.setCondType(strToEnumCondType(condDB.condType));
01514 
01515     // object types - logical conditions have no objects associated in GT
01516     // one put however a "Castor" object type
01517     int nrObj = 1;
01518 
01519     L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
01520     std::vector<L1GtObject> objType(nrObj, obj);
01521     castorCond.setObjectType(objType);
01522 
01523     // irrelevant, set to false for completeness
01524     castorCond.setCondGEq(false);
01525 
01526     // logical conditions have no ObjectParameter, no CorrelationParameter
01527 
01528     // get chip number list
01529     std::list<int> chipList = listChipNumber(condDB.cond);
01530 
01531     // eliminate duplicates
01532     chipList.sort();
01533     chipList.unique();
01534 
01535     // add the same condition once to every chip where required
01536     for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
01537 
01538         castorCond.setCondChipNr(*itChip);
01539 
01540         // no check for uniqueness - done by DB
01541         ( m_vecCastorTemplate[*itChip] ).push_back(castorCond);
01542 
01543         if (m_isDebugEnabled) {
01544             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition " << ( condDB.cond )
01545                     << " on chip " << ( *itChip ) << "\n " << std::endl;
01546 
01547             LogTrace("L1GtTriggerMenuConfigOnlineProd") << castorCond << "\n" << std::endl;
01548         }
01549     }
01550 
01551 }
01552 
01553 void L1GtTriggerMenuConfigOnlineProd::addBptxCondition(const TableMenuCond& condDB) {
01554 
01555     L1GtBptxTemplate bptxCond(condDB.cond);
01556     bptxCond.setCondType(strToEnumCondType(condDB.condType));
01557 
01558     // object types - logical conditions have no objects associated in GT
01559     // one put however a "Bptx" object type
01560     int nrObj = 1;
01561 
01562     L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
01563     std::vector<L1GtObject> objType(nrObj, obj);
01564     bptxCond.setObjectType(objType);
01565 
01566     // irrelevant, set to false for completeness
01567     bptxCond.setCondGEq(false);
01568 
01569     // logical conditions have no ObjectParameter, no CorrelationParameter
01570 
01571     // get chip number list
01572     std::list<int> chipList = listChipNumber(condDB.cond);
01573 
01574 
01575 
01576     // eliminate duplicates
01577     chipList.sort();
01578     chipList.unique();
01579 
01580     // add the same condition once to every chip where required
01581     for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
01582 
01583         bptxCond.setCondChipNr(*itChip);
01584 
01585         // no check for uniqueness - done by DB
01586         ( m_vecBptxTemplate[*itChip] ).push_back(bptxCond);
01587 
01588         if (m_isDebugEnabled) {
01589             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition " << ( condDB.cond )
01590                     << " on chip " << ( *itChip ) << "\n " << std::endl;
01591 
01592             LogTrace("L1GtTriggerMenuConfigOnlineProd") << bptxCond << "\n" << std::endl;
01593         }
01594     }
01595 
01596 }
01597 
01598 void L1GtTriggerMenuConfigOnlineProd::addExternalCondition(const TableMenuCond& condDB) {
01599 
01600     L1GtExternalTemplate externalCond(condDB.cond);
01601     externalCond.setCondType(strToEnumCondType(condDB.condType));
01602 
01603     // object types - logical conditions have no objects associated in GT
01604     // one put however a "External" object type
01605     int nrObj = 1;
01606 
01607     L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
01608     std::vector<L1GtObject> objType(nrObj, obj);
01609     externalCond.setObjectType(objType);
01610 
01611     // irrelevant, set to false for completeness
01612     externalCond.setCondGEq(false);
01613 
01614     // logical conditions have no ObjectParameter, no CorrelationParameter
01615 
01616     // get chip number list
01617     std::list<int> chipList = listChipNumber(condDB.cond);
01618 
01619 
01620 
01621     // eliminate duplicates
01622     chipList.sort();
01623     chipList.unique();
01624 
01625     // add the same condition once to every chip where required
01626     for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
01627 
01628         externalCond.setCondChipNr(*itChip);
01629 
01630         // no check for uniqueness - done by DB
01631         ( m_vecExternalTemplate[*itChip] ).push_back(externalCond);
01632 
01633         if (m_isDebugEnabled) {
01634             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition " << ( condDB.cond )
01635                     << " on chip " << ( *itChip ) << "\n " << std::endl;
01636 
01637             LogTrace("L1GtTriggerMenuConfigOnlineProd") << externalCond << "\n" << std::endl;
01638         }
01639     }
01640 
01641 }
01642 
01643 void L1GtTriggerMenuConfigOnlineProd::addCorrelationCondition(const TableMenuCond& condDB) {
01644 
01645     // create a new correlation condition
01646     L1GtCorrelationTemplate correlationCond(condDB.cond);
01647     correlationCond.setCondType(strToEnumCondType(condDB.condType));
01648 
01649     // two objects (for sure) - type taken from DB
01650     const int nrObj = 2;
01651 
01652     std::vector<L1GtObject> objType(nrObj);
01653     L1GtObject obj = strToEnumL1GtObject(condDB.gtObject1);
01654     objType[0] = obj;
01655 
01656     obj = strToEnumL1GtObject(condDB.gtObject2);
01657     objType[1] = obj;
01658 
01659     correlationCond.setObjectType(objType);
01660 
01661     // get chip number list, eliminate duplicates
01662     std::list<int> chipList = listChipNumber(condDB.cond);
01663     chipList.sort();
01664     chipList.unique();
01665 
01666     // temporary vectors for sub-conditions
01667     std::vector<L1GtConditionCategory> subcondCategory(nrObj);
01668     std::vector<int> subcondIndex(nrObj);
01669 
01670     bool wrongSubcondition = false;
01671 
01672     for (int iObj = 0; iObj < nrObj; ++iObj) {
01673 
01674         L1GtObject gtObj = objType[iObj];
01675 
01676         // sub-conditions (all have the same condGEq as the correlation condition).
01677         switch (gtObj) {
01678             case Mu: {
01679                 subcondCategory.push_back(CondMuon);
01680 
01681                 // temporary storage of the parameters
01682                 std::vector<L1GtMuonTemplate::ObjectParameter> objParameter(1);
01683 
01684                 std::string subcondName;
01685                 if (iObj == 0) {
01686                     fillMuonObjectParameter(condDB.objectParameter1FK, objParameter[0]);
01687                     subcondName = condDB.objectParameter1FK;
01688                 } else if (iObj == 1) {
01689                     subcondName = condDB.objectParameter2FK;
01690                     fillMuonObjectParameter(condDB.objectParameter2FK, objParameter[0]);
01691                 }
01692 
01693                 L1GtMuonTemplate::CorrelationParameter corrPar; //  dummy
01694 
01695                 L1GtMuonTemplate subcond(subcondName, Type1s);
01696                 subcond.setCondGEq(condDB.condGEq);
01697                 subcond.setObjectType(std::vector<L1GtObject> (1, gtObj));
01698                 subcond.setConditionParameter(objParameter, corrPar);
01699 
01700                 // add the same sub-condition once to every chip where required
01701                 for (std::list<int>::const_iterator itChip = chipList.begin(); itChip
01702                         != chipList.end(); ++itChip) {
01703 
01704                     subcond.setCondChipNr(*itChip);
01705 
01706                     // index
01707                     subcondIndex[iObj] = ( m_corMuonTemplate[*itChip] ).size() - 1;
01708 
01709                     // no check for uniqueness - done by DB
01710                     ( m_corMuonTemplate[*itChip] ).push_back(subcond);
01711 
01712                     if (m_isDebugEnabled) {
01713                         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition "
01714                                 << ( condDB.cond ) << " on chip " << ( *itChip ) << "\n "
01715                                 << std::endl;
01716 
01717                         LogTrace("L1GtTriggerMenuConfigOnlineProd") << subcond << "\n" << std::endl;
01718                     }
01719                 }
01720 
01721             }
01722                 break;
01723 
01724             case IsoEG:
01725             case NoIsoEG:
01726             case CenJet:
01727             case ForJet:
01728             case TauJet: {
01729 
01730                 subcondCategory.push_back(CondCalo);
01731 
01732                 // temporary storage of the parameters
01733                 std::vector<L1GtCaloTemplate::ObjectParameter> objParameter(1);
01734 
01735                 std::string subcondName;
01736                 if (iObj == 0) {
01737                     fillCaloObjectParameter(condDB.objectParameter1FK, objParameter[0]);
01738                     subcondName = condDB.objectParameter1FK;
01739                 } else if (iObj == 1) {
01740                     subcondName = condDB.objectParameter2FK;
01741                     fillCaloObjectParameter(condDB.objectParameter2FK, objParameter[0]);
01742                 }
01743 
01744                 L1GtCaloTemplate::CorrelationParameter corrPar; //  dummy
01745 
01746                 L1GtCaloTemplate subcond(subcondName, Type1s);
01747                 subcond.setCondGEq(condDB.condGEq);
01748                 subcond.setObjectType(std::vector<L1GtObject> (1, gtObj));
01749                 subcond.setConditionParameter(objParameter, corrPar);
01750 
01751                 // add the same sub-condition once to every chip where required
01752                 for (std::list<int>::const_iterator itChip = chipList.begin(); itChip
01753                         != chipList.end(); ++itChip) {
01754 
01755                     subcond.setCondChipNr(*itChip);
01756 
01757                     // index
01758                     subcondIndex[iObj] = ( m_corCaloTemplate[*itChip] ).size() - 1;
01759 
01760                     // no check for uniqueness - done by DB
01761                     ( m_corCaloTemplate[*itChip] ).push_back(subcond);
01762 
01763                     if (m_isDebugEnabled) {
01764                         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition "
01765                                 << ( condDB.cond ) << " on chip " << ( *itChip ) << "\n "
01766                                 << std::endl;
01767 
01768                         LogTrace("L1GtTriggerMenuConfigOnlineProd") << subcond << "\n" << std::endl;
01769                     }
01770                 }
01771             }
01772                 break;
01773 
01774             case ETM:
01775             case HTM: {
01776 
01777                 subcondCategory.push_back(CondEnergySum);
01778 
01779                 // temporary storage of the parameters
01780                 std::vector<L1GtEnergySumTemplate::ObjectParameter> objParameter(1);
01781 
01782                 std::string subcondName;
01783                 if (iObj == 0) {
01784                     fillEnergySumObjectParameter(condDB.objectParameter1FK, objParameter[0], gtObj);
01785                     subcondName = condDB.objectParameter1FK;
01786                 } else if (iObj == 1) {
01787                     subcondName = condDB.objectParameter2FK;
01788                     fillEnergySumObjectParameter(condDB.objectParameter2FK, objParameter[0], gtObj);
01789                 }
01790 
01791                 L1GtConditionType condType;
01792 
01793                 switch (gtObj) {
01794                     case ETM: {
01795                         condType = TypeETM;
01796                     }
01797                         break;
01798                     case HTM: {
01799                         condType = TypeHTM;
01800                     }
01801                         break;
01802                     default: {
01803                         edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
01804                                 << "\n Warning: wrong L1GtConditionType "
01805                                 << gtObj << std::endl;
01806 
01807                     }
01808                         break;
01809                 }
01810 
01811                 L1GtEnergySumTemplate subcond(subcondName, condType);
01812                 subcond.setCondGEq(condDB.condGEq);
01813                 subcond.setObjectType(std::vector<L1GtObject> (1, gtObj));
01814                 subcond.setConditionParameter(objParameter);
01815 
01816                 // add the same sub-condition once to every chip where required
01817                 for (std::list<int>::const_iterator itChip = chipList.begin(); itChip
01818                         != chipList.end(); ++itChip) {
01819 
01820                     subcond.setCondChipNr(*itChip);
01821 
01822                     // index
01823                     subcondIndex[iObj] = ( m_corEnergySumTemplate[*itChip] ).size() - 1;
01824 
01825                     // no check for uniqueness - done by DB
01826                     ( m_corEnergySumTemplate[*itChip] ).push_back(subcond);
01827 
01828                     if (m_isDebugEnabled) {
01829                         LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition "
01830                                 << ( condDB.cond ) << " on chip " << ( *itChip ) << "\n "
01831                                 << std::endl;
01832 
01833                         LogTrace("L1GtTriggerMenuConfigOnlineProd") << subcond << "\n" << std::endl;
01834                     }
01835                 }
01836             }
01837                 break;
01838             case ETT:
01839             case HTT:
01840             case JetCounts:
01841             case HfBitCounts:
01842             case HfRingEtSums:
01843             case Castor:
01844             case BPTX:
01845             case GtExternal:
01846             case TechTrig: {
01847                 wrongSubcondition = true;
01848                 edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
01849                         << "\n Warning: correlation condition "
01850                         << (condDB.cond)
01851                         << " with invalid sub-condition object type " << gtObj
01852                         << "\n Condition ignored!" << std::endl;
01853             }
01854             default: {
01855                 wrongSubcondition = true;
01856                 edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
01857                         << "\n Warning: correlation condition "
01858                         << (condDB.cond)
01859                         << " with invalid sub-condition object type " << gtObj
01860                         << "\n Condition ignored!" << std::endl;
01861 
01862                 //
01863 
01864             }
01865                 break;
01866         }
01867 
01868     }
01869 
01870     if (wrongSubcondition) {
01871         edm::LogWarning("L1GtTriggerMenuConfigOnlineProd")
01872                 << "\n Warning: wrong sub-condition for correlation condition "
01873                 << (condDB.cond)
01874                 << "\n Condition not inserted in menu. \n A sub-condition may be left in the menu"
01875                 << std::endl;
01876         return;
01877 
01878     }
01879 
01880     // get the correlation parameters for the correlation condition (std::string)
01881     L1GtCorrelationTemplate::CorrelationParameter corrParameter;
01882     corrParameter.deltaEtaRange = condDB.deltaEtaRange;
01883     corrParameter.deltaPhiRange = condDB.deltaPhiRange;
01884 
01885     // set condition categories
01886     correlationCond.setCond0Category(subcondCategory[0]);
01887     correlationCond.setCond1Category(subcondCategory[1]);
01888 
01889     // set condition indices in correlation vector
01890     correlationCond.setCond0Index(subcondIndex[0]);
01891     correlationCond.setCond1Index(subcondIndex[1]);
01892 
01893     // set correlation parameter
01894     corrParameter.deltaPhiMaxbits = 0; //  TODO
01895     correlationCond.setCorrelationParameter(corrParameter);
01896 
01897 
01898     // add the same condition once to every chip where required
01899     for (std::list<int>::const_iterator itChip = chipList.begin(); itChip != chipList.end(); ++itChip) {
01900 
01901         correlationCond.setCondChipNr(*itChip);
01902 
01903         // no check for uniqueness - done by DB
01904         ( m_vecCorrelationTemplate[*itChip] ).push_back(correlationCond);
01905 
01906         if (m_isDebugEnabled) {
01907             LogTrace("L1GtTriggerMenuConfigOnlineProd") << "\n Adding condition " << ( condDB.cond )
01908                     << " on chip " << ( *itChip ) << "\n " << std::endl;
01909 
01910             LogTrace("L1GtTriggerMenuConfigOnlineProd") << correlationCond << "\n" << std::endl;
01911         }
01912     }
01913 
01914 }
01915 
01916 
01917 
01918 // add the conditions from a menu to the corresponding list
01919 void L1GtTriggerMenuConfigOnlineProd::addConditions() {
01920 
01921     // loop over m_tableMenuCond
01922     for (std::vector<TableMenuCond>::const_iterator constIt = m_tableMenuCond.begin(); constIt
01923             != m_tableMenuCond.end(); constIt++) {
01924 
01925         L1GtConditionCategory conCategory = strToEnumCondCategory((*constIt).condCategory);
01926 
01927         switch (conCategory) {
01928             case CondMuon: {
01929 
01930                 addMuonCondition(*constIt);
01931 
01932             }
01933                 break;
01934             case CondCalo: {
01935 
01936                 addCaloCondition(*constIt);
01937 
01938             }
01939                 break;
01940             case CondEnergySum: {
01941 
01942                 addEnergySumCondition(*constIt);
01943 
01944             }
01945                 break;
01946             case CondJetCounts: {
01947                 addJetCountsCondition(*constIt);
01948 
01949             }
01950                 break;
01951             case CondHfBitCounts: {
01952                 addHfBitCountsCondition(*constIt);
01953 
01954             }
01955                 break;
01956             case CondHfRingEtSums: {
01957                 addHfRingEtSumsCondition(*constIt);
01958 
01959             }
01960                 break;
01961             case CondCastor: {
01962 
01963                 addCastorCondition(*constIt);
01964 
01965             }
01966                 break;
01967             case CondBptx: {
01968 
01969                 addBptxCondition(*constIt);
01970 
01971             }
01972                 break;
01973             case CondExternal: {
01974 
01975                 addExternalCondition(*constIt);
01976 
01977             }
01978                 break;
01979             case CondCorrelation: {
01980 
01981                 addCorrelationCondition(*constIt);
01982 
01983             }
01984                 break;
01985             case CondNull: {
01986 
01987                 // do nothing
01988 
01989             }
01990                 break;
01991             default: {
01992 
01993                 // do nothing
01994 
01995             }
01996                 break;
01997         }
01998 
01999     }
02000 
02001 }
02002 
02003 
02004 DEFINE_FWK_EVENTSETUP_MODULE( L1GtTriggerMenuConfigOnlineProd);