ProtoDUNEChannelMapAlgv7.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file ProtoDUNEChannelMapAlgv7.cxx
3 /// \brief Interface to algorithm class for a specific detector channel mapping
4 ///
5 /// \version $Id: $
6 /// \author tylerdalion@gmail.com
7 ////////////////////////////////////////////////////////////////////////
8 
13 
22 
23 #include <iomanip>
24 
25 using std::map;
27 using std::cout;
28 using std::endl;
29 using std::setw;
30 
31 typedef unsigned int Index;
32 
33 namespace geo {
34 
35 //----------------------------------------------------------------------------
36 
40  {
41  fSorter = new GeoObjectSorterAPA(p);
42  }
43 
44 
45 //----------------------------------------------------------------------------
46 
48  Uninitialize();
49 
50  // Call the base-class version to perform TPC-related actions
52 
53  // Manually entered based on maps from Chris Macias
54  // http://indico.fnal.gov/event/14582/session/30/contribution/30/material/slides/0.pdf
55  //
56  // That gives SSP and channel ranges from OpDet. These offline channels correspond
57  // to the APAs listed. This is for the geometry that includes the arapuca bar with its
58  // 16 optical windows (protodune geometry v7).
59  //
60  // USDaS(APA5) MSDaS(APA6) DSDaS(APA4)
61  // 19-28 10-18+29-44 0-9
62  //
63  // USRaS(APA3) MSRaS(APA2) DSRaS(APA1)
64  // 45-60+81-89 71-80 61-70
65 
66 
67  // DSDaS -- "normal" pattern
68  fSSP[ 0] = 41; fSSPChOne[ 0] = 0;
69  fSSP[ 1] = 41; fSSPChOne[ 1] = 4;
70  fSSP[ 2] = 41; fSSPChOne[ 2] = 8;
71  fSSP[ 3] = 42; fSSPChOne[ 3] = 0;
72  fSSP[ 4] = 42; fSSPChOne[ 4] = 4;
73  fSSP[ 5] = 42; fSSPChOne[ 5] = 8;
74  fSSP[ 6] = 43; fSSPChOne[ 6] = 0;
75  fSSP[ 7] = 43; fSSPChOne[ 7] = 4;
76  fSSP[ 8] = 43; fSSPChOne[ 8] = 8;
77  fSSP[ 9] = 44; fSSPChOne[ 9] = 0;
78 
79  // MSDaS -- unusual patternfor ARAPUCA
80  fSSP[10] = 61; fSSPChOne[10] = 0;
81  fSSP[11] = 61; fSSPChOne[11] = 4;
82  fSSP[12] = 61; fSSPChOne[12] = 8;
83  fSSP[13] = 62; fSSPChOne[13] = 0;
84  fSSP[14] = 62; fSSPChOne[14] = 4;
85  fSSP[29] = 63; fSSPChOne[29] = 0; // ARAPUCA
86  fSSP[30] = 63; fSSPChOne[30] = 0; // ARAPUCA
87  fSSP[31] = 63; fSSPChOne[31] = 1; // ARAPUCA
88  fSSP[32] = 63; fSSPChOne[32] = 1; // ARAPUCA
89  fSSP[33] = 63; fSSPChOne[33] = 2; // ARAPUCA
90  fSSP[34] = 63; fSSPChOne[34] = 2; // ARAPUCA
91  fSSP[35] = 63; fSSPChOne[35] = 3; // ARAPUCA
92  fSSP[36] = 63; fSSPChOne[36] = 3; // ARAPUCA
93  fSSP[37] = 63; fSSPChOne[37] = 4; // ARAPUCA
94  fSSP[38] = 63; fSSPChOne[38] = 5; // ARAPUCA
95  fSSP[39] = 63; fSSPChOne[39] = 6; // ARAPUCA
96  fSSP[40] = 63; fSSPChOne[40] = 7; // ARAPUCA
97  fSSP[41] = 63; fSSPChOne[41] = 8; // ARAPUCA
98  fSSP[42] = 63; fSSPChOne[42] = 9; // ARAPUCA
99  fSSP[43] = 63; fSSPChOne[43] = 10; // ARAPUCA
100  fSSP[44] = 63; fSSPChOne[44] = 11; // ARAPUCA
101  fSSP[15] = 62; fSSPChOne[15] = 8;
102  fSSP[16] = 64; fSSPChOne[16] = 0;
103  fSSP[17] = 64; fSSPChOne[17] = 4;
104  fSSP[18] = 64; fSSPChOne[18] = 8;
105 
106  // USDaS -- unusual pattern
107  fSSP[19] = 53; fSSPChOne[19] = 0;
108  fSSP[20] = 53; fSSPChOne[20] = 4;
109  fSSP[21] = 53; fSSPChOne[21] = 8;
110  fSSP[22] = 54; fSSPChOne[22] = 0;
111  fSSP[23] = 51; fSSPChOne[23] = 0;
112  fSSP[24] = 54; fSSPChOne[24] = 4;
113  fSSP[25] = 51; fSSPChOne[25] = 4;
114  fSSP[26] = 51; fSSPChOne[26] = 8;
115  fSSP[27] = 54; fSSPChOne[27] = 8;
116  fSSP[28] = 52; fSSPChOne[28] = 0;
117 
118  // DSRaS -- "normal" pattern
119  fSSP[61] = 11; fSSPChOne[61] = 0;
120  fSSP[62] = 11; fSSPChOne[62] = 4;
121  fSSP[63] = 11; fSSPChOne[63] = 8;
122  fSSP[64] = 12; fSSPChOne[64] = 0;
123  fSSP[65] = 12; fSSPChOne[65] = 4;
124  fSSP[66] = 12; fSSPChOne[66] = 8;
125  fSSP[67] = 13; fSSPChOne[67] = 0;
126  fSSP[68] = 13; fSSPChOne[68] = 4;
127  fSSP[69] = 13; fSSPChOne[69] = 8;
128  fSSP[70] = 14; fSSPChOne[70] = 0;
129 
130  // MSRaS -- "normal" pattern
131  fSSP[71] = 21; fSSPChOne[71] = 0;
132  fSSP[72] = 21; fSSPChOne[72] = 4;
133  fSSP[73] = 21; fSSPChOne[73] = 8;
134  fSSP[74] = 22; fSSPChOne[74] = 0;
135  fSSP[75] = 22; fSSPChOne[75] = 4;
136  fSSP[76] = 22; fSSPChOne[76] = 8;
137  fSSP[77] = 23; fSSPChOne[77] = 0;
138  fSSP[78] = 23; fSSPChOne[78] = 4;
139  fSSP[79] = 23; fSSPChOne[79] = 8;
140  fSSP[80] = 24; fSSPChOne[80] = 0;
141 
142  // USRaS -- unusual patternfor ARAPUCA
143  fSSP[81] = 31; fSSPChOne[81] = 0;
144  fSSP[82] = 31; fSSPChOne[82] = 4;
145  fSSP[83] = 31; fSSPChOne[83] = 8;
146  fSSP[45] = 34; fSSPChOne[45] = 0; // ARAPUCA
147  fSSP[46] = 34; fSSPChOne[46] = 0; // ARAPUCA
148  fSSP[47] = 34; fSSPChOne[47] = 1; // ARAPUCA
149  fSSP[48] = 34; fSSPChOne[48] = 1; // ARAPUCA
150  fSSP[49] = 34; fSSPChOne[49] = 2; // ARAPUCA
151  fSSP[50] = 34; fSSPChOne[50] = 2; // ARAPUCA
152  fSSP[51] = 34; fSSPChOne[51] = 3; // ARAPUCA
153  fSSP[52] = 34; fSSPChOne[52] = 3; // ARAPUCA
154  fSSP[53] = 34; fSSPChOne[53] = 4; // ARAPUCA
155  fSSP[54] = 34; fSSPChOne[54] = 5; // ARAPUCA
156  fSSP[55] = 34; fSSPChOne[55] = 6; // ARAPUCA
157  fSSP[56] = 34; fSSPChOne[56] = 7; // ARAPUCA
158  fSSP[57] = 34; fSSPChOne[57] = 8; // ARAPUCA
159  fSSP[58] = 34; fSSPChOne[58] = 9; // ARAPUCA
160  fSSP[59] = 34; fSSPChOne[59] = 10; // ARAPUCA
161  fSSP[60] = 34; fSSPChOne[60] = 11; // ARAPUCA
162  fSSP[84] = 32; fSSPChOne[84] = 0;
163  fSSP[85] = 32; fSSPChOne[85] = 4;
164  fSSP[86] = 32; fSSPChOne[86] = 8;
165  fSSP[87] = 33; fSSPChOne[87] = 0;
166  fSSP[88] = 33; fSSPChOne[88] = 4;
167  fSSP[89] = 33; fSSPChOne[89] = 8;
168 
169  // The above enables OpDet + HW channel -> OpChannel
170  //
171  // Fill the maps below to do the reverse by looping through
172  // all possible OpDet and HW Channel combinations
173 
174  fMaxOpChannel = 0;
175  fNOpChannels = 0;
176 
177  for (Index opDet = 0; opDet < 90; opDet++) {
178  for (Index hwCh = 0; hwCh < NOpHardwareChannels(opDet); hwCh++) {
179 
180  // Find the channel number for this opDet and hw channel
181  Index opChannel = OpChannel(opDet, hwCh);
182 
183  // Count channels and record the maximum possible channel
184  if (opChannel > fMaxOpChannel) fMaxOpChannel = opChannel;
185  fNOpChannels++;
186 
187  // Fill maps for opChannel -> opDet and hwChannel
188  fOpDet[opChannel] = opDet;
189  fHWChannel[opChannel] = hwCh;
190  }
191  }
192 
193 // PrintChannelMaps();
194  }
195 
196 
197 //----------------------------------------------------------------------------
198 
200  // Call the base-class version to perform TPC-related actions
202  }
203 
204 //----------------------------------------------------------------------------
205 
207  return fNOpChannels;
208  }
209 
210 //----------------------------------------------------------------------------
211 
213  return fMaxOpChannel;
214  }
215 
216 //----------------------------------------------------------------------------
217 
219 
220  // ARAPUCAs
221  if ((opDet > 28 && opDet < 61))
222  return 1;
223  else
224  return 4;
225  }
226 
227 //----------------------------------------------------------------------------
228 
230 
231  Index sspch = fSSPChOne.at(detNum) + channel;
232  Index ssp = fSSP.at(detNum);
233 
234  // Special handling of ARAPUCA in MSDaS which cross between SSP 62 and 63
235  if (sspch > 12) {
236  mf::LogError("ProtoDUNEChannelMapAlgv7") << "Invalid address: SSP #" << ssp << ", SSP channel" << sspch;
237  }
238 
239  return OpChannelFromSSP(ssp, sspch);
240  }
241 
242 //----------------------------------------------------------------------------
243 
245  if (!IsValidOpChannel(opChannel, 90)) {
246  mf::LogWarning("ProtoDUNEChannelMapAlgv7") << "Requesting an OpDet number for an uninstrumented channel, " << opChannel;
247  return 99999;
248  }
249  return fOpDet.at(opChannel);
250  }
251 
252 //----------------------------------------------------------------------------
253 
255  if (!IsValidOpChannel(opChannel, 90)) {
256  mf::LogWarning("ProtoDUNEChannelMapAlgv7") << "Requesting an OpDet number for an uninstrumented channel, " << opChannel;
257  return 99999;
258  }
259  return fHWChannel.at(opChannel);
260  }
261 
262 
263 //----------------------------------------------------------------------------
264 
266  // Expects SSP #'s of the from NM where N is APA number and M is SSP within the APA
267  // So, IP 504 -> AP # 54
268 
269  // ( ( APA # - 1 ) )*4 + SSP per APA)*12 + SSP channel
270  Index ch = ( (trunc(ssp/10) - 1)*4 + ssp%10 - 1 )*12 + sspch;
271  return ch;
272 
273  }
274 
275 
276 //----------------------------------------------------------------------------
277 
278 
280 
281 
282  cout << "---------------------------------------------------------------" << endl;
283  cout << "---------------------------------------------------------------" << endl;
284  cout << "---------------------------------------------------------------" << endl;
285  cout << "---------------------------------------------------------------" << endl;
286  cout << "---------------------------------------------------------------" << endl;
287  cout << "---------------------------------------------------------------" << endl;
288  cout << "---------------------------------------------------------------" << endl;
289  cout << endl << endl;
290 
291  std::vector<Index> ssps = { 11, 12, 13, 14,
292  21, 22, 23, 24,
293  31, 32, 33, 34,
294  41, 42, 43, 44,
295  51, 52, 53, 54,
296  61, 62, 63, 64 };
297 
298  cout << endl << "By SSP" << endl;
299  for (Index ssp : ssps) {
300  for (Index sspch = 0; sspch < 12; sspch++) {
301  cout << setw(2) << ssp << " " << setw(2) << sspch << ": " << setw(3) << OpChannelFromSSP(ssp, sspch) << endl;
302  }
303  }
304 
305  cout << endl << "Non-Beam side" << endl;
306  for (Index opDet = 0; opDet < 45; opDet ++) {
307  cout << setw(2) << opDet << ":";
308  for (Index hwCh = 0; hwCh < NOpHardwareChannels(opDet); hwCh++) {
309  cout << " " << setw(2) << OpChannel(opDet, hwCh);
310  }
311  cout << endl;
312  }
313 
314 
315  cout << endl << "Beam side" << endl;
316  for (Index opDet = 45; opDet < 90; opDet ++) {
317  cout << setw(2) << opDet << ":";
318  for (Index hwCh = 0; hwCh < NOpHardwareChannels(opDet); hwCh++) {
319  cout << " " << setw(2) << OpChannel(opDet, hwCh);
320  }
321  cout << endl;
322  }
323 
324 
325  cout << endl << "Online -> offline" << endl;
326  for (Index opCh = 0; opCh < MaxOpChannel(90); opCh++) {
327  cout << setw(3) << opCh << ": ";
328  if ( IsValidOpChannel(opCh, 90) ) {
329  cout << setw(2) << OpDetFromOpChannel(opCh) << ", "
330  << setw(2) << HardwareChannelFromOpChannel(opCh) << endl;
331  }
332  else {
333  cout << "empty channel" << endl;
334  }
335  }
336 
337  cout << endl << endl;
338  cout << "---------------------------------------------------------------" << endl;
339  cout << "---------------------------------------------------------------" << endl;
340  cout << "---------------------------------------------------------------" << endl;
341  cout << "---------------------------------------------------------------" << endl;
342  cout << "---------------------------------------------------------------" << endl;
343  cout << "---------------------------------------------------------------" << endl;
344  cout << "---------------------------------------------------------------" << endl;
345 
346  }
347 }
Index MaxOpChannel(Index NOpDets) const override
Returns the number of optical channels contained in some detectors.
ProtoDUNEChannelMapAlgv7(const fhicl::ParameterSet &pset)
Encapsulate the construction of a single cyostat.
Index HardwareChannelFromOpChannel(Index opChannel) const override
Returns the hardware channel number of specified optical channel.
Interface to algorithm class for standard sorting of geo::XXXGeo objects.
void Uninitialize() override
Deconfiguration: prepare for a following call of Initialize()
std::map< Index, Index > fHWChannel
const geo::GeoObjectSorter * fSorter
sorts geo::XXXGeo objects
Interface to algorithm class for a specific detector channel mapping in protoDUNE.
Interface to algorithm class for a specific detector channel mapping.
Index OpChannel(Index detNum, Index channel) const override
Returns the channel ID of the specified hardware channel.
uint8_t channel
Definition: CRTFragment.hh:201
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Interface to algorithm class for sorting geo::XXXGeo objects.
Index OpChannelFromSSP(Index ssp, Index sspch) const
void Initialize(GeometryData_t const &geodata) override
Geometry initialisation.
Index NOpHardwareChannels(Index opDet) const override
Returns the number of channels in the specified optical detectors.
p
Definition: test.py:223
Encapsulate the geometry of an auxiliary detector.
bool IsValidOpChannel(Index opChannel, Index) const override
Returns whether the ID identifies a valid optical detector channel.
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
Encapsulate the geometry of a wire.
void Uninitialize() override
Deconfiguration: prepare for a following call of Initialize()
Index OpDetFromOpChannel(Index opChannel) const override
Returns the optical detector the specified optical channel belongs.
std::map< Index, Index > fSSPChOne
Index NOpChannels(Index NOpDets) const override
Returns the number of optical channels contained in some detectors.
Encapsulate the construction of a single detector plane.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Access the description of detector geometry.
int fNOpChannels
void Initialize(GeometryData_t const &geodata) override
Geometry initialisation.
Data in the geometry description.
Definition: GeometryData.h:31
int fMaxOpChannel
LArSoft geometry interface.
Definition: ChannelGeo.h:16
unsigned int Index
QTextStream & endl(QTextStream &s)
Encapsulate the construction of a single detector plane.