GeometryGeoIDTestAlg.cxx
Go to the documentation of this file.
1 /**
2  * @file GeometryGeoIDTestAlg.cxx
3  * @brief Unit test for geometry iterators
4  * @date October 31, 2016
5  * @author Gianluca Petrillo (petrillo@fnal.gov)
6  *
7  * The methods require a Boost test environment.
8  */
9 
10 // LArSoft libraries
14 
15 // Boost libraries
16 #include <boost/test/unit_test.hpp>
17 
18 // C/C++ standard libraries
19 #include <type_traits>
20 
21 
22 
23 //-----------------------------------------------------------------------------
24 unsigned int geo::GeometryGeoIDTestAlg::Run() const {
25  // All the tests
26 
28  TPCGeoIDTest();
30  WireGeoIDTest();
31 
32  return 0;
33 } // GeometryGeoIDTestAlg::Run()
34 
35 
36 
37 //-----------------------------------------------------------------------------
39 
40  auto iCryo = geom->begin_cryostat_id();
41  for (geo::CryostatGeo const& cryostat: geom->IterateCryostats()) {
42 
43  geo::CryostatID const& ID = cryostat.ID();
44 
45  // the ID of this CryostatGeo is the expected one in a sequential scheme:
46  BOOST_TEST(ID == *iCryo);
47 
48  // the ID of this CryostatGeo is associated to the CryostatGeo itself
49  auto const& cryostatFromID = geom->Cryostat(ID);
50  BOOST_TEST(&cryostat == &cryostatFromID);
51 
52 
53  ++iCryo;
54  } // for cryostat
55 
56 } // GeometryGeoIDTestAlg::CryostatGeoIDTest()
57 
58 
59 
60 //-----------------------------------------------------------------------------
62 
63  auto iTPC = geom->begin_TPC_id();
64  for (geo::TPCGeo const& tpc: geom->IterateTPCs()) {
65 
66  geo::TPCID const& ID = tpc.ID();
67 
68  // the ID of this TPCGeo is the expected one in a sequential scheme:
69  BOOST_TEST(ID == *iTPC);
70 
71  // the ID of this TPCGeo is associated to the TPCGeo itself
72  auto const& TPCFromID = geom->TPC(ID);
73  BOOST_TEST(&tpc == &TPCFromID);
74 
75 
76  ++iTPC;
77  } // for TPC
78 
79 } // GeometryGeoIDTestAlg::TPCGeoIDTest()
80 
81 
82 
83 //-----------------------------------------------------------------------------
85 
86  auto iPlane = geom->begin_plane_id();
87  for (geo::PlaneGeo const& plane: geom->IteratePlanes()) {
88 
89  geo::PlaneID const& ID = plane.ID();
90 
91  // the ID of this PlaneGeo is the expected one in a sequential scheme:
92  BOOST_TEST(ID == *iPlane);
93 
94  // the ID of this PlaneGeo is associated to the PlaneGeo itself
95  auto const& planeFromID = geom->Plane(ID);
96  BOOST_TEST(&plane == &planeFromID);
97 
98 
99  ++iPlane;
100  } // for plane
101 
102 } // GeometryGeoIDTestAlg::PlaneGeoIDTest()
103 
104 
105 
106 //-----------------------------------------------------------------------------
108 
109  auto iWire = geom->begin_wire_id();
110  for (geo::WireGeo const& wire [[gnu::unused]]: geom->IterateWires()) {
111 
112  // this test is disabled since geo::WireID does not support ID()
113  // (as of LArSoft 6.13)
114  /*
115  geo::WireID const& ID = wire.ID();
116 
117  // the ID of this WireGeo is the expected one in a sequential scheme:
118  BOOST_TEST(ID == *iWire);
119 
120  // the ID of this WireGeo is associated to the WireGeo itself
121  auto const& wireFromID = geom->Wire(ID);
122  BOOST_TEST(&wire == &wireFromID);
123  */
124 
125  ++iWire;
126  } // for wire
127 
128 } // GeometryGeoIDTestAlg::WireGeoIDTest()
129 
130 
131 //-----------------------------------------------------------------------------
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
GeometryCore const * geom
pointer to the geometry description
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
TPC_id_iterator begin_TPC_id() const
Returns an iterator pointing to the first TPC ID in the detector.
IteratorBox< wire_iterator,&GeometryCore::begin_wire,&GeometryCore::end_wire > IterateWires() const
Enables ranged-for loops on all wires of the detector.
IteratorBox< plane_iterator,&GeometryCore::begin_plane,&GeometryCore::end_plane > IteratePlanes() const
Enables ranged-for loops on all planes of the detector.
unsigned int ID
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Geometry information for a single TPC.
Definition: TPCGeo.h:38
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
Tests the correct assignment of IDs to detector geometry objects.
IteratorBox< TPC_iterator,&GeometryCore::begin_TPC,&GeometryCore::end_TPC > IterateTPCs() const
Enables ranged-for loops on all TPCs of the detector.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
unsigned int Run() const
Executes the test.
Definition of data types for geometry description.
IteratorBox< cryostat_iterator,&GeometryCore::begin_cryostat,&GeometryCore::end_cryostat > IterateCryostats() const
Enables ranged-for loops on all cryostats of the detector.
cryostat_id_iterator begin_cryostat_id() const
Returns an iterator pointing to the first cryostat ID.
Access the description of detector geometry.
plane_id_iterator begin_plane_id() const
Returns an iterator pointing to the first plane ID in the detector.
wire_id_iterator begin_wire_id() const
Returns an iterator pointing to the first wire ID in the detector.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190