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);
59 BOOST_TEST( mapper.hasElement({ 0, 1 }));
60 BOOST_TEST( mapper.hasElement({ 0, 2 }));
61 BOOST_TEST(!mapper.hasElement({ 0, 3 }));
62 BOOST_TEST(!mapper.hasElement({ 0, 4 }));
63 BOOST_TEST( mapper.hasElement({ 1, 0 }));
64 BOOST_TEST( mapper.hasElement({ 1, 1 }));
65 BOOST_TEST( mapper.hasElement({ 1, 2 }));
66 BOOST_TEST(!mapper.hasElement({ 1, 3 }));
67 BOOST_TEST(!mapper.hasElement({ 1, 4 }));
68 BOOST_TEST(!mapper.hasElement({ 2, 0 }));
69 BOOST_TEST(!mapper.hasElement({ 2, 1 }));
70 BOOST_TEST(!mapper.hasElement({ 2, 2 }));
71 BOOST_TEST(!mapper.hasElement({ 2, 3 }));
72 BOOST_TEST(!mapper.hasElement({ 2, 4 }));
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}));
236 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 0, 0}));
237 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 0, 1}));
238 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 0, 2}));
239 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 1, 0}));
240 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 1, 1}));
241 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 1, 2}));
242 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 2, 0}));
243 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 2, 1}));
244 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 2, 2}));
245 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 3, 0}));
246 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 3, 1}));
247 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 3, 2}));
248 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 4, 0}));
249 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 4, 1}));
250 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 0, 4, 2}));
251 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 0, 0}));
252 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 0, 1}));
253 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 0, 2}));
254 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 1, 0}));
255 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 1, 1}));
256 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 1, 2}));
257 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 2, 0}));
258 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 2, 1}));
259 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 2, 2}));
260 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 3, 0}));
261 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 3, 1}));
262 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 3, 2}));
263 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 4, 0}));
264 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 4, 1}));
265 BOOST_TEST( mapper.hasCryostat(
geo::PlaneID{ 1, 4, 2}));
266 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 0, 0}));
267 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 0, 1}));
268 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 0, 2}));
269 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 1, 0}));
270 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 1, 1}));
271 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 1, 2}));
272 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 2, 0}));
273 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 2, 1}));
274 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 2, 2}));
275 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 3, 0}));
276 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 3, 1}));
277 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 3, 2}));
278 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 4, 0}));
279 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 2, 4, 1}));
280 BOOST_TEST(!mapper.hasCryostat(
geo::PlaneID{ 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.
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.
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
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).
process_name largeant stream1 can override from command line with o or output physics producers generator N
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.
The data type to uniquely identify a cryostat.