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 {
136  uint32_t detUnit = 0;
137  int stripInDU = 0;
138  int febInLB = lbstrip.febInLB();
139  int stripPinInFeb = lbstrip.stripPinInFeb();
140 
141  const FebConnectorSpec * feb = location.feb(febInLB);
142  if (feb) {
143  detUnit = feb->rawId();
144  const ChamberStripSpec strip = feb->strip(stripPinInFeb);
145  if (strip.chamberStripNumber > -1) {
146  stripInDU = strip.chamberStripNumber;
147  } else {
148  // LogWarning("detUnitFrame")<<"problem with stip for febInLB: "<<febInLB
149  // <<" strip pin: "<< stripPinInFeb
150  // <<" strip pin: "<< stripPinInFeb;
151  if (debug) {
152  LogDebug("")<<"problem with stip for febInLB: "<<febInLB
153  <<" strip pin: "<< stripPinInFeb
154  <<" strip pin: "<< stripPinInFeb
155  <<" for linkBoard: "<<location.print(3);
156  }
157  }
158  } else {
159  // LogWarning("detUnitFrame")<<"problem with detUnit for febInLB: ";
160  if (debug) {
161  LogDebug("") <<"problem with detUnit for febInLB: " <<febInLB
162  <<" for linkBoard: "<<location.print(1);
163  }
164  }
165  return std::make_pair(detUnit,stripInDU);
166 }
167 
168 
169 //
170 // ALL BELOW IS TEMPORARY, TO BE REMOVED !!!!
171 //
172 
173 std::pair<LinkBoardElectronicIndex, int>
174 RPCReadOutMapping::getRAWSpecForCMSChamberSrip(uint32_t detId, int strip, int dccInputChannel) const{
175 
176  LinkBoardElectronicIndex linkboard;
177  linkboard.dccId = 790;
178  linkboard.dccInputChannelNum = dccInputChannel;
179 
180  for(int k=0;k<18;k++){
181  linkboard.tbLinkInputNum = k;
182  for(int j=0;j<3;j++){
183  linkboard.lbNumInLink = j;
184  const LinkBoardSpec *location = this->location(linkboard);
185  if (location) {
186  for(int i=1;i<7;i++){
187  const FebConnectorSpec * feb = location->feb(i);
188  if(feb && feb->rawId()==detId){
189  for(int l=1;l<17;l++){
190  int pin = l;
191  const ChamberStripSpec aStrip = feb->strip(pin);
192  if(aStrip.cmsStripNumber==strip){
193  int bitInLink = (i-1)*16+l-1;
194  std::pair<LinkBoardElectronicIndex, int> stripInfo(linkboard,bitInLink);
195  return stripInfo;
196  }
197  }
198  }
199  }
200  }
201  }
202  }
203  RPCDetId aDet(detId);
204  std::cout<<"Strip: "<<strip<<" not found for detector: "<<aDet<<std::endl;
205  std::pair<LinkBoardElectronicIndex, int> dummyStripInfo(linkboard,-99);
206  return dummyStripInfo;
207 }
208 
209 
210 std::vector<const LinkBoardSpec*> RPCReadOutMapping::getLBforChamber(const std::string &name) const{
211 
212 
213  std::vector<const LinkBoardSpec*> vLBforChamber;
214 
215  LinkBoardElectronicIndex linkboard;
216  linkboard.dccId = 790;
217  linkboard.dccInputChannelNum = 1;
218  linkboard.tbLinkInputNum = 1;
219  linkboard.lbNumInLink = 0;
220  const LinkBoardSpec *location = this->location(linkboard);
221 
222  for(int k=0;k<18;k++){
223  linkboard.dccInputChannelNum = 1;
224  linkboard.tbLinkInputNum = k;
225  for(int j=0;j<3;j++){
226  linkboard.lbNumInLink = j;
227  int febInputNum=1;
228  location = this->location(linkboard);
229  if (location) {
230  //location->print();
231  for(int j=0;j<6;j++){
232  const FebConnectorSpec * feb = location->feb(febInputNum+j);
233  if(feb){
234  //feb->print();
235  std::string chName = feb->chamber().chamberLocationName();
236  if(chName==name){
237  vLBforChamber.push_back(location);
238  //feb->chamber().print();
239  break;
240  }
241  }
242  }
243  }
244  }
245  }
246  return vLBforChamber;
247 }
#define LogDebug(id)
const std::vector< TriggerBoardSpec > & triggerBoards() const
Definition: DccSpec.h:25
int i
Definition: DBlmapReader.cc:9
const int cablePinNum(int istrip) const
const uint32_t & rawId() const
DetUnit to which data belongs.
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
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:21
static MessageDrop * instance()
Definition: MessageDrop.cc:65
std::pair< uint32_t, int > StripInDetUnit
first member is DetUnit ID, second strip in DetUnit frame
static bool debugEnabled
Definition: MessageDrop.h:105
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:19
unsigned dccId(const DetId &)
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
std::string link(std::string &nm, std::string &ns)
Definition: hierarchy.cc:47
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)
bool first
Definition: L1TdeRCT.cc:94
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
int k[5][pyjets_maxn]
const std::vector< FebConnectorSpec > & febs() const
Definition: LinkBoardSpec.h:34
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.
#define debug
Definition: MEtoEDMFormat.h:34
int linkBoardNumInLink() const
this LB number in link
Definition: LinkBoardSpec.h:24
const std::vector< LinkBoardSpec > & linkBoards() const
Definition: LinkConnSpec.h:24