13 #ifndef LARCOREOBJ_SIMPLETYPESANDCONSTANTS_GEO_TYPES_H 14 #define LARCOREOBJ_SIMPLETYPESANDCONSTANTS_GEO_TYPES_H 31 template <
typename ID>
34 template <
typename ID>
37 if constexpr (isTopGeoElementID<ID>)
40 return geoElementLevel<typename ID::ParentID_t>() + 1U;
43 template <
typename ID, std::
size_t Index,
typename =
void>
46 template <std::
size_t Index,
typename ID>
49 template <
typename ID, std::
size_t UpIndex>
52 template <std::
size_t UpIndex,
typename ID>
55 template <std::
size_t Index,
typename ID>
58 static_assert(Index <=
ID::Level,
"Index not available for this type.");
60 return id.deepestIndex();
62 return getAbsIDindex<Index>(
id.parentID());
65 template <std::
size_t Index,
typename ID>
68 static_assert(Index <=
ID::Level,
"Index not available for this type.");
70 return id.deepestIndex();
72 return getAbsIDindex<Index>(
id.parentID());
75 template <std::
size_t UpIndex,
typename ID>
78 static_assert(UpIndex <=
ID::Level,
"Index not available for this type.");
79 if constexpr (UpIndex == 0)
80 return id.deepestIndex();
199 template <std::
size_t L>
203 template <std::
size_t A>
208 static constexpr
CryostatID_t InvalidID = std::numeric_limits<CryostatID_t>::max();
210 bool isValid =
false;
226 explicit constexpr
operator bool()
const {
return isValid; }
246 explicit operator std::string()
const {
return toString(); }
259 template <std::
size_t Index = 0U>
260 constexpr
auto getIndex()
const;
262 template <std::
size_t Index = 0U>
265 template <std::
size_t Above>
266 constexpr
auto getRelIndex()
const;
271 return ThreeWayComparison(deepestIndex(), other.
deepestIndex());
288 template <
typename T>
291 return (a == b) ? 0 : ((a < b) ? -1 : +1);
304 template <std::
size_t L>
308 template <std::
size_t A>
313 static constexpr
OpDetID_t InvalidID = std::numeric_limits<OpDetID_t>::max();
333 explicit operator std::string()
const {
return toString(); }
346 template <std::
size_t Index = 0U>
347 constexpr
auto getIndex()
const;
349 template <std::
size_t Index = 0U>
352 template <std::
size_t Above>
353 constexpr
auto getRelIndex()
const;
367 return ThreeWayComparison(deepestIndex(), other.
deepestIndex());
388 template <std::
size_t L>
392 template <std::
size_t A>
397 static constexpr
TPCID_t InvalidID = std::numeric_limits<TPCID_t>::max();
402 constexpr
TPCID() =
default;
415 explicit operator std::string()
const {
return toString(); }
428 template <std::
size_t Index = 0U>
429 constexpr
auto getIndex()
const;
431 template <std::
size_t Index = 0U>
434 template <std::
size_t Above>
435 constexpr
auto getRelIndex()
const;
449 return ThreeWayComparison(deepestIndex(), other.
deepestIndex());
470 template <std::
size_t L>
474 template <std::
size_t A>
479 static constexpr
PlaneID_t InvalidID = std::numeric_limits<PlaneID_t>::max();
497 explicit operator std::string()
const {
return toString(); }
510 template <std::
size_t Index = 0U>
511 constexpr
auto getIndex()
const;
513 template <std::
size_t Index = 0U>
516 template <std::
size_t Above>
517 constexpr
auto getRelIndex()
const;
531 return ThreeWayComparison(deepestIndex(), other.
deepestIndex());
552 template <std::
size_t L>
556 template <std::
size_t A>
561 static constexpr
WireID_t InvalidID = std::numeric_limits<WireID_t>::max();
566 constexpr
WireID() =
default;
579 explicit operator std::string()
const {
return toString(); }
592 template <std::
size_t Index = 0U>
593 constexpr
auto getIndex()
const;
595 template <std::
size_t Index = 0U>
598 template <std::
size_t Above>
599 constexpr
auto getRelIndex()
const;
613 return ThreeWayComparison(deepestIndex(), other.
deepestIndex());
657 out << ((
TPCID const&)pid) <<
" P:" << pid.
Plane;
722 return (static_cast<CryostatID const&>(a) == static_cast<CryostatID const&>(b)) &&
729 return (static_cast<CryostatID const&>(a) != static_cast<CryostatID const&>(b)) ||
736 int cmp_res = (
static_cast<CryostatID const&
>(a)).cmp(b);
746 return (static_cast<TPCID const&>(a) == static_cast<TPCID const&>(b)) && (a.
Plane == b.
Plane);
752 return (static_cast<TPCID const&>(a) != static_cast<TPCID const&>(b)) || (a.
Plane != b.
Plane);
758 int cmp_res = (
static_cast<TPCID const&
>(a)).cmp(b);
768 return (static_cast<PlaneID const&>(a) == static_cast<PlaneID const&>(b)) && (a.
Wire == b.
Wire);
774 return (static_cast<PlaneID const&>(a) != static_cast<PlaneID const&>(b)) || (a.
Wire != b.
Wire);
780 int cmp_res = (
static_cast<PlaneID const&
>(a)).cmp(b);
817 template <
typename ID, std::size_t Index,
typename >
818 struct AbsIDtypeStruct {
819 static_assert(Index <=
ID::Level,
"Requested ID index is not available.");
823 template <
typename ID, std::
size_t Index>
829 template <
typename ID, std::
size_t UpIndex>
831 static_assert(UpIndex <=
ID::Level,
"Requested parent ID index is not available.");
835 template <
typename ID>
841 template <
typename T>
844 std::ostringstream sstr;
858 template <std::size_t Index >
861 static_assert(Index <=
Level,
"This ID type does not have the requested Index level.");
862 return details::getAbsIDindex<Index>(*this);
865 template <std::size_t Index >
868 static_assert(Index <=
Level,
"This ID type does not have the requested Index level.");
869 return details::getAbsIDindex<Index>(*this);
872 template <std::
size_t Above>
875 static_assert(Above <=
Level,
"This ID type does not have the requested Index level.");
876 return getIndex<
Level - Above>();
880 template <std::size_t Index >
883 static_assert(Index <=
Level,
"This ID type does not have the requested Index level.");
884 return details::getAbsIDindex<Index>(*this);
887 template <std::size_t Index >
890 static_assert(Index <=
Level,
"This ID type does not have the requested Index level.");
891 return details::getAbsIDindex<Index>(*this);
894 template <std::
size_t Above>
897 static_assert(Above <=
Level,
"This ID type does not have the requested Index level.");
898 return getIndex<
Level - Above>();
902 template <std::size_t Index >
905 static_assert(Index <=
Level,
"This ID type does not have the requested Index level.");
906 return details::getAbsIDindex<Index>(*this);
909 template <std::size_t Index >
912 static_assert(Index <=
Level,
"This ID type does not have the requested Index level.");
913 return details::getAbsIDindex<Index>(*this);
916 template <std::
size_t Above>
919 static_assert(Above <=
Level,
"This ID type does not have the requested Index level.");
920 return getIndex<
Level - Above>();
924 template <std::size_t Index >
927 static_assert(Index <=
Level,
"This ID type does not have the requested Index level.");
928 return details::getAbsIDindex<Index>(*this);
931 template <std::size_t Index >
934 static_assert(Index <=
Level,
"This ID type does not have the requested Index level.");
935 return details::getAbsIDindex<Index>(*this);
938 template <std::
size_t Above>
941 static_assert(Above <=
Level,
"This ID type does not have the requested Index level.");
942 return getIndex<
Level - Above>();
946 template <std::size_t Index >
949 static_assert(Index <=
Level,
"This ID type does not have the requested Index level.");
950 return details::getAbsIDindex<Index>(*this);
953 template <std::size_t Index >
956 static_assert(Index <=
Level,
"This ID type does not have the requested Index level.");
957 return details::getAbsIDindex<Index>(*this);
960 template <std::
size_t Above>
963 static_assert(Above <=
Level,
"This ID type does not have the requested Index level.");
964 return getIndex<
Level - Above>();
969 #endif // LARCOREOBJ_SIMPLETYPESANDCONSTANTS_GEO_TYPES_H constexpr CryostatID(CryostatID_t c)
Constructor: valid ID of cryostat with index c.
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.
ParentID_t & parentID()
Return the parent ID of this one (a plane ID).
constexpr int cmp(TPCID const &other) const
Returns < 0 if this is smaller than other, 0 if equal, > 0 if larger.
constexpr auto getIndex() const
Returns the index level Index of this type.
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
coordinates
Enumerate the possible plane projections.
constexpr auto getIndex() const
Returns the index level Index of this type.
double z
z position of intersection
constexpr WireID const & asWireID() const
Conversion to WireID (for convenience of notation).
typename RelIDtypeStruct< ID, UpIndex >::type RelIDtype
Drift direction is unknown.
static constexpr TPCID_t InvalidID
Special code for an invalid ID.
_plane_orient
Enumerate the possible plane projections.
TPCID & asTPCID()
Conversion to TPCID (for convenience of notation).
auto & writeIndex()
Returns the index level Index of this type.
constexpr PlaneID(TPCID const &tpcid, PlaneID_t p)
Constructor: plane with index p in the TPC identified by tpcid.
details::AbsIDtype< L, ThisID_t > ID_t
Type of the ID with the specified level L.
void setValidity(bool valid)
Sets the validity of the ID.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
auto & writeIndex()
Returns the index level Index of this type.
static constexpr int ThreeWayComparison(T a, T b)
Returns < 0 if a < b, 0 if a == b, > 0 if a > b.
constexpr std::size_t geoElementLevel()
constexpr WireID(PlaneID const &planeid, WireID_t w)
Constructor: wire with index w in the plane identified by planeid.
Drift towards positive values.
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.
constexpr int cmp(OpDetID const &other) const
Returns < 0 if this is smaller than other, 0 if equal, > 0 if larger.
_plane_sigtype
Enumerate the possible plane projections.
auto & deepestIndex()
Returns the deepest ID available (plane's).
ParentID_t & parentID()
Return the parent ID of this one (a TPC ID).
constexpr WireID const & asConstWireID()
Conversion to WireID (for convenience of notation).
unsigned int PlaneID_t
Type for the ID number.
Planes which measure X direction.
The data type to uniquely identify a Plane.
constexpr auto abs(T v)
Returns the absolute value of the argument.
CryostatID & asCryostatID()
Conversion to CryostatID (for convenience of notation).
constexpr bool operator==(CryostatID const &a, CryostatID const &b)
Comparison: the IDs point to the same cryostat (validity is ignored)
constexpr auto getIndex() const
Returns the index level Index of this type.
OpDetID & asOpDetID()
Conversion to OpDetID (for convenience of notation).
constexpr WireID(CryostatID_t c, TPCID_t t, PlaneID_t p, WireID_t w)
CryostatID_t Cryostat
Index of cryostat.
_plane_proj
Enumerate the possible plane projections.
Planes which measure Z direction.
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (plane's).
static constexpr WireID_t InvalidID
Special code for an invalid ID.
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
WireID_t Wire
Index of the wire within its plane.
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).
Drift towards negative X values.
unsigned int TPC
TPC of intersection.
constexpr bool operator!() const
Returns true if the ID is not valid.
static constexpr Level_t Plane
typename AbsIDtypeStruct< typename ID::ParentID_t, Index >::type type
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (wire's).
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (OpDet's).
auto & deepestIndex()
Returns the deepest ID available (TPC's).
Planes which measure Y direction.
details::RelIDtype< A, ThisID_t > UpperID_t
Type of the ID A levels above this one.
constexpr int cmp(WireID const &other) const
Returns < 0 if this is smaller than tpcid, 0 if equal, > 0 if larger.
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.
3-dimensional objects, potentially hits, clusters, prongs, etc.
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.
static constexpr CryostatID_t getInvalidID()
Return the value of the invalid ID as a r-value.
constexpr bool isTopGeoElementID
Whether ID represents an element on top of the hierarchy.
auto & deepestIndex()
Returns the deepest ID available (cryostat's).
OpDetID_t OpDet
Index of the optical detector within its cryostat.
typename AbsIDtypeStruct< ID, Index >::type AbsIDtype
auto & deepestIndex()
Returns the deepest ID available (wire's).
Planes that are in the horizontal plane.
static constexpr TPCID_t getInvalidID()
Return the value of the invalid TPC ID as a r-value.
constexpr TPCID const & asConstTPCID()
Conversion to TPCID (for convenience of notation).
driftdir
Drift direction: positive or negative.
static constexpr Level_t OpDet
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.
Planes that are in the vertical plane (e.g. ArgoNeuT).
constexpr bool operator!=(CryostatID const &a, CryostatID const &b)
Comparison: the IDs point to different cryostats (validity is ignored)
static constexpr Level_t TPC
auto & writeIndex()
Returns the index level Index of this type.
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
constexpr CryostatID const & asConstCryostatID()
Conversion to CryostatID (for convenience of notation).
void markValid()
Sets the ID as valid.
constexpr auto getIndex() const
Returns the index level Index of this type.
constexpr CryostatID const & asCryostatID() const
Conversion to CryostatID (for convenience of notation).
constexpr PlaneID const & asPlaneID() const
Conversion to PlaneID (for convenience of notation).
PlaneID & asPlaneID()
Conversion to PlaneID (for convenience of notation).
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
static constexpr Level_t Cryostat
constexpr ParentID_t parentID() const
Return the parent ID of this one (void).
void markInvalid()
Sets the ID as invalid.
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
constexpr CryostatID(CryostatID_t c, bool valid)
Constructor: valid ID of cryostat with index c.
ParentID_t & parentID()
Return the parent ID of this one (a cryostat ID).
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
constexpr auto getAbsIDindex(ID const &id)
constexpr TPCID const & asTPCID() const
Conversion to TPCID (for convenience of notation).
constexpr PlaneID(CryostatID_t c, TPCID_t t, PlaneID_t p)
Constructor: plane with index p in the cryostat index c, TPC index t.
static constexpr WireID_t getInvalidID()
Return the value of the invalid wire ID as a r-value.
typename RelIDtypeStruct< typename ID::ParentID_t, UpIndex-1U >::type type
auto & writeIndex()
Returns the index level Index of this type.
unsigned int CryostatID_t
Type for the ID number.
unsigned int OpDetID_t
Type for the ID number.
constexpr ParentID_t const & parentID() const
Return the parent ID of this one (a cryostat ID).
unsigned int TPCID_t
Type for the ID number.
Drift towards positive X values.
bool operator<(const WireIDIntersection &otherIntersect) const
static constexpr OpDetID_t InvalidID
Special code for an invalid ID.
double y
y position of intersection
WireID & asWireID()
Conversion to WireID (for convenience of notation).
static constexpr Level_t Wire
constexpr ParentID_t const & parentID() const
Return the parent ID of this one (a plane ID).
Drift towards negative values.
constexpr OpDetID const & asOpDetID() const
Conversion to OpDetID (for convenience of notation).
ParentID_t & parentID()
Return the parent ID of this one (a cryostat ID).
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (TPC's).
constexpr OpDetID(CryostatID const &cryoid, OpDetID_t o)
constexpr PlaneID const & asConstPlaneID()
Conversion to PlaneID (for convenience of notation).
void ParentID_t
Type of the parent ID (none!).
unsigned int WireID_t
Type for the ID number.
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
static constexpr CryostatID_t InvalidID
Special code for an invalid ID.
auto getRelIDindex(ID const &id)
constexpr OpDetID(CryostatID_t c, OpDetID_t o)
Constructor: opdtical detector with index o in the cryostat index c
Planes which measure W (third view for Bo, MicroBooNE, etc).
constexpr PlaneID const & planeID() const
static constexpr PlaneID_t InvalidID
Special code for an invalid ID.
TPCID_t TPC
Index of the TPC within its cryostat.
auto & writeIndex()
Returns the index level Index of this type.
The data type to uniquely identify a optical detector.
constexpr auto getRelIndex() const
Returns the index Above levels higher than Level.
recob::tracking::Plane Plane
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.
auto & deepestIndex()
Returns the deepest ID available (OpDet's).
static constexpr PlaneID_t getInvalidID()
Return the value of the invalid plane ID as a r-value.
constexpr OpDetID const & asConstOpDetID()
Conversion to OpDetID (for convenience of notation).
constexpr TPCID(CryostatID const &cryoid, TPCID_t t)
Constructor: TPC with index t in the cryostat identified by cryoid.
constexpr int cmp(PlaneID const &other) const
Returns < 0 if this is smaller than other, 0 if equal, > 0 if larger.
constexpr auto getIndex() const
Returns the index level Index of this type.
ParentID_t parentID()
Return the parent ID of this one (void).
std::string SignalTypeName(geo::SigType_t sigType)
Returns the name of the specified signal type.
The data type to uniquely identify a cryostat.
constexpr ParentID_t const & parentID() const
Return the parent ID of this one (a TPC ID).
Signal from collection planes.
constexpr auto const & deepestIndex() const
Returns the value of the deepest ID available (cryostat's).