9 #include "cetlib/cpu_timer.h"
10 #include "fhiclcpp/ParameterSet.h"
22 namespace lar_cluster3d {
54 cet::cpu_timer theClockBuildNeighborhood;
61 hit3DVec.reserve(hitPairList.size());
63 for(
const auto&
hit : hitPairList) hit3DVec.emplace_back(&
hit);
69 theClockBuildNeighborhood.stop();
70 fTimeToBuild = theClockBuildNeighborhood.accumulated_real_time();
82 cet::cpu_timer theClockBuildNeighborhood;
90 hit3DVec.reserve(hitPairList.size());
92 for(
const auto& hit3D : hitPairList)
96 for(
const auto& hit2D : hit3D->getHits())
97 if (hit2D) hit2D->clearStatusBits(0xFFFFFFFF);
98 hit3DVec.emplace_back(hit3D);
105 theClockBuildNeighborhood.stop();
106 fTimeToBuild = theClockBuildNeighborhood.accumulated_real_time();
113 Hit3DVec::iterator last,
120 if (first != last) kdTreeNodeContainer.emplace_back(*first);
121 else kdTreeNodeContainer.emplace_back(
KdTreeNode());
131 std::vector<float> rangeVec(3,0.);
133 rangeVec[0] = (*minMaxXPair.second)->getPosition()[0] - (*minMaxXPair.first)->getPosition()[0];
134 rangeVec[1] = (*minMaxYPair.second)->getPosition()[1] - (*minMaxYPair.first)->getPosition()[1];
135 rangeVec[2] = (*minMaxZPair.second)->getPosition()[2] - (*minMaxZPair.first)->getPosition()[2];
137 std::vector<float>::iterator maxRangeItr = std::max_element(rangeVec.begin(),rangeVec.end());
139 size_t maxRangeIdx =
std::distance(rangeVec.begin(),maxRangeItr);
142 std::sort(first,last,[maxRangeIdx](
const auto& left,
const auto& right){
return left->
getPosition()[maxRangeIdx] < right->
getPosition()[maxRangeIdx];});
145 Hit3DVec::iterator middleItr =
first;
147 std::advance(middleItr, middleElem);
152 while(middleItr != first+1)
154 if (!((*(middleItr-1))->getPosition()[maxRangeIdx] < (*middleItr)->getPosition()[maxRangeIdx])) middleItr--;
160 float axisVal = 0.5*((*middleItr)->getPosition()[maxRangeIdx] + (*(middleItr-1))->getPosition()[maxRangeIdx]);
164 kdTreeNodeContainer.push_back(
KdTreeNode(axis[maxRangeIdx],axisVal,leftNode,rightNode));
167 return kdTreeNodeContainer.back();
204 return CandPairList.size();
209 bool foundEntry(
false);
214 float hitSeparation(0.);
224 if (bestDist < std::numeric_limits<float>::max()) bestDist = std::max(bestDist,hitSeparation);
225 else bestDist = std::max(
float(0.5),hitSeparation);
228 foundEntry = !selfNotFound;
280 bool consistent(
false);
288 int wireDeltas[] = {0, 0, 0};
291 for(
size_t idx = 0; idx < 3; idx++)
295 std::sort(wireDeltas, wireDeltas + 3);
298 if (wireDeltas[2] < 3)
303 if (hitSeparation < bestDist)
305 bestDist = hitSeparation;
318 const Eigen::Vector3f& node1Pos = node1->
getPosition();
319 const Eigen::Vector3f& node2Pos = node2->
getPosition();
320 float deltaNode[] = {node1Pos[0]-node2Pos[0], node1Pos[1]-node2Pos[1], node1Pos[2]-node2Pos[2]};
321 float yzDist2 = deltaNode[1]*deltaNode[1] + deltaNode[2]*deltaNode[2];
324 return std::sqrt(yzDist2);
329 const Eigen::Vector3f& node1Pos = node1->
getPosition();
330 const Eigen::Vector3f& node2Pos = node2->
getPosition();
331 float deltaNode[] = {node1Pos[0]-node2Pos[0], node1Pos[1]-node2Pos[1], node1Pos[2]-node2Pos[2]};
332 float yzDist2 = deltaNode[1]*deltaNode[1] + deltaNode[2]*deltaNode[2];
333 float xDist2 = deltaNode[0]*deltaNode[0];
336 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
const Eigen::Vector3f getPosition() const
void configure(fhicl::ParameterSet const &pset)
Configure our kdTree...
std::list< KdTreeNode > KdTreeNodeList
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
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
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?
std::list< CandPair > CandPairList
float DistanceBetweenNodesYZ(const reco::ClusterHit3D *, const reco::ClusterHit3D *) const
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