LArSoft  v09_90_00
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 131 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 137 of file DBScanAlg.cxx.

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

Member Function Documentation

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

Definition at line 149 of file DBScanAlg.cxx.

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

Definition at line 156 of file DBScanAlg.cxx.

References center().

Referenced by center().

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

Definition at line 158 of file DBScanAlg.cxx.

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

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

Definition at line 200 of file DBScanAlg.cxx.

References n.

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

Definition at line 225 of file DBScanAlg.cxx.

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

Definition at line 234 of file DBScanAlg.cxx.

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

Member Data Documentation

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

Definition at line 136 of file DBScanAlg.cxx.

const BoundingBox& AcceptFindNeighbors::fBound

Definition at line 132 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fEps[2]

Definition at line 133 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fMaxWidth

Definition at line 134 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fWireDist

Definition at line 135 of file DBScanAlg.cxx.


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