DAQChannelMapTests.cpp
Go to the documentation of this file.
1 #include <cppunit/extensions/HelperMacros.h>
2 #include <DAQChannelMap/ChannelMapException.h>
3 #include <DAQChannelMap/DAQChannelMap.h>
4 
5 #define PATTERN1 0x01234567
6 #define PATTERN2 0x76543210
7 #define PATTERN3 0x89abcdef
8 #define PATTERN4 0xfedcba98
9 #define PATTERN5 0xf0f0f0f0
10 #define PATTERN6 0xe1e1e1e1
11 #define PATTERN7 0xd2d2d2d2
12 #define PATTERN8 0xc3c3c3c3
13 #define PATTERN9 0xb4b4b4b4
14 #define PATTERN0 0xa5a5a5a5
15 
16 #define BUFFER_WORDS 1000
17 #define SMALL_BUFFER_WORDS 1
18 
19 using namespace daqchannelmap;
20 
21 class DAQChannelMapTests : public CppUnit::TestFixture
22 {
23  CPPUNIT_TEST_SUITE(DAQChannelMapTests);
24  CPPUNIT_TEST(testBasicChannelGetOnline);
25  CPPUNIT_TEST(testDiBlockLookups);
26  CPPUNIT_TEST(testViewLookups);
27 
28 
29  CPPUNIT_TEST(testBasicOfflineChannelGet);
30  CPPUNIT_TEST(testBasicChannelGetOffline);
31  CPPUNIT_TEST(testDiBlockLookupsOffline);
32 
33  CPPUNIT_TEST(testPlaneLookupsOffline);
34  CPPUNIT_TEST(testViewLookupsOffline);
35 
36  CPPUNIT_TEST_SUITE_END();
37 
38 public:
39  void setUp();
40  void tearDown();
41 
42  void testBasicChannelGetOnline();
43  void testDiBlockLookups();
44  void testViewLookups();
45 
46  void testBasicChannelGetOffline();
47  void testBasicOfflineChannelGet();
48  void testDiBlockLookupsOffline();
49 
50  void testPlaneLookupsOffline();
51  void testViewLookupsOffline();
52 
53 private:
54 
56 
57 };
58 
59 // Register all the tests
61 CPPUNIT_REGISTRY_ADD_TO_DEFAULT("DAQChannelMap");
62 
63 void
65 {
66 }
67 
68 void
70 {
71 }
72 
73 void
75 {
76  // Retrieve the channel map class (singleton)
77  DAQChannelMap* chanMap;
78  chanMap = DAQChannelMap::getInstance();
79 
80  dchan theChan;
81 
82 
83  vector_count = 0;
84  printf("\nTesting Online Channel encoding/decoding\n");
85  // Test channel encoding/decoding
86  for(int det = IPND_ID; det < FARDET_ID; ++det){
87  for(int diblock = 1; diblock < NUM_DIBLOCK_DET[det]; ++diblock){
88  for(int dcm = 1; dcm < NUM_DCMS_DIBLOCK[det]; ++dcm ){
89  for(int port = 1; port < NUM_DCM_PORTS; ++port ){
90  for(int pixel = 1; pixel < (NUM_PIXELS+1); ++pixel ){
92  vector_count++;
93  CPPUNIT_ASSERT(DAQChannelMap::getDetector(theChan) == det);
94  CPPUNIT_ASSERT(DAQChannelMap::getDiBlock(theChan) == diblock);
95  CPPUNIT_ASSERT(DAQChannelMap::getDCMLocal(theChan) == dcm);
96  CPPUNIT_ASSERT(DAQChannelMap::getDCMPort(theChan) == port);
97  CPPUNIT_ASSERT(DAQChannelMap::getPixel(theChan) == pixel);
98  } // endfor pixel
99  } // endfor port
100  } // endfor dcm
101  } // endfor diblock
102  } // endfor det
103 
104  printf("Channel encoding/decoding complete\n");
105  printf("Run Condition: %d test vectors run", vector_count);
106 
107 }
108 
110 {
111  // Retrieve the channel map class (singleton)
112  DAQChannelMap* chanMap;
113  chanMap = DAQChannelMap::getInstance();
114 
115  lchan theChan;
116 
117  printf("\nTesting Offline Channel encoding/decoding\n");
118  vector_count = 0;
119  // Test channel encoding/decoding
120  for(int det = IPND_ID; det < FARDET_ID; ++det){
121  for(int plane = START_CHAN_IDX; plane < NUM_PLANES_DIBLOCK*NUM_DIBLOCK_DET[det]; ++plane){
122  for(int cell = START_CHAN_IDX; cell < NUM_YCHAN_PLANE[det]; ++cell ){
124  vector_count++;
125  CPPUNIT_ASSERT(DAQChannelMap::getDetectorOffline(theChan) == det);
126  CPPUNIT_ASSERT(DAQChannelMap::getPlaneOffline(theChan) == plane);
127  CPPUNIT_ASSERT(DAQChannelMap::getCellOffline(theChan) == cell);
128 
129 #ifdef VERBOSE_DEBUG
130  printf("%2d %4d %3d\t0x%08x\t %d %d %d\n", det, plane, cell, theChan,
131  DAQChannelMap::getDetectorOffline(theChan),
132  DAQChannelMap::getPlaneOffline(theChan),
133  DAQChannelMap::getCellOffline(theChan));
134 #endif /* VERBOSE_DEBUG */
135  } // endfor dcm
136  } // endfor diblock
137  } // endfor det
138  printf("Online Channel encoding/decoding complete\n");
139  printf("Run Condition: %d test vectors run", vector_count);
140 
141 }
142 
144 {
145  // Retrieve the channel map class (singleton)
146  DAQChannelMap* chanMap;
147  chanMap = DAQChannelMap::getInstance();
148 
149  dchan theChan;
150 
151  printf("\nTesting Channel encoding/decoding\n");
152 
153  int max_planes;
154  int max_cells;
155 
156  // Test channel encoding/decoding
157  for(int det = IPND_ID; det < FARDET_ID; ++det ){
158  max_planes = NUM_PLANES_DIBLOCK * NUM_DIBLOCK_DET[det];
159  max_cells = NUM_XCHAN_PLANE[det] > NUM_YCHAN_PLANE[det] ?
160  NUM_XCHAN_PLANE[det] : NUM_YCHAN_PLANE[det];
161  for(int plane = 1; plane < max_planes; ++plane ){
162  for(int cell = 1; cell < max_cells; ++cell ){
164  CPPUNIT_ASSERT(DAQChannelMap::getDetector(theChan) == det);
165  CPPUNIT_ASSERT(DAQChannelMap::getPlaneOffline(theChan) == plane);
166  CPPUNIT_ASSERT(DAQChannelMap::getCellOffline(theChan) == cell);
167  } // endfor cell
168  } // endfor plane
169  } // endfor det
170  printf("Offline Channel encoding/decoding complete\n");
171 
172 }
173 
174 void
176 {
177  // Retrieve the channel map class (singleton)
178  DAQChannelMap* chanMap;
179  chanMap = DAQChannelMap::getInstance();
180 
181  dchan theChan;
182  printf("\n");
183 
184  printf("\nTesting Diblock Information retrieval\n");
185 
186  int CHAN_AB_NEAR = (NUM_X_PLANES_A_BLOCK + NUM_X_PLANES_B_BLOCK)*NUM_CHAN_X_PLANE_IPND +
187  (NUM_Y_PLANES_A_BLOCK + NUM_Y_PLANES_B_BLOCK)*NUM_CHAN_Y_PLANE_IPND;
188  int CHAN_AA_NEAR = (NUM_X_PLANES_A_BLOCK + NUM_X_PLANES_A_BLOCK)*NUM_CHAN_X_PLANE_IPND +
189  (NUM_Y_PLANES_A_BLOCK + NUM_Y_PLANES_A_BLOCK)*NUM_CHAN_Y_PLANE_IPND;
190 
191  int CHAN_AB_FAR = (NUM_X_PLANES_A_BLOCK + NUM_X_PLANES_B_BLOCK)*NUM_CHAN_X_PLANE_FARDET +
192  (NUM_Y_PLANES_A_BLOCK + NUM_Y_PLANES_B_BLOCK)*NUM_CHAN_Y_PLANE_FARDET;
193  int CHAN_AA_FAR = (NUM_X_PLANES_A_BLOCK + NUM_X_PLANES_A_BLOCK)*NUM_CHAN_X_PLANE_FARDET +
194  (NUM_Y_PLANES_A_BLOCK + NUM_Y_PLANES_A_BLOCK)*NUM_CHAN_Y_PLANE_FARDET;
195 
196 
197  int NEAR_CHAN_VECTOR[] = {CHAN_IDX_0_1
198  CHAN_AB_NEAR, CHAN_AB_NEAR, CHAN_AA_NEAR,0x0};
199  int FAR_CHAN_VECTOR[] = {CHAN_IDX_0_1
200  CHAN_AB_FAR, CHAN_AB_FAR, CHAN_AA_FAR,
201  CHAN_AB_FAR, CHAN_AB_FAR, CHAN_AB_FAR,
202  CHAN_AB_FAR, CHAN_AA_FAR, CHAN_AB_FAR,
203  CHAN_AB_FAR, CHAN_AB_FAR, CHAN_AB_FAR,
204  CHAN_AA_FAR, CHAN_AB_FAR, CHAN_AB_FAR,
205  0x0};
206 
207  printf("-----\n");
208  for(int diblock=START_CHAN_IDX; diblock <= NUM_DIBLOCK_IPND; diblock++){
209  printf("IPND Detector, Diblock %2d = %02X ",diblock,
211  CPPUNIT_ASSERT(DAQChannelMap::getDiBlockType(diblock, IPND_ID) ==
212  DetectorDiBlockConfig_IPND[diblock]);
213  CPPUNIT_ASSERT(DAQChannelMap::getChanPerDiBlockType(DAQChannelMap::getDiBlockType(diblock, IPND_ID),
214  IPND_ID) == NEAR_CHAN_VECTOR[diblock]);
215  printf("(Channels: %3d)\n",DAQChannelMap::getChanPerDiBlockType(DAQChannelMap::getDiBlockType(diblock, IPND_ID),IPND_ID));
216  } // endfor diblock
217 
218  printf("-----\n");
219  for(int diblock=START_CHAN_IDX; diblock <= NUM_DIBLOCK_NDOS; diblock++){
220  printf("NDOS Detector, Diblock %2d = %02X ",diblock,
222  CPPUNIT_ASSERT(DAQChannelMap::getDiBlockType(diblock, NDOS_ID) ==
223  DetectorDiBlockConfig_NDOS[diblock]);
224  CPPUNIT_ASSERT(DAQChannelMap::getChanPerDiBlockType(DAQChannelMap::getDiBlockType(diblock, NDOS_ID),
225  NDOS_ID) == NEAR_CHAN_VECTOR[diblock]);
226  printf("(Channels: %3d)\n",DAQChannelMap::getChanPerDiBlockType(DAQChannelMap::getDiBlockType(diblock, NDOS_ID),NDOS_ID));
227 
228  } // endfor diblock
229 
230  printf("-----\n");
231  for(int diblock=START_CHAN_IDX; diblock <= NUM_DIBLOCK_NEARDET; diblock++){
232  printf("Near Detector, Diblock %2d = %02X ",diblock,
234  CPPUNIT_ASSERT(DAQChannelMap::getDiBlockType(diblock, NEARDET_ID) ==
235  DetectorDiBlockConfig_NEARDET[diblock]);
236  CPPUNIT_ASSERT(DAQChannelMap::getChanPerDiBlockType(DAQChannelMap::getDiBlockType(diblock, NEARDET_ID),
237  NEARDET_ID) == NEAR_CHAN_VECTOR[diblock]);
238 
239  printf("(Channels: %3d)\n",DAQChannelMap::getChanPerDiBlockType(DAQChannelMap::getDiBlockType(diblock, NEARDET_ID),NEARDET_ID));
240  } // endfor diblock
241 
242  printf("-----\n");
243  for(int diblock=START_CHAN_IDX; diblock <= NUM_DIBLOCK_FARDET; diblock++){
244  printf("Far Detector, Diblock %2d = %02X ",diblock,
246  CPPUNIT_ASSERT(DAQChannelMap::getDiBlockType(diblock, FARDET_ID) ==
247  DetectorDiBlockConfig_FARDET[diblock]);
248  CPPUNIT_ASSERT(DAQChannelMap::getChanPerDiBlockType(DAQChannelMap::getDiBlockType(diblock, FARDET_ID),
249  FARDET_ID) == FAR_CHAN_VECTOR[diblock]);
250 
251  printf("(Channels: %3d)\n",DAQChannelMap::getChanPerDiBlockType(DAQChannelMap::getDiBlockType(diblock, FARDET_ID),FARDET_ID));
252  } // endfor diblock
253 
254  printf("-----\n");
255 
256 }
257 
259  // Retrieve the channel map class (singleton)
260  DAQChannelMap* chanMap;
261  chanMap = DAQChannelMap::getInstance();
262 
263  lchan theLChan;
264 
265  printf("\nTesting Offline Diblock decoding\n");
266 
267  // Define some known test vectors and see what they return
268  uint32_t tvect[20]; // Test Vectors
269  tvect[0] = DAQChannelMap::encodeLChan(IPND_ID, 1 + END_OFFSET_IDX, 5);
270  tvect[1] = DAQChannelMap::encodeLChan(IPND_ID, 2 + END_OFFSET_IDX, 5);
271  tvect[2] = DAQChannelMap::encodeLChan(IPND_ID, 30 + END_OFFSET_IDX, 37);
272  tvect[3] = DAQChannelMap::encodeLChan(IPND_ID, 31 + END_OFFSET_IDX, 37);
273  tvect[4] = DAQChannelMap::encodeLChan(IPND_ID, 32 + END_OFFSET_IDX, 37);
274  tvect[5] = DAQChannelMap::encodeLChan(IPND_ID, 61 + END_OFFSET_IDX, 3);
275  tvect[6] = DAQChannelMap::encodeLChan(IPND_ID, 62 + END_OFFSET_IDX, 3);
276  tvect[7] = DAQChannelMap::encodeLChan(IPND_ID, 63 + END_OFFSET_IDX, 3);
277  tvect[8] = DAQChannelMap::encodeLChan(IPND_ID, 93 + END_OFFSET_IDX, 3);
278  tvect[9] = DAQChannelMap::encodeLChan(IPND_ID, 94 + END_OFFSET_IDX, 3);
279 
280 
281 
282  uint32_t avect1[] = {1,1,1,1,2,2,2,3,3,4};
283  uint32_t avect2[] = {1,1,1,1,1,1,1,2,2,2};
284  uint32_t avect3[] = {AB_BLOCK,AB_BLOCK,AB_BLOCK,AB_BLOCK,AB_BLOCK,
285  AB_BLOCK,AB_BLOCK,AB_BLOCK,AB_BLOCK,AB_BLOCK};
286 
287  for(int i=0; i< 10; i++){
288  printf("0x%08x |\t%d %d %x | \t%d %d %x\n",tvect[i],avect1[i],avect2[i],avect3[i],
289  DAQChannelMap::getBlockOffline(tvect[i]),
290  DAQChannelMap::getDiBlockOffline(tvect[i]),
291  DAQChannelMap::getDiBlockTypeOffline(tvect[i])
292  );
293  CPPUNIT_ASSERT(DAQChannelMap::getBlockOffline(tvect[i]) == avect1[i]);
294  CPPUNIT_ASSERT(DAQChannelMap::getDiBlockOffline(tvect[i]) == avect2[i]);
295  CPPUNIT_ASSERT(DAQChannelMap::getDiBlockTypeOffline(tvect[i]) == avect3[i]);
296  }
297 
298  printf("---\n");
299 
300  tvect[0] = DAQChannelMap::encodeLChan(NDOS_ID, 1 + END_OFFSET_IDX, 5);
301  tvect[1] = DAQChannelMap::encodeLChan(NDOS_ID, 2 + END_OFFSET_IDX, 5);
302  tvect[2] = DAQChannelMap::encodeLChan(NDOS_ID, 30 + END_OFFSET_IDX, 37);
303  tvect[3] = DAQChannelMap::encodeLChan(NDOS_ID, 31 + END_OFFSET_IDX, 37);
304  tvect[4] = DAQChannelMap::encodeLChan(NDOS_ID, 32 + END_OFFSET_IDX, 37);
305  tvect[5] = DAQChannelMap::encodeLChan(NDOS_ID, 61 + END_OFFSET_IDX, 3);
306  tvect[6] = DAQChannelMap::encodeLChan(NDOS_ID, 62 + END_OFFSET_IDX, 3);
307  tvect[7] = DAQChannelMap::encodeLChan(NDOS_ID, 63 + END_OFFSET_IDX, 3);
308  tvect[8] = DAQChannelMap::encodeLChan(NDOS_ID, 93 + END_OFFSET_IDX, 3);
309  tvect[9] = DAQChannelMap::encodeLChan(NDOS_ID, 94 + END_OFFSET_IDX, 3);
310  tvect[10] = DAQChannelMap::encodeLChan(NDOS_ID, 123 + END_OFFSET_IDX, 3);
311  tvect[11] = DAQChannelMap::encodeLChan(NDOS_ID, 124 + END_OFFSET_IDX, 3);
312  tvect[12] = DAQChannelMap::encodeLChan(NDOS_ID, 125 + END_OFFSET_IDX, 3);
313  tvect[13] = DAQChannelMap::encodeLChan(NDOS_ID, 126 + END_OFFSET_IDX, 3);
314  tvect[14] = DAQChannelMap::encodeLChan(NDOS_ID, 125 + END_OFFSET_IDX, 3);
315  tvect[15] = DAQChannelMap::encodeLChan(NDOS_ID, 126 + END_OFFSET_IDX, 3);
316 
317  uint32_t avect21[] = {1,1,1,1,2,2,2,3,3,4,4,4,5,5};
318  uint32_t avect22[] = {1,1,1,1,1,1,1,2,2,2,2,2,3,3};
319  uint32_t avect23[] = {AB_BLOCK,AB_BLOCK,AB_BLOCK,AB_BLOCK,AB_BLOCK,
320  AB_BLOCK,AB_BLOCK,AB_BLOCK,AB_BLOCK,AB_BLOCK,
321  AB_BLOCK,AB_BLOCK,AA_BLOCK,AA_BLOCK};
322 
323 
324  for(int i=0; i< 14; i++){
325  printf("0x%08x |\t%d %d %x | \t%d %d %x\n",tvect[i],avect21[i],avect22[i],avect23[i],
326  DAQChannelMap::getBlockOffline(tvect[i]),
327  DAQChannelMap::getDiBlockOffline(tvect[i]),
328  DAQChannelMap::getDiBlockTypeOffline(tvect[i])
329  );
330  CPPUNIT_ASSERT(DAQChannelMap::getBlockOffline(tvect[i]) == avect21[i]);
331  CPPUNIT_ASSERT(DAQChannelMap::getDiBlockOffline(tvect[i]) == avect22[i]);
332  CPPUNIT_ASSERT(DAQChannelMap::getDiBlockTypeOffline(tvect[i]) == avect23[i]);
333  }
334 
335  printf("---\n");
336 
337 }
338 
340  // Retrieve the channel map class (singleton)
341  DAQChannelMap* chanMap;
342  chanMap = DAQChannelMap::getInstance();
343 
344  dchan theDChan;
345  uint32_t view;
346 
347  printf("\nTesting Online View decoding\n");
348  // Test channel encoding/decoding
349  for(int det = IPND_ID; det <= FARDET_ID; ++det){
350  for(int diblock = 1; diblock <= NUM_DIBLOCK_DET[det]; ++diblock){
351  for(int dcm = 1; dcm <= NUM_DCMS_DIBLOCK[det]; ++dcm ){
352  for(int port = 1; port <= NUM_DCM_PORTS; ++port ){
353  for(int pixel = 1; pixel <= (NUM_PIXELS+1); ++pixel ){
354  theDChan = DAQChannelMap::encodeDChan(det,diblock,dcm,port,pixel);
355 
356  if(dcm <= NUM_X_DCMS[det]){
357  CPPUNIT_ASSERT(DAQChannelMap::getView(theDChan) == X_VIEW);
358  }
359 #ifdef VERBOSE_DEBUG
360  printf("%2d %2d %2d\t0x%08x\t %x \n",
361  DAQChannelMap::getDetector(theDChan),
362  DAQChannelMap::getDiBlock(theDChan),
363  DAQChannelMap::getDCMLocal(theDChan),
364  theDChan,
365  DAQChannelMap::getView(theDChan));
366 
367 #endif /* VERBOSE_DEBUG */
368  } // endfor pixel
369  } // endfor port
370  } // endfor dcm
371  } // endfor diblock
372  } // endfor det
373  printf("Online View decoding complete\n");
374 
375 
376  lchan theLChan;
377 
378  printf("\nTesting Offline View decoding\n");
379 
380  for(int det_ID = IPND_ID; det_ID <= FARDET_ID; det_ID++){
381  // Define some known test vectors and see what they return
382  uint32_t tvect[20]; // Test Vectors
383  uint32_t avect[20]; // Answer Vectors
384  tvect[0] = DAQChannelMap::encodeLChan(det_ID, 1 + END_OFFSET_IDX, 5);
385  avect[0] = X_VIEW;
386  tvect[1] = DAQChannelMap::encodeLChan(det_ID, 2 + END_OFFSET_IDX, 45);
387  avect[1] = Y_VIEW;
388  tvect[2] = DAQChannelMap::encodeLChan(det_ID, 3 + END_OFFSET_IDX, 5);
389  avect[2] = X_VIEW;
390  tvect[3] = DAQChannelMap::encodeLChan(det_ID, 4 + END_OFFSET_IDX, 45);
391  avect[3] = Y_VIEW;
392  tvect[4] = DAQChannelMap::encodeLChan(det_ID, 5 + END_OFFSET_IDX, 37);
393  avect[4] = X_VIEW;
394  tvect[5] = DAQChannelMap::encodeLChan(det_ID, 6 + END_OFFSET_IDX, 37);
395  avect[5] = Y_VIEW;
396  tvect[6] = DAQChannelMap::encodeLChan(det_ID, 7 + END_OFFSET_IDX, 37);
397  avect[6] = X_VIEW;
398  tvect[7] = DAQChannelMap::encodeLChan(det_ID, 62 + END_OFFSET_IDX, 3);
399  avect[7] = Y_VIEW;
400  tvect[8] = DAQChannelMap::encodeLChan(det_ID, 62 + END_OFFSET_IDX + 1, 3);
401  avect[8] = X_VIEW;
402  tvect[9] = DAQChannelMap::encodeLChan(det_ID, 62 + END_OFFSET_IDX + 2, 3);
403  avect[9] = Y_VIEW;
404  tvect[10] = DAQChannelMap::encodeLChan(det_ID, 62 + END_OFFSET_IDX + 3, 3);
405  avect[10] = X_VIEW;
406  tvect[11] = DAQChannelMap::encodeLChan(det_ID, 62 + END_OFFSET_IDX + 4, 3);
407  avect[11] = Y_VIEW;
408  tvect[12] = DAQChannelMap::encodeLChan(det_ID, 62 + END_OFFSET_IDX + 30, 3);
409  avect[12] = Y_VIEW;
410  tvect[13] = DAQChannelMap::encodeLChan(det_ID, 62 + END_OFFSET_IDX + 31, 3);
411  avect[13] = X_VIEW;
412  tvect[14] = DAQChannelMap::encodeLChan(det_ID, 124 + END_OFFSET_IDX, 3);
413  avect[14] = Y_VIEW;
414  tvect[15] = DAQChannelMap::encodeLChan(det_ID, 124 + END_OFFSET_IDX + 1, 3);
415  avect[15] = X_VIEW;
416  tvect[16] = DAQChannelMap::encodeLChan(det_ID, 124 + END_OFFSET_IDX + 2, 3);
417  avect[16] = Y_VIEW;
418  tvect[17] = DAQChannelMap::encodeLChan(det_ID, 124 + END_OFFSET_IDX + 31, 3);
419  avect[17] = X_VIEW;
420  tvect[18] = DAQChannelMap::encodeLChan(det_ID, 124 + END_OFFSET_IDX + 32, 3);
421  avect[18] = X_VIEW;
422  tvect[19] = DAQChannelMap::encodeLChan(det_ID, 124 + END_OFFSET_IDX + 33, 3);
423  avect[19] = Y_VIEW;
424 
425  for(int i=0; i< 20; i++){
426  if( (det_ID != IPND_ID) || (i < 10)){
427  printf("%d 0x%08x\t| %4d \t| %4d\n",i, tvect[i],avect[i],DAQChannelMap::getViewOffline(tvect[i]));
428  CPPUNIT_ASSERT(DAQChannelMap::getViewOffline(tvect[i]) == avect[i]);
429  }
430  }
431 
432  }
433 #ifdef FULL_TESTING
434  // Test channel encoding/decoding
435  for(int det = IPND_ID; det < FARDET_ID; ++det){
436  for(int plane = START_CHAN_IDX; plane < NUM_PLANES_DIBLOCK*NUM_DIBLOCK_DET[det]; ++plane){
437  for(int cell = START_CHAN_IDX; cell < NUM_YCHAN_PLANE[det]; ++cell ){
439  CPPUNIT_ASSERT(DAQChannelMap::getViewOffline(theLChan) == X_VIEW);
440  CPPUNIT_ASSERT(DAQChannelMap::getPlaneOffline(theLChan) == plane);
441  CPPUNIT_ASSERT(DAQChannelMap::getCellOffline(theLChan) == cell);
442 #ifdef VERBOSE_DEBUG
443  printf("%2d %4d %3d\t0x%08x\t %d %d %d\n", det, plane, cell, theLChan,
444  DAQChannelMap::getDetectorOffline(theLChan),
445  DAQChannelMap::getPlaneOffline(theLChan),
446  DAQChannelMap::getCellOffline(theLChan));
447 #endif /* VERBOSE_DEBUG */
448 
449  } // endfor dcm
450  } // endfor diblock
451  } // endfor det
452 #endif
453  printf("Offline View decoding complete\n");
454 
455 }
456 
457 
459  // Retrieve the channel map class (singleton)
460  DAQChannelMap* chanMap;
461  chanMap = DAQChannelMap::getInstance();
462 
463  lchan theLChan;
464  int thePlane;
465 
466  printf("\nTesting Offline Plane (diblock level) Decoding\n");
467  // Test plane number decoding
468 
469  vector_count = 0;
470  // Test channel encoding/decoding
471 
472 
473  for(int det = IPND_ID; det <= FARDET_ID; ++det){
474  for(int diblock = START_CHAN_IDX; diblock < NUM_DIBLOCK_DET[det]; ++diblock){
475  for(int plane = START_CHAN_IDX; plane < NUM_PLANES_DIBLOCK; ++plane){
476  if(START_CHAN_IDX){
477  thePlane = (diblock-1)*NUM_PLANES_DIBLOCK + plane;
478  }else{
479  thePlane = diblock*NUM_PLANES_DIBLOCK + plane;
480  }
481  for(int cell = START_CHAN_IDX; cell < DAQChannelMap::getMaxChanPlane((DetectorIdent)det,thePlane); ++cell ){
482  theLChan = DAQChannelMap::encodeLChan(det,thePlane,cell);
483  vector_count++;
484  CPPUNIT_ASSERT(DAQChannelMap::getPlaneDiBlockLocalOffline(theLChan) == plane);
485  } // endfor cell
486  } // endfor plane
487  } // endfor diblock
488  } // endfor det
489 
490  printf("Offline Plane decoding (block level) complete\n");
491  printf("Run Condition: %d test vectors run.\n", vector_count);
492 
493  vector_count = 0;
494 
495  // Test channel encoding/decoding
496  for(int det = IPND_ID; det <= FARDET_ID; ++det){
497  printf("Detector = %s\n",DetectorLabels[det]);
498  for(int block = START_CHAN_IDX; block < NUM_DIBLOCK_DET[det]*2; ++block){
499  // printf("Block Number: %d\n",block);
500  for(int plane = START_CHAN_IDX; plane < NUM_PLANES_BLOCK; ++plane){
501  // printf("Plane Number: %d \n",plane);
502  if(START_CHAN_IDX){
503  thePlane = (block-1)*NUM_PLANES_BLOCK + plane;
504  }else{
505  thePlane = block*NUM_PLANES_BLOCK + plane;
506  }
507  for(int cell = START_CHAN_IDX; cell < DAQChannelMap::getMaxChanPlane((DetectorIdent)det,thePlane); ++cell ){
508  theLChan = DAQChannelMap::encodeLChan(det,thePlane,cell);
509  vector_count++;
510  CPPUNIT_ASSERT(DAQChannelMap::getPlaneBlockLocalOffline(theLChan) == plane);
511  } // endfor cell
512  } // endfor plane
513  } // endfor diblock
514  } // endfor det
515 
516  printf("Offline Plane decoding complete\n");
517  printf("Run Condition: %d test vectors run.\n", vector_count);
518 
519 }
520 
522  // Retrieve the channel map class (singleton)
523  DAQChannelMap* chanMap;
524  chanMap = DAQChannelMap::getInstance();
525 
526  lchan theLChan;
527  lchan testchan;
528  int thePlane;
529 
530  printf("\nTesting View (diblock level) Decoding\n");
531  // Test view decoder
532 
533  vector_count = 0;
534 
535  int xcount=0;
536  int ycount=0;
537 
538  int theView;
539 
540  for(int det = IPND_ID; det <= FARDET_ID; ++det){
541  printf("Detector = %s\n",DetectorLabels[det]);
542  for(int diblock = START_CHAN_IDX; diblock < NUM_DIBLOCK_DET[det]; ++diblock){
543  // printf("Block Number: %d\n",block);
544 
545  xcount=0;
546  ycount=0;
547  for(int plane = START_CHAN_IDX; plane < NUM_PLANES_BLOCK; ++plane){
548  // printf("Plane Number: %d \n",plane);
549 
550  if(START_CHAN_IDX){
551  thePlane = (diblock-1)*NUM_PLANES_DIBLOCK + plane;
552  }else{
553  thePlane = diblock*NUM_PLANES_DIBLOCK + plane;
554  }
555 
556  theView = DAQChannelMap::getViewOffline(DAQChannelMap::encodeLChan(det,thePlane,START_CHAN_IDX));
557 
558  switch(theView){
559  case X_VIEW:
560  xcount++;
561  break;
562  case Y_VIEW:
563  ycount++;
564  break;
565  default:
566  printf("ERROR\n");
567  break;
568  }
569 
570  for(int cell = START_CHAN_IDX; cell < DAQChannelMap::getMaxChanPlane((DetectorIdent)det,thePlane); ++cell ){
571  theLChan = DAQChannelMap::encodeLChan(det,thePlane,cell);
572  vector_count++;
573 
574  switch(theView){
575  case X_VIEW:
576  CPPUNIT_ASSERT(DAQChannelMap::getPlaneViewDiBlockLocal(theLChan) == xcount);
577  break;
578  case Y_VIEW:
579  CPPUNIT_ASSERT(DAQChannelMap::getPlaneViewDiBlockLocal(theLChan) == ycount);
580  break;
581  default:
582  printf("ERROR\n");
583  break;
584  }
585 
586  } // endfor cell
587  } // endfor plane
588  } // endfor diblock
589  } // endfor det
590 
591 
592  printf("Offline View decoding complete\n");
593  printf("Run Condition: %d test vectors run.\n", vector_count);
594 
595 
596  printf("\nTesting Plane View (global level) Decoding\n");
597 
598  vector_count = 0;
599 
600  for(int det = IPND_ID; det <= FARDET_ID; ++det){
601  printf("Detector = %s\n",DetectorLabels[det]);
602 
603  xcount = 0;
604  ycount = 0;
605 
606  for(int diblock = START_CHAN_IDX; diblock <= NUM_DIBLOCK_DET[det]; ++diblock){
607  printf("%s\tDiblock %d \t0x%02X\tXp= %d\tYp = %d\n",DetectorLabels[det],diblock,DetectorDiBlockConfig[det][diblock],
608  DAQChannelMap::getPlanesDiBlockView((DiBlock_TYPE)DetectorDiBlockConfig[det][diblock],(DetView_TYPE)X_VIEW),
609  DAQChannelMap::getPlanesDiBlockView((DiBlock_TYPE)DetectorDiBlockConfig[det][diblock],(DetView_TYPE)Y_VIEW));
610  }
611 
612  for(int plane = START_CHAN_IDX; plane < NUM_DIBLOCK_DET[det]*NUM_PLANES_DIBLOCK; ++plane){
613  // printf("Plane Number: %d\n",plane);
614 
615  theLChan = DAQChannelMap::encodeLChan(det,plane,START_CHAN_IDX);
616  theView = DAQChannelMap::getViewOffline(theLChan);
617 
618  switch(theView){
619  case X_VIEW:
620  xcount++;
621  break;
622  case Y_VIEW:
623  ycount++;
624  break;
625  default:
626  printf("ERROR\n");
627  break;
628  }
629 
630  vector_count++;
631 
632 
633 
634  DAQChannelMap::getPlaneViewLocal(theLChan);
635 
636  switch(theView){
637  case X_VIEW:
638  CPPUNIT_ASSERT(DAQChannelMap::getPlaneViewLocal(theLChan) == xcount);
639  break;
640  case Y_VIEW:
641  CPPUNIT_ASSERT(DAQChannelMap::getPlaneViewLocal(theLChan) == ycount);
642  break;
643  default:
644  printf("ERROR\n");
645  break;
646  }
647 
648  } // endfor plane
649  } // endfor det
650 
651  printf("Offline Plane View decoding complete\n");
652  printf("Run Condition: %d test vectors run.\n", vector_count);
653 
654 
655 }
int getDetector(uint32_t anychan) const
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
Size of the Near detector in diblocks including muon catcher.
virtual DetView_TYPE getView(dchan daqchan) const =0
Which view (X or Y) does this daq channel readout?
#define CHAN_IDX_0_1
This thing has to have a comma at the end or it could be entirely empty.
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(DAQChannelMapTests,"DAQChannelMap")
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
Identifier for the Y measuring view of the detector (side)
block
print "ROW IS " print row
Definition: elec2geo.py:31
static DAQChannelMap * getInstance(int detID)
Size of the Far detector in diblocks.
Identifier for the X measuring view of the detector (top)
printf("%d Experimental points found\n", nlines)
Size of the IP/ND detector in diblocks.
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
CPPUNIT_REGISTRY_ADD_TO_DEFAULT("DAQChannelMap")
DetView_TYPE
Types of Detector View.
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
DiBlock_TYPE
Types of Diblock.
uint32_t dchan
< DAQ Channel Map Package
int port
Definition: client_test.C:9
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
virtual DiBlock_TYPE getDiBlockType(dchan chan) const =0
What format is the diblock? Only relevant in NDOS.
Size of the NDOS detector in diblocks including muon catcher.