Use PCA to try to find path in cluster.
237 std::string pluses(level/2,
'+');
238 std::string indent(level/2,
' ');
242 reco::ClusterParametersList::iterator inputPositionItr = positionItr;
248 std::cout << indent <<
">>> breakIntoTinyBits with " << clusterToBreak.getHitPairListPtr().size() <<
" input hits " << std::endl;
255 bool storeCurrentCluster(
true);
259 if (clusterToBreak.getBestEdgeList().size() > 6 &&
260 clusterToBreak.getHitPairListPtr().size() > size_t(2 * minimumClusterSize))
270 clusHitPairVector.sort([](
const auto&
left,
const auto&
right){
return left->getArclenToPoca() <
right->getArclenToPoca();});
274 std::vector<const reco::ClusterHit3D*> vertexHitVec;
276 std::cout << indent <<
"+> Breaking cluster, convex hull has " << bestEdgeList.size() <<
" edges to work with" << std::endl;
278 for(
const auto& edge : bestEdgeList)
280 vertexHitVec.push_back(std::get<0>(edge));
281 vertexHitVec.push_back(std::get<1>(edge));
285 std::sort(vertexHitVec.begin(),vertexHitVec.end(),[](
const auto&
left,
const auto&
right){
return left->getArclenToPoca() <
right->getArclenToPoca();});
288 using Hit3DItrPair = std::pair<reco::HitPairListPtr::iterator,reco::HitPairListPtr::iterator>;
289 using VertexPairList = std::list<Hit3DItrPair>;
291 VertexPairList vertexPairList;
292 reco::HitPairListPtr::iterator firstHitItr = clusHitPairVector.begin();
294 for(
const auto& hit3D : vertexHitVec)
296 reco::HitPairListPtr::iterator vertexItr = std::find(firstHitItr,clusHitPairVector.end(),hit3D);
298 if (vertexItr == clusHitPairVector.end())
300 std::cout << indent <<
">>>>>>>>>>>>>>>>> Hit not found in input list, cannot happen? <<<<<<<<<<<<<<<<<<<" << std::endl;
304 std::cout << indent <<
"+> -- Distance from first to current vertex point: " <<
std::distance(firstHitItr,vertexItr) <<
" first: " << *firstHitItr <<
", vertex: " << *vertexItr;
307 if (
std::distance(firstHitItr,vertexItr) > minimumClusterSize)
309 vertexPairList.emplace_back(Hit3DItrPair(firstHitItr,vertexItr));
310 firstHitItr = vertexItr;
321 std::cout << indent <<
"+> loop over vertices done, remant distance: " <<
std::distance(firstHitItr,clusHitPairVector.end()) << std::endl;
324 if (!vertexPairList.empty() &&
std::distance(firstHitItr,clusHitPairVector.end()) < minimumClusterSize)
325 vertexPairList.back().second = clusHitPairVector.end();
327 vertexPairList.emplace_back(Hit3DItrPair(firstHitItr,clusHitPairVector.end()));
330 std::cout << indent <<
"+> ---> breaking cluster into " << vertexPairList.size() <<
" subclusters" << std::endl;
332 if (vertexPairList.size() > 1)
334 storeCurrentCluster =
false;
337 for(
auto& hit3DItrPair : vertexPairList)
342 std::cout << indent <<
"+> -- building new cluster, size: " <<
std::distance(hit3DItrPair.first,hit3DItrPair.second) << std::endl;
345 hitPairListPtr.resize(
std::distance(hit3DItrPair.first,hit3DItrPair.second));
348 std::copy(hit3DItrPair.first,hit3DItrPair.second,hitPairListPtr.begin());
359 std::cout << indent <<
"+> -- >> cluster has a valid Full PCA" << std::endl;
366 if (fullPrimaryVec.dot(newPrimaryVec) < 0.)
368 for(
size_t vecIdx = 0; vecIdx < 3; vecIdx++) newFullPCA.
flipAxis(vecIdx);
374 positionItr =
breakIntoTinyBits(clusterParams, positionItr, outputClusterList, level+4);
381 if (storeCurrentCluster)
386 std::set<const reco::ClusterHit2D*> hitSet;
389 for(
const auto& hit3D : clusterToBreak.getHitPairListPtr())
391 for(
const auto& hit2D : hit3D->getHits())
393 if (hit2D) hitSet.insert(hit2D);
398 for(
const auto& hit2D : hitSet)
401 clusterToBreak.UpdateParameters(hit2D);
404 std::cout << indent <<
"*********>>> storing new subcluster of size " << clusterToBreak.getHitPairListPtr().size() << std::endl;
406 positionItr = outputClusterList.insert(positionItr,clusterToBreak);
411 else if (inputPositionItr == positionItr)
std::cout << indent <<
"***** DID NOT STORE A CLUSTER *****" << std::endl;
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
void flipAxis(size_t axis)
reco::PrincipalComponents & getSkeletonPCA()
reco::HitPairListPtr & getHitPairListPtr()
std::list< EdgeTuple > EdgeList
void buildConvexHull(reco::ClusterParameters &clusterParameters, int level=0) const
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
reco::PrincipalComponents & getFullPCA()
size_t m_minTinyClusterSize
Minimum size for a "tiny" cluster.
std::list< const reco::ClusterHit3D * > HitPairListPtr
reco::ClusterParametersList::iterator breakIntoTinyBits(reco::ClusterParameters &cluster, reco::ClusterParametersList::iterator positionItr, reco::ClusterParametersList &outputClusterList, int level=0) const
Use PCA to try to find path in cluster.
PrincipalComponentsAlg m_pcaAlg
BEGIN_PROLOG could also be cout
const EigenVectors & getEigenVectors() const