DAQChannelMapBaseOLD.cpp
Go to the documentation of this file.
1 /*
2  * File: DAQChannelMapBaseOLD.cpp
3  * Author: denis
4  *
5  * Created on February 10, 2012, 10:17 AM
6  */
7 
8 #include "DAQChannelMap/DAQChannelMapBaseOLD.h"
9 #include "NovaDAQConventions/DAQConventions.h"
10 
11 #include <iostream>
12 
13 using namespace daqchannelmap;
14 
15 // Standard enumeration
16 #define PUT_ENUM(INPUT) CHAN_IDX_0_1 \
17  INPUT##_NEARDET, \
18  INPUT##_FARDET, \
19  INPUT##_NDOS, \
20  INPUT##_TESTBEAM_2Block_1x1, \
21  INPUT##_TESTBEAM_3Block_1x1, \
22  INPUT##_TESTBEAM_2Block_2x2, \
23  INPUT##_TESTBEAM_3Block_2x2, \
24  INPUT##_IPND
25 
26 
27 const unsigned int DAQChannelMapBaseOLD::NUM_XCHAN_PLANE[] = { PUT_ENUM(NUM_CHAN_X_PLANE) };
28 const unsigned int DAQChannelMapBaseOLD::NUM_YCHAN_PLANE[] = { PUT_ENUM(NUM_CHAN_Y_PLANE)};
29 const unsigned int DAQChannelMapBaseOLD::NUM_DIBLOCK_DET[] = { PUT_ENUM(NUM_DIBLOCK) };
30 const unsigned int DAQChannelMapBaseOLD::NUM_DCMS_DIBLOCK[]= { PUT_ENUM(NUM_DCMS_DIBLOCK) };
31 const unsigned int DAQChannelMapBaseOLD::NUM_X_DCMS[] = { PUT_ENUM(NUM_X_DCMS) };
32 const unsigned int DAQChannelMapBaseOLD::NUM_Y_DCMS[] = { PUT_ENUM(NUM_Y_DCMS) };
33 
34 
37  TERM_CHAR
38  };
39 
42  MC_ND_DIBLOCK, // Muon catcher for NearDet
43  TERM_CHAR
44  };
45 
48  MC_DIBLOCK, // Muon catcher for NDOS (actually it's just incomplete B-block)
49  TERM_CHAR
50  };
51 
58  TERM_CHAR
59  };
60 
61 
64  TERM_CHAR
65  };
68  TERM_CHAR
69  };
72  TERM_CHAR
73  };
76  TERM_CHAR
77  };
78 
79 // Mapping of APD, index is the Pixel Channel, result is the module cell
80 const unsigned int DAQChannelMapBaseOLD::apd_pixel2cell_v0[] = {25,24,27,26,29,28,31,30,
81  17,16,19,18,21,20,22,23,
82  15,14,12,13,10,11, 8, 9,
83  6, 7, 4, 5, 2, 3, 0, 1
84  };
85 // Back Mapping of APD, index is the module cell, result is the APD channel
86 const unsigned int DAQChannelMapBaseOLD::apd_cell2pixel_v0[] = {30,31,28,29,26,27,24,25,
87  22,23,20,21,18,19,17,16,
88  9, 8,11,10,13,12,14,15,
89  1, 0, 3, 2, 5, 4, 7, 6};
90 
91 //------------------------------------------------------------------------------
93  _planesInDiblockDetectorArray(NULL)
94  ,_planesInBlockDetectorArray(NULL)
95  ,_planesInBlockDetectorSize(NULL)
96  ,_planesInDiblockDetectorSize(NULL)
97  ,_planesBeforeDiblockDetectorArray(NULL)
98  ,_planesBeforeBlockDetectorArray(NULL)
99  ,_BlockOrderInDiblockArray(NULL)
100  ,_numberOfTypePlanesInBlockArray(NULL)
101  ,_numberOfTypePlanesInDiBlockArray(NULL)
102  ,_numberOfXDCMsInDiblockDetectorArray(NULL)
103  ,_numberOfYDCMsInDiblockDetectorArray(NULL)
104  ,_planeType_planeNumberArray(NULL)
105 
106 {
107 
109 
111 
113 
115 
117 
119 
121 
123 
125 
127 
129 }
130 
131 //------------------------------------------------------------------------------
138 
144 
147 
149 }
150 
151 
152 
153 //------------------------------------------------------------------------------
154 /// Initialization methods
155 //------------------------------------------------------------------------------
156 
157 //------------------------------------------------------------------------------
159 
160  /// First, need to resize the maps
161  _apdPixel2CellMap.resize(32);
162  _cell2ApdPixelMap.resize(32);
163 
164  const unsigned int* apd_pixel2cell_pointer = apd_pixel2cell_v0;
165 
166  /// First, construct the map of apdPixel2CellMap
167  for(uint32_t iapd_pixel = 0; iapd_pixel < 32; ++iapd_pixel){
168  const pixel_t ipixel = (pixel_t) (apd_pixel2cell_pointer[iapd_pixel]);
169  _apdPixel2CellMap[iapd_pixel] = ipixel;
170  _cell2ApdPixelMap[ipixel] = iapd_pixel;
171  }
172 
175 
176  return true;
177 }
178 
179 //------------------------------------------------------------------------------
181 
189 
191 
192  return true;
193 }
194 
195 //------------------------------------------------------------------------------
197 
198  /// Needs _numberOfCellsPerDCMInDiblock initialized
200  std::cerr<<"initNumberOfCellsPerDCMInDiblock can not be initialized\n";
201  exit(1);
202  }// end of check whether _numberOfCellsPerDCMInDiblock is initialized
203 
204  return true;
205 }
206 
207 //------------------------------------------------------------------------------
209 
210  for(uint32_t idiblock_type = 0; idiblock_type <= MAX_DIBLOCK_TYPE; idiblock_type++){
211  std::vector <uint32_t> temp_vector;
212  temp_vector.resize(2);
213  _BlockOrderInDiblock.push_back(temp_vector);
214  }/// end of loop over diblock types
215 
228 
230 
231  return true;
232 }
233 
234 //------------------------------------------------------------------------------
236 
237  /// Needs BlockOrderInDiblock initialized
239  std::cerr<<"BlockOrderInDiblock can not be initialized\n";
240  exit(1);
241  }// end of check whether BlockOrderInDiblock is initialized
242 
243  return true;
244 }
245 
246 //------------------------------------------------------------------------------
248 
255 
257 
258  return true;
259 }
260 
261 //------------------------------------------------------------------------------
263 
264  /// Needs _planesInBlockType initialized
265  if( _planesInBlockType.size() < MAX_BLOCK_TYPE+1 && !initPlanesInBlockID() ) {
266  std::cerr<<"_planesInBlockType can not be initialized\n";
267  exit(1);
268  }// end of check whether _planesInBlockType is initialized
269 
270  return true;
271 }
272 
273 //------------------------------------------------------------------------------
275 
277 
278  numberOfPlanesInBlock_t number_of_yz_planes_in_block;
279  numberOfPlanesInBlock_t number_of_xz_planes_in_block;
280  number_of_yz_planes_in_block.resize(MAX_BLOCK_TYPE+1);
281  number_of_xz_planes_in_block.resize(MAX_BLOCK_TYPE+1);
282 
283  number_of_yz_planes_in_block[A_BLOCK] = NUM_YZ_PLANES_A_BLOCK; ///< Number of vertical planes. A-Block starts with horizontal plane
284  number_of_yz_planes_in_block[B_BLOCK] = NUM_YZ_PLANES_B_BLOCK; ///< B-block starts with vertical plane
285  number_of_yz_planes_in_block[AFULL_BLOCK] = NUM_YZ_PLANES_AFULL_BLOCK; ///< AFULL-block starts with horizontal plane
286  number_of_yz_planes_in_block[M_BLOCK] = NUM_YZ_PLANES_MC_BLOCK; ///< NDOS Muon catcher starts with vertical plane
287  number_of_yz_planes_in_block[MC_ND_BLOCK] = NUM_YZ_PLANES_MC_ND_BLOCK; ///< NearDet Muon catcher starts with horizontal plane (I think...)
288 
289  /// Calculating number of XZ planes for each Block Type
290  for(block_t iblock_type = MIN_BLOCK_TYPE; iblock_type <= MAX_BLOCK_TYPE; iblock_type++){
291  const DetBlock_TYPE block_type = (DetBlock_TYPE)iblock_type;
292  number_of_xz_planes_in_block[block_type] = getNumberOfPlanesInBlock(block_type) - number_of_yz_planes_in_block[block_type];
293  }// end of loop over blocks calculating number of XZ planes for each Block Type
294 
295  _numberOfTypePlanesInBlock.resize(2);
296  _numberOfTypePlanesInBlock[XZ_PLANE-1] = number_of_xz_planes_in_block;
297  _numberOfTypePlanesInBlock[YZ_PLANE-1] = number_of_yz_planes_in_block;
298 
300 
301  return true;
302 }
303 
304 //------------------------------------------------------------------------------
306 
307  /// Needs _numberOfTypePlanesInBlock initialized
309  std::cerr<<"_numberOfTypePlanesInBlock can not be initialized\n";
310  exit(1);
311  }// end of check whether _numberOfTypePlanesInBlock is initialized
312 
313  return true;
314 }
315 
316 //------------------------------------------------------------------------------
318 
319 
320  /// Needs PlanesInBlockID initialized
322  /// Needs BlockOrderInDiblock initialized
324  /// Needs NumberOfTypePlanesInBlock initialized
326 
327  /// Filling Number of planes in Diblock and each of its views
329 
333  for(uint32_t idiblock_type = MIN_DIBLOCK_TYPE; idiblock_type <= MAX_DIBLOCK_TYPE; idiblock_type++){
334  const DetBlock_TYPE block0 = (DetBlock_TYPE)_BlockOrderInDiblock[idiblock_type][0];
335  const DetBlock_TYPE block1 = (DetBlock_TYPE)_BlockOrderInDiblock[idiblock_type][1];
336 
340  }// end of loop over diblocks filling Number of planes in Diblock and each of its views
341 
342 
344 
345 
347 
348 
349  return true;
350 }
351 
352 //------------------------------------------------------------------------------
354 
355  /// Needs _numberOfTypePlanesInDiBlock initialized
356  if( _numberOfTypePlanesInDiBlock.size() < 2 && !initPlanesInDiblockID() ) {
357  std::cerr<<"_numberOfTypePlanesInDiBlock can not be initialized\n";
358  exit(1);
359  }// end of check whether _numberOfTypePlanesInDiBlock is initialized
360 
361  return true;
362 }
363 
364 //------------------------------------------------------------------------------
366 
368  _startPlaneTypeInBlock[A_BLOCK] = XZ_PLANE; /// A-block starts with vertical plane
369  _startPlaneTypeInBlock[B_BLOCK] = YZ_PLANE; /// B-block starts with horizontal plane
370  _startPlaneTypeInBlock[AFULL_BLOCK] = YZ_PLANE; /// AFULL-block starts with horizontal plane
371  _startPlaneTypeInBlock[M_BLOCK] = YZ_PLANE; /// M-block starts with horizontal plane
372  _startPlaneTypeInBlock[MC_ND_BLOCK] = YZ_PLANE; /// MC-ND-block starts with a horizontal module
373 
374 
376 
377  return true;
378 }
379 
380 //------------------------------------------------------------------------------
382 
383  /// Needs _startPlaneTypeInBlock initialized
385  std::cerr<<"_startPlaneTypeInBlock can not be initialized\n";
386  exit(1);
387  }// end of check whether _startPlaneTypeInBlock is initialized
388 
389  return true;
390 }
391 
392 //------------------------------------------------------------------------------
394 
395  /// Needs PlanesInBlockID initialized
397  /// Needs BlockOrderInDiblock initialized
399 
400  /// Fill Number of Planes in Diblock
401  for(uint32_t idet = 0; idet < novadaq::cnv::kNDetector; idet++){
402 
403  std::vector <uint32_t> number_of_planes_in_diblock_for_current_detector;
404  std::vector <uint32_t> number_of_planes_in_block_for_current_detector;
405 
406  std::vector <uint32_t> number_of_planes_before_diblock_for_current_detector;
407  std::vector <uint32_t> number_of_planes_before_block_for_current_detector;
408 
409  /// Fill stuff only for legal detectors, otherwise leave vectors empty
410  if(idet > novadaq::cnv::kUNKNOWN_DET && idet<novadaq::cnv::kNDetector){
411 
412 
413  // we index from 1 on diblocks and blocks, so need to push 0
414  for(int i=0; i<BLOCK_OFFSET; ++i){
415  number_of_planes_in_block_for_current_detector.push_back(0);
416  number_of_planes_before_block_for_current_detector.push_back(0);
417  }
418  for(int i=0; i<DIBLOCK_OFFSET; ++i){
419  number_of_planes_in_diblock_for_current_detector.push_back(0);
420  number_of_planes_before_diblock_for_current_detector.push_back(0);
421  }
422 
423 
424  int current_n_planes = 0;
425  /// Loop over all diblock numbers in the detector
426  for(diblock_t idiblock = DIBLOCK_OFFSET; idiblock < MAX_DIBLOCK+DIBLOCK_OFFSET; idiblock++){
427 
428  const DiBlock_TYPE diblock_type = getDiBlockType(idet, idiblock);
429 
430  if(diblock_type == (int)TERM_CHAR) break;
431 
432  const uint32_t nplanes_in_diblock = getNumberOfPlanesInDiblock(diblock_type);
433 
434  /// Fill planes for diblock
435  number_of_planes_in_diblock_for_current_detector.push_back(nplanes_in_diblock);
436 
437  number_of_planes_before_diblock_for_current_detector.push_back(
438  number_of_planes_before_diblock_for_current_detector[number_of_planes_before_diblock_for_current_detector.size() - 1]
439  +nplanes_in_diblock
440  );
441 
442  /// Blocks in the current diblock
443  const DetBlock_TYPE block0 = getBlockType(diblock_type, (uint32_t) 0);
444  const DetBlock_TYPE block1 = getBlockType(diblock_type, (uint32_t) 1);
445  const int nplanes_in_block_0 = getNumberOfPlanesInBlock(block0);
446  const int nplanes_in_block_1 = getNumberOfPlanesInBlock(block1);
447 
448 
449  /// Fill planes for two blocks of the current diblock
450  number_of_planes_in_block_for_current_detector.push_back(nplanes_in_block_0);
451  number_of_planes_in_block_for_current_detector.push_back(nplanes_in_block_1);
452 
453  current_n_planes += nplanes_in_block_0;
454  number_of_planes_before_block_for_current_detector.push_back(current_n_planes);
455  current_n_planes += nplanes_in_block_1;
456  number_of_planes_before_block_for_current_detector.push_back(current_n_planes);
457  }// end of loop over diblocks
458  }// end of if detector is legal
459 
460 
461  _planesInDiblockDetector.push_back(number_of_planes_in_diblock_for_current_detector);
462  _planesInBlockDetector.push_back(number_of_planes_in_block_for_current_detector);
463  }
464 
467 
470 
471 
472  _planesBeforeBlockDetector.resize(novadaq::cnv::kNDetector);
473  _planesBeforeDiblockDetector.resize(novadaq::cnv::kNDetector);
474 
475  /// Fill Number of Planes in Diblock
476  for(uint32_t idet = 0; idet < novadaq::cnv::kNDetector; idet++){
477 
478  /// Fill stuff only for legal detectors, otherwise leave vectors empty
479  if(idet > novadaq::cnv::kUNKNOWN_DET && idet<novadaq::cnv::kNDetector){
480 
481  const uint32_t num_diblocks = getTotalNumberOfDiblocks(idet) + DIBLOCK_OFFSET;
482  const uint32_t num_blocks = getTotalNumberOfBlocks(idet) + BLOCK_OFFSET;
483 
484  std::vector<uint32_t> nplanes_before_diblock;
485  std::vector<uint32_t> nplanes_before_block;
486 
487 
488  // we index from 1 on diblocks and blocks, so need to push 0
489  for(int i=0; i<BLOCK_OFFSET; ++i){
490  nplanes_before_block.push_back(0);
491  nplanes_before_block.push_back(0);
492  }
493  for(int i=0; i<DIBLOCK_OFFSET; ++i){
494  nplanes_before_diblock.push_back(0);
495  nplanes_before_diblock.push_back(0);
496  }
497 
498  uint32_t planes = 0;
499  /// Count all planes before this Diblock. Add them to the offline plane number
500  for(diblock_t idiblock = 1 + DIBLOCK_OFFSET; idiblock < num_diblocks; idiblock++){
501  planes += getNumberOfPlanesInDiblock(idet, idiblock - DIBLOCK_OFFSET);
502  nplanes_before_diblock.push_back(planes);
503  }// end of loop over diblocks before the current one
504 
505  _planesBeforeDiblockDetector[idet] = nplanes_before_diblock;
506 
507  planes = 0;
508  /// Count all planes before this Block. Add them to the offline plane number
509  for(block_t iblock = 1 + BLOCK_OFFSET; iblock < num_blocks; iblock++){
510  planes += getNumberOfPlanesInBlock(idet, iblock - BLOCK_OFFSET);
511  nplanes_before_block.push_back(planes);
512  }// end of loop over blocks before the current one
513 
514  _planesBeforeBlockDetector[idet] = nplanes_before_block;
515  }
516 
517  }// end of loop over detectors
518 
521 
522  return true;
523 }
524 
525 //------------------------------------------------------------------------------
527 
528  /// Needs _planesInBlockDetector initialized
530  std::cerr<<"_planesInBlockDetector can not be initialized\n";
531  exit(1);
532  }// end of check whether _planesInBlockDetector is initialized
533 
534  return true;
535 }
536 
537 
538 //------------------------------------------------------------------------------
540 
541  /// Initialize vectors
542  for(uint32_t detector_id = 0; detector_id <= novadaq::cnv::kNDetector; ++detector_id){
543  std::vector<uint32_t> tmp_vector;
544  tmp_vector.resize(MAX_DIBLOCK_TYPE+1);
545 
546  _numberOfXDCMsInDiblockDetector.push_back(tmp_vector);
547  _numberOfYDCMsInDiblockDetector.push_back(tmp_vector);
548  }// end of initializing vectors
549 
550 
551  for(uint32_t detector = 0; detector <= novadaq::cnv::kNDetector; detector++){
552  for(diblock_t idiblock = MIN_DIBLOCK_TYPE; idiblock <= MAX_DIBLOCK_TYPE; ++idiblock){
555  }
556  }// end of filling number of DCMs
557 
558 
559  /// Exceptions are the muon catchers, for which number of DCMs is 1 in each view
564 
565 
568 
569  return true;
570 }// end of initNumberOfXDCMsInDiblockDetector
571 
572 //------------------------------------------------------------------------------
574 
575  /// Needs _numberOfXDCMsInDiblockDetector initialized
577  std::cerr<<"_numberOfXDCMsInDiblockDetector can not be initialized\n";
578  exit(1);
579  }// end of check whether _numberOfXDCMsInDiblockDetector is initialized
580 
581  return true;
582 }
583 
584 //------------------------------------------------------------------------------
586 
587  for(uint32_t idet = 0; idet < novadaq::cnv::kNDetector; ++idet){
588  std::vector <uint32_t> planeType_plane;
589 
590  _totalNumberOfPlanes.push_back(0);
591 
592  /// Fill stuff only for legal detectors, otherwise leave vectors empty
593  if(idet > novadaq::cnv::kUNKNOWN_DET && idet<novadaq::cnv::kNDetector){
594 
595  const uint32_t total_number_of_diblocks = getTotalNumberOfDiblocks(idet) + DIBLOCK_OFFSET;
596 
597  for(diblock_t idiblock = DIBLOCK_OFFSET; idiblock < total_number_of_diblocks; ++idiblock){
599  }
600 
601  planeType_plane.resize(_totalNumberOfPlanes[idet]);
602 
603 
604  for(offline_plane_t iplane = 0; iplane < _totalNumberOfPlanes[idet]; ++iplane){
605 
606  /// current block number
607  const diblock_t diblock_number = getDiblockNumber(idet, iplane);
608  const block_t block_number = getBlockNumber(idet, iplane);
609 
610  const DiBlock_TYPE diblock_type = getDiBlockType(idet, diblock_number);
611 
612  const uint32_t local_plane_in_block = getLocalPlaneInBlock(idet, iplane);
613 
614  const uint32_t local_block_number_in_diblock = (block_number - BLOCK_OFFSET) % 2;
615 
616  const DetBlock_TYPE block_type = getBlockType(diblock_type, local_block_number_in_diblock);
617 
618  const DetPlane_TYPE starting_plane = getStartPlaneTypeInBlock(block_type);
619 
620  if(local_plane_in_block % 2 == 0)
621  planeType_plane[iplane] = starting_plane;
622  else
623  planeType_plane[iplane] = getOtherPlaneType(starting_plane);
624 
625  }// end of loop over planes
626 
627  }
628  _planeType_planeNumber.push_back(planeType_plane);
629 
630  }// end of loop over detectors
631 
632 
634 
635 
636  //print();
637  return true;
638 
639 }
640 
641 //------------------------------------------------------------------------------
643 
644  /// Loop over all possible detector IDs
645  for(int i=0; i< 100; ++i){
652  }
653 
655 
656  return true;
657 }
658 
659 
660 //------------------------------------------------------------------------------
662  std::cout<<"Printing DiBlockConfigVector\n";
663 
664 
665  int ndetectors = DetectorDiBlockConfigVector.size();
666  for(int idet = 0; idet < ndetectors; ++idet){
667  int ndiblocks = DetectorDiBlockConfigVector[idet].size();
668 
669  std::cout<<"Detector "<<idet<<"\n";
670  std::cout<<"N diblocks = "<<ndiblocks<<"\n";
671  }
672 
673 }
674 
675 //------------------------------------------------------------------------------
676 std::vector<uint32_t> DAQChannelMapBaseOLD::getVector(const unsigned int* inn, const unsigned int maxsize){
677 
678  std::vector<uint32_t> out;
679 
680  if(maxsize == 0)
681  out.push_back(0);
682 
683  for(uint32_t i = 0; i < maxsize; ++i){
684  out.push_back(inn[i]);
685  if(inn[i] == TERM_CHAR)break;
686  }
687 
688  return out;
689 }
690 
691 
692 
693 //------------------------------------------------------------------------------
695 
696  std::cout<<__PRETTY_FUNCTION__<<"\n";
697 
698  /// loop over detectors
699  for(uint32_t idet = 0; idet < novadaq::cnv::kNDetector; idet++){
700 
701  /// working with legal detector IDs only
702  if(idet > novadaq::cnv::kUNKNOWN_DET && idet<novadaq::cnv::kNDetector){
703 
704  std::cout<<"Detector ID"<<idet<<"\n";
705 
706  const uint32_t number_of_planes = getTotalNumberOfPlanes(idet);
707 
708  for(offline_plane_t iplane = 0; iplane < number_of_planes; ++iplane){
709  print(idet, iplane);
710  std::cout<<"\n";
711  }
712  }
713  }// end of loop over detectors
714 
715 
716  return true;
717 
718 }
719 //------------------------------------------------------------------------------
720 bool DAQChannelMapBaseOLD::print(const int idet, const offline_plane_t iplane) const {
721 
722 
723  /// current block number
724  const diblock_t diblock_number = getDiblockNumber(idet, iplane);
725  const block_t block_number = getBlockNumber(idet, iplane);
726 
727  const DiBlock_TYPE diblock_type = getDiBlockType(idet, diblock_number);
728 
729  const uint32_t local_block_number_in_diblock = (block_number - BLOCK_OFFSET) % 2;
730 
731  const DetBlock_TYPE block_type = getBlockType(diblock_type, local_block_number_in_diblock);
732 
733 
734  std::cout<<"Plane="<<iplane
735  <<" Diblock type="<<diblock_type
736  <<" Block type="<<block_type
737  <<" local_block_number_in_diblock="<<local_block_number_in_diblock
738  <<" Plane type="<<getPlaneType(idet, iplane)
739  <<" NumberOfChannels="<<getNumberOfChannelsInPlane(idet, iplane);
740 
741  return true;
742 }
743 
744 
745 
746 //------------------------------------------------------------------------------
747 /// Get minimum detector ID
749 //------------------------------------------------------------------------------
750 /// Get maximum detector ID
752 
753 //------------------------------------------------------------------------------
756 }
757 
758 //------------------------------------------------------------------------------
761 
762 
764 
765 
770 
773 
776 
777 //------------------------------------------------------------------------------
778 uint32_t DAQChannelMapBaseOLD::getDiblockNumber(const block_t block_number) const
779 {
780  // WARNING: Assumption of 2 blocks per diblock.
781  return DIBLOCK_OFFSET + (block_number - BLOCK_OFFSET)/2;
782 }
783 
784 //------------------------------------------------------------------------------
785 uint32_t DAQChannelMapBaseOLD::getLocalBlockInDiblock (const block_t block_number) const
786 {
787  return ODD(block_number-BLOCK_OFFSET);
788 }
789 
792 uint32_t DAQChannelMapBaseOLD::getNumberOfDCM (int detector, DiBlock_TYPE diblock_type) const {return getNumberOfXDCM(detector, diblock_type) + getNumberOfYDCM(detector, diblock_type);}
795 
796 //---------------------------------------------------------------------------------------
797 uint32_t DAQChannelMapBaseOLD::getNumberOfChannelsInPlane(const int detId, const DetPlane_TYPE plane_type) const{
798 
799  if(plane_type == XZ_PLANE)
800  return getNumberOfChannelsInXPlane(detId);
801 
802  return getNumberOfChannelsInYPlane(detId);
803 }
804 //---------------------------------------------------------------------------------------
806  return getNumberOfChannelsInPlane(detId, getPlaneType(detId, plane_0));
807 }
808 //---------------------------------------------------------------------------------------
810  return _numberOfTypePlanesInBlockArray[plane_type-1][block_type];
811 }
812 //---------------------------------------------------------------------------------------
814  return _numberOfTypePlanesInDiBlockArray[plane_type-1][diblock_type];
815 }
816 
817 //---------------------------------------------------------------------------------------
818 DetBlock_TYPE DAQChannelMapBaseOLD::getBlockType(DiBlock_TYPE diblock_type, uint32_t local_block_number_in_diblock) const{return (DetBlock_TYPE)_BlockOrderInDiblockArray[diblock_type][local_block_number_in_diblock];}
819 
820 //---------------------------------------------------------------------------------------
822  return _startPlaneTypeInBlockArray[block_type];
823 }
824 
825 //---------------------------------------------------------------------------------------
827 //---------------------------------------------------------------------------------------
828 // WARNING: Assumption of 2 blocks per diblock.
830 //---------------------------------------------------------------------------------------
832 //---------------------------------------------------------------------------------------
834 
835 //------------------------------------------------------------------------------
837  ,offline_plane_t plane_0
838  ,const numberOfPlanesInBlockDetector_t& planes_in_block_or_diblock
839  ,const BlockNumerationOffset block_enum_offset
840  ) const
841 {
842 
843  CHECKERROR( plane_0);
844 
845  offline_plane_t planescount = 0;
846  uint32_t max_number_of_blocks_or_diblocks = planes_in_block_or_diblock[detector].size();
847  uint32_t iblock_or_diblock = block_enum_offset; //we index from 0 or 1 on diblocks and blocks
848  for(; iblock_or_diblock < max_number_of_blocks_or_diblocks; ++iblock_or_diblock) {
849  planescount += planes_in_block_or_diblock[detector][iblock_or_diblock];
850  if(plane_0 < planescount) return iblock_or_diblock;
851  }
852 
853  return iblock_or_diblock;
854 }
855 
856 //------------------------------------------------------------------------------
858  ,offline_plane_t plane_0
859  ,const uint32_t max_number_of_blocks_or_diblocks
860  ,const uint** planes_in_block_or_diblock
861  ,const BlockNumerationOffset block_enum_offset
862  ) const
863 {
864 
865  CHECKERROR( plane_0);
866 
867  offline_plane_t planescount = 0;
868  uint32_t iblock_or_diblock = block_enum_offset; //we index from 0 or 1 on diblocks and blocks
869  for(; iblock_or_diblock < max_number_of_blocks_or_diblocks; ++iblock_or_diblock) {
870  planescount += planes_in_block_or_diblock[detector][iblock_or_diblock];
871  if(plane_0 < planescount) return iblock_or_diblock;
872  }
873 
874  return iblock_or_diblock;
875 }
876 
877 
878 //------------------------------------------------------------------------------
879 // Returns local plane number for the diblock from offline channel
881 {
882  return getLocalPlaneInBlockOrDiblock(detector, plane_0, _planesInDiblockDetectorSize[detector], (const uint32_t**)_planesInDiblockDetectorArray, DIBLOCK_OFFSET);
883 }
884 
885 //------------------------------------------------------------------------------
887 {
888  return getLocalPlaneInBlockOrDiblock(detector, plane_0, _planesInBlockDetectorSize[detector], (const uint32_t**)_planesInBlockDetectorArray, BLOCK_OFFSET);
889 }
890 
891 //------------------------------------------------------------------------------
893  ,offline_plane_t plane_0
894  ,const numberOfPlanesInBlockDetector_t& planes_in_block_or_diblock
895  ,const BlockNumerationOffset block_enum_offset
896  ) const
897 {
898 
899  offline_plane_t planescount = 0;
900  /// Add all planes before the current diblock
901  /// we index from 1 on diblocks
902  const uint32_t max_number_of_blocks_or_diblocks = planes_in_block_or_diblock[detector].size() - block_enum_offset;
903  for(uint32_t iblock_or_diblock = block_enum_offset; iblock_or_diblock <= max_number_of_blocks_or_diblocks; iblock_or_diblock++){
904 
905  uint32_t adding = planes_in_block_or_diblock[detector][iblock_or_diblock];
906 
907  if(planescount+adding > plane_0) break;
908 
909  planescount += adding;
910  }// end of loop over blocks or diblocks
911 
912  return plane_0 - planescount;
913 }
914 
915 //------------------------------------------------------------------------------
917  ,const offline_plane_t plane_0
918  ,const uint32_t max_number_of_blocks_or_diblocks
919  ,const uint** planes_in_block_or_diblock
920  ,const BlockNumerationOffset block_enum_offset
921  ) const{
922 
923  offline_plane_t planescount = 0;
924  /// Add all planes before the current diblock
925  /// we index from 1 on diblocks
926  for(uint32_t iblock_or_diblock = block_enum_offset; iblock_or_diblock < max_number_of_blocks_or_diblocks; iblock_or_diblock++){
927 
928  uint32_t adding = planes_in_block_or_diblock[detector][iblock_or_diblock];
929 
930  if(planescount+adding > plane_0) break;
931 
932  planescount += adding;
933  }// end of loop over blocks or diblocks
934 
935  return plane_0 - planescount;
936 
937 }
938 
939 //------------------------------------------------------------------------------
941  if(detector_plane_type == XZ_PLANE)return X_VIEW;
942  return Y_VIEW;
943 }
944 
945 //------------------------------------------------------------------------------
947  if(view_type == X_VIEW)return XZ_PLANE;
948  return YZ_PLANE;
949 }
950 
951 //------------------------------------------------------------------------------
953  if(input_view == X_VIEW)return Y_VIEW;
954  return X_VIEW;
955 }
956 
957 //------------------------------------------------------------------------------
959  if(input_plane_type == XZ_PLANE)return YZ_PLANE;
960  return XZ_PLANE;
961 }
962 
963 //------------------------------------------------------------------------------
965  switch(err_code){
966  case ERROR_GENERAL: return "General Error"; break;
967  case ERROR_UNKNOWN: return "Unknown Error"; break;
968  case ERROR_UNDEFINED: return "Undefined Error"; break;
969  case ERROR_CHAN_OUTRANGE: return "Channel Out of Range"; break;
970  case ERROR_PLANE_OUTRANGE: return "Plane Out of Range"; break;
971  case ERROR_BLOCK_OUTRANGE: return "Block Out of Range"; break;
972  case ERROR_DIBLOCK_OUTRANGE: return "DiBlock Out of Range"; break;
973  case ERROR_DCM_OUTRANGE: return "DCM Out of Range"; break;
974  case ERROR_PORT_OUTRANGE: return "Port Out of Range"; break;
975  case ERROR_PIXEL_OUTRANGE: return "Pixel Out of Range"; break;
976  case ERROR_CELL_OUTRANGE: return "Cell Out of Range"; break;
977  case ERROR_MODULE_OUTRANGE: return "Module Out of Range"; break;
978  case ERROR_UNKNOWN_DIBLOCK: return "Unknown Diblock"; break;
979  case ERROR_UNKNOWN_DIBLOCK_TYPE: return "Unknown Diblock Type"; break;
980  case ERROR_UNKNOWN_DCM: return "Unknown DCM"; break;
981  case ERROR_UNKNOWN_LINK: return "Unknown Link"; break;
982  case ERROR_UNKNOWN_VIEW: return "Unknown Readout View"; break;
983  case ERROR_UNKNOWN_DET: return "Unknown Detector"; break;
984  case ERROR_UNKNOWN_CELL: return "Unknown Cell"; break;
985 
986  default:
987  return "Error Code Not Found";
988  break;
989  }
990 
991  return "Error with Error";
992 }
993 
994 //------------------------------------------------------------------------------
995 bool DAQChannelMapBaseOLD::allocateArray(uint32_t**& outputarray, const std::vector< std::vector<uint32_t> >& input_vector){
996 
997  outputarray = (unsigned int**)malloc(input_vector.size() * sizeof(unsigned int*));
998 
999  for(uint32_t i = 0; i < input_vector.size(); ++i){
1000  if(input_vector[i].size() > 0)
1001  outputarray[i] = (uint32_t*)&input_vector[i][0];
1002  }
1003 
1004  return true;
1005 }
1006 
1007 //------------------------------------------------------------------------------
1008 bool DAQChannelMapBaseOLD::allocateSize (uint32_t*& outputarray, const std::vector< std::vector<uint32_t> >& input_vector){
1009 
1010  outputarray = (unsigned int*)malloc(input_vector.size() * sizeof(unsigned int));
1011 
1012  for(uint32_t i = 0; i < input_vector.size(); ++i){
1013  outputarray[i] = input_vector[i].size();
1014  }
1015 
1016  return true;
1017 
1018 }
uint32_t ** _numberOfTypePlanesInDiBlockArray
Keyed bu the DetPlane_TYPE and.
static const unsigned int apd_pixel2cell_v0[]
static const unsigned int NUM_YCHAN_PLANE[]
NDOS Muon catcher Block.
Identifier for the vertical plane.
uint32_t getLocalBlockInDiblock(const block_t) const
Identifier for a "B" type detector block (starts with Y measuring plane)
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
uint32_t getNumberOfPlanesBeforeDiblock(int detId, diblock_t) const
static const unsigned int DetectorDiBlockConfig_FARDET[]
bool initNumberOfCellsPerDCMInDiblock()
Initialization methods.
DetBlock_TYPE
Types of Block.
Identifider for NearDet Muon catcher.
uint32_t getNumberOfChannelsInPlane(const int detId, const DetPlane_TYPE) const
Get Number of channels in plane.
#define PUT_ENUM(INPUT)
std::vector< uint32_t > _totalNumberOfPlanes
uint32_t pixel_t
Type for physical pixel on APD.
uint32_t getTotalNumberOfPlanes(const int detId) const
Total number of Planes in the detector.
numberOfPlanesInBlockDetector_t _planesBeforeBlockDetector
#define CHECKERROR(a)
uint32_t offline_plane_t
Type for offline plane. Offline counts from 0.
#define CHAN_IDX_0_1
This thing has to have a comma at the end or it could be entirely empty.
uint32_t getNumberOfCellsPerDCM(DiBlock_TYPE) const
Number of cells per DCM for a given diblock type.
do we count diblocks from 0 or 1
OStream cerr
Definition: OStream.cxx:7
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)
std::vector< uint32_t > _planesInBlockType
DiBlock_TYPE getDiBlockType(int detId, diblock_t) const
Diblock type given detectorID and diblock number.
uint32_t getNumberOfPlanesInBlock(int detId, block_t) const
Number of planes in the block given detectorID and block number.
static const unsigned int apd_cell2pixel_v0[]
static const unsigned int DetectorDiBlockConfig_NEARDET[]
uint32_t getNumberOfXDCM(int detId, DiBlock_TYPE) const
Number of DCMs for horizontal planes in the diblock given detectorID and Diblock type.
uint32_t getNumberOfDCM(int detId, DiBlock_TYPE) const
Total number of DCMs in the diblock given detectorID and Diblock type.
std::vector< apd_pixel_t > _cell2ApdPixelMap
uint32_t getNumberOfYDCM(int detId, DiBlock_TYPE) const
Number of DCMs for vertical planes in the diblock given detectorID and Diblock type.
Identifier for the Y measuring view of the detector (side)
const char * errorString(DAQChanMapErrorCodes err_code) const
DetPlane_TYPE detViewToDetPlane(DetView_TYPE) const
Conversion from DetView_TYPE to DetPlane_TYPE.
numberOfPlanesInBlockDetector_t _planesInBlockDetector
Identifier for the horizontal plane.
numberOfDCMsInDiblockDetector_t _numberOfXDCMsInDiblockDetector
std::vector< DetPlane_TYPE > _startPlaneTypeInBlock
Does the block start with X or Y plane. Keyed by block.
uint32_t getBlockOrDiblock(int detId, offline_plane_t, const numberOfPlanesInBlockDetector_t &, const BlockNumerationOffset) const
std::vector< uint32_t > _planesInDiblockType
Far Detector at Ash River, MN.
offline_plane_t getLocalPlaneInBlockOrDiblock(int detId, offline_plane_t, const numberOfPlanesInBlockDetector_t &, const BlockNumerationOffset) const
DetBlock_TYPE getBlockType(DiBlock_TYPE, uint32_t local_block_number_in_diblock) const
Block type given diblock type an local block in diblock.
block
print "ROW IS " print row
Definition: elec2geo.py:31
static const unsigned int NUM_X_DCMS[]
bool print() const
Print all detectors info.
numberOfTypePlanesInDiblock_t _numberOfTypePlanesInDiBlock
Keyed bu the DetPlane_TYPE and.
DetView_TYPE detPlaneToDetView(DetPlane_TYPE) const
Conversion from DetPlane_TYPE to DetView_TYPE.
std::vector< std::vector< uint32_t > > DetectorDiBlockConfigVector
std::vector< uint32_t > _numberOfCellsPerDCMInDiblock
Keyed bu the DetPlane_TYPE and.
std::vector< uint32_t > getVector(const unsigned int *, const unsigned int maxsize=1000000)
static const unsigned int DetectorDiBlockConfig_IPND[]
Identifier for diblocks of configuration B-A.
bool allocateArray(uint32_t **&, const std::vector< std::vector< uint32_t > > &)
#define ODD(x)
Prototype Near Detector on the surface at FNAL.
static const unsigned int DetectorDiBlockConfig_NDOS[]
DetView_TYPE getOtherView(DetView_TYPE) const
opposite plane view from the input. For instance Y = getOtherView(X)
Identifier for the X measuring view of the detector (top)
Identifier for an "AFULL" type detector block (starts with X measuring plane). 32 planes block...
Near Detector in the NuMI cavern.
do we count blocks from 0 or 1
std::vector< std::vector< uint32_t > > numberOfPlanesInBlockDetector_t
Identifier for an "A" type detector block (starts with X measuring plane)
pixel_t APDPixel2Pixel(apd_pixel_t) const
Pixel number from APDPixel.
Identifier for diblocks using a 32/32 configuration.
uint32_t ** _planeType_planeNumberArray
Plane type as a function of offline plane number and DetectorID.
uint32_t getBlockNumber(int detId, offline_plane_t) const
The block number given the detectorID and offline plane number.
static const unsigned int DetectorDiBlockConfig_TESTBEAM_2Block_1x1[]
std::vector< std::vector< uint32_t > > _planeType_planeNumber
OStream cout
Definition: OStream.cxx:6
static const unsigned int NUM_Y_DCMS[]
static const unsigned int NUM_DIBLOCK_DET[]
bool allocateSize(uint32_t *&, const std::vector< std::vector< uint32_t > > &)
offline_plane_t getLocalPlaneInBlock(int detId, offline_plane_t) const
Local plane in block number given the detectorID and offline plane number.
uint32_t getTotalNumberOfDiblocks(int detId) const
Total number of diblocks for a given detector.
int getDetectorIDMinimum() const
Get minimum detector ID.
int getDetectorIDMaximum() const
Get maximum detector ID.
bool isinitNumberOfCellsPerDCMInDiblock()
Checks for Initialization methods.
numberOfPlanesInBlockDetector_t _planesInDiblockDetector
static const unsigned int DetectorDiBlockConfig_TESTBEAM_3Block_1x1[]
uint32_t ** _numberOfTypePlanesInBlockArray
Keyed bu the DetPlane_TYPE and.
Identifier for diblocks of configuration A-B.
NearDet Muon catcher Block.
Identifider for NDOS Muon catcher.
uint32_t getTotalNumberOfBlocks(int detId) const
Total number of blocks for a given detector.
static const unsigned int DetectorDiBlockConfig_TESTBEAM_2Block_2x2[]
numberOfDCMsInDiblockDetector_t _numberOfYDCMsInDiblockDetector
static const unsigned int NUM_XCHAN_PLANE[]
DetView_TYPE
Types of Detector View.
static const unsigned int NUM_DCMS_DIBLOCK[]
Identifier for diblocks of configuration A-A.
exit(0)
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) ...
uint32_t diblock_t
Type for diblocks and blocks.
std::vector< uint32_t > numberOfPlanesInBlock_t
Some type defs.
DetPlane_TYPE
Types of Detector Plane.
Identifier for diblocks of configuration A-B.
uint32_t getNumberOfPlanesInDiblock(int detId, diblock_t) const
Number of planes in the diblock given detectorID and diblock number.
offline_plane_t getLocalPlaneInDiblock(int detId, offline_plane_t) const
Local plane in diblock number given the detectorID and offline plane number.
uint32_t * _numberOfCellsPerDCMInDiblockArray
Number of cells that each DCM caries for each diblock type.
DetPlane_TYPE getPlaneType(const int detId, const offline_plane_t) const
get Plane type
DiBlock_TYPE
Types of Diblock.
uint32_t getNumberOfChannelsInXPlane(int detId) const
Number of channels in X plane for a given detectorID.
numberOfTypePlanesInBlock_t _numberOfTypePlanesInBlock
uint32_t getDiblockNumber(int detId, offline_plane_t) const
The diblock number given the detectorID and offline plane number.
DetPlane_TYPE getStartPlaneTypeInBlock(DetBlock_TYPE) const
Starting plane in the block given its type.
bool initApdPixel2PixelMap()
Initialization methods.
numberOfPlanesInBlockDetector_t _BlockOrderInDiblock
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) ...
numberOfPlanesInBlockDetector_t _planesBeforeDiblockDetector
static const unsigned int DetectorDiBlockConfig_TESTBEAM_3Block_2x2[]
uint32_t getNumberOfPlanesBeforeBlock(int detId, block_t) const
Number of planes before block or diblock.
apd_pixel_t pixel2APDPixel(pixel_t) const
APDPixel number from Pixel.
unsigned int uint