CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/L1TriggerConfig/L1GtConfigProducers/src/L1GtParametersConfigOnlineProd.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtParametersConfigOnlineProd.h"
00019 
00020 // system include files
00021 #include "boost/lexical_cast.hpp"
00022 
00023 // user include files
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025 
00026 // constructor
00027 L1GtParametersConfigOnlineProd::L1GtParametersConfigOnlineProd(const edm::ParameterSet& parSet) :
00028     L1ConfigOnlineProdBase<L1GtParametersRcd, L1GtParameters> (parSet) {
00029 
00030     // empty
00031 
00032 }
00033 
00034 // destructor
00035 L1GtParametersConfigOnlineProd::~L1GtParametersConfigOnlineProd() {
00036 
00037     // empty
00038 
00039 }
00040 
00041 // public methods
00042 
00043 boost::shared_ptr<L1GtParameters> L1GtParametersConfigOnlineProd::newObject(
00044         const std::string& objectKey) {
00045 
00046     // shared pointer for L1GtParameters
00047     boost::shared_ptr<L1GtParameters> pL1GtParameters = boost::shared_ptr<L1GtParameters>(
00048             new L1GtParameters());
00049 
00050     // l1GtParameters: parameters in table GTFE_SETUP_FK
00051 
00052     const std::string gtSchema = "CMS_GT";
00053 
00054     // SQL query:
00055     //   SELECT EVM_INCLUDE_TCS,
00056     //          EVM_INCLUDE_FDL,
00057     //          DAQ_INCLUDE_FDL,
00058     //          DAQ_INCLUDE_PSB0,
00059     //          DAQ_INCLUDE_PSB1,
00060     //          DAQ_INCLUDE_PSB2,
00061     //          DAQ_INCLUDE_PSB3,
00062     //          DAQ_INCLUDE_PSB4,
00063     //          DAQ_INCLUDE_PSB5,
00064     //          DAQ_INCLUDE_PSB6,
00065     //          DAQ_INCLUDE_GMT,
00066     //          DAQ_INCLUDE_TIM,
00067     //          DAQ_NB_BC_PER_EVENT_FDL,
00068     //          BST_DATA_NB_BYTES
00069     //   FROM CMS_GT.GT_GTFE_SETUP
00070     //   WHERE GT_GTFE_SETUP.ID = objectKey
00071 
00072     std::vector<std::string> columns;
00073     columns.push_back("EVM_INCLUDE_TCS");
00074     columns.push_back("EVM_INCLUDE_FDL");
00075     columns.push_back("DAQ_INCLUDE_FDL");
00076     columns.push_back("DAQ_INCLUDE_PSB0");
00077     columns.push_back("DAQ_INCLUDE_PSB1");
00078     columns.push_back("DAQ_INCLUDE_PSB2");
00079     columns.push_back("DAQ_INCLUDE_PSB3");
00080     columns.push_back("DAQ_INCLUDE_PSB4");
00081     columns.push_back("DAQ_INCLUDE_PSB5");
00082     columns.push_back("DAQ_INCLUDE_PSB6");
00083     columns.push_back("DAQ_INCLUDE_GMT");
00084     columns.push_back("DAQ_INCLUDE_TIM");
00085     columns.push_back("DAQ_NB_BC_PER_EVENT_FDL");
00086     columns.push_back("DAQ_NB_BC_PER_EVENT_PSB0");
00087     columns.push_back("DAQ_NB_BC_PER_EVENT_PSB1");
00088     columns.push_back("DAQ_NB_BC_PER_EVENT_PSB2");
00089     columns.push_back("DAQ_NB_BC_PER_EVENT_PSB3");
00090     columns.push_back("DAQ_NB_BC_PER_EVENT_PSB4");
00091     columns.push_back("DAQ_NB_BC_PER_EVENT_PSB5");
00092     columns.push_back("DAQ_NB_BC_PER_EVENT_PSB6");
00093     columns.push_back("DAQ_NB_BC_PER_EVENT_GMT");
00094     columns.push_back("DAQ_NB_BC_PER_EVENT_TIM");
00095     columns.push_back("BST_DATA_NB_BYTES");
00096 
00097 
00098     l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(
00099             columns, gtSchema, "GT_GTFE_SETUP", "GT_GTFE_SETUP.ID", m_omdsReader.singleAttribute(
00100                     objectKey));
00101 
00102     // check if query was successful
00103     if (results.queryFailed()) {
00104         edm::LogError("L1-O2O") << "Problem with L1GtParameters key:" << objectKey;
00105         return pL1GtParameters;
00106     }
00107 
00108     bool activeBoardsEvmTCS = false;
00109     results.fillVariable("EVM_INCLUDE_TCS", activeBoardsEvmTCS);
00110 
00111     bool activeBoardsEvmFDL = false;
00112     results.fillVariable("EVM_INCLUDE_FDL", activeBoardsEvmFDL);
00113 
00114     bool activeBoardsDaqFDL = false;
00115     results.fillVariable("DAQ_INCLUDE_FDL", activeBoardsDaqFDL);
00116 
00117     bool activeBoardsDaqPSB0 = false;
00118     results.fillVariable("DAQ_INCLUDE_PSB0", activeBoardsDaqPSB0);
00119 
00120     bool activeBoardsDaqPSB1 = false;
00121     results.fillVariable("DAQ_INCLUDE_PSB1", activeBoardsDaqPSB1);
00122 
00123     bool activeBoardsDaqPSB2 = false;
00124     results.fillVariable("DAQ_INCLUDE_PSB2", activeBoardsDaqPSB2);
00125 
00126     bool activeBoardsDaqPSB3 = false;
00127     results.fillVariable("DAQ_INCLUDE_PSB3", activeBoardsDaqPSB3);
00128 
00129     bool activeBoardsDaqPSB4;
00130     results.fillVariable("DAQ_INCLUDE_PSB4", activeBoardsDaqPSB4);
00131 
00132     bool activeBoardsDaqPSB5 = false;
00133     results.fillVariable("DAQ_INCLUDE_PSB5", activeBoardsDaqPSB5);
00134 
00135     bool activeBoardsDaqPSB6;
00136     results.fillVariable("DAQ_INCLUDE_PSB6", activeBoardsDaqPSB6);
00137 
00138     bool activeBoardsDaqGMT;
00139     results.fillVariable("DAQ_INCLUDE_GMT", activeBoardsDaqGMT);
00140 
00141     bool activeBoardsDaqTIM = false;
00142     results.fillVariable("DAQ_INCLUDE_TIM", activeBoardsDaqTIM);
00143 
00144     std::string totalBxInEventStr;
00145     results.fillVariable("DAQ_NB_BC_PER_EVENT_FDL", totalBxInEventStr);
00146 
00147     //
00148     std::string daqNrBxBoardStrFDL;
00149     results.fillVariable("DAQ_NB_BC_PER_EVENT_FDL", daqNrBxBoardStrFDL);
00150 
00151     std::string daqNrBxBoardStrPSB0;
00152     results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB0", daqNrBxBoardStrPSB0);
00153 
00154     std::string daqNrBxBoardStrPSB1;
00155     results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB1", daqNrBxBoardStrPSB1);
00156 
00157     std::string daqNrBxBoardStrPSB2;
00158     results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB2", daqNrBxBoardStrPSB2);
00159 
00160     std::string daqNrBxBoardStrPSB3;
00161     results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB3", daqNrBxBoardStrPSB3);
00162 
00163     std::string daqNrBxBoardStrPSB4;
00164     results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB4", daqNrBxBoardStrPSB4);
00165 
00166     std::string daqNrBxBoardStrPSB5;
00167     results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB5", daqNrBxBoardStrPSB5);
00168 
00169     std::string daqNrBxBoardStrPSB6;
00170     results.fillVariable("DAQ_NB_BC_PER_EVENT_PSB6", daqNrBxBoardStrPSB6);
00171 
00172     std::string daqNrBxBoardStrGMT;
00173     results.fillVariable("DAQ_NB_BC_PER_EVENT_GMT", daqNrBxBoardStrGMT);
00174 
00175     std::string daqNrBxBoardStrTIM;
00176     results.fillVariable("DAQ_NB_BC_PER_EVENT_TIM", daqNrBxBoardStrTIM);
00177 
00178     std::string bstLengthBytesStr;
00179     results.fillVariable("BST_DATA_NB_BYTES", bstLengthBytesStr);
00180 
00181     // fill the record
00182 
00183     // total Bx's in the event
00184     int totalBxInEventVal = boost::lexical_cast<int>(totalBxInEventStr);
00185     pL1GtParameters->setGtTotalBxInEvent(totalBxInEventVal);
00186 
00187     // FIXME: need board maps in DB, with active bit number...
00188     //        now, they are hardwired
00189 
00190     // get the mapping of boards to active bits
00191 
00192     // active boards in the L1 DAQ record & number of BXs per board
00193     boost::uint16_t daqActiveBoardsVal = 0;
00194 
00195     int daqActiveBoardsLength = 16; // ...hard...
00196     std::vector<int> daqNrBxBoard(daqActiveBoardsLength, 0);
00197 
00198     int iActiveBit = 0;
00199     if (activeBoardsDaqFDL) {
00200         daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
00201     }
00202     daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrFDL);
00203 
00204     iActiveBit = 1;
00205     if (activeBoardsDaqPSB0) {
00206         daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
00207     }
00208     daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB0);
00209 
00210     iActiveBit = 2;
00211     if (activeBoardsDaqPSB1) {
00212         daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
00213     }
00214     daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB1);
00215 
00216     iActiveBit = 3;
00217     if (activeBoardsDaqPSB2) {
00218         daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
00219     }
00220     daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB2);
00221 
00222     iActiveBit = 4;
00223     if (activeBoardsDaqPSB3) {
00224         daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
00225     }
00226     daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB3);
00227 
00228     iActiveBit = 5;
00229     if (activeBoardsDaqPSB4) {
00230         daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
00231     }
00232     daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB4);
00233 
00234     iActiveBit = 6;
00235     if (activeBoardsDaqPSB5) {
00236         daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
00237     }
00238     daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB5);
00239 
00240     iActiveBit = 7;
00241     if (activeBoardsDaqPSB6) {
00242         daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
00243     }
00244     daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrPSB6);
00245 
00246     iActiveBit = 8;
00247     if (activeBoardsDaqGMT) {
00248         daqActiveBoardsVal = daqActiveBoardsVal | ( 1 << iActiveBit );
00249     }
00250     daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrGMT);
00251 
00252     // FIXME fix TIM active bit
00253     //iActiveBit = 9;
00254     //if (activeBoardsDaqTIM) {
00255     //    daqActiveBoardsVal = daqActiveBoardsVal | (1 << iActiveBit);
00256     //}
00257     //daqNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrTIM);
00258 
00259     // active boards in the L1 EVM record
00260     boost::uint16_t evmActiveBoardsVal = 0;
00261 
00262     int evmActiveBoardsLength = 16; // ...hard...
00263     std::vector<int> evmNrBxBoard(evmActiveBoardsLength, 0);
00264 
00265     iActiveBit = 0;
00266     if (activeBoardsEvmTCS) {
00267         evmActiveBoardsVal = evmActiveBoardsVal | ( 1 << iActiveBit );
00268     }
00269     // always 1 TCS payload - hardcoded
00270     evmNrBxBoard.at(iActiveBit) = 1;
00271 
00272     iActiveBit = 1;
00273     if (activeBoardsEvmFDL) {
00274         evmActiveBoardsVal = evmActiveBoardsVal | ( 1 << iActiveBit );
00275     }
00276     // FDL must have the same length in EVM and DAQ
00277     evmNrBxBoard.at(iActiveBit) = boost::lexical_cast<int>(daqNrBxBoardStrFDL);
00278 
00279 
00280     //
00281     pL1GtParameters->setGtDaqActiveBoards(daqActiveBoardsVal);
00282     pL1GtParameters->setGtEvmActiveBoards(evmActiveBoardsVal);
00283     pL1GtParameters->setGtDaqNrBxBoard(daqNrBxBoard);
00284     pL1GtParameters->setGtEvmNrBxBoard(evmNrBxBoard);
00285 
00286     //
00287     unsigned int bstLengthBytesVal = boost::lexical_cast<unsigned int>(bstLengthBytesStr);
00288     pL1GtParameters->setGtBstLengthBytes(bstLengthBytesVal);
00289 
00290     if (edm::isDebugEnabled()) {
00291         std::ostringstream myCoutStream;
00292         pL1GtParameters->print(myCoutStream);
00293         LogTrace("L1GtParametersConfigOnlineProd")
00294                 << "\nThe following L1GtParameters record was read from OMDS: \n"
00295                 << myCoutStream.str() << "\n" << std::endl;
00296     }
00297 
00298     return pL1GtParameters;
00299 }
00300 
00301 DEFINE_FWK_EVENTSETUP_MODULE( L1GtParametersConfigOnlineProd);