All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
geo_types_test.cc
Go to the documentation of this file.
1 /**
2  * @file geo_types_test.cc
3  * @brief Test of geo_types.h types
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date May 5th, 2015
6  */
7 
8 // Define the following non-zero to exclude include code that is required
9 // not to be compilable
10 #ifndef GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
11 # define GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS 1
12 #endif // !GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
13 
14 // Boost libraries
15 /*
16  * Boost Magic: define the name of the module;
17  * and do that before the inclusion of Boost unit test headers
18  * because it will change what they provide.
19  * Among the those, there is a main() function and some wrapping catching
20  * unhandled exceptions and considering them test failures, and probably more.
21  * This also makes fairly complicate to receive parameters from the command line
22  * (for example, a random seed).
23  */
24 #define BOOST_TEST_MODULE ( geo_types_test )
25 #include "boost/test/unit_test.hpp"
26 
27 // LArSoft libraries
29 
30 // C/C++ standard libraries
31 #include <type_traits> // add_const<>
32 
33 //------------------------------------------------------------------------------
34 template <typename T>
35 auto makeConst(T& var) -> decltype(auto) { return const_cast<T const&>(var); }
36 
37 template <typename ID>
38 constexpr bool assertGeoIDlevel()
39  { return geo::details::geoElementLevel<ID>() == ID::Level; }
40 
41 //------------------------------------------------------------------------------
42 // compile-time tests:
43 //
44 // consistency check between levels
45 static_assert(assertGeoIDlevel<geo::CryostatID>());
46 static_assert(assertGeoIDlevel<geo::OpDetID>());
47 static_assert(assertGeoIDlevel<geo::TPCID>());
48 static_assert(assertGeoIDlevel<geo::PlaneID>());
49 static_assert(assertGeoIDlevel<geo::WireID>());
50 static_assert( geo::details::isTopGeoElementID<geo::CryostatID>);
51 static_assert(!geo::details::isTopGeoElementID<geo::OpDetID>);
52 static_assert(!geo::details::isTopGeoElementID<geo::TPCID>);
53 static_assert(!geo::details::isTopGeoElementID<geo::PlaneID>);
54 static_assert(!geo::details::isTopGeoElementID<geo::WireID>);
55 
56 static_assert(std::is_same_v<geo::CryostatID::ID_t<0U>, geo::CryostatID>);
57 static_assert(std::is_same_v<geo::CryostatID::UpperID_t<0U>, geo::CryostatID>);
58 static_assert(std::is_same_v<geo::OpDetID::ID_t<0U>, geo::CryostatID>);
59 static_assert(std::is_same_v<geo::OpDetID::ID_t<1U>, geo::OpDetID>);
60 static_assert(std::is_same_v<geo::OpDetID::UpperID_t<0U>, geo::OpDetID>);
61 static_assert(std::is_same_v<geo::OpDetID::UpperID_t<1U>, geo::CryostatID>);
62 static_assert(std::is_same_v<geo::TPCID::ID_t<0U>, geo::CryostatID>);
63 static_assert(std::is_same_v<geo::TPCID::ID_t<1U>, geo::TPCID>);
64 static_assert(std::is_same_v<geo::TPCID::UpperID_t<0U>, geo::TPCID>);
65 static_assert(std::is_same_v<geo::TPCID::UpperID_t<1U>, geo::CryostatID>);
66 static_assert(std::is_same_v<geo::PlaneID::ID_t<0U>, geo::CryostatID>);
67 static_assert(std::is_same_v<geo::PlaneID::ID_t<1U>, geo::TPCID>);
68 static_assert(std::is_same_v<geo::PlaneID::ID_t<2U>, geo::PlaneID>);
69 static_assert(std::is_same_v<geo::PlaneID::UpperID_t<0U>, geo::PlaneID>);
70 static_assert(std::is_same_v<geo::PlaneID::UpperID_t<1U>, geo::TPCID>);
71 static_assert(std::is_same_v<geo::PlaneID::UpperID_t<2U>, geo::CryostatID>);
72 static_assert(std::is_same_v<geo::WireID::ID_t<0U>, geo::CryostatID>);
73 static_assert(std::is_same_v<geo::WireID::ID_t<1U>, geo::TPCID>);
74 static_assert(std::is_same_v<geo::WireID::ID_t<2U>, geo::PlaneID>);
75 static_assert(std::is_same_v<geo::WireID::ID_t<3U>, geo::WireID>);
76 static_assert(std::is_same_v<geo::WireID::UpperID_t<0U>, geo::WireID>);
77 static_assert(std::is_same_v<geo::WireID::UpperID_t<1U>, geo::PlaneID>);
78 static_assert(std::is_same_v<geo::WireID::UpperID_t<2U>, geo::TPCID>);
79 static_assert(std::is_same_v<geo::WireID::UpperID_t<3U>, geo::CryostatID>);
80 
81 static_assert(geo::CryostatID{0} .getIndex <0U>() == 0);
82 static_assert(geo::CryostatID{0} .getRelIndex<0U>() == 0);
83 static_assert(geo::OpDetID{0,1} .getIndex <0U>() == 0);
84 static_assert(geo::OpDetID{0,1} .getIndex <1U>() == 1);
85 static_assert(geo::OpDetID{0,1} .getRelIndex<0U>() == 1);
86 static_assert(geo::OpDetID{0,1} .getRelIndex<1U>() == 0);
87 static_assert(geo::TPCID{0,1} .getIndex <0U>() == 0);
88 static_assert(geo::TPCID{0,1} .getIndex <1U>() == 1);
89 static_assert(geo::TPCID{0,1} .getRelIndex<0U>() == 1);
90 static_assert(geo::TPCID{0,1} .getRelIndex<1U>() == 0);
91 static_assert(geo::PlaneID{0,1,2} .getIndex <0U>() == 0);
92 static_assert(geo::PlaneID{0,1,2} .getIndex <1U>() == 1);
93 static_assert(geo::PlaneID{0,1,2} .getIndex <2U>() == 2);
94 static_assert(geo::PlaneID{0,1,2} .getRelIndex<0U>() == 2);
95 static_assert(geo::PlaneID{0,1,2} .getRelIndex<1U>() == 1);
96 static_assert(geo::PlaneID{0,1,2} .getRelIndex<2U>() == 0);
97 static_assert(geo::WireID{0,1,2,3}.getIndex <0U>() == 0);
98 static_assert(geo::WireID{0,1,2,3}.getIndex <1U>() == 1);
99 static_assert(geo::WireID{0,1,2,3}.getIndex <2U>() == 2);
100 static_assert(geo::WireID{0,1,2,3}.getIndex <3U>() == 3);
101 static_assert(geo::WireID{0,1,2,3}.getRelIndex<0U>() == 3);
102 static_assert(geo::WireID{0,1,2,3}.getRelIndex<1U>() == 2);
103 static_assert(geo::WireID{0,1,2,3}.getRelIndex<2U>() == 1);
104 static_assert(geo::WireID{0,1,2,3}.getRelIndex<3U>() == 0);
105 
106 // IDs must not be convertible to integers
107 static_assert(
109  "geo::CryostatID can be implicitly converted to an integral type"
110  );
111 static_assert(
113  "geo::OpDetID can be implicitly converted to an integral type"
114  );
115 static_assert(
117  "geo::TPCID can be implicitly converted to an integral type"
118  );
119 static_assert(
121  "geo::PlaneID can be implicitly converted to an integral type"
122  );
123 static_assert(
125  "geo::WireID can be implicitly converted to an integral type"
126  );
127 
128 
129 
130 //------------------------------------------------------------------------------
131 // run-time tests:
132 //
133 void TestIDvalidity(geo::CryostatID const& id, bool answer) {
134  // - check isValid
135  BOOST_TEST(id.isValid == answer);
136  // - check operator!
137  BOOST_TEST(!id == !answer);
138  // - check operator bool
139  BOOST_TEST((bool)id == answer);
140 } // TestIDvalidity()
141 
143 
144  bool const orig = bool(id);
145 
146  id.setValidity(true);
147  BOOST_TEST(bool(id));
148  id.setValidity(false);
149  BOOST_TEST(!id);
150  id.markValid();
151  BOOST_TEST(bool(id));
152  id.markInvalid();
153  BOOST_TEST(!id);
154  id.setValidity(orig);
155  BOOST_TEST(bool(id) == orig);
156 
157 } // TestSetIDvalidity()
158 
159 /// Test comparison operators
160 template <typename TESTID, typename REFID = TESTID>
161 void TestCompareSmallerID(TESTID const& id, REFID const& smaller) {
162  BOOST_TEST(!(id < smaller) );
163  BOOST_TEST(!(id == smaller) );
164  BOOST_TEST( id != smaller );
165  BOOST_TEST( smaller < id );
166  BOOST_TEST(smaller.cmp(id) < 0);
167  BOOST_TEST(id.cmp(smaller) > 0);
168 } // TestCompareSmallerID()
169 
170 /// Test comparison operators
171 template <typename TESTID, typename REFID = TESTID>
172 void TestCompareSameID(TESTID const& id, REFID const& same) {
173  BOOST_TEST(!(id < same) );
174  BOOST_TEST( id == same );
175  BOOST_TEST(!(id != same) );
176  BOOST_TEST(!(same < id) );
177  BOOST_TEST(same.cmp(id) == 0);
178  BOOST_TEST(id.cmp(same) == 0);
179 } // TestCompareSameID()
180 
181 /// Test comparison operators
182 template <typename TESTID>
183 void TestCompareSelfID(TESTID const& id)
184  { return TestCompareSameID(id, id); }
185 
186 /// Test comparison operators
187 template <typename TESTID, typename REFID = TESTID>
188 void TestCompareLargerID(TESTID const& id, REFID const& larger) {
189  BOOST_TEST( id < larger );
190  BOOST_TEST( id != larger );
191  BOOST_TEST(!(id == larger) );
192  BOOST_TEST(!(larger < id) );
193  BOOST_TEST(larger.cmp(id) > 0);
194  BOOST_TEST(id.cmp(larger) < 0);
195 } // TestCompareLargerID()
196 
197 
198 /// Test comparison operators
199 template <typename TESTID, typename REFID = TESTID>
201  TESTID const& id,
202  REFID const& smaller,
203  REFID const& same,
204  REFID const& larger
205 ) {
206  TestCompareSmallerID(id, smaller);
207  TestCompareSameID(id, same);
208  TestCompareSelfID(id);
209  TestCompareLargerID(id, larger);
210 } // TestCryostatComparison()
211 
212 
213 // --- BEGIN CryostatID tests --------------------------------------------------
215 
216  BOOST_TEST_MESSAGE("Testing default-constructed cryostat ID");
217 
218  geo::CryostatID cid;
219 
220  // a default-constructed ID is invalid:
221  TestIDvalidity(cid, false);
222  TestSetIDvalidity(cid);
223 
224 /* // feature not added
225  // test assignment from ID_t
226  cid = 1;
227  BOOST_TEST(cid.Cryostat == 1);
228 */
229 
230  BOOST_TEST(&cid.deepestIndex() == &cid.Cryostat);
231  BOOST_TEST(&makeConst(cid).deepestIndex() == &cid.Cryostat);
232 
233 } // test_CryostatID_defaultConstructor()
234 
235 
237 
238  BOOST_TEST_CHECKPOINT("Testing cryostat ID constructed with an integer");
239 
240  geo::CryostatID cid(1);
241 
242  // an explicitly constructed ID is valid:
243  TestIDvalidity(cid, true);
244  TestSetIDvalidity(cid);
245 
246  // check the ID value
247  BOOST_TEST(cid.Cryostat == geo::CryostatID::CryostatID_t(1));
248 
249  // test comparison operators
250  // (exercise copy constructor too)
251  geo::CryostatID smaller_cid(0), same_cid(cid), larger_cid(2);
252 
253  TestIDcomparison(cid, smaller_cid, same_cid, larger_cid);
254 
255  // test setting and accessing a single index
256  BOOST_TEST(cid.getIndex<0U>() == 1);
257  cid.writeIndex<0U>() = 2;
258  BOOST_TEST(cid.getIndex<0U>() == 2);
259 
260 
261  // make sure the ID with cryostat 0 is fine (it's not a bad ID!)
262  BOOST_TEST_CHECKPOINT("Testing cryostat ID constructed with an integer 0");
263 
264  geo::CryostatID first_cid(0);
265  TestIDvalidity(cid, true);
266  TestSetIDvalidity(cid);
267 
268  // check the ID value
269  BOOST_TEST(first_cid.Cryostat == geo::CryostatID::CryostatID_t(0));
270 
271 } // test_CryostatID_directConstructor()
272 
273 
274 // --- END CryostatID tests ----------------------------------------------------
275 
276 
277 
278 // --- BEGIN OpDetID tests -----------------------------------------------------
280 
281  BOOST_TEST_CHECKPOINT("Testing default-constructed optical detector ID");
282 
283  geo::OpDetID oid;
284 
285  // a default-constructed ID is invalid:
286  TestIDvalidity(oid, false);
287  TestSetIDvalidity(oid);
288 
289  BOOST_TEST(&oid.deepestIndex() == &oid.OpDet);
290  BOOST_TEST(&makeConst(oid).deepestIndex() == &oid.OpDet);
291 
292 } // test_OpDetID_defaultConstructor()
293 
294 
296 
297  BOOST_TEST_CHECKPOINT("Testing integral-constructed optical detector ID");
298 
299 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
300  BOOST_TEST_MESSAGE(" (test skipped)");
301 #else
302  geo::OpDetID oid(1);
303 
304  BOOST_TEST_MESSAGE("OpDetID(1) = " << std::string(oid));
305 
306  geo::OpDetID::OpDetID_t what = oid;
307 
308  BOOST_TEST_MESSAGE("int(OpDetID(1)) = " << what);
309 
310 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
311 
312 } // test_OpDetID_integralConstructor()
313 
314 
316 
317  BOOST_TEST_CHECKPOINT("Testing ID-constructed optical detector ID");
318 
319  geo::CryostatID cid(1);
320  geo::OpDetID oid(cid, 15);
321 
322  // an explicitly constructed ID is valid:
323  TestIDvalidity(oid, true);
324  TestSetIDvalidity(oid);
325 
326  // check the ID value
327  BOOST_TEST(oid.Cryostat == geo::CryostatID::CryostatID_t( 1));
328  BOOST_TEST(oid.OpDet == geo::OpDetID::OpDetID_t(15));
329 
330  // test comparison operators (exercise copy constructor too)
331  // - with optical detector ID
332  BOOST_TEST_CHECKPOINT("Testing comparison with optical detector ID");
333  geo::OpDetID smaller_oid(cid, oid.OpDet - 1), same_oid(oid),
334  larger_oid(cid, oid.OpDet + 1);
335 
336  TestIDcomparison(oid, smaller_oid, same_oid, larger_oid);
337 
338 } // test_OpDetID_nestedConstructor()
339 
340 
342 
343  BOOST_TEST_CHECKPOINT("Testing optical detector ID constructed with indices");
344 
345  geo::OpDetID oid(1, 15);
346 
347  // an explicitly constructed ID is valid:
348  TestIDvalidity(oid, true);
349  TestSetIDvalidity(oid);
350 
351  BOOST_TEST_CHECKPOINT("Testing comparison with same cryostat ID");
352 
353  geo::OpDetID smaller_oid(1, 14), same_oid(1, 15), larger_oid(1, 16);
354  TestIDcomparison(oid, smaller_oid, same_oid, larger_oid);
355 
356  BOOST_TEST_CHECKPOINT("Testing comparison with different cryostat ID");
357  geo::OpDetID smaller_cid(0, 16), larger_cid(2, 14);
358  TestCompareSmallerID(oid, smaller_cid);
359  TestCompareLargerID(oid, larger_cid);
360 
361  // test setting and accessing a single index
362  BOOST_TEST(oid.getIndex<0U>() == 1);
363  oid.writeIndex<0U>() = 2;
364  BOOST_TEST(oid.getIndex<0U>() == 2);
365 
366  BOOST_TEST(oid.getIndex<1U>() == 15);
367  oid.writeIndex<1U>() = 19;
368  BOOST_TEST(oid.getIndex<1U>() == 19);
369 
370  // make sure the ID with optical detector 0 is fine (it's not a bad ID!)
371  BOOST_TEST_CHECKPOINT
372  ("Testing optical detector ID constructed with OpDet #0");
373 
374  geo::OpDetID first_oid(0, 0);
375  TestIDvalidity(first_oid, true);
376  TestSetIDvalidity(first_oid);
377 
378  // - check the ID value
379  BOOST_TEST(first_oid.Cryostat == geo::CryostatID::CryostatID_t(0));
380  BOOST_TEST(first_oid.OpDet == geo::OpDetID::OpDetID_t(0));
381 
382 
383 } // test_OpDetID_directConstructor()
384 
385 
386 // --- END OpDetID tests -------------------------------------------------------
387 
388 
389 
390 // --- BEGIN TPCID tests -------------------------------------------------------
392 
393  BOOST_TEST_CHECKPOINT("Testing default-constructed TPC ID");
394 
395  geo::TPCID tid;
396 
397  // a default-constructed ID is invalid:
398  TestIDvalidity(tid, false);
399  TestSetIDvalidity(tid);
400 
401  BOOST_TEST(&tid.deepestIndex() == &tid.TPC);
402  BOOST_TEST(&makeConst(tid).deepestIndex() == &tid.TPC);
403 
404 } // test_TPCID_defaultConstructor()
405 
406 
408 
409  BOOST_TEST_CHECKPOINT("Testing integral-constructed TPC ID");
410 
411 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
412  BOOST_TEST_MESSAGE(" (test skipped)");
413 #else
414  geo::TPCID tid(1);
415 
416  BOOST_TEST_MESSAGE("TPCID(1) = " << std::string(tid));
417 
418  geo::TPCID::TPCID_t what = tid;
419 
420  BOOST_TEST_MESSAGE("int(TPCID(1)) = " << what);
421 
422 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
423 
424 } // test_TPCID_integralConstructor()
425 
426 
428 
429  BOOST_TEST_CHECKPOINT("Testing ID-constructed TPC ID");
430 
431  geo::CryostatID cid(1);
432  geo::TPCID tid(cid, 15);
433 
434  // an explicitly constructed ID is valid:
435  TestIDvalidity(tid, true);
436  TestSetIDvalidity(tid);
437 
438  // check the ID value
439  BOOST_TEST(tid.Cryostat == geo::CryostatID::CryostatID_t( 1));
440  BOOST_TEST(tid.TPC == geo::TPCID::TPCID_t(15));
441 
442  // test comparison operators (exercise copy constructor too)
443  // - with TPC ID
444  BOOST_TEST_CHECKPOINT("Testing comparison with TPC ID");
445  geo::TPCID smaller_tid(cid, tid.TPC - 1), same_tid(tid),
446  larger_tid(cid, tid.TPC + 1);
447 
448  TestIDcomparison(tid, smaller_tid, same_tid, larger_tid);
449 
450 } // test_TPCID_nestedConstructor()
451 
452 
454 
455  BOOST_TEST_CHECKPOINT("Testing TPC ID constructed with indices");
456 
457  geo::TPCID tid(1, 15);
458 
459  // an explicitly constructed ID is valid:
460  TestIDvalidity(tid, true);
461  TestSetIDvalidity(tid);
462 
463  BOOST_TEST_CHECKPOINT("Testing comparison with same cryostat ID");
464 
465  geo::TPCID smaller_tid(1, 14), same_tid(1, 15), larger_tid(1, 16);
466  TestIDcomparison(tid, smaller_tid, same_tid, larger_tid);
467 
468  BOOST_TEST_CHECKPOINT("Testing comparison with different cryostat ID");
469  geo::TPCID smaller_cid(0, 16), larger_cid(2, 14);
470  TestCompareSmallerID(tid, smaller_cid);
471  TestCompareLargerID(tid, larger_cid);
472 
473  // make sure the ID with TPC 0 is fine (it's not a bad ID!)
474  BOOST_TEST_CHECKPOINT("Testing TPC ID constructed with a TPC #0");
475 
476  // test setting and accessing a single index
477  BOOST_TEST(tid.getIndex<0U>() == 1);
478  tid.writeIndex<0U>() = 2;
479  BOOST_TEST(tid.getIndex<0U>() == 2);
480 
481  BOOST_TEST(tid.getIndex<1U>() == 15);
482  tid.writeIndex<1U>() = 19;
483  BOOST_TEST(tid.getIndex<1U>() == 19);
484 
485 
486  geo::TPCID first_tid(0, 0);
487  TestIDvalidity(first_tid, true);
488  TestSetIDvalidity(first_tid);
489 
490  // - check the ID value
491  BOOST_TEST(first_tid.Cryostat == geo::CryostatID::CryostatID_t(0));
492  BOOST_TEST(first_tid.TPC == geo::TPCID::TPCID_t(0));
493 
494 
495 } // test_TPCID_directConstructor()
496 
497 
498 // --- END TPCID tests ---------------------------------------------------------
499 
500 
501 
502 // --- BEGIN PlaneID tests -----------------------------------------------------
504 
505  BOOST_TEST_CHECKPOINT("Testing default-constructed plane ID");
506 
507  geo::PlaneID pid;
508 
509  // a default-constructed ID is invalid:
510  TestIDvalidity(pid, false);
511  TestSetIDvalidity(pid);
512 
513  BOOST_TEST(&pid.deepestIndex() == &pid.Plane);
514  BOOST_TEST(&makeConst(pid).deepestIndex() == &pid.Plane);
515 
516 } // test_PlaneID_defaultConstructor()
517 
518 
520 
521  BOOST_TEST_CHECKPOINT("Testing integral-constructed plane ID");
522 
523 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
524  BOOST_TEST_MESSAGE(" (test skipped)");
525 #else
526  geo::PlaneID pid(1);
527 
528  BOOST_TEST_MESSAGE("PlaneID(1) = " << std::string(pid));
529 
530  geo::PlaneID::PlaneID_t what = pid;
531 
532  BOOST_TEST_MESSAGE("int(PlaneID(1)) = " << what);
533 
534 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
535 
536 } // test_PlaneID_integralConstructor()
537 
538 
540 
541  BOOST_TEST_CHECKPOINT("Testing ID-constructed plane ID");
542 
543  geo::TPCID tid(1, 15);
544  geo::PlaneID pid(tid, 32);
545 
546  // an explicitly constructed ID is valid:
547  TestIDvalidity(pid, true);
548  TestSetIDvalidity(pid);
549 
550  // check the ID value
551  BOOST_TEST(pid.Cryostat == geo::CryostatID::CryostatID_t( 1));
552  BOOST_TEST(pid.TPC == geo::TPCID::TPCID_t(15));
553  BOOST_TEST(pid.Plane == geo::PlaneID::PlaneID_t(32));
554 
555  // test comparison operators (exercise copy constructor too)
556  BOOST_TEST_CHECKPOINT("Testing comparison with plane ID");
557  geo::PlaneID smaller_pid(tid, pid.Plane - 1), same_pid(pid),
558  larger_pid(tid, pid.Plane + 1);
559 
560  TestIDcomparison(pid, smaller_pid, same_pid, larger_pid);
561 
562 } // test_PlaneID_nestedConstructor()
563 
564 
566 
567  BOOST_TEST_CHECKPOINT("Testing plane ID constructed with indices");
568 
569  geo::PlaneID pid(1, 15, 32);
570 
571  // an explicitly constructed ID is valid:
572  TestIDvalidity(pid, true);
573  TestSetIDvalidity(pid);
574 
575  // check the ID value
576  BOOST_TEST(pid.Cryostat == geo::CryostatID::CryostatID_t( 1));
577  BOOST_TEST(pid.TPC == geo::TPCID::TPCID_t(15));
578  BOOST_TEST(pid.Plane == geo::PlaneID::PlaneID_t(32));
579 
580  BOOST_TEST_CHECKPOINT("Testing comparison with same TPC ID");
581 
583  smaller_pid(1, 15, 31), same_pid(1, 15, 32), larger_pid(1, 15, 33);
584  TestIDcomparison(pid, smaller_pid, same_pid, larger_pid);
585 
586  BOOST_TEST_CHECKPOINT("Testing comparison with different TPC ID (1)");
587  geo::PlaneID smaller_tid1(1, 14, 33), larger_tid1(1, 16, 31);
588  TestCompareSmallerID(pid, smaller_tid1);
589  TestCompareLargerID(pid, larger_tid1);
590  BOOST_TEST_CHECKPOINT("Testing comparison with different TPC ID (2)");
591  geo::PlaneID smaller_tid2(1, 14, 32), larger_tid2(1, 16, 32);
592  TestCompareSmallerID(pid, smaller_tid2);
593  TestCompareLargerID(pid, larger_tid2);
594 
595  BOOST_TEST_CHECKPOINT("Testing comparison with different cryostat ID");
596  geo::PlaneID smaller_cid1(0, 15, 33), larger_cid1(2, 15, 31);
597  TestCompareSmallerID(pid, smaller_cid1);
598  TestCompareLargerID(pid, larger_cid1);
599  BOOST_TEST_CHECKPOINT("Testing comparison with different cryostat ID (2)");
600  geo::PlaneID smaller_cid2(0, 15, 32), larger_cid2(2, 15, 32);
601  TestCompareSmallerID(pid, smaller_cid2);
602  TestCompareLargerID(pid, larger_cid2);
603 
604  // test setting and accessing a single index
605  BOOST_TEST(pid.getIndex<0U>() == 1);
606  pid.writeIndex<0U>() = 2;
607  BOOST_TEST(pid.getIndex<0U>() == 2);
608 
609  BOOST_TEST(pid.getIndex<1U>() == 15);
610  pid.writeIndex<1U>() = 19;
611  BOOST_TEST(pid.getIndex<1U>() == 19);
612 
613  BOOST_TEST(pid.getIndex<2U>() == 32);
614  pid.writeIndex<2U>() = 76;
615  BOOST_TEST(pid.getIndex<2U>() == 76);
616 
617 
618  // make sure the ID with plane 0 is fine (it's not a bad ID!)
619  BOOST_TEST_CHECKPOINT("Testing plane ID constructed with a plane #0");
620 
621  geo::PlaneID first_pid(0, 0, 0);
622  TestIDvalidity(first_pid, true);
623  TestSetIDvalidity(first_pid);
624 
625  // - check the ID value
626  BOOST_TEST(first_pid.Cryostat == geo::CryostatID::CryostatID_t(0));
627  BOOST_TEST(first_pid.TPC == geo::TPCID::TPCID_t(0));
628  BOOST_TEST(first_pid.Plane == geo::PlaneID::PlaneID_t(0));
629 
630 } // test_PlaneID_directConstructor()
631 
632 
633 // --- END PlaneID tests -------------------------------------------------------
634 
635 
636 
637 // --- BEGIN WireID tests ------------------------------------------------------
639 
640  BOOST_TEST_CHECKPOINT("Testing default-constructed wire ID");
641 
642  geo::WireID wid;
643 
644  // a default-constructed ID is invalid:
645  TestIDvalidity(wid, false);
646  TestSetIDvalidity(wid);
647 
648  BOOST_TEST(&wid.deepestIndex() == &wid.Wire);
649  BOOST_TEST(&makeConst(wid).deepestIndex() == &wid.Wire);
650 
651 } // test_WireID_defaultConstructor()
652 
653 
655 
656  BOOST_TEST_CHECKPOINT("Testing integral-constructed wire ID");
657 
658 #if GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
659  BOOST_TEST_MESSAGE(" (test skipped)");
660 #else
661  geo::WireID wid(1);
662 
663  BOOST_TEST_MESSAGE("WireID(1) = " << std::string(wid));
664 
665  geo::WireID::WireID_t what = wid;
666 
667  BOOST_TEST_MESSAGE("int(WireID(1)) = " << what);
668 
669 #endif // GEO_TYPES_TEST_SKIP_COMPILATION_ERRORS
670 } // test_WireID_integralConstructor()
671 
672 
674 
675  BOOST_TEST_CHECKPOINT("Testing ID-constructed wire ID");
676 
677  geo::PlaneID pid(1, 15, 32);
678  geo::WireID wid(pid, 27);
679 
680  // an explicitly constructed ID is valid:
681  TestIDvalidity(wid, true);
682  TestSetIDvalidity(wid);
683 
684  // check the ID value
685  BOOST_TEST(wid.Cryostat == geo::CryostatID::CryostatID_t( 1));
686  BOOST_TEST(wid.TPC == geo::TPCID::TPCID_t(15));
687  BOOST_TEST(wid.Plane == geo::PlaneID::PlaneID_t(32));
688  BOOST_TEST(wid.Wire == geo::WireID::WireID_t(27));
689 
690  // test comparison operators (exercise copy constructor too)
691  // - with TPC ID
692  BOOST_TEST_CHECKPOINT("Testing comparison with wire ID");
693  geo::WireID smaller_wid(pid, wid.Wire - 1), same_wid(wid),
694  larger_wid(pid, wid.Wire + 1);
695 
696  TestIDcomparison(wid, smaller_wid, same_wid, larger_wid);
697 
698 } // test_WireID_nestedConstructor()
699 
700 
702 
703  BOOST_TEST_CHECKPOINT("Testing wire ID constructed with indices");
704 
705  geo::WireID wid(1, 15, 32, 27);
706 
707  // an explicitly constructed ID is valid:
708  TestIDvalidity(wid, true);
709  TestSetIDvalidity(wid);
710 
711  // check the ID value
712  BOOST_TEST(wid.Cryostat == geo::CryostatID::CryostatID_t( 1));
713  BOOST_TEST(wid.TPC == geo::TPCID::TPCID_t(15));
714  BOOST_TEST(wid.Plane == geo::PlaneID::PlaneID_t(32));
715  BOOST_TEST(wid.Wire == geo::WireID::WireID_t(27));
716 
717  BOOST_TEST_CHECKPOINT("Testing comparison with same TPC ID");
718 
720  smaller_wid(1, 15, 32, 26), same_wid(1, 15, 32, 27),
721  larger_wid(1, 15, 32, 28);
722  TestIDcomparison(wid, smaller_wid, same_wid, larger_wid);
723 
724  BOOST_TEST_CHECKPOINT("Testing comparison with different plane ID (1)");
725  geo::WireID smaller_pid1(1, 15, 31, 28), larger_pid1(1, 15, 33, 26);
726  TestCompareSmallerID(wid, smaller_pid1);
727  TestCompareLargerID(wid, larger_pid1);
728  BOOST_TEST_CHECKPOINT("Testing comparison with different plane ID (2)");
729  geo::WireID smaller_pid2(1, 15, 31, 27), larger_pid2(1, 15, 33, 27);
730  TestCompareSmallerID(wid, smaller_pid2);
731  TestCompareLargerID(wid, larger_pid2);
732 
733  BOOST_TEST_CHECKPOINT("Testing comparison with different TPC ID (1)");
734  geo::WireID smaller_tid1(1, 14, 32, 28), larger_tid1(1, 16, 32, 26);
735  TestCompareSmallerID(wid, smaller_tid1);
736  TestCompareLargerID(wid, larger_tid1);
737  BOOST_TEST_CHECKPOINT("Testing comparison with different TPC ID (2)");
738  geo::WireID smaller_tid2(1, 14, 32, 27), larger_tid2(1, 16, 32, 27);
739  TestCompareSmallerID(wid, smaller_tid2);
740  TestCompareLargerID(wid, larger_tid2);
741 
742  BOOST_TEST_CHECKPOINT("Testing comparison with different cryostat ID");
743  geo::WireID smaller_cid1(0, 15, 32, 28), larger_cid1(2, 15, 32, 26);
744  TestCompareSmallerID(wid, smaller_cid1);
745  TestCompareLargerID(wid, larger_cid1);
746  BOOST_TEST_CHECKPOINT("Testing comparison with different cryostat ID (2)");
747  geo::WireID smaller_cid2(0, 15, 32, 27), larger_cid2(2, 15, 32, 27);
748  TestCompareSmallerID(wid, smaller_cid2);
749  TestCompareLargerID(wid, larger_cid2);
750 
751  // make sure the ID with wire 0 is fine (it's not a bad ID!)
752  BOOST_TEST_CHECKPOINT("Testing wire ID constructed with a wire #0");
753 
754  // test setting and accessing a single index
755  BOOST_TEST(wid.getIndex<0U>() == 1);
756  wid.writeIndex<0U>() = 2;
757  BOOST_TEST(wid.getIndex<0U>() == 2);
758 
759  BOOST_TEST(wid.getIndex<1U>() == 15);
760  wid.writeIndex<1U>() = 19;
761  BOOST_TEST(wid.getIndex<1U>() == 19);
762 
763  BOOST_TEST(wid.getIndex<2U>() == 32);
764  wid.writeIndex<2U>() = 76;
765  BOOST_TEST(wid.getIndex<2U>() == 76);
766 
767  BOOST_TEST(wid.getIndex<3U>() == 27);
768  wid.writeIndex<3U>() = 45;
769  BOOST_TEST(wid.getIndex<3U>() == 45);
770 
771 
772  geo::WireID first_wid(0, 0, 0, 0);
773  TestIDvalidity(first_wid, true);
774  TestSetIDvalidity(first_wid);
775 
776  // - check the ID value
777  BOOST_TEST(first_wid.Cryostat == geo::CryostatID::CryostatID_t(0));
778  BOOST_TEST(first_wid.TPC == geo::TPCID::TPCID_t(0));
779  BOOST_TEST(first_wid.Plane == geo::PlaneID::PlaneID_t(0));
780  BOOST_TEST(first_wid.Wire == geo::WireID::WireID_t(0));
781 
782 } // test_WireID_directConstructor()
783 
784 
785 // --- END WireID tests -------------------------------------------------------
786 
787 
788 //
789 // CryostatID test
790 //
791 BOOST_AUTO_TEST_CASE(CryostatIDtest) {
794 }
795 
796 //
797 // OpDetID test
798 //
799 BOOST_AUTO_TEST_CASE(OpDetIDtest) {
804 }
805 
806 //
807 // TPCID test
808 //
814 }
815 
816 //
817 // PlaneID test
818 //
819 BOOST_AUTO_TEST_CASE(PlaneIDtest) {
824 }
825 
826 //
827 // WireID test
828 //
829 BOOST_AUTO_TEST_CASE(WireIDtest) {
834 }
835 
void test_OpDetID_defaultConstructor()
BOOST_AUTO_TEST_CASE(AllTests)
void test_TPCID_defaultConstructor()
constexpr auto getIndex() const
Returns the index level Index of this type.
Definition: geo_types.h:904
void test_OpDetID_integralConstructor()
void TestCompareSelfID(TESTID const &id)
Test comparison operators.
constexpr auto getIndex() const
Returns the index level Index of this type.
Definition: geo_types.h:973
void test_TPCID_nestedConstructor()
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
Definition: geo_types.h:572
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
Definition: geo_types.h:398
auto & writeIndex()
Returns the index level Index of this type.
Definition: geo_types.h:911
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
Definition: geo_types.h:198
auto & writeIndex()
Returns the index level Index of this type.
Definition: geo_types.h:934
void TestCompareSameID(TESTID const &id, REFID const &same)
Test comparison operators.
void test_TPCID_directConstructor()
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
Definition: geo_types.h:480
void test_OpDetID_nestedConstructor()
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:473
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
void test_PlaneID_directConstructor()
void test_WireID_defaultConstructor()
void test_PlaneID_integralConstructor()
constexpr auto getIndex() const
Returns the index level Index of this type.
Definition: geo_types.h:950
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
static constexpr bool
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (plane&#39;s).
Definition: geo_types.h:516
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
Definition: geo_types.h:941
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
auto makeConst(T &var) -> decltype(auto)
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (wire&#39;s).
Definition: geo_types.h:602
void TestIDvalidity(geo::CryostatID const &id, bool answer)
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (OpDet&#39;s).
Definition: geo_types.h:342
void TestSetIDvalidity(geo::CryostatID &id)
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
Definition: geo_types.h:202
OpDetID_t OpDet
Index of the optical detector within its cryostat.
Definition: geo_types.h:319
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
Definition: geo_types.h:568
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
Definition: geo_types.h:394
void test_WireID_directConstructor()
void test_OpDetID_directConstructor()
void test_PlaneID_nestedConstructor()
auto & writeIndex()
Returns the index level Index of this type.
Definition: geo_types.h:888
void TestCompareSmallerID(TESTID const &id, REFID const &smaller)
Test comparison operators.
constexpr auto getIndex() const
Returns the index level Index of this type.
Definition: geo_types.h:927
void test_WireID_nestedConstructor()
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
Definition of data types for geometry description.
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
Definition: geo_types.h:987
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
Definition: geo_types.h:895
void test_TPCID_integralConstructor()
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
Definition: geo_types.h:484
void test_CryostatID_directConstructor()
void test_WireID_integralConstructor()
void test_CryostatID_defaultConstructor()
auto & writeIndex()
Returns the index level Index of this type.
Definition: geo_types.h:957
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
unsigned int OpDetID_t
Type for the ID number.
Definition: geo_types.h:298
unsigned int TPCID_t
Type for the ID number.
Definition: geo_types.h:387
void TestCompareLargerID(TESTID const &id, REFID const &larger)
Test comparison operators.
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (TPC&#39;s).
Definition: geo_types.h:428
unsigned int WireID_t
Type for the ID number.
Definition: geo_types.h:561
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
Definition: geo_types.h:964
constexpr bool assertGeoIDlevel()
temporary value
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
Definition: geo_types.h:309
auto & writeIndex()
Returns the index level Index of this type.
Definition: geo_types.h:980
The data type to uniquely identify a optical detector.
Definition: geo_types.h:297
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
Definition: geo_types.h:918
void test_PlaneID_defaultConstructor()
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
Definition: geo_types.h:305
constexpr auto getIndex() const
Returns the index level Index of this type.
Definition: geo_types.h:881
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
void TestIDcomparison(TESTID const &id, REFID const &smaller, REFID const &same, REFID const &larger)
Test comparison operators.
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (cryostat&#39;s).
Definition: geo_types.h:253