LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
extractMaxGeometryElements.h
Go to the documentation of this file.
1 
8 #ifndef LARCOREALG_GEOMETRY_DETAILS_EXTRACTMAXGEOMETRYELEMENTS_H
9 #define LARCOREALG_GEOMETRY_DETAILS_EXTRACTMAXGEOMETRYELEMENTS_H
10 
11 // LArSoft libraries
16 
17 // C/C++ standard libraries
18 #include <array>
19 #include <cstddef> // std::size_t
20 #include <vector>
21 
22 namespace geo::details {
23 
41  template <std::size_t Levels = 4U>
42  static std::array<unsigned int, Levels> extractMaxGeometryElements(
43  std::vector<CryostatGeo> const& Cryostats,
44  WireReadoutGeom const& wireReadoutGeom);
45 
46 } // namespace geo::details
47 
48 // -----------------------------------------------------------------------------
49 // --- template implementation
50 // -----------------------------------------------------------------------------
51 template <std::size_t Levels /* = 4U */>
52 std::array<unsigned int, Levels> geo::details::extractMaxGeometryElements(
53  std::vector<CryostatGeo> const& Cryostats,
54  WireReadoutGeom const& wireReadoutGeom)
55 {
56  static_assert(Levels > 0U);
57  static_assert(Levels <= 4U);
58 
59  std::array<unsigned int, Levels> maxElements;
60  maxElements.fill(0U);
61 
62  auto setMax = [&maxElements](std::size_t index, unsigned int value) {
63  if (maxElements[index] < value) maxElements[index] = value;
64  };
65 
66  setMax(0U, Cryostats.size());
67  if constexpr (Levels > 1U) {
68  for (CryostatGeo const& cryo : Cryostats) {
69  setMax(1U, cryo.NTPC());
70  if constexpr (Levels > 2U) {
71  for (TPCGeo const& TPC : cryo.IterateTPCs()) {
72  setMax(2U, wireReadoutGeom.Nplanes(TPC.ID()));
73  if constexpr (Levels > 3U) {
74  for (PlaneGeo const& plane : wireReadoutGeom.Iterate<PlaneGeo>(TPC.ID())) {
75  setMax(3U, plane.Nwires());
76  } // for planes
77  } // if do wires
78  } // for TPCs
79  } // if do planes
80  } // for cryostats
81  } // if do TPCs
82 
83  return maxElements;
84 } // geo::details::extractMaxGeometryElements()
85 
86 // -----------------------------------------------------------------------------
87 
88 #endif // LARCOREALG_GEOMETRY_DETAILS_EXTRACTMAXGEOMETRYELEMENTS_H
Encapsulate the construction of a single cyostat .
static std::array< unsigned int, Levels > extractMaxGeometryElements(std::vector< CryostatGeo > const &Cryostats, WireReadoutGeom const &wireReadoutGeom)
Extracts the maximum number of elements per type.
double value
Definition: spectrum.C:18
Encapsulate the construction of a single detector plane .
Interface to geometry for wire readouts .
Encapsulate the construction of a single detector plane .