CMS 3D CMS Logo

L1GtBoardMapsTrivialProducer.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtBoardMapsTrivialProducer.h"
00019 
00020 // system include files
00021 #include <memory>
00022 #include "boost/shared_ptr.hpp"
00023 
00024 #include <string>
00025 #include <vector>
00026 
00027 // user include files
00028 //   base class
00029 #include "FWCore/Utilities/interface/EDMException.h"
00030 
00031 #include "FWCore/Framework/interface/ESProducer.h"
00032 
00033 #include "FWCore/Framework/interface/ModuleFactory.h"
00034 #include "FWCore/Framework/interface/ESHandle.h"
00035 
00036 #include "CondFormats/L1TObjects/interface/L1GtFwd.h"
00037 #include "CondFormats/L1TObjects/interface/L1GtBoard.h"
00038 #include "CondFormats/DataRecord/interface/L1GtBoardMapsRcd.h"
00039 
00040 // forward declarations
00041 
00042 // constructor(s)
00043 L1GtBoardMapsTrivialProducer::L1GtBoardMapsTrivialProducer(const edm::ParameterSet& parSet)
00044 {
00045     // tell the framework what data is being produced
00046     setWhatProduced(this, &L1GtBoardMapsTrivialProducer::produceBoardMaps);
00047 
00048     // now do what ever other initialization is needed
00049 
00050     // get the list of the board names and indices
00051     std::vector<std::string> boardList =
00052         parSet.getParameter<std::vector<std::string> >("BoardList");
00053 
00054     std::vector<int> boardIndexVec =
00055         parSet.getParameter<std::vector<int> >("BoardIndex");
00056 
00057     // check if the board list and the board indices are consistent
00058     // i.e. have the same number of entries
00059 
00060     if (boardList.size() != boardIndexVec.size()) {
00061         throw cms::Exception("Configuration")
00062         << "\nError: inconsistent length of board list and board indices.\n"
00063         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00064         << std::endl;
00065     }
00066 
00067     // L1 GT DAQ record map
00068     std::vector<int> boardPositionDaqRecord =
00069         parSet.getParameter<std::vector<int> >("BoardPositionDaqRecord");
00070 
00071     if (boardList.size() != boardPositionDaqRecord.size()) {
00072         throw cms::Exception("Configuration")
00073         << "\nError: inconsistent length of board list and board indices in GT DAQ record.\n"
00074         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00075         << std::endl;
00076     }
00077 
00078     // L1 GT EVM record map
00079     std::vector<int> boardPositionEvmRecord =
00080         parSet.getParameter<std::vector<int> >("BoardPositionEvmRecord");
00081 
00082     if (boardList.size() != boardPositionEvmRecord.size()) {
00083         throw cms::Exception("Configuration")
00084         << "\nError: inconsistent length of board list and board indices in GT EVM record.\n"
00085         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00086         << std::endl;
00087     }
00088 
00089     // L1 GT "active boards" map for DAQ record
00090     std::vector<int> activeBoardsDaqRecord =
00091         parSet.getParameter<std::vector<int> >("ActiveBoardsDaqRecord");
00092 
00093     if (boardList.size() != activeBoardsDaqRecord.size()) {
00094         throw cms::Exception("Configuration")
00095         << "\nError: inconsistent length of board list and active boards in GT DAQ record.\n"
00096         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00097         << std::endl;
00098     }
00099 
00100     // L1 GT "active boards" map for EVM record
00101     std::vector<int> activeBoardsEvmRecord =
00102         parSet.getParameter<std::vector<int> >("ActiveBoardsEvmRecord");
00103 
00104     if (boardList.size() != activeBoardsEvmRecord.size()) {
00105         throw cms::Exception("Configuration")
00106         << "\nError: inconsistent length of board list and active boards in GT EVM record.\n"
00107         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00108         << std::endl;
00109     }
00110 
00111     // L1 GT board - slot map
00112     std::vector<int> boardSlotMap =
00113         parSet.getParameter<std::vector<int> >("BoardSlotMap");
00114 
00115     if (boardList.size() != boardSlotMap.size()) {
00116         throw cms::Exception("Configuration")
00117         << "\nError: inconsistent length of board list and board - slot map.\n"
00118         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00119         << std::endl;
00120     }
00121 
00122     // L1 GT board name in hw record map
00123     std::vector<int> boardHexNameMap =
00124         parSet.getParameter<std::vector<int> >("BoardHexNameMap");
00125 
00126     if (boardList.size() != boardHexNameMap.size()) {
00127         throw cms::Exception("Configuration")
00128         << "\nError: inconsistent length of board list and board name in hw record map.\n"
00129         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00130         << std::endl;
00131     }
00132 
00133 
00134 
00135     // GCT PSB to GT - map cables to input quadruplets  and PSB indices
00136 
00137 
00138     // L1 GT cable list (GCT input to PSB)
00139     std::vector<std::string> cableList =
00140         parSet.getParameter<std::vector<std::string> >("CableList");
00141 
00142     // L1 GT calo input to PSB map
00143     //    gives the mapping of GT calorimeter input to GT PSBs via PSB index
00144     //    4 infinicables per PSB (last PSB can use only 2!)
00145     std::vector<int> cableToPsbMap =
00146         parSet.getParameter<std::vector<int> >("CableToPsbMap");
00147 
00148 
00149     if (cableList.size() != cableToPsbMap.size()) {
00150         throw cms::Exception("Configuration")
00151         << "\nError: inconsistent length of cable list and input to PSB list.\n"
00152         << "\n       Can not define the mapping of GCT quadruplets to GT PSBs.\n"
00153         << std::endl;
00154     }
00155 
00156 
00157     // reserve space for L1 GT boards
00158     m_gtBoardMaps.reserve(boardList.size());
00159 
00160 
00161     // fill the maps
00162     int posVec = 0;
00163 
00164     for (std::vector<std::string>::const_iterator
00165             it = boardList.begin(); it != boardList.end(); ++it) {
00166 
00167         L1GtBoardType boardType;
00168 
00169         if ( (*it) == "GTFE" ) {
00170             boardType = GTFE;
00171         } else if ( (*it) == "FDL" ) {
00172             boardType = FDL;
00173         } else if ( (*it) == "PSB" ) {
00174             boardType = PSB;
00175         } else if ( (*it) == "GMT" ) {
00176             boardType = GMT;
00177         } else if ( (*it) == "TCS" ) {
00178             boardType = TCS;
00179         } else if ( (*it) == "TIM" ) {
00180             boardType = TIM;
00181         } else {
00182             throw cms::Exception("Configuration")
00183             << "\nError: no such board: " << (*it).c_str() << "\n"
00184             << "\n       Can not define the mapping of the L1 GT boards.     \n"
00185             << std::endl;
00186         }
00187 
00188         // construct from board type and board index
00189 
00190         int iBoard = boardIndexVec.at(posVec);
00191         L1GtBoard gtBoard = L1GtBoard(boardType, iBoard);
00192 
00193         // set the position of board data block
00194         // in the GT DAQ readout record
00195         gtBoard.setGtPositionDaqRecord(boardPositionDaqRecord.at(posVec));
00196 
00197         // set the position of board data block
00198         // in the GT EVM readout record
00199         gtBoard.setGtPositionEvmRecord(boardPositionEvmRecord.at(posVec));
00200 
00201         // set the bit of board in the GTFE ACTIVE_BOARDS
00202         // for the GT DAQ readout record
00203         gtBoard.setGtBitDaqActiveBoards(activeBoardsDaqRecord.at(posVec));
00204 
00205         // set the bit of board in the GTFE ACTIVE_BOARDS
00206         // for the GT EVM readout record
00207         gtBoard.setGtBitEvmActiveBoards(activeBoardsEvmRecord.at(posVec));
00208 
00209         // set board slot
00210         gtBoard.setGtBoardSlot(boardSlotMap.at(posVec));
00211 
00212         // set board hex fragment name in hw record
00213         gtBoard.setGtBoardHexName(boardHexNameMap.at(posVec));
00214 
00215         // set L1 quadruplet (4x16 bits)(cable) in the PSB input
00216         // valid for PSB only
00217 
00218         if (boardType == PSB) {
00219 
00220             L1GtPsbQuad psbQuad = Free;
00221             int posCable = 0;
00222             int iPsb = 0;
00223             std::vector<L1GtPsbQuad> quadVec(L1GtBoard::NumberCablesBoard);
00224 
00225             for (std::vector<std::string>::const_iterator
00226                     cIt = cableList.begin(); cIt != cableList.end(); ++cIt) {
00227 
00228 
00229                 if ( *cIt == "TechTr" ) {
00230                     psbQuad = TechTr;
00231                 } else if ( *cIt == "IsoEGQ" ) {
00232                     psbQuad = IsoEGQ;
00233                 } else if ( *cIt == "NoIsoEGQ" ) {
00234                     psbQuad = NoIsoEGQ;
00235                 } else if ( *cIt == "CenJetQ" ) {
00236                     psbQuad = CenJetQ;
00237                 } else if ( *cIt == "ForJetQ" ) {
00238                     psbQuad = ForJetQ;
00239                 } else if ( *cIt == "TauJetQ" ) {
00240                     psbQuad = TauJetQ;
00241                 } else if ( *cIt == "ESumsQ" ) {
00242                     psbQuad = ESumsQ;
00243                 } else if ( *cIt == "JetCountsQ" ) {
00244                     psbQuad = JetCountsQ;
00245                 } else if ( *cIt == "MQB1" ) {
00246                     psbQuad = MQB1;
00247                 } else if ( *cIt == "MQB2" ) {
00248                     psbQuad = MQB2;
00249                 } else if ( *cIt == "MQF3" ) {
00250                     psbQuad = MQF3;
00251                 } else if ( *cIt == "MQF4" ) {
00252                     psbQuad = MQF4;
00253                 } else if ( *cIt == "MQB5" ) {
00254                     psbQuad = MQB5;
00255                 } else if ( *cIt == "MQB6" ) {
00256                     psbQuad = MQB6;
00257                 } else if ( *cIt == "MQF7" ) {
00258                     psbQuad = MQF7;
00259                 } else if ( *cIt == "MQF8" ) {
00260                     psbQuad = MQF8;
00261                 } else if ( *cIt == "MQB9" ) {
00262                     psbQuad = MQB9;
00263                 } else if ( *cIt == "MQB10" ) {
00264                     psbQuad = MQB10;
00265                 } else if ( *cIt == "MQF11" ) {
00266                     psbQuad = MQF11;
00267                 } else if ( *cIt == "MQF12" ) {
00268                     psbQuad = MQF12;
00269                 } else if ( *cIt == "Free" ) {
00270                     psbQuad = Free;
00271                 } else if ( *cIt == "HfQ" ) {
00272                     psbQuad = HfQ;
00273                 } else {
00274                     // should not arrive here
00275                     throw cms::Exception("Configuration")
00276                     << "\nError: no such quadruplet: " << (*cIt).c_str() << "\n"
00277                     << "\n       Can not define the mapping of quadruplets to the L1 PSB boards.\n"
00278                     << std::endl;
00279                 }
00280 
00281                 int psbIndex = cableToPsbMap.at(posCable);
00282 
00283                 if (psbIndex == gtBoard.gtBoardIndex()) {
00284 
00285                     if (iPsb > L1GtBoard::NumberCablesBoard) {
00286                         throw cms::Exception("Configuration")
00287                         << "\nError: too many cables for PSB_" << gtBoard.gtBoardIndex()
00288                         << "\n\n       "
00289                         << "Can not define the mapping of cables to L1 PSB boards.     \n"
00290                         << std::endl;
00291 
00292                     }
00293                     quadVec[iPsb] = psbQuad;
00294                     iPsb++;
00295                 }
00296                 posCable++;
00297 
00298             }
00299 
00300             gtBoard.setGtQuadInPsb(quadVec);
00301 
00302         }
00303 
00304         // push the board in the vector
00305         m_gtBoardMaps.push_back(gtBoard);
00306 
00307         // increase the counter
00308         posVec++;
00309 
00310     }
00311 
00312 }
00313 
00314 // destructor
00315 L1GtBoardMapsTrivialProducer::~L1GtBoardMapsTrivialProducer()
00316 {
00317 
00318     // empty
00319 
00320 }
00321 
00322 
00323 // member functions
00324 
00325 // method called to produce the data
00326 boost::shared_ptr<L1GtBoardMaps> L1GtBoardMapsTrivialProducer::produceBoardMaps(
00327     const L1GtBoardMapsRcd& iRecord)
00328 {
00329 
00330     using namespace edm::es;
00331 
00332     boost::shared_ptr<L1GtBoardMaps> pL1GtBoardMaps =
00333         boost::shared_ptr<L1GtBoardMaps>( new L1GtBoardMaps() );
00334 
00335     pL1GtBoardMaps->setGtBoardMaps(m_gtBoardMaps);
00336 
00337     return pL1GtBoardMaps ;
00338 }

Generated on Tue Jun 9 17:40:28 2009 for CMSSW by  doxygen 1.5.4