Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**
0002  * \class L1GtParametersConfigOnlineProd
0003  *
0004  *
0005  * Description: online producer for L1GtParameters.
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/L1GtParametersConfigOnlineProd.h"
0017 
0018 // user include files
0019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0020 
0021 // constructor
0022 L1GtParametersConfigOnlineProd::L1GtParametersConfigOnlineProd(const edm::ParameterSet& parSet)
0023     : L1ConfigOnlineProdBase<L1GtParametersRcd, L1GtParameters>(parSet) {
0024   // empty
0025 }
0026 
0027 // destructor
0028 L1GtParametersConfigOnlineProd::~L1GtParametersConfigOnlineProd() {
0029   // empty
0030 }
0031 
0032 // public methods
0033 
0034 std::unique_ptr<L1GtParameters> L1GtParametersConfigOnlineProd::newObject(const std::string& objectKey) {
0035   auto pL1GtParameters = std::make_unique<L1GtParameters>();
0036 
0037   // l1GtParameters: parameters in table GTFE_SETUP_FK
0038 
0039   const std::string gtSchema = "CMS_GT";
0040 
0041   // SQL query:
0042   //   SELECT EVM_INCLUDE_TCS,
0043   //          EVM_INCLUDE_FDL,
0044   //          DAQ_INCLUDE_FDL,
0045   //          DAQ_INCLUDE_PSB0,
0046   //          DAQ_INCLUDE_PSB1,
0047   //          DAQ_INCLUDE_PSB2,
0048   //          DAQ_INCLUDE_PSB3,
0049   //          DAQ_INCLUDE_PSB4,
0050   //          DAQ_INCLUDE_PSB5,
0051   //          DAQ_INCLUDE_PSB6,
0052   //          DAQ_INCLUDE_GMT,
0053   //          DAQ_INCLUDE_TIM,
0054   //          DAQ_NB_BC_PER_EVENT_FDL,
0055   //          BST_DATA_NB_BYTES
0056   //   FROM CMS_GT.GT_GTFE_SETUP
0057   //   WHERE GT_GTFE_SETUP.ID = objectKey
0058 
0059   std::vector<std::string> columns;
0060   columns.push_back("EVM_INCLUDE_TCS");
0061   columns.push_back("EVM_INCLUDE_FDL");
0062   columns.push_back("DAQ_INCLUDE_FDL");
0063   columns.push_back("DAQ_INCLUDE_PSB0");
0064   columns.push_back("DAQ_INCLUDE_PSB1");
0065   columns.push_back("DAQ_INCLUDE_PSB2");
0066   columns.push_back("DAQ_INCLUDE_PSB3");
0067   columns.push_back("DAQ_INCLUDE_PSB4");
0068   columns.push_back("DAQ_INCLUDE_PSB5");
0069   columns.push_back("DAQ_INCLUDE_PSB6");
0070   columns.push_back("DAQ_INCLUDE_GMT");
0071   columns.push_back("DAQ_INCLUDE_TIM");
0072   columns.push_back("DAQ_NB_BC_PER_EVENT_FDL");
0073   columns.push_back("DAQ_NB_BC_PER_EVENT_PSB0");
0074   columns.push_back("DAQ_NB_BC_PER_EVENT_PSB1");
0075   columns.push_back("DAQ_NB_BC_PER_EVENT_PSB2");
0076   columns.push_back("DAQ_NB_BC_PER_EVENT_PSB3");
0077   columns.push_back("DAQ_NB_BC_PER_EVENT_PSB4");
0078   columns.push_back("DAQ_NB_BC_PER_EVENT_PSB5");
0079   columns.push_back("DAQ_NB_BC_PER_EVENT_PSB6");
0080   columns.push_back("DAQ_NB_BC_PER_EVENT_GMT");
0081   columns.push_back("DAQ_NB_BC_PER_EVENT_TIM");
0082   columns.push_back("BST_DATA_NB_BYTES");
0083 
0084   l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(
0085       columns, gtSchema, "GT_GTFE_SETUP", "GT_GTFE_SETUP.ID", m_omdsReader.singleAttribute(objectKey));
0086 
0087   // check if query was successful
0088   if (results.queryFailed()) {
0089     edm::LogError("L1-O2O") << "Problem with L1GtParameters key:" << objectKey;
0090     return pL1GtParameters;
0091   }
0092 
0093   bool activeBoardsEvmTCS = false;
0094   results.fillVariable("EVM_INCLUDE_TCS", activeBoardsEvmTCS);
0095 
0096   bool activeBoardsEvmFDL = false;
0097   results.fillVariable("EVM_INCLUDE_FDL", activeBoardsEvmFDL);
0098 
0099   bool activeBoardsDaqFDL = false;
0100   results.fillVariable("DAQ_INCLUDE_FDL", activeBoardsDaqFDL);
0101 
0102   bool activeBoardsDaqPSB0 = false;
0103   results.fillVariable("DAQ_INCLUDE_PSB0", activeBoardsDaqPSB0);
0104 
0105   bool activeBoardsDaqPSB1 = false;
0106   results.fillVariable("DAQ_INCLUDE_PSB1", activeBoardsDaqPSB1);
0107 
0108   bool activeBoardsDaqPSB2 = false;
0109   results.fillVariable("DAQ_INCLUDE_PSB2", activeBoardsDaqPSB2);
0110 
0111   bool activeBoardsDaqPSB3 = false;
0112   results.fillVariable("DAQ_INCLUDE_PSB3", activeBoardsDaqPSB3);
0113 
0114   bool activeBoardsDaqPSB4;
0115   results.fillVariable("DAQ_INCLUDE_PSB4", activeBoardsDaqPSB4);
0116 
0117   bool activeBoardsDaqPSB5 = false;
0118   results.fillVariable("DAQ_INCLUDE_PSB5", activeBoardsDaqPSB5);
0119 
0120   bool activeBoardsDaqPSB6;
0121   results.fillVariable("DAQ_INCLUDE_PSB6", activeBoardsDaqPSB6);
0122 
0123   bool activeBoardsDaqGMT;
0124   results.fillVariable("DAQ_INCLUDE_GMT", activeBoardsDaqGMT);
0125 
0126   bool activeBoardsDaqTIM = false;
0127   results.fillVariable("DAQ_INCLUDE_TIM", activeBoardsDaqTIM);
0128 
0129   std::string totalBxInEventStr;
0130   results.fillVariable("DAQ_NB_BC_PER_EVENT_FDL", totalBxInEventStr);
0131 
0132   //
0133   std::string daqNrBxBoardStrFDL;
0134   results.fillVariable("DAQ_NB_BC_PER_EVENT_FDL", daqNrBxBoardStrFDL);
0135 
0136   std::string daqNrBxBoardStrPSB0;
0137   results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB0", daqNrBxBoardStrPSB0);
0138 
0139   std::string daqNrBxBoardStrPSB1;
0140   results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB1", daqNrBxBoardStrPSB1);
0141 
0142   std::string daqNrBxBoardStrPSB2;
0143   results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB2", daqNrBxBoardStrPSB2);
0144 
0145   std::string daqNrBxBoardStrPSB3;
0146   results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB3", daqNrBxBoardStrPSB3);
0147 
0148   std::string daqNrBxBoardStrPSB4;
0149   results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB4", daqNrBxBoardStrPSB4);
0150 
0151   std::string daqNrBxBoardStrPSB5;
0152   results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB5", daqNrBxBoardStrPSB5);
0153 
0154   std::string daqNrBxBoardStrPSB6;
0155   results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB6", daqNrBxBoardStrPSB6);
0156 
0157   std::string daqNrBxBoardStrGMT;
0158   results.fillVariable("DAQ_NB_BC_PER_EVENT_GMT", daqNrBxBoardStrGMT);
0159 
0160   std::string daqNrBxBoardStrTIM;
0161   results.fillVariable("DAQ_NB_BC_PER_EVENT_TIM", daqNrBxBoardStrTIM);
0162 
0163   std::string bstLengthBytesStr;
0164   results.fillVariable("BST_DATA_NB_BYTES", bstLengthBytesStr);
0165 
0166   // fill the record
0167 
0168   // total Bx's in the event
0169   int totalBxInEventVal = std::stoi(totalBxInEventStr);
0170   pL1GtParameters->setGtTotalBxInEvent(totalBxInEventVal);
0171 
0172   // FIXME: need board maps in DB, with active bit number...
0173   //        now, they are hardwired
0174 
0175   // get the mapping of boards to active bits
0176 
0177   // active boards in the L1 DAQ record & number of BXs per board
0178   uint16_t daqActiveBoardsVal = 0;
0179 
0180   int daqActiveBoardsLength = 16;  // ...hard...
0181   std::vector<int> daqNrBxBoard(daqActiveBoardsLength, 0);
0182 
0183   int iActiveBit = 0;
0184   if (activeBoardsDaqFDL) {
0185     daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
0186   }
0187   daqNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrFDL);
0188 
0189   iActiveBit = 1;
0190   if (activeBoardsDaqPSB0) {
0191     daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
0192   }
0193   daqNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrPSB0);
0194 
0195   iActiveBit = 2;
0196   if (activeBoardsDaqPSB1) {
0197     daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
0198   }
0199   daqNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrPSB1);
0200 
0201   iActiveBit = 3;
0202   if (activeBoardsDaqPSB2) {
0203     daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
0204   }
0205   daqNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrPSB2);
0206 
0207   iActiveBit = 4;
0208   if (activeBoardsDaqPSB3) {
0209     daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
0210   }
0211   daqNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrPSB3);
0212 
0213   iActiveBit = 5;
0214   if (activeBoardsDaqPSB4) {
0215     daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
0216   }
0217   daqNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrPSB4);
0218 
0219   iActiveBit = 6;
0220   if (activeBoardsDaqPSB5) {
0221     daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
0222   }
0223   daqNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrPSB5);
0224 
0225   iActiveBit = 7;
0226   if (activeBoardsDaqPSB6) {
0227     daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
0228   }
0229   daqNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrPSB6);
0230 
0231   iActiveBit = 8;
0232   if (activeBoardsDaqGMT) {
0233     daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
0234   }
0235   daqNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrGMT);
0236 
0237   // FIXME fix TIM active bit
0238   //iActiveBit = 9;
0239   //if (activeBoardsDaqTIM) {
0240   //    daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
0241   //}
0242   //daqNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrTIM);
0243 
0244   // active boards in the L1 EVM record
0245   uint16_t evmActiveBoardsVal = 0;
0246 
0247   int evmActiveBoardsLength = 16;  // ...hard...
0248   std::vector<int> evmNrBxBoard(evmActiveBoardsLength, 0);
0249 
0250   iActiveBit = 0;
0251   if (activeBoardsEvmTCS) {
0252     evmActiveBoardsVal = evmActiveBoardsVal | (1 << iActiveBit);
0253   }
0254   // always 1 TCS payload - hardcoded
0255   evmNrBxBoard.at(iActiveBit) = 1;
0256 
0257   iActiveBit = 1;
0258   if (activeBoardsEvmFDL) {
0259     evmActiveBoardsVal = evmActiveBoardsVal | (1 << iActiveBit);
0260   }
0261   // FDL must have the same length in EVM and DAQ
0262   evmNrBxBoard.at(iActiveBit) = std::stoi(daqNrBxBoardStrFDL);
0263 
0264   //
0265   pL1GtParameters->setGtDaqActiveBoards(daqActiveBoardsVal);
0266   pL1GtParameters->setGtEvmActiveBoards(evmActiveBoardsVal);
0267   pL1GtParameters->setGtDaqNrBxBoard(daqNrBxBoard);
0268   pL1GtParameters->setGtEvmNrBxBoard(evmNrBxBoard);
0269 
0270   //
0271   unsigned int bstLengthBytesVal = std::stoul(bstLengthBytesStr);
0272   pL1GtParameters->setGtBstLengthBytes(bstLengthBytesVal);
0273 
0274   if (edm::isDebugEnabled()) {
0275     std::ostringstream myCoutStream;
0276     pL1GtParameters->print(myCoutStream);
0277     LogTrace("L1GtParametersConfigOnlineProd") << "\nThe following L1GtParameters record was read from OMDS: \n"
0278                                                << myCoutStream.str() << "\n"
0279                                                << std::endl;
0280   }
0281 
0282   return pL1GtParameters;
0283 }
0284 
0285 DEFINE_FWK_EVENTSETUP_MODULE(L1GtParametersConfigOnlineProd);