10 #define BOOST_TEST_MODULE (geo ID mapper test) 11 #include <boost/test/unit_test.hpp> 22 std::size_t
const NCryostats, std::size_t
const NTPCs
27 std::size_t
const N = NCryostats * NTPCs;
30 BOOST_TEST(mapper.
dimSize<0U>() == NCryostats);
31 BOOST_TEST(mapper.
dimSize<1U>() == NTPCs);
32 BOOST_TEST(mapper.
dimSize<2U>() == 0U);
33 BOOST_TEST(mapper.
dimSize<3U>() == 0U);
35 BOOST_TEST(!mapper.
empty());
36 BOOST_TEST(mapper.
size() ==
N);
38 auto expected_index = Mapper_t::index_type{ 0 };
39 for (
auto c: util::counter<unsigned int>(NCryostats)) {
40 for (
auto t: util::counter<unsigned int>(NTPCs)) {
43 auto const&
ID = mapper.
ID(expected_index);
45 BOOST_TEST(mapper.
index(expected_ID) == expected_index);
46 BOOST_TEST(
ID == expected_ID);
47 BOOST_TEST(
ID.isValid);
52 BOOST_TEST(mapper.
size() == expected_index);
53 BOOST_TEST(!mapper.
ID(expected_index).
isValid);
91 auto const& constMapper = mapper;
93 BOOST_TEST(constMapper.dimSize<0U>() == NCryostats);
94 BOOST_TEST(constMapper.dimSize<1U>() == NTPCs);
95 BOOST_TEST(constMapper.dimSize<2U>() == 0U);
96 BOOST_TEST(constMapper.dimSize<3U>() == 0U);
100 BOOST_TEST(mapper.
empty());
108 std::size_t
const NCryostats,
109 std::size_t
const NTPCs,
110 std::size_t
const NPlanes
115 std::size_t
const N = NCryostats * NTPCs * NPlanes;
118 BOOST_TEST(mapper.
dimSize<0U>() == NCryostats);
119 BOOST_TEST(mapper.
dimSize<1U>() == NTPCs);
120 BOOST_TEST(mapper.
dimSize<2U>() == NPlanes);
121 BOOST_TEST(mapper.
dimSize<3U>() == 0U);
123 BOOST_TEST(!mapper.
empty());
124 BOOST_TEST(mapper.
size() ==
N);
126 auto expected_index = Mapper_t::index_type{ 0 };
127 for (
auto c: util::counter<unsigned int>(NCryostats)) {
128 for (
auto t: util::counter<unsigned int>(NTPCs)) {
129 for (
auto p: util::counter<unsigned int>(NPlanes)) {
132 BOOST_TEST(mapper.
index(expected_ID) == expected_index);
133 BOOST_TEST(mapper.
ID(expected_index) == expected_ID);
139 BOOST_TEST(mapper.
size() == expected_index);
144 BOOST_TEST( mapper.
hasPlane({ 0, 0, 0}));
145 BOOST_TEST( mapper.
hasPlane({ 0, 0, 1}));
146 BOOST_TEST(!mapper.
hasPlane({ 0, 0, 2}));
147 BOOST_TEST( mapper.
hasPlane({ 0, 1, 0}));
148 BOOST_TEST( mapper.
hasPlane({ 0, 1, 1}));
149 BOOST_TEST(!mapper.
hasPlane({ 0, 1, 2}));
150 BOOST_TEST( mapper.
hasPlane({ 0, 2, 0}));
151 BOOST_TEST( mapper.
hasPlane({ 0, 2, 1}));
152 BOOST_TEST(!mapper.
hasPlane({ 0, 2, 2}));
153 BOOST_TEST(!mapper.
hasPlane({ 0, 3, 0}));
154 BOOST_TEST(!mapper.
hasPlane({ 0, 3, 1}));
155 BOOST_TEST(!mapper.
hasPlane({ 0, 3, 2}));
156 BOOST_TEST(!mapper.
hasPlane({ 0, 4, 0}));
157 BOOST_TEST(!mapper.
hasPlane({ 0, 4, 1}));
158 BOOST_TEST(!mapper.
hasPlane({ 0, 4, 2}));
159 BOOST_TEST( mapper.
hasPlane({ 1, 0, 0}));
160 BOOST_TEST( mapper.
hasPlane({ 1, 0, 1}));
161 BOOST_TEST(!mapper.
hasPlane({ 1, 0, 2}));
162 BOOST_TEST( mapper.
hasPlane({ 1, 1, 0}));
163 BOOST_TEST( mapper.
hasPlane({ 1, 1, 1}));
164 BOOST_TEST(!mapper.
hasPlane({ 1, 1, 2}));
165 BOOST_TEST( mapper.
hasPlane({ 1, 2, 0}));
166 BOOST_TEST( mapper.
hasPlane({ 1, 2, 1}));
167 BOOST_TEST(!mapper.
hasPlane({ 1, 2, 2}));
168 BOOST_TEST(!mapper.
hasPlane({ 1, 3, 0}));
169 BOOST_TEST(!mapper.
hasPlane({ 1, 3, 1}));
170 BOOST_TEST(!mapper.
hasPlane({ 1, 3, 2}));
171 BOOST_TEST(!mapper.
hasPlane({ 1, 4, 0}));
172 BOOST_TEST(!mapper.
hasPlane({ 1, 4, 1}));
173 BOOST_TEST(!mapper.
hasPlane({ 1, 4, 2}));
174 BOOST_TEST(!mapper.
hasPlane({ 2, 0, 0}));
175 BOOST_TEST(!mapper.
hasPlane({ 2, 0, 1}));
176 BOOST_TEST(!mapper.
hasPlane({ 2, 0, 2}));
177 BOOST_TEST(!mapper.
hasPlane({ 2, 1, 0}));
178 BOOST_TEST(!mapper.
hasPlane({ 2, 1, 1}));
179 BOOST_TEST(!mapper.
hasPlane({ 2, 1, 2}));
180 BOOST_TEST(!mapper.
hasPlane({ 2, 2, 0}));
181 BOOST_TEST(!mapper.
hasPlane({ 2, 2, 1}));
182 BOOST_TEST(!mapper.
hasPlane({ 2, 2, 2}));
183 BOOST_TEST(!mapper.
hasPlane({ 2, 3, 0}));
184 BOOST_TEST(!mapper.
hasPlane({ 2, 3, 1}));
185 BOOST_TEST(!mapper.
hasPlane({ 2, 3, 2}));
186 BOOST_TEST(!mapper.
hasPlane({ 2, 4, 0}));
187 BOOST_TEST(!mapper.
hasPlane({ 2, 4, 1}));
188 BOOST_TEST(!mapper.
hasPlane({ 2, 4, 2}));
283 auto const& constMapper = mapper;
285 BOOST_TEST(constMapper.dimSize<0U>() == NCryostats);
286 BOOST_TEST(constMapper.dimSize<1U>() == NTPCs);
287 BOOST_TEST(constMapper.dimSize<2U>() == NPlanes);
288 BOOST_TEST(constMapper.dimSize<3U>() == 0U);
291 BOOST_TEST(mapper.
empty());
296 BOOST_AUTO_TEST_SUITE(geoidmapper_test)
301 constexpr std::size_t NCryostats = 2U;
302 constexpr std::size_t NTPCs = 3U;
314 BOOST_TEST(mapper2.
empty());
325 constexpr std::size_t NCryostats = 2U;
326 constexpr std::size_t NTPCs = 3U;
327 constexpr std::size_t NPlanes = 2U;
339 BOOST_TEST(mapper2.
empty());
349 BOOST_AUTO_TEST_SUITE_END()
void PlaneIDmappingTest(geo::PlaneIDmapper<> mapper, std::size_t const NCryostats, std::size_t const NTPCs, std::size_t const NPlanes)
void TPCIDmappingTest(geo::TPCIDmapper<> mapper, std::size_t const NCryostats, std::size_t const NTPCs)
ID_t ID(index_type const index) const
Returns the ID corresponding to the specified linear index.
bool hasCryostat(geo::CryostatID const &cryoid) const
Returns whether this mapping covers the specified cryostat.
index_type size() const
Returns the number of elements in the mapping.
void resizeAs(geo::GeoIDmapper< OIDType, OIndex > const &other)
Resizes the mapping to reflect the one from another mapping.
GeoID firstID() const
Returns the ID of the first element with GeoID type.
The data type to uniquely identify a Plane.
bool isValid
Whether this ID points to a valid element.
Mapping between geometry/readout ID and flat index.
BOOST_AUTO_TEST_CASE(TPCIDmappingTestCase)
static constexpr unsigned int dimensions()
Dimensions of the ID of this mapping.
unsigned int dimSize() const
Dimensions of the Level dimension of this mapping.
Test of util::counter and support utilities.
The data type to uniquely identify a TPC.
Definition of data types for geometry description.
GeoID lastID() const
Returns the ID of the last covered element with GeoID type.
bool hasElement(GeoID const &id) const
Returns whether this mapping hosts data for the specified ID.
bool empty() const
Returns whether the mapping has no elements (false by assumptions).
detail::Node< FrameID, bool > PlaneID
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
index_type index(ID_t const &id) const
Returns the linear index corresponding to the specified ID.
bool hasPlane(geo::PlaneID const &planeid) const
Returns whether this mapping covers the specified plane.
bool hasTPC(geo::TPCID const &tpcid) const
Returns whether this mapping covers the specified TPC.
The data type to uniquely identify a cryostat.
void clear()
Sets all dimension sizes to 0.