CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCReadOutMapping.cc
Go to the documentation of this file.
2 
3 
10 
12 
13 #include<iostream>
14 
15 using namespace edm;
16 
17 
19  : theVersion(version) { }
20 
22 {
23  IMAP im = theFeds.find(dccId);
24  const DccSpec & ddc = (*im).second;
25  return (im != theFeds.end()) ? &ddc : 0;
26 }
27 
29 {
30  theFeds[dcc.id()] = dcc;
31 }
32 
33 
34 std::vector<const DccSpec*> RPCReadOutMapping::dccList() const
35 {
36  std::vector<const DccSpec*> result;
37  result.reserve(theFeds.size());
38  for (IMAP im = theFeds.begin(); im != theFeds.end(); im++) {
39  result.push_back( &(im->second) );
40  }
41  return result;
42 }
43 
44 std::pair<int,int> RPCReadOutMapping::dccNumberRange() const
45 {
46 
47  if (theFeds.empty()) return std::make_pair(0,-1);
48  else {
49  IMAP first = theFeds.begin();
50  IMAP last = theFeds.end(); last--;
51  return std::make_pair(first->first, last->first);
52  }
53 }
54 
55 
56 std::vector< std::pair< LinkBoardElectronicIndex, LinkBoardPackedStrip> >
57  RPCReadOutMapping::rawDataFrame( const StripInDetUnit & stripInDetUnit) const
58 {
59  std::vector< std::pair< LinkBoardElectronicIndex, LinkBoardPackedStrip> > result;
60  LinkBoardElectronicIndex eleIndex = { 0,0,0,0 };
61 
62  const uint32_t & rawDetId = stripInDetUnit.first;
63  const int & stripInDU = stripInDetUnit.second;
64 
65  for (IMAP im=theFeds.begin(); im != theFeds.end(); im++) {
66  const DccSpec & dccSpec = (*im).second;
67  const std::vector<TriggerBoardSpec> & triggerBoards = dccSpec.triggerBoards();
68  for ( std::vector<TriggerBoardSpec>::const_iterator
69  it = triggerBoards.begin(); it != triggerBoards.end(); it++) {
70  const TriggerBoardSpec & triggerBoard = (*it);
71  typedef std::vector<const LinkConnSpec* > LINKS;
72  LINKS linkConns = triggerBoard.enabledLinkConns();
73  for ( LINKS::const_iterator ic = linkConns.begin(); ic != linkConns.end(); ic++) {
74 
75  const LinkConnSpec & link = **ic;
76  const std::vector<LinkBoardSpec> & boards = link.linkBoards();
77  for ( std::vector<LinkBoardSpec>::const_iterator
78  ib = boards.begin(); ib != boards.end(); ib++) {
79 
80  const LinkBoardSpec & board = (*ib);
81 
82  eleIndex.dccId = dccSpec.id();
83  eleIndex.dccInputChannelNum = triggerBoard.dccInputChannelNum();
84  eleIndex.tbLinkInputNum = link.triggerBoardInputNumber();
85  eleIndex.lbNumInLink = board.linkBoardNumInLink();
86 
87  const std::vector<FebConnectorSpec> & febs = board.febs();
88  int febCheck = 0;
89  for ( std::vector<FebConnectorSpec>::const_iterator
90  ifc = febs.begin(); ifc != febs.end(); ifc++) {
91  const FebConnectorSpec & febConnector = (*ifc);
92  febCheck++;
93  if (febConnector.rawId() != rawDetId) continue;
94  int febInLB = febConnector.linkBoardInputNum();
95  /* if (febInLB != febCheck) {
96  edm::LogError("rawDataFrame") << " problem with febInLB: " <<febInLB<<" "<<febCheck;
97  } */
98  for (int istrip=0; istrip<febConnector.nstrips(); istrip++) {
99  int stripPinInFeb = febConnector.cablePinNum(istrip);
100  if (febConnector.chamberStripNum(istrip) == stripInDU) {
101  result.push_back(
102  std::make_pair( eleIndex, LinkBoardPackedStrip( febInLB, stripPinInFeb) ) );
103  }
104  }
105  }
106  }
107  }
108  }
109  }
110  return result;
111 }
112 
113 const LinkBoardSpec*
115 {
116  //FIXME after debugging change to dcc(ele.dccId)->triggerBoard(ele.dccInputChannelNum)->...
117  const DccSpec *dcc = RPCReadOutMapping::dcc(ele.dccId);
118  if (dcc) {
119  const TriggerBoardSpec *tb = dcc->triggerBoard(ele.dccInputChannelNum);
120  if (tb) {
121  const LinkConnSpec *lc = tb->linkConn( ele.tbLinkInputNum);
122  if (lc) {
123  const LinkBoardSpec *lb = lc->linkBoard(ele.lbNumInLink);
124  return lb;
125  }
126  }
127  }
128  return 0;
129 }
130 
133  const LinkBoardPackedStrip & lbstrip) const
134 {
135  uint32_t detUnit = 0;
136  int stripInDU = 0;
137  int febInLB = lbstrip.febInLB();
138  int stripPinInFeb = lbstrip.stripPinInFeb();
139 
140  const FebConnectorSpec * feb = location.feb(febInLB);
141  if (feb) {
142  detUnit = feb->rawId();
143  const ChamberStripSpec strip = feb->strip(stripPinInFeb);
144  if (strip.chamberStripNumber > -1) {
145  stripInDU = strip.chamberStripNumber;
146  } else {
147  // LogWarning("detUnitFrame")<<"problem with stip for febInLB: "<<febInLB
148  // <<" strip pin: "<< stripPinInFeb
149  // <<" strip pin: "<< stripPinInFeb;
150  LogDebug("")<<"problem with stip for febInLB: "<<febInLB
151  <<" strip pin: "<< stripPinInFeb
152  <<" strip pin: "<< stripPinInFeb
153  <<" for linkBoard: "<<location.print(3);
154  }
155  } else {
156  // LogWarning("detUnitFrame")<<"problem with detUnit for febInLB: ";
157  LogDebug("") <<"problem with detUnit for febInLB: " <<febInLB
158  <<" for linkBoard: "<<location.print(1);
159  }
160  return std::make_pair(detUnit,stripInDU);
161 }
162 
163 
164 //
165 // ALL BELOW IS TEMPORARY, TO BE REMOVED !!!!
166 //
167 
168 std::pair<LinkBoardElectronicIndex, int>
169 RPCReadOutMapping::getRAWSpecForCMSChamberSrip(uint32_t detId, int strip, int dccInputChannel) const{
170 
171  LinkBoardElectronicIndex linkboard;
172  linkboard.dccId = 790;
173  linkboard.dccInputChannelNum = dccInputChannel;
174 
175  for(int k=0;k<18;k++){
176  linkboard.tbLinkInputNum = k;
177  for(int j=0;j<3;j++){
178  linkboard.lbNumInLink = j;
179  const LinkBoardSpec *location = this->location(linkboard);
180  if (location) {
181  for(int i=1;i<7;i++){
182  const FebConnectorSpec * feb = location->feb(i);
183  if(feb && feb->rawId()==detId){
184  for(int l=1;l<17;l++){
185  int pin = l;
186  const ChamberStripSpec aStrip = feb->strip(pin);
187  if(aStrip.cmsStripNumber==strip){
188  int bitInLink = (i-1)*16+l-1;
189  std::pair<LinkBoardElectronicIndex, int> stripInfo(linkboard,bitInLink);
190  return stripInfo;
191  }
192  }
193  }
194  }
195  }
196  }
197  }
198  RPCDetId aDet(detId);
199  std::cout<<"Strip: "<<strip<<" not found for detector: "<<aDet<<std::endl;
200  std::pair<LinkBoardElectronicIndex, int> dummyStripInfo(linkboard,-99);
201  return dummyStripInfo;
202 }
203 
204 
205 std::vector<const LinkBoardSpec*> RPCReadOutMapping::getLBforChamber(const std::string &name) const{
206 
207 
208  std::vector<const LinkBoardSpec*> vLBforChamber;
209 
210  LinkBoardElectronicIndex linkboard;
211  linkboard.dccId = 790;
212  linkboard.dccInputChannelNum = 1;
213  linkboard.tbLinkInputNum = 1;
214  linkboard.lbNumInLink = 0;
215  const LinkBoardSpec *location = this->location(linkboard);
216 
217  for(int k=0;k<18;k++){
218  linkboard.dccInputChannelNum = 1;
219  linkboard.tbLinkInputNum = k;
220  for(int j=0;j<3;j++){
221  linkboard.lbNumInLink = j;
222  int febInputNum=1;
223  location = this->location(linkboard);
224  if (location) {
225  //location->print();
226  for(int j=0;j<6;j++){
227  const FebConnectorSpec * feb = location->feb(febInputNum+j);
228  if(feb){
229  //feb->print();
230  std::string chName = feb->chamber().chamberLocationName();
231  if(chName==name){
232  vLBforChamber.push_back(location);
233  //feb->chamber().print();
234  break;
235  }
236  }
237  }
238  }
239  }
240  }
241  return vLBforChamber;
242 }
#define LogDebug(id)
const std::vector< TriggerBoardSpec > & triggerBoards() const
Definition: DccSpec.h:27
int i
Definition: DBlmapReader.cc:9
const int cablePinNum(int istrip) const
const uint32_t & rawId() const
DetUnit to which data belongs.
int ib
Definition: cuy.py:660
std::vector< const LinkBoardSpec * > getLBforChamber(const std::string &name) const
RPCReadOutMapping(const std::string &version="")
const ChamberLocationSpec & chamber() const
std::string print(int depth=0) const
debud printout
const LinkBoardSpec * linkBoard(int linkBoardNumInLink) const
LB served by this link, identified by its position in link.
Definition: LinkConnSpec.cc:21
int id() const
id of FED
Definition: DccSpec.h:23
std::pair< uint32_t, int > StripInDetUnit
first member is DetUnit ID, second strip in DetUnit frame
std::vector< const LinkConnSpec * > enabledLinkConns() const
not masked links belonging to this TB
std::vector< const DccSpec * > dccList() const
all FEDs in map
std::map< int, DccSpec >::const_iterator IMAP
int triggerBoardInputNumber() const
this link input number in TriggerBoard
Definition: LinkConnSpec.h:21
const int nstrips() const
const int chamberStripNum(int istrip) const
const TriggerBoardSpec * triggerBoard(int channelNumber) const
TB attached to channel.
Definition: DccSpec.cc:21
const ChamberStripSpec strip(int pinNumber) const
strip info for input pin
const LinkConnSpec * linkConn(int tbInputNumber) const
link attached to this TB with given input number
std::map< int, DccSpec > theFeds
std::pair< LinkBoardElectronicIndex, int > getRAWSpecForCMSChamberSrip(uint32_t detId, int strip, int dccInputChannel) const
void add(const DccSpec &dcc)
attach FED to map
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
const FebConnectorSpec * feb(int febInputNum) const
get Feb by its connection number to this board
std::pair< int, int > dccNumberRange() const
Range of FED IDs in map (min and max id)
int linkBoardInputNum() const
this FEB channel in LinkBoard
virtual StripInDetUnit detUnitFrame(const LinkBoardSpec &location, const LinkBoardPackedStrip &packedStrip) const
convert strip location as in raw data (LB and LBchannel) to detUnit frame
std::string chamberLocationName() const
virtual const LinkBoardSpec * location(const LinkBoardElectronicIndex &ele) const
conversion between electronic and detector indexing
const std::vector< FebConnectorSpec > & febs() const
Definition: LinkBoardSpec.h:36
std::vector< std::pair< LinkBoardElectronicIndex, LinkBoardPackedStrip > > rawDataFrame(const StripInDetUnit &duFrame) const
connection &quot;paths&quot; that lead from one digi to one strip
int dccInputChannelNum() const
input channel number to DCC
tuple cout
Definition: gather_cfg.py:121
const DccSpec * dcc(int dccId) const
FED identified by ID.
int linkBoardNumInLink() const
this LB number in link
Definition: LinkBoardSpec.h:26
unsigned dccId(DetId const &)
const std::vector< LinkBoardSpec > & linkBoards() const
Definition: LinkConnSpec.h:26