LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
apa::APAGeometryAlg Class Reference

#include "APAGeometryAlg.h"

Public Member Functions

 APAGeometryAlg (fhicl::ParameterSet const &pset)
 
 APAGeometryAlg ()
 
void reconfigure (fhicl::ParameterSet const &p)
 
void Init ()
 Initialize some chanel numbers to speed up other methods. More...
 
bool APAChannelsIntersect (uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector) const
 If the channels intersect, get all intersections. More...
 
bool LineSegChanIntersect (TVector3 xyzStart, TVector3 xyzEnd, uint32_t chan, std::vector< geo::WireID > &widsCrossed, bool ExtendLine) const
 If a line given by start/end points intersects a channel. More...
 
std::vector< geo::WireIDChanSegsPerSide (uint32_t chan, unsigned int side) const
 
std::vector< geo::WireIDChanSegsPerSide (std::vector< geo::WireID > wids, unsigned int side) const
 
std::vector< double > ThreeChanPos (uint32_t u, uint32_t v, uint32_t z) const
 Find the center of the 3 intersections, choose best if multiple. More...
 
geo::WireID NearestWireIDOnChan (const double WorldLoc[3], uint32_t chan, unsigned int const plane, unsigned int const tpc=0, unsigned int const cstat=0) const
 
unsigned int ChannelToAPA (uint32_t chan) const
 Get number of the APA containing the given channel. More...
 
void ChannelToAPA (uint32_t chan, unsigned int &apa, unsigned int &cryo) const
 
APAView_t APAView (uint32_t chan) const
 Get which of the 4 APA views the channel is in. More...
 
unsigned int ChannelsInView (geo::View_t geoview) const
 
uint32_t FirstChannelInView (geo::View_t geoview, unsigned int apa, unsigned int cryo) const
 
uint32_t FirstChannelInView (geo::View_t geoview, uint32_t chan) const
 
uint32_t FirstChannelInView (uint32_t chan) const
 
unsigned int ChannelsInAPAView (APAView_t apaview) const
 
unsigned int ChannelsPerAPA () const
 

Private Attributes

art::ServiceHandle< geo::Geometry const > fGeom
 
unsigned int fChannelsPerAPA
 All APAs have this same number of channels. More...
 
unsigned int fAPAsPerCryo
 
uint32_t fFirstU
 
uint32_t fLastU
 
uint32_t fFirstV
 
uint32_t fLastV
 
uint32_t fFirstZ0
 
uint32_t fLastZ0
 
uint32_t fFirstZ1
 
uint32_t fLastZ1
 
double fChannelRange [2]
 

Detailed Description

Definition at line 33 of file APAGeometryAlg.h.

Constructor & Destructor Documentation

apa::APAGeometryAlg::APAGeometryAlg ( fhicl::ParameterSet const &  pset)

Definition at line 29 of file APAGeometryAlg.cxx.

References Init(), and reconfigure().

30  {
31  this->reconfigure(pset);
32  this->Init();
33  }
void Init()
Initialize some chanel numbers to speed up other methods.
void reconfigure(fhicl::ParameterSet const &p)
apa::APAGeometryAlg::APAGeometryAlg ( )

Definition at line 36 of file APAGeometryAlg.cxx.

References Init().

37  {
38  this->Init();
39  }
void Init()
Initialize some chanel numbers to speed up other methods.

Member Function Documentation

bool apa::APAGeometryAlg::APAChannelsIntersect ( uint32_t  chan1,
uint32_t  chan2,
std::vector< geo::WireIDIntersection > &  IntersectVector 
) const

If the channels intersect, get all intersections.

Definition at line 446 of file APAGeometryAlg.cxx.

References ChannelToAPA(), geo::GeometryCore::ChannelToWire(), fGeom, geo::GeometryCore::View(), and geo::GeometryCore::WireIDsIntersect().

Referenced by ThreeChanPos(), and apa::DisambigAlg::UseEndPts().

450  {
451 
452  // Get the WireIDs and view for each channel, make sure views are different
453  geo::WireIDIntersection widIntersect;
454  std::vector<geo::WireID> wids1 = fGeom->ChannelToWire(chan1);
455  std::vector<geo::WireID> wids2 = fGeom->ChannelToWire(chan2);
456  geo::View_t view1 = fGeom->View(chan1);
457  geo::View_t view2 = fGeom->View(chan2);
458  if (view1 == view2) {
459  mf::LogWarning("APAChannelsIntersect")
460  << "Comparing two channels in the same view, return false";
461  return false;
462  }
463  if (wids1[0].Cryostat != wids2[0].Cryostat ||
464  this->ChannelToAPA(chan1) != this->ChannelToAPA(chan2)) {
465  throw cet::exception("APAChannelsIntersect")
466  << "Comparing two channels in in different APAs: "
467  << "channel " << chan1 << " in Cryo " << wids1[0].Cryostat << ", APA "
468  << this->ChannelToAPA(chan1) << ", and channel " << chan2 << " in Cryo "
469  << wids2[0].Cryostat << ", APA " << this->ChannelToAPA(chan2) << "\n";
470  return false;
471  }
472 
473  // Loop through wids1 and see if wids2 has any intersecting wires,
474  // given that the WireIDs are in the same TPC
475  for (unsigned int i1 = 0; i1 < wids1.size(); i1++) {
476  for (unsigned int i2 = 0; i2 < wids2.size(); i2++) {
477 
478  // make sure it is reasonable to intersect
479  if (wids1[i1].Plane == wids2[i2].Plane ||
480  wids1[i1].TPC != wids2[i2].TPC || // not reasonable for a *WireID*
481  wids1[i1].Cryostat != wids2[i2].Cryostat)
482  continue;
483 
484  // std::cout << "Checking: \n WireID 1 = ("
485  // << wids1[i1].Cryostat << "," << wids1[i1].TPC << ","
486  // << wids1[i1].Plane << "," << wids1[i1].Wire
487  // << ") \n WireID 2 = ("
488  // << wids2[i2].Cryostat << "," << wids2[i2].TPC << ","
489  // << wids2[i2].Plane << "," << wids2[i2].Wire << ")" << std::endl;
490 
491  // Check if they even intersect; if they do, push back
492  if (fGeom->WireIDsIntersect(wids1[i1], wids2[i2], widIntersect)) {
493 
494  // std::cout << "we have an intersect" << std::endl;
495 
496  IntersectVector.push_back(widIntersect);
497  }
498  }
499  }
500 
501  // Of all considered configurations, there are never more than
502  // 4 intersections per channel pair
503  if (IntersectVector.size() > 4) {
504  mf::LogWarning("APAChannelsIntersect")
505  << "Got " << IntersectVector.size() << " intersections for channels " << chan1 << " and "
506  << chan2 << " - never expect more than 4, so far";
507  }
508 
509  // With increasing IntersectVector index, the WireID
510  // vector indices of the intersecting wireIDs increase.
511  // This matches the direction in which ChannelToWire
512  // builds its output WireID vector in the APA/35t Alg
513  std::sort(IntersectVector.begin(), IntersectVector.end());
514 
515  // return true if any intersection points were found
516  if (IntersectVector.size() == 0)
517  return false;
518  else
519  return true;
520  }
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, Point_t &intersection) const
Computes the intersection between two wires.
unsigned int ChannelToAPA(uint32_t chan) const
Get number of the APA containing the given channel.
art::ServiceHandle< geo::Geometry const > fGeom
View_t View(PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
recob::tracking::Plane Plane
Definition: TrackState.h:17
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
APAView_t apa::APAGeometryAlg::APAView ( uint32_t  chan) const

Get which of the 4 APA views the channel is in.

Definition at line 191 of file APAGeometryAlg.cxx.

References fChannelsPerAPA, fFirstZ1, fGeom, fLastV, fLastZ0, apa::kU, geo::kU, apa::kUnknown, apa::kV, geo::kV, geo::kZ, apa::kZ0, apa::kZ1, and geo::GeometryCore::View().

192  {
193 
194  // it seems trivial to do this for U and V, but this gives a side to
195  // geo::kZ, unlike Geometry::View(c), as is often needed in disambiguation
196 
197  geo::View_t view = fGeom->View(chan);
198  switch (view) {
199  default: break;
200  case geo::kU: return kU;
201  case geo::kV: return kV;
202  case geo::kZ:
203  unsigned int modchan = chan % fChannelsPerAPA;
204  // Channel mapping number in the order of U, V, Z0, then Z1
205  if (modchan > fLastV && modchan < fFirstZ1) return kZ0;
206  if (modchan > fLastZ0) return kZ1;
207  }
208 
209  return kUnknown;
210  }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Planes which measure V.
Definition: geo_types.h:136
Planes which measure Z direction.
Definition: geo_types.h:138
U view on both sides of the APA.
V view on both sides of the APA.
Z view on the larger-x side of the APA.
Planes which measure U.
Definition: geo_types.h:135
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
Z view on the smaller-x side of the APA.
art::ServiceHandle< geo::Geometry const > fGeom
View_t View(PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
unsigned int apa::APAGeometryAlg::ChannelsInAPAView ( APAView_t  apaview) const

Definition at line 143 of file APAGeometryAlg.cxx.

References fFirstU, fFirstV, fFirstZ0, fFirstZ1, fLastZ1, apa::kU, apa::kV, apa::kZ0, and apa::kZ1.

Referenced by ChannelsInView().

144  {
145 
146  switch (apaview) {
147  default: return 0;
148  case kU: return fFirstV - fFirstU;
149  case kV: return fFirstZ0 - fFirstV;
150  case kZ0: return fFirstZ1 - fFirstZ0;
151  case kZ1: return fLastZ1 - fFirstZ1 + 1;
152  }
153  }
U view on both sides of the APA.
V view on both sides of the APA.
Z view on the larger-x side of the APA.
Z view on the smaller-x side of the APA.
unsigned int apa::APAGeometryAlg::ChannelsInView ( geo::View_t  geoview) const

Definition at line 126 of file APAGeometryAlg.cxx.

References ChannelsInAPAView(), apa::kU, geo::kU, apa::kV, geo::kV, geo::kZ, apa::kZ0, and apa::kZ1.

Referenced by apa::DisambigAlg::FindChanTimeEndPts(), and apa::DisambigAlg::MakeCloseHits().

127  {
128 
129  switch (geoview) {
130  default: return 0;
131  case geo::kU: return ChannelsInAPAView(kU);
132  case geo::kV: return ChannelsInAPAView(kV);
133  case geo::kZ:
135  return ChannelsInAPAView(kZ0);
136  else
137  throw cet::exception("ChannelsInView")
138  << "Both Z sides should have the same amount of channels\n";
139  }
140  }
Planes which measure V.
Definition: geo_types.h:136
unsigned int ChannelsInAPAView(APAView_t apaview) const
Planes which measure Z direction.
Definition: geo_types.h:138
U view on both sides of the APA.
V view on both sides of the APA.
Z view on the larger-x side of the APA.
Planes which measure U.
Definition: geo_types.h:135
Z view on the smaller-x side of the APA.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
unsigned int apa::APAGeometryAlg::ChannelsPerAPA ( ) const
inline

Definition at line 76 of file APAGeometryAlg.h.

76 { return fChannelsPerAPA; };
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
unsigned int apa::APAGeometryAlg::ChannelToAPA ( uint32_t  chan) const

Get number of the APA containing the given channel.

Definition at line 120 of file APAGeometryAlg.cxx.

References fChannelsPerAPA.

Referenced by APAChannelsIntersect(), FirstChannelInView(), apa::DisambigAlg::MakeCloseHits(), and apa::DisambigAlg::RunDisambig().

121  {
122  return chan / fChannelsPerAPA;
123  }
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
void apa::APAGeometryAlg::ChannelToAPA ( uint32_t  chan,
unsigned int &  apa,
unsigned int &  cryo 
) const

Definition at line 105 of file APAGeometryAlg.cxx.

References fAPAsPerCryo, and fChannelsPerAPA.

106  {
107 
108  cryo = chan / (fAPAsPerCryo * fChannelsPerAPA);
109 
110  // Number apa uniquely across cryostats so that
111  // apa to recob::Object maps are easy to work with.
112  // If we decide to reset APA number per cryo, uncomment:
113  //chan -= cryo*fAPAsPerCryo*fChannelsPerAPA;
114  apa = chan / fChannelsPerAPA;
115 
116  return;
117  }
unsigned int fAPAsPerCryo
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
std::vector< geo::WireID > apa::APAGeometryAlg::ChanSegsPerSide ( uint32_t  chan,
unsigned int  side 
) const

Definition at line 213 of file APAGeometryAlg.cxx.

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

214  {
215 
216  std::vector<geo::WireID> wids = fGeom->ChannelToWire(chan);
217  return this->ChanSegsPerSide(wids, side);
218  }
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
art::ServiceHandle< geo::Geometry const > fGeom
std::vector< geo::WireID > ChanSegsPerSide(uint32_t chan, unsigned int side) const
std::vector< geo::WireID > apa::APAGeometryAlg::ChanSegsPerSide ( std::vector< geo::WireID wids,
unsigned int  side 
) const

Definition at line 221 of file APAGeometryAlg.cxx.

223  {
224  // Given a vector of wireIDs and an APA side, return
225  // the wireIDs the the tpc side where tpc%2 = side
226 
227  std::vector<geo::WireID> thisSide;
228 
229  for (size_t i = 0; i < wids.size(); i++)
230  if (wids[i].TPC % 2 == side) thisSide.push_back(wids[i]);
231 
232  return thisSide;
233  }
uint32_t apa::APAGeometryAlg::FirstChannelInView ( geo::View_t  geoview,
unsigned int  apa,
unsigned int  cryo 
) const

Definition at line 156 of file APAGeometryAlg.cxx.

References fAPAsPerCryo, fChannelsPerAPA, fFirstU, fFirstV, fFirstZ0, geo::kU, geo::kV, and geo::kZ.

Referenced by apa::DisambigAlg::FindChanTimeEndPts(), FirstChannelInView(), and apa::DisambigAlg::MakeCloseHits().

159  {
160 
161  switch (geoview) {
162  default: return 0 + (uint32_t)(apa + cryo * fAPAsPerCryo) * fChannelsPerAPA;
163  case geo::kU: return fFirstU + (uint32_t)(apa + cryo * fAPAsPerCryo) * fChannelsPerAPA;
164  case geo::kV: return fFirstV + (uint32_t)(apa + cryo * fAPAsPerCryo) * fChannelsPerAPA;
165  case geo::kZ:
166  //TODO: would need tpc number for the rest of this
167  return fFirstZ0 + (uint32_t)(apa + cryo * fAPAsPerCryo) * fChannelsPerAPA;
168  }
169  }
Planes which measure V.
Definition: geo_types.h:136
Planes which measure Z direction.
Definition: geo_types.h:138
unsigned int fAPAsPerCryo
Planes which measure U.
Definition: geo_types.h:135
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
uint32_t apa::APAGeometryAlg::FirstChannelInView ( geo::View_t  geoview,
uint32_t  chan 
) const

Definition at line 182 of file APAGeometryAlg.cxx.

References ChannelToAPA(), and FirstChannelInView().

183  {
184 
185  unsigned int apa, cryo;
186  this->ChannelToAPA(chan, apa, cryo);
187  return this->FirstChannelInView(geoview, apa, cryo);
188  }
uint32_t FirstChannelInView(geo::View_t geoview, unsigned int apa, unsigned int cryo) const
unsigned int ChannelToAPA(uint32_t chan) const
Get number of the APA containing the given channel.
uint32_t apa::APAGeometryAlg::FirstChannelInView ( uint32_t  chan) const

Definition at line 172 of file APAGeometryAlg.cxx.

References ChannelToAPA(), fGeom, FirstChannelInView(), and geo::GeometryCore::View().

173  {
174 
175  geo::View_t geoview = fGeom->View(chan);
176  unsigned int apa, cryo;
177  this->ChannelToAPA(chan, apa, cryo);
178  return this->FirstChannelInView(geoview, chan);
179  }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
uint32_t FirstChannelInView(geo::View_t geoview, unsigned int apa, unsigned int cryo) const
unsigned int ChannelToAPA(uint32_t chan) const
Get number of the APA containing the given channel.
art::ServiceHandle< geo::Geometry const > fGeom
View_t View(PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
void apa::APAGeometryAlg::Init ( )

Initialize some chanel numbers to speed up other methods.

Definition at line 45 of file APAGeometryAlg.cxx.

References geo::GeometryCore::ChannelToWire(), fAPAsPerCryo, fChannelRange, fChannelsPerAPA, fFirstU, fFirstV, fFirstZ0, fFirstZ1, fGeom, fLastU, fLastV, fLastZ0, fLastZ1, geo::kU, geo::kV, geo::kZ, geo::GeometryCore::Nchannels(), geo::GeometryCore::NTPC(), geo::TPCID::TPC, geo::GeometryCore::View(), and geo::GeometryCore::WirePitch().

Referenced by APAGeometryAlg().

46  {
47 
48  // find the number of channels per APA
49  uint32_t channel = 0;
50 
51  // old logic -- segfaults if there is just one APA
52  //while( fGeom->ChannelToWire(channel+1)[0].TPC < 2 ) channel++;
53  //fChannelsPerAPA = channel + 1;
54 
56  for (channel = 0; channel < fGeom->Nchannels(); ++channel) {
57  if (fGeom->ChannelToWire(channel)[0].TPC > 1) {
58  fChannelsPerAPA = channel;
59  break;
60  }
61  }
62 
63  // Step through channel c and find the view boundaries, until
64  // outside of first APA - these help optimize ChannelToAPAView
65  // (very dependent on the conventions implimented in the channel map)
66  fFirstU = 0;
67  uint32_t c = 1;
68  geo::WireID wid = (fGeom->ChannelToWire(c))[0];
69  geo::WireID lastwid;
70  while (wid.TPC < 2) {
71 
72  if (fGeom->View(c) == geo::kV && fGeom->View(c - 1) == geo::kU) {
73  fLastU = c - 1;
74  fFirstV = c;
75  }
76 
77  if (fGeom->View(c) == geo::kZ && fGeom->View(c - 1) == geo::kV) {
78  fLastV = c - 1;
79  fFirstZ0 = c;
80  }
81 
82  if (wid.TPC == lastwid.TPC + 1) {
83  fLastZ0 = c - 1;
84  fFirstZ1 = c;
85  }
86 
87  lastwid = wid;
88  c++;
89  if (c >= fGeom->Nchannels()) break;
90  wid = (fGeom->ChannelToWire(c))[0]; // for the while condition
91  }
92 
93  fLastZ1 = c - 1;
94 
95  if (fLastZ1 + 1 != fChannelsPerAPA)
96  throw cet::exception("APAGeometryAlg") << "Channel boundaries are inconsistent.\n";
97 
98  // some other things that will be needed
99  fAPAsPerCryo = fGeom->NTPC() / 2;
102  }
unsigned int NTPC(CryostatID const &cryoid=cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
Definition: GeometryCore.h:686
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
Planes which measure V.
Definition: geo_types.h:136
Planes which measure Z direction.
Definition: geo_types.h:138
unsigned int fAPAsPerCryo
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
Planes which measure U.
Definition: geo_types.h:135
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
art::ServiceHandle< geo::Geometry const > fGeom
View_t View(PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:399
Length_t WirePitch(PlaneID const &planeid=plane_zero) const
Returns the distance between two consecutive wires.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool apa::APAGeometryAlg::LineSegChanIntersect ( TVector3  xyzStart,
TVector3  xyzEnd,
uint32_t  chan,
std::vector< geo::WireID > &  widsCrossed,
bool  ExtendLine = true 
) const

If a line given by start/end points intersects a channel.

Definition at line 272 of file APAGeometryAlg.cxx.

References geo::GeometryCore::ChannelToWire(), fGeom, geo::GeometryCore::NearestWireID(), geo::GeometryCore::PositionToTPCID(), geo::vect::toPoint(), lar::util::ValueInRange(), w, and geo::WireID::Wire.

277  {
278  // This assumes a smooth wire numbering, and that the line seg is contained in a tpc.
279  // Meant for use with the approximate line calculated
280  // by matching cluster endpoints in disambiguation.
281 
282  // Find tpc, use midpoint in case start/end is on a boundary
283  geo::Point_t const xyzMid{
284  (xyzStart[0] + xyzEnd[0]) / 2, (xyzStart[1] + xyzEnd[1]) / 2, (xyzStart[2] + xyzEnd[2]) / 2};
285  auto const& tpcid = fGeom->PositionToTPCID(xyzMid);
286 
287  // Find the nearest wire number to the line segment endpoints
288  std::vector<geo::WireID> wids = fGeom->ChannelToWire(chan);
289  geo::PlaneID const planeID{tpcid, wids[0].Plane};
290  using geo::vect::toPoint;
291  unsigned int startW = fGeom->NearestWireID(toPoint(xyzStart), planeID).Wire;
292  unsigned int endW = fGeom->NearestWireID(toPoint(xyzEnd), planeID).Wire;
293 
294  if (startW > endW) std::swap(startW, endW);
295 
296  // Loop through wireIDs and check for intersection, if in the right TPC
297  for (size_t w = 0; w < wids.size(); w++) {
298  if (wids[w].TPC != tpcid.TPC) continue;
299  if (wids[w].Cryostat != tpcid.Cryostat)
300  throw cet::exception("LineSegChanIntersect")
301  << "Channel and line not in the same crostat.\n";
302 
303  // If the current wire id wire number is inbetween the start/end
304  // point wires, the line segment intersects the wireID at some point.
305 
306  // TODO: for now, extend range, but that is application specific. fix asap
307  // The longer we make the range, the more conservative it is, so it is safe
308  // to extend the range a bit to get hits at the ends of the line
309  unsigned int ext = 0;
310  if (ExtendLine) ext = 10;
311 
312  if (lar::util::ValueInRange(wids[w].Wire * 1., (startW - ext) * 1., (endW + ext) * 1.))
313  widsCrossed.push_back(wids[w]);
314  }
315 
316  return widsCrossed.size() > 0;
317  }
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
bool ValueInRange(double value, double min, double max)
Returns whether a value is within the specified range.
Definition: NumericUtils.cxx:7
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
art::ServiceHandle< geo::Geometry const > fGeom
WireID NearestWireID(Point_t const &point, PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
Float_t w
Definition: plot.C:20
TPCID PositionToTPCID(Point_t const &point) const
Returns the ID of the TPC at specified location.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
geo::WireID apa::APAGeometryAlg::NearestWireIDOnChan ( const double  WorldLoc[3],
uint32_t  chan,
unsigned int const  plane,
unsigned int const  tpc = 0,
unsigned int const  cstat = 0 
) const

Definition at line 236 of file APAGeometryAlg.cxx.

References util::abs(), geo::GeometryCore::ChannelToWire(), fChannelRange, fGeom, geo::kZ, geo::GeometryCore::NearestWireID(), and geo::GeometryCore::View().

Referenced by ThreeChanPos(), and apa::DisambigAlg::UseEndPts().

241  {
242 
243  std::vector<geo::WireID> cWids = fGeom->ChannelToWire(chan);
244 
245  if (cWids[0].Cryostat != cstat)
246  throw cet::exception("APAGeometryAlg")
247  << "Channel " << chan << "not in cryostat " << cstat << "\n";
248  if (std::floor(cWids[0].TPC / 2) != std::floor(tpc / 2))
249  throw cet::exception("APAGeometryAlg")
250  << "Channel " << chan << "not in APA " << std::floor(tpc / 2) << "\n";
251 
252  // special case for vertical wires
253  if (fGeom->View(chan) == geo::kZ) return fGeom->ChannelToWire(chan)[0];
254 
255  unsigned int xyzWire = fGeom
256  ->NearestWireID(geo::Point_t{WorldLoc[0], WorldLoc[1], WorldLoc[2]},
257  geo::PlaneID{cstat, tpc, plane})
258  .Wire;
259 
260  // The desired wire ID will be the only channel
261  // segment within half the channel range.
262  geo::WireID wid;
263  for (size_t i = 0; i < cWids.size(); i++) {
264  if (cWids[i].TPC != tpc) continue;
265  if (std::abs((int)cWids[i].Wire - (int)xyzWire) < fChannelRange[plane] / 2) wid = cWids[i];
266  }
267 
268  return wid;
269  }
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
constexpr auto abs(T v)
Returns the absolute value of the argument.
Planes which measure Z direction.
Definition: geo_types.h:138
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
art::ServiceHandle< geo::Geometry const > fGeom
WireID NearestWireID(Point_t const &point, PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
View_t View(PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void apa::APAGeometryAlg::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 42 of file APAGeometryAlg.cxx.

Referenced by APAGeometryAlg().

42 {}
std::vector< double > apa::APAGeometryAlg::ThreeChanPos ( uint32_t  u,
uint32_t  v,
uint32_t  z 
) const

Find the center of the 3 intersections, choose best if multiple.

Definition at line 320 of file APAGeometryAlg.cxx.

References util::abs(), APAChannelsIntersect(), geo::GeometryCore::ChannelToWire(), fGeom, geo::WireGeo::GetCenter(), geo::TPCGeo::Length(), NearestWireIDOnChan(), geo::GeometryCore::TPC(), geo::GeometryCore::WireIDsIntersect(), geo::GeometryCore::WireIDToWireGeo(), geo::WireIDIntersection::y, and geo::WireIDIntersection::z.

Referenced by apa::DisambigAlg::UseEndPts().

321  {
322 
323  // Say we've associated a U, V, and Z channel -- perhaps by associating hits
324  // or cluster endpoints -- these don't necessarily all intersect, but they
325  // are hopefully pretty close. Find the center of the 3 intersections.
326 
327  // get data needed along the way
328  std::vector<geo::WireIDIntersection> UVIntersects;
329  this->APAChannelsIntersect(u, v, UVIntersects);
330  std::vector<double> UVzToZ(UVIntersects.size());
331  geo::WireID Zwid = fGeom->ChannelToWire(z)[0];
332  unsigned int cryo = Zwid.Cryostat;
333  unsigned int tpc = Zwid.TPC;
334  std::vector<geo::WireID> Uwids = fGeom->ChannelToWire(u);
335  std::vector<geo::WireID> Vwids = fGeom->ChannelToWire(v);
336  std::vector<geo::WireID> UwidsInTPC, VwidsInTPC;
337  for (size_t i = 0; i < Uwids.size(); i++)
338  if (Uwids[i].TPC == tpc) UwidsInTPC.push_back(Uwids[i]);
339  for (size_t i = 0; i < Vwids.size(); i++)
340  if (Vwids[i].TPC == tpc) VwidsInTPC.push_back(Vwids[i]);
341  auto const Zcent = fGeom->WireIDToWireGeo(Zwid).GetCenter();
342 
343  std::cout << "Zcent = " << Zcent.Z() << ", UVintersects zpos = ";
344  for (size_t uv = 0; uv < UVIntersects.size(); uv++) {
345  std::cout << UVIntersects[uv].z << ", ";
346  }
347  std::cout << "\n";
348 
351 
352  //std::cout << "U = " << u << " V = " << v << ", " << UVIntersects.size() << std::endl;
353 
354  if (UVIntersects.size() == 0) {
355  if (UwidsInTPC.size() > 1 || VwidsInTPC.size() > 1)
356  throw cet::exception("ThreeChanPos") << "U/V channels don't intersect, bad return.\n";
357 
358  // Now assume there are only one of each u and v wireIDs on in this TPC
359  mf::LogWarning("ThreeChanPos")
360  << "No U/V intersect, exceptional channels. See if U or V intersects Z\n";
361  std::vector<double> yzCenter(2, 0.);
362  geo::WireID Uwid = UwidsInTPC[0];
363  geo::WireID Vwid = VwidsInTPC[0];
364  geo::WireIDIntersection UZInt, VZInt;
365  bool checkUZ = fGeom->WireIDsIntersect(Uwid, Zwid, UZInt);
366  bool checkVZ = fGeom->WireIDsIntersect(Vwid, Zwid, VZInt);
367  if (!checkUZ && !checkVZ)
368  throw cet::exception("NoChanIntersect") << "No channels intersect, bad return.\n";
369  if (checkUZ && !checkVZ) {
370  yzCenter[0] = UZInt.y;
371  yzCenter[1] = UZInt.z;
372  }
373  if (checkVZ && !checkUZ) {
374  yzCenter[0] = VZInt.y;
375  yzCenter[1] = VZInt.z;
376  }
377  if (checkUZ && checkVZ) {
378  yzCenter[0] = (VZInt.y + UZInt.y) / 2;
379  yzCenter[1] = (VZInt.z + UZInt.z) / 2;
380  }
381  return yzCenter;
382  }
383 
386 
387  // In case the uv channels intersect twice on the same side, choose the best case.
388  // Note: this will not happen for APAs with UV angle at about 36, but will for 45
389  std::cout << "UVzToZ = ";
390  for (size_t widI = 0; widI < UVIntersects.size(); widI++) {
391  UVzToZ[widI] = std::abs(UVIntersects[widI].z - Zcent.Z());
392  std::cout << UVzToZ[widI] << ", ";
393  }
394  std::cout << "\n";
395 
396  unsigned int bestWidI = 0;
397  double minZdiff = fGeom->TPC(Zwid).Length(); // start it out at maximum z
398  for (unsigned int widI = 0; widI < UVIntersects.size(); widI++) {
399 
400  //std::cout << "widI = " << widI << std::endl;
401 
402  if (UVIntersects[widI].TPC == tpc && UVzToZ[widI] < minZdiff) {
403  minZdiff = UVzToZ[widI];
404  bestWidI = widI;
405  //std::cout << "bestWidI = " << bestWidI << std::endl;
406  }
407  }
408  geo::WireIDIntersection ChosenUVInt = UVIntersects[bestWidI];
409 
410  // Now having the UV intersection, get the UZ and VZ
411  double UVInt[3] = {0.};
412  UVInt[1] = ChosenUVInt.y;
413  UVInt[2] = ChosenUVInt.z;
414  geo::WireID Uwid = this->NearestWireIDOnChan(UVInt, u, 0, tpc, cryo);
415  geo::WireID Vwid = this->NearestWireIDOnChan(UVInt, v, 1, tpc, cryo);
416  geo::WireIDIntersection UZInt, VZInt;
417  bool checkUZ = fGeom->WireIDsIntersect(Uwid, Zwid, UZInt);
418  bool checkVZ = fGeom->WireIDsIntersect(Vwid, Zwid, VZInt);
419 
420  std::cout << "UZint.z = " << UZInt.z << " (" << checkUZ << "), VZint.z = " << VZInt.z << " ("
421  << checkVZ << ")\n";
422 
423  // find the center
424  std::vector<double> yzCenter(2, 0.);
425 
426  if (!checkUZ || !checkVZ) {
427  //throw cet::exception("ThreeChanPos") << "WireIDs were expected to intersect.\n";
428 
429  std::cout << "ChosenUVint.y = " << ChosenUVInt.y << "ChosenUVint.z = " << ChosenUVInt.z
430  << std::endl;
431 
432  //temporary case
433  yzCenter[0] = ChosenUVInt.y;
434  yzCenter[1] = ChosenUVInt.z;
435  }
436  else {
437 
438  yzCenter[0] = (ChosenUVInt.y + UZInt.y + VZInt.y) / 3;
439  yzCenter[1] = (ChosenUVInt.z + UZInt.z + VZInt.z) / 3;
440  }
441 
442  return yzCenter;
443  }
Point_t const & GetCenter() const
Returns the world coordinate of the center of the wire [cm].
Definition: WireGeo.h:221
double z
z position of intersection
Definition: geo_types.h:792
WireGeo const & WireIDToWireGeo(WireID const &wireid) const
Returns the specified wire.
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
Double_t z
Definition: plot.C:276
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, Point_t &intersection) const
Computes the intersection between two wires.
constexpr auto abs(T v)
Returns the absolute value of the argument.
bool APAChannelsIntersect(uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector) const
If the channels intersect, get all intersections.
double Length() const
Length is associated with z coordinate [cm].
Definition: TPCGeo.h:104
TPCGeo const & TPC(TPCID const &tpcid=tpc_zero) const
Returns the specified TPC.
Definition: GeometryCore.h:722
art::ServiceHandle< geo::Geometry const > fGeom
geo::WireID NearestWireIDOnChan(const double WorldLoc[3], uint32_t chan, unsigned int const plane, unsigned int const tpc=0, unsigned int const cstat=0) const
double y
y position of intersection
Definition: geo_types.h:791
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

unsigned int apa::APAGeometryAlg::fAPAsPerCryo
private

Definition at line 82 of file APAGeometryAlg.h.

Referenced by ChannelToAPA(), FirstChannelInView(), and Init().

double apa::APAGeometryAlg::fChannelRange[2]
private

Definition at line 94 of file APAGeometryAlg.h.

Referenced by Init(), and NearestWireIDOnChan().

unsigned int apa::APAGeometryAlg::fChannelsPerAPA
private

All APAs have this same number of channels.

Definition at line 81 of file APAGeometryAlg.h.

Referenced by APAView(), ChannelToAPA(), FirstChannelInView(), and Init().

uint32_t apa::APAGeometryAlg::fFirstU
private

Definition at line 85 of file APAGeometryAlg.h.

Referenced by ChannelsInAPAView(), FirstChannelInView(), and Init().

uint32_t apa::APAGeometryAlg::fFirstV
private

Definition at line 87 of file APAGeometryAlg.h.

Referenced by ChannelsInAPAView(), FirstChannelInView(), and Init().

uint32_t apa::APAGeometryAlg::fFirstZ0
private

Definition at line 89 of file APAGeometryAlg.h.

Referenced by ChannelsInAPAView(), FirstChannelInView(), and Init().

uint32_t apa::APAGeometryAlg::fFirstZ1
private

Definition at line 91 of file APAGeometryAlg.h.

Referenced by APAView(), ChannelsInAPAView(), and Init().

uint32_t apa::APAGeometryAlg::fLastU
private

Definition at line 86 of file APAGeometryAlg.h.

Referenced by Init().

uint32_t apa::APAGeometryAlg::fLastV
private

Definition at line 88 of file APAGeometryAlg.h.

Referenced by APAView(), and Init().

uint32_t apa::APAGeometryAlg::fLastZ0
private

Definition at line 90 of file APAGeometryAlg.h.

Referenced by APAView(), and Init().

uint32_t apa::APAGeometryAlg::fLastZ1
private

Definition at line 92 of file APAGeometryAlg.h.

Referenced by ChannelsInAPAView(), and Init().


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