Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:35:40

0001 #ifndef RPCEMap_H
0002 #define RPCEMap_H
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
0007 #include <map>
0008 #include <vector>
0009 #include <utility>
0010 #include <string>
0011 #include <iostream>
0012 
0013 class RPCEMap {
0014 public:
0015   RPCEMap(const std::string& version = "") : theVersion(version) {}
0016 
0017   virtual ~RPCEMap() {}
0018 
0019   std::string theVersion;
0020 
0021   struct dccItem {
0022     int theId;
0023     int nTBs;
0024 
0025     COND_SERIALIZABLE;
0026   };
0027   struct tbItem {
0028     int theNum;
0029     int nLinks;
0030 
0031     COND_SERIALIZABLE;
0032   };
0033   struct linkItem {
0034     int theTriggerBoardInputNumber;
0035     int nLBs;
0036 
0037     COND_SERIALIZABLE;
0038   };
0039   struct lbItem {
0040     bool theMaster;
0041     int theLinkBoardNumInLink;
0042     int theCode;
0043     int nFebs;
0044 
0045     lbItem() : theMaster(false), theLinkBoardNumInLink(0), theCode(0), nFebs(0) { /* nop */ }
0046 
0047     COND_SERIALIZABLE;
0048   };
0049   struct febItem {
0050     int theLinkBoardInputNum;
0051     int thePartition;
0052     int theChamber;
0053     int theAlgo;
0054 
0055     COND_SERIALIZABLE;
0056   };
0057 
0058   std::vector<dccItem> theDccs;
0059   std::vector<tbItem> theTBs;
0060   std::vector<linkItem> theLinks;
0061   std::vector<lbItem> theLBs;
0062   std::vector<febItem> theFebs;
0063 
0064   RPCReadOutMapping const* convert() const {
0065     RPCReadOutMapping* cabling = new RPCReadOutMapping(theVersion);
0066     int diskOffset = 4;
0067     int year = atoi(theVersion.substr(6, 4).c_str());
0068     int month = atoi(theVersion.substr(3, 2).c_str());
0069     if (year < 2012 || (year == 2012 && month < 11))
0070       diskOffset = 3;
0071     int lastTB = 0;
0072     int lastLink = 0;
0073     int lastLB = 0;
0074     int lastFeb = 0;
0075     for (unsigned int idcc = 0; idcc < theDccs.size(); idcc++) {
0076       DccSpec dcc(theDccs[idcc].theId);
0077       for (int itb = lastTB; itb < lastTB + theDccs[idcc].nTBs; itb++) {
0078         TriggerBoardSpec tb(theTBs[itb].theNum);
0079         for (int ilink = lastLink; ilink < lastLink + theTBs[itb].nLinks; ilink++) {
0080           LinkConnSpec lc(theLinks[ilink].theTriggerBoardInputNumber);
0081           for (int ilb = lastLB; ilb < lastLB + theLinks[ilink].nLBs; ilb++) {
0082             LinkBoardSpec lb(theLBs[ilb].theMaster, theLBs[ilb].theLinkBoardNumInLink, theLBs[ilb].theCode);
0083             for (int ifeb = lastFeb; ifeb < lastFeb + theLBs[ilb].nFebs; ifeb++) {
0084               int sector = (theFebs[ifeb].theChamber) % 100;
0085               char subsector = ((theFebs[ifeb].theChamber) / 100) % 10 - 2;
0086               char febZRadOrnt = ((theFebs[ifeb].theChamber) / 1000) % 5;
0087               char febZOrnt = ((theFebs[ifeb].theChamber) / 5000) % 2;
0088               char diskOrWheel = ((theFebs[ifeb].theChamber) / 10000) % 10 - diskOffset;
0089               char layer = ((theFebs[ifeb].theChamber) / 100000) % 10;
0090               char barrelOrEndcap = (theFebs[ifeb].theChamber) / 1000000;
0091               ChamberLocationSpec chamber = {
0092                   diskOrWheel, layer, sector, subsector, febZOrnt, febZRadOrnt, barrelOrEndcap};
0093               char cmsEtaPartition = (theFebs[ifeb].thePartition) / 1000;
0094               char positionInCmsEtaPartition = ((theFebs[ifeb].thePartition) % 1000) / 100;
0095               char localEtaPartition = ((theFebs[ifeb].thePartition) % 100) / 10;
0096               char positionInLocalEtaPartition = (theFebs[ifeb].thePartition) % 10;
0097               FebLocationSpec afeb = {
0098                   cmsEtaPartition, positionInCmsEtaPartition, localEtaPartition, positionInLocalEtaPartition};
0099               FebConnectorSpec febConnector(theFebs[ifeb].theLinkBoardInputNum, chamber, afeb);
0100               febConnector.addStrips(theFebs[ifeb].theAlgo);
0101               lb.add(febConnector);
0102               //              std::cout<<"End of FEB"<<std::endl;
0103             }
0104             lc.add(lb);
0105             lastFeb += theLBs[ilb].nFebs;
0106           }
0107           tb.add(lc);
0108           lastLB += theLinks[ilink].nLBs;
0109         }
0110         dcc.add(tb);
0111         lastLink += theTBs[itb].nLinks;
0112       }
0113       cabling->add(dcc);
0114       lastTB += theDccs[idcc].nTBs;
0115     }
0116     return cabling;
0117   };
0118 
0119 private:
0120   COND_SERIALIZABLE;
0121 };
0122 
0123 #endif  // RPCEMap_H