DAQChannelMapOLD.cpp
Go to the documentation of this file.
1 #include "DAQChannelMap/DAQChannelMapOLD.h"
2 #include "DAQChannelMap/BitFields.h"
3 #include "DAQChannelMap/boundscheck.h"
4 #include "NovaDAQConventions/DAQConventions.h"
5 
6 #include <stdio.h>
7 #include <iostream>
8 
9 using namespace daqchannelmap;
10 
11 /**********************************************************************************
12  * DAQChannelMap Class Implimentation *
13  **********************************************************************************/
14 
15 // Initialize the singleton pointer to NULL
17 
18 //------------------------------------------------------------------------------
19 /*! getInstance method returns the current instance if there is one
20  or creates the initial instance if there is not one */
22  if(_instanceID == NULL){ // Check if there is an instance active
23  _instanceID = new DAQChannelMapOLD(); // If there is not, make a new one
24  }
25  return _instanceID;
26 }
27 
28 //------------------------------------------------------------------------------
29 DAQChannelMapOLD::DAQChannelMapOLD(){ }// end of DAQChannelMapOLD constructor
30 DAQChannelMapOLD::~DAQChannelMapOLD(){ } //!< Default Destructor
31 
32 //------------------------------------------------------------------------------
34  dcm_id_t dcmid, dcm_link_t dcmport,
35  pixel_t pixel) const{
36  dchan chan = 0x0;
37  BITFIELDSET(chan,detector, MASK_DETECTOR, SHIFT_DETECTOR);
38  BITFIELDSET(chan,diblock, MASK_DIBLOCK, SHIFT_DIBLOCK);
39  BITFIELDSET(chan,dcmid, MASK_DCMID, SHIFT_DCMID);
40  BITFIELDSET(chan,dcmport, MASK_DCMPORT, SHIFT_DCMPORT);
42  return chan;
43 }
44 
45 //------------------------------------------------------------------------------
47  offline_plane_t plane_0,
48  offline_cell_t cell_0) const{
49  lchan chan = 0x0;
53  return chan;
54 }
55 
56 //------------------------------------------------------------------------------
58 
59  const int detector = getDetectorOffline(chan);
60  const offline_plane_t plane_0 = getPlaneOffline(chan);
61  const offline_cell_t cell_0 = getCellOffline(chan);
62  //const DiBlock_TYPE diblock_type = getDiBlockTypeOffline(chan);
63  //uint32_t cell_1 = 1;
64 
65 // // Test for MC DCM 2...
66 // if(detector==novadaq::cnv::kNEARDET && diblock_type==MC_ND_DIBLOCK){
67 // const DetPlane_TYPE plane_type = getPlaneTypeOffline(chan);
68 // const dcm_id_t dcm_id = getDCM(detector, plane_type, diblock_type, 10000203);
69 
70 // if(dcm_id==2){
71 // cell_1 = 63 - cell_0 - 32;
72 // }
73 // else cell_1 = cell_0;
74 // }
75 // else cell_1 = cell_0;
76 
77 
78  return encodeDChan(detector, plane_0, cell_0);
79 }
80 
81 
82 //------------------------------------------------------------------------------
84  ,const offline_plane_t plane_0
85  ,const offline_cell_t cell_0 ) const {
86 
87  const block_t block_number = getBlockNumber(detector, plane_0);
88  const diblock_t diblock_number = getDiblockNumber(block_number);
89  const DiBlock_TYPE diblock_type = getDiBlockType(detector, diblock_number);
90  const DetPlane_TYPE plane_type = getPlaneType(detector, plane_0);
91  const online_cell_t online_cell_0 = offlineCellToOnlineCell(cell_0, detector, plane_type, diblock_type);
92 
93 
94  const dcm_id_t dcm_id = getDCM(detector, plane_type, diblock_type, online_cell_0);
95  const dcm_link_t dcm_link = getDCMLink(detector, plane_0, online_cell_0, diblock_type, block_number, plane_type);
96 
97  const pixel_t pixel = getPixel(online_cell_0, diblock_type);
98 
99  const apd_pixel_t apd_pixel = pixel2APDPixel(pixel);
100 
101 
102  //std::cout<<" diblock: "<<diblock_number<<" diblock type: "<<diblock_type<<" dcm: "<<dcm_id<<" feb: "<<dcm_link<<" pixel: "<<apd_pixel<<std::endl;
103 
104  return encodeDChan(detector, diblock_number, dcm_id, dcm_link, apd_pixel);
105 
106 }
107 
108 
109 //------------------------------------------------------------------------------
111 
112  const int det = getDetector(chan);
113  const diblock_t diblock_id = getDiBlock(chan);
114  const dcm_id_t dcm_id = getDCM(chan);
115  const dcm_link_t dcm_link_id = getDCMLink(chan);
116  const apd_pixel_t apd_pixel_id = getPixel(chan);
117 
118 
119  const offline_plane_t plane_0 = getPlane(det, diblock_id, dcm_id, dcm_link_id);
120  const offline_cell_t cell_0 = getCell(det, diblock_id, dcm_id, dcm_link_id, apd_pixel_id);
121 
122  return encodeLChan(det, plane_0, cell_0);
123 }
124 
125 //------------------------------------------------------------------------------
127  return (int)BOUNDSCHECK(
131 }
132 
133 //------------------------------------------------------------------------------
135  return BOUNDSCHECK(
138 }
139 
140 //------------------------------------------------------------------------------
142  return BOUNDSCHECK(
145 }
146 
147 //------------------------------------------------------------------------------
149  return BOUNDSCHECK(
152 }
153 
154 //------------------------------------------------------------------------------
156  return BOUNDSCHECK(
159 }
160 
161 //------------------------------------------------------------------------------
163  const int detector_id = getDetector(daqchan);
164  const dcm_id_t dcm_id = getDCM(daqchan);
165  const DiBlock_TYPE diblock_type = getDiBlockType(daqchan);
166 
167  const DetPlane_TYPE plane_type = getPlaneType(detector_id, dcm_id, diblock_type);
168 
169  return detPlaneToDetView(plane_type);
170 }
171 
172 //------------------------------------------------------------------------------
173 //! Returns the type of diblock that the channel was on
175  const int detector = getDetector(daqchan);
176  const diblock_t diblock_number = getDiBlock(daqchan);
177 
178  return getDiBlockType(detector, diblock_number);//calling base
179 }
180 
181 //------------------------------------------------------------------------------
182 //! Returns the Plane in coordinates relative to the dcm (i.e. 0-31)
184 
185  const int detector_id = getDetector(daqchan);
186  const diblock_t diblock_id = getDiBlock(daqchan);
187  const dcm_id_t dcm_id = getDCM(daqchan);
188  const dcm_link_t dcm_link_id = getDCMLink(daqchan);
189 
190  return getPlane(detector_id, diblock_id, dcm_id, dcm_link_id);
191 }
192 
193 //------------------------------------------------------------------------------
194 //! Returns the Plane in coordinates relative to the dcm (i.e. 0-31)
195 offline_plane_t DAQChannelMapOLD::getPlane(const int detector_id, const diblock_t diblock_id, const dcm_id_t dcm_id, const dcm_link_t dcm_link_id) {
196 
197  /// Now Based on (detector_id, diblock_id, dcm_id, dcm_link_id), calculate these variables
198  const DiBlock_TYPE diblock_type = getDiBlockType(detector_id, diblock_id);// calling base
199  const offline_plane_t local_plane_in_diblock_view = getLocalPlaneInDiblockView(detector_id, dcm_link_id, diblock_type);
200  const DetPlane_TYPE plane_type = getPlaneType(detector_id, dcm_id, diblock_type);
201 
202  return getNumberOfPlanesBeforeDiblock(detector_id, diblock_id)
203  +getLocalPlaneInDiblock(local_plane_in_diblock_view, diblock_type, plane_type);
204 }
205 
206 //------------------------------------------------------------------------------
207 // Offline Channel Decoding
209 
211 
212 
213  return (int)BOUNDSCHECK(
217 }
218 
219 //------------------------------------------------------------------------------
221 
223 
224  return BOUNDSCHECK(
226  0,NUM_PLANES_DIBLOCK[getDetectorOffline(chan)]*NUM_DIBLOCK_DET[getDetectorOffline(chan)], ERROR_PLANE_OUTRANGE);
227 }
228 
229 //------------------------------------------------------------------------------
231  return BOUNDSCHECK(
234 }
235 
236 //------------------------------------------------------------------------------
238 
239  const int detector = getDetectorOffline(chan);
240  const offline_plane_t plane_0 = getPlaneOffline(chan); // plane starts from 0 in Offline
241 
242  return getBlockNumber(detector, plane_0);
243 }
244 //------------------------------------------------------------------------------
246  const int detector = getDetectorOffline(chan);
247  const offline_plane_t plane_0 = getPlaneOffline(chan); // plane starts from 0 in Offline
248 
249  return getDiblockNumber(detector, plane_0);
250 }
251 
252 //------------------------------------------------------------------------------
253 // Returns the module relative to the current dcm that a channel belongs to
254 // (normally 0 or 1 but could be 2 for the NDOS or NearDet muon catchers.)
255 //
256 // For FarDet and NearDet:
257 // Local Module 0 refers to DCM ports 0-31
258 // Local Module 1 refers to DCM ports 32-63
259 // For NDOS:
260 // Local Module 0 refers to DCM ports in range 0-15, 32-47
261 // Local Module 1 refers to DCM ports in range 16-31, 48-63
262 //------------------------------------------------------------------------------
263 uint32_t DAQChannelMapOLD::getLocalModuleInDCM(const int detector_id, dcm_id_t dcm_id, dcm_link_t dcm_link, const DiBlock_TYPE diblock_type) const {
264 
265  // if(detector_id == novadaq::cnv::kFARDET) return dcm_link/32;
266 
267  /// Compute for FarDet or NearDet according to the above comment
268  if(detector_id == novadaq::cnv::kNEARDET){
269 
270  /// NearDet muon catcher must be treated differently
271  if(detector_id == novadaq::cnv::kNEARDET && diblock_type == MC_ND_DIBLOCK) {
272 
273  // The mapping for each DCM in the NearDet MC is different (go team!!!)
274  // There are 11 planes and the FEBs are plugged in in numerical order with
275  // no gaps (0-32 for the top, 0-21 for the side) so dividing by 11 tells you
276  // which module you are in.
277  if(dcm_id == 1) {
278  if(dcm_link > 32) return -1; // Flag as uninstrumented.
279  else return dcm_link/11;
280  }
281 
282  // The FEBs for DCM 2 are plugged in in reverse order, which is why I have
283  // to do the 1-(module) thing.
284  if(dcm_id == 2) {
285  if(dcm_link > 21) return -1; // Flag as uninstrumented.
286  else return dcm_link/11;
287  // else return 1 - (dcm_link/11); This was implemented when the FEBs were switched for Mod 0 and Mod 1.
288  }
289 
290  // Otherwise this is DCM 3 or 4 which for the NearDet MC is uninstrumented.
291  return -1;
292 
293  }
294 
295  // Otherwise this is a "normal" NearDet diblock.
296  if(dcm_id==3){
297  if(dcm_link/32 == 0) return 1;
298  else if(dcm_link/32 == 1) return 0;
299  }
300  else return dcm_link / 32 ;
301  }
302 
303  /// Otherwise this must be NDOS, and compute according to the above comment
304 
305  if(detector_id == novadaq::cnv::kNDOS){
306  /// Muon catcher screws things up
307  if(diblock_type == MC_DIBLOCK) return dcm_link / 16;
308 
309  return (dcm_link % 32)/16;
310  }
311 
312  /// If not NearDet or NDOS, then must be FarDet.
313  return dcm_link/32;
314 }
315 
316 //------------------------------------------------------------------------------
317 //! Returns the Cell in coordinates relative to the detector view (i.e. 1-"a big number" for far det)
318 // Cells are referenced in the offline 0-95 (NDOS) with cell 0 at the snout end in X-View
319 // And cell 0 at the bottom of the detector
321 
322  /// straight extractions
323  const int detector_id = getDetector(daqchan);
324  const diblock_t diblock_number = getDiBlock(daqchan);
325  const dcm_id_t dcm_id = getDCM(daqchan);
326  const dcm_link_t dcm_link_id = getDCMLink(daqchan);
327  const apd_pixel_t apd_pixel_id = getPixel(daqchan);
328 
329  return getCell(detector_id, diblock_number, dcm_id, dcm_link_id, apd_pixel_id);
330 }
331 
332 
333 //------------------------------------------------------------------------------
335  const diblock_t diblock_number,
336  const dcm_id_t dcm_id ,
337  const dcm_link_t dcm_link_id ,
338  const apd_pixel_t apd_pixel_id
339  ) const {
340 
341 
342  const DiBlock_TYPE diblock_type = getDiBlockType(detector_id, diblock_number);
343 
344  const pixel_t pixel_id = APDPixel2Pixel(apd_pixel_id);
345 
346  uint32_t number_of_x_dcm = 0;
347  const DetPlane_TYPE plane_type = getPlaneType(detector_id, dcm_id, diblock_type, number_of_x_dcm);
348  const online_cell_t online_cell = getOnlineCell(detector_id, dcm_id, dcm_link_id, pixel_id, diblock_type, plane_type, number_of_x_dcm);
349 
350  return onlineCellToOfflineCell(online_cell, detector_id, plane_type, diblock_type);
351 }
352 
353 
354 
355 //------------------------------------------------------------------------------
357  const diblock_t diblock_id = getDiBlockOffline(chan);
358  const int detector = getDetectorOffline(chan);
359 
360  return getDiBlockType(detector, diblock_id);// calling base
361 }
362 
363 //------------------------------------------------------------------------------
365  const int detector = getDetectorOffline(logicalchan);
366  const uint32_t block_number = getBlockOffline(logicalchan);
367 
368  return getBlockType(block_number, detector);
369 }
370 
371 //------------------------------------------------------------------------------
373 
374  const diblock_t diblockID = getDiblockNumber(blockID); //< we count diblocks from 1
375  const uint32_t local_block_number_in_diblock = getLocalBlockInDiblock(blockID); //< we count from 0
376 
377  const DiBlock_TYPE diblock_type = getDiBlockType(detector, diblockID);// calling base
378 
379  return getBlockType(diblock_type, local_block_number_in_diblock);
380 }
381 
382 //------------------------------------------------------------------------------
383 // Returns local plane number for the diblock from offline channel
385  const int detector = getDetectorOffline(chan);
386  const offline_plane_t plane_0 = getPlaneOffline(chan); //< plane starts from 0 in Offline
387 
388  return getLocalPlaneInDiblock(detector, plane_0);
389 }
390 
391 //------------------------------------------------------------------------------
393  const int detector = getDetectorOffline(chan);
394  const offline_plane_t plane_0 = getPlaneOffline(chan); // plane starts from 0 in Offline
395 
396  return getLocalPlaneInBlock(detector, plane_0);
397 }
398 
399 //------------------------------------------------------------------------------
402 }
403 
404 //------------------------------------------------------------------------------
406  const DetBlock_TYPE block_type = getBlockType(chan);
407  const uint32_t local_plane_in_block = getLocalPlaneInBlockOffline(chan);
408 
409  const DetPlane_TYPE start_plane_type = getStartPlaneTypeInBlock(block_type);
410 
411  /// If local plane is even, then the view is the same as the one that the block starts with
412  if(EVEN(local_plane_in_block)) return start_plane_type;
413 
414  return getOtherPlaneType(start_plane_type);
415 }
416 
417 //------------------------------------------------------------------------------
419 
420  const offline_plane_t local_plane_in_block = getLocalPlaneInBlockOffline(chan);
421 
422  offline_plane_t local_plane_in_block_view = local_plane_in_block / 2;
423 
424  const int local_block_in_diblock = getLocalBlockInDiblockOffline(chan);
425 
426  if(local_block_in_diblock == 0) {
427  return local_plane_in_block_view;
428  }
429 
430  /// otherwise, we need to calculate how many planes of the same view
431  /// were in the first diblock
432 
433  const int detector = getDetectorOffline(chan);
434 
435  /// The first block of the diblock - it's the one before the current
436  const block_t block_id_of_the_first_block_in_diblock = getBlockOffline(chan) - 1;
437  const DetBlock_TYPE block_type_of_the_first_block_in_diblock = getBlockType(block_id_of_the_first_block_in_diblock, detector);
438 
439  /// View of the plane
440  const DetPlane_TYPE plane_type = getPlaneTypeOffline(chan);
441 
442  /// Add the number of planes in the view for that diblock
443  local_plane_in_block_view += getNumberOfPlaneTypeInBlock(block_type_of_the_first_block_in_diblock, plane_type);
444 
445  return local_plane_in_block_view;
446 }
447 
448 //------------------------------------------------------------------------------
450  ,const offline_plane_t plane_0
451  ) const {
452  const block_t block_number = getBlockNumber(detector, plane_0);
453  return getLocalPlaneInDiblockView(detector, plane_0, block_number);
454 }
455 
456 //------------------------------------------------------------------------------
458  ,const offline_plane_t plane_0
459  ,const block_t block_number
460  ) const {
461 
462  const offline_plane_t local_plane_in_block = getLocalPlaneInBlock(detector, plane_0);
463 
464  offline_plane_t local_plane_in_diblock_view = local_plane_in_block / 2;
465 
466  const int local_block_in_diblock = getLocalBlockInDiblock(block_number);
467 
468  if(local_block_in_diblock == 0){
469  return local_plane_in_diblock_view;
470  }
471 
472  /// otherwise, we need to calculate how many planes of the same view
473  /// were in the first diblock
474 
475  /// The first block of the diblock - it's the one before the current
476  const block_t block_id_of_the_first_block_in_diblock = block_number - 1;
477  const DetBlock_TYPE block_type_of_the_first_block_in_diblock = getBlockType(block_id_of_the_first_block_in_diblock, detector);
478 
479  /// View of the plane
480  const DetPlane_TYPE plane_type = getPlaneType(detector, plane_0);
481 
482  /// Add the number of planes in the view for that diblock
483  local_plane_in_diblock_view += getNumberOfPlaneTypeInBlock(block_type_of_the_first_block_in_diblock, plane_type);
484 
485  return local_plane_in_diblock_view;
486 }
487 
488 
489 //------------------------------------------------------------------------------
491  ,const offline_plane_t plane_0
492  ,const block_t block_number
493  ,const DetPlane_TYPE plane_type
494  ) const {
495 
496  const offline_plane_t local_plane_in_block = getLocalPlaneInBlock(detector, plane_0);
497 
498  offline_plane_t local_plane_in_diblock_view = local_plane_in_block / 2;
499 
500  const int local_block_in_diblock = getLocalBlockInDiblock(block_number);
501 
502  if(local_block_in_diblock == 0){
503  return local_plane_in_diblock_view;
504  }
505 
506  /// otherwise, we need to calculate how many planes of the same view
507  /// were in the first diblock
508 
509  /// The first block of the diblock - it's the one before the current
510  const block_t block_id_of_the_first_block_in_diblock = block_number - 1;
511  const DetBlock_TYPE block_type_of_the_first_block_in_diblock = getBlockType(block_id_of_the_first_block_in_diblock, detector);
512 
513  /// Add the number of planes in the view for that diblock
514  local_plane_in_diblock_view += getNumberOfPlaneTypeInBlock(block_type_of_the_first_block_in_diblock, plane_type);
515 
516  return local_plane_in_diblock_view;
517 }
518 
519 
520 //------------------------------------------------------------------------------
521 // Returns the plane number of the channel in the X or Y view
523 
524  const diblock_t diblock = getDiBlockOffline(chan);
525  const int detector = getDetectorOffline(chan);
526  const DetPlane_TYPE plane_type = getPlaneTypeOffline(chan);
527 
528  // Sum the number of planes in this view prior to the current diblock
529  // that the channel is from
530 
531  /// the plane number that the current channel is on in the local diblock
532  uint32_t total_planes = getLocalPlaneInDiblockViewOffline(chan);
533 
534  for(uint32_t idiblock = 0; idiblock < diblock; ++idiblock){
535  const DiBlock_TYPE diblock_type = getDiBlockType(detector, idiblock);// calling base
536  total_planes += getNumberOfPlaneTypeInDiblock(diblock_type, plane_type);
537  }// end of loop over diblocks
538 
539  return total_planes;
540 }
541 
542 //------------------------------------------------------------------------------
544 
545  const int detector = getDetectorOffline(chan);
546  const offline_plane_t plane_0 = getPlaneOffline(chan);
547  const offline_cell_t cell_0 = getCellOffline(chan);
548 
549  return getDCM(detector, plane_0, cell_0);
550 }
551 
552 
553 //------------------------------------------------------------------------------
555  ,const offline_plane_t plane_offline_0
556  ,const offline_cell_t cell_offline_0) const{
557 
558  const diblock_t diblock_number = getDiblockNumber(detector, plane_offline_0);
559  const DiBlock_TYPE diblock_type = getDiBlockType(detector, diblock_number);
560 
561  const DetPlane_TYPE plane_type = getPlaneType(detector, plane_offline_0);
562 
563  const online_cell_t online_cell_0 = offlineCellToOnlineCell(cell_offline_0, detector, plane_type, diblock_type);
564 
565  return getDCM(detector, plane_type, diblock_type, online_cell_0);
566 }
567 
568 
569 //------------------------------------------------------------------------------
571  ,const DetPlane_TYPE plane_type
572  ,const DiBlock_TYPE diblock_type
573  ,const online_cell_t online_cell_0) const
574 {
575 
576  const dcm_id_t first_dcm_in_view = getFirstDCMInView(detector, plane_type, diblock_type);
577 
578  // Treat the NearDet muon catcher as a special case.
579  if(detector == novadaq::cnv::kNEARDET && diblock_type == MC_ND_DIBLOCK) {
580  // This one is simple: If this is a vertical (XZ) plane, then this is DCM 1.
581  // If this is a horizontal (YZ) plane, then this is DCM 2.
582  if(plane_type == XZ_PLANE) return 1;
583  else return 2;
584  }
585 
586  /// For NearDet the first DCM is half-populated
587  // NOTE: "first_dcm_in_view == 1" really is asking "Is this the XZ_VIEW?" but this is
588  // how it was originally coded and I don't want to mess with something that
589  // isn't broken.
590  if(detector == novadaq::cnv::kNEARDET && first_dcm_in_view == 1) {
591  if(online_cell_0 >= NUM_CELLS)
592  return first_dcm_in_view + 1;
593 
594  return first_dcm_in_view;
595  }
596 
597  return first_dcm_in_view + online_cell_0 / getNumberOfCellsPerDCM(diblock_type);
598 }
599 
600 
601 //------------------------------------------------------------------------------
603  ,const offline_plane_t plane_0
604  ,const offline_cell_t cell_0 ) const {
605 
606  const DetPlane_TYPE plane_type = getPlaneType(detector, plane_0);
607  const diblock_t diblock_number = getDiblockNumber(detector, plane_0);
608  const DiBlock_TYPE diblock_type = getDiBlockType(detector, diblock_number);
609  const online_cell_t online_cell_0 = offlineCellToOnlineCell(cell_0, detector, plane_type, diblock_type);
610 
611  return getPixel(online_cell_0, diblock_type);
612 }
613 
614 //------------------------------------------------------------------------------
616  ,const DiBlock_TYPE diblock_type) const {
617  const online_cell_t local_cell_in_dcm = getLocalCellInDCM(online_cell_0, diblock_type);
618 
619  return local_cell_in_dcm % NUM_PIXELS;
620  }
621 
622 
623 //------------------------------------------------------------------------------
625 
626  const int detector = getDetectorOffline(chan);
627  const offline_plane_t plane_0 = getPlaneOffline(chan);
628  const offline_cell_t cell_0 = getCellOffline(chan);
629 
630  return getDCMLink(detector, plane_0, cell_0);
631 }
632 
633 //------------------------------------------------------------------------------
635  ,const offline_plane_t plane_0
636  ,const offline_cell_t cell_0) const {
637 
638 
639  const DetPlane_TYPE plane_type = getPlaneType(detector, plane_0);
640 
641  const block_t block_number = getBlockNumber(detector, plane_0);
642  const diblock_t diblock_number = getDiblockNumber(block_number);
643  const DiBlock_TYPE diblock_type = getDiBlockType(detector, diblock_number);
644 
645  const online_cell_t online_cell_0 = offlineCellToOnlineCell(cell_0, detector, plane_type, diblock_type);
646 
647 
648  return getDCMLink(detector, plane_0, online_cell_0, diblock_type, block_number, plane_type);
649 }// end of getDCMLinkOffline
650 
651 
652 //------------------------------------------------------------------------------
654  ,const offline_plane_t plane_0
655  ,const online_cell_t online_cell_0
656  ,const DiBlock_TYPE diblock_type
657  ,const block_t block_number
658  ,const DetPlane_TYPE plane_type) const {
659 
660  // For the NearDet, FEBs 32-63 in DCM 1 are not instrumented but there is no gap in cells.
661  // So if we are in DCM 2, we need to shift global cell number by 32 to compensate for this gap.
662  const uint32_t dcm = getDCM(detector, plane_type, diblock_type, online_cell_0);
663  online_cell_t temp_cell = online_cell_0;
664  if(detector == novadaq::cnv::kNEARDET && dcm == 2 && diblock_type != MC_ND_DIBLOCK)
665  temp_cell += 32;
666 
667  const uint32_t local_module = getLocalModuleInDCMOffline(temp_cell, diblock_type); //< either 0 or 1 (or 2 in the MC)
668  const offline_plane_t local_plane_in_diblock_view = getLocalPlaneInDiblockView(detector, plane_0, block_number, plane_type);
669 
670  /// For FarDet and NearDet, the calculation is different than it is for NDOS
671  if(detector == novadaq::cnv::kFARDET || detector == novadaq::cnv::kNEARDET){
672 
673  // Treat the NearDet muon catcher as a special case
674  if(detector == novadaq::cnv::kNEARDET && diblock_type == MC_ND_DIBLOCK) {
675  return local_plane_in_diblock_view + 11*local_module;
676  // comment..
677  // return local_plane_in_diblock_view + 11*(1-local_module);
678  }
679 
680  // Otherwise this is a "normal" FarDet or NearDet diblock.
681  return local_plane_in_diblock_view + 32*local_module;
682  }
683 
684  // Otherwise, this must be NDOS
685 
686  /// Calculate DCM link number according to NOvA-doc-4219
687  /// This math is true for NDOS only
688  dcm_link_t dcm_link = local_plane_in_diblock_view + 16*local_module;
689  if(local_plane_in_diblock_view > 15) dcm_link += 16;
690 
691  return dcm_link;
692 }// end of getDCMLinkOffline
693 
694 
695 
696 //------------------------------------------------------------------------------
697 // If it's the upstream block in diblock, then it's 0, if not, it's 1
699  const uint32_t block = getBlockOffline(logicalchan);
700 
701  return getLocalBlockInDiblock(block);
702 }// end of getLocalBlockInDiblockOffline
703 
704 //------------------------------------------------------------------------------
706  return encodeDChan(encodeLChan(detector,plane,cell));
707 }
708 
709 //------------------------------------------------------------------------------
710 /// First DCM in the view. if the channel is in a XZ plane, the DCM is 1. Otherwise, it's 7 for the far detector,
711 /// 3 for the near detector, and 2 for NDOS
713 
714  const DetPlane_TYPE plane_type = getPlaneTypeOffline(chan);
715  const int detector = getDetectorOffline(chan);
716  const DiBlock_TYPE diblock_type = getDiBlockTypeOffline(chan);
717 
718  return getFirstDCMInView(detector, plane_type, diblock_type);
719 }
720 
721 //------------------------------------------------------------------------------
722 /// First DCM in the view. if the channel is in a XZ plane, the DCM is 1. Otherwise, it's 7 for the far detector,
723 /// 3 for the near detector, and 2 for NDOS
725 
726  /// If it's XZ plane, then the first DCM is 1
727  if(plane_type == XZ_PLANE) return 1;
728 
729  /// Otherwise, it's the next DCM after the last XZ DCM
730  return getNumberOfXDCM(detector, diblock_type) + 1;
731 }
732 
733 //------------------------------------------------------------------------------
734 dcm_id_t DAQChannelMapOLD::getFirstDCMInView(const DetPlane_TYPE plane_type, const uint32_t number_of_x_dcms) const{
735 
736  // WARNING: This functions allows you to override the constants defined in DAQChannelMapOLDConstants.h!!!
737 
738  /// If it's XZ plane, then the first DCM is 1
739  if(plane_type == XZ_PLANE) return 1;
740 
741  /// Otherwise, it's the next DCM after the last XZ DCM
742  return number_of_x_dcms + 1;
743 }
744 
745 
746 
747 
748 //------------------------------------------------------------------------------
750 
751  const DetPlane_TYPE plane_type = getPlaneTypeOffline(chan);
752  const int detector = getDetectorOffline(chan);
753  const DiBlock_TYPE diblock_type = getDiBlockTypeOffline(chan);
754 
755  return getLastDCMInView(detector, plane_type, diblock_type);
756 }
757 //------------------------------------------------------------------------------
759 
760 
761  /// If it's XZ plane, then the first DCM is NUM_X_DCMS
762  if(plane_type == XZ_PLANE) return getNumberOfXDCM(detector, diblock_type);
763 
764  /// So, it's vertical (YZ) plane
765 
766  return getFirstDCMInView(detector, plane_type, diblock_type) + getNumberOfYDCM(detector, diblock_type) - 1;
767 }
768 
769 //------------------------------------------------------------------------------
771 
772  const int detector = getDetectorOffline(chan);
773  const offline_plane_t plane_0 = getPlaneOffline(chan);
774  const offline_cell_t cell_0 = getCellOffline(chan);
775 
776  return getPixel(detector, plane_0, cell_0);
777 
778  // NOTE: The 4 lines below were originally in this code un-commented. I saw no way that
779  // these lines could have been reached due to the return statement above, but Denis
780  // is full of mystery so I didn't want to delete them just in case we needed them...
781 
782  // const online_cell_t online_cell_0 = getOnlineCellOffline(chan);
783  // const DiBlock_TYPE diblock_type = getDiBlockTypeOffline(chan);
784  // const online_cell_t local_cell_in_dcm = getLocalCellInDCM(online_cell_0, diblock_type);
785  // return local_cell_in_dcm % NUM_PIXELS;
786 }
787 
788 
789 //------------------------------------------------------------------------------
791 
792  const online_cell_t online_cell_0 = getOnlineCellOffline(chan);
793  const DiBlock_TYPE diblock_type = getDiBlockTypeOffline(chan);
794 
795  return getLocalModuleInDCMOffline(online_cell_0, diblock_type);
796 }
797 
798 //------------------------------------------------------------------------------
799 uint32_t DAQChannelMapOLD::getLocalModuleInDCMOffline(online_cell_t online_cell_0, DiBlock_TYPE diblock_type) const{
800 
801  // NOTE: No special exception was ever made here for the NDOS muon catcher in the original code
802  // despite the comment below. I don't know if this case is being treated correctly or not.
803 
804  /// This is what it should be. But Muon catcher screws things up
805  const online_cell_t local_cell_in_dcm = getLocalCellInDCM(online_cell_0, diblock_type);
806 
807  return local_cell_in_dcm / NUM_PIXELS;
808 }
809 
810 //------------------------------------------------------------------------------
812 
813  const online_cell_t number_of_cells_per_dcm = getNumberOfCellsPerDCM(diblock_type);
814 
815  // Treat the NearDet muon catcher as a special case since the number of modules in the NearDet MC is not
816  // the same as the "normal" NearDet diblocks (and there are no DAQChannelMapOLD constants that specify the
817  // difference between number of modules in a NearDet diblock vs. number of modules in a NearDet MC diblock.)
818  // It would probably be more work than it is worth to add this, so we will just catch this special case.
819  // Since there is only one DCM per view, then online_cell_0 IS the local cell in the DCM in this case (for
820  // either view.)
821  if(diblock_type == MC_ND_DIBLOCK) return online_cell_0;
822 
823  // return online_cell_0 - (online_cell_0 / number_of_cells_per_dcm)*number_of_cells_per_dcm;
824  // OR... ...we could just use modulo instead...
825  return online_cell_0 % number_of_cells_per_dcm;
826 }
827 
828 //------------------------------------------------------------------------------
829 DetPlane_TYPE DAQChannelMapOLD::getPlaneType(int detector_id, dcm_id_t dcm_id, DiBlock_TYPE diblock_type) const {
830  if(dcm_id <= getNumberOfXDCM(detector_id, diblock_type)) return XZ_PLANE;
831 
832  return YZ_PLANE;
833 }
834 
835 //------------------------------------------------------------------------------
836 DetPlane_TYPE DAQChannelMapOLD::getPlaneType(int detector_id, dcm_id_t dcm_id, DiBlock_TYPE diblock_type, uint32_t& number_of_x_dcm) const{
837 
838  // I don't understand why we are passing in number_of_x_dcm by reference when there is a function that
839  // will get this value for you.
840 
841  number_of_x_dcm = getNumberOfXDCM(detector_id, diblock_type);
842 
843  if(dcm_id <= getNumberOfXDCM(detector_id, diblock_type)) return XZ_PLANE;
844  return YZ_PLANE;
845 }
846 
847 //------------------------------------------------------------------------------
849 
850  /// For the FarDet and NearDet, the math is simple
851  if(detector == novadaq::cnv::kFARDET || detector == novadaq::cnv::kNEARDET){
852 
853  // Treat the NearDet muon catcher as a special case.
854  if(diblock_type == MC_ND_DIBLOCK) {
855  // The FEBs (dcm_links) on the NearDet MC are plugged in in numerical order with no gaps
856  // and there are 11 planes in either view. So dcm_link_id % 11 will tell you the local
857  // plane in view for an FEB in this case.
858  return dcm_link_id % 11;
859  }
860 
861  // Otherwise its a normal FarDet or NearDet diblock.
862  return dcm_link_id % 32;
863  }
864 
865  /// Otherwise, this is NDOS.
866 
867  /// DCM links are counted from 0. Refer to NOvA-doc-4219.
868  if(dcm_link_id < 32) return dcm_link_id % 16;
869 
870  /// Muon catcher screws things up. We use 1 DCM for muon catcher in each view
871  if(diblock_type == MC_DIBLOCK) return (dcm_link_id - 32) % 16;
872 
873  return 16 + (dcm_link_id - 32) % 16;
874 
875 }
876 
877 //------------------------------------------------------------------------------
879  offline_plane_t local_plane_in_diblock_in_view,
880  DetPlane_TYPE plane_type) const {
881 
882  // WARNING: Hardcoded assumption of 2 blocks per diblock!
883 
884  const DetBlock_TYPE first_block_of_diblock_type = getBlockType(diblock_type, (uint32_t)0);/// calling base
885 
886  /// Get Number of planes of the same type in that first diblock.
887  /// Needed to figure out which block current plane belongs to
888  const uint32_t number_of_planes_of_the_same_type_in_first_block_of_the_diblock = getNumberOfPlaneTypeInBlock(first_block_of_diblock_type, plane_type);
889 
890  if(local_plane_in_diblock_in_view < number_of_planes_of_the_same_type_in_first_block_of_the_diblock) return 0;
891 
892  return 1;
893 }
894 
895 //------------------------------------------------------------------------------
896 uint32_t DAQChannelMapOLD::getLocalBlockInDiblock(const int detector, const offline_plane_t plane_0) const{
897  const uint32_t block_number = getBlockNumber(detector, plane_0);
898  return getLocalBlockInDiblock(block_number);
899 }
900 
901 
902 //------------------------------------------------------------------------------
903 /// Optionally we can also calculate DetBlock_TYPE
905  const offline_plane_t local_plane_in_diblock_in_view,
906  const DetPlane_TYPE plane_type,
907  DetBlock_TYPE& output_block_type,
908  DetBlock_TYPE& first_block_type,
909  uint32_t& number_of_planes_of_the_same_type_in_first_block_of_the_diblock
910  ) const{
911 
912  first_block_type = getBlockType(diblock_type, (uint32_t)0);/// calling base
913 
914  /// Get Number of planes of the same type in that first diblock.
915  /// Needed to figure out which block current plane belongs to
916  number_of_planes_of_the_same_type_in_first_block_of_the_diblock = getNumberOfPlaneTypeInBlock(first_block_type, plane_type);
917 
918  if(local_plane_in_diblock_in_view < number_of_planes_of_the_same_type_in_first_block_of_the_diblock) {
919  output_block_type = first_block_type;
920  return 0;
921  }
922 
923  output_block_type = getBlockType(diblock_type, (uint32_t)1);
924  return 1;
925 }
926 
927 
928 
929 //------------------------------------------------------------------------------
931  DiBlock_TYPE diblock_type,
932  DetPlane_TYPE plane_type){
933  DetBlock_TYPE current_block_type;
934  DetBlock_TYPE first_block_type;
935  uint32_t number_of_planes_of_the_same_type_in_first_block_of_the_diblock;
936 
937  const uint32_t local_block_in_diblock = getLocalBlockInDiblock(diblock_type, local_plane_in_diblock_view, plane_type, current_block_type,first_block_type,number_of_planes_of_the_same_type_in_first_block_of_the_diblock);
938 
939  const DetPlane_TYPE start_plane_type = getStartPlaneTypeInBlock(current_block_type);
940 
941  /// Does the block starts with a different plane?
942  uint32_t is_block_starts_with_different_plane = 0;
943  if(plane_type != start_plane_type) is_block_starts_with_different_plane = 1;
944 
945  /// If it's the first block. We can calculate plane easily
946  if(local_block_in_diblock == 0)
947  return local_plane_in_diblock_view*2 + is_block_starts_with_different_plane;
948 
949  /// So, it's the second block. Need to do some magic
950 
951  /// To find local plane in the (second) block in the view we subtract
952  /// number of planes of the same type in the first diblock from the local plane in diblock view
953  const offline_plane_t local_plane_in_block_view = local_plane_in_diblock_view - number_of_planes_of_the_same_type_in_first_block_of_the_diblock;
954 
955  return getNumberOfPlanesInBlock(first_block_type) + local_plane_in_block_view*2 + is_block_starts_with_different_plane;
956 }
957 
958 //------------------------------------------------------------------------------
960  dcm_id_t dcm_id,
961  dcm_link_t dcm_link,
962  pixel_t pixel,
963  DiBlock_TYPE diblock_type) const {
964  const DetPlane_TYPE plane_type = getPlaneType(detector, dcm_id, diblock_type);
965  return getOnlineCell(detector, dcm_id, dcm_link, pixel, diblock_type, plane_type);
966 }
967 
968 //------------------------------------------------------------------------------
970  const dcm_id_t dcm_id,
971  const dcm_link_t dcm_link,
972  const pixel_t pixel,
973  const DiBlock_TYPE diblock_type,
974  const DetPlane_TYPE plane_type) const{
975 
976  const dcm_id_t first_dcm_in_view = getFirstDCMInView(detector, plane_type, diblock_type);
977  const uint32_t local_module_in_dcm = getLocalModuleInDCM(detector, dcm_id, dcm_link, diblock_type);
978 
979  online_cell_t cell = getNumberOfCellsPerDCM(diblock_type)*(dcm_id - first_dcm_in_view) + NUM_PIXELS*local_module_in_dcm + pixel;
980 
981  /// The NearDet has an uninstrumented section in DCM 01 in diblocks 1-3. Nothing is plugged
982  /// into FEBs 32-63, yet there is no gap in cell number.
983 
984  /// If we are in DCM 2, we have to subtract 32 due to this gap.
985  if(detector == novadaq::cnv::kNEARDET && dcm_id == 2 && diblock_type != MC_ND_DIBLOCK)
986  return cell - 32;
987 
988  /// If we are in the bottom half of DCM 1 (FEBs 32-63) then this is hardware with nothing plugged in,
989  /// so return a BIG number.
990  if(detector == novadaq::cnv::kNEARDET && dcm_id == 1 && diblock_type != MC_ND_DIBLOCK && dcm_link >= 32)
991  return -1;
992 
993  // Otherwise, we do not have to do this special correction.
994  return cell;
995 
996 }
997 
998 //------------------------------------------------------------------------------
1000  const dcm_id_t dcm_id,
1001  const dcm_link_t dcm_link,
1002  const pixel_t pixel,
1003  const DiBlock_TYPE diblock_type,
1004  const DetPlane_TYPE plane_type,
1005  const uint32_t number_of_x_dcms ) const{
1006 
1007  // WARNING: This function allows you to override the constants defined in DAQCHannelMapConstants.h!!!
1008 
1009  const dcm_id_t first_dcm_in_view = getFirstDCMInView(plane_type, number_of_x_dcms);
1010  const uint32_t local_module_in_dcm = getLocalModuleInDCM(detector, dcm_id, dcm_link, diblock_type);
1011 
1012  online_cell_t cell = getNumberOfCellsPerDCM(diblock_type)*(dcm_id - first_dcm_in_view) + NUM_PIXELS*local_module_in_dcm + pixel;
1013 
1014  /// The NearDet has an uninstrumented section in DCM 01 in diblocks 1-3. Nothing is plugged
1015  /// into FEBs 32-63, yet there is no gap in cell number.
1016 
1017  /// If we are in DCM 2, we have to subtract 32 due to this gap.
1018  if(detector == novadaq::cnv::kNEARDET && dcm_id == 2 && diblock_type != MC_ND_DIBLOCK)
1019  return cell - 32;
1020 
1021  /// If we are in the bottom half of DCM 1 (FEBs 32-63) then this is hardware with nothing plugged in,
1022  /// so return a BIG number.
1023  if(detector == novadaq::cnv::kNEARDET && dcm_id == 1 && diblock_type != MC_ND_DIBLOCK && dcm_link >= 32)
1024  return -1;
1025 
1026  // Otherwise, we do not have to do this special correction.
1027  return cell;
1028 
1029 }
1030 
1031 
1032 
1033 
1034 //------------------------------------------------------------------------------
1036 
1037  const offline_cell_t cell_offline_0 = getCellOffline(chan);
1038  const DetPlane_TYPE plane_type = getPlaneTypeOffline(chan);
1039  const int detector = getDetectorOffline(chan);
1040  const DiBlock_TYPE diblock_type = getDiBlockTypeOffline(chan);
1041 
1042  return offlineCellToOnlineCell(cell_offline_0, detector, plane_type, diblock_type);
1043 }
1044 
1045 //------------------------------------------------------------------------------
1047  int detector,
1048  DetPlane_TYPE plane_type,
1049  DiBlock_TYPE diblock_type
1050  ) const {
1051  return ConvertCell((uint32_t)online_cell_0, detector, plane_type, diblock_type);
1052 }
1053 //------------------------------------------------------------------------------
1055  int detector,
1056  DetPlane_TYPE plane_type,
1057  DiBlock_TYPE diblock_type
1058  ) const {
1059  return ConvertCell((uint32_t)offline_cell_0, detector, plane_type, diblock_type);
1060 }
1061 
1062 //------------------------------------------------------------------------------
1063 uint32_t DAQChannelMapOLD::ConvertCell(uint32_t input_cell,
1064  int detector,
1065  DetPlane_TYPE plane_type,
1066  DiBlock_TYPE diblock_type
1067  ) const {
1068 
1069  /// If the plane is vertical, then the order is reversed
1070  if(plane_type == YZ_PLANE){
1071  // If this is the NearDet muon catcher, then there are only 64 cells (not 96)
1072  // in the YZ_PLANE.
1073  if(diblock_type == MC_ND_DIBLOCK)
1074  return 64 - input_cell -1;
1075  // Otherwise, we can use the default number of Y channels.
1076  return getNumberOfChannelsInYPlane(detector) - input_cell - 1;
1077  }// end of if the plane is horizontal
1078 
1079  /// If the plane is horizontal, then the order is the same
1080  return input_cell;
1081 }
1082 
1083 //------------------------------------------------------------------------------
1085 
1086  const int det = getDetector(chan);
1087  const diblock_t diblock = getDiBlock(chan);
1088  const dcm_id_t dcm_id = getDCM(chan);
1089  const dcm_link_t dcm_link = getDCMLink(chan);
1090  const pixel_t pixel = getPixel(chan);
1091 
1092  const offline_plane_t plane_0 = getPlane(chan);
1093  const offline_cell_t cell_0 = getCell(chan);
1094 
1095  const lchan offline_channel = encodeLChan(det, plane_0, cell_0);
1096 
1097  std::cout<<"DAQChannel=";printHex(chan);
1098  std::cout<<"(";printBinary(chan);std::cout<<")";
1099  std::cout<<"\n";
1100 
1101  std::cout<<" Detector="<<det<<"("<<novadaq::cnv::DetInfo::GetName(det)<<")";
1102  std::cout<<" Diblock="<<diblock;
1103  std::cout<<" DCM="<<dcm_id;
1104  std::cout<<" DCMLink="<<dcm_link;
1105  std::cout<<" Pixel="<<pixel;
1106 
1107  std::cout<<" ";
1108 
1109  std::cout<<" Plane="<<plane_0;
1110  std::cout<<" Cell="<<cell_0;
1111 
1112  std::cout<<"\n";
1113  std::cout<<" OfflineChannel=";
1114  printHex(offline_channel);std::cout<<"(";printBinary(offline_channel);std::cout<<")";
1115 
1116  std::cout<<"\n";
1117 
1118  return true;
1119 }
1120 
1121 //------------------------------------------------------------------------------
1123 
1124  const int det = getDetectorOffline(chan);
1125  const offline_plane_t plane_0 = getPlaneOffline(chan);
1126  const offline_cell_t cell_0 = getCellOffline(chan);
1127 
1128  const diblock_t diblock = getDiBlockOffline(chan);
1129  const dcm_id_t dcm_id = getDCMOffline(chan);
1130  const dcm_link_t dcm_link = getDCMLinkOffline(chan);
1131  const apd_pixel_t apd_pixel = pixel2APDPixel(getPixelOffline(chan));
1132 
1133  const dchan daq_channel = encodeDChan(det, diblock, dcm_id, dcm_link, apd_pixel);
1134 
1135  std::cout<<"OfflineChannel=";printHex(chan);
1136  std::cout<<"(";printBinary(chan);std::cout<<")";
1137  std::cout<<"\n";
1138 
1139  std::cout<<"Detector="<<det<<"("<<novadaq::cnv::DetInfo::GetName(det)<<")";
1140  std::cout<<" Plane="<<plane_0;
1141  std::cout<<" Cell="<<cell_0;
1142 
1143  std::cout<<" ";
1144 
1145  std::cout<<" Diblock="<<diblock;
1146  std::cout<<" DCM="<<dcm_id;
1147  std::cout<<" DCMLink="<<dcm_link;
1148  std::cout<<" Pixel="<<apd_pixel;
1149 
1150  std::cout<<"\n";
1151  std::cout<<"DAQChannel=";printHex(daq_channel);
1152  std::cout<<"(";printBinary(daq_channel);std::cout<<")";
1153 
1154  std::cout<<"\n";
1155 
1156  return true;
1157 }
1158 
1159 //------------------------------------------------------------------------------
1160 // Stolen from RawDAQData::printWord
1162 
1163  const int SHIFT = 8 * sizeof( unsigned ) - 1;
1164  const unsigned MASK = 1 << SHIFT;
1165 
1166  for ( int i = 1; i <= SHIFT + 1; i++ ){
1167  std::cout << ( value & MASK ? '1' : '0' );
1168  value <<= 1;
1169 
1170  if ( i % 8 == 0 ) std::cout << ' ';
1171  }
1172 
1173  return true;
1174 }// end of printBinary
1175 
1176 //------------------------------------------------------------------------------
1177 // Stolen from RawDAQData::printWord
1179  printf("0x%08x",value);
1180 
1181  return true;
1182 }// end of printHex
1183 
1184 
static std::string GetName(int id)
pixel_t getPixel(dchan daqchan) const
Decodes APD pixel number from the universal daq channel number.
Identifier for the vertical plane.
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
offline_cell_t onlineCellToOfflineCell(online_cell_t, int detId, DetPlane_TYPE, DiBlock_TYPE) const
Offline to Online and vice versa.
uint32_t getNumberOfPlanesBeforeDiblock(int detId, diblock_t) const
offline_plane_t getPlaneOffline(lchan logicalchan) const
Returns the plane (detector wide) that the offline channel belongs to – Verified.
int getDetectorOffline(lchan logicalchan) const
Returns the detector that the offline channel belongs to – Verified.
APD Pixel Number (8bit), valid range 0-31.
dcm_id_t getLastDCMInViewOffline(lchan logicalchan) const
DetBlock_TYPE
Types of Block.
Identifider for NearDet Muon catcher.
uint32_t pixel_t
Type for physical pixel on APD.
uint32_t getLocalBlockInDiblockOffline(lchan logicalchan) const
If it&#39;s the upstream block in the diblock, then it&#39;s 0, if not, it&#39;s 1.
dcm_id_t getFirstDCMInViewOffline(lchan logicalchan) const
online_cell_t getOnlineCell(int detId, dcm_id_t, dcm_link_t, pixel_t, DiBlock_TYPE) const
uint32_t getLocalBlockInDiblock(const int detector, const offline_plane_t) const
uint32_t offline_plane_t
Type for offline plane. Offline counts from 0.
uint32_t getNumberOfCellsPerDCM(DiBlock_TYPE) const
Number of cells per DCM for a given diblock type.
dcm_id_t getLastDCMInView(int detector, DetPlane_TYPE, DiBlock_TYPE) const
uint32_t getNumberOfChannelsInYPlane(int detId) const
Number of channels in Y plane for a given detectorID.
DetPlane_TYPE getOtherPlaneType(DetPlane_TYPE) const
opposite plane view from the input. For instance Y = getOtherView(X)
dcm_id_t getDCMOffline(lchan logicalchan) const
Plane Number,(18bit), valid range 0-930 (far det)
dcm_link_t getDCMLink(dchan daqchan) const
Decodes Link Port on the DCM from the universal daq channel number.
diblock_t getDiBlock(dchan daqchan) const
Decodes Diblock number from universal daq channel number.
uint32_t getNumberOfPlanesInBlock(int detId, block_t) const
Number of planes in the block given detectorID and block number.
uint32_t offline_cell_t
< DAQ Channel Map Package
static DAQChannelMapOLD * getInstance()
Method to obtain the class instance.
offline_plane_t getLocalPlaneInDiblock(offline_plane_t local_plane_in_diblock_view, DiBlock_TYPE, DetPlane_TYPE)
dcm_id_t getFirstDCMInView(int detector, DetPlane_TYPE, DiBlock_TYPE) const
uint32_t getNumberOfXDCM(int detId, DiBlock_TYPE) const
Number of DCMs for horizontal planes in the diblock given detectorID and Diblock type.
~DAQChannelMapOLD()
Default Destructor.
uint32_t getNumberOfYDCM(int detId, DiBlock_TYPE) const
Number of DCMs for vertical planes in the diblock given detectorID and Diblock type.
bool printOffline(lchan logicalchan)
Print Information about the Offline logical Channel.
dcm_link_t getDCMLinkOffline(lchan logicalchan) const
Identifier for the horizontal plane.
Detector ID, (4bit), valid range 1-4.
#define BITFIELDGET(block, mask, shift)
Definition: BitFields.h:23
Far Detector at Ash River, MN.
block
print "ROW IS " print row
Definition: elec2geo.py:31
Diblock ID, (6bit), valid range 1-15.
bool print() const
Print all detectors info.
DetView_TYPE detPlaneToDetView(DetPlane_TYPE) const
Conversion from DetPlane_TYPE to DetView_TYPE.
static DAQChannelMapOLD * _instanceID
Instance pointer for singleton class.
dchan encodeDChan(lchan logicalchan)
const XML_Char int const XML_Char * value
Definition: expat.h:331
Detector ID, (4bit), valid range 1-4.
DCM ID, (6bit), valid range 1-12.
Prototype Near Detector on the surface at FNAL.
uint32_t ConvertCell(uint32_t input_cell, int detId, DetPlane_TYPE, DiBlock_TYPE) const
If input cell if offline_cell, then the output is online cell.
DiBlock_TYPE getDiBlockTypeOffline(lchan logicalchan) const
Returns the DiBlock type (i.e. AB, BA, AA) of the offline channel – Verified.
offline_cell_t getCellOffline(lchan logicalchan) const
Returns the cell the cell on the current plane that the offline channel belongs to – Verified...
printf("%d Experimental points found\n", nlines)
Near Detector in the NuMI cavern.
offline_plane_t getLocalPlaneInBlockOffline(lchan logicalchan) const
Returns the Plane relative to the start of the current block – Verified.
int getDetector(dchan daqchan) const
Decodes detector identity from universal channel number.
#define BOUNDSCHECK(value, min, max, err)
Definition: boundscheck.h:22
pixel_t APDPixel2Pixel(apd_pixel_t) const
Pixel number from APDPixel.
DetBlock_TYPE getBlockType(lchan logicalchan) const
Returns the DiBlock type (i.e. AB, BA, AA) of the daq channel – Verified.
offline_plane_t getPlaneViewOffline(lchan logicalchan)
Returns the Plane number relative to the current view – Verified.
Cell Number, (10bit), valid range 1-384 (far det)
DiBlock_TYPE getDiBlockType(dchan daqchan) const
Returns the DiBlock type (i.e. AB, BA, AA) of the daq channel – Verified.
uint32_t getBlockNumber(int detId, offline_plane_t) const
The block number given the detectorID and offline plane number.
OStream cout
Definition: OStream.cxx:6
uint32_t dcm_id_t
Type for DCM number, counts from 1.
static const unsigned int NUM_DIBLOCK_DET[]
uint32_t dcm_link_t
Type for DCM number. Counts from 1.
offline_plane_t getLocalPlaneInBlock(int detId, offline_plane_t) const
Local plane in block number given the detectorID and offline plane number.
#define BITFIELDSET(block, data, mask, shift)
Definition: BitFields.h:24
uint32_t getLocalModuleInDCMOffline(lchan) const
Returns the module number (0 or 1) to which a given module belongs.
DetView_TYPE getViewOffline(lchan logicalchan) const
Returns the Plane type that the offline channel is on.
DetPlane_TYPE getPlaneType(int detId, dcm_id_t, DiBlock_TYPE) const
offline_plane_t getLocalPlaneInDiblockOffline(lchan logicalchan) const
Returns the Plane relative to the start of the current diblock – Verified.
Identifider for NDOS Muon catcher.
offline_plane_t getPlane(dchan daqchan)
Returns the plane position, as referenced relative to the full detector, of the daq channel...
DetView_TYPE
Types of Detector View.
block_t getBlockOffline(lchan logicalchan) const
Returns the Block that the offline channel is on – Verified.
uint32_t getNumberOfPlaneTypeInDiblock(DiBlock_TYPE, DetPlane_TYPE) const
Number of planes (X or Y) in the diblock given diblock type and type of plane(X or Y) ...
offline_plane_t getLocalPlaneInDiblockView(const int detector, dcm_link_t, const DiBlock_TYPE) const
Returns the Plane number relative to the current view and diblock – Verified.
DCM Link Port (8bit), valid range 0-63.
uint32_t diblock_t
Type for diblocks and blocks.
DetPlane_TYPE
Types of Detector Plane.
DiBlock_TYPE
Types of Diblock.
offline_plane_t getLocalPlaneInDiblockViewOffline(lchan logicalchan) const
Returns the Plane number relative to the current view and diblock – Verified.
uint32_t getDiblockNumber(int detId, offline_plane_t) const
The diblock number given the detectorID and offline plane number.
uint32_t dchan
< DAQ Channel Map Package
DetPlane_TYPE getStartPlaneTypeInBlock(DetBlock_TYPE) const
Starting plane in the block given its type.
offline_cell_t getCell(dchan daqchan) const
Returns the cell position, as referenced relative to the full detector, of the daq channel...
dchan l2d(offline_plane_t, offline_cell_t, int detId)
Convience Methods for accessing DAQ parameters from the logical space.
dcm_id_t getDCM(dchan daqchan) const
Decodes DCM position on the diblock from universal daq channel number.
online_cell_t getOnlineCellOffline(lchan logicalchan) const
#define EVEN(x)
< DAQ Channel Map Package
DetView_TYPE getView(dchan daqchan) const
Returns the View (X or Y) from the universal daq channel number.
diblock_t getDiBlockOffline(lchan logicalchan) const
Returns the DiBlock that the offline channel is on – Verified.
online_cell_t getLocalCellInDCM(online_cell_t, DiBlock_TYPE) const
uint32_t getLocalModuleInDCM(const int detector_id, dcm_id_t, dcm_link_t, const DiBlock_TYPE) const
Returns the module number (0 or 1) to which a given module belongs.
uint32_t getNumberOfPlaneTypeInBlock(DetBlock_TYPE, DetPlane_TYPE) const
Number of planes (X or Y) in the block given block type and type of plane(X or Y) ...
pixel_t getPixelOffline(lchan logicalchan) const
online_cell_t offlineCellToOnlineCell(offline_cell_t, int detId, DetPlane_TYPE, DiBlock_TYPE) const
DetPlane_TYPE getPlaneTypeOffline(lchan logicalchan) const
Returns the View that the offline channel is on.
apd_pixel_t pixel2APDPixel(pixel_t) const
APDPixel number from Pixel.