LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
extractMaxGeometryElements.h
Go to the documentation of this file.
1 
10 #ifndef LARCOREALG_GEOMETRY_DETAILS_EXTRACTMAXGEOMETRYELEMENTS_H
11 #define LARCOREALG_GEOMETRY_DETAILS_EXTRACTMAXGEOMETRYELEMENTS_H
12 
13 // LArSoft libraries
18 
19 // C/C++ standard libraries
20 #include <array>
21 #include <cstddef> // std::size_t
22 
23 namespace geo::details {
24 
42  template <std::size_t Levels = 4U>
43  static std::array<unsigned int, Levels> extractMaxGeometryElements(
44  geo::GeometryData_t::CryostatList_t const& Cryostats);
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  geo::GeometryData_t::CryostatList_t const& Cryostats)
54 {
55  static_assert(Levels > 0U);
56  static_assert(Levels <= 4U);
57 
58  std::array<unsigned int, Levels> maxElements;
59  maxElements.fill(0U);
60 
61  auto setMax = [&maxElements](std::size_t index, unsigned int value) {
62  if (maxElements[index] < value) maxElements[index] = value;
63  };
64 
65  setMax(0U, Cryostats.size());
66  if constexpr (Levels > 1U) {
67  for (geo::CryostatGeo const& cryo : Cryostats) {
68  setMax(1U, cryo.NTPC());
69  if constexpr (Levels > 2U) {
70  for (geo::TPCGeo const& TPC : cryo.IterateTPCs()) {
71  setMax(2U, TPC.Nplanes());
72  if constexpr (Levels > 3U) {
73  for (geo::PlaneGeo const& plane : TPC.IteratePlanes()) {
74  setMax(3U, plane.Nwires());
75  } // for planes
76  } // if do wires
77  } // for TPCs
78  } // if do planes
79  } // for cryostats
80  } // if do TPCs
81 
82  return maxElements;
83 } // geo::details::extractMaxGeometryElements()
84 
85 // -----------------------------------------------------------------------------
86 
87 #endif // LARCOREALG_GEOMETRY_DETAILS_EXTRACTMAXGEOMETRYELEMENTS_H
Encapsulate the construction of a single cyostat.
Simple data structure holding the data of the geometry.
Geometry information for a single TPC.
Definition: TPCGeo.h:36
static std::array< unsigned int, Levels > extractMaxGeometryElements(geo::GeometryData_t::CryostatList_t const &Cryostats)
Extracts the maximum number of elements per type.
std::vector< geo::CryostatGeo > CryostatList_t
Type of list of cryostats.
Definition: GeometryData.h:33
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:78
double value
Definition: spectrum.C:18
Encapsulate the construction of a single detector plane.
Encapsulate the construction of a single detector plane.