CMS 3D CMS Logo

RPCEMap.h
Go to the documentation of this file.
1 #ifndef RPCEMap_H
2 #define RPCEMap_H
3 
5 
7 #include <map>
8 #include <vector>
9 #include <utility>
10 #include <string>
11 #include <iostream>
12 #include <boost/cstdint.hpp>
13 
14 class RPCEMap {
15 public:
16 
17  RPCEMap(const std::string & version = "")
18  : theVersion(version) { }
19 
20  virtual ~RPCEMap(){}
21 
23 
24  struct dccItem {
25  int theId;
26  int nTBs;
27 
29 };
30  struct tbItem {
31  int theNum;
32  int nLinks;
33 
35 };
36  struct linkItem {
38  int nLBs;
39 
41 };
42  struct lbItem {
43  bool theMaster;
45  int theCode;
46  int nFebs;
47 
48  lbItem() : theMaster(0), theLinkBoardNumInLink(0), theCode(0), nFebs(0) { /* nop */ };
49 
51 };
52  struct febItem {
56  int theAlgo;
57 
59 };
60 
61  std::vector<dccItem> theDccs;
62  std::vector<tbItem> theTBs;
63  std::vector<linkItem> theLinks;
64  std::vector<lbItem> theLBs;
65  std::vector<febItem> theFebs;
66 
67  RPCReadOutMapping const* convert() const {
68  RPCReadOutMapping * cabling = new RPCReadOutMapping(theVersion);
69  int diskOffset=4;
70  int year=atoi(theVersion.substr(6,4).c_str());
71  int month=atoi(theVersion.substr(3,2).c_str());
72  if (year < 2012 || (year==2012 && month<11)) diskOffset=3;
73  int lastTB=0;
74  int lastLink=0;
75  int lastLB=0;
76  int lastFeb=0;
77  for (unsigned int idcc=0; idcc<theDccs.size(); idcc++) {
78  DccSpec dcc(theDccs[idcc].theId);
79  for (int itb=lastTB; itb<lastTB+theDccs[idcc].nTBs; itb++) {
80  TriggerBoardSpec tb(theTBs[itb].theNum);
81  for (int ilink=lastLink; ilink<lastLink+theTBs[itb].nLinks; ilink++) {
82  LinkConnSpec lc(theLinks[ilink].theTriggerBoardInputNumber);
83  for (int ilb=lastLB; ilb<lastLB+theLinks[ilink].nLBs; ilb++) {
84  LinkBoardSpec lb(theLBs[ilb].theMaster,theLBs[ilb].theLinkBoardNumInLink,theLBs[ilb].theCode);
85  for (int ifeb=lastFeb; ifeb<lastFeb+theLBs[ilb].nFebs; ifeb++) {
86  int sector=(theFebs[ifeb].theChamber)%100;
87  char subsector=((theFebs[ifeb].theChamber)/100)%10-2;
88  char febZRadOrnt=((theFebs[ifeb].theChamber)/1000)%5;
89  char febZOrnt=((theFebs[ifeb].theChamber)/5000)%2;
90  char diskOrWheel=((theFebs[ifeb].theChamber)/10000)%10-diskOffset;
91  char layer=((theFebs[ifeb].theChamber)/100000)%10;
92  char barrelOrEndcap=(theFebs[ifeb].theChamber)/1000000;
93  ChamberLocationSpec chamber={diskOrWheel,layer,sector,subsector,febZOrnt,febZRadOrnt,barrelOrEndcap};
94  char cmsEtaPartition=(theFebs[ifeb].thePartition)/1000;
95  char positionInCmsEtaPartition=((theFebs[ifeb].thePartition)%1000)/100;
96  char localEtaPartition=((theFebs[ifeb].thePartition)%100)/10;
97  char positionInLocalEtaPartition=(theFebs[ifeb].thePartition)%10;
98  FebLocationSpec afeb={cmsEtaPartition,positionInCmsEtaPartition,localEtaPartition,positionInLocalEtaPartition};
99  FebConnectorSpec febConnector(theFebs[ifeb].theLinkBoardInputNum,chamber,afeb);
100  febConnector.addStrips(theFebs[ifeb].theAlgo);
101  lb.add(febConnector);
102 // std::cout<<"End of FEB"<<std::endl;
103  }
104  lc.add(lb);
105  lastFeb+=theLBs[ilb].nFebs;
106  }
107  tb.add(lc);
108  lastLB+=theLinks[ilink].nLBs;
109  }
110  dcc.add(tb);
111  lastLink+=theTBs[itb].nLinks;
112  }
113  cabling->add(dcc);
114  lastTB+=theDccs[idcc].nTBs;
115  }
116  return cabling;
117 };
118 
119 private:
120 
121 
123 };
124 
125 #endif // RPCEMap_H
126 
int theTriggerBoardInputNumber
Definition: RPCEMap.h:37
int theLinkBoardInputNum
Definition: RPCEMap.h:53
void add(const FebConnectorSpec &feb)
attach feb
Definition: LinkBoardSpec.cc:8
std::vector< tbItem > theTBs
Definition: RPCEMap.h:62
void addStrips(int algo)
add strip info
void add(const LinkBoardSpec &lb)
attach LinkBoard to this link
Definition: LinkConnSpec.cc:16
void add(const LinkConnSpec &lc)
attach connection to TB
int theLinkBoardNumInLink
Definition: RPCEMap.h:44
std::vector< dccItem > theDccs
Definition: RPCEMap.h:61
std::vector< febItem > theFebs
Definition: RPCEMap.h:65
void add(const DccSpec &dcc)
attach FED to map
void add(const TriggerBoardSpec &tb)
attach TB to DCC. The channel is defined by TB
Definition: DccSpec.cc:34
int thePartition
Definition: RPCEMap.h:54
std::vector< linkItem > theLinks
Definition: RPCEMap.h:63
bool theMaster
Definition: RPCEMap.h:43
#define COND_SERIALIZABLE
Definition: Serializable.h:38
std::vector< lbItem > theLBs
Definition: RPCEMap.h:64
RPCEMap(const std::string &version="")
Definition: RPCEMap.h:17
std::string theVersion
Definition: RPCEMap.h:22
RPCReadOutMapping const * convert() const
Definition: RPCEMap.h:67
virtual ~RPCEMap()
Definition: RPCEMap.h:20