LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_cluster3d::kdTree Class Reference

kdTree class definiton More...

#include "kdTree.h"

Classes

class  KdTreeNode
 define a kd tree node More...
 

Public Types

using KdTreeNodeVec = std::vector< KdTreeNode >
 
using KdTreeNodeList = std::list< KdTreeNode >
 
using Hit3DVec = std::vector< const reco::ClusterHit3D * >
 
using CandPair = std::pair< double, const reco::ClusterHit3D * >
 
using CandPairList = std::list< CandPair >
 

Public Member Functions

 kdTree ()
 Default Constructor. More...
 
 kdTree (fhicl::ParameterSet const &pset)
 Constructor. More...
 
 ~kdTree ()
 Destructor. More...
 
void configure (fhicl::ParameterSet const &pset)
 Configure our kdTree... More...
 
KdTreeNodeBuildKdTree (Hit3DVec::iterator, Hit3DVec::iterator, KdTreeNodeList &, int depth=0) const
 Given an input set of ClusterHit3D objects, build a kd tree structure. More...
 
size_t FindNearestNeighbors (const reco::ClusterHit3D *, const KdTreeNode &, CandPairList &, float &) const
 
bool FindEntry (const reco::ClusterHit3D *, const KdTreeNode &, CandPairList &, float &, bool &, int) const
 
bool FindEntryBrute (const reco::ClusterHit3D *, const KdTreeNode &, int) const
 
KdTreeNode BuildKdTree (const reco::HitPairList &, KdTreeNodeList &) const
 Given an input HitPairList, build out the map of nearest neighbors. More...
 
KdTreeNode BuildKdTree (const reco::HitPairListPtr &, KdTreeNodeList &) const
 Given an input HitPairListPtr, build out the map of nearest neighbors. More...
 
float getTimeToExecute () const
 

Private Member Functions

bool consistentPairs (const reco::ClusterHit3D *pair1, const reco::ClusterHit3D *pair2, float &hitSeparation) const
 The bigger question: are two pairs of hits consistent? More...
 
float DistanceBetweenNodes (const reco::ClusterHit3D *, const reco::ClusterHit3D *) const
 
float DistanceBetweenNodesYZ (const reco::ClusterHit3D *, const reco::ClusterHit3D *) const
 

Private Attributes

bool fEnableMonitoring
 
float fTimeToBuild
 
float fPairSigmaPeakTime
 Consider hits consistent if "significance" less than this. More...
 
float fRefLeafBestDist
 Set neighborhood distance to this when ref leaf found. More...
 
int fMaxWireDeltas
 Maximum total number of delta wires. More...
 

Detailed Description

kdTree class definiton

Definition at line 31 of file kdTree.h.

Member Typedef Documentation

using lar_cluster3d::kdTree::CandPair = std::pair<double, const reco::ClusterHit3D*>

Definition at line 83 of file kdTree.h.

Definition at line 84 of file kdTree.h.

Definition at line 70 of file kdTree.h.

Definition at line 69 of file kdTree.h.

Definition at line 68 of file kdTree.h.

Constructor & Destructor Documentation

lar_cluster3d::kdTree::kdTree ( )
inline

Default Constructor.

Definition at line 36 of file kdTree.h.

37  : fEnableMonitoring(false)
38  , fTimeToBuild(0.)
39  , fPairSigmaPeakTime(0.)
40  , fRefLeafBestDist(0.)
41  , fMaxWireDeltas(0)
42  {}
float fRefLeafBestDist
Set neighborhood distance to this when ref leaf found.
Definition: kdTree.h:120
float fPairSigmaPeakTime
Consider hits consistent if "significance" less than this.
Definition: kdTree.h:119
int fMaxWireDeltas
Maximum total number of delta wires.
Definition: kdTree.h:121
lar_cluster3d::kdTree::kdTree ( fhicl::ParameterSet const &  pset)

Constructor.

Parameters
pset

Definition at line 24 of file kdTree.cxx.

References configure().

25  {
26  this->configure(pset);
27  }
void configure(fhicl::ParameterSet const &pset)
Configure our kdTree...
Definition: kdTree.cxx:35
lar_cluster3d::kdTree::~kdTree ( )

Destructor.

Definition at line 31 of file kdTree.cxx.

31 {}

Member Function Documentation

kdTree::KdTreeNode & lar_cluster3d::kdTree::BuildKdTree ( Hit3DVec::iterator  first,
Hit3DVec::iterator  last,
KdTreeNodeList kdTreeNodeContainer,
int  depth = 0 
) const

Given an input set of ClusterHit3D objects, build a kd tree structure.

Parameters
hitPairListThe input list of 3D hits to run clustering on
kdTreeVecContainer for the nodes

Definition at line 109 of file kdTree.cxx.

References reco::ClusterHit3D::getPosition(), art::left(), art::right(), lar_cluster3d::kdTree::KdTreeNode::xPlane, lar_cluster3d::kdTree::KdTreeNode::yPlane, and lar_cluster3d::kdTree::KdTreeNode::zPlane.

Referenced by BuildKdTree(), lar_cluster3d::DBScanAlg::Cluster3DHits(), lar_cluster3d::MinSpanTreeAlg::Cluster3DHits(), and lar_cluster3d::MSTPathFinder::ModifyClusters().

113  {
114  // Ok, so if the input list is more than one element then we have work to do... but if less then handle end condition
115  if (std::distance(first, last) < 2) {
116  if (first != last)
117  kdTreeNodeContainer.emplace_back(*first);
118  else
119  kdTreeNodeContainer.emplace_back(KdTreeNode());
120  }
121  // Otherwise we need to keep splitting...
122  else {
123  // First task is to find "d" with the largest range. We need to find the min/max for the four dimensions
124  std::pair<Hit3DVec::iterator, Hit3DVec::iterator> minMaxXPair = std::minmax_element(
125  first, last, [](const reco::ClusterHit3D* left, const reco::ClusterHit3D* right) {
126  return left->getPosition()[0] < right->getPosition()[0];
127  });
128  std::pair<Hit3DVec::iterator, Hit3DVec::iterator> minMaxYPair = std::minmax_element(
129  first, last, [](const reco::ClusterHit3D* left, const reco::ClusterHit3D* right) {
130  return left->getPosition()[1] < right->getPosition()[1];
131  });
132  std::pair<Hit3DVec::iterator, Hit3DVec::iterator> minMaxZPair = std::minmax_element(
133  first, last, [](const reco::ClusterHit3D* left, const reco::ClusterHit3D* right) {
134  return left->getPosition()[2] < right->getPosition()[2];
135  });
136 
137  std::vector<float> rangeVec(3, 0.);
138 
139  rangeVec[0] =
140  (*minMaxXPair.second)->getPosition()[0] - (*minMaxXPair.first)->getPosition()[0];
141  rangeVec[1] =
142  (*minMaxYPair.second)->getPosition()[1] - (*minMaxYPair.first)->getPosition()[1];
143  rangeVec[2] =
144  (*minMaxZPair.second)->getPosition()[2] - (*minMaxZPair.first)->getPosition()[2];
145 
146  std::vector<float>::iterator maxRangeItr = std::max_element(rangeVec.begin(), rangeVec.end());
147 
148  size_t maxRangeIdx = std::distance(rangeVec.begin(), maxRangeItr);
149 
150  // Sort the list so we can do the split
151  std::sort(first, last, [maxRangeIdx](const auto& left, const auto& right) {
152  return left->getPosition()[maxRangeIdx] < right->getPosition()[maxRangeIdx];
153  });
154 
155  size_t middleElem = std::distance(first, last) / 2;
156  Hit3DVec::iterator middleItr = first;
157 
158  std::advance(middleItr, middleElem);
159 
160  // Take care of the special case where the value of the median may be repeated so we actually want to make sure we point at the first occurence
161  if (std::distance(first, middleItr) > 1) {
162  while (middleItr != first + 1) {
163  if (!((*(middleItr - 1))->getPosition()[maxRangeIdx] <
164  (*middleItr)->getPosition()[maxRangeIdx]))
165  middleItr--;
166  else
167  break;
168  }
169  }
170 
172  float axisVal = 0.5 * ((*middleItr)->getPosition()[maxRangeIdx] +
173  (*(middleItr - 1))->getPosition()[maxRangeIdx]);
174  KdTreeNode& leftNode = BuildKdTree(first, middleItr, kdTreeNodeContainer, depth + 1);
175  KdTreeNode& rightNode = BuildKdTree(middleItr, last, kdTreeNodeContainer, depth + 1);
176 
177  kdTreeNodeContainer.push_back(KdTreeNode(axis[maxRangeIdx], axisVal, leftNode, rightNode));
178  }
179 
180  return kdTreeNodeContainer.back();
181  }
intermediate_table::iterator iterator
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:102
const Eigen::Vector3f getPosition() const
Definition: Cluster3D.h:155
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
KdTreeNode & BuildKdTree(Hit3DVec::iterator, Hit3DVec::iterator, KdTreeNodeList &, int depth=0) const
Given an input set of ClusterHit3D objects, build a kd tree structure.
Definition: kdTree.cxx:109
kdTree::KdTreeNode lar_cluster3d::kdTree::BuildKdTree ( const reco::HitPairList hitPairList,
KdTreeNodeList kdTreeNodeContainer 
) const

Given an input HitPairList, build out the map of nearest neighbors.

Definition at line 48 of file kdTree.cxx.

References BuildKdTree(), fEnableMonitoring, and fTimeToBuild.

50  {
51  // The first task is to build the kd tree
52  cet::cpu_timer theClockBuildNeighborhood;
53 
54  if (fEnableMonitoring) theClockBuildNeighborhood.start();
55 
56  // The input is a list and we need to copy to a vector so we can sort ranges
57  Hit3DVec hit3DVec;
58 
59  hit3DVec.reserve(hitPairList.size());
60 
61  for (const auto& hit : hitPairList)
62  hit3DVec.emplace_back(&hit);
63 
64  KdTreeNode topNode = BuildKdTree(hit3DVec.begin(), hit3DVec.end(), kdTreeNodeContainer);
65 
66  if (fEnableMonitoring) {
67  theClockBuildNeighborhood.stop();
68  fTimeToBuild = theClockBuildNeighborhood.accumulated_real_time();
69  }
70 
71  return topNode;
72  }
std::vector< const reco::ClusterHit3D * > Hit3DVec
Definition: kdTree.h:70
Detector simulation of raw signals on wires.
KdTreeNode & BuildKdTree(Hit3DVec::iterator, Hit3DVec::iterator, KdTreeNodeList &, int depth=0) const
Given an input set of ClusterHit3D objects, build a kd tree structure.
Definition: kdTree.cxx:109
kdTree::KdTreeNode lar_cluster3d::kdTree::BuildKdTree ( const reco::HitPairListPtr hitPairList,
KdTreeNodeList kdTreeNodeContainer 
) const

Given an input HitPairListPtr, build out the map of nearest neighbors.

Definition at line 75 of file kdTree.cxx.

References BuildKdTree(), fEnableMonitoring, fTimeToBuild, reco::ClusterHit3D::HITINVIEW0, reco::ClusterHit3D::HITINVIEW1, and reco::ClusterHit3D::HITINVIEW2.

77  {
78 
79  // The first task is to build the kd tree
80  cet::cpu_timer theClockBuildNeighborhood;
81 
82  if (fEnableMonitoring) theClockBuildNeighborhood.start();
83 
84  // The input is a list and we need to copy to a vector so we can sort ranges
85  //Hit3DVec hit3DVec{std::begin(hitPairList),std::end(hitPairList)};
86  Hit3DVec hit3DVec;
87 
88  hit3DVec.reserve(hitPairList.size());
89 
90  for (const auto& hit3D : hitPairList) {
91  // Make sure all the bits used by the clustering stage have been cleared
94  for (const auto& hit2D : hit3D->getHits())
95  if (hit2D) hit2D->clearStatusBits(0xFFFFFFFF);
96  hit3DVec.emplace_back(hit3D);
97  }
98 
99  KdTreeNode topNode = BuildKdTree(hit3DVec.begin(), hit3DVec.end(), kdTreeNodeContainer);
100 
101  if (fEnableMonitoring) {
102  theClockBuildNeighborhood.stop();
103  fTimeToBuild = theClockBuildNeighborhood.accumulated_real_time();
104  }
105 
106  return topNode;
107  }
Hit contains 2D hit from view 2 (w plane)
Definition: Cluster3D.h:113
Hit contains 2D hit from view 0 (u plane)
Definition: Cluster3D.h:111
std::vector< const reco::ClusterHit3D * > Hit3DVec
Definition: kdTree.h:70
Hit contains 2D hit from view 1 (v plane)
Definition: Cluster3D.h:112
KdTreeNode & BuildKdTree(Hit3DVec::iterator, Hit3DVec::iterator, KdTreeNodeList &, int depth=0) const
Given an input set of ClusterHit3D objects, build a kd tree structure.
Definition: kdTree.cxx:109
void lar_cluster3d::kdTree::configure ( fhicl::ParameterSet const &  pset)

Configure our kdTree...

Parameters
ParameterSetThe input set of parameters for configuration

Definition at line 35 of file kdTree.cxx.

References fEnableMonitoring, fMaxWireDeltas, fPairSigmaPeakTime, fRefLeafBestDist, fTimeToBuild, and fhicl::ParameterSet::get().

Referenced by kdTree().

36  {
37  fEnableMonitoring = pset.get<bool>("EnableMonitoring", true);
38  fPairSigmaPeakTime = pset.get<float>("PairSigmaPeakTime", 3.);
39  fRefLeafBestDist = pset.get<float>("RefLeafBestDist", 0.5);
40  fMaxWireDeltas = pset.get<int>("MaxWireDeltas", 3);
41 
42  fTimeToBuild = 0;
43 
44  return;
45  }
float fRefLeafBestDist
Set neighborhood distance to this when ref leaf found.
Definition: kdTree.h:120
float fPairSigmaPeakTime
Consider hits consistent if "significance" less than this.
Definition: kdTree.h:119
int fMaxWireDeltas
Maximum total number of delta wires.
Definition: kdTree.h:121
bool lar_cluster3d::kdTree::consistentPairs ( const reco::ClusterHit3D pair1,
const reco::ClusterHit3D pair2,
float &  hitSeparation 
) const
private

The bigger question: are two pairs of hits consistent?

Definition at line 297 of file kdTree.cxx.

References util::abs(), DistanceBetweenNodesYZ(), fPairSigmaPeakTime, reco::ClusterHit3D::getAvePeakTime(), reco::ClusterHit3D::getSigmaPeakTime(), and reco::ClusterHit3D::getWireIDs().

Referenced by FindEntry(), and FindNearestNeighbors().

300  {
301  // Strategy: We consider comparing "hit pairs" which may consist of 2 or 3 actual hits.
302  // Also, if only pairs, they can be U-V, U-W or V-W so we can't assume which views we have
303  // So do a simplified comparison:
304  // 1) compare the pair times and require "overlap" (in the sense of hit pair production)
305  // 2) look at distance between pairs in each of the wire directions
306 
307  bool consistent(false);
308 
309  if (bestDist < std::numeric_limits<float>::max() &&
310  pair1->getWireIDs()[0].Cryostat == pair2->getWireIDs()[0].Cryostat &&
311  pair1->getWireIDs()[0].TPC == pair2->getWireIDs()[0].TPC) {
312  // Loose constraint to weed out the obviously bad combinations
313  // So this is not strictly correct but is close enough and should save computation time...
314  if (std::fabs(pair1->getAvePeakTime() - pair2->getAvePeakTime()) <
315  fPairSigmaPeakTime * (pair1->getSigmaPeakTime() + pair2->getSigmaPeakTime())) {
316  int wireDeltas[] = {0, 0, 0};
317 
318  // Now go through the hits and compare view by view to look for delta wire and tigher constraint on delta t
319  for (size_t idx = 0; idx < 3; idx++)
320  wireDeltas[idx] =
321  std::abs(int(pair1->getWireIDs()[idx].Wire) - int(pair2->getWireIDs()[idx].Wire));
322 
323  // put wire deltas in order...
324  std::sort(wireDeltas, wireDeltas + 3);
325 
326  // Requirement to be considered a nearest neighbor
327  if (wireDeltas[2] < 3) {
328  float hitSeparation = std::max(float(0.0001), DistanceBetweenNodesYZ(pair1, pair2));
329 
330  // Final cut...
331  if (hitSeparation < bestDist) {
332  bestDist = hitSeparation;
333  consistent = true;
334  }
335  }
336  }
337  }
338 
339  return consistent;
340  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
float getSigmaPeakTime() const
Definition: Cluster3D.h:162
float getAvePeakTime() const
Definition: Cluster3D.h:160
float DistanceBetweenNodesYZ(const reco::ClusterHit3D *, const reco::ClusterHit3D *) const
Definition: kdTree.cxx:342
float fPairSigmaPeakTime
Consider hits consistent if "significance" less than this.
Definition: kdTree.h:119
const std::vector< geo::WireID > & getWireIDs() const
Definition: Cluster3D.h:170
float lar_cluster3d::kdTree::DistanceBetweenNodes ( const reco::ClusterHit3D node1,
const reco::ClusterHit3D node2 
) const
private

Definition at line 355 of file kdTree.cxx.

References reco::ClusterHit3D::getPosition().

357  {
358  const Eigen::Vector3f& node1Pos = node1->getPosition();
359  const Eigen::Vector3f& node2Pos = node2->getPosition();
360  float deltaNode[] = {
361  node1Pos[0] - node2Pos[0], node1Pos[1] - node2Pos[1], node1Pos[2] - node2Pos[2]};
362  float yzDist2 = deltaNode[1] * deltaNode[1] + deltaNode[2] * deltaNode[2];
363  float xDist2 = deltaNode[0] * deltaNode[0];
364 
365  // Standard euclidean distance
366  return std::sqrt(xDist2 + yzDist2);
367 
368  // Manhatten distance
369  //return std::fabs(deltaNode[0]) + std::fabs(deltaNode[1]) + std::fabs(deltaNode[2]);
370  /*
371  // Chebyshev distance
372  // We look for maximum distance by wires...
373 
374  // Now go through the hits and compare view by view to look for delta wire and tigher constraint on delta t
375  int wireDeltas[] = {0,0,0};
376 
377  for(size_t idx = 0; idx < 3; idx++)
378  wireDeltas[idx] = std::abs(int(node1->getWireIDs()[idx].Wire) - int(node2->getWireIDs()[idx].Wire));
379 
380  // put wire deltas in order...
381  std::sort(wireDeltas, wireDeltas + 3);
382 
383  return std::sqrt(deltaNode[0]*deltaNode[0] + 0.09 * float(wireDeltas[2]*wireDeltas[2]));
384  */
385  }
const Eigen::Vector3f getPosition() const
Definition: Cluster3D.h:155
float lar_cluster3d::kdTree::DistanceBetweenNodesYZ ( const reco::ClusterHit3D node1,
const reco::ClusterHit3D node2 
) const
private

Definition at line 342 of file kdTree.cxx.

References reco::ClusterHit3D::getPosition().

Referenced by consistentPairs().

344  {
345  const Eigen::Vector3f& node1Pos = node1->getPosition();
346  const Eigen::Vector3f& node2Pos = node2->getPosition();
347  float deltaNode[] = {
348  node1Pos[0] - node2Pos[0], node1Pos[1] - node2Pos[1], node1Pos[2] - node2Pos[2]};
349  float yzDist2 = deltaNode[1] * deltaNode[1] + deltaNode[2] * deltaNode[2];
350 
351  // Standard euclidean distance
352  return std::sqrt(yzDist2);
353  }
const Eigen::Vector3f getPosition() const
Definition: Cluster3D.h:155
bool lar_cluster3d::kdTree::FindEntry ( const reco::ClusterHit3D refHit,
const KdTreeNode node,
CandPairList CandPairList,
float &  bestDist,
bool &  selfNotFound,
int  depth 
) const

Definition at line 224 of file kdTree.cxx.

References consistentPairs(), lar_cluster3d::kdTree::KdTreeNode::getAxisValue(), lar_cluster3d::kdTree::KdTreeNode::getClusterHit3D(), reco::ClusterHit3D::getPosition(), lar_cluster3d::kdTree::KdTreeNode::getSplitAxis(), lar_cluster3d::kdTree::KdTreeNode::isLeafNode(), lar_cluster3d::kdTree::KdTreeNode::leftTree(), and lar_cluster3d::kdTree::KdTreeNode::rightTree().

230  {
231  bool foundEntry(false);
232 
233  // If at a leaf then time to decide to add hit or not
234  if (node.isLeafNode()) {
235  float hitSeparation(0.);
236 
237  // Is this the droid we are looking for?
238  if (refHit == node.getClusterHit3D()) selfNotFound = false;
239 
240  // This is the tight constraint on the hits
241  if (consistentPairs(refHit, node.getClusterHit3D(), hitSeparation)) {
242  CandPairList.emplace_back(hitSeparation, node.getClusterHit3D());
243 
244  if (bestDist < std::numeric_limits<float>::max())
245  bestDist = std::max(bestDist, hitSeparation);
246  else
247  bestDist = std::max(float(0.5), hitSeparation);
248  }
249 
250  foundEntry = !selfNotFound;
251  }
252  // Otherwise we need to keep searching
253  else {
254  float refPosition = refHit->getPosition()[node.getSplitAxis()];
255 
256  if (refPosition < node.getAxisValue()) {
257  foundEntry =
258  FindEntry(refHit, node.leftTree(), CandPairList, bestDist, selfNotFound, depth + 1);
259 
260  if (!foundEntry && refPosition + bestDist > node.getAxisValue())
261  foundEntry =
262  FindEntry(refHit, node.rightTree(), CandPairList, bestDist, selfNotFound, depth + 1);
263  }
264  else {
265  foundEntry =
266  FindEntry(refHit, node.rightTree(), CandPairList, bestDist, selfNotFound, depth + 1);
267 
268  if (!foundEntry && refPosition - bestDist < node.getAxisValue())
269  foundEntry =
270  FindEntry(refHit, node.leftTree(), CandPairList, bestDist, selfNotFound, depth + 1);
271  }
272  }
273 
274  return foundEntry;
275  }
const Eigen::Vector3f getPosition() const
Definition: Cluster3D.h:155
bool consistentPairs(const reco::ClusterHit3D *pair1, const reco::ClusterHit3D *pair2, float &hitSeparation) const
The bigger question: are two pairs of hits consistent?
Definition: kdTree.cxx:297
std::list< CandPair > CandPairList
Definition: kdTree.h:84
bool FindEntry(const reco::ClusterHit3D *, const KdTreeNode &, CandPairList &, float &, bool &, int) const
Definition: kdTree.cxx:224
bool lar_cluster3d::kdTree::FindEntryBrute ( const reco::ClusterHit3D refHit,
const KdTreeNode node,
int  depth 
) const

Definition at line 277 of file kdTree.cxx.

References lar_cluster3d::kdTree::KdTreeNode::getClusterHit3D(), lar_cluster3d::kdTree::KdTreeNode::isLeafNode(), lar_cluster3d::kdTree::KdTreeNode::leftTree(), and lar_cluster3d::kdTree::KdTreeNode::rightTree().

280  {
281  // If at a leaf then time to decide to add hit or not
282  if (node.isLeafNode()) {
283  // This is the tight constraint on the hits
284  if (refHit == node.getClusterHit3D()) return true;
285  }
286  // Otherwise we need to keep searching
287  else {
288  if (FindEntryBrute(refHit, node.leftTree(), depth + 1)) return true;
289  if (FindEntryBrute(refHit, node.rightTree(), depth + 1)) return true;
290  }
291 
292  return false;
293  }
bool FindEntryBrute(const reco::ClusterHit3D *, const KdTreeNode &, int) const
Definition: kdTree.cxx:277
size_t lar_cluster3d::kdTree::FindNearestNeighbors ( const reco::ClusterHit3D refHit,
const KdTreeNode node,
CandPairList CandPairList,
float &  bestDist 
) const

Definition at line 183 of file kdTree.cxx.

References consistentPairs(), fRefLeafBestDist, lar_cluster3d::kdTree::KdTreeNode::getAxisValue(), lar_cluster3d::kdTree::KdTreeNode::getClusterHit3D(), reco::ClusterHit3D::getPosition(), lar_cluster3d::kdTree::KdTreeNode::getSplitAxis(), lar_cluster3d::kdTree::KdTreeNode::isLeafNode(), lar_cluster3d::kdTree::KdTreeNode::leftTree(), and lar_cluster3d::kdTree::KdTreeNode::rightTree().

Referenced by lar_cluster3d::DBScanAlg::Cluster3DHits(), lar_cluster3d::DBScanAlg::expandCluster(), lar_cluster3d::MinSpanTreeAlg::RunPrimsAlgorithm(), and lar_cluster3d::MSTPathFinder::RunPrimsAlgorithm().

187  {
188  // If at a leaf then time to decide to add hit or not
189  if (node.isLeafNode()) {
190  // Is this the droid we are looking for?
191  if (refHit == node.getClusterHit3D())
192  bestDist =
193  fRefLeafBestDist; // This distance will grab neighbors with delta wire # = 1 in all three planes
194  // This is the tight constraint on the hits
195  else if (consistentPairs(refHit, node.getClusterHit3D(), bestDist)) {
196  CandPairList.emplace_back(bestDist, node.getClusterHit3D());
197 
198  bestDist = std::max(
200  bestDist); // This insures we will always consider neighbors with wire # changing in 2 planes
201  }
202  }
203  // Otherwise we need to keep searching
204  else {
205  float refPosition = refHit->getPosition()[node.getSplitAxis()];
206 
207  if (refPosition < node.getAxisValue()) {
208  FindNearestNeighbors(refHit, node.leftTree(), CandPairList, bestDist);
209 
210  if (refPosition + bestDist > node.getAxisValue())
211  FindNearestNeighbors(refHit, node.rightTree(), CandPairList, bestDist);
212  }
213  else {
214  FindNearestNeighbors(refHit, node.rightTree(), CandPairList, bestDist);
215 
216  if (refPosition - bestDist < node.getAxisValue())
217  FindNearestNeighbors(refHit, node.leftTree(), CandPairList, bestDist);
218  }
219  }
220 
221  return CandPairList.size();
222  }
float fRefLeafBestDist
Set neighborhood distance to this when ref leaf found.
Definition: kdTree.h:120
const Eigen::Vector3f getPosition() const
Definition: Cluster3D.h:155
size_t FindNearestNeighbors(const reco::ClusterHit3D *, const KdTreeNode &, CandPairList &, float &) const
Definition: kdTree.cxx:183
bool consistentPairs(const reco::ClusterHit3D *pair1, const reco::ClusterHit3D *pair2, float &hitSeparation) const
The bigger question: are two pairs of hits consistent?
Definition: kdTree.cxx:297
std::list< CandPair > CandPairList
Definition: kdTree.h:84
float lar_cluster3d::kdTree::getTimeToExecute ( ) const
inline

Member Data Documentation

bool lar_cluster3d::kdTree::fEnableMonitoring
private

Definition at line 117 of file kdTree.h.

Referenced by BuildKdTree(), and configure().

int lar_cluster3d::kdTree::fMaxWireDeltas
private

Maximum total number of delta wires.

Definition at line 121 of file kdTree.h.

Referenced by configure().

float lar_cluster3d::kdTree::fPairSigmaPeakTime
private

Consider hits consistent if "significance" less than this.

Definition at line 119 of file kdTree.h.

Referenced by configure(), and consistentPairs().

float lar_cluster3d::kdTree::fRefLeafBestDist
private

Set neighborhood distance to this when ref leaf found.

Definition at line 120 of file kdTree.h.

Referenced by configure(), and FindNearestNeighbors().

float lar_cluster3d::kdTree::fTimeToBuild
mutableprivate

Definition at line 118 of file kdTree.h.

Referenced by BuildKdTree(), and configure().


The documentation for this class was generated from the following files: