LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 142 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 148 of file DBScanAlg.cxx.

151  :fBound(b), fEps(), fMaxWidth(maxWidth), fWireDist(wireDist)
152  ,fBadWireSum(badWireSum)
153  {
154  fEps[0] = eps;
155  fEps[1] = eps2;
156  }
const BoundingBox & fBound
Definition: DBScanAlg.cxx:143
std::vector< unsigned int > & fBadWireSum
Definition: DBScanAlg.cxx:147

Member Function Documentation

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

Definition at line 158 of file DBScanAlg.cxx.

References RStarBoundingBox< dimensions >::edges.

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

Definition at line 166 of file DBScanAlg.cxx.

References center().

Referenced by center().

166 { return center(fBound); }
const BoundingBox & fBound
Definition: DBScanAlg.cxx:143
BoundingBox center() const
Definition: DBScanAlg.cxx:166
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.

References util::absDiff(), e, and RStarBoundingBox< dimensions >::edges.

168  {
169  // Precomupation of a few things...box centers, wire bridging
170  // quantities, etc...
171  double bCenter0 = center(b).edges[0].first;
172  double bCenter1 = center(b).edges[1].first;
173  double tCenter0 = center().edges[0].first; // "t" is for test-point
174  double tCenter1 = center().edges[1].first;
175  // widths in the time direction
176  double bWidth = std::abs( b.edges[1].second - b.edges[1].first);
177  double tWidth = std::abs(fBound.edges[1].second - fBound.edges[1].first);
178  // bad channel counting
179  unsigned int wire1 = (unsigned int) (tCenter0/fWireDist + 0.5);
180  unsigned int wire2 = (unsigned int) (bCenter0/fWireDist + 0.5);
181  // Clamp the wize number to something resonably.
183  if (wire1 < fBadWireSum.size()) wire1 = fBadWireSum.size();
184  if (wire2 < fBadWireSum.size()) wire2 = fBadWireSum.size();
185  // The getSimilarity[2] wirestobridge calculation is asymmetric,
186  // but is plugged into the cache symmetrically.I am assuming that
187  // this is OK because the wires that are hit cannot be bad.
188  unsigned int wirestobridge = util::absDiff(fBadWireSum[wire1], fBadWireSum[wire2]);
189  double cmtobridge = wirestobridge*fWireDist;
190 
191  // getSimilarity()
192  double sim = std::abs(tCenter0 - bCenter0) - cmtobridge;
193  sim*=sim; // square it
194 
195  // getSimilarity2()
196  if ( std::abs(tCenter0 - bCenter0) > 1e-10 ) {
197  cmtobridge *= std::abs((tCenter1-bCenter1)/(tCenter0-bCenter0));
198  }
199  double sim2 = std::abs(tCenter1 - bCenter1) - cmtobridge;
200  sim2 *= sim2; // square it
201 
202  // getWidthFactor()
203  // double k=0.13; // see the comments on getWidthFactor
204  // double k=0.78; // as I don't know where these came from
205  // double k=4.5;
206  // double k=1.96;
207  double k=0.1;
208  double WFactor = (exp(4.6*((tWidth*tWidth)+(bWidth*bWidth))))*k; // ??
209  // We clamp WFactor on [ 1.0, 6.25 ]
210  if (WFactor<1.0) WFactor = 1.0;
211  if (WFactor>6.25) WFactor = 6.25;
212 
213  // Now we implement the test...see FindNeighbors
214  return (((sim )/(fEps[0]*fEps[0]) ) +
215  ((sim2)/(fEps[1]*fEps[1]*(WFactor))) <= 1 );
216  }
const BoundingBox & fBound
Definition: DBScanAlg.cxx:143
Monte Carlo Simulation.
std::vector< unsigned int > & fBadWireSum
Definition: DBScanAlg.cxx:147
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]
Float_t e
Definition: plot.C:34
BoundingBox center() const
Definition: DBScanAlg.cxx:166
BoundingBox AcceptFindNeighbors::nearestPoint ( const BoundingBox b) const
inline

Definition at line 217 of file DBScanAlg.cxx.

References RStarBoundingBox< dimensions >::edges, and n.

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

Definition at line 239 of file DBScanAlg.cxx.

References RStarBoundingBox< dimensions >::overlaps().

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

Definition at line 247 of file DBScanAlg.cxx.

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

Member Data Documentation

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

Definition at line 147 of file DBScanAlg.cxx.

const BoundingBox& AcceptFindNeighbors::fBound

Definition at line 143 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fEps[2]

Definition at line 144 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fMaxWidth

Definition at line 145 of file DBScanAlg.cxx.

double AcceptFindNeighbors::fWireDist

Definition at line 146 of file DBScanAlg.cxx.


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