CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/L1TriggerConfig/L1GtConfigProducers/src/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 
00026 // user include files
00027 //   base class
00028 #include "FWCore/Utilities/interface/EDMException.h"
00029 
00030 #include "FWCore/Framework/interface/ModuleFactory.h"
00031 #include "FWCore/Framework/interface/ESHandle.h"
00032 
00033 #include "CondFormats/L1TObjects/interface/L1GtFwd.h"
00034 
00035 // forward declarations
00036 
00037 //
00038 
00039 std::vector<L1GtObject> chInputObjects(
00040         const std::vector<std::string>& chInputStrings)
00041 {
00042     std::vector<L1GtObject> chInputObjectsV;
00043     chInputObjectsV.reserve(chInputStrings.size());
00044 
00045     L1GtObject obj;
00046 
00047     for (std::vector<std::string>::const_iterator itObj =
00048             chInputStrings.begin(); itObj != chInputStrings.end(); ++itObj) {
00049 
00050         if ((*itObj) == "Mu") {
00051             obj = Mu;
00052         }
00053         else if ((*itObj) == "NoIsoEG") {
00054             obj = NoIsoEG;
00055         }
00056         else if ((*itObj) == "IsoEG") {
00057             obj = IsoEG;
00058         }
00059         else if ((*itObj) == "CenJet") {
00060             obj = CenJet;
00061         }
00062         else if ((*itObj) == "ForJet") {
00063             obj = ForJet;
00064         }
00065         else if ((*itObj) == "TauJet") {
00066             obj = TauJet;
00067         }
00068         else if ((*itObj) == "ETM") {
00069             obj = ETM;
00070         }
00071         else if ((*itObj) == "ETT") {
00072             obj = ETT;
00073         }
00074         else if ((*itObj) == "HTT") {
00075             obj = HTT;
00076         }
00077         else if ((*itObj) == "HTM") {
00078             obj = HTM;
00079         }
00080         else if ((*itObj) == "JetCounts") {
00081             obj = JetCounts;
00082         }
00083         else if ((*itObj) == "HfBitCounts") {
00084             obj = HfBitCounts;
00085         }
00086         else if ((*itObj) == "HfRingEtSums") {
00087             obj = HfRingEtSums;
00088         }
00089         else if ((*itObj) == "TechTrig") {
00090             obj = TechTrig;
00091         }
00092         else if ((*itObj) == "BPTX") {
00093             obj = BPTX;
00094         }
00095         else if ((*itObj) == "GtExternal") {
00096             obj = GtExternal;
00097         }
00098         else {
00099             throw cms::Exception("Configuration")
00100                     << "\nError: no such L1 GT object: " << (*itObj) << "\n"
00101                     << "\n       Can not define the mapping of the L1 GT boards.     \n"
00102                     << std::endl;
00103 
00104         }
00105 
00106         chInputObjectsV.push_back(obj);
00107     }
00108 
00109     return chInputObjectsV;
00110 }
00111 
00112 // constructor(s)
00113 L1GtBoardMapsTrivialProducer::L1GtBoardMapsTrivialProducer(const edm::ParameterSet& parSet)
00114 {
00115     // tell the framework what data is being produced
00116     setWhatProduced(this, &L1GtBoardMapsTrivialProducer::produceBoardMaps);
00117 
00118     // now do what ever other initialization is needed
00119 
00120     // get the list of the board names and indices
00121     std::vector<std::string> boardList =
00122         parSet.getParameter<std::vector<std::string> >("BoardList");
00123 
00124     std::vector<int> boardIndexVec =
00125         parSet.getParameter<std::vector<int> >("BoardIndex");
00126 
00127     // check if the board list and the board indices are consistent
00128     // i.e. have the same number of entries
00129 
00130     if (boardList.size() != boardIndexVec.size()) {
00131         throw cms::Exception("Configuration")
00132         << "\nError: inconsistent length of board list and board indices.\n"
00133         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00134         << std::endl;
00135     }
00136 
00137     // L1 GT DAQ record map
00138     std::vector<int> boardPositionDaqRecord =
00139         parSet.getParameter<std::vector<int> >("BoardPositionDaqRecord");
00140 
00141     if (boardList.size() != boardPositionDaqRecord.size()) {
00142         throw cms::Exception("Configuration")
00143         << "\nError: inconsistent length of board list and board indices in GT DAQ record.\n"
00144         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00145         << std::endl;
00146     }
00147 
00148     // L1 GT EVM record map
00149     std::vector<int> boardPositionEvmRecord =
00150         parSet.getParameter<std::vector<int> >("BoardPositionEvmRecord");
00151 
00152     if (boardList.size() != boardPositionEvmRecord.size()) {
00153         throw cms::Exception("Configuration")
00154         << "\nError: inconsistent length of board list and board indices in GT EVM record.\n"
00155         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00156         << std::endl;
00157     }
00158 
00159     // L1 GT "active boards" map for DAQ record
00160     std::vector<int> activeBoardsDaqRecord =
00161         parSet.getParameter<std::vector<int> >("ActiveBoardsDaqRecord");
00162 
00163     if (boardList.size() != activeBoardsDaqRecord.size()) {
00164         throw cms::Exception("Configuration")
00165         << "\nError: inconsistent length of board list and active boards in GT DAQ record.\n"
00166         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00167         << std::endl;
00168     }
00169 
00170     // L1 GT "active boards" map for EVM record
00171     std::vector<int> activeBoardsEvmRecord =
00172         parSet.getParameter<std::vector<int> >("ActiveBoardsEvmRecord");
00173 
00174     if (boardList.size() != activeBoardsEvmRecord.size()) {
00175         throw cms::Exception("Configuration")
00176         << "\nError: inconsistent length of board list and active boards in GT EVM record.\n"
00177         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00178         << std::endl;
00179     }
00180 
00181     // L1 GT board - slot map
00182     std::vector<int> boardSlotMap =
00183         parSet.getParameter<std::vector<int> >("BoardSlotMap");
00184 
00185     if (boardList.size() != boardSlotMap.size()) {
00186         throw cms::Exception("Configuration")
00187         << "\nError: inconsistent length of board list and board - slot map.\n"
00188         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00189         << std::endl;
00190     }
00191 
00192     // L1 GT board name in hw record map
00193     std::vector<int> boardHexNameMap =
00194         parSet.getParameter<std::vector<int> >("BoardHexNameMap");
00195 
00196     if (boardList.size() != boardHexNameMap.size()) {
00197         throw cms::Exception("Configuration")
00198         << "\nError: inconsistent length of board list and board name in hw record map.\n"
00199         << "\n       Can not define the mapping of the L1 GT boards.     \n"
00200         << std::endl;
00201     }
00202 
00203 
00204 
00205     // GCT PSB to GT - map cables to input quadruplets  and PSB indices
00206 
00207 
00208     // L1 GT cable list (GCT input to PSB)
00209     std::vector<std::string> cableList =
00210         parSet.getParameter<std::vector<std::string> >("CableList");
00211 
00212     // L1 GT calo input to PSB map
00213     //    gives the mapping of GT calorimeter input to GT PSBs via PSB index
00214     //    4 infinicables per PSB (last PSB can use only 2!)
00215     std::vector<int> cableToPsbMap =
00216         parSet.getParameter<std::vector<int> >("CableToPsbMap");
00217 
00218 
00219     if (cableList.size() != cableToPsbMap.size()) {
00220         throw cms::Exception("Configuration")
00221         << "\nError: inconsistent length of cable list and input to PSB list.\n"
00222         << "\n       Can not define the mapping of GCT quadruplets to GT PSBs.\n"
00223         << std::endl;
00224     }
00225 
00226 
00227     // detailed input configuration for PSB
00228     std::vector<edm::ParameterSet> psbInput = parSet.getParameter<std::vector<
00229             edm::ParameterSet> > ("PsbInput");
00230 
00231     // reserve space for L1 GT boards
00232     m_gtBoardMaps.reserve(boardList.size());
00233 
00234 
00235     // fill the maps
00236     int posVec = 0;
00237 
00238     for (std::vector<std::string>::const_iterator
00239             it = boardList.begin(); it != boardList.end(); ++it) {
00240 
00241         L1GtBoardType boardType;
00242 
00243         if ( (*it) == "GTFE" ) {
00244             boardType = GTFE;
00245         } else if ( (*it) == "FDL" ) {
00246             boardType = FDL;
00247         } else if ( (*it) == "PSB" ) {
00248             boardType = PSB;
00249         } else if ( (*it) == "GMT" ) {
00250             boardType = GMT;
00251         } else if ( (*it) == "TCS" ) {
00252             boardType = TCS;
00253         } else if ( (*it) == "TIM" ) {
00254             boardType = TIM;
00255         } else {
00256             throw cms::Exception("Configuration")
00257             << "\nError: no such board: " << (*it).c_str() << "\n"
00258             << "\n       Can not define the mapping of the L1 GT boards.     \n"
00259             << std::endl;
00260         }
00261 
00262         // construct from board type and board index
00263 
00264         int iBoard = boardIndexVec.at(posVec);
00265         L1GtBoard gtBoard = L1GtBoard(boardType, iBoard);
00266 
00267         // set the position of board data block
00268         // in the GT DAQ readout record
00269         gtBoard.setGtPositionDaqRecord(boardPositionDaqRecord.at(posVec));
00270 
00271         // set the position of board data block
00272         // in the GT EVM readout record
00273         gtBoard.setGtPositionEvmRecord(boardPositionEvmRecord.at(posVec));
00274 
00275         // set the bit of board in the GTFE ACTIVE_BOARDS
00276         // for the GT DAQ readout record
00277         gtBoard.setGtBitDaqActiveBoards(activeBoardsDaqRecord.at(posVec));
00278 
00279         // set the bit of board in the GTFE ACTIVE_BOARDS
00280         // for the GT EVM readout record
00281         gtBoard.setGtBitEvmActiveBoards(activeBoardsEvmRecord.at(posVec));
00282 
00283         // set board slot
00284         int boardSlot = boardSlotMap.at(posVec);
00285         gtBoard.setGtBoardSlot(boardSlot);
00286 
00287         // set board hex fragment name in hw record
00288         gtBoard.setGtBoardHexName(boardHexNameMap.at(posVec));
00289 
00290         // set L1 quadruplet (4x16 bits)(cable) in the PSB input
00291         // valid for PSB only
00292 
00293         if (boardType == PSB) {
00294 
00295             L1GtPsbQuad psbQuad = Free;
00296             int posCable = 0;
00297             int iPsb = 0;
00298             std::vector<L1GtPsbQuad> quadVec(L1GtBoard::NumberCablesBoard);
00299 
00300             for (std::vector<std::string>::const_iterator
00301                     cIt = cableList.begin(); cIt != cableList.end(); ++cIt) {
00302 
00303 
00304                 if ( *cIt == "TechTr" ) {
00305                     psbQuad = TechTr;
00306                 } else if ( *cIt == "IsoEGQ" ) {
00307                     psbQuad = IsoEGQ;
00308                 } else if ( *cIt == "NoIsoEGQ" ) {
00309                     psbQuad = NoIsoEGQ;
00310                 } else if ( *cIt == "CenJetQ" ) {
00311                     psbQuad = CenJetQ;
00312                 } else if ( *cIt == "ForJetQ" ) {
00313                     psbQuad = ForJetQ;
00314                 } else if ( *cIt == "TauJetQ" ) {
00315                     psbQuad = TauJetQ;
00316                 } else if ( *cIt == "ESumsQ" ) {
00317                     psbQuad = ESumsQ;
00318                 } else if ( *cIt == "JetCountsQ" ) {
00319                     psbQuad = JetCountsQ;
00320                 } else if ( *cIt == "MQB1" ) {
00321                     psbQuad = MQB1;
00322                 } else if ( *cIt == "MQB2" ) {
00323                     psbQuad = MQB2;
00324                 } else if ( *cIt == "MQF3" ) {
00325                     psbQuad = MQF3;
00326                 } else if ( *cIt == "MQF4" ) {
00327                     psbQuad = MQF4;
00328                 } else if ( *cIt == "MQB5" ) {
00329                     psbQuad = MQB5;
00330                 } else if ( *cIt == "MQB6" ) {
00331                     psbQuad = MQB6;
00332                 } else if ( *cIt == "MQF7" ) {
00333                     psbQuad = MQF7;
00334                 } else if ( *cIt == "MQF8" ) {
00335                     psbQuad = MQF8;
00336                 } else if ( *cIt == "MQB9" ) {
00337                     psbQuad = MQB9;
00338                 } else if ( *cIt == "MQB10" ) {
00339                     psbQuad = MQB10;
00340                 } else if ( *cIt == "MQF11" ) {
00341                     psbQuad = MQF11;
00342                 } else if ( *cIt == "MQF12" ) {
00343                     psbQuad = MQF12;
00344                 } else if ( *cIt == "Free" ) {
00345                     psbQuad = Free;
00346                 } else if ( *cIt == "HfQ" ) {
00347                     psbQuad = HfQ;
00348                 } else {
00349                     // should not arrive here
00350                     throw cms::Exception("Configuration")
00351                     << "\nError: no such quadruplet: " << (*cIt).c_str() << "\n"
00352                     << "\n       Can not define the mapping of quadruplets to the L1 PSB boards.\n"
00353                     << std::endl;
00354                 }
00355 
00356                 int psbIndex = cableToPsbMap.at(posCable);
00357 
00358                 if (psbIndex == gtBoard.gtBoardIndex()) {
00359 
00360                     if (iPsb > L1GtBoard::NumberCablesBoard) {
00361                         throw cms::Exception("Configuration")
00362                         << "\nError: too many cables for PSB_" << gtBoard.gtBoardIndex()
00363                         << "\n\n       "
00364                         << "Can not define the mapping of cables to L1 PSB boards.     \n"
00365                         << std::endl;
00366 
00367                     }
00368                     quadVec[iPsb] = psbQuad;
00369                     iPsb++;
00370                 }
00371                 posCable++;
00372 
00373             }
00374 
00375             gtBoard.setGtQuadInPsb(quadVec);
00376 
00377         }
00378 
00379         if (boardType == PSB) {
00380 
00381             std::map<int, std::vector<L1GtObject> > inputPsbChannels;
00382 
00383             std::vector<std::string> chStrings;
00384             chStrings.reserve(2); // most channels have 2 objects
00385 
00386             std::vector<L1GtObject>  chObjects;
00387 
00388             for (std::vector<edm::ParameterSet>::const_iterator itPSet =
00389                     psbInput.begin(); itPSet != psbInput.end(); ++itPSet) {
00390 
00391                 //
00392                 int slot = itPSet->getParameter<int> ("Slot");
00393 
00394                 if (slot == boardSlot) {
00395                     chStrings = itPSet->getParameter<std::vector<std::string> > (
00396                             "Ch0");
00397                     chObjects = chInputObjects(chStrings);
00398                     inputPsbChannels[0] = chObjects;
00399                     chStrings.clear();
00400                     chObjects.clear();
00401 
00402                     chStrings = itPSet->getParameter<std::vector<std::string> > (
00403                             "Ch1");
00404                     chObjects = chInputObjects(chStrings);
00405                     inputPsbChannels[1] = chObjects;
00406                     chStrings.clear();
00407                     chObjects.clear();
00408 
00409                     chStrings = itPSet->getParameter<std::vector<std::string> > (
00410                             "Ch2");
00411                     chObjects = chInputObjects(chStrings);
00412                     inputPsbChannels[2] = chObjects;
00413                     chStrings.clear();
00414                     chObjects.clear();
00415 
00416                     chStrings = itPSet->getParameter<std::vector<std::string> > (
00417                             "Ch3");
00418                     chObjects = chInputObjects(chStrings);
00419                     inputPsbChannels[3] = chObjects;
00420                     chStrings.clear();
00421                     chObjects.clear();
00422 
00423                     chStrings = itPSet->getParameter<std::vector<std::string> > (
00424                             "Ch4");
00425                     chObjects = chInputObjects(chStrings);
00426                     inputPsbChannels[4] = chObjects;
00427                     chStrings.clear();
00428                     chObjects.clear();
00429 
00430                     chStrings = itPSet->getParameter<std::vector<std::string> > (
00431                             "Ch5");
00432                     chObjects = chInputObjects(chStrings);
00433                     inputPsbChannels[5] = chObjects;
00434                     chStrings.clear();
00435                     chObjects.clear();
00436 
00437                     chStrings = itPSet->getParameter<std::vector<std::string> > (
00438                             "Ch6");
00439                     chObjects = chInputObjects(chStrings);
00440                     inputPsbChannels[6] = chObjects;
00441                     chStrings.clear();
00442                     chObjects.clear();
00443 
00444                     chStrings = itPSet->getParameter<std::vector<std::string> > (
00445                             "Ch7");
00446                     chObjects = chInputObjects(chStrings);
00447                     inputPsbChannels[7] = chObjects;
00448                     chStrings.clear();
00449                     chObjects.clear();
00450                 }
00451             }
00452 
00453             gtBoard.setGtInputPsbChannels(inputPsbChannels);
00454         }
00455 
00456         // push the board in the vector
00457         m_gtBoardMaps.push_back(gtBoard);
00458 
00459         // increase the counter
00460         posVec++;
00461 
00462     }
00463 
00464 }
00465 
00466 // destructor
00467 L1GtBoardMapsTrivialProducer::~L1GtBoardMapsTrivialProducer()
00468 {
00469 
00470     // empty
00471 
00472 }
00473 
00474 
00475 // member functions
00476 
00477 // method called to produce the data
00478 boost::shared_ptr<L1GtBoardMaps> L1GtBoardMapsTrivialProducer::produceBoardMaps(
00479     const L1GtBoardMapsRcd& iRecord)
00480 {
00481 
00482     using namespace edm::es;
00483 
00484     boost::shared_ptr<L1GtBoardMaps> pL1GtBoardMaps =
00485         boost::shared_ptr<L1GtBoardMaps>( new L1GtBoardMaps() );
00486 
00487     pL1GtBoardMaps->setGtBoardMaps(m_gtBoardMaps);
00488 
00489     return pL1GtBoardMaps ;
00490 }
00491