LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
apa::APAGeometryAlg Class Reference

#include "APAGeometryAlg.h"

Public Member Functions

 APAGeometryAlg (fhicl::ParameterSet const &pset)
 
 APAGeometryAlg ()
 
virtual ~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)
 If the channels intersect, get all intersections. More...
 
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. More...
 
std::vector< geo::WireIDChanSegsPerSide (uint32_t chan, unsigned int side)
 
std::vector< geo::WireIDChanSegsPerSide (std::vector< geo::WireID > wids, unsigned int side)
 
std::vector< double > ThreeChanPos (uint32_t u, uint32_t v, uint32_t z)
 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)
 
unsigned int ChannelToAPA (uint32_t chan)
 Get number of the APA containing the given channel. More...
 
void ChannelToAPA (uint32_t chan, unsigned int &apa, unsigned int &cryo)
 
APAView_t APAView (uint32_t chan)
 Get which of the 4 APA views the channel is in. More...
 
unsigned int ChannelsInView (geo::View_t geoview)
 
uint32_t FirstChannelInView (geo::View_t geoview, unsigned int apa, unsigned int cryo)
 
uint32_t FirstChannelInView (geo::View_t geoview, uint32_t chan)
 
uint32_t FirstChannelInView (uint32_t chan)
 
unsigned int ChannelsInAPAView (APAView_t apaview)
 
unsigned int ChannelsPerAPA ()
 

Private Attributes

art::ServiceHandle< geo::GeometryfGeom
 
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 41 of file APAGeometryAlg.h.

Constructor & Destructor Documentation

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

Definition at line 39 of file APAGeometryAlg.cxx.

References Init(), and reconfigure().

40  {
41  this->reconfigure(pset);
42  this->Init();
43  }
void Init()
Initialize some chanel numbers to speed up other methods.
void reconfigure(fhicl::ParameterSet const &p)
apa::APAGeometryAlg::APAGeometryAlg ( )

Definition at line 47 of file APAGeometryAlg.cxx.

References Init().

48  {
49  this->Init();
50  }
void Init()
Initialize some chanel numbers to speed up other methods.
apa::APAGeometryAlg::~APAGeometryAlg ( )
virtual

Definition at line 53 of file APAGeometryAlg.cxx.

54  {
55  }

Member Function Documentation

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

If the channels intersect, get all intersections.

Definition at line 478 of file APAGeometryAlg.cxx.

References ChannelToAPA(), geo::GeometryCore::ChannelToWire(), fGeom, geo::GeometryCore::View(), and geo::GeometryCore::WireIDsIntersect().

Referenced by ThreeChanPos(), and apa::DisambigAlg::UseEndPts().

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

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

Definition at line 217 of file APAGeometryAlg.cxx.

References fChannelsPerAPA, fFirstZ1, fGeom, fLastV, fLastZ0, apa::kU, geo::kU, apa::kUnknown, apa::kV, geo::kV, geo::kZ, apa::kZ0, apa::kZ1, and geo::GeometryCore::View().

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

Definition at line 156 of file APAGeometryAlg.cxx.

References fFirstU, fFirstV, fFirstZ0, fFirstZ1, fLastZ1, apa::kU, apa::kV, apa::kZ0, and apa::kZ1.

Referenced by ChannelsInView().

156  {
157 
158  switch(apaview){
159  default :
160  return 0;
161  case kU :
162  return fFirstV-fFirstU;
163  case kV :
164  return fFirstZ0-fFirstV;
165  case kZ0 :
166  return fFirstZ1-fFirstZ0;
167  case kZ1 :
168  return fLastZ1-fFirstZ1 + 1;
169  }
170 
171  }
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)

Definition at line 136 of file APAGeometryAlg.cxx.

References ChannelsInAPAView(), apa::kU, geo::kU, apa::kV, geo::kV, geo::kZ, apa::kZ0, and apa::kZ1.

Referenced by apa::DisambigAlg::FindChanTimeEndPts(), and apa::DisambigAlg::MakeCloseHits().

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

Definition at line 90 of file APAGeometryAlg.h.

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

Get number of the APA containing the given channel.

Definition at line 129 of file APAGeometryAlg.cxx.

References fChannelsPerAPA.

Referenced by APAChannelsIntersect(), FirstChannelInView(), apa::DisambigAlg::MakeCloseHits(), and apa::DisambigAlg::RunDisambig().

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

Definition at line 113 of file APAGeometryAlg.cxx.

References fAPAsPerCryo, and fChannelsPerAPA.

115  {
116 
117  cryo = chan / (fAPAsPerCryo*fChannelsPerAPA);
118 
119  // Number apa uniquely across cryostats so that
120  // apa to recob::Object maps are easy to work with.
121  // If we decide to reset APA number per cryo, uncomment:
122  //chan -= cryo*fAPAsPerCryo*fChannelsPerAPA;
123  apa = chan / fChannelsPerAPA;
124 
125  return;
126  }
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 
)

Definition at line 243 of file APAGeometryAlg.cxx.

References geo::GeometryCore::ChannelToWire(), and fGeom.

243  {
244 
245  std::vector<geo::WireID> wids = fGeom->ChannelToWire(chan);
246  return this->ChanSegsPerSide(wids, side);
247 
248  }
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.
std::vector< geo::WireID > ChanSegsPerSide(uint32_t chan, unsigned int side)
std::vector< geo::WireID > apa::APAGeometryAlg::ChanSegsPerSide ( std::vector< geo::WireID wids,
unsigned int  side 
)

Definition at line 253 of file APAGeometryAlg.cxx.

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

Definition at line 175 of file APAGeometryAlg.cxx.

References fAPAsPerCryo, fChannelsPerAPA, fFirstU, fFirstV, fFirstZ0, geo::kU, geo::kV, and geo::kZ.

Referenced by apa::DisambigAlg::FindChanTimeEndPts(), FirstChannelInView(), and apa::DisambigAlg::MakeCloseHits().

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

Definition at line 205 of file APAGeometryAlg.cxx.

References ChannelToAPA(), and FirstChannelInView().

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

Definition at line 195 of file APAGeometryAlg.cxx.

References ChannelToAPA(), fGeom, FirstChannelInView(), and geo::GeometryCore::View().

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

Initialize some chanel numbers to speed up other methods.

Definition at line 63 of file APAGeometryAlg.cxx.

References geo::GeometryCore::ChannelToWire(), fAPAsPerCryo, fChannelRange, fChannelsPerAPA, fFirstU, fFirstV, fFirstZ0, fFirstZ1, fGeom, fLastU, fLastV, fLastZ0, fLastZ1, geo::kU, geo::kV, geo::kZ, geo::GeometryCore::NTPC(), geo::TPCID::TPC, geo::GeometryCore::View(), and geo::GeometryCore::WirePitch().

Referenced by APAGeometryAlg().

64  {
65 
66  // find the number of channels per APA
67  uint32_t channel = 0;
68  while( fGeom->ChannelToWire(channel+1)[0].TPC < 2 ) channel++;
69  fChannelsPerAPA = channel + 1;
70 
71  // Step through channel c and find the view boundaries, until
72  // outside of first APA - these help optimize ChannelToAPAView
73  // (very dependent on the conventions implimented in the channel map)
74  fFirstU = 0;
75  uint32_t c = 1;
76  geo::WireID wid = (fGeom->ChannelToWire(c))[0];
77  geo::WireID lastwid;
78  while( wid.TPC < 2 ){
79 
80  if( fGeom->View(c) == geo::kV && fGeom->View(c-1) == geo::kU ){
81  fLastU = c-1;
82  fFirstV = c; }
83 
84  if( fGeom->View(c) == geo::kZ && fGeom->View(c-1) == geo::kV ){
85  fLastV = c-1;
86  fFirstZ0 = c; }
87 
88  if( wid.TPC == lastwid.TPC + 1 ){
89  fLastZ0 = c-1;
90  fFirstZ1 = c; }
91 
92  lastwid = wid;
93  c++;
94  wid = (fGeom->ChannelToWire(c))[0]; // for the while condition
95 
96  }
97 
98  fLastZ1 = c - 1;
99 
100 
101  if( fLastZ1 + 1 != fChannelsPerAPA ) throw cet::exception("APAGeometryAlg")
102  << "Channel boundaries are inconsistent.\n";
103 
104  // some other things that will be needed
105  fAPAsPerCryo = fGeom->NTPC(0)/2;
108 
109  }
Planes which measure V.
Definition: geo_types.h:77
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.
Definition: geo_types.h:79
unsigned int fAPAsPerCryo
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
Planes which measure U.
Definition: geo_types.h:76
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.
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:203
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 
)

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

Definition at line 305 of file APAGeometryAlg.cxx.

References geo::GeometryCore::ChannelToWire(), fGeom, geo::GeometryCore::NearestWire(), geo::GeometryCore::PositionToTPC(), geo::GeometryCore::ValueInRange(), and w.

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

Definition at line 270 of file APAGeometryAlg.cxx.

References geo::GeometryCore::ChannelToWire(), fChannelRange, fGeom, geo::kZ, geo::GeometryCore::NearestWireID(), geo::GeometryCore::View(), and geo::WireID::Wire.

Referenced by ThreeChanPos(), and apa::DisambigAlg::UseEndPts().

275  {
276 
277  std::vector<geo::WireID> cWids = fGeom->ChannelToWire( chan );
278 
279  if( cWids[0].Cryostat != cstat )
280  throw cet::exception("APAGeometryAlg") << "Channel " << chan
281  << "not in cryostat " << cstat << "\n";
282  if( std::floor( cWids[0].TPC / 2 ) != std::floor( tpc / 2 ) )
283  throw cet::exception("APAGeometryAlg") << "Channel " << chan
284  << "not in APA " << std::floor(tpc/2) << "\n";
285 
286  // special case for vertical wires
287  if(fGeom->View(chan)==geo::kZ) return fGeom->ChannelToWire(chan)[0];
288 
289  unsigned int xyzWire = fGeom->NearestWireID( WorldLoc, plane, tpc, cstat ).Wire;
290 
291  // The desired wire ID will be the only channel
292  // segment within half the channel range.
293  geo::WireID wid;
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];
297  }
298 
299  return wid;
300 
301  }
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.
Definition: geo_types.h:79
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:313
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
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 58 of file APAGeometryAlg.cxx.

Referenced by APAGeometryAlg().

59  {
60  }
std::vector< double > apa::APAGeometryAlg::ThreeChanPos ( uint32_t  u,
uint32_t  v,
uint32_t  z 
)

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

Definition at line 357 of file APAGeometryAlg.cxx.

References APAChannelsIntersect(), geo::GeometryCore::ChannelToWire(), geo::GeometryCore::Cryostat(), fGeom, geo::WireGeo::GetCenter(), geo::TPCGeo::Length(), NearestWireIDOnChan(), geo::CryostatGeo::TPC(), geo::GeometryCore::WireIDsIntersect(), geo::GeometryCore::WireIDToWireGeo(), geo::WireIDIntersection::y, and geo::WireIDIntersection::z.

Referenced by apa::DisambigAlg::UseEndPts().

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

Member Data Documentation

unsigned int apa::APAGeometryAlg::fAPAsPerCryo
private

Definition at line 98 of file APAGeometryAlg.h.

Referenced by ChannelToAPA(), FirstChannelInView(), and Init().

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

Definition at line 110 of file APAGeometryAlg.h.

Referenced by Init(), and NearestWireIDOnChan().

unsigned int apa::APAGeometryAlg::fChannelsPerAPA
private

All APAs have this same number of channels.

Definition at line 97 of file APAGeometryAlg.h.

Referenced by APAView(), ChannelToAPA(), FirstChannelInView(), and Init().

uint32_t apa::APAGeometryAlg::fFirstU
private

Definition at line 101 of file APAGeometryAlg.h.

Referenced by ChannelsInAPAView(), FirstChannelInView(), and Init().

uint32_t apa::APAGeometryAlg::fFirstV
private

Definition at line 103 of file APAGeometryAlg.h.

Referenced by ChannelsInAPAView(), FirstChannelInView(), and Init().

uint32_t apa::APAGeometryAlg::fFirstZ0
private

Definition at line 105 of file APAGeometryAlg.h.

Referenced by ChannelsInAPAView(), FirstChannelInView(), and Init().

uint32_t apa::APAGeometryAlg::fFirstZ1
private

Definition at line 107 of file APAGeometryAlg.h.

Referenced by APAView(), ChannelsInAPAView(), and Init().

uint32_t apa::APAGeometryAlg::fLastU
private

Definition at line 102 of file APAGeometryAlg.h.

Referenced by Init().

uint32_t apa::APAGeometryAlg::fLastV
private

Definition at line 104 of file APAGeometryAlg.h.

Referenced by APAView(), and Init().

uint32_t apa::APAGeometryAlg::fLastZ0
private

Definition at line 106 of file APAGeometryAlg.h.

Referenced by APAView(), and Init().

uint32_t apa::APAGeometryAlg::fLastZ1
private

Definition at line 108 of file APAGeometryAlg.h.

Referenced by ChannelsInAPAView(), and Init().


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