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