IcebergChannelMapService.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////////////////////////
2 // Class: IcebergChannelMapService
3 // Module type: service
4 // File: IcebergChannelMapService.h
5 // Author: Tom Junk, November 2018
6 //
7 // Implementation of hardware-offline channel mapping reading from files. Keep the FELIX map functionality around just
8 // in case someone uses FELIX on Iceberg
9 // Separate files for TPC wires and SSP modules
10 ///////////////////////////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef IcebergChannelMapService_H
13 #define IcebergChannelMapService_H
14 
15 #include <map>
16 #include <vector>
17 #include <iostream>
18 #include <limits>
19 #include <fstream>
20 
23 
24 namespace dune {
25  class IcebergChannelMapService;
26 }
27 
29 
30 public:
31 
34 
35  typedef enum _FelixOrRCE
36  {
39  } FelixOrRCE;
40 
41  /////////////////////////\ Iceberg channel map functions //////////////////////////////
42 
43  // TPC channel map accessors
44 
45  // Map instrumentation numbers (crate:slot:fiber:FEMBchannel) to offline channel number
46  // FEMB channel number is really the stream index number, but for FELIX, it is restricted to be in the range 0:127, so really it's more like an FEMB channel number
47 
48  unsigned int GetOfflineNumberFromDetectorElements(unsigned int crate, unsigned int slot, unsigned int fiber, unsigned int fembchannel, FelixOrRCE frswitch);
49 
50  /// Returns APA/crate
51  unsigned int APAFromOfflineChannel(unsigned int offlineChannel) const;
52 
53  /// Returns APA/crate in installation notation
54  unsigned int InstalledAPAFromOfflineChannel(unsigned int offlineChannel) const;
55 
56  /// Returns WIB/slot
57  unsigned int WIBFromOfflineChannel(unsigned int offlineChannel) const;
58 
59  /// Returns FEMB/fiber
60  unsigned int FEMBFromOfflineChannel(unsigned int offlineChannel) const;
61 
62  /// Returns FEMB channel
63  unsigned int FEMBChannelFromOfflineChannel(unsigned int offlineChannel) const;
64 
65  /// Returns RCE(FELIX) stream(frame) channel
66  unsigned int StreamChannelFromOfflineChannel(unsigned int offlineChannel, FelixOrRCE frswitch) const;
67 
68  /// Returns global slot ID
69  unsigned int SlotIdFromOfflineChannel(unsigned int offlineChannel) const;
70 
71  /// Returns global fiber ID
72  unsigned int FiberIdFromOfflineChannel(unsigned int offlineChannel) const;
73 
74  /// Returns chip number
75  unsigned int ChipFromOfflineChannel(unsigned int offlineChannel) const;
76 
77  /// Returns chip channel number
78  unsigned int ChipChannelFromOfflineChannel(unsigned int offlineChannel) const;
79 
80  /// Returns ASIC number -- to be deprecated
81  unsigned int ASICFromOfflineChannel(unsigned int offlineChannel);
82 
83  /// Returns ASIC channel number -- to be deprecated
84  unsigned int ASICChannelFromOfflineChannel(unsigned int offlineChannel);
85 
86  // replaced by these
87 
88  unsigned int AsicFromOfflineChannel(unsigned int offlineChannel) const;
89 
90  unsigned int AsicChannelFromOfflineChannel(unsigned int offlineChannel) const;
91 
92  unsigned int AsicLinkFromOfflineChannel(unsigned int offlineChannel) const;
93 
94  /// Returns plane
95  unsigned int PlaneFromOfflineChannel(unsigned int offlineChannel) const;
96 
97 
98  // SSP channel map accessors
99 
100  unsigned int SSPOfflineChannelFromOnlineChannel(unsigned int onlineChannel);
101 
102  unsigned int SSPOnlineChannelFromOfflineChannel(unsigned int offlineChannel) const;
103 
104  unsigned int SSPAPAFromOfflineChannel(unsigned int offlineChannel) const;
105 
106  unsigned int SSPWithinAPAFromOfflineChannel(unsigned int offlineChannel) const;
107 
108  unsigned int SSPGlobalFromOfflineChannel(unsigned int offlineChannel) const;
109 
110  unsigned int SSPChanWithinSSPFromOfflineChannel(unsigned int offlineChannel) const;
111 
112  unsigned int OpDetNoFromOfflineChannel(unsigned int offlineChannel) const;
113 
114 private:
115 
116  // hardcoded TPC channel map sizes
117  // Note -- we are assuming that FELIX with its two fibers per fragment knows the fiber numbers and that we aren't
118  // encoding double-size channel lists for FELIX with single fiber numbers.
119 
120  const size_t fNChans = 1280;
121  const size_t fNCrates = 1;
122  const size_t fNSlots = 3;
123  const size_t fNFibers = 4;
124  const size_t fNFEMBChans = 128;
125 
126  // hardcoded SSP channel map sizes -- left over from ProtoDUNE-SP
127 
128  const size_t fNSSPChans = 288;
129  //const size_t fNSSPs = 24;
130  //const size_t fNSSPsPerAPA = 4;
131  const size_t fNChansPerSSP = 12;
132  const size_t fNAPAs = 6;
133 
134  // control behavior in case we need to fall back to default behavior
135 
140 
143 
144  // TPC Maps
145  unsigned int farrayCsfcToOffline[1][3][4][128]; // implement as an array. Do our own bounds checking
146 
147  // lookup tables as functions of offline channel number
148 
149  unsigned int fvAPAMap[1280]; // APA(=crate)
150  unsigned int fvWIBMap[1280]; // WIB(slot)
151  unsigned int fvFEMBMap[1280]; // FEMB(fiber)
152  unsigned int fvFEMBChannelMap[1280]; // FEMB internal channel
153  unsigned int fvStreamChannelMap[1280]; // RCE(FELIX) internal channel
154  unsigned int fvSlotIdMap[1280]; // global WIB(slot) ID
155  unsigned int fvFiberIdMap[1280]; // global FEMB(fiber) ID
156  unsigned int fvChipMap[1280]; // Chip
157  unsigned int fvChipChannelMap[1280]; //Chip internal channel
158  unsigned int fvASICMap[1280]; // ASIC
159  unsigned int fvASICChannelMap[1280]; // ASIC internal channel
160  unsigned int fvPlaneMap[1280]; // Plane type
161 
162  unsigned int fFELIXarrayCsfcToOffline[6][5][4][128]; // implement as an array. Do our own bounds checking
163  unsigned int fFELIXvAPAMap[1280]; // APA(=crate)
164  unsigned int fFELIXvWIBMap[1280]; // WIB(slot)
165  unsigned int fFELIXvFEMBMap[1280]; // FEMB(fiber)
166  unsigned int fFELIXvFEMBChannelMap[1280]; // FEMB internal channel
167  unsigned int fFELIXvStreamChannelMap[1280]; // RCE(FELIX) internal channel
168  unsigned int fFELIXvSlotIdMap[1280]; // global WIB(slot) ID
169  unsigned int fFELIXvFiberIdMap[1280]; // global FEMB(fiber) ID
170  unsigned int fFELIXvChipMap[1280]; // Chip
171  unsigned int fFELIXvChipChannelMap[1280]; //Chip internal channel
172  unsigned int fFELIXvASICMap[1280]; // ASIC
173  unsigned int fFELIXvASICChannelMap[1280]; // ASIC internal channel
174  unsigned int fFELIXvPlaneMap[1280]; // Plane type
175 
176  // SSP Maps
177 
178  unsigned int farraySSPOnlineToOffline[288]; // all accesses to this array need to be bounds-checked first.
179  unsigned int farraySSPOfflineToOnline[288];
180  unsigned int fvSSPAPAMap[288];
181  unsigned int fvSSPWithinAPAMap[288]; // Global SSP number 11, 12, 21, etc.
182  unsigned int fvSSPGlobalMap[288]; // Also global SSP number 11, 12, 21, etc.
183  unsigned int fvSSPChanWithinSSPMap[288];
184  unsigned int fvOpDetNoMap[288]; // PDS op det number
185 
186  size_t count_bits(size_t i); // returns the number of bits set, for use in determing whether to print a warning out
187 
188  //-----------------------------------------------
189 
190  void check_offline_channel(unsigned int offlineChannel) const
191  {
192  if (offlineChannel >= fNChans)
193  {
194  throw cet::exception("IcebergChannelMapService") << "Offline TPC Channel Number out of range: " << offlineChannel << "\n";
195  }
196  };
197 
198  void SSP_check_offline_channel(unsigned int offlineChannel) const
199  {
200  if (offlineChannel >= fNSSPChans)
201  {
202  throw cet::exception("IcebergChannelMapService") << "Offline SSP Channel Number out of range: " << offlineChannel << "\n";
203  }
204  };
205 };
206 
208 
209 #endif
unsigned int SSPAPAFromOfflineChannel(unsigned int offlineChannel) const
unsigned int SSPOfflineChannelFromOnlineChannel(unsigned int onlineChannel)
unsigned int farrayCsfcToOffline[1][3][4][128]
unsigned int ASICChannelFromOfflineChannel(unsigned int offlineChannel)
Returns ASIC channel number – to be deprecated.
unsigned int AsicChannelFromOfflineChannel(unsigned int offlineChannel) const
void check_offline_channel(unsigned int offlineChannel) const
unsigned int FiberIdFromOfflineChannel(unsigned int offlineChannel) const
Returns global fiber ID.
unsigned int SlotIdFromOfflineChannel(unsigned int offlineChannel) const
Returns global slot ID.
unsigned int OpDetNoFromOfflineChannel(unsigned int offlineChannel) const
unsigned int ChipChannelFromOfflineChannel(unsigned int offlineChannel) const
Returns chip channel number.
unsigned int AsicLinkFromOfflineChannel(unsigned int offlineChannel) const
unsigned int GetOfflineNumberFromDetectorElements(unsigned int crate, unsigned int slot, unsigned int fiber, unsigned int fembchannel, FelixOrRCE frswitch)
unsigned int SSPOnlineChannelFromOfflineChannel(unsigned int offlineChannel) const
struct dune::tde::crate crate
unsigned int AsicFromOfflineChannel(unsigned int offlineChannel) const
#define DECLARE_ART_SERVICE(svc, scope)
enum dune::IcebergChannelMapService::_FelixOrRCE FelixOrRCE
unsigned int SSPChanWithinSSPFromOfflineChannel(unsigned int offlineChannel) const
unsigned int StreamChannelFromOfflineChannel(unsigned int offlineChannel, FelixOrRCE frswitch) const
Returns RCE(FELIX) stream(frame) channel.
unsigned int fFELIXarrayCsfcToOffline[6][5][4][128]
unsigned int APAFromOfflineChannel(unsigned int offlineChannel) const
Returns APA/crate.
IcebergChannelMapService(fhicl::ParameterSet const &pset)
unsigned int InstalledAPAFromOfflineChannel(unsigned int offlineChannel) const
Returns APA/crate in installation notation.
unsigned int FEMBChannelFromOfflineChannel(unsigned int offlineChannel) const
Returns FEMB channel.
unsigned int ChipFromOfflineChannel(unsigned int offlineChannel) const
Returns chip number.
unsigned int ASICFromOfflineChannel(unsigned int offlineChannel)
Returns ASIC number – to be deprecated.
unsigned int PlaneFromOfflineChannel(unsigned int offlineChannel) const
Returns plane.
unsigned int SSPWithinAPAFromOfflineChannel(unsigned int offlineChannel) const
unsigned int SSPGlobalFromOfflineChannel(unsigned int offlineChannel) const
unsigned int WIBFromOfflineChannel(unsigned int offlineChannel) const
Returns WIB/slot.
unsigned int FEMBFromOfflineChannel(unsigned int offlineChannel) const
Returns FEMB/fiber.
void SSP_check_offline_channel(unsigned int offlineChannel) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33