DAQChannelMap.cpp
Go to the documentation of this file.
1 #include <cstdio>
2 #include <cstdlib>
3 #include <iostream>
4 #include "DAQChannelMap/FarDetDAQChannelMap.h"
5 #include "DAQChannelMap/NDOSDAQChannelMap.h"
6 #include "DAQChannelMap/NearDetDAQChannelMap.h"
7 #include "DAQChannelMap/TestBeamDAQChannelMap.h"
8 #include "DAQChannelMap/BitFields.h"
9 #include "DAQChannelMap/boundscheck.h"
10 #include "NovaDAQConventions/DAQConventions.h"
11 using namespace daqchannelmap;
12 
13 // Create an initial detector specific instance if there is no current
14 // instance or return the current instance.
15 //
17 {
18  static FarDetDAQChannelMap* FarDetInst = 0;
19  static NearDetDAQChannelMap* NearDetInst = 0;
20  static NDOSDAQChannelMap* NDOSInst = 0;
21  static TestBeamDAQChannelMap* TestBeamInst = 0;
22 
23  switch(detID) {
25  if (NearDetInst) { delete NearDetInst; NearDetInst = 0; }
26  if (NDOSInst) { delete NDOSInst; NDOSInst = 0; }
27  if (TestBeamInst){ delete TestBeamInst;TestBeamInst= 0; }
28  if (FarDetInst==0) FarDetInst = new FarDetDAQChannelMap();
29  return FarDetInst;
31  if (FarDetInst) { delete FarDetInst; FarDetInst = 0; }
32  if (NDOSInst) { delete NDOSInst; NDOSInst = 0; }
33  if (TestBeamInst){ delete TestBeamInst;TestBeamInst= 0; }
34  if (NearDetInst==0) NearDetInst = new NearDetDAQChannelMap();
35  return NearDetInst;
36  case novadaq::cnv::kNDOS :
37  if (FarDetInst) { delete FarDetInst; FarDetInst = 0; }
38  if (NearDetInst) { delete NearDetInst; NearDetInst = 0; }
39  if (TestBeamInst){ delete TestBeamInst;TestBeamInst= 0; }
40  if (NDOSInst==0) NDOSInst = new NDOSDAQChannelMap();
41  return NDOSInst;
43  if (FarDetInst) { delete FarDetInst; FarDetInst = 0; }
44  if (NearDetInst) { delete NearDetInst; NearDetInst = 0; }
45  if (NDOSInst) { delete NDOSInst; NDOSInst = 0; }
46  if (TestBeamInst==0) TestBeamInst = new TestBeamDAQChannelMap();
47  return TestBeamInst;
48  default:
49  std::cerr<<" No valid detector specified!!!!!"<<std::endl;
50  abort();
51  }
52  return 0;
53 }
54 
55 //......................................................................
56 
58 
59 //......................................................................
60 
62 
63 //......................................................................
64 
67  dcm_id_t dcm,
68  feb_t feb,
69  pixel_t pixel) const
70 {
71  dchan chan = 0x0;
72  BITFIELDSET(chan,detector, MASK_DETECTOR, SHIFT_DETECTOR);
73  BITFIELDSET(chan,diblock, MASK_DIBLOCK, SHIFT_DIBLOCK);
77  return chan;
78 }
79 
80 //......................................................................
81 
83  plane_t plane,
84  cell_t cell) const
85 {
86  lchan chan = 0x0;
90  return chan;
91 }
92 
93 //......................................................................
94 
96 {
101 }
102 
103 //......................................................................
104 
106 {
108  MIN_DIBLOCK,
109  MAX_DIBLOCK,
111 }
112 
113 //......................................................................
114 
116 {
118  MIN_DCM,
119  MAX_DCM,
121 }
122 
123 //......................................................................
124 
126 {
128  MIN_PORT,
129  MAX_PORT,
131 }
132 
133 //......................................................................
134 
136 {
138  MIN_PIXEL,
139  MAX_PIXEL,
141 }
142 
143 //......................................................................
144 
146 {
148  0,
149  NUM_PLANES_DIBLOCK[getDetector(chan)]*
150  NUM_DIBLOCK_DET[getDetector(chan)], ERROR_PLANE_OUTRANGE);
151 }
152 
153 //......................................................................
154 
156 {
158  0,
159  NUM_CELLS*
160  NUM_PLANES_DIBLOCK[getDetectorOffline(chan)]*
161  NUM_DIBLOCK_DET[getDetectorOffline(chan)],
163 }
164 ////////////////////////////////////////////////////////////////
int getDetector(uint32_t anychan) const
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
APD Pixel Number (8bit), valid range 0-31.
uint32_t pixel_t
Type for physical pixel on APD.
OStream cerr
Definition: OStream.cxx:7
Plane Number,(18bit), valid range 0-930 (far det)
cell_t getCell(lchan logicalchan) const
Decode the cell number from an lchan.
lchan encodeLChan(int detId, plane_t plane, cell_t cell) const
Detector ID, (4bit), valid range 1-4.
#define BITFIELDGET(block, mask, shift)
Definition: BitFields.h:23
Far Detector at Ash River, MN.
Diblock ID, (6bit), valid range 1-15.
static DAQChannelMap * getInstance(int detID)
DAQChannelMap()
DAQChannelMap is a singleton - keep the constructor private.
Detector ID, (4bit), valid range 1-4.
DCM ID, (6bit), valid range 1-12.
Prototype Near Detector on the surface at FNAL.
Near Detector in the NuMI cavern.
uint32_t feb_t
Type for DCM link port. Counts from 0.
#define BOUNDSCHECK(value, min, max, err)
Definition: boundscheck.h:22
Cell Number, (10bit), valid range 1-384 (far det)
uint32_t dcm_id_t
Type for DCM number, counts from 1.
#define BITFIELDSET(block, data, mask, shift)
Definition: BitFields.h:24
pixel_t getPixel(dchan daqchan) const
Decode the pixel id from a dchan.
uint32_t plane_t
Type for plane.
plane_t getPlane(lchan logicalchan) const
Decode the plane number from an lchan.
DCM Link Port (8bit), valid range 0-63.
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
uint32_t dchan
< DAQ Channel Map Package
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.