CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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 diskOffset=4;
00056     int year=atoi(theVersion.substr(6,4).c_str());
00057     int month=atoi(theVersion.substr(3,2).c_str());
00058     if (year < 2012 || (year==2012 && month<11)) diskOffset=3;
00059     int lastTB=0;
00060     int lastLink=0;
00061     int lastLB=0;
00062     int lastFeb=0;
00063     for (unsigned int idcc=0; idcc<theDccs.size(); idcc++) {
00064       DccSpec dcc(theDccs[idcc].theId);
00065       for (int itb=lastTB; itb<lastTB+theDccs[idcc].nTBs; itb++) {
00066         TriggerBoardSpec tb(theTBs[itb].theNum);
00067         for (int ilink=lastLink; ilink<lastLink+theTBs[itb].nLinks; ilink++) {
00068           LinkConnSpec lc(theLinks[ilink].theTriggerBoardInputNumber);
00069           for (int ilb=lastLB; ilb<lastLB+theLinks[ilink].nLBs; ilb++) {
00070             LinkBoardSpec lb(theLBs[ilb].theMaster,theLBs[ilb].theLinkBoardNumInLink,theLBs[ilb].theCode);
00071             for (int ifeb=lastFeb; ifeb<lastFeb+theLBs[ilb].nFebs; ifeb++) {
00072               int sector=(theFebs[ifeb].theChamber)%100;
00073               char subsector=((theFebs[ifeb].theChamber)/100)%10-2;
00074               char febZRadOrnt=((theFebs[ifeb].theChamber)/1000)%5;
00075               char febZOrnt=((theFebs[ifeb].theChamber)/5000)%2;
00076               char diskOrWheel=((theFebs[ifeb].theChamber)/10000)%10-diskOffset;
00077               char layer=((theFebs[ifeb].theChamber)/100000)%10;
00078               char barrelOrEndcap=(theFebs[ifeb].theChamber)/1000000;
00079               ChamberLocationSpec chamber={diskOrWheel,layer,sector,subsector,febZOrnt,febZRadOrnt,barrelOrEndcap};
00080               char cmsEtaPartition=(theFebs[ifeb].thePartition)/1000;
00081               char positionInCmsEtaPartition=((theFebs[ifeb].thePartition)%1000)/100;
00082               char localEtaPartition=((theFebs[ifeb].thePartition)%100)/10;
00083               char positionInLocalEtaPartition=(theFebs[ifeb].thePartition)%10;
00084               FebLocationSpec afeb={cmsEtaPartition,positionInCmsEtaPartition,localEtaPartition,positionInLocalEtaPartition};
00085               FebConnectorSpec febConnector(theFebs[ifeb].theLinkBoardInputNum,chamber,afeb);
00086               febConnector.addStrips(theFebs[ifeb].theAlgo);
00087               lb.add(febConnector);
00088 //              std::cout<<"End of FEB"<<std::endl;
00089             }
00090             lc.add(lb);
00091             lastFeb+=theLBs[ilb].nFebs;
00092           }
00093           tb.add(lc);
00094           lastLB+=theLinks[ilink].nLBs;
00095         }
00096         dcc.add(tb);
00097         lastLink+=theTBs[itb].nLinks;
00098       }
00099       cabling->add(dcc);
00100       lastTB+=theDccs[idcc].nTBs;
00101     }
00102   return cabling;
00103 };
00104   
00105 private:
00106   
00107 };
00108 
00109 #endif // RPCEMap_H
00110