9 #include "cetlib/cpu_timer.h" 52 cet::cpu_timer theClockBuildNeighborhood;
59 hit3DVec.reserve(hitPairList.size());
61 for (
const auto&
hit : hitPairList)
62 hit3DVec.emplace_back(&
hit);
67 theClockBuildNeighborhood.stop();
68 fTimeToBuild = theClockBuildNeighborhood.accumulated_real_time();
80 cet::cpu_timer theClockBuildNeighborhood;
88 hit3DVec.reserve(hitPairList.size());
90 for (
const auto& hit3D : hitPairList) {
94 for (
const auto& hit2D : hit3D->getHits())
95 if (hit2D) hit2D->clearStatusBits(0xFFFFFFFF);
96 hit3DVec.emplace_back(hit3D);
102 theClockBuildNeighborhood.stop();
103 fTimeToBuild = theClockBuildNeighborhood.accumulated_real_time();
115 if (std::distance(first, last) < 2) {
117 kdTreeNodeContainer.emplace_back(*first);
119 kdTreeNodeContainer.emplace_back(
KdTreeNode());
124 std::pair<Hit3DVec::iterator, Hit3DVec::iterator> minMaxXPair = std::minmax_element(
128 std::pair<Hit3DVec::iterator, Hit3DVec::iterator> minMaxYPair = std::minmax_element(
132 std::pair<Hit3DVec::iterator, Hit3DVec::iterator> minMaxZPair = std::minmax_element(
137 std::vector<float> rangeVec(3, 0.);
140 (*minMaxXPair.second)->getPosition()[0] - (*minMaxXPair.first)->getPosition()[0];
142 (*minMaxYPair.second)->getPosition()[1] - (*minMaxYPair.first)->getPosition()[1];
144 (*minMaxZPair.second)->getPosition()[2] - (*minMaxZPair.first)->getPosition()[2];
148 size_t maxRangeIdx = std::distance(rangeVec.begin(), maxRangeItr);
151 std::sort(first, last, [maxRangeIdx](
const auto& left,
const auto& right) {
155 size_t middleElem = std::distance(first, last) / 2;
158 std::advance(middleItr, middleElem);
161 if (std::distance(first, middleItr) > 1) {
162 while (middleItr != first + 1) {
163 if (!((*(middleItr - 1))->getPosition()[maxRangeIdx] <
164 (*middleItr)->getPosition()[maxRangeIdx]))
172 float axisVal = 0.5 * ((*middleItr)->getPosition()[maxRangeIdx] +
173 (*(middleItr - 1))->getPosition()[maxRangeIdx]);
177 kdTreeNodeContainer.push_back(
KdTreeNode(axis[maxRangeIdx], axisVal, leftNode, rightNode));
180 return kdTreeNodeContainer.back();
186 float& bestDist)
const 221 return CandPairList.size();
231 bool foundEntry(
false);
235 float hitSeparation(0.);
244 if (bestDist < std::numeric_limits<float>::max())
245 bestDist = std::max(bestDist, hitSeparation);
247 bestDist = std::max(
float(0.5), hitSeparation);
250 foundEntry = !selfNotFound;
260 if (!foundEntry && refPosition + bestDist > node.
getAxisValue())
268 if (!foundEntry && refPosition - bestDist < node.
getAxisValue())
299 float& bestDist)
const 307 bool consistent(
false);
309 if (bestDist < std::numeric_limits<float>::max() &&
316 int wireDeltas[] = {0, 0, 0};
319 for (
size_t idx = 0; idx < 3; idx++)
324 std::sort(wireDeltas, wireDeltas + 3);
327 if (wireDeltas[2] < 3) {
331 if (hitSeparation < bestDist) {
332 bestDist = hitSeparation;
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];
352 return std::sqrt(yzDist2);
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];
366 return std::sqrt(xDist2 + yzDist2);
Hit contains 2D hit from view 2 (w plane)
float fRefLeafBestDist
Set neighborhood distance to this when ref leaf found.
std::list< reco::ClusterHit3D > HitPairList
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
const Eigen::Vector3f getPosition() const
void configure(fhicl::ParameterSet const &pset)
Configure our kdTree...
std::list< KdTreeNode > KdTreeNodeList
constexpr auto abs(T v)
Returns the absolute value of the argument.
Implements a kdTree for use in clustering.
size_t FindNearestNeighbors(const reco::ClusterHit3D *, const KdTreeNode &, CandPairList &, float &) const
Hit contains 2D hit from view 0 (u plane)
float getSigmaPeakTime() const
std::vector< const reco::ClusterHit3D * > Hit3DVec
kdTree()
Default Constructor.
float DistanceBetweenNodes(const reco::ClusterHit3D *, const reco::ClusterHit3D *) const
float getAvePeakTime() const
T get(std::string const &key) const
Hit contains 2D hit from view 1 (v plane)
std::list< const reco::ClusterHit3D * > HitPairListPtr
Definition of data types for geometry description.
bool consistentPairs(const reco::ClusterHit3D *pair1, const reco::ClusterHit3D *pair2, float &hitSeparation) const
The bigger question: are two pairs of hits consistent?
Detector simulation of raw signals on wires.
std::list< CandPair > CandPairList
float DistanceBetweenNodesYZ(const reco::ClusterHit3D *, const reco::ClusterHit3D *) const
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
bool FindEntry(const reco::ClusterHit3D *, const KdTreeNode &, CandPairList &, float &, bool &, int) const
bool FindEntryBrute(const reco::ClusterHit3D *, const KdTreeNode &, int) const
float fPairSigmaPeakTime
Consider hits consistent if "significance" less than this.
const KdTreeNode & rightTree() const
const std::vector< geo::WireID > & getWireIDs() const
int fMaxWireDeltas
Maximum total number of delta wires.
float getAxisValue() const
const reco::ClusterHit3D * getClusterHit3D() const
KdTreeNode & BuildKdTree(Hit3DVec::iterator, Hit3DVec::iterator, KdTreeNodeList &, int depth=0) const
Given an input set of ClusterHit3D objects, build a kd tree structure.
const KdTreeNode & leftTree() const
SplitAxis getSplitAxis() const