LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
geo::details::ActiveAreaCalculator Struct Reference

Class computing the active area of the plane. More...

Public Member Functions

 ActiveAreaCalculator (geo::PlaneGeo const &plane, double wMargin, double dMargin)
 
 ActiveAreaCalculator (geo::PlaneGeo const &plane, double margin=0.0)
 
 operator geo::PlaneGeo::Rect ()
 

Private Types

using Projection_t = ROOT::Math::PositionVector2D< ROOT::Math::Cartesian2D< double >, geo::PlaneGeo::WidthDepthReferenceTag >
 
using Vector_t = geo::PlaneGeo::WidthDepthDisplacement_t
 

Private Member Functions

void initializeWireEnds ()
 
void includeAllWireEnds ()
 
void adjustCorners ()
 
void applyMargin ()
 
geo::PlaneGeo::Rect recomputeArea ()
 

Static Private Member Functions

static bool none_or_both (bool a, bool b)
 Returns true if a and b are both true or both false (exclusive nor). More...
 
template<typename T >
static bool equal (T a, T b, T tol=T(1e-5))
 Returns whether the two numbers are the same, lest a tolerance. More...
 

Private Attributes

PlaneGeo const & plane
 Plane to work on. More...
 
double const wMargin = 0.0
 Margin subtracted from each side of width. More...
 
double const dMargin = 0.0
 Margin subtracted from each side of depth. More...
 
geo::PlaneGeo::Rect activeArea
 Result. More...
 
Projection_t wireEnds [4]
 Cache: wire end projections. More...
 

Static Private Attributes

static constexpr std::size_t kFirstWireStart = 0
 
static constexpr std::size_t kFirstWireEnd = 1
 
static constexpr std::size_t kLastWireStart = 2
 
static constexpr std::size_t kLastWireEnd = 3
 

Detailed Description

Class computing the active area of the plane.

The active area is defined in the width/depth space which include approximatively all wires.

This algorithm requires the frame reference and the wire pitch to be already defined.

That area is tuned so that all its points are closer than half a wire pitch from a wire.

Definition at line 85 of file PlaneGeo.cxx.

Member Typedef Documentation

using geo::details::ActiveAreaCalculator::Projection_t = ROOT::Math::PositionVector2D <ROOT::Math::Cartesian2D<double>, geo::PlaneGeo::WidthDepthReferenceTag>
private

Definition at line 103 of file PlaneGeo.cxx.

Constructor & Destructor Documentation

geo::details::ActiveAreaCalculator::ActiveAreaCalculator ( geo::PlaneGeo const &  plane,
double  wMargin,
double  dMargin 
)
inline

Definition at line 88 of file PlaneGeo.cxx.

89  : plane(plane)
90  , wMargin(wMargin)
91  , dMargin(dMargin)
92  {}
double const dMargin
Margin subtracted from each side of depth.
Definition: PlaneGeo.cxx:118
PlaneGeo const & plane
Plane to work on.
Definition: PlaneGeo.cxx:116
double const wMargin
Margin subtracted from each side of width.
Definition: PlaneGeo.cxx:117
geo::details::ActiveAreaCalculator::ActiveAreaCalculator ( geo::PlaneGeo const &  plane,
double  margin = 0.0 
)
inline

Definition at line 94 of file PlaneGeo.cxx.

95  : ActiveAreaCalculator(plane, margin, margin)
96  {}
PlaneGeo const & plane
Plane to work on.
Definition: PlaneGeo.cxx:116
ActiveAreaCalculator(geo::PlaneGeo const &plane, double wMargin, double dMargin)
Definition: PlaneGeo.cxx:88

Member Function Documentation

void geo::details::ActiveAreaCalculator::adjustCorners ( )
inlineprivate

Definition at line 164 of file PlaneGeo.cxx.

References lar::util::simple_geo::Rectangle< Data >::depth, geo::vect::dot(), equal(), geo::PlaneGeo::GetIncreasingWireDirection(), lar::util::simple_geo::Range< Data >::lower, max, min, none_or_both(), lar::util::simple_geo::Range< Data >::upper, geo::PlaneGeo::VectorWidthDepthProjection(), lar::util::simple_geo::Rectangle< Data >::width, geo::PlaneGeo::WirePitch(), X, x1, and Y.

Referenced by recomputeArea().

165  {
166  //
167  // Modify the corners so that none is father than half a pitch from all
168  // wires.
169  //
170  // directions in wire/depth plane
171  Vector_t const widthDir = { 1.0, 0.0 };
172  Vector_t const depthDir = { 0.0, 1.0 };
175  double const hp = plane.WirePitch() / 2.0; // half pitch
176 
177  //
178  // The plan: identify if wires are across or corner, and then:
179  // - across:
180  // - identify which sides
181  // - set the farther end of the wire from the side to be p/2 from
182  // its corner
183  // - corner:
184  // - identify which corners
185  // - move the corners to p/2 from the wires
186  //
187 
188  //
189  // are the wires crossing side to side, as opposed to cutting corners?
190  //
191 
192  // these are the angles of the original wire coordinate direction
193  double const cosAngleWidth = geo::vect::dot(wireCoordDir, widthDir);
194  double const cosAngleDepth = geo::vect::dot(wireCoordDir, depthDir);
195  // if the wire coordinate direction is on first or third quadrant:
196  bool const bPositiveAngle
197  = none_or_both((wireCoordDir.X() >= 0), (wireCoordDir.Y() >= 0));
198 
199  // now we readjust the wire coordinate direction to always point
200  // toward positive width; this breaks the relation between
201  // wireCoordDir and which is the first/last wire
202  if (cosAngleWidth < 0) wireCoordDir = -wireCoordDir;
203 
204  // let's study the first wire (ends are sorted by width)
206  bool const bAlongWidth // horizontal
209  bool const bAlongDepth = !bAlongWidth && // vertical
212  assert(!(bAlongWidth && bAlongDepth));
213 
214  if (bAlongWidth) { // horizontal
215 
216  // +---------+
217  // | ___,--| upper width bound
218  // |--' |
219 
220  // find which is the wire with higher width:
221  // the last wire is highest if the wire coordinate direction (which
222  // is defined by what is first and what is last) is parallel to the
223  // width direction
224  std::size_t const iUpperWire
225  = (cosAngleDepth > 0)? kLastWireStart: kFirstWireStart;
226  // largest distance from upper depth bound of the two ends of wire
227  double const maxUpperDistance = activeArea.depth.upper
228  - std::min
229  (wireEnds[iUpperWire].Y(), wireEnds[iUpperWire ^ 0x1].Y())
230  ;
231  // set the upper side so that the maximum distance is p/2
232  // (it may be actually less if the wire is not perfectly horizontal)
233  activeArea.depth.upper += (hp - maxUpperDistance);
234 
235  // |--.___ |
236  // | `--| deal with the lower bound now
237  // +---------+
238 
239  std::size_t const iLowerWire
240  = (cosAngleDepth > 0)? kFirstWireStart: kLastWireStart;
241  // largest distance from lower depth bound of the two ends of wire
242  double const maxLowerDistance
243  = std::max
244  (wireEnds[iLowerWire].Y(), wireEnds[iLowerWire ^ 0x1].Y())
246  ;
247  // set the upper side so that the minimum distance is p/2
248  activeArea.depth.lower -= (hp - maxLowerDistance);
249 
250  } // horizontal wires
251  else if (bAlongDepth) { // vertical
252  // --,---+
253  // | |
254  // \ |
255  // | | upper depth bound
256  // \ |
257  // | |
258  // ------+
259 
260  // find which is the wire with higher depth:
261  // the last wire is highest if the wire coordinate direction (which
262  // is defined by what is first and what is last) is parallel to the
263  // depth direction
264  std::size_t const iUpperWire
265  = (cosAngleWidth > 0)? kLastWireStart: kFirstWireStart;
266  // largest distance from upper depth bound of the two ends of wire
267  double const maxUpperDistance = activeArea.width.upper
268  - std::min
269  (wireEnds[iUpperWire].X(), wireEnds[iUpperWire ^ 0x1].X())
270  ;
271  // set the upper side so that the minimum distance is p/2
272  activeArea.width.upper += (hp - maxUpperDistance);
273 
274  // +-,----
275  // | |
276  // | \ .
277  // | | deal with the lower bound now
278  // | \ .
279  // | |
280  // +------
281  std::size_t const iLowerWire
282  = (cosAngleWidth > 0)? kFirstWireStart: kLastWireStart;
283  // largest distance from lower width bound of the two ends of wire
284  double const maxLowerDistance
285  = std::max
286  (wireEnds[iLowerWire].X(), wireEnds[iLowerWire ^ 0x1].X())
288  ;
289  // set the upper side so that the minimum distance is p/2
290  activeArea.width.lower -= (hp - maxLowerDistance);
291 
292  } // vertical wires
293  else if (bPositiveAngle) { // wires are not going across: corners!
294  // corners at (lower width, lower depth), (upper width, upper depth)
295 
296  // -._------+
297  // `-._ | upper width corner (upper depth)
298  // `-|
299 
300  // start of the wire on the upper corner
301  // (width coordinate is lower for start than for end)
302  std::size_t const iUpperWire
303  = (cosAngleWidth > 0)? kLastWireStart: kFirstWireStart;
304 
305  double const upperDistance = geo::vect::dot(
306  Vector_t(activeArea.width.upper - wireEnds[iUpperWire].X(), 0.0),
307  wireCoordDir
308  );
309  // make the upper distance become p/2
310  auto const upperDelta = (hp - upperDistance) * wireCoordDir;
311  activeArea.width.upper += upperDelta.X();
312  activeArea.depth.upper += upperDelta.Y();
313 
314  // |-._
315  // | `-._ lower width corner (lower depth)
316  // +-------`-
317 
318  // end of the wire on the lower corner
319  // (width coordinate is lower than the end)
320  std::size_t const iLowerWire
321  = (cosAngleWidth > 0)? kFirstWireEnd: kLastWireEnd;
322 
323  double const lowerDistance = geo::vect::dot(
324  Vector_t(wireEnds[iLowerWire].X() - activeArea.width.lower, 0.0),
325  wireCoordDir
326  );
327  // make the lower distance become p/2 (note direction of wire coord)
328  auto const lowerDelta = (hp - lowerDistance) * wireCoordDir;
329  activeArea.width.lower -= lowerDelta.X();
330  activeArea.depth.lower -= lowerDelta.Y();
331 
332  }
333  else { // !bPositiveAngle
334  // corners at (lower width, upper depth), (upper width, lower depth)
335 
336  // _,-|
337  // _,-' | upper width corner (lower depth)
338  // -'-------+
339 
340  // start of the wire on the upper corner
341  // (width coordinate is lower than the end)
342  std::size_t const iUpperWire
343  = (cosAngleWidth > 0)? kLastWireStart: kFirstWireStart;
344 
345  double const upperDistance = geo::vect::dot(
346  Vector_t(activeArea.width.upper - wireEnds[iUpperWire].X(), 0.0),
347  wireCoordDir
348  );
349  // make the upper distance become p/2
350  auto const upperDelta = (hp - upperDistance) * wireCoordDir;
351  activeArea.width.upper += upperDelta.X();
352  activeArea.depth.lower += upperDelta.Y();
353 
354  // +------_,-
355  // | _,-' lower width corner (upper depth)
356  // |-'
357 
358  // end of the wire on the lower corner
359  // (width coordinate is lower than the end)
360  std::size_t const iLowerWire
361  = (cosAngleWidth > 0)? kFirstWireEnd: kLastWireEnd;
362 
363  double const lowerDistance = geo::vect::dot(
364  Vector_t(wireEnds[iLowerWire].X() - activeArea.width.lower, 0.0),
365  wireCoordDir
366  );
367  // make the lower distance become p/2 (note direction of wire coord)
368  auto const lowerDelta = (hp - lowerDistance) * wireCoordDir;
369  activeArea.width.lower -= lowerDelta.X();
370  activeArea.depth.upper -= lowerDelta.Y();
371 
372  } // if ...
373 
374  } // adjustCorners()
WidthDepthProjection_t VectorWidthDepthProjection(geo::Vector_t const &v) const
Returns the projection of the specified vector on the plane.
Definition: PlaneGeo.h:917
constexpr auto dot(Vector const &a, Vector const &b)
Return cross product of two vectors.
static bool none_or_both(bool a, bool b)
Returns true if a and b are both true or both false (exclusive nor).
Definition: PlaneGeo.cxx:418
Float_t x1[n_points_granero]
Definition: compare.C:5
Float_t Y
Definition: plot.C:39
geo::PlaneGeo::WidthDepthDisplacement_t Vector_t
Definition: PlaneGeo.cxx:104
static constexpr std::size_t kLastWireStart
Definition: PlaneGeo.cxx:113
static constexpr std::size_t kFirstWireStart
Definition: PlaneGeo.cxx:111
PlaneGeo const & plane
Plane to work on.
Definition: PlaneGeo.cxx:116
Vector GetIncreasingWireDirection() const
Returns the direction of increasing wires.
Definition: PlaneGeo.h:408
Projection_t wireEnds[4]
Cache: wire end projections.
Definition: PlaneGeo.cxx:122
Int_t max
Definition: plot.C:27
Range_t width
Range along width direction.
Definition: SimpleGeo.h:393
static constexpr std::size_t kLastWireEnd
Definition: PlaneGeo.cxx:114
Range_t depth
Range along depth direction.
Definition: SimpleGeo.h:394
Int_t min
Definition: plot.C:26
Data_t upper
Ending coordinate.
Definition: SimpleGeo.h:327
static constexpr std::size_t kFirstWireEnd
Definition: PlaneGeo.cxx:112
static bool equal(T a, T b, T tol=T(1e-5))
Returns whether the two numbers are the same, lest a tolerance.
Definition: PlaneGeo.cxx:422
Data_t lower
Starting coordinate.
Definition: SimpleGeo.h:326
Float_t X
Definition: plot.C:39
recob::tracking::Vector_t Vector_t
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:367
geo::PlaneGeo::Rect activeArea
Result.
Definition: PlaneGeo.cxx:119
void geo::details::ActiveAreaCalculator::applyMargin ( )
inlineprivate

Definition at line 377 of file PlaneGeo.cxx.

References lar::util::simple_geo::Rectangle< Data >::depth, dMargin, lar::util::simple_geo::Range< Data >::lower, lar::util::simple_geo::Range< Data >::upper, lar::util::simple_geo::Rectangle< Data >::width, and wMargin.

Referenced by recomputeArea().

378  {
379  if (wMargin != 0.0) {
382  }
383  if (dMargin != 0.0) {
386  }
387  } // applyMargin()
double const dMargin
Margin subtracted from each side of depth.
Definition: PlaneGeo.cxx:118
Range_t width
Range along width direction.
Definition: SimpleGeo.h:393
Range_t depth
Range along depth direction.
Definition: SimpleGeo.h:394
double const wMargin
Margin subtracted from each side of width.
Definition: PlaneGeo.cxx:117
Data_t upper
Ending coordinate.
Definition: SimpleGeo.h:327
Data_t lower
Starting coordinate.
Definition: SimpleGeo.h:326
geo::PlaneGeo::Rect activeArea
Result.
Definition: PlaneGeo.cxx:119
template<typename T >
static bool geo::details::ActiveAreaCalculator::equal ( a,
b,
tol = T(1e-5) 
)
inlinestaticprivate

Returns whether the two numbers are the same, lest a tolerance.

Definition at line 422 of file PlaneGeo.cxx.

Referenced by adjustCorners().

423  { return std::abs(a - b) <= tol; }
void geo::details::ActiveAreaCalculator::includeAllWireEnds ( )
inlineprivate

Definition at line 150 of file PlaneGeo.cxx.

References lar::util::simple_geo::Rectangle< Data >::depth, lar::util::simple_geo::Range< Data >::extendToInclude(), and lar::util::simple_geo::Rectangle< Data >::width.

Referenced by recomputeArea().

151  {
152  //
153  // Find the basic area containing all the coordinates.
154  //
155 
156  // include all the coordinates of the first and last wire
157  for (auto const& aWireEnd: wireEnds) {
158  activeArea.width.extendToInclude(aWireEnd.X());
159  activeArea.depth.extendToInclude(aWireEnd.Y());
160  }
161 
162  } // includeAllWireEnds()
void extendToInclude(Data_t)
Extends the range to include the specified point.
Definition: SimpleGeo.h:456
Projection_t wireEnds[4]
Cache: wire end projections.
Definition: PlaneGeo.cxx:122
Range_t width
Range along width direction.
Definition: SimpleGeo.h:393
Range_t depth
Range along depth direction.
Definition: SimpleGeo.h:394
geo::PlaneGeo::Rect activeArea
Result.
Definition: PlaneGeo.cxx:119
void geo::details::ActiveAreaCalculator::initializeWireEnds ( )
inlineprivate

Definition at line 124 of file PlaneGeo.cxx.

References geo::PlaneGeo::FirstWire(), geo::WireGeo::GetEnd(), geo::WireGeo::GetStart(), kFirstWireEnd, kFirstWireStart, kLastWireEnd, kLastWireStart, geo::PlaneGeo::LastWire(), geo::PlaneGeo::PointWidthDepthProjection(), and X.

Referenced by recomputeArea().

125  {
126  //
127  // Collect the projections of the relevant points.
128  //
129  // Sorted so that start points have width not larger than end points.
130  //
131  // PointWidthDepthProjection() erroneously returns a vector rather
132  // than a point, so a conversion is required
133  auto makeProjection
134  = [](auto v){ return Projection_t(v.X(), v.Y()); };
135 
136  wireEnds[kFirstWireStart] = makeProjection
138  wireEnds[kFirstWireEnd] = makeProjection
142  wireEnds[kLastWireStart] = makeProjection
144  wireEnds[kLastWireEnd] = makeProjection
148  } // initializeWireEnds()
void GetStart(double *xyz) const
Definition: WireGeo.h:129
static constexpr std::size_t kLastWireStart
Definition: PlaneGeo.cxx:113
WidthDepthProjection_t PointWidthDepthProjection(geo::Point_t const &point) const
Returns the projection of the specified point on the plane.
Definition: PlaneGeo.h:897
static constexpr std::size_t kFirstWireStart
Definition: PlaneGeo.cxx:111
PlaneGeo const & plane
Plane to work on.
Definition: PlaneGeo.cxx:116
Projection_t wireEnds[4]
Cache: wire end projections.
Definition: PlaneGeo.cxx:122
const WireGeo & FirstWire() const
Return the first wire in the plane.
Definition: PlaneGeo.h:325
static constexpr std::size_t kLastWireEnd
Definition: PlaneGeo.cxx:114
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
void GetEnd(double *xyz) const
Definition: WireGeo.h:133
static constexpr std::size_t kFirstWireEnd
Definition: PlaneGeo.cxx:112
const WireGeo & LastWire() const
Return the last wire in the plane.
Definition: PlaneGeo.h:331
Float_t X
Definition: plot.C:39
ROOT::Math::PositionVector2D< ROOT::Math::Cartesian2D< double >, geo::PlaneGeo::WidthDepthReferenceTag > Projection_t
Definition: PlaneGeo.cxx:103
static bool geo::details::ActiveAreaCalculator::none_or_both ( bool  a,
bool  b 
)
inlinestaticprivate

Returns true if a and b are both true or both false (exclusive nor).

Definition at line 418 of file PlaneGeo.cxx.

Referenced by adjustCorners().

418 { return a == b; }
geo::details::ActiveAreaCalculator::operator geo::PlaneGeo::Rect ( )
inline

Definition at line 98 of file PlaneGeo.cxx.

References recomputeArea().

99  { return recomputeArea(); }
geo::PlaneGeo::Rect recomputeArea()
Definition: PlaneGeo.cxx:390
geo::PlaneGeo::Rect geo::details::ActiveAreaCalculator::recomputeArea ( )
inlineprivate

Definition at line 390 of file PlaneGeo.cxx.

References activeArea, adjustCorners(), applyMargin(), includeAllWireEnds(), and initializeWireEnds().

Referenced by operator geo::PlaneGeo::Rect().

391  {
392  activeArea = {};
393 
394  //
395  // 0. collect the projections of the relevant point
396  //
398 
399  //
400  // 1. find the basic area containing all the coordinates
401  //
403 
404  //
405  // 2. adjust area so that no corner is father than half a wire pitch
406  //
407  adjustCorners();
408 
409  //
410  // 3. apply an absolute margin
411  //
412  applyMargin();
413 
414  return activeArea;
415  } // computeArea()
geo::PlaneGeo::Rect activeArea
Result.
Definition: PlaneGeo.cxx:119

Member Data Documentation

geo::PlaneGeo::Rect geo::details::ActiveAreaCalculator::activeArea
private

Result.

Definition at line 119 of file PlaneGeo.cxx.

Referenced by recomputeArea().

double const geo::details::ActiveAreaCalculator::dMargin = 0.0
private

Margin subtracted from each side of depth.

Definition at line 118 of file PlaneGeo.cxx.

Referenced by applyMargin().

constexpr std::size_t geo::details::ActiveAreaCalculator::kFirstWireEnd = 1
staticprivate

Definition at line 112 of file PlaneGeo.cxx.

Referenced by initializeWireEnds().

constexpr std::size_t geo::details::ActiveAreaCalculator::kFirstWireStart = 0
staticprivate

Definition at line 111 of file PlaneGeo.cxx.

Referenced by initializeWireEnds().

constexpr std::size_t geo::details::ActiveAreaCalculator::kLastWireEnd = 3
staticprivate

Definition at line 114 of file PlaneGeo.cxx.

Referenced by initializeWireEnds().

constexpr std::size_t geo::details::ActiveAreaCalculator::kLastWireStart = 2
staticprivate

Definition at line 113 of file PlaneGeo.cxx.

Referenced by initializeWireEnds().

PlaneGeo const& geo::details::ActiveAreaCalculator::plane
private

Plane to work on.

Definition at line 116 of file PlaneGeo.cxx.

Projection_t geo::details::ActiveAreaCalculator::wireEnds[4]
private

Cache: wire end projections.

Definition at line 122 of file PlaneGeo.cxx.

double const geo::details::ActiveAreaCalculator::wMargin = 0.0
private

Margin subtracted from each side of width.

Definition at line 117 of file PlaneGeo.cxx.

Referenced by applyMargin().


The documentation for this struct was generated from the following file: