LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo_types.h
Go to the documentation of this file.
1 
13 #ifndef LARCOREOBJ_SIMPLETYPESANDCONSTANTS_GEO_TYPES_H
14 #define LARCOREOBJ_SIMPLETYPESANDCONSTANTS_GEO_TYPES_H
15 
16 // C++ standard libraries
17 #include <climits>
18 #include <cmath>
19 #include <iosfwd> // std::ostream
20 #include <limits> // std::numeric_limits<>
21 #include <sstream>
22 #include <string>
23 
24 namespace geo {
25  namespace details {
27  template <typename T>
28  std::string writeToString(T const& value);
29 
31  template <typename ID>
32  constexpr bool isTopGeoElementID = std::is_void_v<typename ID::ParentID_t>;
33 
34  template <typename ID>
35  constexpr std::size_t geoElementLevel()
36  {
37  if constexpr (isTopGeoElementID<ID>)
38  return 0U;
39  else
40  return geoElementLevel<typename ID::ParentID_t>() + 1U;
41  } // geoElementLevel()
42 
43  template <typename ID, std::size_t Index, typename = void>
45 
46  template <std::size_t Index, typename ID>
48 
49  template <typename ID, std::size_t UpIndex>
51 
52  template <std::size_t UpIndex, typename ID>
54 
55  template <std::size_t Index, typename ID>
56  constexpr auto getAbsIDindex(ID const& id)
57  {
58  static_assert(Index <= ID::Level, "Index not available for this type.");
59  if constexpr (Index == ID::Level)
60  return id.deepestIndex();
61  else
62  return getAbsIDindex<Index>(id.parentID());
63  }
64 
65  template <std::size_t Index, typename ID>
66  auto& getAbsIDindex(ID& id)
67  {
68  static_assert(Index <= ID::Level, "Index not available for this type.");
69  if constexpr (Index == ID::Level)
70  return id.deepestIndex();
71  else
72  return getAbsIDindex<Index>(id.parentID());
73  }
74 
75  template <std::size_t UpIndex, typename ID>
76  auto getRelIDindex(ID const& id)
77  {
78  static_assert(UpIndex <= ID::Level, "Index not available for this type.");
79  if constexpr (UpIndex == 0)
80  return id.deepestIndex();
81  else
82  return getRelIDindex<UpIndex - 1U>(id.parentID());
83  }
84 
85  } // namespace details
86 } // namespace geo
87 
88 // BEGIN Geometry --------------------------------------------------------------
120 namespace geo {
122 
123  // --- BEGIN -- Geometry enumerators -----------------------------------------
126 
127  typedef enum coordinates {
131  } Coord_t;
132 
134  typedef enum _plane_proj {
135  kU,
136  kV,
137  kW,
138  kZ = kW,
139  kY,
140  kX,
141  k3D,
143  } View_t;
144 
145  typedef enum _plane_orient {
148  } Orient_t;
149 
150  typedef enum _plane_sigtype {
154  } SigType_t;
155 
162  typedef enum driftdir {
169 
172  struct ElementLevel {
173 
174  using Level_t = std::size_t;
175 
176  static constexpr Level_t Cryostat = 0U;
177  static constexpr Level_t OpDet = 1U;
178  static constexpr Level_t TPC = 1U;
179  static constexpr Level_t Plane = 2U;
180  static constexpr Level_t Wire = 3U;
181  static constexpr Level_t NLevels = 4U;
182 
183  }; // struct ElementLevel
184 
186  // --- END -- Geometry enumerators -------------------------------------------
187 
190 
192  struct CryostatID {
193  using CryostatID_t = unsigned int;
194 
196  using ParentID_t = void;
197 
199  template <std::size_t L>
201 
203  template <std::size_t A>
205 
206  // not constexpr because we would need an implementation file to define it
208  static constexpr CryostatID_t InvalidID = std::numeric_limits<CryostatID_t>::max();
209 
210  bool isValid = false;
211  CryostatID_t Cryostat = InvalidID;
212 
214  constexpr CryostatID() = default;
215 
217  explicit constexpr CryostatID(CryostatID_t c) : isValid(true), Cryostat(c) {}
218 
220  constexpr CryostatID(CryostatID_t c, bool valid) : isValid(valid), Cryostat(c) {}
221 
224 
226  explicit constexpr operator bool() const { return isValid; }
227 
229  constexpr bool operator!() const { return !isValid; }
230 
232  void setValidity(bool valid) { isValid = valid; }
233 
235  void markValid() { setValidity(true); }
236 
238  void markInvalid() { setValidity(false); }
240 
241  // comparison operators are out of class
242 
244  std::string toString() const { return details::writeToString(*this); }
246  explicit operator std::string() const { return toString(); }
248 
249  // the following four methods are useful for (templated) abstraction
251  constexpr auto const& deepestIndex() const { return Cryostat; }
253  auto& deepestIndex() { return Cryostat; }
255  constexpr ParentID_t parentID() const {}
259  template <std::size_t Index = 0U>
260  constexpr auto getIndex() const;
262  template <std::size_t Index = 0U>
263  auto& writeIndex();
265  template <std::size_t Above>
266  constexpr auto getRelIndex() const;
267 
269  constexpr int cmp(CryostatID const& other) const
270  {
271  return ThreeWayComparison(deepestIndex(), other.deepestIndex());
272  }
273 
275  constexpr CryostatID const& asCryostatID() const { return *this; }
277  CryostatID& asCryostatID() { return *this; }
279  constexpr CryostatID const& asConstCryostatID() { return *this; }
280 
282  static constexpr auto Level = geo::ElementLevel::Cryostat;
283 
285  static constexpr CryostatID_t getInvalidID() { return CryostatID::InvalidID; }
286 
288  template <typename T>
289  static constexpr int ThreeWayComparison(T a, T b)
290  {
291  return (a == b) ? 0 : ((a < b) ? -1 : +1);
292  }
293 
294  }; // struct CryostatID
295 
297  struct OpDetID : public CryostatID {
298  using OpDetID_t = unsigned int;
299 
300  using ThisID_t = OpDetID;
302 
304  template <std::size_t L>
306 
308  template <std::size_t A>
310 
311  // not constexpr because we would need an implementation file to define it
313  static constexpr OpDetID_t InvalidID = std::numeric_limits<OpDetID_t>::max();
314 
316  OpDetID_t OpDet = InvalidID;
317 
319  constexpr OpDetID() = default;
320 
323  constexpr OpDetID(CryostatID const& cryoid, OpDetID_t o) : CryostatID(cryoid), OpDet(o) {}
324 
326  constexpr OpDetID(CryostatID_t c, OpDetID_t o) : CryostatID(c), OpDet(o) {}
327 
328  // comparison operators are out of class
329 
331  std::string toString() const { return details::writeToString(*this); }
333  explicit operator std::string() const { return toString(); }
335 
336  // the following two methods are useful for (templated) abstraction
338  constexpr auto const& deepestIndex() const { return OpDet; }
340  auto& deepestIndex() { return OpDet; }
342  constexpr ParentID_t const& parentID() const { return *this; }
344  ParentID_t& parentID() { return *this; }
346  template <std::size_t Index = 0U>
347  constexpr auto getIndex() const;
349  template <std::size_t Index = 0U>
350  auto& writeIndex();
352  template <std::size_t Above>
353  constexpr auto getRelIndex() const;
354 
356  constexpr OpDetID const& asOpDetID() const { return *this; }
358  OpDetID& asOpDetID() { return *this; }
360  constexpr OpDetID const& asConstOpDetID() { return *this; }
361 
363  constexpr int cmp(OpDetID const& other) const
364  {
365  int cmp_res = CryostatID::cmp(other);
366  if (cmp_res == 0) // same cryostat: compare optical detectors
367  return ThreeWayComparison(deepestIndex(), other.deepestIndex());
368  else // return the order of cryostats
369  return cmp_res;
370  } // cmp()
371 
373  static constexpr auto Level = geo::ElementLevel::OpDet;
374 
376  static constexpr OpDetID_t getInvalidID() { return OpDetID::InvalidID; }
377 
378  }; // struct OpDetID
379 
381  struct TPCID : public CryostatID {
382  using TPCID_t = unsigned int;
383 
384  using ThisID_t = TPCID;
386 
388  template <std::size_t L>
390 
392  template <std::size_t A>
394 
395  // not constexpr because we would need an implementation file to define it
397  static constexpr TPCID_t InvalidID = std::numeric_limits<TPCID_t>::max();
398 
399  TPCID_t TPC = InvalidID;
400 
402  constexpr TPCID() = default;
403 
405  constexpr TPCID(CryostatID const& cryoid, TPCID_t t) : CryostatID(cryoid), TPC(t) {}
406 
408  constexpr TPCID(CryostatID_t c, TPCID_t t) : CryostatID(c), TPC(t) {}
409 
410  // comparison operators are out of class
411 
413  std::string toString() const { return details::writeToString(*this); }
415  explicit operator std::string() const { return toString(); }
417 
418  // the following two methods are useful for (templated) abstraction
420  constexpr auto const& deepestIndex() const { return TPC; }
422  auto& deepestIndex() { return TPC; }
424  constexpr ParentID_t const& parentID() const { return *this; }
426  ParentID_t& parentID() { return *this; }
428  template <std::size_t Index = 0U>
429  constexpr auto getIndex() const;
431  template <std::size_t Index = 0U>
432  auto& writeIndex();
434  template <std::size_t Above>
435  constexpr auto getRelIndex() const;
436 
438  constexpr TPCID const& asTPCID() const { return *this; }
440  TPCID& asTPCID() { return *this; }
442  constexpr TPCID const& asConstTPCID() { return *this; }
443 
445  constexpr int cmp(TPCID const& other) const
446  {
447  int cmp_res = CryostatID::cmp(other);
448  if (cmp_res == 0) // same cryostat: compare TPC
449  return ThreeWayComparison(deepestIndex(), other.deepestIndex());
450  else // return the order of cryostats
451  return cmp_res;
452  } // cmp()
453 
455  static constexpr auto Level = geo::ElementLevel::TPC;
456 
458  static constexpr TPCID_t getInvalidID() { return TPCID::InvalidID; }
459 
460  }; // struct TPCID
461 
463  struct PlaneID : public TPCID {
464  using PlaneID_t = unsigned int;
465 
466  using ThisID_t = PlaneID;
467  using ParentID_t = TPCID;
468 
470  template <std::size_t L>
472 
474  template <std::size_t A>
476 
477  // not constexpr because we would need an implementation file to define it
479  static constexpr PlaneID_t InvalidID = std::numeric_limits<PlaneID_t>::max();
480 
481  PlaneID_t Plane = InvalidID;
482 
484  constexpr PlaneID() = default;
485 
487  constexpr PlaneID(TPCID const& tpcid, PlaneID_t p) : TPCID(tpcid), Plane(p) {}
488 
490  constexpr PlaneID(CryostatID_t c, TPCID_t t, PlaneID_t p) : TPCID(c, t), Plane(p) {}
491 
492  // comparison operators are out of class
493 
495  std::string toString() const { return details::writeToString(*this); }
497  explicit operator std::string() const { return toString(); }
499 
500  // the following two methods are useful for (templated) abstraction
502  constexpr auto const& deepestIndex() const { return Plane; }
504  auto& deepestIndex() { return Plane; }
506  constexpr ParentID_t const& parentID() const { return *this; }
508  ParentID_t& parentID() { return *this; }
510  template <std::size_t Index = 0U>
511  constexpr auto getIndex() const;
513  template <std::size_t Index = 0U>
514  auto& writeIndex();
516  template <std::size_t Above>
517  constexpr auto getRelIndex() const;
518 
520  constexpr PlaneID const& asPlaneID() const { return *this; }
522  PlaneID& asPlaneID() { return *this; }
524  constexpr PlaneID const& asConstPlaneID() { return *this; }
525 
527  constexpr int cmp(PlaneID const& other) const
528  {
529  int cmp_res = TPCID::cmp(other);
530  if (cmp_res == 0) // same TPC: compare plane
531  return ThreeWayComparison(deepestIndex(), other.deepestIndex());
532  else // return the order of planes
533  return cmp_res;
534  } // cmp()
535 
537  static constexpr auto Level = geo::ElementLevel::Plane;
538 
540  static constexpr PlaneID_t getInvalidID() { return PlaneID::InvalidID; }
541 
542  }; // struct PlaneID
543 
544  // The data type to uniquely identify a code wire segment.
545  struct WireID : public PlaneID {
546  using WireID_t = unsigned int;
547 
548  using ThisID_t = WireID;
549  using ParentID_t = PlaneID;
550 
552  template <std::size_t L>
554 
556  template <std::size_t A>
558 
559  // not constexpr because we would need an implementation file to define it
561  static constexpr WireID_t InvalidID = std::numeric_limits<WireID_t>::max();
562 
563  WireID_t Wire = InvalidID;
564 
566  constexpr WireID() = default;
567 
569  constexpr WireID(PlaneID const& planeid, WireID_t w) : PlaneID(planeid), Wire(w) {}
570 
573  constexpr WireID(CryostatID_t c, TPCID_t t, PlaneID_t p, WireID_t w) : PlaneID(c, t, p), Wire(w)
574  {}
575 
577  std::string toString() const { return details::writeToString(*this); }
579  explicit operator std::string() const { return toString(); }
581 
582  // the following two methods are useful for (templated) abstraction
584  constexpr auto const& deepestIndex() const { return Wire; }
586  auto& deepestIndex() { return Wire; }
588  constexpr ParentID_t const& parentID() const { return *this; }
590  ParentID_t& parentID() { return *this; }
592  template <std::size_t Index = 0U>
593  constexpr auto getIndex() const;
595  template <std::size_t Index = 0U>
596  auto& writeIndex();
598  template <std::size_t Above>
599  constexpr auto getRelIndex() const;
600 
602  constexpr WireID const& asWireID() const { return *this; }
604  WireID& asWireID() { return *this; }
606  constexpr WireID const& asConstWireID() { return *this; }
607 
609  constexpr int cmp(WireID const& other) const
610  {
611  int cmp_res = PlaneID::cmp(other);
612  if (cmp_res == 0) // same plane: compare wires
613  return ThreeWayComparison(deepestIndex(), other.deepestIndex());
614  else // return the order of wire
615  return cmp_res;
616  } // cmp()
617 
620  constexpr PlaneID const& planeID() const { return *this; }
621 
623  static constexpr auto Level = geo::ElementLevel::Wire;
624 
626  static constexpr WireID_t getInvalidID() { return WireID::InvalidID; }
627 
628  }; // struct WireID
629 
630  //----------------------------------------------------------------------------
631  //--- ID output operators
632  //---
634  inline std::ostream& operator<<(std::ostream& out, CryostatID const& cid)
635  {
636  out << "C:" << cid.Cryostat;
637  return out;
638  } // operator<< (CryostatID)
639 
641  inline std::ostream& operator<<(std::ostream& out, OpDetID const& oid)
642  {
643  out << oid.asCryostatID() << " O:" << oid.OpDet;
644  return out;
645  } // operator<< (OpDetID)
646 
648  inline std::ostream& operator<<(std::ostream& out, TPCID const& tid)
649  {
650  out << ((CryostatID const&)tid) << " T:" << tid.TPC;
651  return out;
652  } // operator<< (TPCID)
653 
655  inline std::ostream& operator<<(std::ostream& out, PlaneID const& pid)
656  {
657  out << ((TPCID const&)pid) << " P:" << pid.Plane;
658  return out;
659  } // operator<< (PlaneID)
660 
662  inline std::ostream& operator<<(std::ostream& out, WireID const& wid)
663  {
664  out << ((PlaneID const&)wid) << " W:" << wid.Wire;
665  return out;
666  } // operator<< (WireID)
667 
669  // Geometry element IDs
670 
671  //----------------------------------------------------------------------------
672  //--- ID comparison operators
673  //---
674 
678 
680  inline constexpr bool operator==(CryostatID const& a, CryostatID const& b)
681  {
682  return a.Cryostat == b.Cryostat;
683  }
684 
686  inline constexpr bool operator!=(CryostatID const& a, CryostatID const& b)
687  {
688  return a.Cryostat != b.Cryostat;
689  }
690 
692  inline constexpr bool operator<(CryostatID const& a, CryostatID const& b)
693  {
694  return a.Cryostat < b.Cryostat;
695  }
696 
698  inline constexpr bool operator==(OpDetID const& a, OpDetID const& b)
699  {
700  return (a.asCryostatID() == b.asCryostatID()) && (a.OpDet == b.OpDet);
701  }
702 
704  inline constexpr bool operator!=(OpDetID const& a, OpDetID const& b)
705  {
706  return (a.asCryostatID() != b.asCryostatID()) || (a.OpDet != b.OpDet);
707  }
708 
710  inline constexpr bool operator<(OpDetID const& a, OpDetID const& b)
711  {
712  int cmp_res = a.asCryostatID().cmp(b);
713  if (cmp_res == 0) // same cryostat: compare optical detectors
714  return a.OpDet < b.OpDet;
715  else // return the order of cryostats
716  return cmp_res < 0;
717  } // operator< (OpDetID, OpDetID)
718 
720  inline constexpr bool operator==(TPCID const& a, TPCID const& b)
721  {
722  return (static_cast<CryostatID const&>(a) == static_cast<CryostatID const&>(b)) &&
723  (a.TPC == b.TPC);
724  } // operator== (TPCID, TPCID)
725 
727  inline constexpr bool operator!=(TPCID const& a, TPCID const& b)
728  {
729  return (static_cast<CryostatID const&>(a) != static_cast<CryostatID const&>(b)) ||
730  (a.TPC != b.TPC);
731  } // operator!= (TPCID, TPCID)
732 
734  inline constexpr bool operator<(TPCID const& a, TPCID const& b)
735  {
736  int cmp_res = (static_cast<CryostatID const&>(a)).cmp(b);
737  if (cmp_res == 0) // same cryostat: compare TPC
738  return a.TPC < b.TPC;
739  else // return the order of cryostats
740  return cmp_res < 0;
741  } // operator< (TPCID, TPCID)
742 
744  inline constexpr bool operator==(PlaneID const& a, PlaneID const& b)
745  {
746  return (static_cast<TPCID const&>(a) == static_cast<TPCID const&>(b)) && (a.Plane == b.Plane);
747  } // operator== (PlaneID, PlaneID)
748 
750  inline constexpr bool operator!=(PlaneID const& a, PlaneID const& b)
751  {
752  return (static_cast<TPCID const&>(a) != static_cast<TPCID const&>(b)) || (a.Plane != b.Plane);
753  } // operator!= (PlaneID, PlaneID)
754 
756  inline constexpr bool operator<(PlaneID const& a, PlaneID const& b)
757  {
758  int cmp_res = (static_cast<TPCID const&>(a)).cmp(b);
759  if (cmp_res == 0) // same TPC: compare plane
760  return a.Plane < b.Plane;
761  else // return the order of TPC
762  return cmp_res < 0;
763  } // operator< (PlaneID, PlaneID)
764 
766  inline constexpr bool operator==(WireID const& a, WireID const& b)
767  {
768  return (static_cast<PlaneID const&>(a) == static_cast<PlaneID const&>(b)) && (a.Wire == b.Wire);
769  } // operator== (WireID, WireID)
770 
772  inline constexpr bool operator!=(WireID const& a, WireID const& b)
773  {
774  return (static_cast<PlaneID const&>(a) != static_cast<PlaneID const&>(b)) || (a.Wire != b.Wire);
775  } // operator!= (WireID, WireID)
776 
777  // Order WireID in increasing plane, then wire
778  inline constexpr bool operator<(WireID const& a, WireID const& b)
779  {
780  int cmp_res = (static_cast<PlaneID const&>(a)).cmp(b);
781  if (cmp_res == 0) // same plane: compare wire
782  return a.Wire < b.Wire;
783  else // return the order of planes
784  return cmp_res < 0;
785  } // operator< (WireID, WireID)
786 
788 
789  //----------------------------------------------------------------------------
791  double y;
792  double z;
793  unsigned int TPC;
794 
795  // In APAs, we want this to increase in the direction wireID
796  // index increases in: moving inward vertically towards y=0
797  bool operator<(const WireIDIntersection& otherIntersect) const
798  {
799  return std::abs(y) > std::abs(otherIntersect.y);
800  }
801  };
802 
803  //----------------------------------------------------------------------------
805  std::string SignalTypeName(geo::SigType_t sigType);
806 
807  //----------------------------------------------------------------------------
808 
809 } // namespace geo
811 // END Geometry ----------------------------------------------------------------
812 
813 namespace geo {
814  namespace details {
815 
816  //--------------------------------------------------------------------------
817  template <typename ID, std::size_t Index, typename /* = void */>
818  struct AbsIDtypeStruct {
819  static_assert(Index <= ID::Level, "Requested ID index is not available.");
821  }; // AbsIDtypeStruct<>
822 
823  template <typename ID, std::size_t Index>
824  struct AbsIDtypeStruct<ID, Index, std::enable_if_t<(Index == ID::Level)>> {
825  using type = ID;
826  };
827 
828  //--------------------------------------------------------------------------
829  template <typename ID, std::size_t UpIndex>
830  struct RelIDtypeStruct {
831  static_assert(UpIndex <= ID::Level, "Requested parent ID index is not available.");
832  using type = typename RelIDtypeStruct<typename ID::ParentID_t, UpIndex - 1U>::type;
833  }; // RelIDtypeStruct<>
834 
835  template <typename ID>
836  struct RelIDtypeStruct<ID, 0U> {
837  using type = ID;
838  };
839 
840  //--------------------------------------------------------------------------
841  template <typename T>
842  inline std::string writeToString(T const& value)
843  {
844  std::ostringstream sstr;
845  sstr << value;
846  return sstr.str();
847  } // writeToString()
848 
849  //--------------------------------------------------------------------------
850 
851  } // namespace details
852 
853 } // namespace geo
854 
855 //------------------------------------------------------------------------------
856 //--- template implementation
857 //------------------------------------------------------------------------------
858 template <std::size_t Index /* = 0U */>
859 constexpr auto geo::CryostatID::getIndex() const
860 {
861  static_assert(Index <= Level, "This ID type does not have the requested Index level.");
862  return details::getAbsIDindex<Index>(*this);
863 } // geo::CryostatID::getIndex() const
864 
865 template <std::size_t Index /* = 0U */>
867 {
868  static_assert(Index <= Level, "This ID type does not have the requested Index level.");
869  return details::getAbsIDindex<Index>(*this);
870 } // geo::CryostatID::writeIndex()
871 
872 template <std::size_t Above>
873 constexpr auto geo::CryostatID::getRelIndex() const
874 {
875  static_assert(Above <= Level, "This ID type does not have the requested Index level.");
876  return getIndex<Level - Above>();
877 } // geo::CryostatID::getRelIndex()
878 
879 //------------------------------------------------------------------------------
880 template <std::size_t Index /* = 0U */>
881 constexpr auto geo::OpDetID::getIndex() const
882 {
883  static_assert(Index <= Level, "This ID type does not have the requested Index level.");
884  return details::getAbsIDindex<Index>(*this);
885 } // geo::OpDetID::getIndex() const
886 
887 template <std::size_t Index /* = 0U */>
889 {
890  static_assert(Index <= Level, "This ID type does not have the requested Index level.");
891  return details::getAbsIDindex<Index>(*this);
892 } // geo::OpDetID::writeIndex()
893 
894 template <std::size_t Above>
895 constexpr auto geo::OpDetID::getRelIndex() const
896 {
897  static_assert(Above <= Level, "This ID type does not have the requested Index level.");
898  return getIndex<Level - Above>();
899 } // geo::OpDetID::getRelIndex()
900 
901 //------------------------------------------------------------------------------
902 template <std::size_t Index /* = 0U */>
903 constexpr auto geo::TPCID::getIndex() const
904 {
905  static_assert(Index <= Level, "This ID type does not have the requested Index level.");
906  return details::getAbsIDindex<Index>(*this);
907 } // geo::TPCID::getIndex() const
908 
909 template <std::size_t Index /* = 0U */>
911 {
912  static_assert(Index <= Level, "This ID type does not have the requested Index level.");
913  return details::getAbsIDindex<Index>(*this);
914 } // geo::TPCID::writeIndex()
915 
916 template <std::size_t Above>
917 constexpr auto geo::TPCID::getRelIndex() const
918 {
919  static_assert(Above <= Level, "This ID type does not have the requested Index level.");
920  return getIndex<Level - Above>();
921 } // geo::TPCID::getRelIndex()
922 
923 //------------------------------------------------------------------------------
924 template <std::size_t Index /* = 0U */>
925 constexpr auto geo::PlaneID::getIndex() const
926 {
927  static_assert(Index <= Level, "This ID type does not have the requested Index level.");
928  return details::getAbsIDindex<Index>(*this);
929 } // geo::PlaneID::getIndex() const
930 
931 template <std::size_t Index /* = 0U */>
933 {
934  static_assert(Index <= Level, "This ID type does not have the requested Index level.");
935  return details::getAbsIDindex<Index>(*this);
936 } // geo::PlaneID::writeIndex()
937 
938 template <std::size_t Above>
939 constexpr auto geo::PlaneID::getRelIndex() const
940 {
941  static_assert(Above <= Level, "This ID type does not have the requested Index level.");
942  return getIndex<Level - Above>();
943 } // geo::PlaneID::getRelIndex()
944 
945 //------------------------------------------------------------------------------
946 template <std::size_t Index /* = 0U */>
947 constexpr auto geo::WireID::getIndex() const
948 {
949  static_assert(Index <= Level, "This ID type does not have the requested Index level.");
950  return details::getAbsIDindex<Index>(*this);
951 } // geo::WireID::getIndex() const
952 
953 template <std::size_t Index /* = 0U */>
955 {
956  static_assert(Index <= Level, "This ID type does not have the requested Index level.");
957  return details::getAbsIDindex<Index>(*this);
958 } // geo::WireID::writeIndex()
959 
960 template <std::size_t Above>
961 constexpr auto geo::WireID::getRelIndex() const
962 {
963  static_assert(Above <= Level, "This ID type does not have the requested Index level.");
964  return getIndex<Level - Above>();
965 } // geo::WireID::getRelIndex()
966 
967 //------------------------------------------------------------------------------
968 
969 #endif // LARCOREOBJ_SIMPLETYPESANDCONSTANTS_GEO_TYPES_H
constexpr CryostatID(CryostatID_t c)
Constructor: valid ID of cryostat with index c.
Definition: geo_types.h:217
IDparameter< geo::OpDetID > OpDetID
Member type of validated geo::OpDetID parameter.
static constexpr OpDetID_t getInvalidID()
Return the value of the invalid optical detector ID as a r-value.
Definition: geo_types.h:376
ParentID_t & parentID()
Return the parent ID of this one (a plane ID).
Definition: geo_types.h:590
constexpr int cmp(TPCID const &other) const
Returns < 0 if this is smaller than other, 0 if equal, > 0 if larger.
Definition: geo_types.h:445
constexpr auto getIndex() const
Returns the index level Index of this type.
Definition: geo_types.h:881
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
coordinates
Enumerate the possible plane projections.
Definition: geo_types.h:127
constexpr auto getIndex() const
Returns the index level Index of this type.
Definition: geo_types.h:947
double z
z position of intersection
Definition: geo_types.h:792
constexpr WireID const & asWireID() const
Conversion to WireID (for convenience of notation).
Definition: geo_types.h:602
typename RelIDtypeStruct< ID, UpIndex >::type RelIDtype
Definition: geo_types.h:53
Drift direction is unknown.
Definition: geo_types.h:163
static constexpr TPCID_t InvalidID
Special code for an invalid ID.
Definition: geo_types.h:397
Who knows?
Definition: geo_types.h:153
_plane_orient
Enumerate the possible plane projections.
Definition: geo_types.h:145
TPCID & asTPCID()
Conversion to TPCID (for convenience of notation).
Definition: geo_types.h:440
auto & writeIndex()
Returns the index level Index of this type.
Definition: geo_types.h:888
constexpr PlaneID(TPCID const &tpcid, PlaneID_t p)
Constructor: plane with index p in the TPC identified by tpcid.
Definition: geo_types.h:487
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
Definition: geo_types.h:200
void setValidity(bool valid)
Sets the validity of the ID.
Definition: geo_types.h:232
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
auto & writeIndex()
Returns the index level Index of this type.
Definition: geo_types.h:910
static constexpr int ThreeWayComparison(T a, T b)
Returns < 0 if a < b, 0 if a == b, > 0 if a > b.
Definition: geo_types.h:289
constexpr std::size_t geoElementLevel()
Definition: geo_types.h:35
Planes which measure V.
Definition: geo_types.h:136
constexpr WireID(PlaneID const &planeid, WireID_t w)
Constructor: wire with index w in the plane identified by planeid.
Definition: geo_types.h:569
Drift towards positive values.
Definition: geo_types.h:164
Unknown view.
Definition: geo_types.h:142
enum geo::_plane_orient Orient_t
Enumerate the possible plane projections.
constexpr bool operator<(CryostatID const &a, CryostatID const &b)
Order cryostats with increasing ID.
Definition: geo_types.h:692
constexpr int cmp(OpDetID const &other) const
Returns < 0 if this is smaller than other, 0 if equal, > 0 if larger.
Definition: geo_types.h:363
_plane_sigtype
Enumerate the possible plane projections.
Definition: geo_types.h:150
auto & deepestIndex()
Returns the deepest ID available (plane&#39;s).
Definition: geo_types.h:504
ParentID_t & parentID()
Return the parent ID of this one (a TPC ID).
Definition: geo_types.h:508
constexpr WireID const & asConstWireID()
Conversion to WireID (for convenience of notation).
Definition: geo_types.h:606
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:464
Planes which measure X direction.
Definition: geo_types.h:140
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
constexpr auto abs(T v)
Returns the absolute value of the argument.
X coordinate.
Definition: geo_types.h:128
CryostatID & asCryostatID()
Conversion to CryostatID (for convenience of notation).
Definition: geo_types.h:277
constexpr bool operator==(CryostatID const &a, CryostatID const &b)
Comparison: the IDs point to the same cryostat (validity is ignored)
Definition: geo_types.h:680
constexpr auto getIndex() const
Returns the index level Index of this type.
Definition: geo_types.h:925
OpDetID & asOpDetID()
Conversion to OpDetID (for convenience of notation).
Definition: geo_types.h:358
constexpr WireID(CryostatID_t c, TPCID_t t, PlaneID_t p, WireID_t w)
Definition: geo_types.h:573
Level
Definition: Level.h:13
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:211
STL namespace.
_plane_proj
Enumerate the possible plane projections.
Definition: geo_types.h:134
Planes which measure Z direction.
Definition: geo_types.h:138
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (plane&#39;s).
Definition: geo_types.h:502
static constexpr WireID_t InvalidID
Special code for an invalid ID.
Definition: geo_types.h:561
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
Definition: geo_types.h:917
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
enum geo::coordinates Coord_t
Enumerate the possible plane projections.
constexpr ParentID_t const & parentID() const
Return the parent ID of this one (a cryostat ID).
Definition: geo_types.h:424
Drift towards negative X values.
Definition: geo_types.h:167
unsigned int TPC
TPC of intersection.
Definition: geo_types.h:793
constexpr bool operator!() const
Returns true if the ID is not valid.
Definition: geo_types.h:229
static constexpr Level_t Plane
Definition: geo_types.h:179
typename AbsIDtypeStruct< typename ID::ParentID_t, Index >::type type
Definition: geo_types.h:820
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (wire&#39;s).
Definition: geo_types.h:584
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (OpDet&#39;s).
Definition: geo_types.h:338
auto & deepestIndex()
Returns the deepest ID available (TPC&#39;s).
Definition: geo_types.h:422
Planes which measure Y direction.
Definition: geo_types.h:139
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
Definition: geo_types.h:204
constexpr int cmp(WireID const &other) const
Returns < 0 if this is smaller than tpcid, 0 if equal, > 0 if larger.
Definition: geo_types.h:609
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
constexpr TPCID(CryostatID_t c, TPCID_t t)
Constructor: TPC with index t in the cryostat index c.
Definition: geo_types.h:408
3-dimensional objects, potentially hits, clusters, prongs, etc.
Definition: geo_types.h:141
std::enable_if_t< std::is_base_of_v< geometry_iterator_base, GEOIT >, std::ostream & > operator<<(std::ostream &out, GEOIT const &it)
Stream output for all geometry ID iterator types: prints the pointed ID.
std::string writeToString(T const &value)
Write the argument into a string.
Definition: geo_types.h:842
static constexpr CryostatID_t getInvalidID()
Return the value of the invalid ID as a r-value.
Definition: geo_types.h:285
Planes which measure U.
Definition: geo_types.h:135
constexpr bool isTopGeoElementID
Whether ID represents an element on top of the hierarchy.
Definition: geo_types.h:32
auto & deepestIndex()
Returns the deepest ID available (cryostat&#39;s).
Definition: geo_types.h:253
OpDetID_t OpDet
Index of the optical detector within its cryostat.
Definition: geo_types.h:316
typename AbsIDtypeStruct< ID, Index >::type AbsIDtype
Definition: geo_types.h:47
auto & deepestIndex()
Returns the deepest ID available (wire&#39;s).
Definition: geo_types.h:586
Planes that are in the horizontal plane.
Definition: geo_types.h:146
static constexpr TPCID_t getInvalidID()
Return the value of the invalid TPC ID as a r-value.
Definition: geo_types.h:458
constexpr TPCID const & asConstTPCID()
Conversion to TPCID (for convenience of notation).
Definition: geo_types.h:442
driftdir
Drift direction: positive or negative.
Definition: geo_types.h:162
static constexpr Level_t OpDet
Definition: geo_types.h:177
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
enum geo::driftdir DriftDirection_t
Drift direction: positive or negative.
Signal from induction planes.
Definition: geo_types.h:151
Planes that are in the vertical plane (e.g. ArgoNeuT).
Definition: geo_types.h:147
Z coordinate.
Definition: geo_types.h:130
constexpr bool operator!=(CryostatID const &a, CryostatID const &b)
Comparison: the IDs point to different cryostats (validity is ignored)
Definition: geo_types.h:686
static constexpr Level_t TPC
Definition: geo_types.h:178
auto & writeIndex()
Returns the index level Index of this type.
Definition: geo_types.h:866
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
constexpr CryostatID const & asConstCryostatID()
Conversion to CryostatID (for convenience of notation).
Definition: geo_types.h:279
Y coordinate.
Definition: geo_types.h:129
void markValid()
Sets the ID as valid.
Definition: geo_types.h:235
constexpr auto getIndex() const
Returns the index level Index of this type.
Definition: geo_types.h:903
constexpr CryostatID const & asCryostatID() const
Conversion to CryostatID (for convenience of notation).
Definition: geo_types.h:275
constexpr PlaneID const & asPlaneID() const
Conversion to PlaneID (for convenience of notation).
Definition: geo_types.h:520
PlaneID & asPlaneID()
Conversion to PlaneID (for convenience of notation).
Definition: geo_types.h:522
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
static constexpr Level_t Cryostat
Definition: geo_types.h:176
constexpr ParentID_t parentID() const
Return the parent ID of this one (void).
Definition: geo_types.h:255
void markInvalid()
Sets the ID as invalid.
Definition: geo_types.h:238
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
Definition: geo_types.h:961
constexpr CryostatID(CryostatID_t c, bool valid)
Constructor: valid ID of cryostat with index c.
Definition: geo_types.h:220
ParentID_t & parentID()
Return the parent ID of this one (a cryostat ID).
Definition: geo_types.h:426
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
Definition: geo_types.h:873
double value
Definition: spectrum.C:18
constexpr auto getAbsIDindex(ID const &id)
Definition: geo_types.h:56
constexpr TPCID const & asTPCID() const
Conversion to TPCID (for convenience of notation).
Definition: geo_types.h:438
constexpr PlaneID(CryostatID_t c, TPCID_t t, PlaneID_t p)
Constructor: plane with index p in the cryostat index c, TPC index t.
Definition: geo_types.h:490
static constexpr WireID_t getInvalidID()
Return the value of the invalid wire ID as a r-value.
Definition: geo_types.h:626
typename RelIDtypeStruct< typename ID::ParentID_t, UpIndex-1U >::type type
Definition: geo_types.h:832
auto & writeIndex()
Returns the index level Index of this type.
Definition: geo_types.h:932
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:193
unsigned int OpDetID_t
Type for the ID number.
Definition: geo_types.h:298
constexpr ParentID_t const & parentID() const
Return the parent ID of this one (a cryostat ID).
Definition: geo_types.h:342
unsigned int TPCID_t
Type for the ID number.
Definition: geo_types.h:382
Drift towards positive X values.
Definition: geo_types.h:166
bool operator<(const WireIDIntersection &otherIntersect) const
Definition: geo_types.h:797
static constexpr OpDetID_t InvalidID
Special code for an invalid ID.
Definition: geo_types.h:313
double y
y position of intersection
Definition: geo_types.h:791
WireID & asWireID()
Conversion to WireID (for convenience of notation).
Definition: geo_types.h:604
static constexpr Level_t Wire
Definition: geo_types.h:180
constexpr ParentID_t const & parentID() const
Return the parent ID of this one (a plane ID).
Definition: geo_types.h:588
Drift towards negative values.
Definition: geo_types.h:165
constexpr OpDetID const & asOpDetID() const
Conversion to OpDetID (for convenience of notation).
Definition: geo_types.h:356
ParentID_t & parentID()
Return the parent ID of this one (a cryostat ID).
Definition: geo_types.h:344
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (TPC&#39;s).
Definition: geo_types.h:420
constexpr OpDetID(CryostatID const &cryoid, OpDetID_t o)
Definition: geo_types.h:323
constexpr PlaneID const & asConstPlaneID()
Conversion to PlaneID (for convenience of notation).
Definition: geo_types.h:524
void ParentID_t
Type of the parent ID (none!).
Definition: geo_types.h:196
unsigned int WireID_t
Type for the ID number.
Definition: geo_types.h:546
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
Definition: geo_types.h:939
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
static constexpr CryostatID_t InvalidID
Special code for an invalid ID.
Definition: geo_types.h:208
auto getRelIDindex(ID const &id)
Definition: geo_types.h:76
constexpr OpDetID(CryostatID_t c, OpDetID_t o)
Constructor: opdtical detector with index o in the cryostat index c
Definition: geo_types.h:326
Planes which measure W (third view for Bo, MicroBooNE, etc).
Definition: geo_types.h:137
constexpr PlaneID const & planeID() const
Definition: geo_types.h:620
static constexpr PlaneID_t InvalidID
Special code for an invalid ID.
Definition: geo_types.h:479
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:399
auto & writeIndex()
Returns the index level Index of this type.
Definition: geo_types.h:954
The data type to uniquely identify a optical detector.
Definition: geo_types.h:297
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
Definition: geo_types.h:895
recob::tracking::Plane Plane
Definition: TrackState.h:17
Namespace collecting geometry-related classes utilities.
constexpr int cmp(CryostatID const &other) const
Returns < 0 if this is smaller than other, 0 if equal, > 0 if larger.
Definition: geo_types.h:269
auto & deepestIndex()
Returns the deepest ID available (OpDet&#39;s).
Definition: geo_types.h:340
static constexpr PlaneID_t getInvalidID()
Return the value of the invalid plane ID as a r-value.
Definition: geo_types.h:540
constexpr OpDetID const & asConstOpDetID()
Conversion to OpDetID (for convenience of notation).
Definition: geo_types.h:360
Float_t w
Definition: plot.C:20
std::size_t Level_t
Definition: geo_types.h:174
constexpr TPCID(CryostatID const &cryoid, TPCID_t t)
Constructor: TPC with index t in the cryostat identified by cryoid.
Definition: geo_types.h:405
constexpr int cmp(PlaneID const &other) const
Returns < 0 if this is smaller than other, 0 if equal, > 0 if larger.
Definition: geo_types.h:527
constexpr auto getIndex() const
Returns the index level Index of this type.
Definition: geo_types.h:859
ParentID_t parentID()
Return the parent ID of this one (void).
Definition: geo_types.h:257
std::string SignalTypeName(geo::SigType_t sigType)
Returns the name of the specified signal type.
Definition: geo_types.cxx:18
The data type to uniquely identify a cryostat.
Definition: geo_types.h:192
constexpr ParentID_t const & parentID() const
Return the parent ID of this one (a TPC ID).
Definition: geo_types.h:506
Signal from collection planes.
Definition: geo_types.h:152
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (cryostat&#39;s).
Definition: geo_types.h:251