Public Member Functions | Public Attributes | List of all members
AcceptFindNeighbors Struct Reference

Public Member Functions

 AcceptFindNeighbors (const BoundingBox &b, double eps, double eps2, double maxWidth, double wireDist, std::vector< unsigned int > &badWireSum)
 
BoundingBox center (const BoundingBox &b) const
 
BoundingBox center () const
 
bool isNear (const BoundingBox &b) const
 
BoundingBox nearestPoint (const BoundingBox &b) const
 
bool operator() (const RTree::Node *const node) const
 
bool operator() (const RTree::Leaf *const leaf) const
 

Public Attributes

const BoundingBoxfBound
 
double fEps [2]
 
double fMaxWidth
 
double fWireDist
 
std::vector< unsigned int > & fBadWireSum
 

Detailed Description

Definition at line 135 of file DBScanAlg.cxx.

Constructor & Destructor Documentation

AcceptFindNeighbors::AcceptFindNeighbors ( const BoundingBox b,
double  eps,
double  eps2,
double  maxWidth,
double  wireDist,
std::vector< unsigned int > &  badWireSum 
)
inline

Definition at line 141 of file DBScanAlg.cxx.

147  : fBound(b), fEps(), fMaxWidth(maxWidth), fWireDist(wireDist), fBadWireSum(badWireSum)
148  {
149  fEps[0] = eps;
150  fEps[1] = eps2;
151  }
std::vector< unsigned int > & fBadWireSum
Definition: DBScanAlg.cxx:140
const BoundingBox & fBound
Definition: DBScanAlg.cxx:136

Member Function Documentation

BoundingBox AcceptFindNeighbors::center ( const BoundingBox b) const
inline

Definition at line 154 of file DBScanAlg.cxx.

155  {
156  BoundingBox c;
157  c.edges[0].first = c.edges[0].second = (b.edges[0].first + b.edges[0].second) / 2.0;
158  c.edges[1].first = c.edges[1].second = (b.edges[1].first + b.edges[1].second) / 2.0;
159  return c;
160  }
std::pair< double, double > edges[dimensions]
BoundingBox AcceptFindNeighbors::center ( ) const
inline

Definition at line 162 of file DBScanAlg.cxx.

163  {
164  return center(fBound);
165  }
const BoundingBox & fBound
Definition: DBScanAlg.cxx:136
BoundingBox center() const
Definition: DBScanAlg.cxx:162
bool AcceptFindNeighbors::isNear ( const BoundingBox b) const
inline
Todo:
activating these should throw a warning or something

Definition at line 168 of file DBScanAlg.cxx.

169  {
170  // Precomupation of a few things...box centers, wire bridging
171  // quantities, etc...
172  double bCenter0 = center(b).edges[0].first;
173  double bCenter1 = center(b).edges[1].first;
174  double tCenter0 = center().edges[0].first; // "t" is for test-point
175  double tCenter1 = center().edges[1].first;
176  // widths in the time direction
177  double bWidth = std::abs(b.edges[1].second - b.edges[1].first);
178  double tWidth = std::abs(fBound.edges[1].second - fBound.edges[1].first);
179  // bad channel counting
180  unsigned int wire1 = (unsigned int)(tCenter0 / fWireDist + 0.5);
181  unsigned int wire2 = (unsigned int)(bCenter0 / fWireDist + 0.5);
182  // Clamp the wize number to something resonably.
183  ///\todo activating these should throw a warning or something
184  if (wire1 < fBadWireSum.size()) wire1 = fBadWireSum.size();
185  if (wire2 < fBadWireSum.size()) wire2 = fBadWireSum.size();
186  // The getSimilarity[2] wirestobridge calculation is asymmetric,
187  // but is plugged into the cache symmetrically.I am assuming that
188  // this is OK because the wires that are hit cannot be bad.
189  unsigned int wirestobridge = util::absDiff(fBadWireSum[wire1], fBadWireSum[wire2]);
190  double cmtobridge = wirestobridge * fWireDist;
191 
192  double sim = std::abs(tCenter0 - bCenter0) - cmtobridge;
193  sim *= sim; // square it
194 
195  if (std::abs(tCenter0 - bCenter0) > 1e-10) {
196  cmtobridge *= std::abs((tCenter1 - bCenter1) / (tCenter0 - bCenter0));
197  }
198  double sim2 = std::abs(tCenter1 - bCenter1) - cmtobridge;
199  sim2 *= sim2; // square it
200 
201  double k = 0.1;
202  double WFactor = (exp(4.6 * ((tWidth * tWidth) + (bWidth * bWidth)))) * k; // ??
203  // We clamp WFactor on [ 1.0, 6.25 ]
204  if (WFactor < 1.0) WFactor = 1.0;
205  if (WFactor > 6.25) WFactor = 6.25;
206 
207  // Now we implement the test...see FindNeighbors
208  return (((sim) / (fEps[0] * fEps[0])) + ((sim2) / (fEps[1] * fEps[1] * (WFactor))) <= 1);
209  }
std::vector< unsigned int > & fBadWireSum
Definition: DBScanAlg.cxx:140
T abs(T value)
const double e
const BoundingBox & fBound
Definition: DBScanAlg.cxx:136
Code to link reconstructed objects back to the MC truth information.
constexpr auto absDiff(A const &a, B const &b)
Returns the absolute value of the difference between two values.
Definition: NumericUtils.h:43
std::pair< double, double > edges[dimensions]
BoundingBox center() const
Definition: DBScanAlg.cxx:162
BoundingBox AcceptFindNeighbors::nearestPoint ( const BoundingBox b) const
inline

Definition at line 211 of file DBScanAlg.cxx.

212  {
213  BoundingBox n;
214  BoundingBox c = center();
215  for (int i = 0; i < 2; ++i) {
216  // The work for finding the nearest point is the same in both
217  // dimensions
218  if (b.edges[i].first > c.edges[i].second) {
219  // Our point is lower than the low edge of the box
220  n.edges[i].first = n.edges[i].second = b.edges[i].first;
221  }
222  else if (b.edges[0].second < c.edges[0].first) {
223  // Our point is higher than the high edge of the box
224  n.edges[i].first = n.edges[i].second = b.edges[i].second;
225  }
226  else {
227  // In this dimension our point lies within the boxes bounds
228  n.edges[i].first = n.edges[i].second = c.edges[i].first;
229  }
230  }
231  // Now give the time dimension a width
232  n.edges[1].first -= fMaxWidth / 2.0;
233  n.edges[1].second += fMaxWidth / 2.0;
234  return n;
235  }
std::void_t< T > n
std::pair< double, double > edges[dimensions]
BoundingBox center() const
Definition: DBScanAlg.cxx:162
bool AcceptFindNeighbors::operator() ( const RTree::Node *const  node) const
inline

Definition at line 237 of file DBScanAlg.cxx.

238  {
239  // if the our point overlaps the bounding box, accept immediately
240  if (fBound.overlaps(node->bound)) return true;
241  // No overlap, so compare to the nearest point on the bounding box
242  // under the assumption that the maximum width applies for that
243  // point
244  return isNear(nearestPoint(node->bound));
245  }
bool isNear(const BoundingBox &b) const
Definition: DBScanAlg.cxx:168
const BoundingBox & fBound
Definition: DBScanAlg.cxx:136
bool overlaps(const RStarBoundingBox< dimensions > &bb) const
BoundingBox nearestPoint(const BoundingBox &b) const
Definition: DBScanAlg.cxx:211
bool AcceptFindNeighbors::operator() ( const RTree::Leaf *const  leaf) const
inline

Definition at line 247 of file DBScanAlg.cxx.

248  {
249  return isNear(leaf->bound);
250  }
bool isNear(const BoundingBox &b) const
Definition: DBScanAlg.cxx:168

Member Data Documentation

std::vector<unsigned int>& AcceptFindNeighbors::fBadWireSum

Definition at line 140 of file DBScanAlg.cxx.

const BoundingBox& AcceptFindNeighbors::fBound

Definition at line 136 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fEps[2]

Definition at line 137 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fMaxWidth

Definition at line 138 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fWireDist

Definition at line 139 of file DBScanAlg.cxx.


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