All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions
geometrydatacontainers_test.cxx File Reference

Unit test for GeometryDataContainers.h library. More...

#include <boost/test/unit_test.hpp>
#include "larcorealg/Geometry/GeometryDataContainers.h"
#include "larcorealg/CoreUtils/counter.h"
#include "larcorealg/CoreUtils/DebugUtils.h"
#include "larcoreobj/SimpleTypesAndConstants/geo_types.h"

Go to the source code of this file.

Classes

struct  Summer< T >
 

Macros

#define BOOST_TEST_MODULE   (geometry data containers test)
 

Functions

void TPCDataContainerTest (geo::TPCDataContainer< int > data, std::size_t const NCryostats, std::size_t const NTPCs)
 
void PlaneDataContainerTest (geo::PlaneDataContainer< int > data, std::size_t const NCryostats, std::size_t const NTPCs, std::size_t const NPlanes)
 
 BOOST_AUTO_TEST_CASE (TPCDataContainerTestCase)
 
 BOOST_AUTO_TEST_CASE (PlaneDataContainerTestCase)
 

Detailed Description

Unit test for GeometryDataContainers.h library.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)
Date
January 2nd, 2018

Definition in file geometrydatacontainers_test.cxx.

Macro Definition Documentation

#define BOOST_TEST_MODULE   (geometry data containers test)

Definition at line 9 of file geometrydatacontainers_test.cxx.

Function Documentation

BOOST_AUTO_TEST_CASE ( TPCDataContainerTestCase  )

Definition at line 815 of file geometrydatacontainers_test.cxx.

815  {
816 
817  constexpr std::size_t NCryostats = 2U;
818  constexpr std::size_t NTPCs = 3U;
819 
820  //
821  // size constructor
822  //
823  geo::TPCDataContainer<int> data1(NCryostats, NTPCs);
824  TPCDataContainerTest(data1, NCryostats, NTPCs);
825 
826  //
827  // default constructor + resize
828  //
830  BOOST_TEST(data2.empty());
831 
832  data2.resizeAs(data1);
833  TPCDataContainerTest(data2, NCryostats, NTPCs);
834 
835 } // TPCDataContainerTestCase
void TPCDataContainerTest(geo::TPCDataContainer< int > data, std::size_t const NCryostats, std::size_t const NTPCs)
Container with one element per geometry TPC.
bool empty() const
Returns whether the container has no elements (false by assumptions).
void resizeAs(geo::GeoIDdataContainer< OT, Mapper_t > const &other)
Prepares the container with default-constructed data.
BOOST_AUTO_TEST_CASE ( PlaneDataContainerTestCase  )

Definition at line 838 of file geometrydatacontainers_test.cxx.

838  {
839 
840  constexpr std::size_t NCryostats = 2U;
841  constexpr std::size_t NTPCs = 3U;
842  constexpr std::size_t NPlanes = 2U;
843 
844  //
845  // size constructor
846  //
847  geo::PlaneDataContainer<int> data1(NCryostats, NTPCs, NPlanes);
848  PlaneDataContainerTest(data1, NCryostats, NTPCs, NPlanes);
849 
850  //
851  // default constructor + resize
852  //
854  BOOST_TEST(data2.empty());
855 
856  data2.resizeAs(data1);
857  PlaneDataContainerTest(data2, NCryostats, NTPCs, NPlanes);
858 
859 } // PlaneDataContainerTestCase
void PlaneDataContainerTest(geo::PlaneDataContainer< int > data, std::size_t const NCryostats, std::size_t const NTPCs, std::size_t const NPlanes)
Container with one element per geometry wire plane.
bool empty() const
Returns whether the container has no elements (false by assumptions).
void resizeAs(geo::GeoIDdataContainer< OT, Mapper_t > const &other)
Prepares the container with default-constructed data.
void PlaneDataContainerTest ( geo::PlaneDataContainer< int >  data,
std::size_t const  NCryostats,
std::size_t const  NTPCs,
std::size_t const  NPlanes 
)

Definition at line 300 of file geometrydatacontainers_test.cxx.

305  {
306 
307  std::size_t const N = NCryostats * NTPCs * NPlanes;
308 
309  static_assert(data.dimensions() == 3U);
310  BOOST_TEST(data.dimSize<0U>() == NCryostats);
311  BOOST_TEST(data.dimSize<1U>() == NTPCs);
312  BOOST_TEST(data.dimSize<2U>() == NPlanes);
313  BOOST_TEST(data.dimSize<3U>() == 0U);
314 
315  BOOST_TEST(!data.empty());
316  BOOST_TEST(data.size() == N);
317  BOOST_TEST(data.capacity() >= N);
318 
319  for (auto c: util::counter<unsigned int>(NCryostats))
320  for (auto t: util::counter<unsigned int>(NTPCs))
321  for (auto p: util::counter<unsigned int>(NPlanes))
322  BOOST_TEST((data[{ c, t, p }]) == 0);
323 
324  BOOST_TEST(data.firstID() == geo::PlaneID(0, 0, 0));
325  BOOST_TEST(data.lastID() == geo::PlaneID(1, 2, 1));
326 
327 
328  std::size_t expected_index = 0U;
329 
330  // simple R/W iteration test
331  for (auto& value: data) {
332  static_assert(std::is_same_v<decltype(value), decltype(data)::reference>);
333 
334  geo::PlaneID const expected_ID = data.mapper().ID(expected_index);
335  BOOST_TEST(value == data[expected_ID]);
336 
337  ++expected_index;
338  } // for
339  BOOST_TEST(data.size() == expected_index);
340 
341  // ID/data pair R/W iteration test
342  expected_index = 0U;
343  for (auto&& [ ID, value ]: data.items()) {
344  static_assert(std::is_same_v<decltype(ID), geo::PlaneID>);
345  static_assert(std::is_same_v<decltype(value), decltype(data)::reference>);
346 
347  geo::PlaneID const expected_ID = data.mapper().ID(expected_index);
348  BOOST_TEST(ID == expected_ID);
349  BOOST_TEST(value == data[expected_ID]);
350 
351  ++expected_index;
352  } // for
353  BOOST_TEST(data.size() == expected_index);
354 
355  BOOST_TEST( data.hasPlane({ 0, 0, 0}));
356  BOOST_TEST( data.hasPlane({ 0, 0, 1}));
357  BOOST_TEST(!data.hasPlane({ 0, 0, 2}));
358  BOOST_TEST( data.hasPlane({ 0, 1, 0}));
359  BOOST_TEST( data.hasPlane({ 0, 1, 1}));
360  BOOST_TEST(!data.hasPlane({ 0, 1, 2}));
361  BOOST_TEST( data.hasPlane({ 0, 2, 0}));
362  BOOST_TEST( data.hasPlane({ 0, 2, 1}));
363  BOOST_TEST(!data.hasPlane({ 0, 2, 2}));
364  BOOST_TEST(!data.hasPlane({ 0, 3, 0}));
365  BOOST_TEST(!data.hasPlane({ 0, 3, 1}));
366  BOOST_TEST(!data.hasPlane({ 0, 3, 2}));
367  BOOST_TEST(!data.hasPlane({ 0, 4, 0}));
368  BOOST_TEST(!data.hasPlane({ 0, 4, 1}));
369  BOOST_TEST(!data.hasPlane({ 0, 4, 2}));
370  BOOST_TEST( data.hasPlane({ 1, 0, 0}));
371  BOOST_TEST( data.hasPlane({ 1, 0, 1}));
372  BOOST_TEST(!data.hasPlane({ 1, 0, 2}));
373  BOOST_TEST( data.hasPlane({ 1, 1, 0}));
374  BOOST_TEST( data.hasPlane({ 1, 1, 1}));
375  BOOST_TEST(!data.hasPlane({ 1, 1, 2}));
376  BOOST_TEST( data.hasPlane({ 1, 2, 0}));
377  BOOST_TEST( data.hasPlane({ 1, 2, 1}));
378  BOOST_TEST(!data.hasPlane({ 1, 2, 2}));
379  BOOST_TEST(!data.hasPlane({ 1, 3, 0}));
380  BOOST_TEST(!data.hasPlane({ 1, 3, 1}));
381  BOOST_TEST(!data.hasPlane({ 1, 3, 2}));
382  BOOST_TEST(!data.hasPlane({ 1, 4, 0}));
383  BOOST_TEST(!data.hasPlane({ 1, 4, 1}));
384  BOOST_TEST(!data.hasPlane({ 1, 4, 2}));
385  BOOST_TEST(!data.hasPlane({ 2, 0, 0}));
386  BOOST_TEST(!data.hasPlane({ 2, 0, 1}));
387  BOOST_TEST(!data.hasPlane({ 2, 0, 2}));
388  BOOST_TEST(!data.hasPlane({ 2, 1, 0}));
389  BOOST_TEST(!data.hasPlane({ 2, 1, 1}));
390  BOOST_TEST(!data.hasPlane({ 2, 1, 2}));
391  BOOST_TEST(!data.hasPlane({ 2, 2, 0}));
392  BOOST_TEST(!data.hasPlane({ 2, 2, 1}));
393  BOOST_TEST(!data.hasPlane({ 2, 2, 2}));
394  BOOST_TEST(!data.hasPlane({ 2, 3, 0}));
395  BOOST_TEST(!data.hasPlane({ 2, 3, 1}));
396  BOOST_TEST(!data.hasPlane({ 2, 3, 2}));
397  BOOST_TEST(!data.hasPlane({ 2, 4, 0}));
398  BOOST_TEST(!data.hasPlane({ 2, 4, 1}));
399  BOOST_TEST(!data.hasPlane({ 2, 4, 2}));
400 
401  BOOST_TEST( data.hasTPC(geo::PlaneID{ 0, 0, 0}));
402  BOOST_TEST( data.hasTPC(geo::PlaneID{ 0, 0, 1}));
403  BOOST_TEST( data.hasTPC(geo::PlaneID{ 0, 0, 2}));
404  BOOST_TEST( data.hasTPC(geo::PlaneID{ 0, 1, 0}));
405  BOOST_TEST( data.hasTPC(geo::PlaneID{ 0, 1, 1}));
406  BOOST_TEST( data.hasTPC(geo::PlaneID{ 0, 1, 2}));
407  BOOST_TEST( data.hasTPC(geo::PlaneID{ 0, 2, 0}));
408  BOOST_TEST( data.hasTPC(geo::PlaneID{ 0, 2, 1}));
409  BOOST_TEST( data.hasTPC(geo::PlaneID{ 0, 2, 2}));
410  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 0, 3, 0}));
411  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 0, 3, 1}));
412  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 0, 3, 2}));
413  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 0, 4, 0}));
414  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 0, 4, 1}));
415  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 0, 4, 2}));
416  BOOST_TEST( data.hasTPC(geo::PlaneID{ 1, 0, 0}));
417  BOOST_TEST( data.hasTPC(geo::PlaneID{ 1, 0, 1}));
418  BOOST_TEST( data.hasTPC(geo::PlaneID{ 1, 0, 2}));
419  BOOST_TEST( data.hasTPC(geo::PlaneID{ 1, 1, 0}));
420  BOOST_TEST( data.hasTPC(geo::PlaneID{ 1, 1, 1}));
421  BOOST_TEST( data.hasTPC(geo::PlaneID{ 1, 1, 2}));
422  BOOST_TEST( data.hasTPC(geo::PlaneID{ 1, 2, 0}));
423  BOOST_TEST( data.hasTPC(geo::PlaneID{ 1, 2, 1}));
424  BOOST_TEST( data.hasTPC(geo::PlaneID{ 1, 2, 2}));
425  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 1, 3, 0}));
426  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 1, 3, 1}));
427  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 1, 3, 2}));
428  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 1, 4, 0}));
429  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 1, 4, 1}));
430  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 1, 4, 2}));
431  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 0, 0}));
432  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 0, 1}));
433  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 0, 2}));
434  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 1, 0}));
435  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 1, 1}));
436  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 1, 2}));
437  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 2, 0}));
438  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 2, 1}));
439  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 2, 2}));
440  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 3, 0}));
441  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 3, 1}));
442  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 3, 2}));
443  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 4, 0}));
444  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 4, 1}));
445  BOOST_TEST(!data.hasTPC(geo::PlaneID{ 2, 4, 2}));
446 
447  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 0, 0}));
448  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 0, 1}));
449  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 0, 2}));
450  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 1, 0}));
451  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 1, 1}));
452  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 1, 2}));
453  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 2, 0}));
454  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 2, 1}));
455  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 2, 2}));
456  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 3, 0}));
457  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 3, 1}));
458  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 3, 2}));
459  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 4, 0}));
460  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 4, 1}));
461  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 0, 4, 2}));
462  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 0, 0}));
463  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 0, 1}));
464  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 0, 2}));
465  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 1, 0}));
466  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 1, 1}));
467  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 1, 2}));
468  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 2, 0}));
469  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 2, 1}));
470  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 2, 2}));
471  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 3, 0}));
472  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 3, 1}));
473  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 3, 2}));
474  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 4, 0}));
475  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 4, 1}));
476  BOOST_TEST( data.hasCryostat(geo::PlaneID{ 1, 4, 2}));
477  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 0, 0}));
478  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 0, 1}));
479  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 0, 2}));
480  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 1, 0}));
481  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 1, 1}));
482  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 1, 2}));
483  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 2, 0}));
484  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 2, 1}));
485  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 2, 2}));
486  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 3, 0}));
487  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 3, 1}));
488  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 3, 2}));
489  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 4, 0}));
490  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 4, 1}));
491  BOOST_TEST(!data.hasCryostat(geo::PlaneID{ 2, 4, 2}));
492 
493 
494  data[{0, 0, 0}] = 4;
495  BOOST_TEST( (data[{0, 0, 0}]) == 4);
496  BOOST_TEST(data.at({0, 0, 0}) == 4);
497  data[{0, 0, 0}] = 5;
498  BOOST_TEST( (data[{0, 0, 0}]) == 5);
499  BOOST_TEST(data.at({0, 0, 0}) == 5);
500 
501  data[{0, 0, 1}] = 6;
502  BOOST_TEST( (data[{0, 0, 1}]) == 6);
503  BOOST_TEST(data.at({0, 0, 1}) == 6);
504 
505  BOOST_TEST( (data[{0, 0, 0}]) == 5);
506 
507  data[{0, 1, 0}] = 15;
508  BOOST_TEST( (data[{0, 1, 0}]) == 15);
509  BOOST_TEST(data.at({0, 1, 0}) == 15);
510 
511  BOOST_TEST( (data[{0, 0, 0}]) == 5);
512  BOOST_TEST( (data[{0, 0, 1}]) == 6);
513 
514  data[{0, 1, 1}] = 16;
515  BOOST_TEST( (data[{0, 1, 1}]) == 16);
516  BOOST_TEST(data.at({0, 1, 1}) == 16);
517 
518  BOOST_TEST( (data[{0, 0, 0}]) == 5);
519  BOOST_TEST( (data[{0, 0, 1}]) == 6);
520  BOOST_TEST( (data[{0, 1, 0}]) == 15);
521 
522  data[{0, 2, 0}] = 25;
523  BOOST_TEST( (data[{0, 2, 0}]) == 25);
524  BOOST_TEST(data.at({0, 2, 0}) == 25);
525 
526  BOOST_TEST( (data[{0, 0, 0}]) == 5);
527  BOOST_TEST( (data[{0, 0, 1}]) == 6);
528  BOOST_TEST( (data[{0, 1, 0}]) == 15);
529  BOOST_TEST( (data[{0, 1, 1}]) == 16);
530 
531  data[{0, 2, 1}] = 26;
532  BOOST_TEST( (data[{0, 2, 1}]) == 26);
533  BOOST_TEST(data.at({0, 2, 1}) == 26);
534 
535  BOOST_TEST( (data[{0, 0, 0}]) == 5);
536  BOOST_TEST( (data[{0, 0, 1}]) == 6);
537  BOOST_TEST( (data[{0, 1, 0}]) == 15);
538  BOOST_TEST( (data[{0, 1, 1}]) == 16);
539  BOOST_TEST( (data[{0, 2, 0}]) == 25);
540 
541  data[{1, 0, 0}] = 105;
542  BOOST_TEST( (data[{1, 0, 0}]) == 105);
543  BOOST_TEST(data.at({1, 0, 0}) == 105);
544 
545  BOOST_TEST( (data[{0, 0, 0}]) == 5);
546  BOOST_TEST( (data[{0, 0, 1}]) == 6);
547  BOOST_TEST( (data[{0, 1, 0}]) == 15);
548  BOOST_TEST( (data[{0, 1, 1}]) == 16);
549  BOOST_TEST( (data[{0, 2, 0}]) == 25);
550  BOOST_TEST( (data[{0, 2, 1}]) == 26);
551 
552  data[{1, 0, 1}] = 106;
553  BOOST_TEST( (data[{1, 0, 1}]) == 106);
554  BOOST_TEST(data.at({1, 0, 1}) == 106);
555 
556  BOOST_TEST( (data[{0, 0, 0}]) == 5);
557  BOOST_TEST( (data[{0, 0, 1}]) == 6);
558  BOOST_TEST( (data[{0, 1, 0}]) == 15);
559  BOOST_TEST( (data[{0, 1, 1}]) == 16);
560  BOOST_TEST( (data[{0, 2, 0}]) == 25);
561  BOOST_TEST( (data[{0, 2, 1}]) == 26);
562  BOOST_TEST( (data[{1, 0, 0}]) == 105);
563 
564  data[{1, 1, 0}] = 115;
565  BOOST_TEST( (data[{1, 1, 0}]) == 115);
566  BOOST_TEST(data.at({1, 1, 0}) == 115);
567 
568  BOOST_TEST( (data[{0, 0, 0}]) == 5);
569  BOOST_TEST( (data[{0, 0, 1}]) == 6);
570  BOOST_TEST( (data[{0, 1, 0}]) == 15);
571  BOOST_TEST( (data[{0, 1, 1}]) == 16);
572  BOOST_TEST( (data[{0, 2, 0}]) == 25);
573  BOOST_TEST( (data[{0, 2, 1}]) == 26);
574  BOOST_TEST( (data[{1, 0, 0}]) == 105);
575  BOOST_TEST( (data[{1, 0, 1}]) == 106);
576 
577  data[{1, 1, 1}] = 116;
578  BOOST_TEST( (data[{1, 1, 1}]) == 116);
579  BOOST_TEST(data.at({1, 1, 1}) == 116);
580 
581  BOOST_TEST( (data[{0, 0, 0}]) == 5);
582  BOOST_TEST( (data[{0, 0, 1}]) == 6);
583  BOOST_TEST( (data[{0, 1, 0}]) == 15);
584  BOOST_TEST( (data[{0, 1, 1}]) == 16);
585  BOOST_TEST( (data[{0, 2, 0}]) == 25);
586  BOOST_TEST( (data[{0, 2, 1}]) == 26);
587  BOOST_TEST( (data[{1, 0, 0}]) == 105);
588  BOOST_TEST( (data[{1, 0, 1}]) == 106);
589  BOOST_TEST( (data[{1, 1, 0}]) == 115);
590 
591  data[{1, 2, 0}] = 125;
592  BOOST_TEST( (data[{1, 2, 0}]) == 125);
593  BOOST_TEST(data.at({1, 2, 0}) == 125);
594 
595  BOOST_TEST((data[{0, 0, 0}]) == 5);
596  BOOST_TEST((data[{0, 0, 1}]) == 6);
597  BOOST_TEST((data[{0, 1, 0}]) == 15);
598  BOOST_TEST((data[{0, 1, 1}]) == 16);
599  BOOST_TEST((data[{0, 2, 0}]) == 25);
600  BOOST_TEST((data[{0, 2, 1}]) == 26);
601  BOOST_TEST((data[{1, 0, 0}]) == 105);
602  BOOST_TEST((data[{1, 0, 1}]) == 106);
603  BOOST_TEST((data[{1, 1, 0}]) == 115);
604  BOOST_TEST((data[{1, 1, 1}]) == 116);
605 
606  data[{1, 2, 1}] = 126;
607  BOOST_TEST( (data[{1, 2, 1}]) == 126);
608  BOOST_TEST(data.at({1, 2, 1}) == 126);
609 
610  BOOST_TEST((data[{0, 0, 0}]) == 5);
611  BOOST_TEST((data[{0, 0, 1}]) == 6);
612  BOOST_TEST((data[{0, 1, 0}]) == 15);
613  BOOST_TEST((data[{0, 1, 1}]) == 16);
614  BOOST_TEST((data[{0, 2, 0}]) == 25);
615  BOOST_TEST((data[{0, 2, 1}]) == 26);
616  BOOST_TEST((data[{1, 0, 0}]) == 105);
617  BOOST_TEST((data[{1, 0, 1}]) == 106);
618  BOOST_TEST((data[{1, 1, 0}]) == 115);
619  BOOST_TEST((data[{1, 1, 1}]) == 116);
620  BOOST_TEST((data[{1, 2, 0}]) == 125);
621 
622 
623  BOOST_CHECK_THROW(data.at({0, 3, 0}), std::out_of_range);
624  BOOST_CHECK_THROW(data.at({0, 4, 0}), std::out_of_range);
625  BOOST_CHECK_THROW(data.at({1, 3, 0}), std::out_of_range);
626  BOOST_CHECK_THROW(data.at({1, 4, 0}), std::out_of_range);
627  BOOST_CHECK_THROW(data.at({2, 0, 0}), std::out_of_range);
628  BOOST_CHECK_THROW(data.at({2, 1, 0}), std::out_of_range);
629  BOOST_CHECK_THROW(data.at({2, 2, 0}), std::out_of_range);
630  BOOST_CHECK_THROW(data.at({2, 3, 0}), std::out_of_range);
631  BOOST_CHECK_THROW(data.at({2, 4, 0}), std::out_of_range);
632  BOOST_CHECK_THROW(data.at({0, 3, 1}), std::out_of_range);
633  BOOST_CHECK_THROW(data.at({0, 4, 1}), std::out_of_range);
634  BOOST_CHECK_THROW(data.at({1, 3, 1}), std::out_of_range);
635  BOOST_CHECK_THROW(data.at({1, 4, 1}), std::out_of_range);
636  BOOST_CHECK_THROW(data.at({2, 0, 1}), std::out_of_range);
637  BOOST_CHECK_THROW(data.at({2, 1, 1}), std::out_of_range);
638  BOOST_CHECK_THROW(data.at({2, 2, 1}), std::out_of_range);
639  BOOST_CHECK_THROW(data.at({2, 3, 1}), std::out_of_range);
640  BOOST_CHECK_THROW(data.at({2, 4, 1}), std::out_of_range);
641  BOOST_CHECK_THROW(data.at({0, 0, 2}), std::out_of_range);
642  BOOST_CHECK_THROW(data.at({0, 1, 2}), std::out_of_range);
643  BOOST_CHECK_THROW(data.at({0, 2, 2}), std::out_of_range);
644  BOOST_CHECK_THROW(data.at({0, 3, 2}), std::out_of_range);
645  BOOST_CHECK_THROW(data.at({1, 0, 2}), std::out_of_range);
646  BOOST_CHECK_THROW(data.at({1, 1, 2}), std::out_of_range);
647  BOOST_CHECK_THROW(data.at({1, 2, 2}), std::out_of_range);
648  BOOST_CHECK_THROW(data.at({1, 3, 2}), std::out_of_range);
649  BOOST_CHECK_THROW(data.at({2, 0, 2}), std::out_of_range);
650  BOOST_CHECK_THROW(data.at({2, 1, 2}), std::out_of_range);
651  BOOST_CHECK_THROW(data.at({2, 2, 2}), std::out_of_range);
652  BOOST_CHECK_THROW(data.at({2, 3, 2}), std::out_of_range);
653 
654  BOOST_TEST(data.first() == 5);
655  data.first() = -5;
656  BOOST_TEST((data[{0, 0, 0}]) == -5);
657  BOOST_TEST(data.first() == -5);
658  data.first() = 5;
659 
660  BOOST_TEST(data.last() == 126);
661  data.last() = -126;
662  BOOST_TEST((data[{1U, 2U, 1U}]) == -126);
663  BOOST_TEST(data.last() == -126);
664  data.last() = 126;
665 
666  auto const& constData = data;
667 
668  static_assert(data.dimensions() == 3U);
669  BOOST_TEST(data.dimSize<0U>() == NCryostats);
670  BOOST_TEST(data.dimSize<1U>() == NTPCs);
671  BOOST_TEST(data.dimSize<2U>() == NPlanes);
672  BOOST_TEST(data.dimSize<3U>() == 0U);
673 
674  BOOST_TEST
675  (std::addressof(constData.first()) == std::addressof(data.first()));
676  BOOST_TEST
677  (std::addressof(constData.last()) == std::addressof(data.last()));
678 
679  BOOST_TEST((constData[{0, 0, 0}]) == (data[{0, 0, 0}]));
680  BOOST_TEST((constData[{0, 0, 1}]) == (data[{0, 0, 1}]));
681  BOOST_TEST((constData[{0, 1, 0}]) == (data[{0, 1, 0}]));
682  BOOST_TEST((constData[{0, 1, 1}]) == (data[{0, 1, 1}]));
683  BOOST_TEST((constData[{0, 2, 0}]) == (data[{0, 2, 0}]));
684  BOOST_TEST((constData[{0, 2, 1}]) == (data[{0, 2, 1}]));
685  BOOST_TEST((constData[{1, 0, 0}]) == (data[{1, 0, 0}]));
686  BOOST_TEST((constData[{1, 0, 1}]) == (data[{1, 0, 1}]));
687  BOOST_TEST((constData[{1, 1, 0}]) == (data[{1, 1, 0}]));
688  BOOST_TEST((constData[{1, 1, 1}]) == (data[{1, 1, 1}]));
689  BOOST_TEST((constData[{1, 2, 0}]) == (data[{1, 2, 0}]));
690  BOOST_TEST((constData[{1, 2, 1}]) == (data[{1, 2, 1}]));
691  BOOST_TEST(constData.at({0, 0, 0}) == data.at({0, 0, 0}));
692  BOOST_TEST(constData.at({0, 0, 1}) == data.at({0, 0, 1}));
693  BOOST_TEST(constData.at({0, 1, 0}) == data.at({0, 1, 0}));
694  BOOST_TEST(constData.at({0, 1, 1}) == data.at({0, 1, 1}));
695  BOOST_TEST(constData.at({0, 2, 0}) == data.at({0, 2, 0}));
696  BOOST_TEST(constData.at({0, 2, 1}) == data.at({0, 2, 1}));
697  BOOST_TEST(constData.at({1, 0, 0}) == data.at({1, 0, 0}));
698  BOOST_TEST(constData.at({1, 0, 1}) == data.at({1, 0, 1}));
699  BOOST_TEST(constData.at({1, 1, 0}) == data.at({1, 1, 0}));
700  BOOST_TEST(constData.at({1, 1, 1}) == data.at({1, 1, 1}));
701  BOOST_TEST(constData.at({1, 2, 0}) == data.at({1, 2, 0}));
702  BOOST_TEST(constData.at({1, 2, 1}) == data.at({1, 2, 1}));
703 
704  BOOST_CHECK_THROW(constData.at({0, 3, 0}), std::out_of_range);
705  BOOST_CHECK_THROW(constData.at({0, 4, 0}), std::out_of_range);
706  BOOST_CHECK_THROW(constData.at({1, 3, 0}), std::out_of_range);
707  BOOST_CHECK_THROW(constData.at({1, 4, 0}), std::out_of_range);
708  BOOST_CHECK_THROW(constData.at({2, 0, 0}), std::out_of_range);
709  BOOST_CHECK_THROW(constData.at({2, 1, 0}), std::out_of_range);
710  BOOST_CHECK_THROW(constData.at({2, 2, 0}), std::out_of_range);
711  BOOST_CHECK_THROW(constData.at({2, 3, 0}), std::out_of_range);
712  BOOST_CHECK_THROW(constData.at({2, 4, 0}), std::out_of_range);
713  BOOST_CHECK_THROW(constData.at({0, 3, 1}), std::out_of_range);
714  BOOST_CHECK_THROW(constData.at({0, 4, 1}), std::out_of_range);
715  BOOST_CHECK_THROW(constData.at({1, 3, 1}), std::out_of_range);
716  BOOST_CHECK_THROW(constData.at({1, 4, 1}), std::out_of_range);
717  BOOST_CHECK_THROW(constData.at({2, 0, 1}), std::out_of_range);
718  BOOST_CHECK_THROW(constData.at({2, 1, 1}), std::out_of_range);
719  BOOST_CHECK_THROW(constData.at({2, 2, 1}), std::out_of_range);
720  BOOST_CHECK_THROW(constData.at({2, 3, 1}), std::out_of_range);
721  BOOST_CHECK_THROW(constData.at({2, 4, 1}), std::out_of_range);
722  BOOST_CHECK_THROW(constData.at({0, 0, 2}), std::out_of_range);
723  BOOST_CHECK_THROW(constData.at({0, 1, 2}), std::out_of_range);
724  BOOST_CHECK_THROW(constData.at({0, 2, 2}), std::out_of_range);
725  BOOST_CHECK_THROW(constData.at({0, 3, 2}), std::out_of_range);
726  BOOST_CHECK_THROW(constData.at({1, 0, 2}), std::out_of_range);
727  BOOST_CHECK_THROW(constData.at({1, 1, 2}), std::out_of_range);
728  BOOST_CHECK_THROW(constData.at({1, 2, 2}), std::out_of_range);
729  BOOST_CHECK_THROW(constData.at({1, 3, 2}), std::out_of_range);
730  BOOST_CHECK_THROW(constData.at({2, 0, 2}), std::out_of_range);
731  BOOST_CHECK_THROW(constData.at({2, 1, 2}), std::out_of_range);
732  BOOST_CHECK_THROW(constData.at({2, 2, 2}), std::out_of_range);
733  BOOST_CHECK_THROW(constData.at({2, 3, 2}), std::out_of_range);
734 
735 
736  auto const cb = constData.begin();
737  auto const ce = constData.end();
738  BOOST_TEST(static_cast<size_t>(ce - cb) == N);
739 
740  // simple read-only iteration test
741  expected_index = 0U;
742  for (auto& value: constData) {
743  static_assert(std::is_same_v
744  <decltype(value), std::decay_t<decltype(constData)>::const_reference>
745  );
746 
747  geo::PlaneID const expected_ID = constData.mapper().ID(expected_index);
748  BOOST_TEST(value == constData[expected_ID]);
749 
750  ++expected_index;
751  } // for
752  BOOST_TEST(constData.size() == expected_index);
753 
754  // ID/data pair read-only iteration test
755  expected_index = 0U;
756  for (auto&& [ ID, value ]: constData.items()) {
757  static_assert(std::is_same_v<decltype(ID), geo::PlaneID>);
758  static_assert(std::is_same_v
759  <decltype(value), std::decay_t<decltype(constData)>::const_reference>
760  );
761 
762  geo::PlaneID const expected_ID = constData.mapper().ID(expected_index);
763  BOOST_TEST(ID == expected_ID);
764  BOOST_TEST(value == constData[expected_ID]);
765 
766  ++expected_index;
767  } // for
768  BOOST_TEST(constData.size() == expected_index);
769 
770 
771  data.fill(14);
772  for (auto c: util::counter<unsigned int>(NCryostats))
773  for (auto t: util::counter<unsigned int>(NTPCs))
774  for (auto p: util::counter<unsigned int>(NPlanes))
775  BOOST_TEST((data[{ c, t, p }]) == 14);
776 
777  data.apply([](int& v){ v *= 2; });
778  for (auto c: util::counter<unsigned int>(NCryostats))
779  for (auto t: util::counter<unsigned int>(NTPCs))
780  for (auto p: util::counter<unsigned int>(NPlanes))
781  BOOST_TEST((data[{ c, t, p }]) == 28);
782 
783  Summer<int> summer;
784  static_assert(std::is_same_v<decltype(data.apply(summer)), Summer<int>&>);
785  data.apply(summer);
786  BOOST_TEST(summer.get() == N * 28);
787 
788  summer.reset();
789  static_assert
790  (std::is_same_v<decltype(constData.apply(summer)), Summer<int>&>);
791  constData.apply(summer);
792  BOOST_TEST(summer.get() == N * 28);
793 
794  auto summer1 = data.apply(Summer<int>{});
795  BOOST_TEST(summer1.get() == N * 28);
796 
797  auto summer2 = constData.apply(Summer<int>{});
798  BOOST_TEST(summer2.get() == N * 28);
799 
800  data.reset();
801  for (auto c: util::counter<unsigned int>(NCryostats))
802  for (auto t: util::counter<unsigned int>(NTPCs))
803  for (auto p: util::counter<unsigned int>(NPlanes))
804  BOOST_TEST((data[{ c, t, p }]) == 0);
805 
806  data.clear();
807  BOOST_TEST(data.empty());
808 
809 } // PlaneDataContainerTest()
void reset()
Sets all the elements to a default-constructed value_type.
GeoID firstID() const
Returns the ID of the first element with GeoID type.
GeoID lastID() const
Returns the ID of the last covered element with GeoID type.
pdgs p
Definition: selectors.fcl:22
size_type capacity() const
Returns the number of elements the container has memory for.
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
reference last()
Returns the element for the last ID (unchecked).
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
reference first()
Returns the element for the first ID (unchecked).
void clear()
Makes the container empty, with no usable storage space.
static constexpr unsigned int dimensions()
Dimensions of the ID of this container.
void fill(value_type value)
Sets all elements to the specified value (copied).
process_name largeant stream1 can override from command line with o or output physics producers generator N
temporary value
size_type size() const
Returns the number of elements in the container.
bool empty() const
Returns whether the container has no elements (false by assumptions).
unsigned int dimSize() const
Dimensions of the Level dimension of this container.
Op apply(Op &&op)
Applies an operation on all elements.
void TPCDataContainerTest ( geo::TPCDataContainer< int >  data,
std::size_t const  NCryostats,
std::size_t const  NTPCs 
)

Definition at line 33 of file geometrydatacontainers_test.cxx.

36  {
37 
38  std::size_t const N = NCryostats * NTPCs;
39 
40  static_assert(data.dimensions() == 2U);
41  BOOST_TEST(data.dimSize<0U>() == NCryostats);
42  BOOST_TEST(data.dimSize<1U>() == NTPCs);
43  BOOST_TEST(data.dimSize<2U>() == 0U);
44  BOOST_TEST(data.dimSize<3U>() == 0U);
45 
46  BOOST_TEST(!data.empty());
47  BOOST_TEST(data.size() == N);
48  BOOST_TEST(data.capacity() >= N);
49 
50  for (auto c: util::counter<unsigned int>(NCryostats))
51  for (auto t: util::counter<unsigned int>(NTPCs))
52  BOOST_TEST((data[{ c, t }]) == 0);
53 
54  BOOST_TEST(data.firstID() == geo::TPCID(0, 0));
55  BOOST_TEST(data.lastID() == geo::TPCID(1, 2));
56 
57 
58  std::size_t expected_index = 0U;
59 
60  // simple R/W iteration test
61  for (auto& value: data) {
62  static_assert(std::is_same_v<decltype(value), decltype(data)::reference>);
63 
64  geo::TPCID const expected_ID = data.mapper().ID(expected_index);
65  BOOST_TEST(value == data[expected_ID]);
66 
67  ++expected_index;
68  } // for
69  BOOST_TEST(data.size() == expected_index);
70 
71  // ID/data pair R/W iteration test
72  expected_index = 0U;
73  for (auto&& [ ID, value ]: data.items()) {
74  static_assert(std::is_same_v<decltype(ID), geo::TPCID>);
75  static_assert(std::is_same_v<decltype(value), decltype(data)::reference>);
76 
77  geo::TPCID const expected_ID = data.mapper().ID(expected_index);
78  BOOST_TEST(ID == expected_ID);
79  BOOST_TEST(value == data[expected_ID]);
80 
81  ++expected_index;
82  } // for
83  BOOST_TEST(data.size() == expected_index);
84 
85 
86  BOOST_TEST( data.hasTPC({ 0, 0}));
87  BOOST_TEST( data.hasTPC({ 0, 1}));
88  BOOST_TEST( data.hasTPC({ 0, 2}));
89  BOOST_TEST(!data.hasTPC({ 0, 3}));
90  BOOST_TEST(!data.hasTPC({ 0, 4}));
91  BOOST_TEST( data.hasTPC({ 1, 0}));
92  BOOST_TEST( data.hasTPC({ 1, 1}));
93  BOOST_TEST( data.hasTPC({ 1, 2}));
94  BOOST_TEST(!data.hasTPC({ 1, 3}));
95  BOOST_TEST(!data.hasTPC({ 1, 4}));
96  BOOST_TEST(!data.hasTPC({ 2, 0}));
97  BOOST_TEST(!data.hasTPC({ 2, 1}));
98  BOOST_TEST(!data.hasTPC({ 2, 2}));
99  BOOST_TEST(!data.hasTPC({ 2, 3}));
100  BOOST_TEST(!data.hasTPC({ 2, 4}));
101 
102  BOOST_TEST( data.hasCryostat(geo::TPCID{ 0, 0}));
103  BOOST_TEST( data.hasCryostat(geo::TPCID{ 0, 1}));
104  BOOST_TEST( data.hasCryostat(geo::TPCID{ 0, 2}));
105  BOOST_TEST( data.hasCryostat(geo::TPCID{ 0, 3}));
106  BOOST_TEST( data.hasCryostat(geo::TPCID{ 0, 4}));
107  BOOST_TEST( data.hasCryostat(geo::TPCID{ 1, 0}));
108  BOOST_TEST( data.hasCryostat(geo::TPCID{ 1, 1}));
109  BOOST_TEST( data.hasCryostat(geo::TPCID{ 1, 2}));
110  BOOST_TEST( data.hasCryostat(geo::TPCID{ 1, 3}));
111  BOOST_TEST( data.hasCryostat(geo::TPCID{ 1, 4}));
112  BOOST_TEST(!data.hasCryostat(geo::TPCID{ 2, 0}));
113  BOOST_TEST(!data.hasCryostat(geo::TPCID{ 2, 1}));
114  BOOST_TEST(!data.hasCryostat(geo::TPCID{ 2, 2}));
115  BOOST_TEST(!data.hasCryostat(geo::TPCID{ 2, 3}));
116  BOOST_TEST(!data.hasCryostat(geo::TPCID{ 2, 4}));
117 
118  data[{0, 0}] = 4;
119  BOOST_TEST((data[{0, 0}]) == 4);
120  BOOST_TEST(data.at({0, 0}) == 4);
121  data[{0, 0}] = 5;
122  BOOST_TEST((data[{0, 0}]) == 5);
123  BOOST_TEST(data.at({0, 0}) == 5);
124 
125  data[{0, 1}] = 6;
126  BOOST_TEST((data[{0, 1}]) == 6);
127  BOOST_TEST(data.at({0, 1}) == 6);
128 
129  BOOST_TEST((data[{0, 0}]) == 5);
130 
131  data[{0, 2}] = 7;
132  BOOST_TEST((data[{0, 2}]) == 7);
133  BOOST_TEST(data.at({0, 2}) == 7);
134 
135  BOOST_TEST((data[{0, 0}]) == 5);
136  BOOST_TEST((data[{0, 1}]) == 6);
137 
138  data[{1, 0}] = 15;
139  BOOST_TEST((data[{1, 0}]) == 15);
140  BOOST_TEST(data.at({1, 0}) == 15);
141 
142  BOOST_TEST((data[{0, 0}]) == 5);
143  BOOST_TEST((data[{0, 1}]) == 6);
144  BOOST_TEST((data[{0, 2}]) == 7);
145 
146  data[{1, 1}] = 16;
147  BOOST_TEST((data[{1, 1}]) == 16);
148  BOOST_TEST(data.at({1, 1}) == 16);
149 
150  BOOST_TEST((data[{0, 0}]) == 5);
151  BOOST_TEST((data[{0, 1}]) == 6);
152  BOOST_TEST((data[{0, 2}]) == 7);
153  BOOST_TEST((data[{1, 0}]) == 15);
154 
155  data[{1, 2}] = 17;
156  BOOST_TEST((data[{1, 2}]) == 17);
157  BOOST_TEST(data.at({1, 2}) == 17);
158 
159  BOOST_TEST((data[{0, 0}]) == 5);
160  BOOST_TEST((data[{0, 1}]) == 6);
161  BOOST_TEST((data[{0, 2}]) == 7);
162  BOOST_TEST((data[{1, 0}]) == 15);
163  BOOST_TEST((data[{1, 1}]) == 16);
164 
165  BOOST_CHECK_THROW(data.at({0, 3}), std::out_of_range);
166  BOOST_CHECK_THROW(data.at({0, 4}), std::out_of_range);
167  BOOST_CHECK_THROW(data.at({1, 3}), std::out_of_range);
168  BOOST_CHECK_THROW(data.at({1, 4}), std::out_of_range);
169  BOOST_CHECK_THROW(data.at({2, 0}), std::out_of_range);
170  BOOST_CHECK_THROW(data.at({2, 1}), std::out_of_range);
171  BOOST_CHECK_THROW(data.at({2, 2}), std::out_of_range);
172  BOOST_CHECK_THROW(data.at({2, 3}), std::out_of_range);
173  BOOST_CHECK_THROW(data.at({2, 4}), std::out_of_range);
174 
175  BOOST_TEST(data.first() == 5);
176  data.first() = -5;
177  BOOST_TEST((data[{0, 0}]) == -5);
178  BOOST_TEST(data.first() == -5);
179  data.first() = 5;
180 
181  BOOST_TEST(data.last() == 17);
182  data.last() = -17;
183  BOOST_TEST((data[{1U, 2U}]) == -17);
184  BOOST_TEST(data.last() == -17);
185  data.last() = 17;
186 
187  auto const& constData = data;
188 
189  BOOST_TEST(constData.size() == N);
190 
191  static_assert(std::decay_t<decltype(constData)>::dimensions() == 2U);
192  BOOST_TEST(constData.dimSize<0U>() == NCryostats);
193  BOOST_TEST(constData.dimSize<1U>() == NTPCs);
194  BOOST_TEST(constData.dimSize<2U>() == 0U);
195  BOOST_TEST(constData.dimSize<3U>() == 0U);
196 
197  BOOST_TEST
198  (std::addressof(constData.first()) == std::addressof(data.first()));
199  BOOST_TEST
200  (std::addressof(constData.last()) == std::addressof(data.last()));
201 
202  BOOST_TEST((constData[{0, 0}]) == (data[{0, 0}]));
203  BOOST_TEST((constData[{0, 1}]) == (data[{0, 1}]));
204  BOOST_TEST((constData[{0, 2}]) == (data[{0, 2}]));
205  BOOST_TEST((constData[{1, 0}]) == (data[{1, 0}]));
206  BOOST_TEST((constData[{1, 1}]) == (data[{1, 1}]));
207  BOOST_TEST((constData[{1, 2}]) == (data[{1, 2}]));
208  BOOST_TEST(constData.at({0, 0}) == data.at({0, 0}));
209  BOOST_TEST(constData.at({0, 1}) == data.at({0, 1}));
210  BOOST_TEST(constData.at({0, 2}) == data.at({0, 2}));
211  BOOST_TEST(constData.at({1, 0}) == data.at({1, 0}));
212  BOOST_TEST(constData.at({1, 1}) == data.at({1, 1}));
213  BOOST_TEST(constData.at({1, 2}) == data.at({1, 2}));
214 
215  BOOST_CHECK_THROW(constData.at({0, 3}), std::out_of_range);
216  BOOST_CHECK_THROW(constData.at({0, 4}), std::out_of_range);
217  BOOST_CHECK_THROW(constData.at({1, 3}), std::out_of_range);
218  BOOST_CHECK_THROW(constData.at({1, 4}), std::out_of_range);
219  BOOST_CHECK_THROW(constData.at({2, 0}), std::out_of_range);
220  BOOST_CHECK_THROW(constData.at({2, 1}), std::out_of_range);
221  BOOST_CHECK_THROW(constData.at({2, 2}), std::out_of_range);
222  BOOST_CHECK_THROW(constData.at({2, 3}), std::out_of_range);
223  BOOST_CHECK_THROW(constData.at({2, 4}), std::out_of_range);
224 
225 
226  auto const cb = constData.begin();
227  auto const ce = constData.end();
228  BOOST_TEST(static_cast<size_t>(ce - cb) == N);
229 
230  // simple read-only iteration test
231  expected_index = 0U;
232  for (auto& value: constData) {
233  static_assert(std::is_same_v
234  <decltype(value), std::decay_t<decltype(constData)>::const_reference>
235  );
236 
237  geo::TPCID const expected_ID = constData.mapper().ID(expected_index);
238  BOOST_TEST(value == constData[expected_ID]);
239 
240  ++expected_index;
241  } // for
242  BOOST_TEST(constData.size() == expected_index);
243 
244  // ID/data pair read-only iteration test
245  expected_index = 0U;
246  for (auto&& [ ID, value ]: constData.items()) {
247  static_assert(std::is_same_v<decltype(ID), geo::TPCID>);
248  static_assert(std::is_same_v
249  <decltype(value), std::decay_t<decltype(constData)>::const_reference>
250  );
251 
252  geo::TPCID const expected_ID = constData.mapper().ID(expected_index);
253  BOOST_TEST(ID == expected_ID);
254  BOOST_TEST(value == constData[expected_ID]);
255 
256  ++expected_index;
257  } // for
258  BOOST_TEST(constData.size() == expected_index);
259 
260 
261  data.fill(14);
262  for (auto c: util::counter<unsigned int>(NCryostats))
263  for (auto t: util::counter<unsigned int>(NTPCs))
264  BOOST_TEST((data[{ c, t }]) == 14);
265 
266  data.apply([](int& v){ v *= 2; });
267  for (auto c: util::counter<unsigned int>(NCryostats))
268  for (auto t: util::counter<unsigned int>(NTPCs))
269  BOOST_TEST((data[{ c, t }]) == 28);
270 
271  Summer<int> summer;
272  static_assert(std::is_same_v<decltype(data.apply(summer)), Summer<int>&>);
273  data.apply(summer);
274  BOOST_TEST(summer.get() == N * 28);
275 
276  summer.reset();
277  static_assert
278  (std::is_same_v<decltype(constData.apply(summer)), Summer<int>&>);
279  constData.apply(summer);
280  BOOST_TEST(summer.get() == N * 28);
281 
282  auto summer1 = data.apply(Summer<int>{});
283  BOOST_TEST(summer1.get() == N * 28);
284 
285  auto summer2 = constData.apply(Summer<int>{});
286  BOOST_TEST(summer2.get() == N * 28);
287 
288  data.reset();
289  for (auto c: util::counter<unsigned int>(NCryostats))
290  for (auto t: util::counter<unsigned int>(NTPCs))
291  BOOST_TEST((data[{ c, t }]) == 0);
292 
293  data.clear();
294  BOOST_TEST(data.empty());
295 
296 } // TPCDataContainerTest()
void reset()
Sets all the elements to a default-constructed value_type.
GeoID firstID() const
Returns the ID of the first element with GeoID type.
GeoID lastID() const
Returns the ID of the last covered element with GeoID type.
size_type capacity() const
Returns the number of elements the container has memory for.
reference last()
Returns the element for the last ID (unchecked).
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
reference first()
Returns the element for the first ID (unchecked).
void clear()
Makes the container empty, with no usable storage space.
static constexpr unsigned int dimensions()
Dimensions of the ID of this container.
void fill(value_type value)
Sets all elements to the specified value (copied).
process_name largeant stream1 can override from command line with o or output physics producers generator N
temporary value
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
size_type size() const
Returns the number of elements in the container.
bool empty() const
Returns whether the container has no elements (false by assumptions).
unsigned int dimSize() const
Dimensions of the Level dimension of this container.
Op apply(Op &&op)
Applies an operation on all elements.