TestBeamDAQChannelMap.cpp
Go to the documentation of this file.
1 ///
2 /// \file TestBeamDAQChannelMap.cpp
3 /// \brief Test Beam detector specific connection map functions
4 /// \author Teresa Lackey <tlackey@indiana.edu>
5 ///
6 #include "DAQChannelMap/TestBeamDAQChannelMap.h"
7 #include "DAQChannelMap/TestBeamDAQChannelMapConstants.h"
8 #include "DAQChannelMap/BitFields.h"
9 #include "DAQChannelMap/boundscheck.h"
10 #include "NovaDAQConventions/DAQConventions.h"
11 #include <stdio.h>
12 #include <iostream>
13 using namespace daqchannelmap;
14 
16 
17 //......................................................................
18 
20 
21 //......................................................................
22 
24 {
25  const int detector = getDetector(logicalchan);
26  const plane_t plane = getPlane(logicalchan);
27  const cell_t cell = getCell(logicalchan);
28  const diblock_t diblock = 1;
29  fiber_t fiber = -1; // initialize to some crazy value.
30  //
31  // For testbeam, snouts are on opposite side of detector.
32  // this means fiber and cell numbers are opposite each other
33  // for both horizontal and vertical modules.
34  //
35  fiber = TB_NUM_CELLS_PLANE - 1 - 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  // One dcm for block0, one for block1.
65  // dcm3 will have febs on both blocks
66 
67  // Top: feb 0,1,4,5, side: feb 2,3,6,7.
68  if (getDCM(d)==3){
69  if (getFEB(d)==0 || getFEB(d)==1 || getFEB(d)==4 || getFEB(d)==5) return X_VIEW;
70  else return Y_VIEW;
71  }
72 
73  else {
74  // FEB 0-31 on top, 32-63 on side.
75  if (getFEB(d) < 32) return X_VIEW;
76  else return Y_VIEW;
77  }
78 }
79 
80 //......................................................................
81 
83  fiber_t fiber) const
84 {
85  //
86  // DCM number calculation using global plane number and cell number
87  // in plane.
88  //
89 
90  // First check exception list for dcm3
91  // 4 planes on dcm 3
92  if (plane==16 || plane==17 || plane==48 || plane==49) return 3;
93 
94  // Then set the other dcms. Block 0 has 32 planes (0-31), block 1 has remaining 31 (32-62).
95  else if (plane < 32){
96  return 1;
97  }
98  //else if (plane>=32){
99  return 2;
100  //}
101 }
102 
103 //......................................................................
104 //
105 // Return feb number. If not in module 0 or 1 will return a very
106 // large value.
107 //
109 {
110  //
111  // computes local module in the DCM (output is 0 or 1).
112  // Note: dcm 3 does not follow same pattern
113  //
114 
115  unsigned int module = 99;
116  // Initialize to a nonsensical number.
117  feb_t feb = -1;
118 
119 
120  if (plane%2 == 0){
121  // Vertical modules
122  module = 1 - (fiber/32) % 2; // 0 or 1
123 
124  // Check planes on dcm 3 first
125  if (plane==16)
126  feb = module; // 0,1
127  else if
128  (plane==48)
129  feb = module + 4; // 4,5
130 
131  // All other (vertical) planes
132  else
133  feb = 16*module + (plane%32)/2; // 0,16,1,17,...
134  }
135  else {
136  // horizontal modules
137  module = (fiber/32) % 2; // 0 or 1
138 
139  // Check planes on dcm 3 first
140  if (plane==17)
141  feb = module + 2; // 2,3
142  else if (plane==49)
143  feb = module + 6; // 6,7
144 
145  // All other (horizontal) planes
146  else
147  feb = 32 + 16*module + (plane%32 - 1)/2; // 32,48,33,49,...
148  }
149 
150  return feb;
151 }
152 
153 //......................................................................
154 
156 {
157  //
158  // Get a value between 0 and 31 corresponding with fiber in local
159  // module which is needed for mapping to pixel on APD.
160  //
161  fiber_t local_fiber = fiber % 32;
162  return FiberToPixel(local_fiber);
163 }
164 
165 //......................................................................
166 
168  dcm_id_t dcm,
169  feb_t feb) const
170 {
171  plane_t plane = -1;
172  // Check for 4 planes on dcm3
173  if (dcm == 3) {
174  if (feb==0 || feb==1) plane = 16;
175  else if (feb==2 || feb==3) plane = 17;
176  else if (feb==4 || feb==5) plane = 48;
177  else plane = 49;
178  }
179 
180  else {
181  //if (dcm == 1 || dcm == 2){
182  // Vertical modules
183  if (feb < 32)
184  plane = (feb % 16)*2 + (dcm-1)*32; // 2n
185  // Horizontal modules
186  else
187  plane = (feb % 16)*2 + 1 + (dcm-1)*32; // 2n+1
188  }
189  return plane;
190 }
191 
192 //......................................................................
193 
195  feb_t feb,
196  pixel_t pixel) const
197 {
198 
199  // Pixel only goes up to 31, not 63. Need to use feb to figure out which module
200 
201  cell_t cell = -1;
202  unsigned int module = 99;
203  if (dcm == 3){
204  // Check exceptions
205  if (feb==0 || feb==4 || feb==3 || feb==7)
206  module = 0;
207  else
208  module = 1;
209  }
210  else{
211  if (feb < 16 || feb > 47)
212  module = 0;
213  else
214  module = 1;
215  }
216 
217  cell = (TB_NUM_CELLS_PLANE - 1 - (1-module)*32 - PixelToFiber(pixel));
218  // }
219  return cell;
220 }
221 
222 //......................................................................
223 
225 {
226  plane_t plane = getPlane(logicalchan);
227  block_t block = -1;
228 
229  if (plane < 32) block = 0;
230  else block = 1;
231 
232  return block;
233 }
234 
235 //......................................................................
236 
238 {
239  return pixeltofiber[pixel];
240 }
241 
242 //......................................................................
243 
245 {
246  return fibertopixel[fiber];
247 }
248 
249 //......................................................................
250 
252 {
253  plane_t plane = getPlane(logicalchan);
254  //
255  // Extra plane on block 0
256  //
257  return plane%32;
258 }
259 
260 //......................................................................
261 
262 unsigned int TestBeamDAQChannelMap::computeModule(lchan logicalchan) const
263 {
264  cell_t cell = getCell(logicalchan);
265  //
266  // cell over 32 will return an integer value corresponding with the
267  // module in which the cell resides. This function appears to be unused.
268  //
269  return cell/32;
270 }
271 
272 //......................................................................
273 
275 {
276  pixel_t pixel = getPixel(daqchan);
277  fiber_t fiber = PixelToFiber(pixel);
278 
279  return fiber;
280 }
281 
282 //......................................................................
283 
285 {
286  return TB_NUM_DIBLOCKS;
287 }
288 
289 //......................................................................
290 
292 {
293  return TB_NUM_DCMS;
294 }
295 
296 //......................................................................
297 
299 {
300  return AAFULL_DIBLOCK;
301 }
302 
303 ////////////////////////////////////////////////////////////////
int getDetector(uint32_t anychan) 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?
Identifier for diblocks of configuration A-AFULL (31/32) - TESTBEAM.
plane_t computePlane(diblock_t diblock, dcm_id_t dcm, feb_t feb) const
lchan encodeLChan(dchan daqchan) const
Convert a DAQ channel ID to a logical channel id.
uint32_t pixel_t
Type for physical pixel on APD.
DiBlock_TYPE getDiBlockType(dchan chan) const
What format is the diblock? Only relevant in NDOS.
const unsigned int pixeltofiber[]
pixel_t computePixel(fiber_t fiber) const
cell_t getCell(lchan logicalchan) const
Decode the cell number from an lchan.
fiber_t PixelToFiber(pixel_t pixel) const
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
const unsigned int fibertopixel[]
plane_t computePlaneInBlock(lchan logicalchan) const
Which global plane in this lchan in?
Identifier for the Y measuring view of the detector (side)
dchan encodeDChan(lchan logicalchan) const
Convert a logical channel ID to a DAQ channel id.
block
print "ROW IS " print row
Definition: elec2geo.py:31
Identifier for the X measuring view of the detector (top)
unsigned int computeModule(lchan logicalchan) const
Which module in this lchan in?
Float_t d
Definition: plot.C:236
uint32_t feb_t
Type for DCM link port. Counts from 0.
block_t computeBlock(lchan logicalchan) const
Which block is this lchan in?
dcm_id_t computeDCM(plane_t plane, fiber_t fiber) const
unsigned int getNumberOfDCM(DiBlock_TYPE dbt) const
How many DCMs does this diblock have?
pixel_t FiberToPixel(fiber_t fiber) const
uint32_t dcm_id_t
Type for DCM number, counts from 1.
fiber_t computeFiberInModule(dchan daqchan) const
Which fiber does this dchan readout?
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.
cell_t computeCell(dcm_id_t dcm, feb_t feb, pixel_t pixel) const
plane_t getPlane(lchan logicalchan) const
Decode the plane number from an lchan.
uint32_t diblock_t
Type for diblocks and blocks.
unsigned int getTotalNumberOfDiblocks() const
How many diblocks does the detector have?
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.
uint32_t dchan
< DAQ Channel Map Package
feb_t computeFEB(plane_t plane, fiber_t fiber) const
diblock_t getDiBlock(dchan daqchan) const
Decode the diblock ID from a dchan.
feb_t getFEB(dchan daqchan) const
Decode the feb id from a dchan.