86 if( wid.
TPC == lastwid.
TPC + 1 ){
101 <<
"Channel boundaries are inconsistent.\n";
114 unsigned int & cryo)
const {
148 <<
"Both Z sides should have the same amount of channels\n";
176 unsigned int cryo )
const {
197 unsigned int apa, cryo;
205 uint32_t chan )
const {
207 unsigned int apa, cryo;
257 std::vector<geo::WireID> thisSide;
259 for(
size_t i = 0; i < wids.size(); i++)
260 if( wids[i].
TPC % 2 == side ) thisSide.push_back(wids[i]);
271 unsigned int const plane,
272 unsigned int const tpc,
273 unsigned int const cstat )
const 278 if( cWids[0].Cryostat != cstat )
280 <<
"not in cryostat " << cstat <<
"\n";
281 if( std::floor( cWids[0].
TPC / 2 ) != std::floor( tpc / 2 ) )
283 <<
"not in APA " << std::floor(tpc/2) <<
"\n";
293 for(
size_t i=0; i<cWids.size(); i++){
294 if( cWids[i].
TPC != tpc )
continue;
305 std::vector<geo::WireID> & widsCrossed,
306 bool ExtendLine =
true )
const 314 unsigned int tpc, cryo;
316 xyzMid[0] = (xyzStart[0]+xyzEnd[0])/2;
317 xyzMid[1] = (xyzStart[1]+xyzEnd[1])/2;
318 xyzMid[2] = (xyzStart[2]+xyzEnd[2])/2;
326 if( startW > endW )
std::swap(startW, endW);
330 for(
size_t w = 0;
w < wids.size();
w++ ){
331 if( wids[
w].
TPC != tpc )
continue;
332 if( wids[
w].Cryostat != cryo )
throw cet::exception(
"LineSegChanIntersect")
333 <<
"Channel and line not in the same crostat.\n";
341 unsigned int ext = 0;
342 if ( ExtendLine) ext = 10;
344 if(
fGeom->
ValueInRange( wids[
w].Wire*1., (startW-ext)*1., (endW+ext)*1. ) ) widsCrossed.push_back(wids[
w]);
348 if( widsCrossed.size() > 0 )
return true;
364 std::vector< geo::WireIDIntersection > UVIntersects;
366 std::vector< double > UVzToZ(UVIntersects.size());
368 unsigned int cryo = Zwid.Cryostat;
369 unsigned int tpc = Zwid.TPC;
372 std::vector<geo::WireID> UwidsInTPC, VwidsInTPC;
373 for(
size_t i=0; i<Uwids.size(); i++)
if( Uwids[i].
TPC==tpc ) UwidsInTPC.push_back(Uwids[i]);
374 for(
size_t i=0; i<Vwids.size(); i++)
if( Vwids[i].
TPC==tpc ) VwidsInTPC.push_back(Vwids[i]);
375 double Zcent[3] = {0.};
378 std::cout <<
"Zcent = " << Zcent[2] <<
", UVintersects zpos = ";
379 for(
size_t uv=0; uv<UVIntersects.size(); uv++){
380 std::cout << UVIntersects[uv].z <<
", ";
389 if( UVIntersects.size() == 0 ){
390 if( UwidsInTPC.size() > 1 || VwidsInTPC.size() > 1 )
391 throw cet::exception(
"ThreeChanPos") <<
"U/V channels don't intersect, bad return.\n";
394 mf::LogWarning(
"ThreeChanPos") <<
"No U/V intersect, exceptional channels. See if U or V intersects Z\n";
395 std::vector<double> yzCenter(2,0.);
401 if( !checkUZ && !checkVZ )
402 throw cet::exception(
"NoChanIntersect") <<
"No channels intersect, bad return.\n";
403 if( checkUZ && !checkVZ ){ yzCenter[0] = UZInt.
y; yzCenter[1] = UZInt.
z; }
404 if( checkVZ && !checkUZ ){ yzCenter[0] = VZInt.
y; yzCenter[1] = VZInt.
z; }
405 if( checkUZ && checkVZ ){ yzCenter[0] = (VZInt.
y+UZInt.
y)/2; yzCenter[1] = (VZInt.
z+UZInt.
z)/2; }
415 std::cout <<
"UVzToZ = ";
416 for(
size_t widI = 0; widI < UVIntersects.size(); widI++ ){
417 UVzToZ[widI] =
std::abs( UVIntersects[widI].z - Zcent[2] );
418 std::cout << UVzToZ[widI] <<
", ";
422 unsigned int bestWidI = 0;
424 for(
unsigned int widI = 0; widI < UVIntersects.size(); widI++ ){
428 if( UVIntersects[widI].
TPC == tpc && UVzToZ[widI] < minZdiff ){
429 minZdiff = UVzToZ[widI];
437 double UVInt[3] = {0.};
438 UVInt[1] = ChosenUVInt.
y; UVInt[2] = ChosenUVInt.
z;
445 std::cout <<
"UZint.z = " << UZInt.
z <<
" (" << checkUZ <<
"), VZint.z = " << VZInt.
z <<
" (" << checkVZ <<
")\n";
448 std::vector<double> yzCenter(2,0.);
451 if( !checkUZ || !checkVZ ){
454 std::cout <<
"ChosenUVint.y = " << ChosenUVInt.
y <<
"ChosenUVint.z = " << ChosenUVInt.
z <<
std::endl;
457 yzCenter[0] = ChosenUVInt.
y;
458 yzCenter[1] = ChosenUVInt.
z;
463 yzCenter[0] = (ChosenUVInt.
y + UZInt.
y + VZInt.
y)/3;
464 yzCenter[1] = (ChosenUVInt.
z + UZInt.
z + VZInt.
z)/3;
478 std::vector< geo::WireIDIntersection >& IntersectVector )
const 488 if( view1 == view2 ){
489 mf::LogWarning(
"APAChannelsIntersect") <<
"Comparing two channels in the same view, return false";
491 if( wids1[0].Cryostat != wids2[0].Cryostat ||
493 throw cet::exception(
"APAChannelsIntersect") <<
"Comparing two channels in in different APAs: " 494 <<
"channel " << chan1 <<
" in Cryo " 495 << wids1[0].Cryostat <<
", APA " << this->
ChannelToAPA(chan1)
496 <<
", and channel " << chan2 <<
" in Cryo " 497 << wids2[0].Cryostat <<
", APA " << this->
ChannelToAPA(chan2)
504 for(
unsigned int i1 = 0; i1 < wids1.size() ; i1++){
505 for(
unsigned int i2 = 0; i2 < wids2.size() ; i2++){
509 wids1[i1].
TPC != wids2[i2].
TPC ||
510 wids1[i1].Cryostat != wids2[i2].Cryostat )
continue;
524 IntersectVector.push_back( widIntersect );
531 if( IntersectVector.size() > 4 ){
532 mf::LogWarning(
"APAChannelsIntersect") <<
"Got " << IntersectVector.size()
533 <<
" intersections for channels " 534 << chan1 <<
" and " << chan2
535 <<
" - never expect more than 4, so far"; }
542 std::sort( IntersectVector.begin(), IntersectVector.end() );
545 if( IntersectVector.size() == 0 )
return false;
double z
z position of intersection
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.
unsigned int ChannelsInAPAView(APAView_t apaview) const
uint32_t FirstChannelInView(geo::View_t geoview, unsigned int apa, unsigned int cryo) const
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.
bool APAChannelsIntersect(uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector) const
If the channels intersect, get all intersections.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
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
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.
void swap(Handle< T > &a, Handle< T > &b)
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.
unsigned int ChannelsInView(geo::View_t geoview) const
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.
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.
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
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.
std::vector< geo::WireID > ChanSegsPerSide(uint32_t chan, unsigned int side) const
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.
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
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Encapsulate the construction of a single detector plane.
WireGeo const & WireIDToWireGeo(geo::WireID const &wireid) const