12 #include "fhiclcpp/ParameterSet.h"
25 namespace lar_cluster3d {
28 : m_maxNumEdgeHits(1000)
31 , m_pcaAlg(pset.
get<fhicl::ParameterSet>(
"PrincipalComponentsAlg"))
44 bool foundGoodSeeds(
false);
65 std::set<const reco::ClusterHit2D*> hit2DSet;
68 double lastArcLen = inputHitPairListPtr.front()->getArclenToPoca();
70 for (
const auto& hit3D : inputHitPairListPtr) {
71 double arcLen = hit3D->getArclenToPoca();
74 seedHit3DList.clear();
78 seedHit3DList.push_back(hit3D);
80 for (
const auto& hit2D : hit3D->getHits()) {
81 hit2DSet.insert(hit2D);
92 size_t num3DHitsToKeep = std::min(2 * seedHit3DList.size(), inputHitPairListPtr.size());
93 size_t numEdgeHits = std::min(
size_t(num3DHitsToKeep / 2),
m_maxNumEdgeHits);
96 reco::HitPairListPtr::iterator edgeHitItr = inputHitPairListPtr.begin();
98 std::advance(edgeHitItr, numEdgeHits);
103 hit3DList.resize(2 * numEdgeHits);
106 reco::HitPairListPtr::iterator nextHit3DItr =
107 std::copy(inputHitPairListPtr.begin(), edgeHitItr, hit3DList.begin());
110 seedHit3DList.clear();
111 seedHit3DList.resize(numEdgeHits);
113 std::copy(inputHitPairListPtr.begin(), edgeHitItr, seedHit3DList.begin());
116 std::advance(edgeHitItr, inputHitPairListPtr.size() - 2 * numEdgeHits);
118 std::copy(edgeHitItr, inputHitPairListPtr.end(), nextHit3DItr);
126 if (seedPCA.getSvdOK()) {
128 if (seedPCA.getEigenVectors().row(2)(1) > 0.) seedPCA.flipAxis(0);
138 double seedDir[3] = {seedPCA.getEigenVectors().row(2)(0),
139 seedPCA.getEigenVectors().row(2)(1),
140 seedPCA.getEigenVectors().row(2)(2)};
141 double seedStart[3] = {seedHit3DList.front()->getX(),
142 seedHit3DList.front()->getY(),
143 seedHit3DList.front()->getZ()};
146 double halfArcLen = 0.5 * fabs(seedHit3DList.back()->getArclenToPoca() -
147 seedHit3DList.front()->getArclenToPoca());
149 seedStart[0] += halfArcLen * seedDir[0];
150 seedStart[1] += halfArcLen * seedDir[1];
151 seedStart[2] += halfArcLen * seedDir[2];
153 for (
const auto& hit3D : seedHit3DList)
154 hit3D->setStatusBit(0x40000000);
156 seedHitPairVec.emplace_back(std::pair<recob::Seed, reco::HitPairListPtr>(
161 foundGoodSeeds =
true;
166 return foundGoodSeeds;
Define a comparator which will sort hits by arc length along a PCA axis.
void PCAAnalysis_calc3DDocas(const reco::HitPairListPtr &hitPairVector, const reco::PrincipalComponents &pca) const
void PCAAnalysis_3D(const reco::HitPairListPtr &hitPairList, reco::PrincipalComponents &pca, bool skeletonOnly=false) const
double m_gapDistance
Maximum allowed distance between hits.
void flipAxis(size_t axis)
size_t m_maxNumEdgeHits
Maximum number hits each end of PCA axis.
PrincipalComponentsAlg m_pcaAlg
This is an algorithm for finding recob::Seed objects in 3D clusters.
ParallelHitsSeedFinderAlg(fhicl::ParameterSet const &pset)
Constructor.
std::list< const reco::ClusterHit3D * > HitPairListPtr
bool findTrackSeeds(reco::HitPairListPtr &hitPairListPtr, reco::PrincipalComponents &inputPCA, SeedHitPairListPairVec &seedHitMap) const override
Given the list of hits this will search for candidate Seed objects and return them.
std::vector< SeedHitPairListPair > SeedHitPairListPairVec
size_t m_numSeed2DHits
Number 2D seed hits desired.
const EigenVectors & getEigenVectors() const