LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
geo::WireReadoutGeom Class Referenceabstract

Interface for a class providing readout channel mapping to geometry. More...

#include "WireReadoutGeom.h"

Inheritance diagram for geo::WireReadoutGeom:
geo::Iterable< details::ReadoutIterationPolicy, details::ToReadoutGeometryElement > geo::WireReadoutStandardGeom

Public Types

using Segment = std::pair< Point_t, Point_t >
 

Public Member Functions

 WireReadoutGeom (GeometryCore const *geom, std::unique_ptr< WireReadoutGeometryBuilder > builder, std::unique_ptr< WireReadoutSorter > sorter)
 
virtual ~WireReadoutGeom ()
 
unsigned int MaxPlanes () const
 Returns the largest number of planes among all TPCs in this detector. More...
 
unsigned int Nviews () const
 Returns the number of views (different wire orientations) More...
 
std::set< View_t > const & Views () const
 Returns a list of possible views in the detector. More...
 
std::set< View_tViews (TPCID const &tpcid) const
 
void WireEndPoints (WireID const &wireid, double *xyzStart, double *xyzEnd) const
 Fills two arrays with the coordinates of the wire end points. More...
 
double ThirdPlane_dTdW (PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2, PlaneID const &output_plane) const
 Returns dT/dW on the third plane, given it in the other two. More...
 
double ThirdPlane_dTdW (PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2) const
 Returns dT/dW on the third plane, given it in the other two. More...
 
double Plane0Pitch (TPCID const &tpcid, unsigned int p1) const
 
double PlanePitch (TPCID const &tpcid, unsigned int p1=0, unsigned int p2=1) const
 
bool HasPlane (PlaneID const &planeid) const
 Returns whether we have the specified plane. More...
 
bool HasElement (PlaneID const &planeid) const
 Returns whether we have the specified plane. More...
 
unsigned int Nplanes (TPCID const &tpcid=details::tpc_zero) const
 Returns the total number of planes in the specified TPC. More...
 
unsigned int NElements (TPCID const &tpcid) const
 Returns the total number of planes in the specified TPC. More...
 
unsigned int NSiblingElements (PlaneID const &planeid) const
 Returns the total number of planes in the specified TPC. More...
 
PlaneGeo const & FirstPlane (TPCID const &tpcid) const
 Returns the first plane of the specified TPC. More...
 
PlaneGeo const & Plane (TPCID const &tpcid, View_t view) const
 Returns the specified wire. More...
 
PlaneGeo const & Plane (PlaneID const &planeid) const
 Returns the specified wire. More...
 
PlaneGeo const & GetElement (PlaneID const &planeid) const
 Returns the specified wire. More...
 
PlaneGeo const * PlanePtr (PlaneID const &planeid) const
 Returns the specified plane. More...
 
PlaneGeo const * GetElementPtr (PlaneID const &planeid) const
 Returns the specified plane. More...
 
Wire details
unsigned int MaxWires () const
 Returns the total number of wires in the specified plane. More...
 
unsigned int Nwires (PlaneID const &planeid) const
 Returns the total number of wires in the specified plane. More...
 
unsigned int NElements (PlaneID const &planeid) const
 Returns the total number of wires in the specified plane. More...
 
unsigned int NSiblingElements (WireID const &wireid) const
 Returns the total number of wires in the specified plane. More...
 
bool HasWire (WireID const &wireid) const
 Returns whether we have the specified wire. More...
 
bool HasElement (WireID const &wireid) const
 Returns whether we have the specified wire. More...
 
WireGeo const * WirePtr (WireID const &wireid) const
 Returns the specified wire. More...
 
WireGeo const * GetElementPtr (WireID const &wireid) const
 Returns the specified wire. More...
 
WireGeo const & Wire (WireID const &wireid) const
 Returns the specified wire. More...
 
WireGeo const & GetElement (WireID const &wireid) const
 Returns the specified wire. More...
 
Segment WireEndPoints (WireID const &wireid) const
 Returns a segment whose ends are the wire end points. More...
 
Wire access and information
double WireAngleToVertical (View_t view, TPCID const &tpcid) const
 Returns the angle of the wires in the specified view from vertical. More...
 
bool WireIDsIntersect (WireID const &wid1, WireID const &wid2, Point_t &intersection) const
 Computes the intersection between two wires. More...
 
std::optional< WireIDIntersectionWireIDsIntersect (WireID const &wid1, WireID const &wid2) const
 Computes the intersection between two wires. More...
 
Wire geometry queries

Please note the differences between functions: ChannelsIntersect(), WireIDsIntersect() and IntersectionPoint() all calculate wires intersection using the same equation. ChannelsIntersect() and WireIdsIntersect() will return true if the two wires cross, return false if they don't. IntersectionPoint() does not check if the two wires cross.

PlaneID ThirdPlane (PlaneID const &pid1, PlaneID const &pid2) const
 Returns the plane that is not in the specified arguments. More...
 
double ThirdPlaneSlope (PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2, PlaneID const &output_plane) const
 Returns the slope on the third plane, given it in the other two. More...
 
double ThirdPlaneSlope (PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2) const
 Returns the slope on the third plane, given it in the other two. More...
 
double ThirdPlaneSlope (PlaneID::PlaneID_t plane1, double slope1, PlaneID::PlaneID_t plane2, double slope2, TPCID const &tpcid) const
 Returns the slope on the third plane, given it in the other two. More...
 
TPC channel mapping
virtual unsigned int Nchannels () const =0
 Returns the total number of channels present (not necessarily contiguous) More...
 
virtual unsigned int Nchannels (readout::ROPID const &ropid) const =0
 Returns the number of channels in the specified ROP. More...
 
std::vector< raw::ChannelID_tChannelsInTPCs () const
 Returns an std::vector<ChannelID_t> in all TPCs in a TPCSet. More...
 
virtual bool HasChannel (raw::ChannelID_t channel) const
 Returns whether the specified channel is valid This default implementation assumes all channels up to Nchannels() valid. More...
 
virtual std::vector< WireIDChannelToWire (raw::ChannelID_t channel) const =0
 
View_t View (raw::ChannelID_t const channel) const
 Returns the view (wire orientation) on the specified TPC channel. More...
 
View_t View (readout::ROPID const &ropid) const
 Returns the view of the channels in the specified readout plane. More...
 
SigType_t SignalType (PlaneID const &pid) const
 Returns the type of signal on the channels of specified TPC plane. More...
 
SigType_t SignalType (raw::ChannelID_t const channel) const
 Return the signal type of the specified channel. More...
 
SigType_t SignalType (readout::ROPID const &ropid) const
 Return the signal type on the specified readout plane. More...
 
raw::ChannelID_t NearestChannel (Point_t const &worldLoc, PlaneID const &planeid) const
 Returns the ID of the channel nearest to the specified position. More...
 
std::optional< WireIDIntersectionChannelsIntersect (raw::ChannelID_t c1, raw::ChannelID_t c2) const
 Returns an intersection point of two channels. More...
 
virtual std::set< PlaneID > const & PlaneIDs () const =0
 Returns a list of the plane IDs in the whole detector. More...
 
virtual raw::ChannelID_t PlaneWireToChannel (WireID const &wireID) const =0
 Returns the channel ID a wire is connected to. More...
 
Optical detector channel mapping
virtual unsigned int NOpChannels (unsigned int NOpDets) const
 Returns the number of optical channels contained in some detectors. More...
 
unsigned int NOpChannels () const
 Number of electronics channels for all the optical detectors. More...
 
unsigned int MaxOpChannel () const
 Largest optical channel number. More...
 
bool IsValidOpChannel (int opChannel) const
 Is this a valid OpChannel number? More...
 
virtual unsigned int MaxOpChannel (unsigned int NOpDets) const
 Returns the number of optical channels contained in some detectors. More...
 
virtual unsigned int NOpHardwareChannels (unsigned int opDet) const
 Returns the number of channels in the specified optical detectors. More...
 
virtual bool IsValidOpChannel (unsigned int opChannel, unsigned int NOpDets) const
 Returns whether the ID identifies a valid optical detector channel. More...
 
virtual unsigned int OpChannel (unsigned int detNum, unsigned int hwchannel=0) const
 Returns the channel ID of the specified hardware channel. More...
 
virtual unsigned int OpDetFromOpChannel (unsigned int opChannel) const
 Returns the optical detector the specified optical channel belongs. More...
 
OpDetGeo const & OpDetGeoFromOpChannel (unsigned int opChannel) const
 Returns the optical detector the specified optical channel belongs. More...
 
virtual unsigned int HardwareChannelFromOpChannel (unsigned int opChannel) const
 Returns the hardware channel number of specified optical channel. More...
 
Mapping of position to wires
virtual double WireCoordinate (double YPos, double ZPos, PlaneID const &planeID) const =0
 Returns the index of the wire nearest to the specified position. More...
 
virtual WireID NearestWireID (Point_t const &worldPos, PlaneID const &planeID) const =0
 Returns the ID of the wire nearest to the specified position. More...
 
TPC set mapping
virtual unsigned int NTPCsets (readout::CryostatID const &cryoid) const =0
 Returns the total number of TPC sets in the specified cryostat. More...
 
virtual unsigned int MaxTPCsets () const =0
 Returns the largest number of TPC sets any cryostat in the detector has. More...
 
virtual bool HasTPCset (readout::TPCsetID const &tpcsetid) const =0
 
readout::TPCsetID FindTPCsetAtPosition (Point_t const &worldLoc) const
 Returns the total number of TPC sets in the specified cryostat. More...
 
virtual readout::TPCsetID TPCtoTPCset (TPCID const &tpcid) const =0
 Returns the ID of the TPC set tpcid belongs to. More...
 
virtual std::vector< TPCIDTPCsetToTPCs (readout::TPCsetID const &tpcsetid) const =0
 Returns a list of ID of TPCs belonging to the specified TPC set. More...
 
virtual TPCID FirstTPCinTPCset (readout::TPCsetID const &tpcsetid) const =0
 Returns the ID of the first TPC belonging to the specified TPC set. More...
 
Readout plane mapping
virtual unsigned int NROPs (readout::TPCsetID const &tpcsetid) const =0
 Returns the total number of ROP in the specified TPC set. More...
 
virtual unsigned int MaxROPs () const =0
 Returns the largest number of ROPs a TPC set in the detector has. More...
 
virtual bool HasROP (readout::ROPID const &ropid) const =0
 
virtual readout::ROPID WirePlaneToROP (PlaneID const &planeid) const =0
 Returns the ID of the ROP planeid belongs to. More...
 
virtual std::vector< PlaneIDROPtoWirePlanes (readout::ROPID const &ropid) const =0
 Returns a list of ID of planes belonging to the specified ROP. More...
 
virtual PlaneID FirstWirePlaneInROP (readout::ROPID const &ropid) const =0
 Returns the ID of the first plane belonging to the specified ROP. More...
 
virtual std::vector< TPCIDROPtoTPCs (readout::ROPID const &ropid) const =0
 Returns a list of ID of TPCs the specified ROP spans. More...
 
virtual readout::ROPID ChannelToROP (raw::ChannelID_t channel) const =0
 Returns the ID of the ROP the channel belongs to. More...
 
virtual raw::ChannelID_t FirstChannelInROP (readout::ROPID const &ropid) const =0
 Returns the ID of the first channel in the specified readout plane. More...
 
Testing (not in the interface)
std::vector< std::vector< std::vector< raw::ChannelID_t > > > const & FirstChannelInNextPlane () const
 Retrieve the private fFirstChannelInNextPlane vector for testing. More...
 
std::vector< std::vector< std::vector< raw::ChannelID_t > > > const & FirstChannelInThisPlane () const
 Retrieve the private fFirstChannelInThisPlane vector for testing. More...
 

Static Public Member Functions

static auto const & start (Segment const &s)
 
static auto const & finish (Segment const &s)
 
static double ComputeThirdPlaneSlope (double angle1, double slope1, double angle2, double slope2, double angle_target)
 Returns the slope on the third plane, given it in the other two. More...
 
static double ComputeThirdPlane_dTdW (double angle1, double pitch1, double dTdW1, double angle2, double pitch2, double dTdW2, double angle_target, double pitch_target)
 Returns the slope on the third plane, given it in the other two. More...
 

Protected Types

template<typename T >
using TPCInfoMap_t = std::vector< std::vector< T >>
 Data type for per-TPC information. More...
 
template<typename T >
using PlaneInfoMap_t = TPCInfoMap_t< std::vector< T >>
 Data type for per-plane information. More...
 

Protected Member Functions

virtual SigType_t SignalTypeForChannelImpl (raw::ChannelID_t const channel) const =0
 Return the signal type of the specified channel. More...
 
virtual SigType_t SignalTypeForROPIDImpl (readout::ROPID const &ropid) const
 Return the signal type on the specified readout plane. More...
 
template<typename T >
T const & AccessElement (PlaneInfoMap_t< T > const &map, PlaneID const &id) const
 Returns the specified element of the plane map. More...
 
template<typename T >
size_t AccessElementSize (PlaneInfoMap_t< T > const &map, TPCID const &id) const
 Returns the number of elements in the specified TPC of the plane map. More...
 
template<typename T >
T const * GetElementPtr (PlaneInfoMap_t< T > const &map, PlaneID const &id) const
 Returns a pointer to the specified element, or nullptr if invalid. More...
 
Internal structure data access

These functions allow access to the XxxInfoMap_t types based on geometry element IDs. They are strictly internal.

template<typename T >
T const & AccessElement (TPCInfoMap_t< T > const &map, TPCID const &id) const
 Returns the specified element of the TPC map. More...
 
template<typename T >
size_t AccessElementSize (TPCInfoMap_t< T > const &map, CryostatID const &id) const
 Returns the number of elements in the specified cryostat of the TPC map. More...
 
template<typename T >
bool isValidElement (TPCInfoMap_t< T > const &map, CryostatID const &id) const
 Returns whether the ID specifies a valid entry. More...
 
template<typename T >
bool isValidElement (TPCInfoMap_t< T > const &map, TPCID const &id) const
 Returns the specified element of the TPC map. More...
 
template<typename T >
bool isValidElement (PlaneInfoMap_t< T > const &map, CryostatID const &id) const
 Returns whether the ID specifies a valid entry. More...
 
template<typename T >
bool isValidElement (PlaneInfoMap_t< T > const &map, TPCID const &id) const
 Returns whether the ID specifies a valid entry. More...
 
template<typename T >
bool isValidElement (PlaneInfoMap_t< T > const &map, PlaneID const &id) const
 Returns whether the ID specifies a valid entry. More...
 

Protected Attributes

PlaneInfoMap_t< raw::ChannelID_tfFirstChannelInThisPlane
 
PlaneInfoMap_t< raw::ChannelID_tfFirstChannelInNextPlane
 

Private Types

using Iteration = Iterable< details::ReadoutIterationPolicy, details::ToReadoutGeometryElement >
 
using range_type = details::RangeType< iterator_type< T >, id_sentinel_for< T >>
 

Private Member Functions

bool WireIDIntersectionCheck (WireID const &wid1, WireID const &wid2) const
 Wire ID check for WireIDsIntersect methods. More...
 
void ResetDriftDirection (TPCID const &tpcid)
 Recomputes the drift direction; needs planes to have been initialised. More...
 
void UpdateAfterSorting (TPCGeo const &tpc, std::vector< PlaneGeo > &planes)
 
void SortPlanes (TPCID const &tpcid, std::vector< PlaneGeo > &planes) const
 Sorts (in place) the specified PlaneGeo objects by drift distance. More...
 
void SortSubVolumes (std::vector< PlaneGeo > &planes, Compare< WireGeo > compareWires) const
 
iterator_type< T > begin () const
 
iterator_type< T > begin (BaseID const &id) const
 
id_sentinel_for< T > end () const
 
id_sentinel_for< T > end (BaseID const &id) const
 
range_type< T > Iterate () const
 
range_type< T > Iterate (ID const &id) const
 

Private Attributes

std::map< TPCID, std::vector< PlaneGeo > > fPlanes
 
std::map< TPCID, std::vector< double > > fPlane0Pitch
 Pitch between planes. More...
 
std::set< View_tallViews
 All views in the detector. More...
 
GeometryCore const * fGeom
 

Detailed Description

Interface for a class providing readout channel mapping to geometry.

Note
A number of methods react specifically when provided with invalid IDs as arguments. An invalid ID is an ID with the isValid flag unset, or, in case of channel IDs, an ID with value raw::InvalidChannelID. An ID that does not present this feature is by definition "valid"; this does not imply that the represented entity (channel, geometry entity or readout group) actually exists. The behaviour of the methods to valid, non-existent IDs should be considered undefined, and it is recommended that the existence of the entity is checked beforehand. Unless the documentation explicitly defines a behaviour, an undefined behaviour should be assumed; nevertheless, the documentation of some of the methods still reminds of this.

Definition at line 52 of file WireReadoutGeom.h.

Member Typedef Documentation

template<typename T >
using geo::WireReadoutGeom::PlaneInfoMap_t = TPCInfoMap_t<std::vector<T>>
protected

Data type for per-plane information.

Definition at line 982 of file WireReadoutGeom.h.

Definition at line 62 of file WireReadoutGeom.h.

template<typename T >
using geo::WireReadoutGeom::TPCInfoMap_t = std::vector<std::vector<T>>
protected

Data type for per-TPC information.

Definition at line 978 of file WireReadoutGeom.h.

Constructor & Destructor Documentation

geo::WireReadoutGeom::WireReadoutGeom ( GeometryCore const *  geom,
std::unique_ptr< WireReadoutGeometryBuilder builder,
std::unique_ptr< WireReadoutSorter sorter 
)
explicit

Definition at line 67 of file WireReadoutGeom.cxx.

References allViews, fGeom, fPlane0Pitch, fPlanes, geo::Iterable< IterationPolicy, Transform >::Iterate(), SortPlanes(), SortSubVolumes(), UpdateAfterSorting(), Views(), and ~WireReadoutGeom().

70  : Iteration{details::ReadoutIterationPolicy{geom, this},
71  details::ToReadoutGeometryElement{this}}
72  , fGeom{geom}
73  {
74  GeoNodePath path{geom->ROOTGeoManager()->GetTopNode()};
75  auto planesPerTPC = builder->extractPlanes(path);
76 
77  Compare<WireGeo> compareWires = [&sorter](auto const& a, auto const& b) {
78  return sorter->compareWires(a, b);
79  };
80 
81  // Update views
82  std::set<View_t> updatedViews;
83  for (auto const& tpc : fGeom->Iterate<TPCGeo>()) {
84  auto& planes = fPlanes[tpc.ID()] = planesPerTPC.at(tpc.Hash());
85  SortPlanes(tpc.ID(), planes);
86  SortSubVolumes(planes, compareWires);
87  UpdateAfterSorting(tpc, planes);
88 
89  auto const& TPCviews = ::Views(planes);
90  updatedViews.insert(TPCviews.cbegin(), TPCviews.cend());
91  fPlane0Pitch[tpc.ID()] = Pitches(planes);
92  }
93  allViews = std::move(updatedViews);
94  }
void SortPlanes(TPCID const &tpcid, std::vector< PlaneGeo > &planes) const
Sorts (in place) the specified PlaneGeo objects by drift distance.
std::map< TPCID, std::vector< PlaneGeo > > fPlanes
std::map< TPCID, std::vector< double > > fPlane0Pitch
Pitch between planes.
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
Iterable< details::ReadoutIterationPolicy, details::ToReadoutGeometryElement > Iteration
std::set< View_t > const & Views() const
Returns a list of possible views in the detector.
void UpdateAfterSorting(TPCGeo const &tpc, std::vector< PlaneGeo > &planes)
void SortSubVolumes(std::vector< PlaneGeo > &planes, Compare< WireGeo > compareWires) const
range_type< T > Iterate() const
Definition: Iterable.h:121
GeometryCore const * fGeom
std::set< View_t > allViews
All views in the detector.
geo::WireReadoutGeom::~WireReadoutGeom ( )
virtualdefault

Referenced by WireReadoutGeom().

Member Function Documentation

template<typename T >
T const& geo::WireReadoutGeom::AccessElement ( TPCInfoMap_t< T > const &  map,
TPCID const &  id 
) const
inlineprotected

Returns the specified element of the TPC map.

Definition at line 994 of file WireReadoutGeom.h.

Referenced by geo::WireReadoutStandardGeom::FirstChannelInROP(), geo::WireReadoutStandardGeom::NROPs(), geo::WireReadoutStandardGeom::WireCoordinate(), and geo::WireReadoutStandardGeom::WireCount().

995  {
996  return map[id.Cryostat][id.TPC];
997  }
template<typename T >
T const& geo::WireReadoutGeom::AccessElement ( PlaneInfoMap_t< T > const &  map,
PlaneID const &  id 
) const
inlineprotected

Returns the specified element of the plane map.

Definition at line 1022 of file WireReadoutGeom.h.

1023  {
1024  return map[id.Cryostat][id.TPC][id.Plane];
1025  }
template<typename T >
size_t geo::WireReadoutGeom::AccessElementSize ( TPCInfoMap_t< T > const &  map,
CryostatID const &  id 
) const
inlineprotected

Returns the number of elements in the specified cryostat of the TPC map.

Definition at line 1001 of file WireReadoutGeom.h.

1002  {
1003  return map[id.Cryostat].size();
1004  }
template<typename T >
size_t geo::WireReadoutGeom::AccessElementSize ( PlaneInfoMap_t< T > const &  map,
TPCID const &  id 
) const
inlineprotected

Returns the number of elements in the specified TPC of the plane map.

Definition at line 1029 of file WireReadoutGeom.h.

1030  {
1031  return map[id.Cryostat][id.TPC].size();
1032  }

Definition at line 72 of file Iterable.h.

References geo::details::iterator_for().

Referenced by finish().

73  {
74  using namespace details;
75  using ID = typename IDIteratorValueType<T>::type;
76  auto const iterator = iterator_for(ID::first(), fPolicy);
77  if constexpr (std::is_base_of<CryostatID, T>{}) { return iterator; }
78  else {
79  static_assert(!std::is_same_v<Transform, void_tag>);
80  return fTransform.template transform<T>(iterator);
81  }
82  }
intermediate_table::iterator iterator
auto iterator_for(LocalID const &id, SiblingPolicy const &siblingPolicy)
Definition: id_iterators.h:236
std::conditional_t< std::is_same_v< details::ToReadoutGeometryElement, void >, void_tag, details::ToReadoutGeometryElement > fTransform
Definition: Iterable.h:134
iterator_type<T> geo::Iterable< details::ReadoutIterationPolicy , details::ToReadoutGeometryElement >::begin ( BaseID const &  id) const
inlineinherited

Definition at line 85 of file Iterable.h.

References geo::details::iterator_for().

86  {
87  using namespace details;
88  using ID = typename IDIteratorValueType<T>::type;
89  static_assert(is_base_of_strict<BaseID, ID>);
90  auto const iterator = iterator_for(ID::first(id), fPolicy);
91  if constexpr (std::is_base_of<CryostatID, T>{}) { return iterator; }
92  else {
93  static_assert(!std::is_same_v<Transform, void_tag>);
94  return fTransform.template transform<T>(iterator);
95  }
96  }
intermediate_table::iterator iterator
auto iterator_for(LocalID const &id, SiblingPolicy const &siblingPolicy)
Definition: id_iterators.h:236
std::conditional_t< std::is_same_v< details::ToReadoutGeometryElement, void >, void_tag, details::ToReadoutGeometryElement > fTransform
Definition: Iterable.h:134
std::optional< WireIDIntersection > geo::WireReadoutGeom::ChannelsIntersect ( raw::ChannelID_t  c1,
raw::ChannelID_t  c2 
) const

Returns an intersection point of two channels.

Parameters
c1one channel ID
c2the other channel ID
Returns
WireIDIntersection object if intersection point was found; otherwise std::nullopt
Todo:

what happens for channels from different TPCs?

what happens for channels with multiple intersection points?

Deprecated:
This is clearly not APA-aware

Definition at line 543 of file WireReadoutGeom.cxx.

References ChannelToWire(), and WireIDsIntersect().

Referenced by util::GeometryUtilities::GetProjectedPoint(), util::GeometryUtilities::GetYZ(), and HasChannel().

546  {
547  // [GP] these errors should be exceptions, and this function is deprecated because it
548  // violates interoperability
549  std::vector<WireID> chan1wires = ChannelToWire(c1);
550  if (chan1wires.empty()) {
551  mf::LogError("ChannelsIntersect")
552  << "1st channel " << c1 << " maps to no wire (is it a real one?)";
553  return std::nullopt;
554  }
555  std::vector<WireID> chan2wires = ChannelToWire(c2);
556  if (chan2wires.empty()) {
557  mf::LogError("ChannelsIntersect")
558  << "2nd channel " << c2 << " maps to no wire (is it a real one?)";
559  return std::nullopt;
560  }
561 
562  if (chan1wires.size() > 1) {
563  mf::LogWarning("ChannelsIntersect")
564  << "1st channel " << c1 << " maps to " << chan2wires.size() << " wires; using the first!";
565  return std::nullopt;
566  }
567  if (chan2wires.size() > 1) {
568  mf::LogError("ChannelsIntersect")
569  << "2nd channel " << c2 << " maps to " << chan2wires.size() << " wires; using the first!";
570  return std::nullopt;
571  }
572 
573  return WireIDsIntersect(chan1wires[0], chan2wires[0]);
574  }
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, Point_t &intersection) const
Computes the intersection between two wires.
virtual std::vector< WireID > ChannelToWire(raw::ChannelID_t channel) const =0
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< raw::ChannelID_t > geo::WireReadoutGeom::ChannelsInTPCs ( ) const

Returns an std::vector<ChannelID_t> in all TPCs in a TPCSet.

Definition at line 462 of file WireReadoutGeom.cxx.

References Nchannels(), PlaneWireToChannel(), and TPCsetToTPCs().

Referenced by ThirdPlaneSlope().

463  {
464  std::vector<raw::ChannelID_t> channels;
465  channels.reserve(Nchannels());
466 
467  for (auto const& ts : Iterate<readout::TPCsetID>()) {
468  for (auto const t : TPCsetToTPCs(ts)) {
469  for (auto const& wire : Iterate<WireID>(t)) {
470  channels.push_back(PlaneWireToChannel(wire));
471  }
472  }
473  }
474  std::sort(channels.begin(), channels.end());
475  auto last = std::unique(channels.begin(), channels.end());
476  channels.erase(last, channels.end());
477  return channels;
478  }
virtual unsigned int Nchannels() const =0
Returns the total number of channels present (not necessarily contiguous)
virtual raw::ChannelID_t PlaneWireToChannel(WireID const &wireID) const =0
Returns the channel ID a wire is connected to.
virtual std::vector< TPCID > TPCsetToTPCs(readout::TPCsetID const &tpcsetid) const =0
Returns a list of ID of TPCs belonging to the specified TPC set.
virtual readout::ROPID geo::WireReadoutGeom::ChannelToROP ( raw::ChannelID_t  channel) const
pure virtual

Returns the ID of the ROP the channel belongs to.

Returns
the ID of the ROP the channel belongs to (invalid if channel is)
See also
HasChannel()

The channel must exist, or be the invalid channel value. With a channel that is not present in the mapping and that is not the invalid channel (raw::InvalidChannelID), the result is undefined.

Implemented in geo::WireReadoutStandardGeom.

Referenced by reco3d::TripletFinder::FillBadMap(), reco3d::TripletFinder::FillHitMap(), HasChannel(), and View().

double geo::WireReadoutGeom::ComputeThirdPlane_dTdW ( double  angle1,
double  pitch1,
double  dTdW1,
double  angle2,
double  pitch2,
double  dTdW2,
double  angle_target,
double  pitch_target 
)
static

Returns the slope on the third plane, given it in the other two.

Parameters
angle1angle or the wires on the first plane
pitch1wire pitch on the first plane
dTdW1slope in dt/dw units as observed on the first plane
angle2angle or the wires on the second plane
pitch2wire pitch on the second plane
dTdW2slope in dt/dw units as observed on the second plane
angle_targetangle or the wires on the target plane
pitch_targetwire pitch on the target plane
Returns
dt/dw slope as measured on the third plane, or 999 if infinity

The input slope must be specified in dt/dw non-homogeneous coordinates.

This function will return a small slope if both input slopes are small.

Definition at line 730 of file WireReadoutGeom.cxx.

References ComputeThirdPlaneSlope().

Referenced by ThirdPlane_dTdW(), and ThirdPlaneSlope().

738  {
739  // we need to convert dt/dw into homogeneous coordinates, and then back;
740  // slope = [dT * (TDCperiod / driftVelocity)] / [dW * wirePitch]
741  // The coefficient of dT is assumed to be the same for all the planes, and it finally
742  // cancels out. Pitches cancel out only if they are all the same.
743  return pitch_target *
744  ComputeThirdPlaneSlope(angle1, dTdW1 / pitch1, angle2, dTdW2 / pitch2, angle_target);
745  }
static double ComputeThirdPlaneSlope(double angle1, double slope1, double angle2, double slope2, double angle_target)
Returns the slope on the third plane, given it in the other two.
double geo::WireReadoutGeom::ComputeThirdPlaneSlope ( double  angle1,
double  slope1,
double  angle2,
double  slope2,
double  angle_target 
)
static

Returns the slope on the third plane, given it in the other two.

Parameters
angle1angle or the wires on the first plane
slope1slope as observed on the first plane
angle2angle or the wires on the second plane
slope2slope as observed on the second plane
angle_targetangle or the wires on the target plane
Returns
the slope as measure on the third plane, or 999 if infinity

This function will return a small slope if both input slopes are small.

Definition at line 702 of file WireReadoutGeom.cxx.

References util::abs().

Referenced by ComputeThirdPlane_dTdW(), and ThirdPlaneSlope().

707  {
708  // note that, if needed, the trigonometric functions can be pre-calculated.
709 
710  // Can't resolve very small slopes
711  if ((std::abs(slope1) < 0.001) && (std::abs(slope2)) < 0.001) return 0.001;
712 
713  // We need the "wire coordinate direction" for each plane. This is perpendicular to
714  // the wire orientation.
715  double slope3 = 0.001;
716  if (std::abs(slope1) > 0.001 && std::abs(slope2) > 0.001) {
717  slope3 =
718  (+(1. / slope1) * std::sin(angle3 - angle2) - (1. / slope2) * std::sin(angle3 - angle1)) /
719  std::sin(angle1 - angle2);
720  }
721  if (slope3 != 0.)
722  slope3 = 1. / slope3;
723  else
724  slope3 = 999.;
725 
726  return slope3;
727  }
constexpr auto abs(T v)
Returns the absolute value of the argument.

Definition at line 99 of file Iterable.h.

Referenced by finish(), and WireEndPoints().

100  {
101  using namespace details;
102  using ID = typename IDIteratorValueType<T>::type;
103  static_assert(std::is_base_of<CryostatID, ID>{});
104  return {fPolicy.template GetEndID<ID>()};
105  }
id_sentinel_for<T> geo::Iterable< details::ReadoutIterationPolicy , details::ToReadoutGeometryElement >::end ( BaseID const &  id) const
inlineinherited

Definition at line 108 of file Iterable.h.

109  {
110  using namespace details;
111  using ID = typename IDIteratorValueType<T>::type;
112  static_assert(std::is_base_of<CryostatID, ID>{});
113  static_assert(is_base_of_strict<BaseID, ID>);
114  return {fPolicy.template GetEndID<ID>(id)};
115  }
readout::TPCsetID geo::WireReadoutGeom::FindTPCsetAtPosition ( Point_t const &  worldLoc) const

Returns the total number of TPC sets in the specified cryostat.

Parameters
cryoidcryostat ID
Returns
number of TPC sets in the cryostat, or 0 if no cryostat found

Definition at line 576 of file WireReadoutGeom.cxx.

References fGeom, geo::GeometryCore::FindTPCAtPosition(), and TPCtoTPCset().

Referenced by HasChannel().

577  {
578  return TPCtoTPCset(fGeom->FindTPCAtPosition(worldLoc));
579  }
TPCID FindTPCAtPosition(Point_t const &point) const
Returns the ID of the TPC at specified location.
GeometryCore const * fGeom
virtual readout::TPCsetID TPCtoTPCset(TPCID const &tpcid) const =0
Returns the ID of the TPC set tpcid belongs to.
std::vector<std::vector<std::vector<raw::ChannelID_t> > > const& geo::WireReadoutGeom::FirstChannelInNextPlane ( ) const
inline

Retrieve the private fFirstChannelInNextPlane vector for testing.

Definition at line 936 of file WireReadoutGeom.h.

References fFirstChannelInThisPlane.

937  {
939  }
PlaneInfoMap_t< raw::ChannelID_t > fFirstChannelInThisPlane
virtual raw::ChannelID_t geo::WireReadoutGeom::FirstChannelInROP ( readout::ROPID const &  ropid) const
pure virtual

Returns the ID of the first channel in the specified readout plane.

Parameters
ropidID of the readout plane
Returns
ID of first channel, or raw::InvalidChannelID if ID is invalid

Note that this check is performed on the validity of the readout plane ID, that does not necessarily imply that the readout plane specified by the ID actually exists. Check if the ROP exists with HasROP(). The behaviour for non-existing readout planes is undefined.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel(), and SignalTypeForROPIDImpl().

std::vector<std::vector<std::vector<raw::ChannelID_t> > > const& geo::WireReadoutGeom::FirstChannelInThisPlane ( ) const
inline

Retrieve the private fFirstChannelInThisPlane vector for testing.

Definition at line 942 of file WireReadoutGeom.h.

References fFirstChannelInNextPlane, SignalTypeForChannelImpl(), and SignalTypeForROPIDImpl().

943  {
945  }
PlaneInfoMap_t< raw::ChannelID_t > fFirstChannelInNextPlane
PlaneGeo const & geo::WireReadoutGeom::FirstPlane ( TPCID const &  tpcid) const

Returns the first plane of the specified TPC.

Parameters
tpcID of the TPC
Returns
a constant reference to the specified plane
Exceptions
cet::exception(WireReadoutGeom category) if plane not present

Definition at line 202 of file WireReadoutGeom.cxx.

References PlanePtr().

Referenced by larg4::LArVoxelReadout::DriftIonizationElectrons(), trkf::TrackLineFitAlg::TrkLineFit(), DUNE::NeutrinoTrackingEff::truthLength(), and Views().

203  {
204  if (auto const* plane_ptr = PlanePtr({tpcid, 0})) { return *plane_ptr; }
205  throw cet::exception("WireReadoutGeom")
206  << "TPC with ID " << tpcid << " does not have a first plane.";
207  }
PlaneGeo const * PlanePtr(PlaneID const &planeid) const
Returns the specified plane.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
virtual TPCID geo::WireReadoutGeom::FirstTPCinTPCset ( readout::TPCsetID const &  tpcsetid) const
pure virtual

Returns the ID of the first TPC belonging to the specified TPC set.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel().

virtual PlaneID geo::WireReadoutGeom::FirstWirePlaneInROP ( readout::ROPID const &  ropid) const
pure virtual

Returns the ID of the first plane belonging to the specified ROP.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel(), and View().

PlaneGeo const& geo::WireReadoutGeom::GetElement ( PlaneID const &  planeid) const
inline

Returns the specified wire.

Parameters
tpcidID of the TPC
viewnumber of the requested view
planeidID of the plane
Returns
a constant reference to the specified plane
Exceptions
cet::exception(GeometryCore category) if cryostat not present
cet::exception(TPCOutOfRange category) if no such TPC
cet::exception(PlaneOutOfRange category) if no such plane

The GetElement() method is overloaded and its return depends on the type of ID.

Definition at line 152 of file WireReadoutGeom.h.

References Plane(), and PlanePtr().

152 { return Plane(planeid); }
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
WireGeo const& geo::WireReadoutGeom::GetElement ( WireID const &  wireid) const
inline

Returns the specified wire.

Parameters
wireidID of the wire
Returns
a constant reference to the specified wire
Exceptions
cet::exceptionif not found

The GetElement() method is overloaded and its return depends on the type of ID.

Definition at line 226 of file WireReadoutGeom.h.

References Wire(), and WireEndPoints().

226 { return Wire(wireid); }
WireGeo const & Wire(WireID const &wireid) const
Returns the specified wire.
PlaneGeo const* geo::WireReadoutGeom::GetElementPtr ( PlaneID const &  planeid) const
inline

Returns the specified plane.

Parameters
planeidplane ID
Returns
a constant pointer to the specified plane, or nullptr if none

The GetElementPtr() method is overloaded and its return depends on the type of ID.

Definition at line 164 of file WireReadoutGeom.h.

References MaxWires(), NElements(), Nwires(), and PlanePtr().

Referenced by geo::WireReadoutStandardGeom::PlaneWireToChannel().

164 { return PlanePtr(planeid); }
PlaneGeo const * PlanePtr(PlaneID const &planeid) const
Returns the specified plane.
WireGeo const* geo::WireReadoutGeom::GetElementPtr ( WireID const &  wireid) const
inline

Returns the specified wire.

Parameters
wireidwire ID
Returns
a constant pointer to the specified wire, or nullptr if none

The GetElementPtr() method is overloaded and its return depends on the type of ID.

Definition at line 213 of file WireReadoutGeom.h.

References Wire(), and WirePtr().

213 { return WirePtr(wireid); }
WireGeo const * WirePtr(WireID const &wireid) const
Returns the specified wire.
template<typename T >
T const* geo::WireReadoutGeom::GetElementPtr ( PlaneInfoMap_t< T > const &  map,
PlaneID const &  id 
) const
inlineprotected

Returns a pointer to the specified element, or nullptr if invalid.

Definition at line 1055 of file WireReadoutGeom.h.

1056  {
1057  if (id.Cryostat >= map.size()) return nullptr;
1058  auto const& cryo_map = map[id.Cryostat];
1059  if (id.TPC >= cryo_map.size()) return nullptr;
1060  auto const& TPC_map = cryo_map[id.TPC];
1061  if (id.Plane >= TPC_map.size()) return nullptr;
1062  auto const& plane_map = TPC_map[id.Plane];
1063  return &plane_map;
1064  } // GetElementPtr()
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
unsigned int geo::WireReadoutGeom::HardwareChannelFromOpChannel ( unsigned int  opChannel) const
virtual

Returns the hardware channel number of specified optical channel.

Parameters
opChannelthe optical detector channel being queried
Returns
the optical detector the specified optical channel belongs to

If the specified optical channel is invalid, behaviour is undefined.

Definition at line 426 of file WireReadoutGeom.cxx.

Referenced by HasChannel(), and IsValidOpChannel().

427  {
428  return 0;
429  }
virtual bool geo::WireReadoutGeom::HasChannel ( raw::ChannelID_t  channel) const
inlinevirtual

Returns whether the specified channel is valid This default implementation assumes all channels up to Nchannels() valid.

Definition at line 567 of file WireReadoutGeom.h.

References c1, c2, ChannelsIntersect(), ChannelToROP(), ChannelToWire(), FindTPCsetAtPosition(), FirstChannelInROP(), FirstTPCinTPCset(), FirstWirePlaneInROP(), HardwareChannelFromOpChannel(), HasROP(), HasTPCset(), raw::isValidChannelID(), IsValidOpChannel(), MaxOpChannel(), MaxROPs(), MaxTPCsets(), Nchannels(), NearestChannel(), NearestWireID(), NOpChannels(), NOpHardwareChannels(), NROPs(), NTPCsets(), OpChannel(), OpDetFromOpChannel(), OpDetGeoFromOpChannel(), PlaneIDs(), PlaneWireToChannel(), ROPtoTPCs(), ROPtoWirePlanes(), SignalType(), TPCsetToTPCs(), TPCtoTPCset(), View(), WireCoordinate(), and WirePlaneToROP().

568  {
569  return raw::isValidChannelID(channel) ? channel < Nchannels() : false;
570  }
virtual unsigned int Nchannels() const =0
Returns the total number of channels present (not necessarily contiguous)
constexpr bool isValidChannelID(raw::ChannelID_t channel)
Definition: RawTypes.h:35
bool geo::WireReadoutGeom::HasElement ( PlaneID const &  planeid) const
inline

Returns whether we have the specified plane.

The HasElement() method is overloaded and its meaning depends on the type of ID.

Definition at line 79 of file WireReadoutGeom.h.

References HasPlane(), MaxPlanes(), Nplanes(), and geo::details::tpc_zero.

79 { return HasPlane(planeid); }
bool HasPlane(PlaneID const &planeid) const
Returns whether we have the specified plane.
bool geo::WireReadoutGeom::HasElement ( WireID const &  wireid) const
inline

Returns whether we have the specified wire.

The HasElement() method is overloaded and its meaning depends on the type of ID.

Definition at line 201 of file WireReadoutGeom.h.

References HasWire(), and WirePtr().

201 { return HasWire(wireid); }
bool HasWire(WireID const &wireid) const
Returns whether we have the specified wire.
bool geo::WireReadoutGeom::HasPlane ( PlaneID const &  planeid) const

Returns whether we have the specified plane.

The HasElement() method is overloaded and its meaning depends on the type of ID.

Definition at line 188 of file WireReadoutGeom.cxx.

References PlanePtr().

Referenced by pma::ProjectionMatchingAlg::buildShowerSeg(), finish(), pma::ProjectionMatchingAlg::guideEndpoints(), HasElement(), pma::PMAlgTracker::matchCluster(), pma::Node3D::Node3D(), trkf::PMAlgTrajFitter::produce(), and pma::ProjectionMatchingAlg::TestTrk_().

189  {
190  return PlanePtr(planeid) != nullptr;
191  }
PlaneGeo const * PlanePtr(PlaneID const &planeid) const
Returns the specified plane.
virtual bool geo::WireReadoutGeom::HasROP ( readout::ROPID const &  ropid) const
pure virtual

Returns whether we have the specified ROP

Returns
whether the readout plane is valid and exists

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel().

virtual bool geo::WireReadoutGeom::HasTPCset ( readout::TPCsetID const &  tpcsetid) const
pure virtual

Returns whether we have the specified TPC set

Returns
whether the TPC set is valid and exists

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel().

bool geo::WireReadoutGeom::HasWire ( WireID const &  wireid) const

Returns whether we have the specified wire.

The HasElement() method is overloaded and its meaning depends on the type of ID.

Definition at line 256 of file WireReadoutGeom.cxx.

References geo::PlaneGeo::HasWire(), and PlanePtr().

Referenced by tca::FillmAllTraj(), HasElement(), NSiblingElements(), pma::ProjectionMatchingAlg::validate(), pma::ProjectionMatchingAlg::validate_on_adc(), pma::ProjectionMatchingAlg::validate_on_adc_test(), and WireIDIntersectionCheck().

257  {
258  PlaneGeo const* pPlane = PlanePtr(wireid);
259  return pPlane ? pPlane->HasWire(wireid) : false;
260  }
PlaneGeo const * PlanePtr(PlaneID const &planeid) const
Returns the specified plane.
template<typename T >
bool geo::WireReadoutGeom::isValidElement ( TPCInfoMap_t< T > const &  map,
CryostatID const &  id 
) const
inlineprotected

Returns whether the ID specifies a valid entry.

Definition at line 1009 of file WireReadoutGeom.h.

Referenced by isValidElement().

1010  {
1011  return id.Cryostat < map.size();
1012  }
template<typename T >
bool geo::WireReadoutGeom::isValidElement ( TPCInfoMap_t< T > const &  map,
TPCID const &  id 
) const
inlineprotected

Returns the specified element of the TPC map.

Definition at line 1014 of file WireReadoutGeom.h.

References isValidElement().

1015  {
1016  return isValidElement(map, id.asCryostatID()) && (id.TPC < map[id.Cryostat].size());
1017  }
bool isValidElement(TPCInfoMap_t< T > const &map, CryostatID const &id) const
Returns whether the ID specifies a valid entry.
template<typename T >
bool geo::WireReadoutGeom::isValidElement ( PlaneInfoMap_t< T > const &  map,
CryostatID const &  id 
) const
inlineprotected

Returns whether the ID specifies a valid entry.

Definition at line 1037 of file WireReadoutGeom.h.

1038  {
1039  return id.Cryostat < map.size();
1040  }
template<typename T >
bool geo::WireReadoutGeom::isValidElement ( PlaneInfoMap_t< T > const &  map,
TPCID const &  id 
) const
inlineprotected

Returns whether the ID specifies a valid entry.

Definition at line 1042 of file WireReadoutGeom.h.

References isValidElement().

1043  {
1044  return isValidElement(map, id.asCryostatID()) && (id.TPC < map[id.Cryostat].size());
1045  }
bool isValidElement(TPCInfoMap_t< T > const &map, CryostatID const &id) const
Returns whether the ID specifies a valid entry.
template<typename T >
bool geo::WireReadoutGeom::isValidElement ( PlaneInfoMap_t< T > const &  map,
PlaneID const &  id 
) const
inlineprotected

Returns whether the ID specifies a valid entry.

Definition at line 1047 of file WireReadoutGeom.h.

References isValidElement().

1048  {
1049  return isValidElement(map, id.asTPCID()) && (id.Plane < AccessSize(map, id.asTPCID()));
1050  }
bool isValidElement(TPCInfoMap_t< T > const &map, CryostatID const &id) const
Returns whether the ID specifies a valid entry.
bool geo::WireReadoutGeom::IsValidOpChannel ( int  opChannel) const

Is this a valid OpChannel number?

Definition at line 493 of file WireReadoutGeom.cxx.

References fGeom, and geo::GeometryCore::NOpDets().

Referenced by cosmic::BeamFlashTrackMatchTaggerAlg::CheckCompatibility(), HasChannel(), cosmic::BeamFlashTrackMatchTaggerAlg::PrintHypothesisFlashComparison(), and opdet::RunHitFinder().

494  {
495  return IsValidOpChannel(opChannel, fGeom->NOpDets());
496  }
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
unsigned int NOpDets() const
Number of OpDets in the whole detector.
GeometryCore const * fGeom
bool geo::WireReadoutGeom::IsValidOpChannel ( unsigned int  opChannel,
unsigned int  NOpDets 
) const
virtual

Returns whether the ID identifies a valid optical detector channel.

Parameters
opChannelchannel number
NOpDetsnumber of optical detectors in the detector
Returns
whether opChannel would be a valid channel

The specification of the number of optical channels reflects the logic described in NOpChannel().

Definition at line 432 of file WireReadoutGeom.cxx.

References HardwareChannelFromOpChannel(), NOpChannels(), NOpHardwareChannels(), and OpDetFromOpChannel().

433  {
434  // Check channel number
435  if (opChannel >= NOpChannels(NOpDets)) return false;
436 
437  // Check opdet number
438  unsigned int opdet = OpDetFromOpChannel(opChannel);
439  if (opdet >= NOpDets) return false;
440 
441  // Check hardware channel number
442  unsigned int hChan = HardwareChannelFromOpChannel(opChannel);
443  return hChan < NOpHardwareChannels(opdet);
444  }
virtual unsigned int OpDetFromOpChannel(unsigned int opChannel) const
Returns the optical detector the specified optical channel belongs.
virtual unsigned int NOpHardwareChannels(unsigned int opDet) const
Returns the number of channels in the specified optical detectors.
virtual unsigned int HardwareChannelFromOpChannel(unsigned int opChannel) const
Returns the hardware channel number of specified optical channel.
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.

Definition at line 121 of file Iterable.h.

Referenced by finish().

122  {
123  return ranges::make_subrange(begin<T>(), end<T>());
124  }
range_type<T> geo::Iterable< details::ReadoutIterationPolicy , details::ToReadoutGeometryElement >::Iterate ( ID const &  id) const
inlineinherited

Definition at line 127 of file Iterable.h.

128  {
129  return ranges::make_subrange(begin<T>(id), end<T>(id));
130  }
unsigned int geo::WireReadoutGeom::MaxOpChannel ( ) const

Largest optical channel number.

Definition at line 487 of file WireReadoutGeom.cxx.

References fGeom, and geo::GeometryCore::NOpDets().

Referenced by cosmic::BeamFlashTrackMatchTaggerAlg::CheckCompatibility(), opdet::ConstructFlash(), HasChannel(), and cosmic::BeamFlashTrackMatchTaggerAlg::PrintHypothesisFlashComparison().

488  {
489  return MaxOpChannel(fGeom->NOpDets());
490  }
unsigned int NOpDets() const
Number of OpDets in the whole detector.
unsigned int MaxOpChannel() const
Largest optical channel number.
GeometryCore const * fGeom
unsigned int geo::WireReadoutGeom::MaxOpChannel ( unsigned int  NOpDets) const
virtual

Returns the number of optical channels contained in some detectors.

Parameters
NOpDetsnumber of optical detectors
Returns
optical channels contained in NOpDets detectors

This function returns the first optical channel ID larger than the last channel ID in a detector with NOpDets optical detectors (with the same logic as NOpChannels()). For example, in a detector with 32 channels with contiguous IDs starting at 0, this function would return 32. If the channels started with ID 1, this function would instead return 33 and if there were a 16 channel gap, so that valid channels are from 0 to 15 and from 32 to 47, this function would return 48.

Definition at line 394 of file WireReadoutGeom.cxx.

References NOpChannels().

395  {
396  // By default just return the number of optical detectos
397  return NOpChannels(NOpDets);
398  }
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
unsigned int geo::WireReadoutGeom::MaxPlanes ( ) const

Returns the largest number of planes among all TPCs in this detector.

Definition at line 166 of file WireReadoutGeom.cxx.

References fPlanes.

Referenced by pma::PMAlgTracker::build(), ShowerRecoTools::ShowerTrajPointdEdx::CalculateElement(), shower::EMShowerAlg::CheckIsolatedHits_(), img::DataProviderAlg::DataProviderAlg(), trkf::TrackKalmanFitter::doFitWork(), geo::details::ReadoutIterationPolicy::EndPlaneID(), HasElement(), shower::EMShowerAlg::MakeShower(), shower::EMShowerAlg::MakeSpacePoints(), Nviews(), shower::EMShowerAlg::OrderShowerHits(), pma::PMAlgTracker::PMAlgTracker(), shower::EMShowerAlg::RelativeWireWidth_(), trkf::TrackKalmanFitter::sortOutput(), and shower::EMShowerAlg::WorstPlane_().

167  {
168  unsigned int maxPlanes = 0;
169  for (auto const& [tpc_id, planes] : fPlanes) {
170  unsigned int maxPlanesInTPC = planes.size();
171  if (maxPlanesInTPC > maxPlanes) maxPlanes = maxPlanesInTPC;
172  }
173  return maxPlanes;
174  }
std::map< TPCID, std::vector< PlaneGeo > > fPlanes
virtual unsigned int geo::WireReadoutGeom::MaxROPs ( ) const
pure virtual

Returns the largest number of ROPs a TPC set in the detector has.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel().

virtual unsigned int geo::WireReadoutGeom::MaxTPCsets ( ) const
pure virtual

Returns the largest number of TPC sets any cryostat in the detector has.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel().

unsigned int geo::WireReadoutGeom::MaxWires ( ) const

Returns the total number of wires in the specified plane.

Parameters
planeidplane ID
Returns
number of wires in specified plane, or 0 if no plane found

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t

Definition at line 177 of file WireReadoutGeom.cxx.

Referenced by cluster::BlurredClusteringAlg::ConvertRecobHitsToVector(), geo::details::ReadoutIterationPolicy::EndWireID(), and GetElementPtr().

178  {
179  unsigned int maxWires = 0;
180  for (PlaneGeo const& plane : Iterate<PlaneGeo>()) {
181  unsigned int maxWiresInPlane = plane.Nwires();
182  if (maxWiresInPlane > maxWires) maxWires = maxWiresInPlane;
183  }
184  return maxWires;
185  }
virtual unsigned int geo::WireReadoutGeom::Nchannels ( ) const
pure virtual
virtual unsigned int geo::WireReadoutGeom::Nchannels ( readout::ROPID const &  ropid) const
pure virtual

Returns the number of channels in the specified ROP.

Returns
number of channels in the specified ROP, 0 if non-existent

Implemented in geo::WireReadoutStandardGeom.

raw::ChannelID_t geo::WireReadoutGeom::NearestChannel ( Point_t const &  worldLoc,
PlaneID const &  planeid 
) const

Returns the ID of the channel nearest to the specified position.

Parameters
worldLoc3D coordinates of the point (world reference frame)
planeidID of the wire plane the channel must belong to
Returns
the ID of the channel, or raw::InvalidChannelID if invalid wire
Bug:
on invalid wire, a geo::InvalidWireError exception is thrown

Definition at line 524 of file WireReadoutGeom.cxx.

References raw::InvalidChannelID, geo::PlaneGeo::NearestWireID(), Plane(), and PlaneWireToChannel().

Referenced by larg4::LArVoxelReadout::DriftIonizationElectrons(), HasChannel(), and apa::DisambigAlg::TrivialDisambig().

526  {
527  // This method is supposed to return a channel number rather than a wire number.
528  // Perform the conversion here (although, maybe faster if we deal in wire numbers
529  // rather than channel numbers?)
530 
531  // NOTE on failure both NearestChannel() and upstream:
532  // * according to documentation, should return invalid channel
533  // * in the actual code throw an exception because of a BUG
534  //
535  // The following implementation automatically becomes in fact compliant to the
536  // documentation if upstreams becomes compliant to. When that happens, just delete
537  // this comment.
538  WireID const wireID = Plane(planeid).NearestWireID(worldPos);
539  return wireID ? PlaneWireToChannel(wireID) : raw::InvalidChannelID;
540  }
WireID NearestWireID(Point_t const &pos) const
Returns the ID of wire closest to the specified position.
Definition: PlaneGeo.cxx:485
Raw data description.
Definition: RawTypes.h:6
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:31
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
virtual raw::ChannelID_t PlaneWireToChannel(WireID const &wireID) const =0
Returns the channel ID a wire is connected to.
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
virtual WireID geo::WireReadoutGeom::NearestWireID ( Point_t const &  worldPos,
PlaneID const &  planeID 
) const
pure virtual

Returns the ID of the wire nearest to the specified position.

Parameters
worldPosposition to be tested
planeIDplane containing the wire
Returns
the ID of the wire closest to worldPos in the specified plane
Exceptions
InvalidWireIDErrorthe ID found is not present in the detector
See also
WireCoordinate(double, double, geo::PlaneID const&)

The plane is required to be valid and exist in the detector. Otherwise, the behaviour is undefined. An exception is thrown if the wire that would be the closest is actually not present; but no check is performed whether the specified position is outside the wire plane: wires are extrapolated to be infinitely long. In other words, the result can be trusted only as long as the position is within the specified wire plane.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel().

unsigned int geo::WireReadoutGeom::NElements ( TPCID const &  tpcid) const
inline

Returns the total number of planes in the specified TPC.

Parameters
tpcidTPC ID
Returns
number of planes in specified TPC, or 0 if no TPC found

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t

Definition at line 103 of file WireReadoutGeom.h.

References Nplanes().

Referenced by GetElementPtr().

103 { return Nplanes(tpcid); }
unsigned int Nplanes(TPCID const &tpcid=details::tpc_zero) const
Returns the total number of planes in the specified TPC.
unsigned int geo::WireReadoutGeom::NElements ( PlaneID const &  planeid) const

Returns the total number of wires in the specified plane.

Parameters
planeidplane ID
Returns
number of wires in specified plane, or 0 if no plane found

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t
unsigned int geo::WireReadoutGeom::NOpChannels ( unsigned int  NOpDets) const
virtual

Returns the number of optical channels contained in some detectors.

Parameters
NOpDetsnumber of optical detectors
Returns
optical channels contained in NOpDets detectors

This function returns how many channels can be expected to be present in a detector with NOpDets optical detectors. This is an upper limit, as not all channels have necessarily to be present.

For example: if a detector has four channels per optical detector, the returned value will be four times the argument NOpDets. If there is a single channel on each optical detector, the return value will be the value NOpDets (this is in fact the fallback implementation). If each optical detector can have anywhere between 2 and 12 channels, the returned value is 12 times NOpDets, and it will be an overestimation of the number of channels.

Definition at line 387 of file WireReadoutGeom.cxx.

Referenced by opdet::OptDetDigitizer::produce().

388  {
389  // By default just return the number of optical detectos
390  return NOpDets;
391  }
unsigned int geo::WireReadoutGeom::NOpChannels ( ) const

Number of electronics channels for all the optical detectors.

Definition at line 481 of file WireReadoutGeom.cxx.

References fGeom, and geo::GeometryCore::NOpDets().

Referenced by HasChannel(), IsValidOpChannel(), and MaxOpChannel().

482  {
483  return NOpChannels(fGeom->NOpDets());
484  }
unsigned int NOpDets() const
Number of OpDets in the whole detector.
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
GeometryCore const * fGeom
unsigned int geo::WireReadoutGeom::NOpHardwareChannels ( unsigned int  opDet) const
virtual

Returns the number of channels in the specified optical detectors.

Parameters
opDetID of the chosen optical detector
Returns
optical channels contained in optical detector with ID opDet

This function returns how many channels are actually present in the optical detector with the specified ID.

For example: if a detector has four channels per optical detector, the returned value will be four, regardless opDet, and . If there is a single channel on each optical detector, the return value will be 1, again ignoring opDet (this is in fact the fallback implementation). If each optical detector can have anywhere between 2 and 12 channels, the returned value will be 2, 12, etc., that is the exact number of channels in opDet.

Although implementations are encouraged to return 0 on invalid optical detectors, the actual return value in that case is undefined.

Definition at line 401 of file WireReadoutGeom.cxx.

Referenced by HasChannel(), and IsValidOpChannel().

402  {
403  // By default, 1 channel per optical detector
404  return 1;
405  }
unsigned int geo::WireReadoutGeom::Nplanes ( TPCID const &  tpcid = details::tpc_zero) const

Returns the total number of planes in the specified TPC.

Parameters
tpcidTPC ID
Returns
number of planes in specified TPC, or 0 if no TPC found

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t

Definition at line 194 of file WireReadoutGeom.cxx.

References fPlanes.

Referenced by tca::AnalyzeHits(), cluster::SmallClusterFinder::beginJob(), lar_cluster3d::StandardHit3DBuilder::BuildChannelStatusVec(), lar_cluster3d::SnippetHit3DBuilder::BuildChannelStatusVec(), ShowerRecoTools::ShowerUnidirectiondEdx::CalculateElement(), ShowerRecoTools::ShowerLinearEnergy::CalculateElement(), ShowerRecoTools::ShowerNumElectronsEnergy::CalculateElement(), opdet::ConstructFlash(), tca::TrajClusterAlg::CreateSlice(), detinfo::DetectorPropertiesStandard::DataFor(), hit::DisambigCheater::DisambigCheater(), larg4::LArVoxelReadout::DriftIonizationElectrons(), calo::TrackCalorimetryAlg::ExtractCalorimetry(), trkf::CCTrackMaker::FillEndMatch(), trkf::CCTrackMaker::FillWireHitRange(), tca::FillWireHitRange(), tca::FindShowers3D(), trkf::CCTrackMaker::FitVertices(), opdet::GetHitGeometryInfo(), corner::CornerFinderAlg::GrabWires(), HasElement(), corner::CornerFinderAlg::InitializeGeometry(), trkf::CCTrackMaker::MakeClusterChains(), trkf::CCTrackMaker::MakeFamily(), NElements(), NSiblingElements(), trkf::CCTrackMaker::PlnMatch(), trkf::CCTrackMaker::PrintClusters(), trk::TrackContainmentAlg::ProcessTracks(), trkf::CCTrackMaker::produce(), ShowerRecoTools::ShowerLinearEnergy::ShowerLinearEnergy(), cluster::SmallClusterFinderAlg::SmallClusterFinderAlg(), trkf::CCTrackMaker::SortMatches(), cheat::BackTracker::SpacePointHitsToWeightedXYZ(), trkf::CCTrackMaker::StoreTrack(), ThirdPlane(), trkf::VertexFitAlg::VertexFit(), trkf::CCTrackMaker::VtxMatch(), nnet::WaveformDenoiseTest::WaveformDenoiseTest(), and geo::WireReadoutStandardGeom::WireReadoutStandardGeom().

195  {
196  auto it = fPlanes.find(tpcid);
197  if (it == fPlanes.cend()) { return 0; }
198  return it->second.size();
199  }
std::map< TPCID, std::vector< PlaneGeo > > fPlanes
virtual unsigned int geo::WireReadoutGeom::NROPs ( readout::TPCsetID const &  tpcsetid) const
pure virtual

Returns the total number of ROP in the specified TPC set.

Parameters
tpcsetidTPC set ID
Returns
number of readout planes in the TPC set, or 0 if no TPC set found

Note that this methods explicitly check the existence of the TPC set.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel(), and geo::details::ReadoutIterationPolicy::NSiblings().

unsigned int geo::WireReadoutGeom::NSiblingElements ( PlaneID const &  planeid) const
inline

Returns the total number of planes in the specified TPC.

Parameters
tpcidTPC ID
Returns
number of planes in specified TPC, or 0 if no TPC found

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t

Definition at line 104 of file WireReadoutGeom.h.

References Nplanes(), and Nviews().

Referenced by geo::details::ReadoutIterationPolicy::NSiblings().

104 { return Nplanes(planeid); }
unsigned int Nplanes(TPCID const &tpcid=details::tpc_zero) const
Returns the total number of planes in the specified TPC.
unsigned int geo::WireReadoutGeom::NSiblingElements ( WireID const &  wireid) const
inline

Returns the total number of wires in the specified plane.

Parameters
planeidplane ID
Returns
number of wires in specified plane, or 0 if no plane found

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t

Definition at line 186 of file WireReadoutGeom.h.

References HasWire(), and Nwires().

186 { return Nwires(wireid); }
unsigned int Nwires(PlaneID const &planeid) const
Returns the total number of wires in the specified plane.
virtual unsigned int geo::WireReadoutGeom::NTPCsets ( readout::CryostatID const &  cryoid) const
pure virtual

Returns the total number of TPC sets in the specified cryostat.

Parameters
cryoidcryostat ID
Returns
number of TPC sets in the cryostat, or 0 if no cryostat found

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel(), and geo::details::ReadoutIterationPolicy::NSiblings().

unsigned int geo::WireReadoutGeom::Nviews ( ) const

Returns the number of views (different wire orientations)

Returns the number of different views, or wire orientations, in the detector.

The function assumes that all TPCs in all cryostats of a detector have the same number of planes, which should be a safe assumption.

Todo:
Change return type to size_t

Definition at line 160 of file WireReadoutGeom.cxx.

References MaxPlanes().

Referenced by NSiblingElements().

161  {
162  return MaxPlanes();
163  }
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
unsigned int geo::WireReadoutGeom::Nwires ( PlaneID const &  planeid) const

Returns the total number of wires in the specified plane.

Parameters
planeidplane ID
Returns
number of wires in specified plane, or 0 if no plane found

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t

Definition at line 249 of file WireReadoutGeom.cxx.

References geo::PlaneGeo::NElements(), and PlanePtr().

Referenced by lar_cluster3d::StandardHit3DBuilder::BuildChannelStatusVec(), lar_cluster3d::SnippetHit3DBuilder::BuildChannelStatusVec(), trkf::CCTrackMaker::FillWireHitRange(), tca::FillWireHitRange(), GetElementPtr(), util::GeometryUtilities::GetYZ(), cluster::MergeClusterAlg::GlobalWire(), cluster::BlurredClusteringAlg::GlobalWire(), shower::EMShowerAlg::GlobalWire_(), corner::CornerFinderAlg::GrabWires(), corner::CornerFinderAlg::InitializeGeometry(), lar_cluster3d::StandardHit3DBuilder::NearestWireID(), lar_cluster3d::SnippetHit3DBuilder::NearestWireID(), NSiblingElements(), util::GeometryUtilities::SelectPolygonHitList(), img::DataProviderAlg::setWireDriftData(), and WireIDIntersectionCheck().

250  {
251  PlaneGeo const* pPlane = PlanePtr(planeid);
252  return pPlane ? pPlane->NElements() : 0;
253  }
PlaneGeo const * PlanePtr(PlaneID const &planeid) const
Returns the specified plane.
unsigned int geo::WireReadoutGeom::OpChannel ( unsigned int  detNum,
unsigned int  hwchannel = 0 
) const
virtual

Returns the channel ID of the specified hardware channel.

Parameters
detNumoptical detector ID
hwchannelhardware channel within the specified optical detector
Returns
ID of the channel identified by detector and hardware channel IDs

If the input IDs identify a non-existing channel, the result is undefined.

Definition at line 408 of file WireReadoutGeom.cxx.

Referenced by HasChannel().

409  {
410  return detNum;
411  }
unsigned int geo::WireReadoutGeom::OpDetFromOpChannel ( unsigned int  opChannel) const
virtual

Returns the optical detector the specified optical channel belongs.

Parameters
opChannelthe optical detector channel being queried
Returns
the optical detector the specified optical channel belongs to

If the specified optical channel is invalid, behaviour is undefined.

Definition at line 414 of file WireReadoutGeom.cxx.

Referenced by cosmic::BeamFlashTrackMatchTaggerAlg::CheckCompatibility(), HasChannel(), IsValidOpChannel(), OpDetGeoFromOpChannel(), and cosmic::BeamFlashTrackMatchTaggerAlg::PrintHypothesisFlashComparison().

415  {
416  return opChannel;
417  }
OpDetGeo const & geo::WireReadoutGeom::OpDetGeoFromOpChannel ( unsigned int  opChannel) const

Returns the optical detector the specified optical channel belongs.

Parameters
opChannelthe optical detector channel being queried
Returns
the optical detector geometry object the specified optical channel belongs to

If the specified optical channel is invalid, behaviour is undefined.

Definition at line 420 of file WireReadoutGeom.cxx.

References fGeom, OpDetFromOpChannel(), and geo::GeometryCore::OpDetGeoFromOpDet().

Referenced by opdet::GetHitGeometryInfo(), and HasChannel().

421  {
422  return fGeom->OpDetGeoFromOpDet(OpDetFromOpChannel(opChannel));
423  }
virtual unsigned int OpDetFromOpChannel(unsigned int opChannel) const
Returns the optical detector the specified optical channel belongs.
GeometryCore const * fGeom
OpDetGeo const & OpDetGeoFromOpDet(unsigned int OpDet) const
Returns the geo::OpDetGeo object for the given detector number.
PlaneGeo const & geo::WireReadoutGeom::Plane ( TPCID const &  tpcid,
View_t  view 
) const

Returns the specified wire.

Parameters
tpcidID of the TPC
viewnumber of the requested view
planeidID of the plane
Returns
a constant reference to the specified plane
Exceptions
cet::exception(GeometryCore category) if cryostat not present
cet::exception(TPCOutOfRange category) if no such TPC
cet::exception(PlaneOutOfRange category) if no such plane

The GetElement() method is overloaded and its return depends on the type of ID.

Definition at line 210 of file WireReadoutGeom.cxx.

References fPlanes, and geo::PlaneGeo::View().

Referenced by calo::TrackCalorimetryAlg::AnalyzeHit(), apa::APAGeometryAlg::APAGeometryAlg(), ShowerRecoTools::ShowerUnidirectiondEdx::CalculateElement(), ShowerRecoTools::ShowerTrajPointdEdx::CalculateElement(), util::GeometryUtilities::CalculatePitch(), util::GeometryUtilities::CalculatePitchPolar(), tca::ChgFracBetween(), tca::ChgFracNearEnd(), detinfo::DetectorPropertiesStandard::DataFor(), tca::dEdx(), calo::TrackCalorimetryAlg::ExtractCalorimetry(), trkf::CCTrackMaker::FillEndMatch(), tca::FillWireHitRange(), tca::Find3DVertices(), apa::DisambigAlg::FindChanTimeEndPts(), lar_cluster3d::HoughSeedFinderAlg::findHoughClusters(), cluster::SmallClusterFinderAlg::FindSmallClusters(), tca::FitTP3Ds(), util::GeometryUtilities::GeometryUtilities(), util::GeometryUtilities::Get2DangleFrom3D(), util::GeometryUtilities::Get2DPointProjection(), util::GeometryUtilities::Get2DPointProjectionCM(), corner::CornerFinderAlg::get_feature_points(), corner::CornerFinderAlg::get_feature_points_fast(), corner::CornerFinderAlg::get_feature_points_LineIntegralScore(), pma::ProjectionMatchingAlg::GetCloseHits_(), GetElement(), opdet::GetHitGeometryInfo(), util::GeometryUtilities::GetProjectedPoint(), nnet::TrainingDataAlg::getProjection(), util::GeometryUtilities::GetTimeTicks(), util::GeometryUtilities::GetXYZ(), cluster::MergeClusterAlg::GlobalWire(), cluster::BlurredClusteringAlg::GlobalWire(), shower::EMShowerAlg::GlobalWire_(), shower::LArPandoraShowerAlg::HitCoordinates(), shower::EMShowerAlg::HitPosition_(), hit::DisambigCheater::InitHitToWids(), lar_cluster3d::PCASeedFinderAlg::LineFit2DHits(), lar_cluster3d::HoughSeedFinderAlg::LineFit2DHits(), apa::APAGeometryAlg::LineSegChanIntersect(), tca::MakeBareTP(), shower::EMShowerAlg::MakeShower(), tca::MakeTP3D(), NearestChannel(), lar_cluster3d::StandardHit3DBuilder::NearestWireID(), lar_cluster3d::SnippetHit3DBuilder::NearestWireID(), apa::APAGeometryAlg::NearestWireIDOnChan(), shower::LArPandoraShowerAlg::OrderShowerHits(), shower::EMShowerAlg::OrderShowerHits_(), util::GeometryUtilities::PitchInView(), trkf::CCTrackMaker::PlnMatch(), tca::PosInPlane(), trk::TrackContainmentAlg::ProcessTracks(), cluster::DBCluster3D::produce(), cluster::TrajCluster::produce(), trkf::CCTrackMaker::produce(), cluster::SmallClusterFinder::produce(), shower::EMShowerAlg::Project3DPointOntoPlane_(), phot::SemiAnalyticalModel::SemiAnalyticalModel(), tca::SetSection(), lar_cluster3d::SnippetHit3DBuilder::SnippetHit3DBuilder(), lar_cluster3d::StandardHit3DBuilder::StandardHit3DBuilder(), lar_pandora::DUNEFarDetVDThreeView::TargetViewU(), lar_pandora::ProtoDUNEDualPhase::TargetViewU(), lar_pandora::ICARUS::TargetViewU(), lar_pandora::VintageLArTPCThreeView::TargetViewU(), lar_pandora::DUNEFarDetVDThreeView::TargetViewV(), lar_pandora::ICARUS::TargetViewV(), lar_pandora::ProtoDUNEDualPhase::TargetViewV(), lar_pandora::VintageLArTPCThreeView::TargetViewV(), lar_pandora::DUNEFarDetVDThreeView::TargetViewW(), lar_pandora::ICARUS::TargetViewW(), lar_pandora::VintageLArTPCThreeView::TargetViewW(), ThirdPlane_dTdW(), ThirdPlaneSlope(), trkf::TrackLineFitAlg::TrkLineFit(), pma::ProjectionMatchingAlg::validate(), pma::ProjectionMatchingAlg::validate_on_adc(), pma::ProjectionMatchingAlg::validate_on_adc_test(), trkf::VertexFitAlg::VertexFit(), View(), Views(), Wire(), lar_pandora::VintageLArTPCThreeView::WirePitchU(), lar_pandora::VintageLArTPCThreeView::WirePitchV(), and lar_pandora::VintageLArTPCThreeView::WirePitchW().

211  {
212  auto it = fPlanes.find(tpcid);
213  if (it == fPlanes.cend()) {
214  throw cet::exception("WireReadoutGeom") << "No TPC with ID " << tpcid << " supported.";
215  }
216  for (PlaneGeo const& plane : it->second) {
217  if (plane.View() == view) { return plane; }
218  }
219  throw cet::exception("WireReadoutGeom")
220  << "TPCGeo " << tpcid << " has no plane for view #" << (size_t)view << "\n";
221  }
std::map< TPCID, std::vector< PlaneGeo > > fPlanes
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
PlaneGeo const & geo::WireReadoutGeom::Plane ( PlaneID const &  planeid) const

Returns the specified wire.

Parameters
tpcidID of the TPC
viewnumber of the requested view
planeidID of the plane
Returns
a constant reference to the specified plane
Exceptions
cet::exception(GeometryCore category) if cryostat not present
cet::exception(TPCOutOfRange category) if no such TPC
cet::exception(PlaneOutOfRange category) if no such plane

The GetElement() method is overloaded and its return depends on the type of ID.

Definition at line 224 of file WireReadoutGeom.cxx.

References PlanePtr().

225  {
226  if (auto const* plane_ptr = PlanePtr(planeid)) { return *plane_ptr; }
227  throw cet::exception("WireReadoutGeom") << "Plane with ID " << planeid << " is not supported.";
228  }
PlaneGeo const * PlanePtr(PlaneID const &planeid) const
Returns the specified plane.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
double geo::WireReadoutGeom::Plane0Pitch ( TPCID const &  tpcid,
unsigned int  p1 
) const

Definition at line 124 of file WireReadoutGeom.cxx.

References fPlane0Pitch.

Referenced by larg4::LArVoxelReadout::DriftIonizationElectrons(), and ThirdPlaneSlope().

125  {
126  return fPlane0Pitch.at(tpcid)[p];
127  }
std::map< TPCID, std::vector< double > > fPlane0Pitch
Pitch between planes.
virtual std::set<PlaneID> const& geo::WireReadoutGeom::PlaneIDs ( ) const
pure virtual

Returns a list of the plane IDs in the whole detector.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel().

double geo::WireReadoutGeom::PlanePitch ( TPCID const &  tpcid,
unsigned int  p1 = 0,
unsigned int  p2 = 1 
) const

Definition at line 130 of file WireReadoutGeom.cxx.

References util::abs(), and fPlane0Pitch.

Referenced by detinfo::DetectorPropertiesStandard::DataFor(), larg4::LArVoxelReadout::DriftIonizationElectrons(), and ThirdPlaneSlope().

131  {
132  auto const& plane0_pitch = fPlane0Pitch.at(tpcid);
133  return std::abs(plane0_pitch[p2] - plane0_pitch[p1]);
134  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::map< TPCID, std::vector< double > > fPlane0Pitch
Pitch between planes.
PlaneGeo const * geo::WireReadoutGeom::PlanePtr ( PlaneID const &  planeid) const

Returns the specified plane.

Parameters
planeidplane ID
Returns
a constant pointer to the specified plane, or nullptr if none

The GetElementPtr() method is overloaded and its return depends on the type of ID.

Definition at line 231 of file WireReadoutGeom.cxx.

References fPlanes, n, geo::PlaneID::parentID(), and geo::PlaneID::Plane.

Referenced by FirstPlane(), GetElement(), geo::details::getElementPtr(), GetElementPtr(), HasPlane(), HasWire(), Nwires(), Plane(), and WirePtr().

232  {
233  auto const [tpc_id, plane] = std::make_pair(planeid.parentID(), planeid.Plane);
234  auto it = fPlanes.find(tpc_id);
235  if (it == fPlanes.cend()) { return nullptr; }
236  if (std::size_t const n = it->second.size(); n <= plane) { return nullptr; }
237  return &it->second[plane];
238  }
std::map< TPCID, std::vector< PlaneGeo > > fPlanes
Char_t n[5]
virtual raw::ChannelID_t geo::WireReadoutGeom::PlaneWireToChannel ( WireID const &  wireID) const
pure virtual
void geo::WireReadoutGeom::ResetDriftDirection ( TPCID const &  tpcid)
private

Recomputes the drift direction; needs planes to have been initialised.

virtual std::vector<TPCID> geo::WireReadoutGeom::ROPtoTPCs ( readout::ROPID const &  ropid) const
pure virtual

Returns a list of ID of TPCs the specified ROP spans.

Parameters
ropidID of the readout plane
Returns
the list of TPC IDs, empty if readout plane ID is invalid

Note that this check is performed on the validity of the readout plane ID, that does not necessarily imply that the readout plane specified by the ID actually exists. Check if the ROP exists with HasROP(). The behaviour on non-existing readout planes is undefined.

Implemented in geo::WireReadoutStandardGeom.

Referenced by reco3d::TripletFinder::FillBadMap(), reco3d::TripletFinder::FillHitMap(), and HasChannel().

virtual std::vector<PlaneID> geo::WireReadoutGeom::ROPtoWirePlanes ( readout::ROPID const &  ropid) const
pure virtual

Returns a list of ID of planes belonging to the specified ROP.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel().

SigType_t geo::WireReadoutGeom::SignalType ( PlaneID const &  pid) const

Returns the type of signal on the channels of specified TPC plane.

Parameters
planeTPC plane ID
Returns
the type of signal on the specified plane, or geo::kMysteryType

Assumes that all the channels on the plane have the same signal type.

Todo:
verify that kMysteryType is returned on invalid plane

Definition at line 499 of file WireReadoutGeom.cxx.

References WirePlaneToROP().

Referenced by geo::WireReadoutDumper::dumpTPCplane(), reco3d::TripletFinder::FillHitMap(), cluster::MergeClusterAlg::GlobalWire(), cluster::BlurredClusteringAlg::GlobalWire(), shower::EMShowerAlg::GlobalWire_(), HasChannel(), shwf::ShowerReco::LongTransEnergy(), caldata::CalWire::produce(), hit::RFFHitFinderAlg::Run(), hit::CCHitFinderAlg::RunCCHitFinder(), and SignalTypeForROPIDImpl().

500  {
501  // map wire plane -> readout plane -> first channel, then use SignalType(channel)
502 
503  auto const ropid = WirePlaneToROP(pid);
504  if (!ropid.isValid) {
505  throw cet::exception("WireReadoutGeom") << "SignalType(): Mapping of wire plane "
506  << std::string(pid) << " to readout plane failed!\n";
507  }
508  return SignalType(ropid);
509  }
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
virtual readout::ROPID WirePlaneToROP(PlaneID const &planeid) const =0
Returns the ID of the ROP planeid belongs to.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
SigType_t geo::WireReadoutGeom::SignalType ( raw::ChannelID_t const  channel) const

Return the signal type of the specified channel.

Parameters
channelID of the channel
Returns
signal type of the channel, or geo::kMysteryType if not known

On any type of error (e.g., invalid or unknown channel ID), geo::kMysteryType is returned.

Definition at line 446 of file WireReadoutGeom.cxx.

References SignalTypeForChannelImpl().

447  {
448  return SignalTypeForChannelImpl(channel);
449  }
virtual SigType_t SignalTypeForChannelImpl(raw::ChannelID_t const channel) const =0
Return the signal type of the specified channel.
SigType_t geo::WireReadoutGeom::SignalType ( readout::ROPID const &  ropid) const

Return the signal type on the specified readout plane.

Parameters
ropidID of the readout plane
Returns
signal type on the plane, or geo::kMysteryType if not known

If the readout plane ID is marked invalid, geo::kMysteryType is returned. If the readout plane is not marked invalid, but it does not match an existing readout plane, the result is undefined.

The default implementation uses readout plane to channel mapping. Other implementation may decide to do the opposite.

Definition at line 451 of file WireReadoutGeom.cxx.

References SignalTypeForROPIDImpl().

452  {
453  return SignalTypeForROPIDImpl(ropid);
454  }
virtual SigType_t SignalTypeForROPIDImpl(readout::ROPID const &ropid) const
Return the signal type on the specified readout plane.
virtual SigType_t geo::WireReadoutGeom::SignalTypeForChannelImpl ( raw::ChannelID_t const  channel) const
protectedpure virtual

Return the signal type of the specified channel.

Parameters
channelID of the channel
Returns
signal type of the channel, or geo::kMysteryType if not known

On any type of error (e.g., invalid or unknown channel ID), geo::kMysteryType is returned.

Implemented in geo::WireReadoutStandardGeom.

Referenced by FirstChannelInThisPlane(), and SignalType().

SigType_t geo::WireReadoutGeom::SignalTypeForROPIDImpl ( readout::ROPID const &  ropid) const
protectedvirtual

Return the signal type on the specified readout plane.

Parameters
ropidID of the readout plane
Returns
signal type on the plane, or geo::kMysteryType if not known

If the readout plane ID is marked invalid, geo::kMysteryType is returned. If the readout plane is not marked invalid, but it does not match an existing readout plane, the result is undefined.

The default implementation uses readout plane to channel mapping. Other implementation may decide to do the opposite.

Definition at line 456 of file WireReadoutGeom.cxx.

References FirstChannelInROP(), and SignalType().

Referenced by FirstChannelInThisPlane(), and SignalType().

457  {
458  return SignalType(FirstChannelInROP(ropid));
459  }
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
virtual raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const =0
Returns the ID of the first channel in the specified readout plane.
void geo::WireReadoutGeom::SortPlanes ( TPCID const &  tpcid,
std::vector< PlaneGeo > &  planes 
) const
private

Sorts (in place) the specified PlaneGeo objects by drift distance.

Definition at line 98 of file WireReadoutGeom.cxx.

References geo::vect::dot(), fGeom, geo::TPCGeo::GetCenter(), geo::vect::normalize(), and geo::GeometryCore::TPC().

Referenced by WireReadoutGeom().

99  {
100  // Sort planes by increasing drift distance.
101  //
102  // This function should work in bootstrap mode, relying on least things as
103  // possible. Therefore we compute here a proxy of the drift axis.
104 
105  // Determine the drift axis (or close to): from TPC center to plane center
106 
107  // Instead of using the plane center, which might be not available yet, we use the
108  // plane box center, which only needs the geometry description to be available.
109 
110  // We use the first plane -- it does not make any difference.
111  auto const TPCcenter = fGeom->TPC(tpcid).GetCenter();
112  auto const driftAxis = vect::normalize(planes[0].GetBoxCenter() - TPCcenter);
113 
114  auto by_distance = [&TPCcenter, &driftAxis](auto const& a, auto const& b) {
115  return vect::dot(a.GetBoxCenter() - TPCcenter, driftAxis) <
116  vect::dot(b.GetBoxCenter() - TPCcenter, driftAxis);
117  };
118  cet::sort_all(planes, by_distance);
119  }
Point_t GetCenter() const
Returns the center of the TPC volume in world coordinates [cm].
Definition: TPCGeo.h:132
constexpr auto dot(Vector const &a, OtherVector const &b)
Return cross product of two vectors.
GeometryCore const * fGeom
Vector normalize(Vector const &v)
Returns a vector parallel to v and with norm 1.
TPCGeo const & TPC(TPCID const &tpcid=details::tpc_zero) const
Returns the specified TPC.
Definition: GeometryCore.h:448
void geo::WireReadoutGeom::SortSubVolumes ( std::vector< PlaneGeo > &  planes,
Compare< WireGeo compareWires 
) const
private

Definition at line 138 of file WireReadoutGeom.cxx.

Referenced by WireReadoutGeom().

140  {
141  for (PlaneGeo& plane : planes)
142  plane.SortWires(compareWires);
143  }
static auto const& geo::WireReadoutGeom::start ( Segment const &  s)
inlinestatic

Definition at line 63 of file WireReadoutGeom.h.

Referenced by WireEndPoints(), and WireIDsIntersect().

63 { return s.first; }
PlaneID geo::WireReadoutGeom::ThirdPlane ( PlaneID const &  pid1,
PlaneID const &  pid2 
) const

Returns the plane that is not in the specified arguments.

Parameters
pid1a plane
pid2another plane
Returns
the ID to the third plane
Exceptions
cet::exception(category: "GeometryCore") if other than 3 planes
cet::exception(category: "GeometryCore") if pid1 and pid2 match

This function requires a geometry with exactly three planes. If the two input planes are not on the same TPC, the result is undefined.

Definition at line 610 of file WireReadoutGeom.cxx.

References Nplanes(), and geo::PlaneID::Plane.

Referenced by ThirdPlane_dTdW(), ThirdPlaneSlope(), and WireEndPoints().

611  {
612  // how many planes in the TPC pid1 belongs to:
613  unsigned const int nPlanes = Nplanes(pid1);
614  if (nPlanes != 3) {
615  throw cet::exception("GeometryCore")
616  << "ThirdPlane() supports only TPCs with 3 planes, and I see " << nPlanes << " instead\n";
617  }
618 
619  PlaneID::PlaneID_t target_plane = nPlanes;
620  for (PlaneID::PlaneID_t iPlane = 0; iPlane < nPlanes; ++iPlane) {
621  if ((iPlane == pid1.Plane) || (iPlane == pid2.Plane)) continue;
622  if (target_plane != nPlanes) {
623  throw cet::exception("GeometryCore")
624  << "ThirdPlane() found too many planes that are not " << std::string(pid1) << " nor "
625  << std::string(pid2) << "! (first " << target_plane << ", then " << iPlane << ")\n";
626  } // if we had a target already
627  target_plane = iPlane;
628  } // for
629  if (target_plane == nPlanes) {
630  throw cet::exception("GeometryCore")
631  << "ThirdPlane() can't find a plane that is not " << std::string(pid1) << " nor "
632  << std::string(pid2) << "!\n";
633  }
634 
635  return PlaneID(pid1, target_plane);
636  }
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:365
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
unsigned int Nplanes(TPCID const &tpcid=details::tpc_zero) const
Returns the total number of planes in the specified TPC.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
double geo::WireReadoutGeom::ThirdPlane_dTdW ( PlaneID const &  pid1,
double  slope1,
PlaneID const &  pid2,
double  slope2,
PlaneID const &  output_plane 
) const

Returns dT/dW on the third plane, given it in the other two.

Parameters
pid1ID of the plane of the first dT/dW
dTdW1dT/dW as seen on the first plane
pid2ID of the plane of the second dT/dW
dTdW2dT/dW as seen on the second plane
output_planeID of the plane on which to calculate the slope
Returns
dT/dW on the third plane, or -999. if dT/dW would be infinity
Exceptions
cet::exception(category: "GeometryCore") if different TPC
cet::exception(category: "GeometryCore") if same plane
cet::exception(category: "GeometryCore") if other than 3 planes

Given a dT/dW as projected in two planes, returns the dT/dW as projected in the third plane. The dT/dW are defined in time ticks/wide number units.

Definition at line 663 of file WireReadoutGeom.cxx.

References ComputeThirdPlane_dTdW(), geo::PlaneGeo::PhiZ(), Plane(), and geo::PlaneGeo::WirePitch().

Referenced by ThirdPlane_dTdW(), and ThirdPlaneSlope().

668  {
669  CheckIndependentPlanesOnSameTPC(pid1, pid2, "ThirdPlane_dTdW()");
670 
671  double angle[3], pitch[3];
672  PlaneGeo const* const planes[3] = {&Plane(pid1), &Plane(pid2), &Plane(output_plane)};
673 
674  // We need wire pitch and "wire coordinate direction" for each plane. The latter is
675  // perpendicular to the wire orientation. PlaneGeo::PhiZ() defines the right
676  // orientation too.
677  for (size_t i = 0; i < 3; ++i) {
678  angle[i] = planes[i]->PhiZ();
679  pitch[i] = planes[i]->WirePitch();
680  }
681 
682  return ComputeThirdPlane_dTdW(
683  angle[0], pitch[0], slope1, angle[1], pitch[1], slope2, angle[2], pitch[2]);
684  }
static double ComputeThirdPlane_dTdW(double angle1, double pitch1, double dTdW1, double angle2, double pitch2, double dTdW2, double angle_target, double pitch_target)
Returns the slope on the third plane, given it in the other two.
double PhiZ() const
Angle from positive z axis of the wire coordinate axis, in radians.
Definition: PlaneGeo.h:164
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
double geo::WireReadoutGeom::ThirdPlane_dTdW ( PlaneID const &  pid1,
double  slope1,
PlaneID const &  pid2,
double  slope2 
) const

Returns dT/dW on the third plane, given it in the other two.

Parameters
pid1ID of the plane of the first dT/dW
dTdW1dT/dW as seen on the first plane
pid2ID of the plane of the second dT/dW
dTdW2dT/dW as seen on the second plane
Returns
dT/dW on the third plane, or -999. if dT/dW would be infinity
Exceptions
cet::exception(category: "GeometryCore") if different TPC
cet::exception(category: "GeometryCore") if same plane
cet::exception(category: "GeometryCore") if other than 3 planes

Given a dT/dW as projected in two planes, returns the dT/dW as projected in the third plane. This function is a shortcut assuming exactly three wire planes in the TPC, in which case the output plane is chosen as the one that is neither of the input planes.

Definition at line 687 of file WireReadoutGeom.cxx.

References ThirdPlane(), and ThirdPlane_dTdW().

691  {
692  return ThirdPlane_dTdW(pid1, slope1, pid2, slope2, ThirdPlane(pid1, pid2));
693  }
PlaneID ThirdPlane(PlaneID const &pid1, PlaneID const &pid2) const
Returns the plane that is not in the specified arguments.
double ThirdPlane_dTdW(PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2, PlaneID const &output_plane) const
Returns dT/dW on the third plane, given it in the other two.
double geo::WireReadoutGeom::ThirdPlaneSlope ( PlaneID const &  pid1,
double  slope1,
PlaneID const &  pid2,
double  slope2,
PlaneID const &  output_plane 
) const

Returns the slope on the third plane, given it in the other two.

Parameters
pid1ID of the plane of the first slope
slope1slope as seen on the first plane
pid2ID of the plane of the second slope
slope2slope as seen on the second plane
output_planeID of the plane on which to calculate the slope
Returns
the slope on the third plane, or -999. if slope would be infinity
Exceptions
cet::exception(category: "GeometryCore") if different TPC
cet::exception(category: "GeometryCore") if input planes match

Given a slope as projected in two planes, returns the slope as projected in the specified output plane. The slopes are defined in uniform units; they should be computed as distance ratios (or tangent of a geometrical angle; the formula is still valid using dt/dw directly in case of equal wire pitch in all planes and uniform drift velocity.

Definition at line 639 of file WireReadoutGeom.cxx.

References ComputeThirdPlaneSlope(), and Plane().

Referenced by trkf::CCTrackMaker::FillEndMatch(), trkf::CCTrackMaker::PlnMatch(), ThirdPlaneSlope(), and WireEndPoints().

644  {
645  CheckIndependentPlanesOnSameTPC(pid1, pid2, "ThirdPlaneSlope()");
646 
647  // We need the "wire coordinate direction" for each plane. This is perpendicular to
648  // the wire orientation. PlaneGeo::PhiZ() defines the right orientation too.
649  return ComputeThirdPlaneSlope(
650  Plane(pid1).PhiZ(), slope1, Plane(pid2).PhiZ(), slope2, Plane(output_plane).PhiZ());
651  }
static double ComputeThirdPlaneSlope(double angle1, double slope1, double angle2, double slope2, double angle_target)
Returns the slope on the third plane, given it in the other two.
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
double geo::WireReadoutGeom::ThirdPlaneSlope ( PlaneID const &  pid1,
double  slope1,
PlaneID const &  pid2,
double  slope2 
) const

Returns the slope on the third plane, given it in the other two.

Parameters
pid1ID of the plane of the first slope
slope1slope as seen on the first plane
pid2ID of the plane of the second slope
slope2slope as seen on the second plane
Returns
the slope on the third plane, or -999. if slope would be infinity
Exceptions
cet::exception(category: "GeometryCore") if different TPC
cet::exception(category: "GeometryCore") if same plane
cet::exception(category: "GeometryCore") if other than 3 planes

Given a slope as projected in two planes, returns the slope as projected in the third plane. This function is a shortcut assuming exactly three wire planes in the TPC, in which case the output plane is chosen as the one that is neither of the input planes.

Definition at line 654 of file WireReadoutGeom.cxx.

References ThirdPlane(), and ThirdPlaneSlope().

658  {
659  return ThirdPlaneSlope(pid1, slope1, pid2, slope2, ThirdPlane(pid1, pid2));
660  }
PlaneID ThirdPlane(PlaneID const &pid1, PlaneID const &pid2) const
Returns the plane that is not in the specified arguments.
double ThirdPlaneSlope(PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2, PlaneID const &output_plane) const
Returns the slope on the third plane, given it in the other two.
double geo::WireReadoutGeom::ThirdPlaneSlope ( PlaneID::PlaneID_t  plane1,
double  slope1,
PlaneID::PlaneID_t  plane2,
double  slope2,
TPCID const &  tpcid 
) const
inline

Returns the slope on the third plane, given it in the other two.

Parameters
plane1index of the plane of the first slope
slope1slope as seen on the first plane
plane2index of the plane of the second slope
slope2slope as seen on the second plane
tpcidTPC where the two planes belong
Returns
the slope on the third plane, or -999. if slope would be infinity
Exceptions
cet::exception(category: "GeometryCore") if different TPC
cet::exception(category: "GeometryCore") if same plane
cet::exception(category: "GeometryCore") if other than 3 planes

Given a slope as projected in two planes, returns the slope as projected in the third plane.

Definition at line 451 of file WireReadoutGeom.h.

References ChannelsInTPCs(), ComputeThirdPlane_dTdW(), ComputeThirdPlaneSlope(), Nchannels(), Plane0Pitch(), PlanePitch(), ThirdPlane_dTdW(), and ThirdPlaneSlope().

456  {
457  return ThirdPlaneSlope(PlaneID(tpcid, plane1), slope1, PlaneID(tpcid, plane2), slope2);
458  }
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
double ThirdPlaneSlope(PlaneID const &pid1, double slope1, PlaneID const &pid2, double slope2, PlaneID const &output_plane) const
Returns the slope on the third plane, given it in the other two.
virtual std::vector<TPCID> geo::WireReadoutGeom::TPCsetToTPCs ( readout::TPCsetID const &  tpcsetid) const
pure virtual

Returns a list of ID of TPCs belonging to the specified TPC set.

Parameters
tpcsetidID of the TPC set to convert into TPC IDs
Returns
the list of TPCs, empty if TPC set is invalid

Note that the check is performed on the validity of the TPC set ID, that does not necessarily imply that the TPC set specified by the ID actually exists. Check the existence of the TPC set first (HasTPCset()). Behaviour on valid, non-existent TPC set IDs is undefined.

Implemented in geo::WireReadoutStandardGeom.

Referenced by ChannelsInTPCs(), and HasChannel().

virtual readout::TPCsetID geo::WireReadoutGeom::TPCtoTPCset ( TPCID const &  tpcid) const
pure virtual

Returns the ID of the TPC set tpcid belongs to.

Implemented in geo::WireReadoutStandardGeom.

Referenced by FindTPCsetAtPosition(), and HasChannel().

void geo::WireReadoutGeom::UpdateAfterSorting ( TPCGeo const &  tpc,
std::vector< PlaneGeo > &  planes 
)
private

Definition at line 146 of file WireReadoutGeom.cxx.

References geo::TPCGeo::DriftDir(), e, geo::TPCGeo::ID(), and lar::util::makeVector3DComparison().

Referenced by WireReadoutGeom().

147  {
148  // ask the planes to update; also check
149  for (unsigned int p = 0; p < planes.size(); ++p) {
150  planes[p].UpdateAfterSorting(PlaneID(tpc.ID(), p), tpc);
151 
152  // check that the plane normal is opposite to the TPC drift direction
153  assert(lar::util::makeVector3DComparison(1e-5).equal(-(planes[p].GetNormalDirection()),
154  tpc.DriftDir()));
155  }
156  }
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
auto makeVector3DComparison(RealType threshold)
Creates a Vector3DComparison from a RealComparisons object.
Float_t e
Definition: plot.C:35
View_t geo::WireReadoutGeom::View ( raw::ChannelID_t const  channel) const

Returns the view (wire orientation) on the specified TPC channel.

Parameters
channelTPC channel ID
Returns
the type of signal on the specified channel, or geo::kUnknown

The view of the readout plane channel belongs to is returned, as in View(readout::ROPID const&) const.

Definition at line 518 of file WireReadoutGeom.cxx.

References ChannelToROP(), raw::InvalidChannelID, and geo::kUnknown.

Referenced by nnet::WaveformDenoiseTest::analyze(), nnet::NoiseWaveformDump::analyze(), nnet::RawWaveformDump::analyze(), nnet::RawWaveformClnSigDump::analyze(), apa::APAGeometryAlg::APAChannelsIntersect(), apa::APAGeometryAlg::APAGeometryAlg(), apa::APAGeometryAlg::APAView(), tca::FillWireHitRange(), apa::APAGeometryAlg::FirstChannelInView(), quad::GetPts2D(), HasChannel(), apa::DisambigAlg::MakeCloseHits(), apa::APAGeometryAlg::NearestWireIDOnChan(), and cheat::BackTracker::TrackIdToSimIDEs_Ps().

519  {
520  return (channel == raw::InvalidChannelID) ? kUnknown : View(ChannelToROP(channel));
521  }
virtual readout::ROPID ChannelToROP(raw::ChannelID_t channel) const =0
Returns the ID of the ROP the channel belongs to.
Unknown view.
Definition: geo_types.h:138
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:31
View_t View(raw::ChannelID_t const channel) const
Returns the view (wire orientation) on the specified TPC channel.
View_t geo::WireReadoutGeom::View ( readout::ROPID const &  ropid) const

Returns the view of the channels in the specified readout plane.

Parameters
ropidreadout plane ID
Returns
the type of signal on the specified ROP

Returns the view (wire orientation) on the channels of specified readout plane. If ropid is an invalid ID, geo::kUnknown is returned. If ropid is a valid ID (i.e. an ID whose isValid flag is set) that points to a non-existent readout plane, the result is undefined. Use HasROP() to check if the readout plane actually exists.

Definition at line 512 of file WireReadoutGeom.cxx.

References FirstWirePlaneInROP(), geo::kUnknown, Plane(), and geo::PlaneGeo::View().

513  {
514  auto const pid = FirstWirePlaneInROP(ropid);
515  return pid ? Plane(pid).View() : kUnknown;
516  }
Unknown view.
Definition: geo_types.h:138
virtual PlaneID FirstWirePlaneInROP(readout::ROPID const &ropid) const =0
Returns the ID of the first plane belonging to the specified ROP.
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:155
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
std::set<View_t> const& geo::WireReadoutGeom::Views ( ) const
inline

Returns a list of possible views in the detector.

Returns
the set of views

Definition at line 123 of file WireReadoutGeom.h.

References allViews, FirstPlane(), and Plane().

Referenced by pma::PMAlgTracker::PMAlgTracker(), and WireReadoutGeom().

123 { return allViews; }
std::set< View_t > allViews
All views in the detector.
std::set< View_t > geo::WireReadoutGeom::Views ( TPCID const &  tpcid) const

Definition at line 241 of file WireReadoutGeom.cxx.

References fPlanes.

242  {
243  auto it = fPlanes.find(tpcid);
244  if (it == fPlanes.cend()) { return {}; }
245  return ::Views(it->second);
246  }
std::map< TPCID, std::vector< PlaneGeo > > fPlanes
WireGeo const & geo::WireReadoutGeom::Wire ( WireID const &  wireid) const

Returns the specified wire.

Parameters
wireidID of the wire
Returns
a constant reference to the specified wire
Exceptions
cet::exceptionif not found

The GetElement() method is overloaded and its return depends on the type of ID.

Definition at line 270 of file WireReadoutGeom.cxx.

References Plane(), and geo::PlaneGeo::Wire().

Referenced by lar_cluster3d::SnippetHit3DBuilder::DistanceFromPointToHitWire(), GetElement(), GetElementPtr(), cluster::MergeClusterAlg::GlobalWire(), cluster::BlurredClusteringAlg::GlobalWire(), shower::EMShowerAlg::GlobalWire_(), lar_cluster3d::PrincipalComponentsAlg::PCAAnalysis_2D(), lar_cluster3d::PrincipalComponentsAlg::PCAAnalysis_calc2DDocas(), trkf::TrackKalmanFitter::setupInputStates(), apa::APAGeometryAlg::ThreeChanPos(), WireEndPoints(), lar_cluster3d::SnippetHit3DBuilder::WireIDsIntersect(), and WireIDsIntersect().

271  {
272  return Plane(wireid).Wire(wireid);
273  }
WireGeo const & Wire(unsigned int iwire) const
Definition: PlaneGeo.cxx:403
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
double geo::WireReadoutGeom::WireAngleToVertical ( View_t  view,
TPCID const &  tpcid 
) const

Returns the angle of the wires in the specified view from vertical.

Parameters
viewthe view
tpcidID of the TPC
Returns
the angle [radians]
Exceptions
cet::exception("GeometryCore" category) if no such view

The angle is defined as in WireGeo::ThetaZ().

This method assumes all wires in the view have the same angle (it queries for the first).

Deprecated:
This does not feel APA-ready

Definition at line 376 of file WireReadoutGeom.cxx.

References geo::PlaneGeo::ViewName().

Referenced by ShowerRecoTools::ShowerUnidirectiondEdx::CalculateElement(), util::GeometryUtilities::CalculatePitch(), util::GeometryUtilities::CalculatePitchPolar(), util::GeometryUtilities::Get2DangleFrom3D(), shower::EMShowerAlg::MakeShower(), util::GeometryUtilities::PitchInView(), lar_pandora::detector_functions::WireAngle(), and WireEndPoints().

377  {
378  for (PlaneGeo const& plane : Iterate<PlaneGeo>(tpcid)) {
379  if (plane.View() == view) return plane.ThetaZ();
380  } // for
381  throw cet::exception("WireReadoutGeom")
382  << "WireAngleToVertical(): no view \"" << PlaneGeo::ViewName(view) << "\" (#" << ((int)view)
383  << ") in " << std::string(tpcid);
384  }
static std::string ViewName(View_t view)
Returns the name of the specified view.
Definition: PlaneGeo.cxx:584
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
virtual double geo::WireReadoutGeom::WireCoordinate ( double  YPos,
double  ZPos,
PlaneID const &  planeID 
) const
pure virtual

Returns the index of the wire nearest to the specified position.

Parameters
YPosy coordinate on the wire plane
ZPosz coordinate on the wire plane
planeIDID of the plane
Returns
an index interpolation between the two nearest wires
See also
NearestWireID()

Respect to NearestWireID(), this method returns a real number, representing a continuous coordinate in the wire axis, with the round values corresponding to the actual wires.

The plane is required to be valid and exist in the detector. Otherwise, the behaviour is undefined.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel().

void geo::WireReadoutGeom::WireEndPoints ( WireID const &  wireid,
double *  xyzStart,
double *  xyzEnd 
) const

Fills two arrays with the coordinates of the wire end points.

Parameters
wireidID of the wire
xyzStart(output) an array with the start coordinate
xyzEnd(output) an array with the end coordinate
Exceptions
cet::exceptionwire not present

The starting point is the wire end with lower z coordinate.

Deprecated:
use the wire ID interface instead (but note that it does not sort the ends)

Definition at line 276 of file WireReadoutGeom.cxx.

References util::abs(), geo::Iterable< details::ReadoutIterationPolicy, details::ToReadoutGeometryElement >::end(), and start().

Referenced by lar_cluster3d::StandardHit3DBuilder::DistanceFromPointToHitWire(), GetElement(), quad::GetPts2D(), apa::DisambigAlg::TrivialDisambig(), and WireIDsIntersect().

277  {
278  auto const [start, end] = WireEndPoints(wireid);
279 
280  xyzStart[0] = start.X();
281  xyzStart[1] = start.Y();
282  xyzStart[2] = start.Z();
283  xyzEnd[0] = end.X();
284  xyzEnd[1] = end.Y();
285  xyzEnd[2] = end.Z();
286 
287  if (xyzEnd[2] < xyzStart[2]) {
288  // Ensure that "End" has higher z-value than "Start"
289  std::swap(xyzStart[0], xyzEnd[0]);
290  std::swap(xyzStart[1], xyzEnd[1]);
291  std::swap(xyzStart[2], xyzEnd[2]);
292  }
293  if (xyzEnd[1] < xyzStart[1] && std::abs(xyzEnd[2] - xyzStart[2]) < 0.01) {
294  // If wire is vertical ensure that "End" has higher y-value than "Start"
295  std::swap(xyzStart[0], xyzEnd[0]);
296  std::swap(xyzStart[1], xyzEnd[1]);
297  std::swap(xyzStart[2], xyzEnd[2]);
298  }
299  }
static auto const & start(Segment const &s)
constexpr auto abs(T v)
Returns the absolute value of the argument.
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
void WireEndPoints(WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
Segment geo::WireReadoutGeom::WireEndPoints ( WireID const &  wireid) const
inline

Returns a segment whose ends are the wire end points.

Parameters
wireidID of the wire
Returns
a segment whose ends are the wire end points
Exceptions
cet::exceptionwire not present

The start and end are assigned as returned from the geo::WireGeo object. The rules for this assignment are documented in that class.

Deprecated:
use the wire ID interface instead (but note that it does not sort the ends)

Definition at line 260 of file WireReadoutGeom.h.

References geo::WireGeo::GetEnd(), geo::WireGeo::GetStart(), ThirdPlane(), ThirdPlaneSlope(), Wire(), WireAngleToVertical(), and WireIDsIntersect().

261  {
262  WireGeo const& wire = Wire(wireid);
263  return {wire.GetStart(), wire.GetEnd()};
264  }
WireGeo const & Wire(WireID const &wireid) const
Returns the specified wire.
bool geo::WireReadoutGeom::WireIDIntersectionCheck ( WireID const &  wid1,
WireID const &  wid2 
) const
private

Wire ID check for WireIDsIntersect methods.

Definition at line 582 of file WireReadoutGeom.cxx.

References geo::PlaneID::asTPCID(), HasWire(), Nwires(), geo::PlaneID::Plane, and geo::WireID::planeID().

Referenced by WireIDsIntersect().

583  {
584  if (wid1.asTPCID() != wid2) {
585  mf::LogError("WireIDIntersectionCheck")
586  << "Comparing two wires on different TPCs: return failure.";
587  return false;
588  }
589  if (wid1.Plane == wid2.Plane) {
590  mf::LogError("WireIDIntersectionCheck")
591  << "Comparing two wires in the same plane: return failure";
592  return false;
593  }
594  if (!HasWire(wid1)) {
595  mf::LogError("WireIDIntersectionCheck")
596  << "1st wire " << wid1 << " does not exist (max wire number: " << Nwires(wid1.planeID())
597  << ")";
598  return false;
599  }
600  if (!HasWire(wid2)) {
601  mf::LogError("WireIDIntersectionCheck")
602  << "2nd wire " << wid2 << " does not exist (max wire number: " << Nwires(wid2.planeID())
603  << ")";
604  return false;
605  }
606  return true;
607  }
unsigned int Nwires(PlaneID const &planeid) const
Returns the total number of wires in the specified plane.
bool HasWire(WireID const &wireid) const
Returns whether we have the specified wire.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool geo::WireReadoutGeom::WireIDsIntersect ( WireID const &  wid1,
WireID const &  wid2,
Point_t intersection 
) const

Computes the intersection between two wires.

Parameters
wid1ID of the first wire
wid2ID of the other wire
[out]intersectionthe intersection point (global coordinates)
Returns
whether an intersection was found inside the TPC the wires belong
See also
geo::WiresIntersection(), geo::LineClosestPoint()

The wires identified by wid1 and wid2 are intersected, and the 3D intersection point is written into the intersection parameter. The "intersection" point is actually the point belonging to the first wire (wid2) which is the closest (in Euclidean 3D metric) to the second wire.

The intersection is computed only if the wires belong to different planes of the same TPC. If that is not the case (i.e. they belong to different TPC or cryostat, or if they belong to the same plane), false is returned and intersection is set with all components to infinity (std::numeric_limits<>::infinity()).

When the intersection is computed, it is always stored in the intersection output parameter. Return value is true if this intersection lies within the physical boundaries first wire, while it is instead false if it lies on the extrapolation of the wire direction, but not within the wire physical extension.

To test that the result is not infinity (nor NaN), use geo::vect::isfinite(intersection) etc.

Note
If geo::WireGeo objects are already available, using instead the free function geo::WiresIntersection() or the method geo::WireGeo::IntersectionWith() is faster (and recommended). For purely geometric intersection, geo::LineClosestPoint() is also available.

Definition at line 344 of file WireReadoutGeom.cxx.

References util::abs(), geo::WireGeo::HalfL(), geo::IntersectionPointAndOffsets< Point >::offset1, geo::IntersectionPointAndOffsets< Point >::offset2, geo::IntersectionPointAndOffsets< Point >::point, Wire(), WireIDIntersectionCheck(), and geo::WiresIntersectionAndOffsets().

Referenced by pma::ProjectionMatchingAlg::addEndpointRef_(), apa::APAGeometryAlg::APAChannelsIntersect(), ChannelsIntersect(), apa::DisambigAlg::CompareViews(), shower::EMShowerAlg::Construct3DPoint_(), trkf::CCTrackMaker::FillEndMatch(), tca::FillWireIntersections(), tca::Find3DVertices(), reco3d::IntersectionCache::ISect(), lar_cluster3d::StandardHit3DBuilder::makeDeadChannelPair(), lar_cluster3d::SnippetHit3DBuilder::makeDeadChannelPair(), lar_cluster3d::StandardHit3DBuilder::makeHitPair(), tca::Match2Planes(), trkf::CCTrackMaker::PlnMatch(), trkf::TrackTrajectoryAlg::ShortTrackTrajectory(), apa::APAGeometryAlg::ThreeChanPos(), and WireEndPoints().

347  {
348  // This is not a real 3D intersection: the wires do not cross, since they are required
349  // to belong to two different planes.
350  //
351  // We take the point on the first wire which is closest to the other one.
352  static_assert(std::numeric_limits<decltype(intersection.X())>::has_infinity,
353  "the vector coordinate type can't represent infinity!");
354  constexpr auto infinity = std::numeric_limits<decltype(intersection.X())>::infinity();
355 
356  if (!WireIDIntersectionCheck(wid1, wid2)) {
357  intersection = {infinity, infinity, infinity};
358  return false;
359  }
360 
361  WireGeo const& wire1 = Wire(wid1);
362  WireGeo const& wire2 = Wire(wid2);
363 
364  // Distance of the intersection point from the center of the two wires:
365  IntersectionPointAndOffsets<Point_t> intersectionAndOffset =
366  WiresIntersectionAndOffsets(wire1, wire2);
367  intersection = intersectionAndOffset.point;
368 
369  return std::abs(intersectionAndOffset.offset1) <= wire1.HalfL() &&
370  std::abs(intersectionAndOffset.offset2) <= wire2.HalfL();
371  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
WireGeo const & Wire(WireID const &wireid) const
Returns the specified wire.
IntersectionPointAndOffsets< Point_t > WiresIntersectionAndOffsets(WireGeo const &wireA, WireGeo const &wireB)
Returns the point of wireA that is closest to wireB.
Definition: WireGeo.h:516
bool WireIDIntersectionCheck(WireID const &wid1, WireID const &wid2) const
Wire ID check for WireIDsIntersect methods.
std::optional< WireIDIntersection > geo::WireReadoutGeom::WireIDsIntersect ( WireID const &  wid1,
WireID const &  wid2 
) const

Computes the intersection between two wires.

Parameters
wid1ID of the first wire
wid2ID of the other wire
Returns
whether an intersection was found within the TPC

The "intersection" refers to the projection of the wires into the same $ x = 0 $ plane. Wires are assumed to have at most one intersection. If wires are parallel, widIntersect will have the two components set to infinity (std::numeric_limits<>::infinity()) and the TPC number set to invalid (geo::TPCID::InvalidID). Also, false is returned. If the intersection is outside the TPC, false is also returned, but the widIntersect will contain the coordinates of that intersection. The TPC number is still set to invalid, although the intersection might belong to a valid TPC somewhere else.

Deprecated:
This method uses arbitrary assumptions and should not be used. Use the interface returning a full vector instead.

Definition at line 302 of file WireReadoutGeom.cxx.

References geo::vect::cross(), finish(), geo::IntersectLines(), lar::util::PointWithinSegments(), start(), geo::TPCID::TPC, geo::WireIDIntersection::TPC, WireEndPoints(), WireIDIntersectionCheck(), geo::Y, geo::WireIDIntersection::y, geo::Z, and geo::WireIDIntersection::z.

304  {
305  if (!WireIDIntersectionCheck(wid1, wid2)) { return std::nullopt; }
306 
307  // get the endpoints to see if wires intersect
308  Segment const w1 = WireEndPoints(wid1);
309  Segment const w2 = WireEndPoints(wid2);
310 
311  // TODO extract the coordinates in the right way;
312  // is it any worth, since then the result is in (y, z), whatever it means?
313  WireIDIntersection result;
314  bool const cross = IntersectLines(start(w1).Y(),
315  start(w1).Z(),
316  finish(w1).Y(),
317  finish(w1).Z(),
318  start(w2).Y(),
319  start(w2).Z(),
320  finish(w2).Y(),
321  finish(w2).Z(),
322  result.y,
323  result.z);
324  if (!cross) { return std::nullopt; }
325 
326  bool const within = lar::util::PointWithinSegments(start(w1).Y(),
327  start(w1).Z(),
328  finish(w1).Y(),
329  finish(w1).Z(),
330  start(w2).Y(),
331  start(w2).Z(),
332  finish(w2).Y(),
333  finish(w2).Z(),
334  result.y,
335  result.z);
336 
337  if (!within) { return std::nullopt; }
338 
339  result.TPC = wid1.TPC;
340  return result;
341  }
static auto const & start(Segment const &s)
bool PointWithinSegments(double A_start_x, double A_start_y, double A_end_x, double A_end_y, double B_start_x, double B_start_y, double B_end_x, double B_end_y, double x, double y)
Returns whether x and y are within both specified ranges (A and B).
bool IntersectLines(double A_start_x, double A_start_y, double A_end_x, double A_end_y, double B_start_x, double B_start_y, double B_end_x, double B_end_y, double &x, double &y)
Computes the intersection between two lines on a plane.
static auto const & finish(Segment const &s)
std::pair< Point_t, Point_t > Segment
bool WireIDIntersectionCheck(WireID const &wid1, WireID const &wid2) const
Wire ID check for WireIDsIntersect methods.
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
void WireEndPoints(WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
virtual readout::ROPID geo::WireReadoutGeom::WirePlaneToROP ( PlaneID const &  planeid) const
pure virtual

Returns the ID of the ROP planeid belongs to.

Implemented in geo::WireReadoutStandardGeom.

Referenced by HasChannel(), and SignalType().

WireGeo const * geo::WireReadoutGeom::WirePtr ( WireID const &  wireid) const

Returns the specified wire.

Parameters
wireidwire ID
Returns
a constant pointer to the specified wire, or nullptr if none

The GetElementPtr() method is overloaded and its return depends on the type of ID.

Definition at line 263 of file WireReadoutGeom.cxx.

References PlanePtr(), and geo::PlaneGeo::WirePtr().

Referenced by geo::details::getElementPtr(), GetElementPtr(), HasElement(), and lar_cluster3d::MinSpanTreeAlg::MinSpanTreeAlg().

264  {
265  PlaneGeo const* pPlane = PlanePtr(wireid);
266  return pPlane ? pPlane->WirePtr(wireid) : nullptr;
267  }
PlaneGeo const * PlanePtr(PlaneID const &planeid) const
Returns the specified plane.

Member Data Documentation

std::set<View_t> geo::WireReadoutGeom::allViews
private

All views in the detector.

Definition at line 1090 of file WireReadoutGeom.h.

Referenced by Views(), and WireReadoutGeom().

GeometryCore const* geo::WireReadoutGeom::fGeom
private
std::map<TPCID, std::vector<double> > geo::WireReadoutGeom::fPlane0Pitch
private

Pitch between planes.

Definition at line 1087 of file WireReadoutGeom.h.

Referenced by Plane0Pitch(), PlanePitch(), and WireReadoutGeom().

std::map<TPCID, std::vector<PlaneGeo> > geo::WireReadoutGeom::fPlanes
private

Definition at line 1086 of file WireReadoutGeom.h.

Referenced by MaxPlanes(), Nplanes(), Plane(), PlanePtr(), Views(), and WireReadoutGeom().


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