All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
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.

Definition at line 104 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.

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:1127
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
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
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
PlaneGeo const & plane
Plane to work on.
Definition: PlaneGeo.cxx:116
Vector GetIncreasingWireDirection() const
Returns the direction of increasing wires.
Definition: PlaneGeo.h:457
Projection_t wireEnds[4]
Cache: wire end projections.
Definition: PlaneGeo.cxx:122
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
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
recob::tracking::Vector_t Vector_t
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:411
geo::PlaneGeo::Rect activeArea
Result.
Definition: PlaneGeo.cxx:119
void geo::details::ActiveAreaCalculator::applyMargin ( )
inlineprivate

Definition at line 377 of file PlaneGeo.cxx.

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.

423  { return std::abs(a - b) <= tol; }
auto const tol
Definition: SurfXYZTest.cc:16
process_name gaushit a
T abs(T value)
void geo::details::ActiveAreaCalculator::includeAllWireEnds ( )
inlineprivate

Definition at line 150 of file PlaneGeo.cxx.

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.

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:157
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:1107
static constexpr std::size_t kFirstWireStart
Definition: PlaneGeo.cxx:111
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
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:344
static constexpr std::size_t kLastWireEnd
Definition: PlaneGeo.cxx:114
void GetEnd(double *xyz) const
Definition: WireGeo.h:163
static constexpr std::size_t kFirstWireEnd
Definition: PlaneGeo.cxx:112
const WireGeo & LastWire() const
Return the last wire in the plane.
Definition: PlaneGeo.h:350
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.

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

Definition at line 98 of file PlaneGeo.cxx.

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.

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.

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

Margin subtracted from each side of depth.

Definition at line 118 of file PlaneGeo.cxx.

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

Definition at line 112 of file PlaneGeo.cxx.

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

Definition at line 111 of file PlaneGeo.cxx.

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

Definition at line 114 of file PlaneGeo.cxx.

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

Definition at line 113 of file PlaneGeo.cxx.

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.


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