CMS 3D CMS Logo

RPCReadOutMappingWithFastSearch.cc

Go to the documentation of this file.
00001 #include "RPCReadOutMappingWithFastSearch.h"
00002 #include <vector>
00003 #include <iostream>
00004 
00005 using namespace std;
00006 
00007 bool RPCReadOutMappingWithFastSearch::lessMap::operator()(
00008     const LinkBoardElectronicIndex & lb1, const LinkBoardElectronicIndex & lb2) const 
00009 {
00010   if ( lb1.dccId              < lb2.dccId)              return true;
00011   if ( lb1.dccId              > lb2.dccId)              return false;
00012   if ( lb1.dccInputChannelNum < lb2.dccInputChannelNum) return true;
00013   if ( lb1.dccInputChannelNum > lb2.dccInputChannelNum) return false;
00014   if ( lb1.tbLinkInputNum     < lb2.tbLinkInputNum)     return true;
00015   if ( lb1.tbLinkInputNum     > lb2.tbLinkInputNum)     return false;
00016   if ( lb1.lbNumInLink        < lb2.lbNumInLink)        return true;
00017   if ( lb1.lbNumInLink        > lb2.lbNumInLink)        return false;
00018   return false;
00019 
00020 }
00021 
00022 RPCReadOutMappingWithFastSearch::RPCReadOutMappingWithFastSearch()
00023    : theMapping(0)
00024 {}
00025 
00026 void RPCReadOutMappingWithFastSearch::init(const RPCReadOutMapping * arm)
00027 {
00028   if (theVersion==arm->version()) return;
00029 
00030   theVersion=arm->version();
00031   theLBMap.clear();
00032   theMapping = arm;
00033 
00034   typedef vector<const DccSpec*> DCCLIST;
00035   DCCLIST dccList = arm->dccList();
00036   for (DCCLIST::const_iterator idcc = dccList.begin(), idccEnd = dccList.end(); 
00037       idcc < idccEnd; ++idcc) {
00038     const DccSpec & dccSpec = **idcc;
00039     const std::vector<TriggerBoardSpec> & triggerBoards = dccSpec.triggerBoards();
00040     for ( std::vector<TriggerBoardSpec>::const_iterator
00041         it = triggerBoards.begin(); it != triggerBoards.end(); it++) {
00042       const TriggerBoardSpec & triggerBoard = (*it);
00043       typedef std::vector<const LinkConnSpec* > LINKS;
00044       LINKS linkConns = triggerBoard.enabledLinkConns();
00045       for ( LINKS::const_iterator ic = linkConns.begin(); ic != linkConns.end(); ic++) {
00046 
00047         const LinkConnSpec & link = **ic;
00048         const std::vector<LinkBoardSpec> & boards = link.linkBoards();
00049         for ( std::vector<LinkBoardSpec>::const_iterator
00050             ib = boards.begin(); ib != boards.end(); ib++) {
00051 
00052           const LinkBoardSpec & board = (*ib);
00053 
00054           LinkBoardElectronicIndex eleIndex;
00055           eleIndex.dccId = dccSpec.id();
00056           eleIndex.dccInputChannelNum = triggerBoard.dccInputChannelNum();
00057           eleIndex.tbLinkInputNum = link.triggerBoardInputNumber();
00058           eleIndex.lbNumInLink = board.linkBoardNumInLink();
00059           LBMap::iterator inMap = theLBMap.find(eleIndex);  
00060           if (inMap != theLBMap.end()) {
00061             cout <<"The element in map already exists!"<< endl;
00062           } else {
00063             theLBMap[eleIndex] = &board;
00064           }
00065         }
00066       }  
00067     }
00068   }
00069 }
00070 
00071 RPCReadOutMapping::StripInDetUnit RPCReadOutMappingWithFastSearch::detUnitFrame(
00072     const LinkBoardSpec& location, const LinkBoardPackedStrip & lbstrip) const
00073 {
00074   return theMapping->detUnitFrame(location,lbstrip);
00075 }
00076 
00077 const LinkBoardSpec* RPCReadOutMappingWithFastSearch::location(const LinkBoardElectronicIndex & ele) const
00078 {
00079   LBMap::const_iterator inMap = theLBMap.find(ele);
00080   return (inMap!= theLBMap.end()) ? inMap->second : 0;
00081 // return theMapping->location(ele);
00082 }

Generated on Tue Jun 9 17:34:47 2009 for CMSSW by  doxygen 1.5.4