9 #include "cetlib/search_path.h" 10 #include "cetlib/cpu_timer.h" 25 #include <unordered_map> 62 cet::cpu_timer theClockBuildNeighborhood;
69 hit3DVec.reserve(hitPairList.size());
71 for(
const auto& hitPtr : hitPairList) hit3DVec.emplace_back(hitPtr.get());
77 theClockBuildNeighborhood.stop();
78 m_timeToBuild = theClockBuildNeighborhood.accumulated_real_time();
90 cet::cpu_timer theClockBuildNeighborhood;
98 hit3DVec.reserve(hitPairList.size());
100 for(
const auto& hit3D : hitPairList)
104 for(
const auto& hit2D : hit3D->getHits())
105 if (hit2D) hit2D->clearStatusBits(0xFFFFFFFF);
106 hit3DVec.emplace_back(hit3D);
113 theClockBuildNeighborhood.stop();
114 m_timeToBuild = theClockBuildNeighborhood.accumulated_real_time();
126 if (std::distance(first,last) < 2)
128 if (first != last) kdTreeNodeContainer.emplace_back(*first);
129 else kdTreeNodeContainer.emplace_back(
KdTreeNode());
139 std::vector<float> rangeVec(3,0.);
141 rangeVec[0] = (*minMaxXPair.second)->getPosition()[0] - (*minMaxXPair.first)->getPosition()[0];
142 rangeVec[1] = (*minMaxYPair.second)->getPosition()[1] - (*minMaxYPair.first)->getPosition()[1];
143 rangeVec[2] = (*minMaxZPair.second)->getPosition()[2] - (*minMaxZPair.first)->getPosition()[2];
147 size_t maxRangeIdx = std::distance(rangeVec.begin(),maxRangeItr);
150 std::sort(first,last,[maxRangeIdx](
const auto& left,
const auto& right){
return left->
getPosition()[maxRangeIdx] < right->
getPosition()[maxRangeIdx];});
152 size_t middleElem = std::distance(first,last) / 2;
155 std::advance(middleItr, middleElem);
158 if (std::distance(first,middleItr) > 1)
160 while(middleItr != first+1)
162 if (!((*(middleItr-1))->getPosition()[maxRangeIdx] < (*middleItr)->getPosition()[maxRangeIdx])) middleItr--;
168 float axisVal = 0.5*((*middleItr)->getPosition()[maxRangeIdx] + (*(middleItr-1))->getPosition()[maxRangeIdx]);
172 kdTreeNodeContainer.push_back(
KdTreeNode(axis[maxRangeIdx],axisVal,leftNode,rightNode));
175 return kdTreeNodeContainer.back();
212 return CandPairList.size();
217 bool foundEntry(
false);
222 float hitSeparation(0.);
233 else bestDist =
std::max(
float(0.5),hitSeparation);
236 foundEntry = !selfNotFound;
288 bool consistent(
false);
296 int wireDeltas[] = {0, 0, 0};
299 for(
size_t idx = 0; idx < 3; idx++)
300 wireDeltas[idx] = std::abs(
int(pair1->
getWireIDs()[idx].Wire) -
int(pair2->
getWireIDs()[idx].Wire));
303 std::sort(wireDeltas, wireDeltas + 3);
307 if (wireDeltas[2] < 3)
312 if (hitSeparation < bestDist)
314 bestDist = hitSeparation;
328 float deltaNode[] = {node1Pos[0]-node2Pos[0], node1Pos[1]-node2Pos[1], node1Pos[2]-node2Pos[2]};
331 return std::sqrt(deltaNode[0]*deltaNode[0]+deltaNode[1]*deltaNode[1]+deltaNode[2]*deltaNode[2]);
Hit contains 2D hit from view 2 (w plane)
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Declaration of signal hit object.
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
float m_pairSigmaPeakTime
Consider hits consistent if "significance" less than this.
Hit contains 2D hit from view 0 (u plane)
float getSigmaPeakTime() const
kdTree(fhicl::ParameterSet const &pset)
Constructor.
std::vector< const reco::ClusterHit3D * > Hit3DVec
std::list< std::unique_ptr< reco::ClusterHit3D >> HitPairList
float DistanceBetweenNodes(const reco::ClusterHit3D *, const reco::ClusterHit3D *) const
float getAvePeakTime() const
float m_refLeafBestDist
Set neighborhood distance to this when ref leaf found.
virtual ~kdTree()
Destructor.
T get(std::string const &key) const
Hit contains 2D hit from view 1 (v plane)
std::list< const reco::ClusterHit3D * > HitPairListPtr
This provides an art tool interface definition for 3D Cluster algorithms.
bool consistentPairs(const reco::ClusterHit3D *pair1, const reco::ClusterHit3D *pair2, float &hitSeparation) const
The bigger question: are two pairs of hits consistent?
const float * getPosition() const
std::list< CandPair > CandPairList
Encapsulate the geometry of a wire.
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
Encapsulate the construction of a single detector plane.
bool FindEntryBrute(const reco::ClusterHit3D *, const KdTreeNode &, int) const
const KdTreeNode & rightTree() const
const std::vector< geo::WireID > & getWireIDs() const
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