LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
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 132 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 138 of file DBScanAlg.cxx.

144  : fBound(b), fEps(), fMaxWidth(maxWidth), fWireDist(wireDist), fBadWireSum(badWireSum)
145  {
146  fEps[0] = eps;
147  fEps[1] = eps2;
148  }
std::vector< unsigned int > & fBadWireSum
Definition: DBScanAlg.cxx:137
const BoundingBox & fBound
Definition: DBScanAlg.cxx:133

Member Function Documentation

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

Definition at line 150 of file DBScanAlg.cxx.

151  {
152  BoundingBox c;
153  c.edges[0].first = c.edges[0].second = (b.edges[0].first + b.edges[0].second) / 2.0;
154  c.edges[1].first = c.edges[1].second = (b.edges[1].first + b.edges[1].second) / 2.0;
155  return c;
156  }
RTree::BoundingBox BoundingBox
Definition: DBScanAlg.h:33
BoundingBox AcceptFindNeighbors::center ( ) const
inline

Definition at line 157 of file DBScanAlg.cxx.

References center().

Referenced by center().

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

Definition at line 159 of file DBScanAlg.cxx.

References util::abs(), lar::util::absDiff(), and e.

160  {
161  // Precomupation of a few things...box centers, wire bridging
162  // quantities, etc...
163  double bCenter0 = center(b).edges[0].first;
164  double bCenter1 = center(b).edges[1].first;
165  double tCenter0 = center().edges[0].first; // "t" is for test-point
166  double tCenter1 = center().edges[1].first;
167  // widths in the time direction
168  double bWidth = std::abs(b.edges[1].second - b.edges[1].first);
169  double tWidth = std::abs(fBound.edges[1].second - fBound.edges[1].first);
170  // bad channel counting
171  unsigned int wire1 = (unsigned int)(tCenter0 / fWireDist + 0.5);
172  unsigned int wire2 = (unsigned int)(bCenter0 / fWireDist + 0.5);
173  // Clamp the wize number to something resonably.
175  if (wire1 < fBadWireSum.size()) wire1 = fBadWireSum.size();
176  if (wire2 < fBadWireSum.size()) wire2 = fBadWireSum.size();
177  // The getSimilarity[2] wirestobridge calculation is asymmetric,
178  // but is plugged into the cache symmetrically.I am assuming that
179  // this is OK because the wires that are hit cannot be bad.
180  unsigned int wirestobridge = lar::util::absDiff(fBadWireSum[wire1], fBadWireSum[wire2]);
181  double cmtobridge = wirestobridge * fWireDist;
182 
183  double sim = std::abs(tCenter0 - bCenter0) - cmtobridge;
184  sim *= sim; // square it
185 
186  if (std::abs(tCenter0 - bCenter0) > 1e-10) {
187  cmtobridge *= std::abs((tCenter1 - bCenter1) / (tCenter0 - bCenter0));
188  }
189  double sim2 = std::abs(tCenter1 - bCenter1) - cmtobridge;
190  sim2 *= sim2; // square it
191 
192  double k = 0.1;
193  double WFactor = (exp(4.6 * ((tWidth * tWidth) + (bWidth * bWidth)))) * k; // ??
194  // We clamp WFactor on [ 1.0, 6.25 ]
195  if (WFactor < 1.0) WFactor = 1.0;
196  if (WFactor > 6.25) WFactor = 6.25;
197 
198  // Now we implement the test...see FindNeighbors
199  return (((sim) / (fEps[0] * fEps[0])) + ((sim2) / (fEps[1] * fEps[1] * (WFactor))) <= 1);
200  }
std::vector< unsigned int > & fBadWireSum
Definition: DBScanAlg.cxx:137
constexpr auto abs(T v)
Returns the absolute value of the argument.
const BoundingBox & fBound
Definition: DBScanAlg.cxx:133
Monte Carlo Simulation.
constexpr auto absDiff(A const &a, B const &b)
Returns the absolute value of the difference between two values.
Definition: NumericUtils.h:69
Float_t e
Definition: plot.C:35
BoundingBox center() const
Definition: DBScanAlg.cxx:157
BoundingBox AcceptFindNeighbors::nearestPoint ( const BoundingBox b) const
inline

Definition at line 201 of file DBScanAlg.cxx.

References n.

202  {
203  BoundingBox n;
204  BoundingBox c = center();
205  for (int i = 0; i < 2; ++i) {
206  // The work for finding the nearest point is the same in both
207  // dimensions
208  if (b.edges[i].first > c.edges[i].second) {
209  // Our point is lower than the low edge of the box
210  n.edges[i].first = n.edges[i].second = b.edges[i].first;
211  }
212  else if (b.edges[0].second < c.edges[0].first) {
213  // Our point is higher than the high edge of the box
214  n.edges[i].first = n.edges[i].second = b.edges[i].second;
215  }
216  else {
217  // In this dimension our point lies within the boxes bounds
218  n.edges[i].first = n.edges[i].second = c.edges[i].first;
219  }
220  }
221  // Now give the time dimension a width
222  n.edges[1].first -= fMaxWidth / 2.0;
223  n.edges[1].second += fMaxWidth / 2.0;
224  return n;
225  }
RTree::BoundingBox BoundingBox
Definition: DBScanAlg.h:33
Char_t n[5]
BoundingBox center() const
Definition: DBScanAlg.cxx:157
bool AcceptFindNeighbors::operator() ( const RTree::Node *const  node) const
inline

Definition at line 226 of file DBScanAlg.cxx.

227  {
228  // if the our point overlaps the bounding box, accept immediately
229  if (fBound.overlaps(node->bound)) return true;
230  // No overlap, so compare to the nearest point on the bounding box
231  // under the assumption that the maximum width applies for that
232  // point
233  return isNear(nearestPoint(node->bound));
234  }
bool isNear(const BoundingBox &b) const
Definition: DBScanAlg.cxx:159
const BoundingBox & fBound
Definition: DBScanAlg.cxx:133
BoundingBox nearestPoint(const BoundingBox &b) const
Definition: DBScanAlg.cxx:201
bool AcceptFindNeighbors::operator() ( const RTree::Leaf *const  leaf) const
inline

Definition at line 235 of file DBScanAlg.cxx.

235 { return isNear(leaf->bound); }
bool isNear(const BoundingBox &b) const
Definition: DBScanAlg.cxx:159

Member Data Documentation

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

Definition at line 137 of file DBScanAlg.cxx.

const BoundingBox& AcceptFindNeighbors::fBound

Definition at line 133 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fEps[2]

Definition at line 134 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fMaxWidth

Definition at line 135 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fWireDist

Definition at line 136 of file DBScanAlg.cxx.


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