All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ICARUSChannelMapAlg.h
Go to the documentation of this file.
1 /**
2  * @file icarusalg/Geometry/ICARUSChannelMapAlg.h
3  * @brief Channel mapping algorithms for ICARUS detector.
4  * @date October 19, 2019
5  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
6  * @see `icarusalg/Geometry/ICARUSChannelMapAlg.cxx`
7  */
8 
9 #ifndef ICARUSCODE_GEOMETRY_ICARUSCHANNELMAPALG_H
10 #define ICARUSCODE_GEOMETRY_ICARUSCHANNELMAPALG_H
11 
12 // ICARUS libraries
16 
17 // LArSoft libraries
19 // #include "larcorealg/Geometry/GeoObjectSorterStandard.h"
25 
26 // framework libraries
27 #include "fhiclcpp/types/OptionalDelegatedParameter.h"
28 #include "fhiclcpp/types/Atom.h"
29 #include "fhiclcpp/types/Table.h"
30 #include "fhiclcpp/ParameterSet.h"
31 
32 // C/C++ standard libraries
33 #include <vector>
34 #include <cassert>
35 
36 
37 // -----------------------------------------------------------------------------
38 // forward declarations
39 namespace icarus {
40 
41  class ICARUSChannelMapAlg;
42 
43 } // namespace icarus
44 
45 
46 // -----------------------------------------------------------------------------
47 /**
48  * @brief Channel mapping for ICARUS detector with split wires.
49  *
50  * This channel mapping is designed for a detector description including two
51  * TPC volumes in each drift volume.
52  *
53  * Each of the four drift volumes in the ICARUS detector (one on each of the two
54  * side of the cathode, on each of the two cryostats/modules) is described by
55  * two "logical" TPC volumes. The division of the drift volume in two TPCs is
56  * not physical, but it is a convenient description to accommodate the fact that
57  * the first induction plane wires are split in two 9-meter halves which are
58  * read independently.
59  *
60  * In this scheme, the physical wires from the second induction and the
61  * collection planes may be described by two `geo::WireGeo` objects associated
62  * to the same readout channel, with the two `geo::WireGeo` belonging to a
63  * different `geo::TPCGeo` and `geo::PlaneGeo` (but the planes are of the same
64  * type and on the same view).
65  * Therefore, physical wires on the second induction and collection planes are
66  * associated with a single `geo::WireGeo` unless they cross the virtual border
67  * between TPCs half way on the beam direction, in which case they are
68  * associated with two `geo::WireGeo`. The first induction wires are always
69  * associated with a single `geo::WireGeo`.
70  * Each physical wire is associated and identified with a single TPC readout
71  * channel.
72  *
73  * The numbering of channels is as follows:
74  *
75  * * the numbering is driven by physical wire planes
76  * * plane `0` goes first, then planes `1` and `2` follow; plane `0` is the
77  * plane closest to the drift volume, that is the first induction plane;
78  * * the internal order of the channels is defined by `geo::PlaneGeo` internal
79  * sorting algorithms, but it is guaranteed to be such that contiguous wires
80  * within the same logical wire plane have contiguous wire numbers, with no
81  * jumps and holes allowed;
82  * * TPC `0` and `1`, which are "logical" TPCs describing the same drift volume,
83  * go first, then TPCs `2` and `3`
84  * * cryostat `0` goes first, then cryostat `1`
85  *
86  * This implies that the first wire plane being enumerated is `C:0 T:0 P:0`,
87  * and then `C:0 T:1 P:0`, that cover the first induction plane of the first
88  * drift volume, then the `C:0 T:0 P:1` and `C:0 T:1 P:1` are grouped together
89  * for the second induction plane, and finally `C:0 T:0 P:2` and `C:0 T:1 P:2`
90  * for the collection.
91  * Thereafter, the enumeration proceeds through `C:0 T:2` and `C:0 T:3` starting
92  * with `C:0 T:2 P:0`, and then with the other cryostat in the same TPC and
93  * plane order.
94  *
95  *
96  * Wireless channels
97  * ==================
98  *
99  * It is possible to specify that some channels at the beginning and at the end
100  * of a readout plane are not connected to wires.
101  *
102  * When a readout plane is extended to include "wireless" channels, additional
103  * channel IDs are included in the sequence of channels.
104  * Channel mapping does not distinguish between wireless channels (which have
105  * readout, cable but no wire), ghost channels (which have no bable either)
106  * and virtual channels (which do not have even readout): the count of wireless
107  * channels includes all of these categories, i.e. all the categories that have
108  * a readout channel ID but no physical wire.
109  *
110  * The range of channels belonging to the readout plane (intended in LArSoft
111  * fashion as `readout::ROPID`) is extended to include these wireless channels,
112  * but each of the wire planes does not include them: they are orphaned of wire
113  * planes (no `geo::PlaneID`).
114  * The total number of channels reported by the mapping (and by the geometry
115  * service) includes these wireless channels as well: they are "valid" readout
116  * channels. Nevertheless, mapping them to a wire list will return an empty
117  * list. The `ChannelStatus` services should be utilized to find out the actual
118  * category of the channels when needed.
119  *
120  *
121  * Configuration
122  * --------------
123  *
124  * These channels are assigned _to each logical readout plane_: in the standard
125  * ICARUS geometry, for example, in each TPC set (i.e. drift volume) there
126  * are two first induction readout planes with 1056 wires each, and one second
127  * induction and one collection readout planes with 5600 wires each, and each
128  * spanning two logical wire planes. Assigning pre- or post-channels to the
129  * first induction planes will increase each of them from 1056 channels to
130  * whatever is requested. Assigning pre- or post-channels to the
131  * second induction or collection planes will increase them from 5600 channels
132  * to whatever is requested.
133  *
134  * The channel mapping configuration of the "standard" ICARUS detector should
135  * include:
136  *
137  * WirelessChannels: {
138  *
139  * FirstInductionPreChannels: 0
140  * FirstInductionPostChannels: 96 # 32 ghost, then 64 virtual
141  *
142  * # C:x S:0 (east TPC)
143  * SecondInductionEvenPreChannels: 96 # 32 ghost, then 64 wireless
144  * SecondInductionEvenPostChannels: 64 # 64 wireless
145  * CollectionEvenPreChannels: 64 # 64 wireless
146  * CollectionEvenPostChannels: 96 # 64 wireless, then 32 ghost
147  *
148  * # C:x S:1 (west TPC)
149  * SecondInductionOddPreChannels: 64 # 64 wireless
150  * SecondInductionOddPostChannels: 96 # 64 wireless, then 32 ghost
151  * CollectionOddPreChannels: 96 # 32 ghost, then 64 wireless
152  * CollectionOddPostChannels: 64 # 64 wireless
153  *
154  * } # WirelessChannels
155  *
156  * The configuration parameters must be specified in the `WirelessChannels`
157  * configuration table, as `FirstInductionPreChannels`,
158  * `FirstInductionPostChannels`, `SecondInductionEvenPreChannels`,
159  * `SecondInductionEvenPostChannels`, `CollectionEvenPreChannels`,
160  * `CollectionEvenPostChannels`, `SecondInductionOddPreChannels`,
161  * `SecondInductionOddPostChannels`, `CollectionOddPreChannels` and
162  * `CollectionOddPostChannels`. They are all `0` by default.
163  *
164  *
165  */
167 
168  // import definitions
171 
172  public:
173 
174  struct Config {
175 
176  using Name = fhicl::Name;
177  using Comment = fhicl::Comment;
178 
180 
181  fhicl::Atom<unsigned int> FirstInductionPreChannels {
182  Name("FirstInductionPreChannels"),
183  Comment
184  ("number of wireless channels before the first regular channel in first induction plane"),
185  0U
186  };
187 
188  fhicl::Atom<unsigned int> FirstInductionPostChannels {
189  Name("FirstInductionPostChannels"),
190  Comment
191  ("number of wireless channels after the last regular channel in first induction plane"),
192  0U
193  };
194 
195  fhicl::Atom<unsigned int> SecondInductionEvenPreChannels {
196  Name("SecondInductionEvenPreChannels"),
197  Comment
198  ("number of wireless/ghost/virtual channels before the first regular channel in second induction planes in even TPC sets"),
199  0U
200  };
201 
202  fhicl::Atom<unsigned int> SecondInductionEvenPostChannels {
203  Name("SecondInductionEvenPostChannels"),
204  Comment
205  ("number of wireless/ghost/virtual channels after the last regular channel in second induction plane in even TPC sets"),
206  0U
207  };
208 
209  fhicl::Atom<unsigned int> SecondInductionOddPreChannels {
210  Name("SecondInductionOddPreChannels"),
211  Comment
212  ("number of wireless/ghost/virtual channels before the first regular channel in second induction plane in odd TPC sets"),
213  0U
214  };
215 
216  fhicl::Atom<unsigned int> SecondInductionOddPostChannels {
217  Name("SecondInductionOddPostChannels"),
218  Comment
219  ("number of wireless/ghost/virtual channels after the last regular channel in second induction plane in odd TPC sets"),
220  0U
221  };
222 
223  fhicl::Atom<unsigned int> CollectionEvenPreChannels {
224  Name("CollectionEvenPreChannels"),
225  Comment
226  ("number of wireless/ghost/virtual channels before the first regular channel in collection plane in even TPC sets"),
227  0U
228  };
229 
230  fhicl::Atom<unsigned int> CollectionEvenPostChannels {
231  Name("CollectionEvenPostChannels"),
232  Comment
233  ("number of wireless/ghost/virtual channels after the last regular channel in collection plane in even TPC sets"),
234  0U
235  };
236 
237  fhicl::Atom<unsigned int> CollectionOddPreChannels {
238  Name("CollectionOddPreChannels"),
239  Comment
240  ("number of wireless/ghost/virtual channels before the first regular channel in collection plane in odd TPC sets"),
241  0U
242  };
243 
244  fhicl::Atom<unsigned int> CollectionOddPostChannels {
245  Name("CollectionOddPostChannels"),
246  Comment
247  ("number of wireless/ghost/virtual channels after the last regular channel in collection plane in odd TPC sets"),
248  0U
249  };
250 
251  }; // WirelessChannelStruct
252 
253 
254  fhicl::OptionalDelegatedParameter Sorter {
255  Name("Sorter"),
256  Comment("configuration of the geometry object sorter")
257  };
258 
259  fhicl::Table<WirelessChannelStruct> WirelessChannels {
260  Name("WirelessChannels"),
261  Comment("configuration of channels with no connected wire")
262  };
263 
264  }; // struct Config
265 
266  /// Type of FHiCL configuration table for this object.
267  using Parameters = fhicl::Table<Config>;
268 
269  /// Constructor: taked a configuration object.
270  ICARUSChannelMapAlg(Config const& config);
271 
272  /// Constructor: takes a FHiCL table object.
274  : ICARUSChannelMapAlg(config()) {}
275 
276 
277  /// Prepares the algorithm extracting information from the geometry.
278  virtual void Initialize(geo::GeometryData_t const& geodata) override;
279 
280 
281  /// Frees the resources of this algorithm.
282  virtual void Uninitialize() override;
283 
284 
285  // --- BEGIN -- Channel mapping ----------------------------------------------
286  /// @name Channel mapping
287  /// @{
288  /**
289  * @brief Returns a collection of ID of wires connected to the `channel`.
290  * @param channel TPC readout channel number
291  * @return collection of the wire IDs associated with `channel`
292  * @throws cet::exception (category: "Geometry") if non-existent channel
293  *
294  * If the TPC readout `channel` is invalid or non-existing, an exception is
295  * thrown.
296  * In ICARUS valid channels are expected to be associated with at least one
297  * wire.
298  */
299  virtual std::vector<geo::WireID> ChannelToWire(raw::ChannelID_t channel) const
300  override;
301 
302  /// Returns the number of readout channels (ID's go `0` to `Nchannels()`).
303  virtual unsigned int Nchannels() const override;
304 
305  /// @brief Returns the number of channels in the specified ROP
306  /// @return number of channels in the specified ROP, 0 if non-existent
307  virtual unsigned int Nchannels(readout::ROPID const& ropid) const override;
308 
309  //@{
311  (geo::WireID const& wireID) const override;
312  virtual raw::ChannelID_t PlaneWireToChannel(unsigned int plane,
313  unsigned int wire,
314  unsigned int tpc,
315  unsigned int cstat) const override
316  { return PlaneWireToChannel(geo::WireID(cstat, tpc, plane, wire)); }
317  //@}
318 
319  /// @}
320  // --- END -- Channel mapping ------------------------------------------------
321 
322 
323  /**
324  * @name Deprecated functions.
325  *
326  * These methods are legacy and might be replaced by `geo::GeometryCore`
327  * calls.
328  */
329  /// @{
330  //@{
331  virtual double WireCoordinate
332  (double YPos, double ZPos, geo::PlaneID const& planeID) const override;
333  virtual double WireCoordinate(double YPos, double ZPos,
334  unsigned int PlaneNo,
335  unsigned int TPCNo,
336  unsigned int cstat) const override
337  { return WireCoordinate(YPos, ZPos, geo::PlaneID(cstat, TPCNo, PlaneNo)); }
338  //@}
339 
340  //@{
341  virtual geo::WireID NearestWireID
342  (const TVector3& worldPos, geo::PlaneID const& planeID) const override;
343  virtual geo::WireID NearestWireID(const TVector3& worldPos,
344  unsigned int PlaneNo,
345  unsigned int TPCNo,
346  unsigned int cstat) const override
347  { return NearestWireID(worldPos, geo::PlaneID(cstat, TPCNo, PlaneNo)); }
348  //@}
349 
350  virtual std::set<geo::PlaneID> const& PlaneIDs() const override;
351 
352  /// @}
353 
354 
355  //
356  // TPC set interface
357  //
358  /// @name TPC set mapping
359  /// @{
360  /**
361  * @brief Returns the total number of TPC sets in the specified cryostat.
362  * @param cryoid cryostat ID
363  * @return number of TPC sets in the cryostat, or 0 if no cryostat found
364  */
365  virtual unsigned int NTPCsets
366  (readout::CryostatID const& cryoid) const override;
367 
368  /// Returns the largest number of TPC sets any cryostat in the detector has.
369  virtual unsigned int MaxTPCsets() const override;
370 
371  /// Returns whether we have the specified TPC set.
372  /// @return whether the TPC set is valid and exists
373  virtual bool HasTPCset(readout::TPCsetID const& tpcsetid) const override;
374 
375  /**
376  * @brief Returns the ID of the TPC set the specified TPC belongs to
377  * @param tpcid ID of the TPC
378  * @return the ID of the corresponding TPC set, or invalid ID when tpcid is
379  *
380  * If the TPC ID is not valid, an invalid TPC set ID is returned.
381  * Note that this check is performed on the validity of the TPC ID, that
382  * does not necessarily imply that the TPC specified by the ID actually
383  * exists.
384  */
386  (geo::TPCID const& tpcid) const override;
387 
388  /**
389  * @brief Returns a list of ID of TPCs belonging to the specified TPC set
390  * @param tpcsetid ID of the TPC set to convert into TPC IDs
391  * @return the list of TPCs, empty if TPC set is invalid
392  *
393  * Each TPC set contains one TPC if on first induction plane, where wires are
394  * split, or two in the second induction and collection planes, which have
395  * shared channels.
396  */
397  virtual std::vector<geo::TPCID> TPCsetToTPCs
398  (readout::TPCsetID const& tpcsetid) const override;
399 
400  /// Returns the ID of the first TPC belonging to the specified TPC set
402  (readout::TPCsetID const& tpcsetid) const override;
403 
404  /// @} TPC set mapping
405 
406 
407 
408  // --- BEGIN -- Readout plane interface --------------------------------------
409  /// @name Readout plane mapping
410  /// @{
411 
412  /**
413  * @brief Returns the total number of readout planes in the specified TPC set.
414  * @param tpcsetid TPC set ID
415  * @return number of readout planes in the TPC sets, or `0` if ID is invalid
416  *
417  * The validity of the requested TPC set is performed like in `HasTPCset()`.
418  */
419  virtual unsigned int NROPs
420  (readout::TPCsetID const& tpcsetid) const override;
421 
422  /// Returns the largest number of ROPs a TPC set in the detector has.
423  virtual unsigned int MaxROPs() const override;
424 
425  /// Returns whether we have the specified ROP
426  /// @return whether the readout plane is valid and exists
427  virtual bool HasROP(readout::ROPID const& ropid) const override;
428 
429  /**
430  * @brief Returns the ID of the ROP planeid belongs to, or invalid if none.
431  * @param planeid ID of the plane
432  * @return the ID of the corresponding ROP, or invalid ID when `planeid` is
433  *
434  * If the plane ID is not valid, an invalid readout plane ID is returned.
435  * Note that this check is performed on the validity of the plane ID, that
436  * does not necessarily imply that the plane specified by the ID actually
437  * exists.
438  */
440  (geo::PlaneID const& planeid) const override;
441 
442  /**
443  * @brief Returns a list of ID of wire planes belonging to the specified ROP.
444  * @param ropid ID of the readout plane to convert into wire planes
445  * @return the list of wire plane IDs, empty if readout plane ID is invalid
446  *
447  * Note that this check is performed on the validity of the readout plane
448  * ID, that does not necessarily imply that the readout plane specified by
449  * the ID actually exists.
450  *
451  * In this mapping, readout planes contain one or two wire planes each,
452  * depending on the view.
453  */
454  virtual std::vector<geo::PlaneID> ROPtoWirePlanes
455  (readout::ROPID const& ropid) const override;
456 
457  /**
458  * @brief Returns a list of ID of TPCs the specified ROP spans
459  * @param ropid ID of the readout plane
460  * @return the list of TPC IDs, empty if readout plane ID is invalid
461  *
462  * In this mapping, readout planes and wire planes are mapped one-to-one.
463  * The returned list contains always one entry, unless the specified readout
464  * plane ID is invalid, in which case the list is empty.
465  * Note that this check is performed on the validity of the readout plane
466  * ID, that does not necessarily imply that the readout plane specified by
467  * the ID actually exists. Check if the ROP exists with HasROP().
468  * The behaviour on non-existing readout planes is undefined.
469  */
470  virtual std::vector<geo::TPCID> ROPtoTPCs
471  (readout::ROPID const& ropid) const override;
472 
473  /// Returns the ID of the ROP the channel belongs to (invalid if none).
475  (raw::ChannelID_t channel) const override;
476 
477  /**
478  * @brief Returns the ID of the first channel in the specified readout plane.
479  * @param ropid ID of the readout plane
480  * @return ID of first channel, or raw::InvalidChannelID if ID is invalid
481  *
482  * Note that this check is performed on the validity of the readout plane
483  * ID, that does not necessarily imply that the readout plane specified by
484  * the ID actually exists. Check if the ROP exists with HasROP().
485  * The behaviour for non-existing readout planes is undefined.
486  */
488  (readout::ROPID const& ropid) const override;
489 
490  /**
491  * @brief Returns the ID of the first plane belonging to the specified ROP.
492  *
493  * The wire planes within a readout plane are supposed to be sorted by beam
494  * (_z_) coordinate, so that the first one should be the closest to the
495  * beam entrance point.
496  */
498  (readout::ROPID const& ropid) const override;
499 
500  /// @}
501  // --- END -- Readout plane interface ----------------------------------------
502 
503 
504  /// Return the sorter.
505  virtual geo::GeoObjectSorter const& Sorter() const override
506  { return fSorter; }
507 
508  private:
509 
510  /// Type for counts of wireless channels: per TPC set (even/odd), then per
511  /// plane starting from the closest to the cathode; `first` is the number of
512  /// wireless channels before the regular ones, `second` is the one after them.
514  = std::array<std::array<std::pair<unsigned int, unsigned int>, 3U>, 2U>;
515 
516 
517 
518  // --- BEGIN -- Readout element information ----------------------------------
519  /**
520  * @name Readout element information
521  *
522  * The geometry and readout data containers have currently no support for
523  * resizing and their size is assigned on construction.
524  *
525  * Access should happen via the corresponding member functions.
526  *
527  */
528  /// @{
529 
531 
532  /// Collected information about TPC sets and readout planes in the geometry.
534  /// Number of TPC sets in each cryostat.
535  std::vector<unsigned int> fTPCsetCount;
536 
537  /// All `geo::TPCGeo` objects in each TPC set, sorted by increasing _z_.
539 
540  /// Number of readout planes in each TPC set.
542 
543  /// All `geo::PlaneGeo` objects in each readout plane, sorted by _z_.
545 
546  /// The TPC set each TPC belongs to.
548 
549  /// The ROP each wire plane belongs to.
551 
552  ReadoutMappingInfo_t() = default;
553 
554  void set(
555  std::vector<unsigned int>&& TPCsetCount,
561  )
562  {
563  fTPCsetCount = std::move(TPCsetCount);
564  fTPCsetTPCs = std::move(TPCsetTPCs );
565  fROPcount = std::move(ROPcount );
566  fROPplanes = std::move(ROPplanes );
567  fTPCtoTPCset = std::move(TPCtoTPCset);
568  fPlaneToROP = std::move(PlaneToROP );
569  assert(fTPCsetCount.size() == fTPCsetTPCs.dimSize<0U>());
570  assert(fTPCsetCount.size() == fROPcount.dimSize<0U>());
571  assert(fTPCsetCount.size() == fROPplanes.dimSize<0U>());
572  assert(fTPCsetCount.size() == fTPCtoTPCset.dimSize<0U>());
573  assert(fTPCsetCount.size() == fPlaneToROP.dimSize<0U>());
574  assert(fTPCsetTPCs.dimSize<1U>() == fROPcount.dimSize<1U>());
575  assert(fTPCsetTPCs.dimSize<1U>() == fROPplanes.dimSize<1U>());
576  assert(fTPCtoTPCset.dimSize<1U>() == fPlaneToROP.dimSize<1U>());
577  } // set()
578 
579  unsigned int NCryostats() const
580  { return fROPplanes.dimSize<0U>(); }
581  unsigned int MaxTPCsets() const { return fROPplanes.dimSize<1U>(); }
582  unsigned int MaxROPs() const { return fROPplanes.dimSize<2U>(); }
583 
584  /// Frees the memory and leaves the object unusable until next `set()`.
585  void clear()
586  {
587  fTPCsetCount.clear(); fTPCsetTPCs.clear();
590  }
591 
592  /// Returns whether all the data containers are initialized.
593  operator bool() const
594  {
595  return !fTPCsetCount.empty() && !fTPCsetTPCs.empty()
596  && !fROPcount.empty() && !fROPplanes.empty()
597  && !fTPCtoTPCset.empty() && !fPlaneToROP.empty();
598  }
599 
600  }; // ReadoutMappingInfo_t
601 
602  /// Collection of information on one plane.
603  struct PlaneInfo_t {
604 
605  ChannelRange_t fChannelRange; ///< Range of channels covered by the plane.
606  readout::ROPID fROPID; ///< Which readout plane this wire plane belongs to.
607 
608  /// Returns the range of channels covered by the wire plane.
609  constexpr ChannelRange_t const& channelRange() const
610  { return fChannelRange; }
611 
612  /// Returns the ID of the last channel in the range.
613  constexpr raw::ChannelID_t firstChannel() const
614  { return fChannelRange.begin(); }
615 
616  /// Returns the ID of the last channel in the range.
617  constexpr raw::ChannelID_t lastChannel() const
618  { return fChannelRange.end() - 1; }
619 
620  /// Returns the ID of the channel after the last in the range.
621  constexpr raw::ChannelID_t endChannel() const
622  { return fChannelRange.end(); }
623 
624  /// Returns the ID of the readout plane this wire plane belongs to.
625  constexpr readout::ROPID ROP() const { return fROPID; }
626 
627  }; // struct PlaneInfo_t
628 
629 
630  /// Information about TPC sets and readout planes in the geometry.
632 
633  /// Mapping of channels to wire planes and ROP's.
635 
636  /// Range of channels covered by each of the wire planes.
638 
639 
640  /// @}
641  // --- END -- Readout element information ------------------------------------
642 
643  // --- BEGIN -- Configuration parameters -------------------------------------
644 
645  /// Count of wireless channels on each plane.
647 
648  // --- END -- Configuration parameters ---------------------------------------
649 
650  // --- BEGIN -- Sorting ------------------------------------------------------
651  /// Algorithms to sort geometry elements.
652 // geo::GeoObjectSorterStandard fSorter;
654 
655  // --- END -- Sorting --------------------------------------------------------
656 
657 
658  using PlaneType_t = std::size_t; ///< Type for plane type identifier.
659 
660  /// Identifier for first induction plane type.
661  static constexpr PlaneType_t kFirstInductionType = 0U;
662  /// Identifier for second induction plane type.
663  static constexpr PlaneType_t kSecondInductionType = 1U;
664  /// Identifier for collection plane type.
665  static constexpr PlaneType_t kCollectionType = 2U;
666  /// Identifier for unknown plane type.
667  static constexpr PlaneType_t kUnknownType
668  = std::numeric_limits<PlaneType_t>::max();
669 
670 
671  // --- BEGIN -- Readout element information access ---------------------------
672  /// @name Readout element information access
673  /// @{
674 
675  /// Returns the number of TPC sets in each cryostat.
676  std::vector<unsigned int> const& TPCsetCount() const
677  { assert(fReadoutMapInfo); return fReadoutMapInfo.fTPCsetCount; }
678 
679  /// Returns the number of TPC sets in the specified cryostat `cid`.
680  unsigned int TPCsetCount(readout::CryostatID const& cid) const
681  { return TPCsetCount()[cid.Cryostat]; }
682 
683  /// All `geo::TPCGeo` objects in each TPC set, sorted by increasing _z_.
685  { assert(fReadoutMapInfo); return fReadoutMapInfo.fTPCsetTPCs; }
686 
687  /// All `geo::TPCGeo` objects in the specified TPC set `sid`.
688  TPCColl_t const& TPCsetTPCs(readout::TPCsetID const& sid) const
689  { return TPCsetTPCs()[sid]; }
690 
691  /// Number of readout planes in each TPC set.
693  { assert(fReadoutMapInfo); return fReadoutMapInfo.fROPcount; }
694 
695  /// Number of readout planes in the specified TPC set `sid`.
696  unsigned int ROPcount(readout::TPCsetID const& sid) const
697  { return ROPcount()[sid]; }
698 
699  /// All `geo::PlaneGeo` objects in each readout plane, sorted by _z_.
701  { assert(fReadoutMapInfo); return fReadoutMapInfo.fROPplanes; }
702 
703  /// All `geo::PlaneGeo` objects in the specified readout plane `rid`.
704  PlaneColl_t const& ROPplanes(readout::ROPID const& rid) const
705  { return ROPplanes()[rid]; }
706 
707  /// The TPC set including each TPC.
709  { assert(fReadoutMapInfo); return fReadoutMapInfo.fTPCtoTPCset; }
710 
711  /* // something similar to this already belongs to the interface
712  /// The TPC set the specified TPC `tid` belongs to.
713  readout::TPCsetID const& TPCtoTPCset(geo::TPCID const& tid) const
714  { return TPCtoTPCset()[tid]; }
715  */
716 
717  /// The readout plane including each wire plane.
719  { assert(fReadoutMapInfo); return fReadoutMapInfo.fPlaneToROP; }
720 
721  /// The readout plane the specified wire plane `pid` belongs to.
722  readout::ROPID const& PlaneToROP(geo::PlaneID const& pid) const
723  { return PlaneToROP()[pid]; }
724 
725  /// @}
726  // --- END -- Readout element information access -----------------------------
727 
728 
729  /// Returns whether the specified cryostat is known to the mapping.
730  bool HasCryostat(readout::CryostatID const& cryoid) const;
731 
732 
733  /**
734  * @brief Fills the information about readout channel mapping.
735  * @param Cryostats the sorted list of cryostats in the detector
736  *
737  *
738  *
739  * The readout information must have been already filled
740  * (`buildReadoutPlanes()`).
741  *
742  */
744  (geo::GeometryData_t::CryostatList_t const& Cryostats);
745 
746 
747  /**
748  * @brief Fills information about the TPC set and readout plane structure.
749  * @param Cryostats the sorted list of cryostats in the detector
750  *
751  * This method extracts and fills the following information:
752  * * the number of TPC sets in each cryostat (`fTPCsetCount`);
753  * * all `geo::TPCGeo` objects in each TPC set, sorted by increasing _z_
754  * (`fTPCsetTPCs`);
755  * * the number of readout planes in each TPC set (`fROPcount`);
756  * * all `geo::PlaneGeo` objects in each readout plane, sorted by increasing
757  * _z_ (`fROPplanes`).
758  *
759  * Cryostats and its components are expected to be already in the final order
760  * and with all their ID's set.
761  *
762  */
764 
765 
766  /**
767  * @brief Returns the "type" of readout plane.
768  * @param ropid ID of the readout plane to query
769  *
770  * Here the "type" refers to the position of the plane in the TPC and as a
771  * consequence to its signal type.
772  * The type of the readout plane is deduced from the type of the planes it
773  * contains.
774  *
775  * The returned value is `kFirstInductionType`, `kSecondInductionType`,
776  * `kCollectionType` or `kUnknownType`.
777  */
778  PlaneType_t findPlaneType(readout::ROPID const& ropid) const;
779 
780 
781  /// Returns the type of signal on the specified `channel`.
783  (raw::ChannelID_t const channel) const override;
784 
785 
787  (Config::WirelessChannelStruct const& params);
788 
789 
790  /// Returns the name of the specified plane type.
791  static std::string PlaneTypeName(PlaneType_t planeType);
792 
793 
794 
795 }; // class icarus::ICARUSChannelMapAlg
796 
797 
798 #endif // ICARUSCODE_GEOMETRY_ICARUSCHANNELMAPALG_H
799 
virtual std::set< geo::PlaneID > const & PlaneIDs() const override
Returns a list of the plane IDs in the whole detector.
PlaneType_t findPlaneType(readout::ROPID const &ropid) const
Returns the &quot;type&quot; of readout plane.
virtual std::vector< geo::TPCID > ROPtoTPCs(readout::ROPID const &ropid) const override
Returns a list of ID of TPCs the specified ROP spans.
Interface for a class providing readout channel mapping to geometry.
Definition: ChannelMapAlg.h:48
Geometry object sorter with PMT following TPC wire order.
ICARUSChannelMapAlg(Config const &config)
Constructor: taked a configuration object.
virtual geo::SigType_t SignalTypeForChannelImpl(raw::ChannelID_t const channel) const override
Returns the type of signal on the specified channel.
constexpr raw::ChannelID_t end() const
Returns the ID of the channel after the last one in the range.
virtual void Initialize(geo::GeometryData_t const &geodata) override
Prepares the algorithm extracting information from the geometry.
virtual std::vector< geo::TPCID > TPCsetToTPCs(readout::TPCsetID const &tpcsetid) const override
Returns a list of ID of TPCs belonging to the specified TPC set.
ChannelRange_t fChannelRange
Range of channels covered by the plane.
Classes identifying readout-related concepts.
constexpr readout::ROPID ROP() const
Returns the ID of the readout plane this wire plane belongs to.
void buildReadoutPlanes(geo::GeometryData_t::CryostatList_t const &Cryostats)
Fills information about the TPC set and readout plane structure.
virtual double WireCoordinate(double YPos, double ZPos, unsigned int PlaneNo, unsigned int TPCNo, unsigned int cstat) const override
Returns the index of the wire nearest to the specified position.
geo::TPCDataContainer< readout::TPCsetID > const & TPCtoTPCset() const
The TPC set including each TPC.
std::size_t PlaneType_t
Type for plane type identifier.
virtual geo::PlaneID FirstWirePlaneInROP(readout::ROPID const &ropid) const override
Returns the ID of the first plane belonging to the specified ROP.
std::array< std::array< std::pair< unsigned int, unsigned int >, 3U >, 2U > WirelessChannelCounts_t
geo::PlaneDataContainer< PlaneInfo_t > fPlaneInfo
Range of channels covered by each of the wire planes.
virtual double WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeID) const override
Returns the index of the wire nearest to the specified position.
virtual readout::ROPID WirePlaneToROP(geo::PlaneID const &planeid) const override
Returns the ID of the ROP planeid belongs to, or invalid if none.
Simple data structure holding the data of the geometry.
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Channel-to-wire mapping data structure.
fhicl::OptionalDelegatedParameter Sorter
virtual std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t channel) const override
Returns a collection of ID of wires connected to the channel.
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
virtual raw::ChannelID_t PlaneWireToChannel(unsigned int plane, unsigned int wire, unsigned int tpc, unsigned int cstat) const override
Returns the channel ID a wire is connected to.
std::vector< geo::CryostatGeo > CryostatList_t
Type of list of cryostats.
Definition: GeometryData.h:34
readout::TPCsetDataContainer< TPCColl_t > fTPCsetTPCs
All geo::TPCGeo objects in each TPC set, sorted by increasing z.
virtual unsigned int NTPCsets(readout::CryostatID const &cryoid) const override
Returns the total number of TPC sets in the specified cryostat.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
static constexpr bool
virtual raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const override
Returns the ID of the first channel in the specified readout plane.
static constexpr PlaneType_t kFirstInductionType
Identifier for first induction plane type.
constexpr raw::ChannelID_t begin() const
Returns the ID of the first channel in the range.
readout::TPCsetDataContainer< unsigned int > fROPcount
Number of readout planes in each TPC set.
virtual bool HasTPCset(readout::TPCsetID const &tpcsetid) const override
PlaneColl_t const & ROPplanes(readout::ROPID const &rid) const
All geo::PlaneGeo objects in the specified readout plane rid.
icarus::GeoObjectSorterPMTasTPC fSorter
Algorithms to sort geometry elements.
virtual unsigned int MaxTPCsets() const override
Returns the largest number of TPC sets any cryostat in the detector has.
virtual bool HasROP(readout::ROPID const &ropid) const override
virtual geo::WireID NearestWireID(const TVector3 &worldPos, geo::PlaneID const &planeID) const override
Returns the ID of the wire nearest to the specified position.
unsigned int TPCsetCount(readout::CryostatID const &cid) const
Returns the number of TPC sets in the specified cryostat cid.
static WirelessChannelCounts_t extractWirelessChannelParams(Config::WirelessChannelStruct const &params)
A few simple data type definitions.
static constexpr PlaneType_t kSecondInductionType
Identifier for second induction plane type.
Containers to hold one datum per TPC or plane.
virtual unsigned int MaxROPs() const override
Returns the largest number of ROPs a TPC set in the detector has.
Mapping of ROP channels into wires.
geo::TPCDataContainer< readout::TPCsetID > fTPCtoTPCset
The TPC set each TPC belongs to.
static constexpr PlaneType_t kCollectionType
Identifier for collection plane type.
geo::PlaneDataContainer< readout::ROPID > const & PlaneToROP() const
The readout plane including each wire plane.
bool HasCryostat(readout::CryostatID const &cryoid) const
Returns whether the specified cryostat is known to the mapping.
void clear()
Frees the memory and leaves the object unusable until next set().
enum geo::_plane_sigtype SigType_t
virtual unsigned int NROPs(readout::TPCsetID const &tpcsetid) const override
Returns the total number of readout planes in the specified TPC set.
Collection of information on one plane.
ReadoutMappingInfo_t fReadoutMapInfo
Information about TPC sets and readout planes in the geometry.
readout::ROPID fROPID
Which readout plane this wire plane belongs to.
Collected information about TPC sets and readout planes in the geometry.
BEGIN_PROLOG vertical distance to the surface Name
TPCColl_t const & TPCsetTPCs(readout::TPCsetID const &sid) const
All geo::TPCGeo objects in the specified TPC set sid.
std::vector< geo::PlaneGeo const * > PlaneColl_t
Type of collection of planes (pointers to geo::PlaneGeo).
void set(std::vector< unsigned int > &&TPCsetCount, readout::TPCsetDataContainer< TPCColl_t > &&TPCsetTPCs, readout::TPCsetDataContainer< unsigned int > &&ROPcount, readout::ROPDataContainer< PlaneColl_t > &&ROPplanes, geo::TPCDataContainer< readout::TPCsetID > &&TPCtoTPCset, geo::PlaneDataContainer< readout::ROPID > &&PlaneToROP)
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
fhicl::Table< Config > Parameters
Type of FHiCL configuration table for this object.
Definition of data types for geometry description.
virtual geo::WireID NearestWireID(const TVector3 &worldPos, unsigned int PlaneNo, unsigned int TPCNo, unsigned int cstat) const override
Returns the ID of the wire nearest to the specified position.
Class identifying a set of planes sharing readout channels.
virtual raw::ChannelID_t PlaneWireToChannel(geo::WireID const &wireID) const override
Returns the channel ID a wire is connected to.
virtual geo::TPCID FirstTPCinTPCset(readout::TPCsetID const &tpcsetid) const override
Returns the ID of the first TPC belonging to the specified TPC set.
readout::TPCsetDataContainer< unsigned int > const & ROPcount() const
Number of readout planes in each TPC set.
WirelessChannelCounts_t const fWirelessChannelCounts
Count of wireless channels on each plane.
virtual std::vector< geo::PlaneID > ROPtoWirePlanes(readout::ROPID const &ropid) const override
Returns a list of ID of wire planes belonging to the specified ROP.
constexpr raw::ChannelID_t lastChannel() const
Returns the ID of the last channel in the range.
void clear()
Makes the container empty, with no usable storage space.
icarus::details::TPCColl_t TPCColl_t
constexpr raw::ChannelID_t endChannel() const
Returns the ID of the channel after the last in the range.
ICARUSChannelMapAlg(Parameters const &config)
Constructor: takes a FHiCL table object.
geo::PlaneDataContainer< readout::ROPID > fPlaneToROP
The ROP each wire plane belongs to.
unsigned int ROPcount(readout::TPCsetID const &sid) const
Number of readout planes in the specified TPC set sid.
void fillChannelToWireMap(geo::GeometryData_t::CryostatList_t const &Cryostats)
Fills the information about readout channel mapping.
constexpr raw::ChannelID_t firstChannel() const
Returns the ID of the last channel in the range.
readout::ROPDataContainer< PlaneColl_t > fROPplanes
All geo::PlaneGeo objects in each readout plane, sorted by z.
virtual geo::GeoObjectSorter const & Sorter() const override
Return the sorter.
Channel mapping for ICARUS detector with split wires.
std::vector< unsigned int > fTPCsetCount
Number of TPC sets in each cryostat.
bool empty() const
Returns whether the container has no elements (false by assumptions).
Interface to algorithm class for a specific detector channel mapping.
Data in the geometry description.
Definition: GeometryData.h:31
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
readout::ROPDataContainer< PlaneColl_t > const & ROPplanes() const
All geo::PlaneGeo objects in each readout plane, sorted by z.
std::vector< geo::TPCGeo const * > TPCColl_t
Type of collection of TPCs (pointers to geo::TPCGeo).
Containers to hold one datum per TPC set or readout plane.
icarus::details::PlaneColl_t PlaneColl_t
unsigned int dimSize() const
Dimensions of the Level dimension of this container.
icarus::details::ChannelToWireMap fChannelToWireMap
Mapping of channels to wire planes and ROP&#39;s.
fhicl::Table< WirelessChannelStruct > WirelessChannels
readout::TPCsetDataContainer< TPCColl_t > const & TPCsetTPCs() const
All geo::TPCGeo objects in each TPC set, sorted by increasing z.
virtual readout::ROPID ChannelToROP(raw::ChannelID_t channel) const override
Returns the ID of the ROP the channel belongs to (invalid if none).
virtual unsigned int Nchannels() const override
Returns the number of readout channels (ID&#39;s go 0 to Nchannels()).
constexpr ChannelRange_t const & channelRange() const
Returns the range of channels covered by the wire plane.
static std::string PlaneTypeName(PlaneType_t planeType)
Returns the name of the specified plane type.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
virtual void Uninitialize() override
Frees the resources of this algorithm.
readout::ROPID const & PlaneToROP(geo::PlaneID const &pid) const
The readout plane the specified wire plane pid belongs to.
Geometry sorter having PMT channels follow the same order as TPC.
std::vector< unsigned int > const & TPCsetCount() const
Returns the number of TPC sets in each cryostat.
static constexpr PlaneType_t kUnknownType
Identifier for unknown plane type.