88 if( wid.
TPC == lastwid.
TPC + 1 ){
102 <<
"Channel boundaries are inconsistent.\n";
115 unsigned int & cryo){
149 <<
"Both Z sides should have the same amount of channels\n";
198 unsigned int apa, cryo;
208 unsigned int apa, cryo;
258 std::vector<geo::WireID> thisSide;
260 for(
size_t i = 0; i < wids.size(); i++)
261 if( wids[i].TPC % 2 == side ) thisSide.push_back(wids[i]);
272 unsigned int const plane,
273 unsigned int const tpc,
274 unsigned int const cstat )
279 if( cWids[0].Cryostat != cstat )
281 <<
"not in cryostat " << cstat <<
"\n";
282 if( std::floor( cWids[0].TPC / 2 ) != std::floor( tpc / 2 ) )
284 <<
"not in APA " << std::floor(tpc/2) <<
"\n";
294 for(
size_t i=0; i<cWids.size(); i++){
295 if( cWids[i].TPC != tpc )
continue;
296 if( std::abs((
int)cWids[i].Wire - (
int)xyzWire) <
fChannelRange[plane]/2 ) wid=cWids[i];
306 std::vector<geo::WireID> & widsCrossed,
307 bool ExtendLine =
true )
315 unsigned int tpc, cryo;
317 xyzMid[0] = (xyzStart[0]+xyzEnd[0])/2;
318 xyzMid[1] = (xyzStart[1]+xyzEnd[1])/2;
319 xyzMid[2] = (xyzStart[2]+xyzEnd[2])/2;
327 if( startW > endW ) std::swap(startW, endW);
331 for(
size_t w = 0;
w < wids.size();
w++ ){
332 if( wids[
w].TPC != tpc )
continue;
333 if( wids[
w].Cryostat != cryo )
throw cet::exception(
"LineSegChanIntersect")
334 <<
"Channel and line not in the same crostat.\n";
342 unsigned int ext = 0;
343 if ( ExtendLine) ext = 10;
345 if(
fGeom->
ValueInRange( wids[
w].Wire*1., (startW-ext)*1., (endW+ext)*1. ) ) widsCrossed.push_back(wids[
w]);
349 if( widsCrossed.size() > 0 )
return true;
365 std::vector< geo::WireIDIntersection > UVIntersects;
367 std::vector< double > UVzToZ(UVIntersects.size());
369 unsigned int cryo = Zwid.Cryostat;
370 unsigned int tpc = Zwid.TPC;
373 std::vector<geo::WireID> UwidsInTPC, VwidsInTPC;
374 for(
size_t i=0; i<Uwids.size(); i++)
if( Uwids[i].TPC==tpc ) UwidsInTPC.push_back(Uwids[i]);
375 for(
size_t i=0; i<Vwids.size(); i++)
if( Vwids[i].TPC==tpc ) VwidsInTPC.push_back(Vwids[i]);
376 double Zcent[3] = {0.};
379 std::cout <<
"Zcent = " << Zcent[2] <<
", UVintersects zpos = ";
380 for(
size_t uv=0; uv<UVIntersects.size(); uv++){
381 std::cout << UVIntersects[uv].z <<
", ";
390 if( UVIntersects.size() == 0 ){
391 if( UwidsInTPC.size() > 1 || VwidsInTPC.size() > 1 )
392 throw cet::exception(
"ThreeChanPos") <<
"U/V channels don't intersect, bad return.\n";
395 mf::LogWarning(
"ThreeChanPos") <<
"No U/V intersect, exceptional channels. See if U or V intersects Z\n";
396 std::vector<double> yzCenter(2,0.);
402 if( !checkUZ && !checkVZ )
403 throw cet::exception(
"NoChanIntersect") <<
"No channels intersect, bad return.\n";
404 if( checkUZ && !checkVZ ){ yzCenter[0] = UZInt.
y; yzCenter[1] = UZInt.
z; }
405 if( checkVZ && !checkUZ ){ yzCenter[0] = VZInt.
y; yzCenter[1] = VZInt.
z; }
406 if( checkUZ && checkVZ ){ yzCenter[0] = (VZInt.
y+UZInt.
y)/2; yzCenter[1] = (VZInt.
z+UZInt.
z)/2; }
416 std::cout <<
"UVzToZ = ";
417 for(
size_t widI = 0; widI < UVIntersects.size(); widI++ ){
418 UVzToZ[widI] = std::abs( UVIntersects[widI].z - Zcent[2] );
419 std::cout << UVzToZ[widI] <<
", ";
423 unsigned int bestWidI = 0;
425 for(
unsigned int widI = 0; widI < UVIntersects.size(); widI++ ){
429 if( UVIntersects[widI].TPC == tpc && UVzToZ[widI] < minZdiff ){
430 minZdiff = UVzToZ[widI];
438 double UVInt[3] = {0.};
439 UVInt[1] = ChosenUVInt.
y; UVInt[2] = ChosenUVInt.
z;
446 std::cout <<
"UZint.z = " << UZInt.
z <<
" (" << checkUZ <<
"), VZint.z = " << VZInt.
z <<
" (" << checkVZ <<
")\n";
449 std::vector<double> yzCenter(2,0.);
452 if( !checkUZ || !checkVZ ){
455 std::cout <<
"ChosenUVint.y = " << ChosenUVInt.
y <<
"ChosenUVint.z = " << ChosenUVInt.
z << std::endl;
458 yzCenter[0] = ChosenUVInt.
y;
459 yzCenter[1] = ChosenUVInt.
z;
464 yzCenter[0] = (ChosenUVInt.
y + UZInt.
y + VZInt.
y)/3;
465 yzCenter[1] = (ChosenUVInt.
z + UZInt.
z + VZInt.
z)/3;
479 std::vector< geo::WireIDIntersection >& IntersectVector )
489 if( view1 == view2 ){
490 mf::LogWarning(
"APAChannelsIntersect") <<
"Comparing two channels in the same view, return false";
492 if( wids1[0].Cryostat != wids2[0].Cryostat ||
494 throw cet::exception(
"APAChannelsIntersect") <<
"Comparing two channels in in different APAs: " 495 <<
"channel " << chan1 <<
" in Cryo " 496 << wids1[0].Cryostat <<
", APA " << this->
ChannelToAPA(chan1)
497 <<
", and channel " << chan2 <<
" in Cryo " 498 << wids2[0].Cryostat <<
", APA " << this->
ChannelToAPA(chan2)
505 for(
unsigned int i1 = 0; i1 < wids1.size() ; i1++){
506 for(
unsigned int i2 = 0; i2 < wids2.size() ; i2++){
510 wids1[i1].TPC != wids2[i2].TPC ||
511 wids1[i1].Cryostat != wids2[i2].Cryostat )
continue;
525 IntersectVector.push_back( widIntersect );
532 if( IntersectVector.size() > 4 ){
533 mf::LogWarning(
"APAChannelsIntersect") <<
"Got " << IntersectVector.size()
534 <<
" intersections for channels " 535 << chan1 <<
" and " << chan2
536 <<
" - never expect more than 4, so far"; }
543 std::sort( IntersectVector.begin(), IntersectVector.end() );
546 if( IntersectVector.size() == 0 )
return false;
bool APAChannelsIntersect(uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector)
If the channels intersect, get all intersections.
double z
z position of intersection
Encapsulate the construction of a single cyostat.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
void Init()
Initialize some chanel numbers to speed up other methods.
unsigned int ChannelToAPA(uint32_t chan)
Get number of the APA containing the given channel.
Declaration of signal hit object.
art::ServiceHandle< geo::Geometry > fGeom
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
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.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
double Length() const
Length is associated with z coordinate [cm].
geo::TPCGeo const & PositionToTPC(geo::Point_t const &point) const
Returns the TPC at specified location.
Z view on the larger-x side of the APA.
enum apa::_apa_plane_proj APAView_t
virtual ~APAGeometryAlg()
bool LineSegChanIntersect(TVector3 xyzStart, TVector3 xyzEnd, uint32_t chan, std::vector< geo::WireID > &widsCrossed, bool ExtendLine)
If a line given by start/end points intersects a channel.
uint32_t FirstChannelInView(geo::View_t geoview, unsigned int apa, unsigned int cryo)
APAView_t APAView(uint32_t chan)
Get which of the 4 APA views the channel is in.
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
std::vector< double > ThreeChanPos(uint32_t u, uint32_t v, uint32_t z)
Find the center of the 3 intersections, choose best if multiple.
std::vector< geo::WireID > ChanSegsPerSide(uint32_t chan, unsigned int side)
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Definition of data types for geometry description.
Z view on the smaller-x side of the APA.
unsigned int ChannelsInAPAView(APAView_t apaview)
Encapsulate the geometry of a wire.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, geo::Point_t &intersection) const
Computes the intersection between two wires.
Encapsulate the construction of a single detector plane.
unsigned int ChannelsInView(geo::View_t geoview)
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
double y
y position of intersection
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
geo::WireID NearestWireID(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
Declaration of basic channel signal object.
void reconfigure(fhicl::ParameterSet const &p)
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
bool ValueInRange(double value, double min, double max) const
Returns whether a value is within the specified range.
TPCID_t TPC
Index of the TPC within its cryostat.
recob::tracking::Plane Plane
cet::coded_exception< error, detail::translate > exception
Encapsulate the construction of a single detector plane.
WireGeo const & WireIDToWireGeo(geo::WireID const &wireid) const
Returns the specified wire.
geo::WireID NearestWireIDOnChan(const double WorldLoc[3], uint32_t chan, unsigned int const plane, unsigned int const tpc=0, unsigned int const cstat=0)