Public Member Functions | Protected Attributes | List of all members
geo::ChannelMapStandardTestAlg Class Reference

#include <ChannelMapStandardTestAlg.h>

Public Member Functions

 ChannelMapStandardTestAlg (fhicl::ParameterSet const &)
 Constructor: reads configuration, does nothing. More...
 
virtual ~ChannelMapStandardTestAlg ()=default
 Virtual destructor. More...
 
virtual void Setup (geo::GeometryCore const &new_geo)
 Algorithm set up. More...
 
virtual unsigned int Run ()
 Executes the test. More...
 
void TPCsetMappingTest () const
 Tests TPCset mappings. More...
 
void ROPMappingTest () const
 Tests ROP mappings. More...
 
void ChannelMappingTest () const
 Tests channel mappings (very, very partial) More...
 

Protected Attributes

GeometryCore const * geom = nullptr
 pointer to the geometry description More...
 

Detailed Description

Definition at line 22 of file ChannelMapStandardTestAlg.h.

Constructor & Destructor Documentation

geo::ChannelMapStandardTestAlg::ChannelMapStandardTestAlg ( fhicl::ParameterSet const &  )
inline

Constructor: reads configuration, does nothing.

Definition at line 26 of file ChannelMapStandardTestAlg.h.

26 {}
virtual geo::ChannelMapStandardTestAlg::~ChannelMapStandardTestAlg ( )
virtualdefault

Virtual destructor.

Member Function Documentation

void geo::ChannelMapStandardTestAlg::ChannelMappingTest ( ) const

Tests channel mappings (very, very partial)

Definition at line 298 of file ChannelMapStandardTestAlg.cxx.

298  {
299 
300  /*
301  * ChannelMapStandardAlg interface being tested (via GeometryCore):
302  *
303  * unsigned int Nchannels() const
304  * (only called, not checked)
305  *
306  * unsigned int HasChannel(raw::ChannelID_t) const
307  *
308  * The rest is not tested here.
309  */
310 
311  // check for invalid input
312  BOOST_TEST(!geom->HasChannel(raw::InvalidChannelID));
313 
314  //
315  // channel-wide checks
316  //
317  unsigned int const NChannels = geom->Nchannels();
318  for (unsigned int iChannel = 0; iChannel < NChannels; ++iChannel) {
320 
321  BOOST_TEST_MESSAGE("channel: " << channel);
322 
323  BOOST_TEST(geom->HasChannel(iChannel));
324 
325  } // for channels
326  BOOST_TEST(!geom->HasChannel((raw::ChannelID_t) NChannels));
327 
328 } // ChannelMapStandardTestAlg::ChannelMappingTest()
uint8_t channel
Definition: CRTFragment.hh:201
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
GeometryCore const * geom
pointer to the geometry description
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
bool HasChannel(raw::ChannelID_t channel) const
Returns whether the specified channel exists and is valid.
void geo::ChannelMapStandardTestAlg::ROPMappingTest ( ) const

Tests ROP mappings.

Definition at line 182 of file ChannelMapStandardTestAlg.cxx.

182  {
183 
184  /*
185  * ChannelMapStandardAlg interface to be tested (via GeometryCore):
186  *
187  * unsigned int Nchannels(readout::ROPID const& ropid) const
188  *
189  * readout::ROPID WirePlaneToROP(geo::PlaneID const& planeid) const
190  *
191  * std::vector<geo::PlaneID> ROPtoWirePlanes
192  * (readout::ROPID const& ropid) const
193  *
194  * std::vector<geo::TPCID> ROPtoTPCs(readout::ROPID const& ropid) const
195  *
196  * readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
197  *
198  * raw::ChannelID_t FirstChannelInROP(readout::ROPID const& ropid) const
199  *
200  * geo::PlaneID FirstWirePlaneInROP(readout::ROPID const& ropid) const
201  * can't do (not exposed!)
202  *
203  */
204 
205  // check for invalid input
206  BOOST_TEST(geom->Nchannels({}) == 0U);
207  BOOST_TEST(!geom->WirePlaneToROP({}).isValid);
208  BOOST_TEST(geom->ROPtoWirePlanes({}).empty());
209  BOOST_TEST(geom->ROPtoTPCs({}).empty());
211  BOOST_TEST(!raw::isValidChannelID(geom->FirstChannelInROP({})));
212 
213  //
214  // TPC-wide checks
215  //
216  for (geo::TPCID const& tpcID: geom->IterateTPCIDs()) {
217  BOOST_TEST_CHECKPOINT("TPC: " << std::string(tpcID));
218 
219  // build a non-existent ROP ID (but we pretend it valid)
220  readout::TPCsetID const tpcsetID = geom->TPCtoTPCset(tpcID);
221  unsigned int const NROPs = geom->NROPs(tpcsetID);
222  readout::ROPID NonexistingROPID(tpcsetID, (readout::ROPID::ROPID_t) NROPs);
223 
224  // check that we don't have ROPs beyond the last one
225  BOOST_TEST(!geom->HasROP(NonexistingROPID));
226  // the behaviour of the other methods is undefined for non-existent ROPs
227  // BOOST_TEST(geom->ROPtoTPCs(NonexistingROPID).empty());
228  // BOOST_TEST(geom->ROPtoWirePlanes(NonexistingROPID).empty());
229  // BOOST_TEST(geom->Nchannels(NonexistingROPID) == 0U);
230  // BOOST_TEST
231  // (!raw::isValidChannelID(geom->FirstChannelInROP(NonexistingROPID)));
232 
233  } // for TPCs
234 
235 
236  //
237  // plane-wide checks
238  //
239  for (geo::PlaneID const& planeID: geom->IteratePlaneIDs()) {
240  BOOST_TEST_MESSAGE("plane: " << std::string(planeID));
241 
242  // check that the ROP of this plane matches the plane itself
243  readout::ROPID const ropID = geom->WirePlaneToROP(planeID);
244  CheckMatchingPlaneLevelIDs(ropID, planeID);
245 
246  /*
247  // ChannelMapStandardAlg::FirstWirePlaneInROP() is not accessible from
248  // GeometryCore: this test is disabled
249  // check that the first (and only) plane is the expected one
250  BOOST_TEST(geom->FirstWirePlaneInROP(ropID) == planeID);
251  */
252 
253  // check that there is only one plane in this ROP
254  std::vector<geo::PlaneID> const PlanesInROP = geom->ROPtoWirePlanes(ropID);
255  BOOST_TEST(PlanesInROP.size() == 1U);
256  BOOST_TEST(PlanesInROP.front() == planeID);
257 
258  // check that the number of channels in the ROP matches the number of wires
259  unsigned int const NChannels = geom->Nchannels(ropID);
260  BOOST_TEST(NChannels == geom->Nwires(planeID));
261 
262  // check that the TPC is one, and the right one
263  std::vector<geo::TPCID> const TPCs = geom->ROPtoTPCs(ropID);
264  BOOST_TEST(TPCs.size() == 1U);
265  BOOST_TEST(TPCs.front() == planeID.asTPCID());
266 
267  // check that the first channel is valid
268  raw::ChannelID_t const FirstChannelID = geom->FirstChannelInROP(ropID);
269  BOOST_TEST(raw::isValidChannelID(FirstChannelID) == ropID.isValid);
270 
271  // check all the channels:
272  for (
273  unsigned int iChannelInROP = 0; iChannelInROP < NChannels; ++iChannelInROP
274  ) {
275  raw::ChannelID_t const channelID = FirstChannelID + iChannelInROP;
276 
277  BOOST_TEST_CHECKPOINT("channel: " << channelID);
278 
279  // is it in the right plane? and only one?
280  std::vector<geo::WireID> const ChannelWires
281  = geom->ChannelToWire(channelID);
282  BOOST_TEST(ChannelWires.size() == 1U);
283  BOOST_TEST(ChannelWires.front() == planeID);
284 
285  // does the channel map back to the right ROP?
286  readout::ROPID const ChannelROPID = geom->ChannelToROP(channelID);
287  BOOST_TEST(ChannelROPID == ropID);
288 
289  } // for channels
290 
291  } // for planes
292 
293 
294 } // ChannelMapStandardTestAlg::ROPMappingTest()
std::vector< geo::TPCID > ROPtoTPCs(readout::ROPID const &ropid) const
Returns a list of ID of TPCs the specified ROP spans.
std::string string
Definition: nybbler.cc:12
unsigned int ROPID_t
Type for the ID number.
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:211
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
readout::ROPID WirePlaneToROP(geo::PlaneID const &planeid) const
Returns the ID of the ROP planeid belongs to.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
readout::TPCsetID TPCtoTPCset(geo::TPCID const &tpcid) const
Returns the ID of the TPC set tpcid belongs to.
IteratorBox< TPC_id_iterator,&GeometryCore::begin_TPC_id,&GeometryCore::end_TPC_id > IterateTPCIDs() const
Enables ranged-for loops on all TPC IDs of the detector.
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
IteratorBox< plane_id_iterator,&GeometryCore::begin_plane_id,&GeometryCore::end_plane_id > IteratePlaneIDs() const
Enables ranged-for loops on all plane IDs of the detector.
bool HasROP(readout::ROPID const &ropid) const
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const
Returns the ID of the first channel in the specified readout plane.
constexpr bool isValidChannelID(raw::ChannelID_t channel)
Definition: RawTypes.h:37
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
Class identifying a set of planes sharing readout channels.
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
GeometryCore const * geom
pointer to the geometry description
std::vector< geo::PlaneID > ROPtoWirePlanes(readout::ROPID const &ropid) const
Returns a list of ID of planes belonging to the specified ROP.
unsigned int NROPs(readout::TPCsetID const &tpcsetid) const
Returns the total number of ROP in the specified TPC set.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
unsigned int geo::ChannelMapStandardTestAlg::Run ( )
virtual

Executes the test.

Definition at line 51 of file ChannelMapStandardTestAlg.cxx.

51  {
52  // All the tests
53 
57 
58  return 0;
59 } // ChannelMapStandardTestAlg::Run()
void ChannelMappingTest() const
Tests channel mappings (very, very partial)
void ROPMappingTest() const
Tests ROP mappings.
void TPCsetMappingTest() const
Tests TPCset mappings.
virtual void geo::ChannelMapStandardTestAlg::Setup ( geo::GeometryCore const &  new_geo)
inlinevirtual

Algorithm set up.

Definition at line 32 of file ChannelMapStandardTestAlg.h.

32 { geom = &new_geo; }
GeometryCore const * geom
pointer to the geometry description
void geo::ChannelMapStandardTestAlg::TPCsetMappingTest ( ) const

Tests TPCset mappings.

Definition at line 64 of file ChannelMapStandardTestAlg.cxx.

64  {
65 
66  /*
67  * ChannelMapStandardAlg interface to be tested (via GeometryCore):
68  *
69  * unsigned int NTPCsets(readout::CryostatID const& cryoid) const
70  *
71  * unsigned int MaxTPCsets() const
72  *
73  * bool HasTPCset(readout::TPCsetID const& tpcsetid) const
74  *
75  * readout::TPCsetID TPCtoTPCset(geo::TPCID const& tpcid) const
76  *
77  * std::vector<geo::TPCID> TPCsetToTPCs
78  * (readout::TPCsetID const& tpcsetid) const
79  *
80  * geo::TPCID FirstTPCinTPCset(readout::TPCsetID const& tpcsetid) const
81  * can't do (not exposed!)
82  *
83  * unsigned int NROPs(readout::TPCsetID const& tpcsetid) const
84  *
85  * unsigned int MaxROPs() const
86  *
87  * bool HasROP(readout::ROPID const& ropid) const
88  * (invalid input is checked in ROPMappingTest())
89  *
90  * std::vector<geo::TPCID> ROPtoTPCs(readout::ROPID const& ropid) const
91  *
92  */
93 
94  // check for invalid input
95  BOOST_TEST(geom->NTPCsets({}) == 0U);
96  BOOST_TEST(!geom->HasTPCset({}));
97  BOOST_TEST(!geom->TPCtoTPCset({}).isValid);
98  BOOST_TEST(geom->TPCsetToTPCs({}).empty());
99  BOOST_TEST(geom->NROPs({}) == 0U);
100  BOOST_TEST(!geom->HasROP({}));
101  BOOST_TEST(geom->ROPtoTPCs({}).empty());
102 
103  //
104  // detector-wide checks
105  //
106  // check that the maximum size of TPC and TPC sets in the detector match
107  BOOST_TEST(geom->MaxTPCsets() == geom->MaxTPCs());
108 
109  // check that the maximum size of planes and ROPs in the detector match
110  BOOST_TEST(geom->MaxROPs() == geom->MaxPlanes());
111 
112  // check that we have no TPC set in cryostats after the last one
113  readout::CryostatID const NonexistingCryostatID(geom->Ncryostats());
114  BOOST_TEST(geom->NTPCsets(NonexistingCryostatID) == 0U);
115 
116  //
117  // cryostat-wide checks
118  //
119  for (geo::CryostatID const& cryostatID: geom->IterateCryostatIDs()) {
120  BOOST_TEST_CHECKPOINT("cryostat: " << std::string(cryostatID));
121 
122  readout::CryostatID const ROcryostatID
123  = static_cast<readout::CryostatID const&>(cryostatID);
124 
125  // check that the number of TPC and TPC sets in each cryostat match
126  unsigned int const NTPCsets = geom->NTPCsets(ROcryostatID);
127  BOOST_TEST(NTPCsets == geom->NTPC(cryostatID));
128 
129  // check that we have no TPC set after the last one
130  readout::TPCsetID const NonexistingTPCsetID
131  (ROcryostatID, (readout::TPCsetID::TPCsetID_t) NTPCsets);
132  BOOST_TEST(!geom->HasTPCset(NonexistingTPCsetID));
133  BOOST_TEST(geom->NROPs(NonexistingTPCsetID) == 0U);
134  // the behaviour of the other methods is undefined for non-existent ROPs
135  // BOOST_TEST(geom->TPCsetToTPCs(NonexistingTPCsetID).empty());
136 
137  } // for cryostats
138 
139  //
140  // TPC-wide checks
141  //
142  for (geo::TPCID const& tpcID: geom->IterateTPCIDs()) {
143  BOOST_TEST_CHECKPOINT("TPC: " << std::string(tpcID));
144 
145  // check that the IDs of this TPC and of the TPC set including it match
146  readout::TPCsetID const tpcsetID = geom->TPCtoTPCset(tpcID);
147  CheckMatchingTPClevelIDs(tpcsetID, tpcID);
148 
149  // check that this TPC set maps to only one (and the right one) TPC
150  std::vector<geo::TPCID> TPCs = geom->TPCsetToTPCs(tpcsetID);
151  BOOST_TEST(TPCs.size() == 1U);
152  BOOST_TEST(TPCs.front() == tpcID);
153 
154  // check that the number of ROP in the TPC set matches the planes in the TPC
155  unsigned int const NROPs = geom->NROPs(tpcsetID);
156  BOOST_TEST(NROPs == geom->Nplanes(tpcID));
157 
158  // check all the ROPs:
159  for (unsigned int iROPinTPCset = 0; iROPinTPCset < NROPs; ++iROPinTPCset) {
160  readout::ROPID const ropID
161  (tpcsetID, (readout::ROPID::ROPID_t) iROPinTPCset);
162 
163  BOOST_TEST_CHECKPOINT("ROP: " << std::string(ropID));
164 
165  // do we have it?
166  BOOST_TEST(geom->HasROP(ropID));
167 
168  // is it in the right TPC? and only one?
169  std::vector<geo::TPCID> TPCs = geom->ROPtoTPCs(ropID);
170  BOOST_TEST(TPCs.size() == 1U);
171  BOOST_TEST(TPCs.front() == tpcID);
172 
173  } // for channels
174 
175  } // for TPCs
176 
177 
178 } // ChannelMapStandardTestAlg::TPCsetMappingTest()
std::vector< geo::TPCID > ROPtoTPCs(readout::ROPID const &ropid) const
Returns a list of ID of TPCs the specified ROP spans.
std::string string
Definition: nybbler.cc:12
unsigned int ROPID_t
Type for the ID number.
unsigned short TPCsetID_t
Type for the ID number.
Definition: readout_types.h:71
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:211
unsigned int MaxROPs() const
Returns the largest number of ROPs a TPC set in the detector has.
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
unsigned int NTPCsets(readout::CryostatID const &cryoid) const
Returns the total number of TPC sets in the specified cryostat.
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
readout::TPCsetID TPCtoTPCset(geo::TPCID const &tpcid) const
Returns the ID of the TPC set tpcid belongs to.
IteratorBox< TPC_id_iterator,&GeometryCore::begin_TPC_id,&GeometryCore::end_TPC_id > IterateTPCIDs() const
Enables ranged-for loops on all TPC IDs of the detector.
bool HasROP(readout::ROPID const &ropid) const
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
Class identifying a set of planes sharing readout channels.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
GeometryCore const * geom
pointer to the geometry description
unsigned int MaxTPCsets() const
Returns the largest number of TPC sets any cryostat in the detector has.
IteratorBox< cryostat_id_iterator,&GeometryCore::begin_cryostat_id,&GeometryCore::end_cryostat_id > IterateCryostatIDs() const
Enables ranged-for loops on all cryostat IDs of the detector.
unsigned int NROPs(readout::TPCsetID const &tpcsetid) const
Returns the total number of ROP in the specified TPC set.
std::vector< geo::TPCID > TPCsetToTPCs(readout::TPCsetID const &tpcsetid) const
Returns a list of ID of TPCs belonging to the specified TPC set.
unsigned int MaxTPCs() const
Returns the largest number of TPCs a cryostat in the detector has.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
bool HasTPCset(readout::TPCsetID const &tpcsetid) const

Member Data Documentation

GeometryCore const* geo::ChannelMapStandardTestAlg::geom = nullptr
protected

pointer to the geometry description

Definition at line 47 of file ChannelMapStandardTestAlg.h.


The documentation for this class was generated from the following files: