64 if (wid.
TPC == lastwid.
TPC + 1) {
78 throw cet::exception(
"APAGeometryAlg") <<
"Channel boundaries are inconsistent.\n";
119 <<
"Both Z sides should have the same amount of channels\n";
138 unsigned int cryo)
const 154 unsigned int apa, cryo;
162 unsigned int apa, cryo;
197 unsigned int side)
const 202 std::vector<geo::WireID> thisSide;
204 for (
size_t i = 0; i < wids.size(); i++)
205 if (wids[i].TPC % 2 == side) thisSide.push_back(wids[i]);
217 if (cWids[0].Cryostat != planeID.
Cryostat)
219 <<
"Channel " << chan <<
"not in cryostat " << planeID.
Cryostat <<
"\n";
221 if (std::floor(cWids[0].TPC / 2) != std::floor(planeID.
TPC / 2))
223 <<
"Channel " << chan <<
"not in APA " << std::floor(planeID.
TPC / 2) <<
"\n";
234 for (
size_t i = 0; i < cWids.size(); i++) {
235 if (cWids[i].TPC != planeID.
TPC)
continue;
247 std::vector<geo::WireID>& widsCrossed,
248 bool ExtendLine =
true)
const 263 unsigned int endW = plane.NearestWireID(xyzEnd).Wire;
265 if (startW > endW) std::swap(startW, endW);
268 for (
size_t w = 0;
w < wids.size();
w++) {
269 if (wids[
w].TPC != tpcid.TPC)
continue;
270 if (wids[
w].Cryostat != tpcid.Cryostat)
272 <<
"Channel and line not in the same crostat.\n";
280 unsigned int ext = 0;
281 if (ExtendLine) ext = 10;
284 widsCrossed.push_back(wids[
w]);
287 return not widsCrossed.empty();
298 std::vector<geo::WireIDIntersection> UVIntersects;
300 std::vector<double> UVzToZ(UVIntersects.size());
302 unsigned int cryo = Zwid.Cryostat;
303 unsigned int tpc = Zwid.TPC;
306 std::vector<geo::WireID> UwidsInTPC, VwidsInTPC;
307 for (
size_t i = 0; i < Uwids.size(); i++)
308 if (Uwids[i].TPC == tpc) UwidsInTPC.push_back(Uwids[i]);
309 for (
size_t i = 0; i < Vwids.size(); i++)
310 if (Vwids[i].TPC == tpc) VwidsInTPC.push_back(Vwids[i]);
313 std::cout <<
"Zcent = " << Zcent.Z() <<
", UVintersects zpos = ";
314 for (
size_t uv = 0; uv < UVIntersects.size(); uv++) {
315 std::cout << UVIntersects[uv].z <<
", ";
322 if (UVIntersects.empty()) {
323 if (UwidsInTPC.size() > 1 || VwidsInTPC.size() > 1)
324 throw cet::exception(
"ThreeChanPos") <<
"U/V channels don't intersect, bad return.\n";
328 <<
"No U/V intersect, exceptional channels. See if U or V intersects Z\n";
329 std::vector<double> yzCenter(2, 0.);
334 if (!UZInt && !VZInt)
335 throw cet::exception(
"NoChanIntersect") <<
"No channels intersect, bad return.\n";
336 if (UZInt && !VZInt) {
337 yzCenter[0] = UZInt->y;
338 yzCenter[1] = UZInt->z;
340 if (VZInt && !UZInt) {
341 yzCenter[0] = VZInt->y;
342 yzCenter[1] = VZInt->z;
344 if (UZInt && VZInt) {
345 yzCenter[0] = (VZInt->y + UZInt->y) / 2;
346 yzCenter[1] = (VZInt->z + UZInt->z) / 2;
356 std::cout <<
"UVzToZ = ";
357 for (
size_t widI = 0; widI < UVIntersects.size(); widI++) {
358 UVzToZ[widI] =
std::abs(UVIntersects[widI].z - Zcent.Z());
359 std::cout << UVzToZ[widI] <<
", ";
363 unsigned int bestWidI = 0;
365 for (
unsigned int widI = 0; widI < UVIntersects.size(); widI++) {
366 if (UVIntersects[widI].TPC == tpc && UVzToZ[widI] < minZdiff) {
367 minZdiff = UVzToZ[widI];
381 std::vector<double> yzCenter(2, 0.);
383 std::cout <<
"UZint = " << std::boolalpha << static_cast<bool>(UZInt)
384 <<
", VZint = " << static_cast<bool>(VZInt) <<
'\n';
385 if (!UZInt || !VZInt) {
386 std::cout <<
"ChosenUVint.y = " << ChosenUVInt.
y <<
"ChosenUVint.z = " << ChosenUVInt.
z 390 yzCenter[0] = ChosenUVInt.
y;
391 yzCenter[1] = ChosenUVInt.
z;
394 std::cout <<
"UZint.z = " << UZInt->z <<
", VZint.z = " << VZInt->z <<
'\n';
395 yzCenter[0] = (ChosenUVInt.
y + UZInt->y + VZInt->y) / 3;
396 yzCenter[1] = (ChosenUVInt.
z + UZInt->z + VZInt->z) / 3;
406 std::vector<geo::WireIDIntersection>& IntersectVector)
const 413 if (view1 == view2) {
415 <<
"Comparing two channels in the same view, return false";
420 <<
"Comparing two channels in in different APAs: " 421 <<
"channel " << chan1 <<
" in Cryo " << wids1[0].Cryostat <<
", APA " 422 <<
ChannelToAPA(chan1) <<
", and channel " << chan2 <<
" in Cryo " << wids2[0].Cryostat
429 for (
unsigned int i1 = 0; i1 < wids1.size(); i1++) {
430 for (
unsigned int i2 = 0; i2 < wids2.size(); i2++) {
434 wids1[i1].TPC != wids2[i2].TPC ||
435 wids1[i1].Cryostat != wids2[i2].Cryostat)
440 IntersectVector.push_back(*widIntersect);
447 if (IntersectVector.size() > 4) {
449 <<
"Got " << IntersectVector.size() <<
" intersections for channels " << chan1 <<
" and " 450 << chan2 <<
" - never expect more than 4, so far";
456 std::sort(IntersectVector.begin(), IntersectVector.end());
459 return not IntersectVector.empty();
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.
Encapsulate the construction of a single cyostat .
Z view on the larger-x side of the APA.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
WireID NearestWireID(Point_t const &pos) const
Returns the ID of wire closest to the specified position.
unsigned int NTPC(CryostatID const &cryoid=details::cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
virtual unsigned int Nchannels() const =0
Returns the total number of channels present (not necessarily contiguous)
Z view on the smaller-x side of the APA.
The data type to uniquely identify a Plane.
unsigned int ChannelsInAPAView(APAView_t apaview) const
uint32_t FirstChannelInView(geo::View_t geoview, unsigned int apa, unsigned int cryo) const
constexpr auto abs(T v)
Returns the absolute value of the argument.
CryostatID_t Cryostat
Index of cryostat.
Planes which measure Z direction.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
WireID_t Wire
Index of the wire within its plane.
unsigned int fAPAsPerCryo
bool APAChannelsIntersect(uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector) const
If the channels intersect, get all intersections.
WireGeo const & Wire(WireID const &wireid) const
Returns the specified wire.
double Length() const
Length is associated with z coordinate [cm].
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.
Point_t middlePoint(BeginIter begin, EndIter end)
Returns the middle of the specified points.
bool LineSegChanIntersect(geo::Point_t const &xyzStart, geo::Point_t const &xyzEnd, uint32_t chan, std::vector< geo::WireID > &widsCrossed, bool ExtendLine) const
If a line given by start/end points intersects a channel.
unsigned int ChannelsInView(geo::View_t geoview) const
U view on both sides of the APA.
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
Definition of data types for geometry description.
V view on both sides of the APA.
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, Point_t &intersection) const
Computes the intersection between two wires.
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
virtual std::vector< WireID > ChannelToWire(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.
geo::WireID NearestWireIDOnChan(geo::Point_t const &WorldLoc, uint32_t chan, geo::PlaneID const &planeID) const
double y
y position of intersection
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< geo::WireID > ChanSegsPerSide(uint32_t chan, unsigned int side) const
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
TPCID_t TPC
Index of the TPC within its cryostat.
TPCGeo const & TPC(TPCID const &tpcid=details::tpc_zero) const
Returns the specified TPC.
geo::WireReadoutGeom const * fWireReadoutGeom
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
TPCID PositionToTPCID(Point_t const &point) const
Returns the ID of the TPC at specified location.
Interface to geometry for wire readouts .
cet::coded_exception< error, detail::translate > exception
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Encapsulate the construction of a single detector plane .