Public Member Functions | Private Attributes | List of all members
apa::APAGeometryAlg Class Reference

#include <APAGeometryAlg.h>

Public Member Functions

 APAGeometryAlg (fhicl::ParameterSet const &pset)
 
 APAGeometryAlg ()
 
void reconfigure (fhicl::ParameterSet const &p)
 
void Init ()
 Initialize some chanel numbers to speed up other methods. More...
 
bool APAChannelsIntersect (uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector) const
 If the channels intersect, get all intersections. More...
 
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. More...
 
std::vector< geo::WireIDChanSegsPerSide (uint32_t chan, unsigned int side) const
 
std::vector< geo::WireIDChanSegsPerSide (std::vector< geo::WireID > wids, unsigned int side) const
 
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. More...
 
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
 
unsigned int ChannelToAPA (uint32_t chan) const
 Get number of the APA containing the given channel. More...
 
void ChannelToAPA (uint32_t chan, unsigned int &apa, unsigned int &cryo) const
 
APAView_t APAView (uint32_t chan) const
 Get which of the 4 APA views the channel is in. More...
 
unsigned int ChannelsInView (geo::View_t geoview) const
 
uint32_t FirstChannelInView (geo::View_t geoview, unsigned int apa, unsigned int cryo) const
 
uint32_t FirstChannelInView (geo::View_t geoview, uint32_t chan) const
 
uint32_t FirstChannelInView (uint32_t chan) const
 
unsigned int ChannelsInAPAView (APAView_t apaview) const
 
unsigned int ChannelsPerAPA () const
 

Private Attributes

art::ServiceHandle< geo::Geometry const > fGeom
 
unsigned int fChannelsPerAPA
 All APAs have this same number of channels. More...
 
unsigned int fAPAsPerCryo
 
uint32_t fFirstU
 
uint32_t fLastU
 
uint32_t fFirstV
 
uint32_t fLastV
 
uint32_t fFirstZ0
 
uint32_t fLastZ0
 
uint32_t fFirstZ1
 
uint32_t fLastZ1
 
double fChannelRange [2]
 

Detailed Description

Definition at line 32 of file APAGeometryAlg.h.

Constructor & Destructor Documentation

apa::APAGeometryAlg::APAGeometryAlg ( fhicl::ParameterSet const &  pset)

Definition at line 29 of file APAGeometryAlg.cxx.

30  {
31  this->reconfigure(pset);
32  this->Init();
33  }
void Init()
Initialize some chanel numbers to speed up other methods.
void reconfigure(fhicl::ParameterSet const &p)
apa::APAGeometryAlg::APAGeometryAlg ( )

Definition at line 37 of file APAGeometryAlg.cxx.

38  {
39  this->Init();
40  }
void Init()
Initialize some chanel numbers to speed up other methods.

Member Function Documentation

bool apa::APAGeometryAlg::APAChannelsIntersect ( uint32_t  chan1,
uint32_t  chan2,
std::vector< geo::WireIDIntersection > &  IntersectVector 
) const

If the channels intersect, get all intersections.

Definition at line 477 of file APAGeometryAlg.cxx.

479  {
480 
481 
482  // Get the WireIDs and view for each channel, make sure views are different
483  geo::WireIDIntersection widIntersect;
484  std::vector< geo::WireID > wids1 = fGeom->ChannelToWire( chan1 );
485  std::vector< geo::WireID > wids2 = fGeom->ChannelToWire( chan2 );
486  geo::View_t view1 = fGeom->View( chan1 );
487  geo::View_t view2 = fGeom->View( chan2 );
488  if( view1 == view2 ){
489  mf::LogWarning("APAChannelsIntersect") << "Comparing two channels in the same view, return false";
490  return false; }
491  if( wids1[0].Cryostat != wids2[0].Cryostat ||
492  this->ChannelToAPA(chan1) != this->ChannelToAPA(chan2) ){
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)
498  << "\n";
499  return false; }
500 
501 
502  // Loop through wids1 and see if wids2 has any intersecting wires,
503  // given that the WireIDs are in the same TPC
504  for( unsigned int i1 = 0; i1 < wids1.size() ; i1++){
505  for( unsigned int i2 = 0; i2 < wids2.size() ; i2++){
506 
507  // make sure it is reasonable to intersect
508  if( wids1[i1].Plane == wids2[i2].Plane ||
509  wids1[i1].TPC != wids2[i2].TPC || // not reasonable for a *WireID*
510  wids1[i1].Cryostat != wids2[i2].Cryostat ) continue;
511 
512 // std::cout << "Checking: \n WireID 1 = ("
513 // << wids1[i1].Cryostat << "," << wids1[i1].TPC << ","
514 // << wids1[i1].Plane << "," << wids1[i1].Wire
515 // << ") \n WireID 2 = ("
516 // << wids2[i2].Cryostat << "," << wids2[i2].TPC << ","
517 // << wids2[i2].Plane << "," << wids2[i2].Wire << ")" << std::endl;
518 
519  // Check if they even intersect; if they do, push back
520  if( fGeom->WireIDsIntersect( wids1[i1], wids2[i2], widIntersect ) ){
521 
522 // std::cout << "we have an intersect" << std::endl;
523 
524  IntersectVector.push_back( widIntersect );
525  }
526  }
527  }
528 
529  // Of all considered configurations, there are never more than
530  // 4 intersections per channel pair
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"; }
536 
537 
538  // With increasing IntersectVector index, the WireID
539  // vector indices of the intersecting wireIDs increase.
540  // This matches the direction in which ChannelToWire
541  // builds its output WireID vector in the APA/35t Alg
542  std::sort( IntersectVector.begin(), IntersectVector.end() );
543 
544  // return true if any intersection points were found
545  if( IntersectVector.size() == 0 ) return false;
546  else return true;
547 
548  }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
unsigned int ChannelToAPA(uint32_t chan) const
Get number of the APA containing the given channel.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
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
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
recob::tracking::Plane Plane
Definition: TrackState.h:17
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
APAView_t apa::APAGeometryAlg::APAView ( uint32_t  chan) const

Get which of the 4 APA views the channel is in.

Definition at line 216 of file APAGeometryAlg.cxx.

216  {
217 
218  // it seems trivial to do this for U and V, but this gives a side to
219  // geo::kZ, unlike Geometry::View(c), as is often needed in disambiguation
220 
221  geo::View_t view = fGeom->View( chan );
222  switch(view){
223  default :
224  break;
225  case geo::kU :
226  return kU;
227  case geo::kV :
228  return kV;
229  case geo::kZ :
230  unsigned int modchan = chan % fChannelsPerAPA;
231  // Channel mapping number in the order of U, V, Z0, then Z1
232  if( modchan > fLastV && modchan < fFirstZ1 ) return kZ0;
233  if( modchan > fLastZ0 ) return kZ1;
234  }
235 
236  return kUnknown;
237 
238  }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Planes which measure V.
Definition: geo_types.h:130
Planes which measure Z direction.
Definition: geo_types.h:132
U view on both sides of the APA.
V view on both sides of the APA.
Z view on the larger-x side of the APA.
Planes which measure U.
Definition: geo_types.h:129
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.
Z view on the smaller-x side of the APA.
art::ServiceHandle< geo::Geometry const > fGeom
unsigned int apa::APAGeometryAlg::ChannelsInAPAView ( APAView_t  apaview) const

Definition at line 155 of file APAGeometryAlg.cxx.

155  {
156 
157  switch(apaview){
158  default :
159  return 0;
160  case kU :
161  return fFirstV-fFirstU;
162  case kV :
163  return fFirstZ0-fFirstV;
164  case kZ0 :
165  return fFirstZ1-fFirstZ0;
166  case kZ1 :
167  return fLastZ1-fFirstZ1 + 1;
168  }
169 
170  }
U view on both sides of the APA.
V view on both sides of the APA.
Z view on the larger-x side of the APA.
Z view on the smaller-x side of the APA.
unsigned int apa::APAGeometryAlg::ChannelsInView ( geo::View_t  geoview) const

Definition at line 135 of file APAGeometryAlg.cxx.

135  {
136 
137  switch(geoview){
138  default :
139  return 0;
140  case geo::kU :
141  return ChannelsInAPAView( kU );
142  case geo::kV :
143  return ChannelsInAPAView( kV );
144  case geo::kZ :
146  return ChannelsInAPAView( kZ0 );
147  else throw cet::exception("ChannelsInView")
148  << "Both Z sides should have the same amount of channels\n";
149  }
150 
151  }
Planes which measure V.
Definition: geo_types.h:130
unsigned int ChannelsInAPAView(APAView_t apaview) const
Planes which measure Z direction.
Definition: geo_types.h:132
U view on both sides of the APA.
V view on both sides of the APA.
Z view on the larger-x side of the APA.
Planes which measure U.
Definition: geo_types.h:129
Z view on the smaller-x side of the APA.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
unsigned int apa::APAGeometryAlg::ChannelsPerAPA ( ) const
inline

Definition at line 80 of file APAGeometryAlg.h.

80 { return fChannelsPerAPA; };
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
unsigned int apa::APAGeometryAlg::ChannelToAPA ( uint32_t  chan) const

Get number of the APA containing the given channel.

Definition at line 128 of file APAGeometryAlg.cxx.

128  {
129 
130  return chan / fChannelsPerAPA;
131  }
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
void apa::APAGeometryAlg::ChannelToAPA ( uint32_t  chan,
unsigned int &  apa,
unsigned int &  cryo 
) const

Definition at line 112 of file APAGeometryAlg.cxx.

114  {
115 
116  cryo = chan / (fAPAsPerCryo*fChannelsPerAPA);
117 
118  // Number apa uniquely across cryostats so that
119  // apa to recob::Object maps are easy to work with.
120  // If we decide to reset APA number per cryo, uncomment:
121  //chan -= cryo*fAPAsPerCryo*fChannelsPerAPA;
122  apa = chan / fChannelsPerAPA;
123 
124  return;
125  }
unsigned int fAPAsPerCryo
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
std::vector< geo::WireID > apa::APAGeometryAlg::ChanSegsPerSide ( uint32_t  chan,
unsigned int  side 
) const

Definition at line 242 of file APAGeometryAlg.cxx.

242  {
243 
244  std::vector<geo::WireID> wids = fGeom->ChannelToWire(chan);
245  return this->ChanSegsPerSide(wids, side);
246 
247  }
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
art::ServiceHandle< geo::Geometry const > fGeom
std::vector< geo::WireID > ChanSegsPerSide(uint32_t chan, unsigned int side) const
std::vector< geo::WireID > apa::APAGeometryAlg::ChanSegsPerSide ( std::vector< geo::WireID wids,
unsigned int  side 
) const

Definition at line 252 of file APAGeometryAlg.cxx.

253  {
254  // Given a vector of wireIDs and an APA side, return
255  // the wireIDs the the tpc side where tpc%2 = side
256 
257  std::vector<geo::WireID> thisSide;
258 
259  for(size_t i = 0; i < wids.size(); i++)
260  if( wids[i].TPC % 2 == side ) thisSide.push_back(wids[i]);
261 
262  return thisSide;
263  }
uint32_t apa::APAGeometryAlg::FirstChannelInView ( geo::View_t  geoview,
unsigned int  apa,
unsigned int  cryo 
) const

Definition at line 174 of file APAGeometryAlg.cxx.

176  {
177 
178 
179  switch(geoview){
180  default :
181  return 0 + (uint32_t)(apa + cryo*fAPAsPerCryo)*fChannelsPerAPA;
182  case geo::kU :
183  return fFirstU + (uint32_t)(apa + cryo*fAPAsPerCryo)*fChannelsPerAPA;
184  case geo::kV :
185  return fFirstV + (uint32_t)(apa + cryo*fAPAsPerCryo)*fChannelsPerAPA;
186  case geo::kZ :
187  //TODO: would need tpc number for the rest of this
188  return fFirstZ0 + (uint32_t)(apa + cryo*fAPAsPerCryo)*fChannelsPerAPA;
189  }
190 
191  }
Planes which measure V.
Definition: geo_types.h:130
Planes which measure Z direction.
Definition: geo_types.h:132
unsigned int fAPAsPerCryo
Planes which measure U.
Definition: geo_types.h:129
unsigned int fChannelsPerAPA
All APAs have this same number of channels.
uint32_t apa::APAGeometryAlg::FirstChannelInView ( geo::View_t  geoview,
uint32_t  chan 
) const

Definition at line 204 of file APAGeometryAlg.cxx.

205  {
206 
207  unsigned int apa, cryo;
208  this->ChannelToAPA( chan, apa, cryo );
209  return this->FirstChannelInView( geoview, apa, cryo );
210 
211  }
uint32_t FirstChannelInView(geo::View_t geoview, unsigned int apa, unsigned int cryo) const
unsigned int ChannelToAPA(uint32_t chan) const
Get number of the APA containing the given channel.
uint32_t apa::APAGeometryAlg::FirstChannelInView ( uint32_t  chan) const

Definition at line 194 of file APAGeometryAlg.cxx.

194  {
195 
196  geo::View_t geoview = fGeom->View(chan);
197  unsigned int apa, cryo;
198  this->ChannelToAPA( chan, apa, cryo );
199  return this->FirstChannelInView( geoview, chan );
200 
201  }
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
uint32_t FirstChannelInView(geo::View_t geoview, unsigned int apa, unsigned int cryo) const
unsigned int ChannelToAPA(uint32_t chan) const
Get number of the APA containing the given channel.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
art::ServiceHandle< geo::Geometry const > fGeom
void apa::APAGeometryAlg::Init ( void  )

Initialize some chanel numbers to speed up other methods.

Definition at line 48 of file APAGeometryAlg.cxx.

49  {
50 
51  // find the number of channels per APA
52  uint32_t channel = 0;
53 
54  // old logic -- segfaults if there is just one APA
55  //while( fGeom->ChannelToWire(channel+1)[0].TPC < 2 ) channel++;
56  //fChannelsPerAPA = channel + 1;
57 
59  for (channel=0; channel < fGeom->Nchannels(); ++channel)
60  {
61  if ( fGeom->ChannelToWire(channel)[0].TPC > 1 )
62  {
64  break;
65  }
66  }
67 
68 
69  // Step through channel c and find the view boundaries, until
70  // outside of first APA - these help optimize ChannelToAPAView
71  // (very dependent on the conventions implimented in the channel map)
72  fFirstU = 0;
73  uint32_t c = 1;
74  geo::WireID wid = (fGeom->ChannelToWire(c))[0];
75  geo::WireID lastwid;
76  while( wid.TPC < 2 ){
77 
78  if( fGeom->View(c) == geo::kV && fGeom->View(c-1) == geo::kU ){
79  fLastU = c-1;
80  fFirstV = c; }
81 
82  if( fGeom->View(c) == geo::kZ && fGeom->View(c-1) == geo::kV ){
83  fLastV = c-1;
84  fFirstZ0 = c; }
85 
86  if( wid.TPC == lastwid.TPC + 1 ){
87  fLastZ0 = c-1;
88  fFirstZ1 = c; }
89 
90  lastwid = wid;
91  c++;
92  if (c >= fGeom->Nchannels()) break;
93  wid = (fGeom->ChannelToWire(c))[0]; // for the while condition
94 
95  }
96 
97  fLastZ1 = c - 1;
98 
99 
100  if( fLastZ1 + 1 != fChannelsPerAPA ) throw cet::exception("APAGeometryAlg")
101  << "Channel boundaries are inconsistent.\n";
102 
103  // some other things that will be needed
104  fAPAsPerCryo = fGeom->NTPC(0)/2;
107 
108  }
Planes which measure V.
Definition: geo_types.h:130
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.
Definition: geo_types.h:132
uint8_t channel
Definition: CRTFragment.hh:201
unsigned int fAPAsPerCryo
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.
Planes which measure U.
Definition: geo_types.h:129
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.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
art::ServiceHandle< geo::Geometry const > fGeom
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool apa::APAGeometryAlg::LineSegChanIntersect ( TVector3  xyzStart,
TVector3  xyzEnd,
uint32_t  chan,
std::vector< geo::WireID > &  widsCrossed,
bool  ExtendLine = true 
) const

If a line given by start/end points intersects a channel.

Definition at line 304 of file APAGeometryAlg.cxx.

307  {
308 
309  // This assumes a smooth wire numbering, and that the line seg is contained in a tpc.
310  // Meant for use with the approximate line calculated
311  // by matching cluster endpoints in disambiguation.
312 
313  // Find tpc, use midpoint in case start/end is on a boundary
314  unsigned int tpc, cryo;
315  double xyzMid[3];
316  xyzMid[0] = (xyzStart[0]+xyzEnd[0])/2;
317  xyzMid[1] = (xyzStart[1]+xyzEnd[1])/2;
318  xyzMid[2] = (xyzStart[2]+xyzEnd[2])/2;
319  fGeom->PositionToTPC(xyzMid, tpc, cryo);
320 
321  // Find the nearest wire number to the line segment endpoints
322  std::vector<geo::WireID> wids = fGeom->ChannelToWire(chan);
323  unsigned int startW = fGeom->NearestWire( xyzStart, wids[0].Plane, tpc, cryo );
324  unsigned int endW = fGeom->NearestWire( xyzEnd, wids[0].Plane, tpc, cryo );
325 
326  if( startW > endW ) std::swap(startW, endW);
327 
328 
329  // Loop through wireIDs and check for intersection, if in the right TPC
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";
334 
335  // If the current wire id wire number is inbetween the start/end
336  // point wires, the line segment intersects the wireID at some point.
337 
338  // TODO: for now, extend range, but that is application specific. fix asap
339  // The longer we make the range, the more conservative it is, so it is safe
340  // to extend the range a bit to get hits at the ends of the line
341  unsigned int ext = 0;
342  if ( ExtendLine) ext = 10;
343 
344  if( fGeom->ValueInRange( wids[w].Wire*1., (startW-ext)*1., (endW+ext)*1. ) ) widsCrossed.push_back(wids[w]);
345 
346  }
347 
348  if( widsCrossed.size() > 0 ) return true;
349  else return false;
350 
351  }
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
geo::TPCGeo const & PositionToTPC(geo::Point_t const &point) const
Returns the TPC at specified location.
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.
art::ServiceHandle< geo::Geometry const > fGeom
bool ValueInRange(double value, double min, double max) const
Returns whether a value is within the specified range.
recob::tracking::Plane Plane
Definition: TrackState.h:17
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
geo::WireID apa::APAGeometryAlg::NearestWireIDOnChan ( const double  WorldLoc[3],
uint32_t  chan,
unsigned int const  plane,
unsigned int const  tpc = 0,
unsigned int const  cstat = 0 
) const

Definition at line 269 of file APAGeometryAlg.cxx.

274  {
275 
276  std::vector<geo::WireID> cWids = fGeom->ChannelToWire( chan );
277 
278  if( cWids[0].Cryostat != cstat )
279  throw cet::exception("APAGeometryAlg") << "Channel " << chan
280  << "not in cryostat " << cstat << "\n";
281  if( std::floor( cWids[0].TPC / 2 ) != std::floor( tpc / 2 ) )
282  throw cet::exception("APAGeometryAlg") << "Channel " << chan
283  << "not in APA " << std::floor(tpc/2) << "\n";
284 
285  // special case for vertical wires
286  if(fGeom->View(chan)==geo::kZ) return fGeom->ChannelToWire(chan)[0];
287 
288  unsigned int xyzWire = fGeom->NearestWireID( WorldLoc, plane, tpc, cstat ).Wire;
289 
290  // The desired wire ID will be the only channel
291  // segment within half the channel range.
292  geo::WireID wid;
293  for(size_t i=0; i<cWids.size(); i++){
294  if( cWids[i].TPC != tpc ) continue;
295  if( std::abs((int)cWids[i].Wire - (int)xyzWire) < fChannelRange[plane]/2 ) wid=cWids[i];
296  }
297 
298  return wid;
299 
300  }
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.
Definition: geo_types.h:132
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
T abs(T value)
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
art::ServiceHandle< geo::Geometry const > fGeom
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.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void apa::APAGeometryAlg::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 43 of file APAGeometryAlg.cxx.

44  {
45  }
std::vector< double > apa::APAGeometryAlg::ThreeChanPos ( uint32_t  u,
uint32_t  v,
uint32_t  z 
) const

Find the center of the 3 intersections, choose best if multiple.

Definition at line 356 of file APAGeometryAlg.cxx.

357  {
358 
359  // Say we've associated a U, V, and Z channel -- perhaps by associating hits
360  // or cluster endpoints -- these don't necessarily all intersect, but they
361  // are hopefully pretty close. Find the center of the 3 intersections.
362 
363  // get data needed along the way
364  std::vector< geo::WireIDIntersection > UVIntersects;
365  this->APAChannelsIntersect( u, v, UVIntersects );
366  std::vector< double > UVzToZ(UVIntersects.size());
367  geo::WireID Zwid = fGeom->ChannelToWire(z)[0];
368  unsigned int cryo = Zwid.Cryostat;
369  unsigned int tpc = Zwid.TPC;
370  std::vector<geo::WireID> Uwids = fGeom->ChannelToWire(u);
371  std::vector<geo::WireID> Vwids = fGeom->ChannelToWire(v);
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.};
376  fGeom->WireIDToWireGeo( Zwid ).GetCenter(Zcent);
377 
378  std::cout << "Zcent = " << Zcent[2] << ", UVintersects zpos = ";
379  for(size_t uv=0; uv<UVIntersects.size(); uv++){
380  std::cout << UVIntersects[uv].z << ", ";
381  }
382  std::cout << "\n";
383 
384  /////////////////////////////////////
385  /////////////////////////////////////
386 
387  //std::cout << "U = " << u << " V = " << v << ", " << UVIntersects.size() << std::endl;
388 
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";
392 
393  // Now assume there are only one of each u and v wireIDs on in this TPC
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.);
396  geo::WireID Uwid = UwidsInTPC[0];
397  geo::WireID Vwid = VwidsInTPC[0];
398  geo::WireIDIntersection UZInt, VZInt;
399  bool checkUZ = fGeom->WireIDsIntersect( Uwid, Zwid, UZInt );
400  bool checkVZ = fGeom->WireIDsIntersect( Vwid, Zwid, VZInt );
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; }
406  return yzCenter;
407  }
408 
409  /////////////////////////////////////
410  /////////////////////////////////////
411 
412 
413  // In case the uv channels intersect twice on the same side, choose the best case.
414  // Note: this will not happen for APAs with UV angle at about 36, but will for 45
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] << ", ";
419  }
420  std::cout<<"\n";
421 
422  unsigned int bestWidI = 0;
423  double minZdiff = fGeom->Cryostat(cryo).TPC(tpc).Length(); // start it out at maximum z
424  for( unsigned int widI = 0; widI < UVIntersects.size(); widI++ ){
425 
426  //std::cout << "widI = " << widI << std::endl;
427 
428  if( UVIntersects[widI].TPC == tpc && UVzToZ[widI] < minZdiff ){
429  minZdiff = UVzToZ[widI];
430  bestWidI = widI;
431  //std::cout << "bestWidI = " << bestWidI << std::endl;
432  }
433  }
434  geo::WireIDIntersection ChosenUVInt = UVIntersects[bestWidI];
435 
436  // Now having the UV intersection, get the UZ and VZ
437  double UVInt[3] = {0.};
438  UVInt[1] = ChosenUVInt.y; UVInt[2] = ChosenUVInt.z;
439  geo::WireID Uwid = this->NearestWireIDOnChan( UVInt, u, 0, tpc, cryo );
440  geo::WireID Vwid = this->NearestWireIDOnChan( UVInt, v, 1, tpc, cryo );
441  geo::WireIDIntersection UZInt, VZInt;
442  bool checkUZ = fGeom->WireIDsIntersect( Uwid, Zwid, UZInt );
443  bool checkVZ = fGeom->WireIDsIntersect( Vwid, Zwid, VZInt );
444 
445  std::cout << "UZint.z = " << UZInt.z << " (" << checkUZ << "), VZint.z = " << VZInt.z << " (" << checkVZ << ")\n";
446 
447  // find the center
448  std::vector<double> yzCenter(2,0.);
449 
450 
451  if( !checkUZ || !checkVZ ){
452  //throw cet::exception("ThreeChanPos") << "WireIDs were expected to intersect.\n";
453 
454  std::cout << "ChosenUVint.y = " << ChosenUVInt.y << "ChosenUVint.z = " << ChosenUVInt.z << std::endl;
455 
456  //temporary case
457  yzCenter[0] = ChosenUVInt.y;
458  yzCenter[1] = ChosenUVInt.z;
459 
460 
461  } else {
462 
463  yzCenter[0] = (ChosenUVInt.y + UZInt.y + VZInt.y)/3;
464  yzCenter[1] = (ChosenUVInt.z + UZInt.z + VZInt.z)/3;
465 
466  }
467 
468 
469  return yzCenter;
470 
471  }
double z
z position of intersection
Definition: geo_types.h:805
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
bool APAChannelsIntersect(uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector) const
If the channels intersect, get all intersections.
double Length() const
Length is associated with z coordinate [cm].
Definition: TPCGeo.h:115
T abs(T value)
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns 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&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:93
double y
y position of intersection
Definition: geo_types.h:804
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:73
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
WireGeo const & WireIDToWireGeo(geo::WireID const &wireid) const

Member Data Documentation

unsigned int apa::APAGeometryAlg::fAPAsPerCryo
private

Definition at line 88 of file APAGeometryAlg.h.

double apa::APAGeometryAlg::fChannelRange[2]
private

Definition at line 100 of file APAGeometryAlg.h.

unsigned int apa::APAGeometryAlg::fChannelsPerAPA
private

All APAs have this same number of channels.

Definition at line 87 of file APAGeometryAlg.h.

uint32_t apa::APAGeometryAlg::fFirstU
private

Definition at line 91 of file APAGeometryAlg.h.

uint32_t apa::APAGeometryAlg::fFirstV
private

Definition at line 93 of file APAGeometryAlg.h.

uint32_t apa::APAGeometryAlg::fFirstZ0
private

Definition at line 95 of file APAGeometryAlg.h.

uint32_t apa::APAGeometryAlg::fFirstZ1
private

Definition at line 97 of file APAGeometryAlg.h.

art::ServiceHandle<geo::Geometry const> apa::APAGeometryAlg::fGeom
private

Definition at line 80 of file APAGeometryAlg.h.

uint32_t apa::APAGeometryAlg::fLastU
private

Definition at line 92 of file APAGeometryAlg.h.

uint32_t apa::APAGeometryAlg::fLastV
private

Definition at line 94 of file APAGeometryAlg.h.

uint32_t apa::APAGeometryAlg::fLastZ0
private

Definition at line 96 of file APAGeometryAlg.h.

uint32_t apa::APAGeometryAlg::fLastZ1
private

Definition at line 98 of file APAGeometryAlg.h.


The documentation for this class was generated from the following files: