HardwareDisplay.cpp
Go to the documentation of this file.
1 ///
2 /// \file HardwareDisplay.cpp
3 /// \brief Map channel addresses to a sensible (x,y) coordinate
4 /// \author messier@indiana.edu
5 /// \version $Id: HardwareDisplay.cpp,v 1.5 2018/07/02 19:22:16 lackey32 Exp $
6 ///
7 #include "DAQChannelMap/HardwareDisplay.h"
8 #include "DAQChannelMap/DAQChannelMap.h"
9 #include <iostream>
10 #include <stdlib.h>
11 #include "NovaDAQConventions/DAQConventions.h"
12 
13 using namespace daqchannelmap;
14 using namespace novadaq::cnv;
15 
17  switch (det) {
18  case kNDOS: this->SetupNDOS(); break;
19  case kNEARDET: this->SetupNearDet(); break;
20  case kFARDET: this->SetupFarDet(); break;
21  case kTESTBEAM:this->SetupTestBeam();break;
22  default:
23  std::cerr << __FILE__ << " : " << __LINE__
24  << " Invalid detector type " << det
25  << std::endl;
26  abort();
27  }
28 }
29 
30 //......................................................................
31 
33 {
34  fDetId = kNDOS;
35 
36  fNdiblocks = 4;
37  fNdcmTop = 1;
38  fNdcmSide = 2;
39  fNfebCols = 16;
40  fNfebRows = 4;
41  fNpixCols = 4;
42  fNpixRows = 8;
43 
44  fNxPerDB = fNfebCols*fNpixCols;
45  fNyPerDCM = fNfebRows*fNpixRows;
46 
47  fXmax = fNdiblocks*fNxPerDB;
48  fYmax = (fNdcmTop+fNdcmSide)*fNyPerDCM;
49 
50  fNplanesPerBL = 31;
51  fNplanes = 2*fNplanesPerBL*fNdiblocks; // 31 planes per block
52  fNxcells = 32*2; // 32 cells / module, 2 modules
53  fNycells = 32*3; // 32 cells / module, 3 modules
54  fNcellPerMod = 32;
55 }
56 
57 //......................................................................
58 
60 {
61  fDetId = kNEARDET;
62 
63  fNdiblocks = 4;
64  fNdcmTop = 2;
65  fNdcmSide = 2;
66  fNfebCols = 16;
67  fNfebRows = 4;
68  fNpixCols = 4;
69  fNpixRows = 8;
70 
71  fNxPerDB = fNfebCols*fNpixCols;
72  fNyPerDCM = fNfebRows*fNpixRows;
73 
74  fXmax = fNdiblocks*fNxPerDB;
75  fYmax = (fNdcmTop+fNdcmSide)*fNyPerDCM;
76 
77  fNplanesPerBL = 32;
78  fNplanes = 2*fNplanesPerBL*fNdiblocks; // 32 planes per block
79  fNxcells = 32*3; // 32 cells / module, 3 modules
80  fNycells = 32*3; // 32 cells / module, 3 modules
81  fNcellPerMod = 32;
82 }
83 
84 //......................................................................
85 
87 {
88  fDetId = kFARDET;
89 
90  fNdiblocks = 14;
91  fNdcmTop = 6;
92  fNdcmSide = 6;
93  fNfebCols = 16;
94  fNfebRows = 4;
95  fNpixCols = 4;
96  fNpixRows = 8;
97 
98  fNxPerDB = fNfebCols*fNpixCols;
99  fNyPerDCM = fNfebRows*fNpixRows;
100 
101  fXmax = fNdiblocks*fNxPerDB;
102  fYmax = (fNdcmTop+fNdcmSide)*fNyPerDCM;
103 
104  fNplanesPerBL = 32;
105  fNplanes = 2*fNplanesPerBL*fNdiblocks; // 32 planes per block
106  fNxcells = 32*12; // 32 cells / module, 12 modules
107  fNycells = 32*12; // 32 cells / module, 12 modules
108  fNcellPerMod = 32;
109 }
110 
111 //......................................................................
112 
114 {
115  fDetId = kTESTBEAM;
116 
117  fNdiblocks = 1;
118  fNdcmTop = 1; // really 3
119  fNdcmSide = 2; // really 3 - Need to make NdcmTop+NdcmSide = 3 for XYDCM function
120  fNfebCols = 16;
121  fNfebRows = 4;
122  fNpixCols = 4;
123  fNpixRows = 8;
124 
125  fNxPerDB = fNfebCols*fNpixCols;
126  fNyPerDCM = fNfebRows*fNpixRows;
127 
128  fXmax = fNdiblocks*fNxPerDB;
129  fYmax = (fNdcmTop+fNdcmSide)*fNyPerDCM;
130 
131  fNplanesPerBL = 32;
132  fNplanes = 2*fNplanesPerBL*fNdiblocks-1; // 2*32*1 - 1
133  fNxcells = 32*2; // 32 cells / module, 2 modules
134  fNycells = 32*2; // 32 cells / module, 2 modules
135  fNcellPerMod = 32;
136 
137 }
138 //......................................................................
139 
140 void HardwareDisplay::DiblockXY(unsigned int db,
141  unsigned int *ix,
142  unsigned int *iy)
143 {
144  //*ix = fNxPerDB*(db-1); // diblocks numbered L to R
145  *ix = fNxPerDB*(fNdiblocks - db); // diblocks numbered R to L
146  *iy = 0;
147 }
148 
149 //......................................................................
150 
151 void HardwareDisplay::DCMXY(unsigned int dcm,
152  unsigned int* ix,
153  unsigned int* iy)
154 {
155  *ix = 0;
156  *iy = fYmax - dcm*fNyPerDCM;
157 }
158 
159 //......................................................................
160 
161 void HardwareDisplay::FEBXY(unsigned int feb,
162  unsigned int* ix,
163  unsigned int* iy)
164 {
165  *ix = (feb%fNfebCols)*fNpixCols;
166  *iy = ((fNfebRows - 1) - feb/fNfebCols)*fNpixRows;
167 }
168 
169 //......................................................................
170 
171 void HardwareDisplay::PixXY(unsigned int pix,
172  unsigned int* ix,
173  unsigned int* iy)
174 {
175  static unsigned int x[32] = {
176  3,3,3,3,3,3,3,3, 2,2,2,2,2,2,2,2,
177  1,1,1,1,1,1,1,1, 0,0,0,0,0,0,0,0
178  };
179  static unsigned int y[32] = {
180  1,0,3,2,5,4,7,6, 1,0,3,2,5,4,6,7,
181  7,6,4,5,2,3,0,1, 6,7,4,5,2,3,0,1
182  };
183 
184  *ix = x[pix];
185  *iy = y[pix];
186 }
187 
188 //......................................................................
189 
190 void HardwareDisplay::DAQToXY(unsigned int db,
191  unsigned int dcm,
192  unsigned int feb,
193  unsigned int pix,
194  unsigned int* ix,
195  unsigned int* iy)
196 {
197  unsigned int x1, x2, x3, x4;
198  unsigned int y1, y2, y3, y4;
199 
200  this->DiblockXY(db, &x1, &y1);
201  this->DCMXY (dcm, &x2, &y2);
202  this->FEBXY (feb, &x3, &y3);
203  this->PixXY (pix, &x4, &y4);
204 
205  *ix = x1+x2+x3+x4;
206  *iy = y1+y2+y3+y4;
207 }
208 
209 
210 
211 
212 
213 //......................................................................
214 
215 void HardwareDisplay::XYDiblock(unsigned int *db,
216  unsigned int ix)
217 {
218  //*db = 1 + ix/fNxPerDB; // diblocks numbered L to R
219  *db = fNdiblocks - ix/fNxPerDB; //diblocks numbered R to L
220 }
221 
222 //......................................................................
223 
224 void HardwareDisplay::XYDCM(unsigned int* dcm,
225  unsigned int iy)
226 {
227  *dcm = (fNdcmTop + fNdcmSide) - iy/fNyPerDCM;
228 }
229 
230 //......................................................................
231 
232 void HardwareDisplay::XYFEB(unsigned int* feb,
233  unsigned int ix,
234  unsigned int iy)
235 {
236  unsigned int x1 = (ix%fNxPerDB)/fNpixCols;
237  unsigned int y1 = (iy%fNyPerDCM)/fNpixRows;
238 
239  *feb = fNfebCols*(fNfebRows - 1 - y1) + x1;
240 }
241 
242 //......................................................................
243 
244 void HardwareDisplay::XYPix(unsigned int* pix,
245  unsigned int ix,
246  unsigned int iy)
247 {
248  static unsigned int P[8][4] = {{30,22,9,1},
249  {31,23,8,0},
250  {28,20,11,3},
251  {29,21,10,2},
252  {26,18,13,5},
253  {27,19,12,4},
254  {24,17,14,7},
255  {25,16,15,6}};
256 
257  unsigned int x1 = ix%fNpixCols;
258  unsigned int y1 = iy%fNpixRows;
259 
260  *pix = P[y1][x1];
261 }
262 
263 //......................................................................
264 
265 void HardwareDisplay::XYToDAQ(unsigned int* db,
266  unsigned int* dcm,
267  unsigned int* feb,
268  unsigned int* pix,
269  unsigned int ix,
270  unsigned int iy)
271 {
272  this->XYDiblock(db, ix);
273  this->XYDCM (dcm, iy);
274  this->XYFEB (feb, ix, iy);
275  this->XYPix (pix, ix, iy);
276 }
277 
278 //......................................................................
279 
281  unsigned int* plane,
282  unsigned int* view,
283  unsigned int* module,
284  unsigned int* cell,
285  unsigned int db,
286  unsigned int dcm,
287  unsigned int feb,
288  unsigned int pix)
289 {
292 
293  unsigned int dchan = cmap->encodeDChan(fDetId, db, dcm, feb, pix);
294  unsigned int lchan = cmap->encodeLChan(dchan);
295 
296  *block = cmap->computeBlock(lchan);
297  *plane = cmap->getPlane(lchan);
298  *cell = cmap->getCell(lchan);
299  *view = cmap->getView(dchan);
300  *module = ((*cell)/fNcellPerMod);
301 }
302 
303 //......................................................................
304 
306  unsigned int* pinb,
307  unsigned int* view,
308  unsigned int* module,
309  unsigned int* cell,
310  unsigned int db,
311  unsigned int dcm,
312  unsigned int feb,
313  unsigned int pix)
314 {
317 
318  unsigned int dchan = cmap->encodeDChan(fDetId, db, dcm, feb, pix);
319  unsigned int lchan = cmap->encodeLChan(dchan);
320 
321  *block = cmap->computeBlock(lchan);
322  *pinb = cmap->computePlaneInBlock(lchan);
323  *cell = cmap->getCell(lchan);
324  *view = cmap->getView(dchan);
325  *module = ((*cell)/fNcellPerMod);
326 }
327 
328 //......................................................................
329 
331  unsigned int* pinb,
332  unsigned int* view,
333  unsigned int* module,
334  unsigned int cell,
335  unsigned int* db,
336  unsigned int* block,
337  unsigned int* dcm,
338  unsigned int* feb,
339  unsigned int* pix)
340 {
343 
344  unsigned int lchan = cmap->encodeLChan(fDetId, plane, cell);
345  unsigned int dchan = cmap->encodeDChan(lchan);
346 
347  *pinb = cmap->computePlaneInBlock(lchan);
348  *view = cmap->getView(dchan);
349  *db = cmap->getDiBlock(dchan);
350  *block = cmap->computeBlock(lchan);
351  *dcm = cmap->getDCM (dchan);
352  *feb = cmap->getFEB(dchan);
353  *pix = cmap->getPixel (dchan);
354  *module = ((cell)/fNcellPerMod);
355 }
356 
357 ///////////////////////////////////////////////////////////////////////
void PlaneCellToDAQ(unsigned int plane, unsigned int *pinb, unsigned int *view, unsigned int *module, unsigned int cell, unsigned int *db, unsigned int *block, unsigned int *dcm, unsigned int *feb, unsigned int *pix)
void XYPix(unsigned int *pix, unsigned int ix, unsigned int iy)
Float_t y1[n_points_granero]
Definition: compare.C:5
void DAQToPlaneInBlockModCell(unsigned int *block, unsigned int *pinb, unsigned int *view, unsigned int *module, unsigned int *cell, unsigned int db, unsigned int dcm, unsigned int feb, unsigned int pix)
void XYDCM(unsigned int *dcm, unsigned int iy)
Float_t x1[n_points_granero]
Definition: compare.C:5
void XYFEB(unsigned int *feb, unsigned int ix, unsigned int iy)
virtual DetView_TYPE getView(dchan daqchan) const =0
Which view (X or Y) does this daq channel readout?
OStream cerr
Definition: OStream.cxx:7
void DAQToXY(unsigned int db, unsigned int dcm, unsigned int feb, unsigned int pix, unsigned int *ix, unsigned int *iy)
void XYToDAQ(unsigned int *db, unsigned int *dcm, unsigned int *feb, unsigned int *pix, unsigned int ix, unsigned int iy)
cell_t getCell(lchan logicalchan) const
Decode the cell number from an lchan.
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
void DiblockXY(unsigned int db, unsigned int *ix, unsigned int *iy)
#define P(a, b, c, d, e, x)
block
print "ROW IS " print row
Definition: elec2geo.py:31
static DAQChannelMap * getInstance(int detID)
Prototype Near Detector on the surface at FNAL.
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
void FEBXY(unsigned int feb, unsigned int *ix, unsigned int *iy)
void DCMXY(unsigned int dcm, unsigned int *ix, unsigned int *iy)
void DAQToPlaneModCell(unsigned int *block, unsigned int *plane, unsigned int *view, unsigned int *module, unsigned int *cell, unsigned int db, unsigned int dcm, unsigned int feb, unsigned int pix)
plane_t getPlane(lchan logicalchan) const
Decode the plane number from an lchan.
cmap::CMap class source code
Definition: CMap.cxx:17
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
virtual block_t computeBlock(lchan logicalchan) const =0
Which block is this lchan in?
uint32_t dchan
< DAQ Channel Map Package
virtual plane_t computePlaneInBlock(lchan logicalchan) const =0
Which global plane in this lchan in?
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
void XYDiblock(unsigned int *db, unsigned int ix)
void PixXY(unsigned int pix, unsigned int *ix, unsigned int *iy)
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.