CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/CondFormats/RPCObjects/interface/RPCEMap.h

Go to the documentation of this file.
00001 #ifndef RPCEMap_H
00002 #define RPCEMap_H
00003 
00004 #include "CondFormats/RPCObjects/interface/RPCReadOutMapping.h"
00005 #include <map>
00006 #include <vector>
00007 #include <utility>
00008 #include <string>
00009 #include <iostream>
00010 #include <boost/cstdint.hpp>
00011 
00012 class RPCEMap {
00013 public:
00014 
00015   RPCEMap(const std::string & version = "")
00016   : theVersion(version) { }
00017 
00018   virtual ~RPCEMap(){}
00019 
00020   std::string theVersion;
00021 
00022   struct dccItem {
00023     int theId;
00024     int nTBs;
00025   };
00026   struct tbItem {
00027     int theNum;
00028     int nLinks;
00029   };
00030   struct linkItem {
00031     int theTriggerBoardInputNumber;
00032     int nLBs;
00033   };
00034   struct lbItem {
00035     bool theMaster;
00036     int theLinkBoardNumInLink;
00037     int theCode;
00038     int nFebs;
00039   };
00040   struct febItem {
00041     int theLinkBoardInputNum;
00042     int thePartition;
00043     int theChamber;
00044     int theAlgo;
00045   };
00046 
00047   std::vector<dccItem> theDccs;
00048   std::vector<tbItem> theTBs;
00049   std::vector<linkItem> theLinks;
00050   std::vector<lbItem> theLBs;
00051   std::vector<febItem> theFebs;
00052 
00053   RPCReadOutMapping* convert() const {
00054     RPCReadOutMapping* cabling = new RPCReadOutMapping(theVersion);
00055     int lastTB=0;
00056     int lastLink=0;
00057     int lastLB=0;
00058     int lastFeb=0;
00059     for (unsigned int idcc=0; idcc<theDccs.size(); idcc++) {
00060       DccSpec dcc(theDccs[idcc].theId);
00061       for (int itb=lastTB; itb<lastTB+theDccs[idcc].nTBs; itb++) {
00062         TriggerBoardSpec tb(theTBs[itb].theNum);
00063         for (int ilink=lastLink; ilink<lastLink+theTBs[itb].nLinks; ilink++) {
00064           LinkConnSpec lc(theLinks[ilink].theTriggerBoardInputNumber);
00065           for (int ilb=lastLB; ilb<lastLB+theLinks[ilink].nLBs; ilb++) {
00066             LinkBoardSpec lb(theLBs[ilb].theMaster,theLBs[ilb].theLinkBoardNumInLink,theLBs[ilb].theCode);
00067             for (int ifeb=lastFeb; ifeb<lastFeb+theLBs[ilb].nFebs; ifeb++) {
00068               int sector=(theFebs[ifeb].theChamber)%100;
00069               char subsector=((theFebs[ifeb].theChamber)/100)%10-2;
00070               char febZRadOrnt=((theFebs[ifeb].theChamber)/1000)%5;
00071               char febZOrnt=((theFebs[ifeb].theChamber)/5000)%2;
00072               char diskOrWheel=((theFebs[ifeb].theChamber)/10000)%10-3;
00073               char layer=((theFebs[ifeb].theChamber)/100000)%10;
00074               char barrelOrEndcap=(theFebs[ifeb].theChamber)/1000000;
00075               ChamberLocationSpec chamber={diskOrWheel,layer,sector,subsector,febZOrnt,febZRadOrnt,barrelOrEndcap};
00076               char cmsEtaPartition=(theFebs[ifeb].thePartition)/1000;
00077               char positionInCmsEtaPartition=((theFebs[ifeb].thePartition)%1000)/100;
00078               char localEtaPartition=((theFebs[ifeb].thePartition)%100)/10;
00079               char positionInLocalEtaPartition=(theFebs[ifeb].thePartition)%10;
00080               FebLocationSpec afeb={cmsEtaPartition,positionInCmsEtaPartition,localEtaPartition,positionInLocalEtaPartition};
00081               FebConnectorSpec febConnector(theFebs[ifeb].theLinkBoardInputNum,chamber,afeb);
00082               febConnector.addStrips(theFebs[ifeb].theAlgo);
00083               lb.add(febConnector);
00084 //              std::cout<<"End of FEB"<<std::endl;
00085             }
00086             lc.add(lb);
00087             lastFeb+=theLBs[ilb].nFebs;
00088           }
00089           tb.add(lc);
00090           lastLB+=theLinks[ilink].nLBs;
00091         }
00092         dcc.add(tb);
00093         lastLink+=theTBs[itb].nLinks;
00094       }
00095       cabling->add(dcc);
00096       lastTB+=theDccs[idcc].nTBs;
00097     }
00098   return cabling;
00099 };
00100   
00101 private:
00102   
00103 };
00104 
00105 #endif // RPCEMap_H
00106