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