16 #include "art_root_io/TFileService.h" 17 #include "art_root_io/TFileDirectory.h" 99 if( wid.
TPC == lastwid.
TPC + 1 ){
114 <<
"Channel boundaries are inconsistent.\n";
127 unsigned int & cryo){
161 <<
"Both Z sides should have the same amount of channels\n";
210 unsigned int apa, cryo;
220 unsigned int apa, cryo;
270 std::vector<geo::WireID> thisSide;
272 for(
size_t i = 0; i < wids.size(); i++)
273 if( wids[i].
TPC % 2 == side ) thisSide.push_back(wids[i]);
284 unsigned int const plane,
285 unsigned int const tpc,
286 unsigned int const cstat )
291 if( cWids[0].Cryostat != cstat )
293 <<
"not in cryostat " << cstat <<
"\n";
294 if( std::floor( cWids[0].
TPC / 2 ) != std::floor( tpc / 2 ) )
296 <<
"not in APA " << std::floor(tpc/2) <<
"\n";
306 for(
size_t i=0; i<cWids.size(); i++){
307 if( cWids[i].
TPC != tpc )
continue;
318 std::vector<geo::WireID> & widsCrossed,
319 bool ExtendLine =
true )
327 unsigned int tpc, cryo;
329 xyzMid[0] = (xyzStart[0]+xyzEnd[0])/2;
330 xyzMid[1] = (xyzStart[1]+xyzEnd[1])/2;
331 xyzMid[2] = (xyzStart[2]+xyzEnd[2])/2;
339 if( startW > endW )
std::swap(startW, endW);
343 for(
size_t w = 0;
w < wids.size();
w++ ){
344 if( wids[
w].
TPC != tpc )
continue;
345 if( wids[
w].Cryostat != cryo )
throw cet::exception(
"LineSegChanIntersect")
346 <<
"Channel and line not in the same crostat.\n";
354 unsigned int ext = 0;
355 if ( ExtendLine) ext = 10;
357 if(
fGeom->
ValueInRange( wids[
w].Wire*1., (startW-ext)*1., (endW+ext)*1. ) ) widsCrossed.push_back(wids[
w]);
361 if( widsCrossed.size() > 0 )
return true;
377 std::vector< geo::WireIDIntersection > UVIntersects;
379 std::vector< double > UVzToZ(UVIntersects.size());
381 unsigned int cryo = Zwid.Cryostat;
382 unsigned int tpc = Zwid.TPC;
385 std::vector<geo::WireID> UwidsInTPC, VwidsInTPC;
386 for(
size_t i=0; i<Uwids.size(); i++)
if( Uwids[i].
TPC==tpc ) UwidsInTPC.push_back(Uwids[i]);
387 for(
size_t i=0; i<Vwids.size(); i++)
if( Vwids[i].
TPC==tpc ) VwidsInTPC.push_back(Vwids[i]);
388 double Zcent[3] = {0.};
391 std::cout <<
"Zcent = " << Zcent[2] <<
", UVintersects zpos = ";
392 for(
size_t uv=0; uv<UVIntersects.size(); uv++){
393 std::cout << UVIntersects[uv].z <<
", ";
402 if( UVIntersects.size() == 0 ){
403 if( UwidsInTPC.size() > 1 || VwidsInTPC.size() > 1 )
404 throw cet::exception(
"ThreeChanPos") <<
"U/V channels don't intersect, bad return.\n";
407 mf::LogWarning(
"ThreeChanPos") <<
"No U/V intersect, exceptional channels. See if U or V intersects Z\n";
408 std::vector<double> yzCenter(2,0.);
414 if( !checkUZ && !checkVZ )
415 throw cet::exception(
"NoChanIntersect") <<
"No channels intersect, bad return.\n";
416 if( checkUZ && !checkVZ ){ yzCenter[0] = UZInt.
y; yzCenter[1] = UZInt.
z; }
417 if( checkVZ && !checkUZ ){ yzCenter[0] = VZInt.
y; yzCenter[1] = VZInt.
z; }
418 if( checkUZ && checkVZ ){ yzCenter[0] = (VZInt.
y+UZInt.
y)/2; yzCenter[1] = (VZInt.
z+UZInt.
z)/2; }
428 std::cout <<
"UVzToZ = ";
429 for(
size_t widI = 0; widI < UVIntersects.size(); widI++ ){
430 UVzToZ[widI] =
std::abs( UVIntersects[widI].z - Zcent[2] );
431 std::cout << UVzToZ[widI] <<
", ";
435 unsigned int bestWidI = 0;
437 for(
unsigned int widI = 0; widI < UVIntersects.size(); widI++ ){
441 if( UVIntersects[widI].
TPC == tpc && UVzToZ[widI] < minZdiff ){
442 minZdiff = UVzToZ[widI];
450 double UVInt[3] = {0.};
451 UVInt[1] = ChosenUVInt.
y; UVInt[2] = ChosenUVInt.
z;
458 std::cout <<
"UZint.z = " << UZInt.
z <<
" (" << checkUZ <<
"), VZint.z = " << VZInt.
z <<
" (" << checkVZ <<
")\n";
461 std::vector<double> yzCenter(2,0.);
464 if( !checkUZ || !checkVZ ){
467 std::cout <<
"ChosenUVint.y = " << ChosenUVInt.
y <<
"ChosenUVint.z = " << ChosenUVInt.
z <<
std::endl;
470 yzCenter[0] = ChosenUVInt.
y;
471 yzCenter[1] = ChosenUVInt.
z;
476 yzCenter[0] = (ChosenUVInt.
y + UZInt.
y + VZInt.
y)/3;
477 yzCenter[1] = (ChosenUVInt.
z + UZInt.
z + VZInt.
z)/3;
491 std::vector< geo::WireIDIntersection >& IntersectVector )
501 if( view1 == view2 ){
502 mf::LogWarning(
"APAChannelsIntersect") <<
"Comparing two channels in the same view, return false";
504 if( wids1[0].Cryostat != wids2[0].Cryostat ||
506 throw cet::exception(
"APAChannelsIntersect") <<
"Comparing two channels in in different APAs: " 507 <<
"channel " << chan1 <<
" in Cryo " 508 << wids1[0].Cryostat <<
", APA " << this->
ChannelToAPA(chan1)
509 <<
", and channel " << chan2 <<
" in Cryo " 510 << wids2[0].Cryostat <<
", APA " << this->
ChannelToAPA(chan2)
517 for(
unsigned int i1 = 0; i1 < wids1.size() ; i1++){
518 for(
unsigned int i2 = 0; i2 < wids2.size() ; i2++){
522 wids1[i1].
TPC != wids2[i2].
TPC ||
523 wids1[i1].Cryostat != wids2[i2].Cryostat )
continue;
537 IntersectVector.push_back( widIntersect );
544 if( IntersectVector.size() > 4 ){
545 mf::LogWarning(
"APAChannelsIntersect") <<
"Got " << IntersectVector.size()
546 <<
" intersections for channels " 547 << chan1 <<
" and " << chan2
548 <<
" - never expect more than 4, so far"; }
555 std::sort( IntersectVector.begin(), IntersectVector.end() );
558 if( IntersectVector.size() == 0 )
return false;
std::vector< geo::WireID > ChanSegsPerSide(uint32_t chan, unsigned int side)
APAView_t APAView(uint32_t chan)
Get which of the 4 APA views the channel is in.
double z
z position of intersection
Encapsulate the construction of a single cyostat.
geo::WireID NearestWireIDOnChan(const double WorldLoc[3], uint32_t chan, unsigned int const plane, unsigned int const tpc=0, unsigned int const cstat=0)
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Declaration of signal hit object.
Z view on the smaller-x side of the APA.
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.
virtual ~APAGeometryAlg()
WireID_t Wire
Index of the wire within its plane.
U view on both sides of the APA.
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.
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.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
unsigned int ChannelToAPA(uint32_t chan)
Get number of the APA containing the given channel.
art::ServiceHandle< geo::Geometry > fGeom
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.
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.
enum dune::apa::_apa_plane_proj APAView_t
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.
void Init()
Initialize some chanel numbers to speed up other methods.
Encapsulate the construction of a single detector plane.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
double y
y position of intersection
unsigned int ChannelsInView(geo::View_t geoview)
std::vector< double > ThreeChanPos(uint32_t u, uint32_t v, uint32_t z)
Find the center of the 3 intersections, choose best if multiple.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
bool APAChannelsIntersect(uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector)
If the channels intersect, get all intersections.
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.
void reconfigure(fhicl::ParameterSet const &p)
Declaration of basic channel signal object.
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.
unsigned int ChannelsInAPAView(APAView_t apaview)
TPCID_t TPC
Index of the TPC within its cryostat.
uint32_t FirstChannelInView(geo::View_t geoview, unsigned int apa, unsigned int cryo)
recob::tracking::Plane Plane
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Encapsulate the construction of a single detector plane.
V view on both sides of the APA.
WireGeo const & WireIDToWireGeo(geo::WireID const &wireid) const
unsigned int fAPAsPerCryo