82 if (wid.
TPC == lastwid.
TPC + 1) {
96 throw cet::exception(
"APAGeometryAlg") <<
"Channel boundaries are inconsistent.\n";
138 <<
"Both Z sides should have the same amount of channels\n";
158 unsigned int cryo)
const 176 unsigned int apa, cryo;
185 unsigned int apa, cryo;
222 unsigned int side)
const 227 std::vector<geo::WireID> thisSide;
229 for (
size_t i = 0; i < wids.size(); i++)
230 if (wids[i].TPC % 2 == side) thisSide.push_back(wids[i]);
238 unsigned int const plane,
239 unsigned int const tpc,
240 unsigned int const cstat)
const 245 if (cWids[0].Cryostat != cstat)
247 <<
"Channel " << chan <<
"not in cryostat " << cstat <<
"\n";
248 if (std::floor(cWids[0].TPC / 2) != std::floor(tpc / 2))
250 <<
"Channel " << chan <<
"not in APA " << std::floor(tpc / 2) <<
"\n";
255 unsigned int xyzWire =
fGeom 263 for (
size_t i = 0; i < cWids.size(); i++) {
264 if (cWids[i].TPC != tpc)
continue;
275 std::vector<geo::WireID>& widsCrossed,
276 bool ExtendLine =
true)
const 284 (xyzStart[0] + xyzEnd[0]) / 2, (xyzStart[1] + xyzEnd[1]) / 2, (xyzStart[2] + xyzEnd[2]) / 2};
294 if (startW > endW) std::swap(startW, endW);
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)
301 <<
"Channel and line not in the same crostat.\n";
309 unsigned int ext = 0;
310 if (ExtendLine) ext = 10;
313 widsCrossed.push_back(wids[
w]);
316 return widsCrossed.size() > 0;
328 std::vector<geo::WireIDIntersection> UVIntersects;
330 std::vector<double> UVzToZ(UVIntersects.size());
332 unsigned int cryo = Zwid.Cryostat;
333 unsigned int tpc = Zwid.TPC;
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]);
343 std::cout <<
"Zcent = " << Zcent.Z() <<
", UVintersects zpos = ";
344 for (
size_t uv = 0; uv < UVIntersects.size(); uv++) {
345 std::cout << UVIntersects[uv].z <<
", ";
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";
360 <<
"No U/V intersect, exceptional channels. See if U or V intersects Z\n";
361 std::vector<double> yzCenter(2, 0.);
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;
373 if (checkVZ && !checkUZ) {
374 yzCenter[0] = VZInt.
y;
375 yzCenter[1] = VZInt.
z;
377 if (checkUZ && checkVZ) {
378 yzCenter[0] = (VZInt.
y + UZInt.
y) / 2;
379 yzCenter[1] = (VZInt.
z + UZInt.
z) / 2;
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] <<
", ";
396 unsigned int bestWidI = 0;
398 for (
unsigned int widI = 0; widI < UVIntersects.size(); widI++) {
402 if (UVIntersects[widI].TPC == tpc && UVzToZ[widI] < minZdiff) {
403 minZdiff = UVzToZ[widI];
411 double UVInt[3] = {0.};
412 UVInt[1] = ChosenUVInt.
y;
413 UVInt[2] = ChosenUVInt.
z;
420 std::cout <<
"UZint.z = " << UZInt.
z <<
" (" << checkUZ <<
"), VZint.z = " << VZInt.
z <<
" (" 424 std::vector<double> yzCenter(2, 0.);
426 if (!checkUZ || !checkVZ) {
429 std::cout <<
"ChosenUVint.y = " << ChosenUVInt.
y <<
"ChosenUVint.z = " << ChosenUVInt.
z 433 yzCenter[0] = ChosenUVInt.
y;
434 yzCenter[1] = ChosenUVInt.
z;
438 yzCenter[0] = (ChosenUVInt.
y + UZInt.
y + VZInt.
y) / 3;
439 yzCenter[1] = (ChosenUVInt.
z + UZInt.
z + VZInt.
z) / 3;
449 std::vector<geo::WireIDIntersection>& IntersectVector)
const 458 if (view1 == view2) {
460 <<
"Comparing two channels in the same view, return false";
463 if (wids1[0].Cryostat != wids2[0].Cryostat ||
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";
475 for (
unsigned int i1 = 0; i1 < wids1.size(); i1++) {
476 for (
unsigned int i2 = 0; i2 < wids2.size(); i2++) {
480 wids1[i1].TPC != wids2[i2].TPC ||
481 wids1[i1].Cryostat != wids2[i2].Cryostat)
496 IntersectVector.push_back(widIntersect);
503 if (IntersectVector.size() > 4) {
505 <<
"Got " << IntersectVector.size() <<
" intersections for channels " << chan1 <<
" and " 506 << chan2 <<
" - never expect more than 4, so far";
513 std::sort(IntersectVector.begin(), IntersectVector.end());
516 if (IntersectVector.size() == 0)
unsigned int NTPC(CryostatID const &cryoid=cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
Point_t const & GetCenter() const
Returns the world coordinate of the center of the wire [cm].
double z
z position of intersection
Functions to help with numbers.
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.
Encapsulate the construction of a single cyostat.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
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.
void Init()
Initialize some chanel numbers to speed up other methods.
The data type to uniquely identify a Plane.
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, Point_t &intersection) const
Computes the intersection between two wires.
unsigned int ChannelsInAPAView(APAView_t apaview) const
uint32_t FirstChannelInView(geo::View_t geoview, unsigned int apa, unsigned int cryo) const
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
constexpr auto abs(T v)
Returns the absolute value of the argument.
Planes which measure Z direction.
U view on both sides of the APA.
WireID_t Wire
Index of the wire within its plane.
unsigned int fAPAsPerCryo
V view on both sides of the APA.
bool APAChannelsIntersect(uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector) const
If the channels intersect, get all intersections.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
double Length() const
Length is associated with z coordinate [cm].
TPCGeo const & TPC(TPCID const &tpcid=tpc_zero) const
Returns the specified TPC.
Z view on the larger-x side of the APA.
enum apa::_apa_plane_proj APAView_t
APAView_t APAView(uint32_t chan) const
Get which of the 4 APA views the channel is in.
unsigned int ChannelToAPA(uint32_t chan) const
Get number of the APA containing the given channel.
unsigned int ChannelsInView(geo::View_t geoview) const
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
Definition of data types for geometry description.
Z view on the smaller-x side of the APA.
Encapsulate the geometry of a wire.
bool ValueInRange(double value, double min, double max)
Returns whether a value is within the specified range.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
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.
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
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
std::vector< geo::WireID > ChanSegsPerSide(uint32_t chan, unsigned int side) const
void reconfigure(fhicl::ParameterSet const &p)
TPCID_t TPC
Index of the TPC within its cryostat.
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.
recob::tracking::Plane Plane
Length_t WirePitch(PlaneID const &planeid=plane_zero) const
Returns the distance between two consecutive wires.
TPCID PositionToTPCID(Point_t const &point) const
Returns the ID of the TPC at specified location.
cet::coded_exception< error, detail::translate > exception
Encapsulate the construction of a single detector plane.