All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
geo::GeometryIteratorLoopTestAlg Class Reference

#include <GeometryIteratorLoopTestAlg.h>

Public Member Functions

 GeometryIteratorLoopTestAlg (fhicl::ParameterSet const &)
 Constructor: reads configuration, does nothing. More...
 
virtual ~GeometryIteratorLoopTestAlg ()=default
 Virtual destructor. More...
 
virtual void Setup (geo::GeometryCore const &new_geo)
 Algorithm set up. More...
 
virtual unsigned int Run ()
 Executes the test. More...
 

Protected Attributes

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

Detailed Description

Definition at line 22 of file GeometryIteratorLoopTestAlg.h.

Constructor & Destructor Documentation

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

Constructor: reads configuration, does nothing.

Definition at line 26 of file GeometryIteratorLoopTestAlg.h.

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

Virtual destructor.

Member Function Documentation

unsigned int geo::GeometryIteratorLoopTestAlg::Run ( )
virtual

Executes the test.

Definition at line 29 of file GeometryIteratorLoopTestAlg.cxx.

29  {
30 
31  /*
32  * This monstrous test looks through the elements of the geometry.
33  * It is structured as follows:
34  *
35  * - loop on cryostats by index
36  * * check global cryostat iterators (ID and element)
37  * - loop on TPCs by index
38  * * check global TPC iterators (ID and element)
39  * * check local TPC iterators (cryostat)
40  * - loop on planes by index
41  * * check global plane iterators (ID and element)
42  * * check local plane iterators (cryostat and TPC)
43  * - loop on wires by index
44  * * check global wire iterators (ID and element)
45  * * check local wire iterators (cryostat, TPC and plane)
46  * * increase wire iterators (also cryostat, TPC and plane locals)
47  * * increase plane iterators (including cryostat and TPC locals)
48  * * loops by range-for with local wire iterators
49  * * increase TPC iterators (including cryostat locals)
50  * * loops by range-for with local plane and wire iterators
51  * * check cryostat-local iterators (TPC, plane, wire IDs and elements)
52  * * loops by range-for with local TPC, plane and wire iterators
53  * - loop on TPC sets by index
54  * * check global TPC set iterators (ID)
55  * - loop on readout planes by index
56  * * check global readout plane iterators (ID)
57  * - loop on channels by channel ID (currently disabled)
58  * * increase readout plane iterators
59  * * check local readout plane iterators (TPC set)
60  * * loops by range-for with local iterators (TPC set)
61  * * increase TPC set iterators
62  * * check local TPC set and readout plane iterators (cryostat)
63  * * loops by range-for with local iterators (TPC set and readout plane)
64  * - loops by range-for
65  * * by cryostat ID
66  * * by cryostat
67  * * by TPC ID
68  * * by TPC
69  * * by plane ID
70  * * by plane
71  * * by wire ID
72  * * by wire
73  * * by TPC set ID
74  * * by TPC set
75  * * by readout plane ID
76  * * by readout plane
77  *
78  * In words: the test is structured in two almost-independent parts.
79  * In the first, nested loops are driven by element indices.
80  * In the second, range-for loops are implemented. The number of loops in
81  * here is compared to the number of iterations recorded in the first
82  * section (hence the dependence of the second part from the first one).
83  * For the elements with both ID and geometry class (cryostat, TPC, plane
84  * and wire) both types of iterators, on ID and on element, are checked,
85  * while the ones lacking an element class (TPC set, readout plane) only
86  * the ID iterators are tested. The same holds for range-for loops too.
87  *
88  * In each index loop, a loop of the contained element is nested. Also,
89  * the iterators concerning the indexed element are checked. Finally,
90  * range-for loops are rolled for iterators local to the element.
91  * For example, each iteration of the TPC loop includes a wire plane loop,
92  * a check on TPC iterators (both global and local to the cryostat), and
93  * a range-for loop on planes and wires on the TPC.
94  *
95  * Cryostat loop contains tests for both TPCs and TPC sets.
96  *
97  */
98 
99 
100  const unsigned int nCryo = geom->Ncryostats();
101  MF_LOG_VERBATIM("GeometryIteratorLoopTest")
102  << "We have " << nCryo << " cryostats";
103 
104  unsigned int nErrors = 0;
105  unsigned int nCryostats = 0, nTPCs = 0, nPlanes = 0, nWires = 0,
106  cumTPCsets = 0, cumROPs = 0;
108  = geom->begin_cryostat_id();
112 
113  auto iTPCsetID = geom->begin_TPCset_id();
114  auto iROPID = geom->begin_ROP_id();
115  // no channel iterator implemented
116 
121 
122  geo::CryostatID runningCID{ 0 };
123  geo::TPCID runningTID{ runningCID, 0 };
124  geo::PlaneID runningPID{ runningTID, 0 };
125  geo::WireID runningWID{ runningPID, 0 };
126  readout::TPCsetID runningSID{ runningCID, 0 };
127  readout::ROPID runningRID{ runningSID, 0 };
128 
129  for(unsigned int c = 0; c < nCryo; ++c) {
130  const geo::CryostatID expCID(c);
131  const CryostatGeo& cryo(geom->Cryostat(c));
132  const unsigned int nTPC = cryo.NTPC();
133  const unsigned int nTPCsets = geom->NTPCsets(expCID);
134 
135  MF_LOG_TRACE("GeometryIteratorLoopTest") << " C=" << c
136  << " (" << nTPC << " TPCs, " << nTPCsets << " TPC sets)";
137 
138  if (runningCID != expCID) {
139  MF_LOG_ERROR("GeometryIteratorLoopTest")
140  << "Cryostat ID incremented to " << runningCID << ", expected: "
141  << expCID;
142  ++nErrors;
143  }
144 
145  if (!iCryostatID) {
146  MF_LOG_ERROR("GeometryIteratorLoopTest")
147  << "Cryostat ID iterator thinks it's all over at C=" << c;
148  ++nErrors;
149  }
150  else if (iCryostatID->Cryostat != c) {
151  MF_LOG_ERROR("GeometryIteratorLoopTest")
152  << "Cryostat ID iterator thinks it's at C=" << (*iCryostatID)
153  << " instead of " << c;
154  ++nErrors;
155  }
156  else if (iCryostatID.get() != &cryo) {
157  MF_LOG_ERROR("GeometryIteratorLoopTest")
158  << "Cryostat ID iterator retrieves CryostatGeo["
159  << ((void*) iCryostatID.get())
160  << "] instead of [" << ((void*) &cryo) << "]";
161  ++nErrors;
162  }
163 
164  if (&*iCryostat != &cryo) {
165  MF_LOG_ERROR("GeometryIteratorLoopTest")
166  << "Cryostat iterator retrieves CryostatGeo["
167  << ((void*) iCryostat.get())
168  << "] (" << iCryostat.ID() << ") instead of ["
169  << ((void*) &cryo) << "] (C=" << c << ")";
170  ++nErrors;
171  }
172 
173  geo::TPC_id_iterator iTPCIDinCryo = geom->begin_TPC_id(expCID);
174  geo::TPC_iterator iTPCinCryo = geom->begin_TPC(expCID);
175  geo::plane_id_iterator iPlaneIDinCryo = geom->begin_plane_id(expCID);
176  geo::plane_iterator iPlaneInCryo = geom->begin_plane(expCID);
177  geo::wire_id_iterator iWireIDinCryo = geom->begin_wire_id(expCID);
178  geo::wire_iterator iWireInCryo = geom->begin_wire(expCID);
179 
180  unsigned int nPlanesInCryo = 0;
181  unsigned int nWiresInCryo = 0;
182 
183  for(unsigned int t = 0; t < nTPC; ++t){
184  const TPCGeo& TPC(cryo.TPC(t));
185  const geo::TPCID expTID(expCID, t);
186  const unsigned int NPlanes = TPC.Nplanes();
187 
188  MF_LOG_TRACE("GeometryIteratorLoopTest") << " " << expTID
189  << " (" << NPlanes << " planes)";
190 
191  if (runningTID != expTID) {
192  MF_LOG_ERROR("GeometryIteratorLoopTest")
193  << "TPC ID incremented to " << runningTID << ", expected: "
194  << expTID;
195  ++nErrors;
196  }
197 
198  if (!iTPCID) {
199  MF_LOG_ERROR("GeometryIteratorLoopTest")
200  << "TPC ID iterator thinks it's all over at " << expTID;
201  ++nErrors;
202  }
203  else if (iTPCID->Cryostat != c) {
204  MF_LOG_ERROR("GeometryIteratorLoopTest")
205  << "TPC ID iterator thinks it's at C=" << iTPCID->Cryostat
206  << " instead of " << c;
207  ++nErrors;
208  }
209  else if (iTPCID->TPC != t) {
210  MF_LOG_ERROR("GeometryIteratorLoopTest")
211  << "TPC ID iterator thinks it's at T=" << iTPCID->TPC
212  << " instead of " << t;
213  ++nErrors;
214  }
215  else if (iTPCID.get() != &TPC) {
216  MF_LOG_ERROR("GeometryIteratorLoopTest")
217  << "TPC ID iterator retrieves TPCGeo[" << ((void*) iTPCID.get())
218  << "] instead of [" << ((void*) &TPC) << "]";
219  ++nErrors;
220  }
221 
222  if (&*iTPC != &TPC) {
223  MF_LOG_ERROR("GeometryIteratorLoopTest")
224  << "TPC iterator retrieves TPCGeo[" << ((void*) iTPC.get())
225  << "] (" << iTPC.ID() << ") instead of [" << ((void*) &TPC)
226  << "] (" << expTID << ")";
227  ++nErrors;
228  }
229 
230  if (*iTPCIDinCryo != expTID) {
231  MF_LOG_ERROR("GeometryIteratorLoopTest")
232  << "TPC ID local iterator in " << expCID
233  << " points to " << *iTPCIDinCryo << " instead of " << expTID;
234  ++nErrors;
235  }
236  if (iTPCinCryo->ID() != expTID) {
237  MF_LOG_ERROR("GeometryIteratorLoopTest")
238  << "TPC local iterator in " << expCID
239  << " points to " << iTPCinCryo->ID() << " instead of " << expTID;
240  ++nErrors;
241  }
242 
243  geo::plane_id_iterator iPlaneIDinTPC = geom->begin_plane_id(expTID);
244  geo::plane_iterator iPlaneInTPC = geom->begin_plane(expTID);
245  geo::wire_id_iterator iWireIDinTPC = geom->begin_wire_id(expTID);
246  geo::wire_iterator iWireInTPC = geom->begin_wire(expTID);
247 
248  unsigned int nPlanesInTPC = 0;
249  unsigned int nWiresInTPC = 0;
250 
251  for(unsigned int p = 0; p < NPlanes; ++p) {
252  const PlaneGeo& Plane(TPC.Plane(p));
253  geo::PlaneID const expPID(expTID, p);
254  const unsigned int NWires = Plane.Nwires();
255 
256  MF_LOG_TRACE("GeometryIteratorLoopTest") << " " << expTID
257  << " (" << NWires << " wires)";
258 
259  if (runningPID != expPID) {
260  MF_LOG_ERROR("GeometryIteratorLoopTest")
261  << "Plane ID incremented to " << runningPID << ", expected: "
262  << expPID;
263  ++nErrors;
264  }
265  if (!iPlaneID) {
266  MF_LOG_ERROR("GeometryIteratorLoopTest")
267  << "plane ID iterator thinks it's all over at " << expPID;
268  ++nErrors;
269  }
270  else if (iPlaneID->Cryostat != c) {
271  MF_LOG_ERROR("GeometryIteratorLoopTest")
272  << "plane ID iterator thinks it's at C=" << iPlaneID->Cryostat
273  << " instead of " << c;
274  ++nErrors;
275  }
276  else if (iPlaneID->TPC != t) {
277  MF_LOG_ERROR("GeometryIteratorLoopTest")
278  << "plane ID iterator thinks it's at T=" << iPlaneID->TPC
279  << " instead of " << t;
280  ++nErrors;
281  }
282  else if (iPlaneID->Plane != p) {
283  MF_LOG_ERROR("GeometryIteratorLoopTest")
284  << "plane ID iterator thinks it's at P=" << iPlaneID->Plane
285  << " instead of " << p;
286  ++nErrors;
287  }
288  else if (iPlaneID.get() != &Plane) {
289  MF_LOG_ERROR("GeometryIteratorLoopTest")
290  << "plane ID iterator retrieves PlaneGeo["
291  << ((void*) iPlaneID.get()) << "] instead of ["
292  << ((void*) &Plane) << "]";
293  ++nErrors;
294  }
295 
296  if (&*iPlane != &Plane) {
297  MF_LOG_ERROR("GeometryIteratorLoopTest")
298  << "plane iterator retrieves PlaneGeo[" << ((void*) iPlane.get())
299  << "] instead of [" << ((void*) &Plane) << "] (" << expPID << ")";
300  ++nErrors;
301  }
302 
303  if (*iPlaneIDinCryo != expPID) {
304  MF_LOG_ERROR("GeometryIteratorLoopTest")
305  << "Plane ID local iterator in " << expCID << " points to "
306  << *iPlaneIDinCryo << " instead of " << expPID;
307  ++nErrors;
308  }
309  if (iPlaneInCryo->ID() != expPID) {
310  MF_LOG_ERROR("GeometryIteratorLoopTest")
311  << "Plane local iterator in " << expCID << " points to "
312  << iPlaneInCryo.ID() << " instead of " << expPID;
313  ++nErrors;
314  }
315 
316  if (*iPlaneIDinTPC != expPID) {
317  MF_LOG_ERROR("GeometryIteratorLoopTest")
318  << "Plane ID local iterator in " << expTID << " points to "
319  << *iPlaneIDinTPC << " instead of " << expPID;
320  ++nErrors;
321  }
322  if (iPlaneInTPC->ID() != expPID) {
323  MF_LOG_ERROR("GeometryIteratorLoopTest")
324  << "Plane local iterator in " << expTID << " points to "
325  << iPlaneInTPC.ID() << " instead of " << expPID;
326  ++nErrors;
327  }
328 
329  geo::wire_id_iterator iWireIDinPlane = geom->begin_wire_id(expPID);
330  geo::wire_iterator iWireInPlane = geom->begin_wire(expPID);
331 
332  unsigned int nWiresInPlane = 0; // will become same as NWires
333 
334  for(unsigned int w = 0; w < NWires; ++w) {
335  const WireGeo& Wire(Plane.Wire(w));
336  geo::WireID const expWID(expPID, w);
337 
338  if (runningWID != expWID) {
339  MF_LOG_ERROR("GeometryIteratorLoopTest")
340  << "Wire ID incremented to " << runningWID << ", expected: "
341  << expWID;
342  ++nErrors;
343  }
344 
345  MF_LOG_TRACE("GeometryIteratorLoopTest") << " " << expWID;
346  if (!iWireID) {
347  MF_LOG_ERROR("GeometryIteratorLoopTest")
348  << "wire ID iterator thinks it's all over at " << expWID;
349  ++nErrors;
350  }
351  else if (iWireID->Cryostat != c) {
352  MF_LOG_ERROR("GeometryIteratorLoopTest")
353  << "wire ID iterator thinks it's at C=" << iWireID->Cryostat
354  << " instead of " << c;
355  ++nErrors;
356  }
357  else if (iWireID->TPC != t) {
358  MF_LOG_ERROR("GeometryIteratorLoopTest")
359  << "wire ID iterator thinks it's at T=" << iWireID->TPC
360  << " instead of " << t;
361  ++nErrors;
362  }
363  else if (iWireID->Plane != p) {
364  MF_LOG_ERROR("GeometryIteratorLoopTest")
365  << "wire ID iterator thinks it's at P=" << iWireID->Plane
366  << " instead of " << p;
367  ++nErrors;
368  }
369  else if (iWireID->Wire != w) {
370  MF_LOG_ERROR("GeometryIteratorLoopTest")
371  << "wire ID iterator thinks it's at W=" << iWireID->Wire
372  << " instead of " << w;
373  ++nErrors;
374  }
375  else if (iWireID.get() != &Wire) {
376  MF_LOG_ERROR("GeometryIteratorLoopTest")
377  << "wire ID iterator retrieves WireGeo["
378  << ((void*) iWireID.get())
379  << "] instead of [" << ((void*) &Wire) << "]";
380  ++nErrors;
381  }
382 
383  if (&*iWire != &Wire) {
384  MF_LOG_ERROR("GeometryIteratorLoopTest")
385  << "wire iterator retrieves WireGeo[" << ((void*) iWire.get())
386  << "] instead of [" << ((void*) &Wire) << "] (" << expWID
387  << ")";
388  ++nErrors;
389  }
390 
391  if (*iWireIDinCryo != expWID) {
392  MF_LOG_ERROR("GeometryIteratorLoopTest")
393  << "Wire ID local iterator in " << expCID << " points to "
394  << *iWireIDinCryo << " instead of " << expWID;
395  ++nErrors;
396  }
397  if (iWireInCryo.ID() != expWID) {
398  MF_LOG_ERROR("GeometryIteratorLoopTest")
399  << "Wire local iterator in " << expCID << " points to "
400  << iWireInCryo.ID() << " instead of " << expWID;
401  ++nErrors;
402  }
403  if (*iWireIDinTPC != expWID) {
404  MF_LOG_ERROR("GeometryIteratorLoopTest")
405  << "Wire ID local iterator in " << expTID << " points to "
406  << *iWireIDinTPC << " instead of " << expWID;
407  ++nErrors;
408  }
409  if (iWireInTPC.ID() != expWID) {
410  MF_LOG_ERROR("GeometryIteratorLoopTest")
411  << "Wire local iterator in " << expTID << " points to "
412  << iWireInTPC.ID() << " instead of " << expWID;
413  ++nErrors;
414  }
415  if (*iWireIDinPlane != expWID) {
416  MF_LOG_ERROR("GeometryIteratorLoopTest")
417  << "Wire ID local iterator in " << expPID << " points to "
418  << *iWireIDinPlane << " instead of " << expWID;
419  ++nErrors;
420  }
421  if (iWireInPlane.ID() != expWID) {
422  MF_LOG_ERROR("GeometryIteratorLoopTest")
423  << "Wire local iterator in " << expPID << " points to "
424  << iWireInPlane.ID() << " instead of " << expWID;
425  ++nErrors;
426  }
427 
428  ++iWireID;
429  ++iWireIDinCryo;
430  ++iWireIDinTPC;
431  ++iWireIDinPlane;
432  ++iWire;
433  ++iWireInCryo;
434  ++iWireInTPC;
435  ++iWireInPlane;
436  ++nWires;
437  ++nWiresInCryo;
438  ++nWiresInTPC;
439  ++nWiresInPlane;
440  geom->IncrementID(runningWID);
441  } // end loop over wires
442 
443  if (iWireIDinPlane != geom->end_wire_id(expPID)) {
444  MF_LOG_ERROR("GeometryIteratorLoopTest")
445  << "Wire ID local iterator in " << expPID
446  << " should be at end and instead points to " << *iWireIDinPlane;
447  ++nErrors;
448  }
449  if (iWireInPlane != geom->end_wire(expPID)) {
450  MF_LOG_ERROR("GeometryIteratorLoopTest")
451  << "Wire local iterator in " << expPID
452  << " should be at end, and instead points to "
453  << iWireInPlane.ID();
454  ++nErrors;
455  }
456 
457  //
458  // test if we can loop all wires in this plane via iterator box
459  //
460  MF_LOG_DEBUG("GeometryIteratorsDump")
461  << "Looping though " << nWiresInPlane << " wires in " << expPID;
462  unsigned int nLoopedWireIDs = 0;
463  for (geo::WireID const& wID: geom->IterateWireIDs(expPID)) {
464  MF_LOG_TRACE("GeometryIteratorsDump") << wID;
465  if (nLoopedWireIDs >= nWiresInPlane) {
466  MF_LOG_ERROR("GeometryIteratorLoopTest")
467  << "After all " << nLoopedWireIDs << " wire IDs in " << expPID
468  << ", iterator has not reached the end ("
469  << *(geom->end_wire_id(expPID)) << ") but it's still at "
470  << wID;
471  ++nErrors;
472  break;
473  }
474  ++nLoopedWireIDs;
475  }
476  if (nLoopedWireIDs < nWiresInPlane) {
477  MF_LOG_ERROR("GeometryIteratorLoopTest")
478  << "Looped only " << nLoopedWireIDs
479  << " wire IDs in " << expPID << ", while we expected "
480  << nWiresInPlane << " iterations!";
481  ++nErrors;
482  } // if
483  unsigned int nLoopedWires = 0;
484  for (geo::WireGeo const& wire: geom->IterateWires(expPID)) {
485  if (nLoopedWires >= nWiresInPlane) {
486  MF_LOG_ERROR("GeometryIteratorLoopTest")
487  << "After all " << nLoopedWires << " wires in "
488  << expPID << ", iterator has not reached the end";
489  ++nErrors;
490  break;
491  }
492  ++nLoopedWires;
493  }
494  if (nLoopedWires < nWiresInPlane) {
495  MF_LOG_ERROR("GeometryIteratorLoopTest")
496  << "Looped only " << nLoopedWires << " wires in " << expPID
497  << ", while we expected " << nWiresInPlane << " iterations!";
498  ++nErrors;
499  } // if
500 
501 
502  ++iPlaneID;
503  ++iPlaneIDinCryo;
504  ++iPlaneIDinTPC;
505  ++iPlane;
506  ++iPlaneInCryo;
507  ++iPlaneInTPC;
508  ++nPlanes;
509  ++nPlanesInCryo;
510  ++nPlanesInTPC;
511  geom->IncrementID(runningPID);
512  } // end loop over planes
513 
514  if (iPlaneIDinTPC != geom->end_plane_id(expTID)) {
515  MF_LOG_ERROR("GeometryIteratorLoopTest")
516  << "Plane ID local iterator in " << expTID
517  << " should be at end and instead points to " << *iPlaneIDinTPC;
518  ++nErrors;
519  }
520  if (iPlaneInTPC != geom->end_plane(expTID)) {
521  MF_LOG_ERROR("GeometryIteratorLoopTest")
522  << "Plane local iterator in " << expTID
523  << " should be at end, and instead points to " << iPlaneInTPC.ID();
524  ++nErrors;
525  }
526 
527  if (iWireIDinTPC != geom->end_wire_id(expTID)) {
528  MF_LOG_ERROR("GeometryIteratorLoopTest")
529  << "Wire ID local iterator in " << expTID
530  << " should be at end and instead points to " << *iWireIDinTPC;
531  ++nErrors;
532  }
533  if (iWireInTPC != geom->end_wire(expTID)) {
534  MF_LOG_ERROR("GeometryIteratorLoopTest")
535  << "Wire local iterator in " << expTID
536  << " should be at end, and instead points to " << iWireInTPC.ID();
537  ++nErrors;
538  }
539 
540  //
541  // test if we can loop all planes in this TPC via iterator box
542  //
543  MF_LOG_DEBUG("GeometryIteratorsDump")
544  << "Looping though " << nPlanesInTPC << " planes in " << expTID;
545  unsigned int nLoopedPlaneIDs = 0;
546  for (geo::PlaneID const& pID: geom->IteratePlaneIDs(expTID)) {
547  MF_LOG_TRACE("GeometryIteratorsDump") << pID;
548  if (nLoopedPlaneIDs >= nPlanesInTPC) {
549  MF_LOG_ERROR("GeometryIteratorLoopTest")
550  << "After all " << nLoopedPlaneIDs << " plane IDs in " << expTID
551  << ", iterator has not reached the end ("
552  << *(geom->end_plane_id(expTID)) << ") but it's still at " << pID;
553  ++nErrors;
554  break;
555  }
556  ++nLoopedPlaneIDs;
557  }
558  if (nLoopedPlaneIDs < nPlanesInTPC) {
559  MF_LOG_ERROR("GeometryIteratorLoopTest")
560  << "Looped only " << nLoopedPlaneIDs
561  << " plane IDs in " << expTID << ", while we expected "
562  << nPlanesInTPC << " iterations!";
563  ++nErrors;
564  } // if
565  unsigned int nLoopedPlanes = 0;
566  for (geo::PlaneGeo const& plane: geom->IteratePlanes(expTID)) {
567  if (nLoopedPlanes >= nPlanesInTPC) {
568  MF_LOG_ERROR("GeometryIteratorLoopTest")
569  << "After all " << nLoopedPlanes << " planes in "
570  << expTID << ", iterator has not reached the end";
571  ++nErrors;
572  break;
573  }
574  ++nLoopedPlanes;
575  }
576  if (nLoopedPlanes < nPlanesInTPC) {
577  MF_LOG_ERROR("GeometryIteratorLoopTest")
578  << "Looped only " << nLoopedPlanes << " planes in " << expTID
579  << ", while we expected " << nPlanesInTPC << " iterations!";
580  ++nErrors;
581  } // if
582 
583  //
584  // test if we can loop all wires in this TPC via iterator box
585  //
586  MF_LOG_DEBUG("GeometryIteratorsDump")
587  << "Looping though " << nWiresInTPC << " wires in " << expTID;
588  unsigned int nLoopedWireIDs = 0;
589  for (geo::WireID const& wID: geom->IterateWireIDs(expTID)) {
590  MF_LOG_TRACE("GeometryIteratorsDump") << wID;
591  if (nLoopedWireIDs >= nWiresInTPC) {
592  MF_LOG_ERROR("GeometryIteratorLoopTest")
593  << "After all " << nLoopedWireIDs << " wire IDs in " << expTID
594  << ", iterator has not reached the end ("
595  << *(geom->end_wire_id(expTID)) << ") but it's still at " << wID;
596  ++nErrors;
597  break;
598  }
599  ++nLoopedWireIDs;
600  }
601  if (nLoopedWireIDs < nWiresInTPC) {
602  MF_LOG_ERROR("GeometryIteratorLoopTest")
603  << "Looped only " << nLoopedWireIDs
604  << " wire IDs in " << expTID << ", while we expected "
605  << nWiresInTPC << " iterations!";
606  ++nErrors;
607  } // if
608  unsigned int nLoopedWires = 0;
609  for (geo::WireGeo const& wire: geom->IterateWires(expTID)) {
610  if (nLoopedWires >= nWiresInTPC) {
611  MF_LOG_ERROR("GeometryIteratorLoopTest")
612  << "After all " << nLoopedWires << " wires in "
613  << expTID << ", iterator has not reached the end";
614  ++nErrors;
615  break;
616  }
617  ++nLoopedWires;
618  }
619  if (nLoopedWires < nWiresInTPC) {
620  MF_LOG_ERROR("GeometryIteratorLoopTest")
621  << "Looped only " << nLoopedWires << " wires in " << expTID
622  << ", while we expected " << nWiresInTPC << " iterations!";
623  ++nErrors;
624  } // if
625 
626 
627  ++iTPCID;
628  ++iTPC;
629  ++iTPCIDinCryo;
630  ++iTPCinCryo;
631  ++nTPCs;
632  geom->IncrementID(runningTID);
633  } // end loop over tpcs
634 
635  if (iTPCIDinCryo != geom->end_TPC_id(expCID)) {
636  MF_LOG_ERROR("GeometryIteratorLoopTest")
637  << "TPC ID local iterator in " << expCID
638  << " should be at end, and instead points to " << *iTPCIDinCryo;
639  ++nErrors;
640  }
641  if (iTPCinCryo != geom->end_TPC(expCID)) {
642  MF_LOG_ERROR("GeometryIteratorLoopTest")
643  << "TPC local iterator in " << expCID
644  << " should be at end, and instead points to " << iTPCinCryo->ID();
645  ++nErrors;
646  }
647 
648  if (iPlaneIDinCryo != geom->end_plane_id(expCID)) {
649  MF_LOG_ERROR("GeometryIteratorLoopTest")
650  << "Plane ID local iterator in " << expCID
651  << " should be at end, and instead points to " << *iPlaneIDinCryo;
652  ++nErrors;
653  }
654  if (iPlaneInCryo != geom->end_plane(expCID)) {
655  MF_LOG_ERROR("GeometryIteratorLoopTest")
656  << "Plane local iterator in " << expCID
657  << " should be at end, and instead points to " << iPlaneInCryo->ID();
658  ++nErrors;
659  }
660 
661  if (iWireIDinCryo != geom->end_wire_id(expCID)) {
662  MF_LOG_ERROR("GeometryIteratorLoopTest")
663  << "Wire ID local iterator in " << expCID
664  << " should be at end, and instead points to " << *iWireIDinCryo;
665  ++nErrors;
666  }
667  if (iWireInCryo != geom->end_wire(expCID)) {
668  MF_LOG_ERROR("GeometryIteratorLoopTest")
669  << "Wire local iterator in " << expCID
670  << " should be at end, and instead points to " << iWireInCryo.ID();
671  ++nErrors;
672  }
673 
674  //
675  // test if we can loop all TPCs in this cryostat via iterator box
676  //
677  unsigned int nTPCsInCryo = cryo.NTPC();
678  MF_LOG_DEBUG("GeometryIteratorsDump")
679  << "Looping though " << nTPCsInCryo << " TPCs in " << expCID;
680  unsigned int nLoopedTPCIDs = 0;
681  for (geo::TPCID const& tID: geom->IterateTPCIDs(expCID)) {
682  MF_LOG_TRACE("GeometryIteratorsDump") << tID;
683  if (nLoopedTPCIDs >= nTPCsInCryo) {
684  MF_LOG_ERROR("GeometryIteratorLoopTest")
685  << "After all " << nLoopedTPCIDs << " TPC IDs in " << expCID
686  << ", iterator has not reached the end ("
687  << *(geom->end_TPC_id(expCID)) << ") but it's still at " << tID;
688  ++nErrors;
689  break;
690  }
691  ++nLoopedTPCIDs;
692  }
693  if (nLoopedTPCIDs < nTPCsInCryo) {
694  MF_LOG_ERROR("GeometryIteratorLoopTest")
695  << "Looped only " << nLoopedTPCIDs
696  << " TPC IDs in " << expCID << ", while we expected "
697  << nTPCsInCryo << " iterations!";
698  ++nErrors;
699  } // if
700  unsigned int nLoopedTPCs = 0;
701  for (geo::TPCGeo const& TPC: geom->IterateTPCs(expCID)) {
702  if (nLoopedTPCs >= nTPCsInCryo) {
703  MF_LOG_ERROR("GeometryIteratorLoopTest")
704  << "After all " << nLoopedTPCs
705  << " TPCs in " << expCID << ", iterator has not reached the end";
706  ++nErrors;
707  break;
708  }
709  ++nLoopedTPCs;
710  }
711  if (nLoopedTPCs < nTPCsInCryo) {
712  MF_LOG_ERROR("GeometryIteratorLoopTest")
713  << "Looped only " << nLoopedTPCs << " TPCs in " << expCID
714  << ", while we expected " << nTPCsInCryo << " iterations!";
715  ++nErrors;
716  } // if
717 
718  //
719  // test if we can loop all planes in this cryostat via iterator box
720  //
721  MF_LOG_DEBUG("GeometryIteratorsDump")
722  << "Looping though " << nPlanesInCryo << " planes in " << expCID;
723  unsigned int nLoopedPlaneIDs = 0;
724  for (geo::PlaneID const& pID: geom->IteratePlaneIDs(expCID)) {
725  MF_LOG_TRACE("GeometryIteratorsDump") << pID;
726  if (nLoopedPlaneIDs >= nPlanesInCryo) {
727  MF_LOG_ERROR("GeometryIteratorLoopTest")
728  << "After all " << nLoopedPlaneIDs << " plane IDs in " << expCID
729  << ", iterator has not reached the end ("
730  << *(geom->end_plane_id(expCID)) << ") but it's still at " << pID;
731  ++nErrors;
732  break;
733  }
734  ++nLoopedPlaneIDs;
735  }
736  if (nLoopedPlaneIDs < nPlanesInCryo) {
737  MF_LOG_ERROR("GeometryIteratorLoopTest")
738  << "Looped only " << nLoopedPlaneIDs
739  << " plane IDs in " << expCID << ", while we expected "
740  << nPlanesInCryo << " iterations!";
741  ++nErrors;
742  } // if
743  unsigned int nLoopedPlanes = 0;
744  for (geo::PlaneGeo const& plane: geom->IteratePlanes(expCID)) {
745  if (nLoopedPlanes >= nPlanesInCryo) {
746  MF_LOG_ERROR("GeometryIteratorLoopTest")
747  << "After all " << nLoopedPlanes
748  << " planes in " << expCID << ", iterator has not reached the end";
749  ++nErrors;
750  break;
751  }
752  ++nLoopedPlanes;
753  }
754  if (nLoopedPlanes < nPlanesInCryo) {
755  MF_LOG_ERROR("GeometryIteratorLoopTest")
756  << "Looped only " << nLoopedPlanes << " planes in " << expCID
757  << ", while we expected " << nPlanesInCryo << " iterations!";
758  ++nErrors;
759  } // if
760 
761  //
762  // test if we can loop all wires in this cryostat via iterator box
763  //
764  MF_LOG_DEBUG("GeometryIteratorsDump")
765  << "Looping though " << nWiresInCryo << " wires in " << expCID;
766  unsigned int nLoopedWireIDs = 0;
767  for (geo::WireID const& wID: geom->IterateWireIDs(expCID)) {
768  MF_LOG_TRACE("GeometryIteratorsDump") << wID;
769  if (nLoopedWireIDs >= nWiresInCryo) {
770  MF_LOG_ERROR("GeometryIteratorLoopTest")
771  << "After all " << nLoopedWireIDs << " wire IDs in " << expCID
772  << ", iterator has not reached the end ("
773  << *(geom->end_wire_id(expCID)) << ") but it's still at " << wID;
774  ++nErrors;
775  break;
776  }
777  ++nLoopedWireIDs;
778  }
779  if (nLoopedWireIDs < nWiresInCryo) {
780  MF_LOG_ERROR("GeometryIteratorLoopTest")
781  << "Looped only " << nLoopedWireIDs
782  << " wire IDs in " << expCID << ", while we expected "
783  << nWiresInCryo << " iterations!";
784  ++nErrors;
785  } // if
786  unsigned int nLoopedWires = 0;
787  for (geo::WireGeo const& wire: geom->IterateWires(expCID)) {
788  if (nLoopedWires >= nWiresInCryo) {
789  MF_LOG_ERROR("GeometryIteratorLoopTest")
790  << "After all " << nLoopedWires
791  << " wires in " << expCID << ", iterator has not reached the end";
792  ++nErrors;
793  break;
794  }
795  ++nLoopedWires;
796  }
797  if (nLoopedWires < nWiresInCryo) {
798  MF_LOG_ERROR("GeometryIteratorLoopTest")
799  << "Looped only " << nLoopedWires << " wires in " << expCID
800  << ", while we expected " << nWiresInCryo << " iterations!";
801  ++nErrors;
802  } // if
803 
804 
805  //
806  // readout iterators
807  //
808  geo::TPCset_id_iterator iTPCsetIDinCryo = geom->begin_TPCset_id(expCID);
809  geo::ROP_id_iterator iROPIDinCryo = geom->begin_ROP_id(expCID);
810 
811  unsigned int nTPCsetsInCryo = 0;
812  unsigned int nROPInCryo = 0;
813 
814  for(unsigned int s = 0; s < nTPCsets; ++s) {
815  readout::TPCsetID const expSID(expCID, s);
816  const unsigned int NROPs = geom->NROPs(expSID);
817 
818  MF_LOG_TRACE("GeometryIteratorLoopTest")
819  << " " << expSID << " (" << NROPs << " planes)";
820 
821  if (runningSID != expSID) {
822  MF_LOG_ERROR("GeometryIteratorLoopTest")
823  << "TPC set ID incremented to " << runningSID << ", expected: "
824  << expSID;
825  ++nErrors;
826  }
827 
828  if (!iTPCsetID) {
829  MF_LOG_ERROR("GeometryIteratorLoopTest")
830  << "TPCset ID iterator thinks it's all over at " << expSID;
831  ++nErrors;
832  }
833  else if (iTPCsetID->Cryostat != c) {
834  MF_LOG_ERROR("GeometryIteratorLoopTest")
835  << "TPC set ID iterator thinks it's at C=" << iTPCsetID->Cryostat
836  << " instead of " << c;
837  ++nErrors;
838  }
839  else if (iTPCsetID->TPCset != s) {
840  MF_LOG_ERROR("GeometryIteratorLoopTest")
841  << "TPC set ID iterator thinks it's at S=" << iTPCsetID->TPCset
842  << " instead of " << s;
843  ++nErrors;
844  }
845 
846  if (*iTPCsetIDinCryo != expSID) {
847  MF_LOG_ERROR("GeometryIteratorLoopTest")
848  << "TPC set ID local iterator in " << expCID
849  << " points to " << *iTPCsetIDinCryo << " instead of " << expSID;
850  ++nErrors;
851  }
852 
853  geo::ROP_id_iterator iROPIDinTPCset = geom->begin_ROP_id(expSID);
854 
855  unsigned int nROPInTPCset = 0; // this will become NROPs
856 
857  for(unsigned int r = 0; r < NROPs; ++r) {
858  readout::ROPID const expRID(expSID, r);
859  const unsigned int NChannels = geom->Nchannels(expRID);
860 
861  MF_LOG_TRACE("GeometryIteratorLoopTest")
862  << " " << expRID << " (" << NChannels << " channels)";
863 
864  if (runningRID != expRID) {
865  MF_LOG_ERROR("GeometryIteratorLoopTest")
866  << "Readout plane ID incremented to " << runningRID
867  << ", expected: " << expRID;
868  ++nErrors;
869  }
870 
871  if (!iROPID) {
872  MF_LOG_ERROR("GeometryIteratorLoopTest")
873  << "readout plane ID iterator thinks it's all over at " << expRID;
874  ++nErrors;
875  }
876  else if (iROPID->Cryostat != c) {
877  MF_LOG_ERROR("GeometryIteratorLoopTest")
878  << "readout plane ID iterator thinks it's at C="
879  << iROPID->Cryostat << " instead of " << c;
880  ++nErrors;
881  }
882  else if (iROPID->TPCset != s) {
883  MF_LOG_ERROR("GeometryIteratorLoopTest")
884  << "readout plane ID iterator thinks it's at S=" << iROPID->TPCset
885  << " instead of " << s;
886  ++nErrors;
887  }
888  else if (iROPID->ROP != r) {
889  MF_LOG_ERROR("GeometryIteratorLoopTest")
890  << "readout plane ID iterator thinks it's at R=" << iROPID->ROP
891  << " instead of " << r;
892  ++nErrors;
893  }
894 
895  if (*iROPIDinCryo != expRID) {
896  MF_LOG_ERROR("GeometryIteratorLoopTest")
897  << "Readout plane ID local iterator in " << expCID
898  << " points to " << *iROPIDinCryo << " instead of " << expRID;
899  ++nErrors;
900  }
901 
902  if (*iROPIDinTPCset != expRID) {
903  MF_LOG_ERROR("GeometryIteratorLoopTest")
904  << "Readout plane ID local iterator in " << expSID
905  << " points to " << *iROPIDinTPCset << " instead of " << expRID;
906  ++nErrors;
907  }
908 
909  /*
910  // ROP-local channel iterators would appear here
911  for(unsigned int ch = 0; ch < NChannels; ++ch) {
912 
913  MF_LOG_TRACE("GeometryIteratorLoopTest") << " channel=" << ch;
914 
915  ++iChannelID;
916  ++nChannels;
917  } // end loop over channels
918  */
919 
920  ++iROPID;
921  ++iROPIDinCryo;
922  ++iROPIDinTPCset;
923  ++cumROPs;
924  ++nROPInCryo;
925  ++nROPInTPCset;
926  geom->IncrementID(runningRID);
927  } // end loop over readout planes
928 
929  if (iROPIDinTPCset != geom->end_ROP_id(expSID)) {
930  MF_LOG_ERROR("GeometryIteratorLoopTest")
931  << "Readout plane ID local iterator in " << expSID
932  << " should be at end and instead points to " << *iROPIDinTPCset;
933  ++nErrors;
934  }
935 
936  //
937  // test if we can loop all ROPs in this TPC set via iterator box
938  //
939  MF_LOG_DEBUG("GeometryIteratorsDump")
940  << "Looping though " << nROPInTPCset << " readout planes in "
941  << expSID;
942  unsigned int nLoopedROPIDs = 0;
943  for (readout::ROPID const& rID: geom->IterateROPIDs(expSID)) {
944  MF_LOG_TRACE("GeometryIteratorsDump") << rID;
945  if (nLoopedROPIDs >= nROPInTPCset) {
946  MF_LOG_ERROR("GeometryIteratorLoopTest")
947  << "After all " << nLoopedROPIDs << " readout plane IDs in "
948  << expSID << ", iterator has not reached the end ("
949  << *(geom->end_ROP_id(expSID)) << ") but it's still at " << rID;
950  ++nErrors;
951  break;
952  }
953  ++nLoopedROPIDs;
954  }
955  if (nLoopedROPIDs < nROPInTPCset) {
956  MF_LOG_ERROR("GeometryIteratorLoopTest")
957  << "Looped only " << nLoopedROPIDs
958  << " readout plane IDs in " << expSID << ", while we expected "
959  << nROPInTPCset << " iterations!";
960  ++nErrors;
961  } // if
962 
963  ++iTPCsetID;
964  ++iTPCsetIDinCryo;
965  ++cumTPCsets;
966  ++nTPCsetsInCryo;
967  geom->IncrementID(runningSID);
968  } // end loop over TPC sets
969 
970  if (iTPCsetIDinCryo != geom->end_TPCset_id(expCID)) {
971  MF_LOG_ERROR("GeometryIteratorLoopTest")
972  << "TPC set ID local iterator in " << expCID
973  << " should be at end, and instead points to " << *iTPCsetIDinCryo;
974  ++nErrors;
975  }
976 
977  if (iROPIDinCryo != geom->end_ROP_id(expCID)) {
978  MF_LOG_ERROR("GeometryIteratorLoopTest")
979  << "Readout plane ID local iterator in " << expCID
980  << " should be at end, and instead points to " << *iROPIDinCryo;
981  ++nErrors;
982  }
983 
984  //
985  // test if we can loop all TPC sets in this cryostat via iterator box
986  //
987  MF_LOG_DEBUG("GeometryIteratorsDump")
988  << "Looping though " << nTPCsetsInCryo << " TPC sets in " << expCID;
989  unsigned int nLoopedTPCsetIDs = 0;
990  for (readout::TPCsetID const& sID: geom->IterateTPCsetIDs(expCID)) {
991  MF_LOG_TRACE("GeometryIteratorsDump") << sID;
992  if (nLoopedTPCsetIDs >= nTPCsetsInCryo) {
993  MF_LOG_ERROR("GeometryIteratorLoopTest")
994  << "After all " << nLoopedTPCsetIDs << " TPC set IDs in " << expCID
995  << ", iterator has not reached the end ("
996  << *(geom->end_TPCset_id(expCID)) << ") but it's still at " << sID;
997  ++nErrors;
998  break;
999  }
1000  ++nLoopedTPCsetIDs;
1001  }
1002  if (nLoopedTPCsetIDs < nTPCsetsInCryo) {
1003  MF_LOG_ERROR("GeometryIteratorLoopTest")
1004  << "Looped only " << nLoopedTPCsetIDs
1005  << " TPC set IDs in " << expCID << ", while we expected "
1006  << nTPCsetsInCryo << " iterations!";
1007  ++nErrors;
1008  } // if
1009 
1010  //
1011  // test if we can loop all readout planes in this cryostat via iterator
1012  // box
1013  //
1014  MF_LOG_DEBUG("GeometryIteratorsDump")
1015  << "Looping though " << nROPInCryo << " readout planes in " << expCID;
1016  unsigned int nLoopedROPIDs = 0;
1017  for (readout::ROPID const& rID: geom->IterateROPIDs(expCID)) {
1018  MF_LOG_TRACE("GeometryIteratorsDump") << rID;
1019  if (nLoopedROPIDs >= nROPInCryo) {
1020  MF_LOG_ERROR("GeometryIteratorLoopTest")
1021  << "After all " << nLoopedROPIDs << " readout plane IDs in "
1022  << expCID << ", iterator has not reached the end ("
1023  << *(geom->end_ROP_id(expCID)) << ") but it's still at " << rID;
1024  ++nErrors;
1025  break;
1026  }
1027  ++nLoopedROPIDs;
1028  }
1029  if (nLoopedROPIDs < nROPInCryo) {
1030  MF_LOG_ERROR("GeometryIteratorLoopTest")
1031  << "Looped only " << nLoopedROPIDs
1032  << " readout plane IDs in " << expCID << ", while we expected "
1033  << nROPInCryo << " iterations!";
1034  ++nErrors;
1035  } // if
1036 
1037  ++iCryostatID;
1038  ++iCryostat;
1039  ++nCryostats;
1040  geom->IncrementID(runningCID);
1041  } // end loop over cryostats
1042 
1043  if (runningCID) {
1044  MF_LOG_ERROR("GeometryIteratorLoopTest")
1045  << "Cryostat ID still valid (" << runningCID
1046  << ") after incrementing from the last one.";
1047  ++nErrors;
1048  }
1049 
1050  if (iCryostatID) {
1051  MF_LOG_ERROR("GeometryIteratorLoopTest")
1052  << "Cryostat ID iterator thinks it's still at " << *iCryostatID
1053  << ", but we are already finished";
1054  ++nErrors;
1055  }
1056  try {
1057  geo::CryostatGeo const& Cryo = *iCryostat;
1058  MF_LOG_ERROR("GeometryIteratorLoopTest")
1059  << "Cryostat iterator thinks it's still at " << iCryostat.ID()
1060  << ", but we are already finished";
1061  ++nErrors;
1062  }
1063  catch (cet::exception const&) {
1064  MF_LOG_DEBUG("GeometryIteratorLoopTest") << "exception caught"
1065  " while dereferencing an iterator to a past-the-end cryostat.\n";
1066  }
1067 
1068  // test if we can loop all cryostats with the iterators (via iterator box)
1069  MF_LOG_DEBUG("GeometryIteratorsDump")
1070  << "Looping though " << nCryostats << " cryostats";
1071  unsigned int nLoopedCryostatIDs = 0;
1072  for (geo::CryostatID const& cID: geom->IterateCryostatIDs()) {
1073  MF_LOG_TRACE("GeometryIteratorsDump") << cID;
1074  if (nLoopedCryostatIDs >= nCryostats) {
1075  MF_LOG_ERROR("GeometryIteratorLoopTest")
1076  << "After all " << nLoopedCryostatIDs
1077  << " cryostat IDs, iterator has not reached the end ("
1078  << *(geom->end_cryostat_id()) << ") but it's still at " << cID;
1079  ++nErrors;
1080  break;
1081  }
1082  ++nLoopedCryostatIDs;
1083  }
1084  if (nLoopedCryostatIDs < nCryostats) {
1085  MF_LOG_ERROR("GeometryIteratorLoopTest")
1086  << "Looped only " << nLoopedCryostatIDs
1087  << " cryostat IDs, while we expected " << nCryostats << " iterations!";
1088  ++nErrors;
1089  } // if
1090  unsigned int nLoopedCryostats = 0;
1091  for (geo::CryostatGeo const& Cryo: geom->IterateCryostats()) {
1092  if (nLoopedCryostats >= nCryostats) {
1093  MF_LOG_ERROR("GeometryIteratorLoopTest")
1094  << "After all " << nLoopedCryostats
1095  << " cryostats, iterator has not reached the end";
1096  ++nErrors;
1097  break;
1098  }
1099  ++nLoopedCryostats;
1100  }
1101  if (nLoopedCryostats < nCryostats) {
1102  MF_LOG_ERROR("GeometryIteratorLoopTest")
1103  << "Looped only " << nLoopedCryostats
1104  << " cryostats, while we expected " << nCryostats << " iterations!";
1105  ++nErrors;
1106  } // if
1107 
1108  if (runningTID) {
1109  MF_LOG_ERROR("GeometryIteratorLoopTest")
1110  << "TPC ID still valid (" << runningTID
1111  << ") after incrementing from the last one.";
1112  ++nErrors;
1113  }
1114 
1115  if (iTPCID) {
1116  MF_LOG_ERROR("GeometryIteratorLoopTest")
1117  << "TPC iterator thinks it's still at " << *iTPCID
1118  << ", but we are already finished";
1119  ++nErrors;
1120  }
1121  try {
1122  geo::TPCGeo const& TPC = *iTPC;
1123  MF_LOG_ERROR("GeometryIteratorLoopTest")
1124  << "TPC iterator thinks it's still at " << iTPC.ID()
1125  << ", but we are already finished";
1126  ++nErrors;
1127  }
1128  catch (cet::exception const&) {
1129  MF_LOG_DEBUG("GeometryIteratorLoopTest") << "exception caught"
1130  " while dereferencing an iterator to a past-the-end TPC.\n";
1131  }
1132 
1133  // test if we can loop all TPCs with the iterators (via iterator box)
1134  MF_LOG_DEBUG("GeometryIteratorsDump")
1135  << "Looping though " << nTPCs << " TPCs";
1136  unsigned int nLoopedTPCIDs = 0;
1137  for (geo::TPCID const& tID: geom->IterateTPCIDs()) {
1138  MF_LOG_TRACE("GeometryIteratorsDump") << tID;
1139  if (nLoopedTPCIDs >= nTPCs) {
1140  MF_LOG_ERROR("GeometryIteratorLoopTest")
1141  << "After all " << nLoopedTPCIDs
1142  << " TPC IDs, iterator has not reached the end ("
1143  << *(geom->end_TPC_id()) << ") but it's still at " << tID;
1144  ++nErrors;
1145  break;
1146  }
1147  ++nLoopedTPCIDs;
1148  }
1149  if (nLoopedTPCIDs < nTPCs) {
1150  MF_LOG_ERROR("GeometryIteratorLoopTest")
1151  << "Looped only " << nLoopedTPCIDs
1152  << " TPC IDs, while we expected " << nTPCs << " iterations!";
1153  ++nErrors;
1154  } // if
1155  unsigned int nLoopedTPCs = 0;
1156  for (geo::TPCGeo const& TPC: geom->IterateTPCs()) {
1157  if (nLoopedTPCs >= nTPCs) {
1158  MF_LOG_ERROR("GeometryIteratorLoopTest")
1159  << "After all " << nLoopedTPCs
1160  << " TPCs, iterator has not reached the end";
1161  ++nErrors;
1162  break;
1163  }
1164  ++nLoopedTPCs;
1165  }
1166  if (nLoopedTPCs < nTPCs) {
1167  MF_LOG_ERROR("GeometryIteratorLoopTest")
1168  << "Looped only " << nLoopedTPCs
1169  << " TPCs, while we expected " << nTPCs << " iterations!";
1170  ++nErrors;
1171  } // if
1172 
1173 
1174  if (runningPID) {
1175  MF_LOG_ERROR("GeometryIteratorLoopTest")
1176  << "Plane ID still valid (" << runningPID
1177  << ") after incrementing from the last one.";
1178  ++nErrors;
1179  }
1180 
1181  if (iPlaneID) {
1182  MF_LOG_ERROR("GeometryIteratorLoopTest")
1183  << "Plane iterator thinks it's still at " << *iPlaneID
1184  << ", but we are already finished";
1185  ++nErrors;
1186  }
1187  try {
1188  geo::PlaneGeo const& Plane = *iPlane;
1189  MF_LOG_ERROR("GeometryIteratorLoopTest")
1190  << "Plane iterator thinks it's still at " << iPlane.ID()
1191  << ", but we are already finished";
1192  ++nErrors;
1193  }
1194  catch (cet::exception const&) {
1195  MF_LOG_DEBUG("GeometryIteratorLoopTest") << "exception caught"
1196  " while dereferencing an iterator to a past-the-end plane.\n";
1197  }
1198 
1199  // test if we can loop all planes with the iterators (via iterator box)
1200  MF_LOG_DEBUG("GeometryIteratorsDump")
1201  << "Looping though " << nPlanes << " planes";
1202  unsigned int nLoopedPlaneIDs = 0;
1203  for (geo::PlaneID const& pID: geom->IteratePlaneIDs()) {
1204  MF_LOG_TRACE("GeometryIteratorsDump") << pID;
1205  if (nLoopedPlaneIDs >= nPlanes) {
1206  MF_LOG_ERROR("GeometryIteratorLoopTest")
1207  << "After all " << nLoopedPlaneIDs
1208  << " planes, ID iterator has not reached the end ("
1209  << *(geom->end_plane_id()) << ") but it's still at " << pID;
1210  ++nErrors;
1211  break;
1212  }
1213  ++nLoopedPlaneIDs;
1214  }
1215  if (nLoopedPlaneIDs < nPlanes) {
1216  MF_LOG_ERROR("GeometryIteratorLoopTest")
1217  << "Looped only " << nLoopedPlaneIDs
1218  << " plane IDs, while we expected " << nPlanes << " iterations!";
1219  ++nErrors;
1220  } // if
1221  unsigned int nLoopedPlanes = 0;
1222  for (geo::PlaneGeo const& Plane: geom->IteratePlanes()) {
1223  if (nLoopedPlanes >= nPlanes) {
1224  MF_LOG_ERROR("GeometryIteratorLoopTest")
1225  << "After all " << nLoopedPlanes
1226  << " planes, iterator has not reached the end";
1227  ++nErrors;
1228  break;
1229  }
1230  ++nLoopedPlanes;
1231  }
1232  if (nLoopedPlanes < nPlanes) {
1233  MF_LOG_ERROR("GeometryIteratorLoopTest")
1234  << "Looped only " << nLoopedPlanes
1235  << " planes, while we expected " << nPlanes << " iterations!";
1236  ++nErrors;
1237  } // if
1238 
1239  if (runningWID) {
1240  MF_LOG_ERROR("GeometryIteratorLoopTest")
1241  << "Wire ID still valid (" << runningWID
1242  << ") after incrementing from the last one.";
1243  ++nErrors;
1244  }
1245 
1246  if (iWireID) {
1247  MF_LOG_ERROR("GeometryIteratorLoopTest")
1248  << "Wire iterator thinks it's still at " << *iWireID
1249  << ", but we are already finished";
1250  ++nErrors;
1251  }
1252  try {
1253  geo::WireGeo const& Wire = *iWire;
1254  MF_LOG_ERROR("GeometryIteratorLoopTest")
1255  << "Wire iterator thinks it's still at " << iWire.ID()
1256  << ", but we are already finished";
1257  ++nErrors;
1258  }
1259  catch (cet::exception const&) {
1260  MF_LOG_DEBUG("GeometryIteratorLoopTest") << "exception caught"
1261  " while dereferencing an iterator to a past-the-end wire.\n";
1262  }
1263 
1264  // test if we can loop all wires with the iterators (via iterator box)
1265  MF_LOG_DEBUG("GeometryIteratorsDump")
1266  << "Looping though " << nWires << " wires";
1267  unsigned int nLoopedWireIDs = 0;
1268  for (geo::WireID const& wID: geom->IterateWireIDs()) {
1269  MF_LOG_TRACE("GeometryIteratorsDump") << wID;
1270  if (nLoopedWireIDs >= nWires) {
1271  MF_LOG_ERROR("GeometryIteratorLoopTest")
1272  << "After all " << nLoopedWireIDs
1273  << " wire IDs, iterator has not reached the end ("
1274  << *(geom->end_wire_id()) << ") but it's still at " << wID;
1275  ++nErrors;
1276  break;
1277  }
1278  ++nLoopedWireIDs;
1279  }
1280  if (nLoopedWireIDs < nWires) {
1281  MF_LOG_ERROR("GeometryIteratorLoopTest")
1282  << "Looped only " << nLoopedWireIDs
1283  << " wire IDs, while we expected " << nWires << " iterations!";
1284  ++nErrors;
1285  } // if
1286  unsigned int nLoopedWires = 0;
1287  for (geo::WireGeo const& Wire: geom->IterateWires()) {
1288  if (nLoopedWires >= nWires) {
1289  MF_LOG_ERROR("GeometryIteratorLoopTest")
1290  << "After all " << nLoopedWires
1291  << " wires, iterator has not reached the end";
1292  ++nErrors;
1293  break;
1294  }
1295  ++nLoopedWires;
1296  }
1297  if (nLoopedWires < nWires) {
1298  MF_LOG_ERROR("GeometryIteratorLoopTest")
1299  << "Looped only " << nLoopedWires
1300  << " wires, while we expected " << nWires << " iterations!";
1301  ++nErrors;
1302  } // if
1303 
1304 
1305  if (runningSID) {
1306  MF_LOG_ERROR("GeometryIteratorLoopTest")
1307  << "TPC set ID still valid (" << runningSID
1308  << ") after incrementing from the last one.";
1309  ++nErrors;
1310  }
1311 
1312  if (iTPCsetID) {
1313  MF_LOG_ERROR("GeometryIteratorLoopTest")
1314  << "TPC set iterator thinks it's still at " << *iTPCsetID
1315  << ", but we are already finished";
1316  ++nErrors;
1317  }
1318 
1319  // test if we can loop all TPC sets with the iterators (via iterator box)
1320  MF_LOG_DEBUG("GeometryIteratorsDump")
1321  << "Looping though " << cumTPCsets << " TPC sets";
1322  unsigned int nLoopedTPCsetIDs = 0;
1323  for (readout::TPCsetID const& sID: geom->IterateTPCsetIDs()) {
1324  MF_LOG_TRACE("GeometryIteratorsDump") << sID;
1325  if (nLoopedTPCsetIDs >= cumTPCsets) {
1326  MF_LOG_ERROR("GeometryIteratorLoopTest")
1327  << "After all " << nLoopedTPCsetIDs
1328  << " TPC set IDs, iterator has not reached the end ("
1329  << *(geom->end_TPCset_id()) << ") but it's still at " << sID;
1330  ++nErrors;
1331  break;
1332  }
1333  ++nLoopedTPCsetIDs;
1334  }
1335  if (nLoopedTPCsetIDs < cumTPCsets) {
1336  MF_LOG_ERROR("GeometryIteratorLoopTest")
1337  << "Looped only " << nLoopedTPCsetIDs
1338  << " TPC set IDs, while we expected " << cumTPCsets << " iterations!";
1339  ++nErrors;
1340  } // if
1341 
1342 
1343  if (runningRID) {
1344  MF_LOG_ERROR("GeometryIteratorLoopTest")
1345  << "readout plane ID still valid (" << runningRID
1346  << ") after incrementing from the last one.";
1347  ++nErrors;
1348  }
1349 
1350  if (iROPID) {
1351  MF_LOG_ERROR("GeometryIteratorLoopTest")
1352  << "readout plane iterator thinks it's still at " << *iROPID
1353  << ", but we are already finished";
1354  ++nErrors;
1355  }
1356 
1357  // test if we can loop all planes with the iterators (via iterator box)
1358  MF_LOG_DEBUG("GeometryIteratorsDump")
1359  << "Looping though " << cumROPs << " readout planes";
1360  unsigned int nLoopedROPIDs = 0;
1361  for (readout::ROPID const& rID: geom->IterateROPIDs()) {
1362  MF_LOG_TRACE("GeometryIteratorsDump") << rID;
1363  if (nLoopedROPIDs >= cumROPs) {
1364  MF_LOG_ERROR("GeometryIteratorLoopTest")
1365  << "After all " << nLoopedROPIDs
1366  << " readout planes, ID iterator has not reached the end ("
1367  << *(geom->end_ROP_id()) << ") but it's still at " << rID;
1368  ++nErrors;
1369  break;
1370  }
1371  ++nLoopedROPIDs;
1372  }
1373  if (nLoopedROPIDs < cumROPs) {
1374  MF_LOG_ERROR("GeometryIteratorLoopTest")
1375  << "Looped only " << nLoopedROPIDs
1376  << " readout plane IDs, while we expected " << cumROPs
1377  << " iterations!";
1378  ++nErrors;
1379  } // if
1380 
1381  return nErrors;
1382  } // GeometryIteratorLoopTestAlg::Run()
wire_iterator begin_wire() const
Returns an iterator pointing to the first wire in the detector.
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
ROP_id_iterator begin_ROP_id() const
Returns an iterator pointing to the first ROP ID in the detector.
wire_iterator end_wire() const
Returns an iterator pointing after the last wire in the detector.
TPC_id_iterator begin_TPC_id() const
Returns an iterator pointing to the first TPC ID in the detector.
BEGIN_PROLOG true icarus_rawdigitfilter FilterTools FilterPlane1 Plane
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.
Base forward iterator browsing all wire IDs in the detector.
Definition: GeometryCore.h:587
Base forward iterator browsing all TPC IDs in the detector.
Definition: GeometryCore.h:292
Base forward iterator browsing all readout plane IDs in the detector.
pdgs p
Definition: selectors.fcl:22
plane_iterator end_plane() const
Returns an iterator pointing after the last plane in the detector.
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Geometry information for a single TPC.
Definition: TPCGeo.h:38
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.
GeometryCore const * geom
pointer to the geometry description
ROP_id_iterator end_ROP_id() const
Returns an iterator pointing after the last ROP ID in the detector.
TPCset_id_iterator end_TPCset_id() const
Returns an iterator pointing after the last TPC set ID in the detector.
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
ElementPtr_t get() const
Returns a pointer to the geometry element, or nullptr if invalid.
Definition: GeometryCore.h:888
BEGIN_PROLOG TPC
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 IncrementID(geo::CryostatID &id) const
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
TPC_iterator begin_TPC() const
Returns an iterator pointing to the first TPC 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.
IteratorBox< wire_id_iterator,&GeometryCore::begin_wire_id,&GeometryCore::end_wire_id > IterateWireIDs() const
Enables ranged-for loops on all wire IDs of the detector.
ElementPtr_t get() const
Returns a pointer to plane, or nullptr if invalid.
IteratorBox< TPC_iterator,&GeometryCore::begin_TPC,&GeometryCore::end_TPC > IterateTPCs() const
Enables ranged-for loops on all TPCs of the detector.
Base forward iterator browsing all cryostat IDs in the detector.
Definition: GeometryCore.h:148
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
TPCset_id_iterator begin_TPCset_id() const
Returns an iterator pointing to the first TPC set ID in the detector.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
wire_id_iterator end_wire_id() const
Returns an iterator pointing after the last wire ID in the detector.
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
TPC_id_iterator end_TPC_id() const
Returns an iterator pointing after the last TPC ID in the detector.
Class identifying a set of planes sharing readout channels.
ElementPtr_t get() const
Returns a pointer to TPC, or nullptr if invalid.
IteratorBox< cryostat_iterator,&GeometryCore::begin_cryostat,&GeometryCore::end_cryostat > IterateCryostats() const
Enables ranged-for loops on all cryostats of the detector.
cryostat_iterator begin_cryostat() const
Returns an iterator pointing to the first cryostat.
Base forward iterator browsing all plane IDs in the detector.
Definition: GeometryCore.h:439
IteratorBox< ROP_id_iterator,&GeometryCore::begin_ROP_id,&GeometryCore::end_ROP_id > IterateROPIDs() const
Enables ranged-for loops on all readout plane IDs of the detector.
ElementPtr_t get() const
Returns a pointer to cryostat, or nullptr if invalid.
LocalID_t const & ID() const
Returns the ID of the pointed geometry element.
Definition: GeometryCore.h:891
plane_id_iterator end_plane_id() const
Returns an iterator pointing after the last plane ID in the detector.
ElementPtr_t get() const
Returns a pointer to wire, or nullptr if invalid.
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
IteratorBox< TPCset_id_iterator,&GeometryCore::begin_TPCset_id,&GeometryCore::end_TPCset_id > IterateTPCsetIDs() const
Enables ranged-for loops on all TPC set IDs of the detector.
cryostat_id_iterator begin_cryostat_id() const
Returns an iterator pointing to the first cryostat ID.
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.
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.
unsigned int NROPs(readout::TPCsetID const &tpcsetid) const
Returns the total number of ROP in the specified TPC set.
Forward iterator browsing all geometry elements in the detector.
Definition: GeometryCore.h:727
Base forward iterator browsing all TPC set IDs in the detector.
Definition: GeometryCore.h:933
esac echo uname r
plane_iterator begin_plane() const
Returns an iterator pointing to the first plane in the detector.
TPC_iterator end_TPC() const
Returns an iterator pointing after the last TPC in the detector.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
cryostat_id_iterator end_cryostat_id() const
Returns an iterator pointing after the last cryostat ID.
virtual void geo::GeometryIteratorLoopTestAlg::Setup ( geo::GeometryCore const &  new_geo)
inlinevirtual

Algorithm set up.

Definition at line 32 of file GeometryIteratorLoopTestAlg.h.

32 { geom = &new_geo; }
GeometryCore const * geom
pointer to the geometry description

Member Data Documentation

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

pointer to the geometry description

Definition at line 38 of file GeometryIteratorLoopTestAlg.h.


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