FarDetDAQChannelMap.cpp
Go to the documentation of this file.
1 ///
2 /// \file FarDetDAQChannelMap.cpp
3 /// \brief Far-detector specific connection map functions
4 /// \version $Id: FarDetDAQChannelMap.cpp,v 1.2 2014/07/14 18:45:29 messier Exp $
5 /// \author Hayes Merritt <hdmerrit@indiana.edu>
6 ///
7 #include "DAQChannelMap/FarDetDAQChannelMap.h"
8 #include "DAQChannelMap/FarDetDAQChannelMapConstants.h"
9 #include "DAQChannelMap/BitFields.h"
10 #include "DAQChannelMap/boundscheck.h"
11 #include "NovaDAQConventions/DAQConventions.h"
12 #include <stdio.h>
13 #include <iostream>
14 using namespace daqchannelmap;
15 
17 
18 //......................................................................
19 
21 
22 //......................................................................
23 
25 {
26  const int detector = getDetector(logicalchan);
27  const plane_t plane = getPlane(logicalchan);
28  const cell_t cell = getCell(logicalchan);
29  const diblock_t diblock = (plane/FD_NUM_PLANES_DIBLOCK) + 1;
30  fiber_t fiber = -1; // initialize to some crazy value.
31  //
32  // ONLY DO THIS FOR CELLS IN HORIZONTAL MODULES.
33  //
34  if (plane%2==0) fiber = FD_NUM_CELLS_PLANE - 1 - cell;
35  else fiber = cell;
36 
37  const dcm_id_t dcm = computeDCM(plane, fiber);
38  const feb_t feb = computeFEB(plane, fiber);
39  const pixel_t pixel = computePixel(fiber);
40 
41  return DAQChannelMap::encodeDChan(detector, diblock, dcm, feb, pixel);
42 }
43 
44 //......................................................................
45 
47 {
48  const int detector = getDetector(daqchan);
49  const diblock_t diblock = getDiBlock(daqchan);
50  const dcm_id_t dcm = getDCM(daqchan);
51  const feb_t feb = getFEB(daqchan);
52  const pixel_t pixel = getPixel(daqchan);
53 
54  const plane_t plane = computePlane(diblock, dcm, feb);
55  const cell_t cell = computeCell(dcm, feb, pixel);
56 
57  return DAQChannelMap::encodeLChan(detector, plane, cell);
58 }
59 
60 //......................................................................
61 
63 {
64  if (getDCM(d)<=6) return X_VIEW;
65  return Y_VIEW;
66 }
67 
68 //......................................................................
69 
71  fiber_t fiber) const
72 {
73  //
74  // DCM number calculation using global plane number and cell number
75  // in plane.
76  //
77  if (plane%2==0){
78  // plane is even corresponding to horizontal modules.
79  return fiber/FD_NUM_CELLS_DCM + 7;
80  }
81  // else
82  //
83  // plane is odd corresponding to vertical modules.
84  //
85  return fiber/FD_NUM_CELLS_DCM + 1;
86 }
87 
88 //......................................................................
89 //
90 // Return feb number. If not in module 0 or 1 will return a very
91 // large value.
92 //
94 {
95  //
96  // computes local module in the DCM (output is 0 or 1).
97  //
98  unsigned int module = (fiber/32) % 2;
99 
100  // Initialize to a nonsensical number.
101  feb_t feb = -1;
102 
103  ///
104  /// \todo This needs to be checked. Not sure if modules are counted
105  /// the way I assume...
106  ///
107  if (module==0) feb = (plane % 64)/2;
108  else if (module==1) feb = (plane % 64)/2 + 32;
109  return feb;
110 }
111 
112 //......................................................................
113 
115 {
116  //
117  // Get a value between 0 and 31 corresponding with fiber in local
118  // module which is needed for mapping to pixel on APD.
119  //
120  fiber_t local_fiber = fiber % 32;
121  return FiberToPixel(local_fiber);
122 }
123 
124 //......................................................................
125 
127  dcm_id_t dcm,
128  feb_t feb) const
129 {
130  if (dcm < 7){
131  //
132  // Vertical modules
133  //
134  return (feb % 32)*2 + 1 + (diblock-1)*64;
135  }
136  // else
137  //
138  // Horizontal modules.
139  //
140  return (feb % 32)*2 + (diblock-1)*64;
141 }
142 
143 //......................................................................
144 
146  feb_t feb,
147  pixel_t pixel) const
148 {
149  if (dcm < 7){
150  //
151  // Vertical modules.
152  // returns physical cell in plane.
153  //
154  cell_t cell = ((dcm-1)*64 + (feb/32)*32 + PixelToFiber(pixel));
155  return cell;
156  }
157  // else...
158  //
159  // Horizontal modules. returns physical cell in plane.
160  //
161  cell_t cell =
162  (FD_NUM_CELLS_PLANE-1) -
163  ((dcm - 7)*64 +
164  (feb/32)*32 +
165  PixelToFiber(pixel));
166  return cell;
167 }
168 
169 //......................................................................
170 
172 {
173  plane_t plane = getPlane(logicalchan);
175 
176  return block;
177 }
178 
179 //......................................................................
180 
182 {
183  return pixeltofiber[pixel];
184 }
185 
186 //......................................................................
187 
189 {
190  return fibertopixel[fiber];
191 }
192 
193 //......................................................................
194 
196 {
197  plane_t plane = getPlane(logicalchan);
198  //
199  // plane mod 32 will return the plane in block for the Far Detector.
200  //
201  return plane%32;
202 }
203 
204 //......................................................................
205 
206 unsigned int FarDetDAQChannelMap::computeModule(lchan logicalchan) const
207 {
208  cell_t cell = getCell(logicalchan);
209  //
210  // cell over 32 will return an integer value corresponding with the
211  // module in which the cell resides.
212  //
213  return cell/32;
214 }
215 
216 //......................................................................
217 
219 {
220  pixel_t pixel = getPixel(daqchan);
221  fiber_t fiber = PixelToFiber(pixel);
222 
223  return fiber;
224 }
225 
226 //......................................................................
227 
229 {
230  return FD_NUM_DIBLOCKS;
231 }
232 
233 //......................................................................
234 
236 {
237  return FD_NUM_DCMS;
238 }
239 
240 //......................................................................
241 
243 {
244  return AFULLAFULL_DIBLOCK;
245 }
246 
247 ////////////////////////////////////////////////////////////////
fiber_t PixelToFiber(pixel_t pixel) const
int getDetector(uint32_t anychan) const
pixel_t computePixel(fiber_t fiber) const
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
DetView_TYPE getView(dchan daqchan) const
Which view (X or Y) does this daq channel readout?
cell_t computeCell(dcm_id_t dcm, feb_t feb, pixel_t pixel) const
unsigned int getNumberOfDCM(DiBlock_TYPE dbt) const
How many DCMs does this diblock have?
uint32_t pixel_t
Type for physical pixel on APD.
fiber_t computeFiberInModule(dchan daqchan) const
Which fiber does this dchan readout?
unsigned int getTotalNumberOfDiblocks() const
How many diblocks does the detector have?
unsigned int computeModule(lchan logicalchan) const
Which module in this lchan in?
const unsigned int pixeltofiber[]
cell_t getCell(lchan logicalchan) const
Decode the cell number from an lchan.
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
plane_t computePlane(diblock_t diblock, dcm_id_t dcm, feb_t feb) const
const unsigned int fibertopixel[]
Identifier for the Y measuring view of the detector (side)
feb_t computeFEB(plane_t plane, fiber_t fiber) const
block
print "ROW IS " print row
Definition: elec2geo.py:31
plane_t computePlaneInBlock(lchan logicalchan) const
Which global plane in this lchan in?
pixel_t FiberToPixel(fiber_t fiber) const
Identifier for the X measuring view of the detector (top)
Float_t d
Definition: plot.C:236
uint32_t feb_t
Type for DCM link port. Counts from 0.
lchan encodeLChan(dchan daqchan) const
Convert a DAQ channel ID to a logical channel id.
dcm_id_t computeDCM(plane_t plane, fiber_t fiber) const
Identifier for diblocks using a 32/32 configuration.
uint32_t dcm_id_t
Type for DCM number, counts from 1.
DiBlock_TYPE getDiBlockType(dchan chan) const
What format is the diblock? Only relevant in NDOS.
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
uint32_t plane_t
Type for plane.
DetView_TYPE
Types of Detector View.
plane_t getPlane(lchan logicalchan) const
Decode the plane number from an lchan.
uint32_t diblock_t
Type for diblocks and blocks.
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
dchan encodeDChan(int detID, diblock_t diblock, dcm_id_t dcm, feb_t feb, pixel_t pixel) const
DiBlock_TYPE
Types of Diblock.
dchan encodeDChan(lchan logicalchan) const
Convert a logical channel ID to a DAQ channel id.
uint32_t dchan
< DAQ Channel Map Package
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
block_t computeBlock(lchan logicalchan) const
Which block is this lchan in?
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.