Use PCA to try to find path in cluster.
579 std::string pluses(level/2,
'+');
580 std::string indent(level/2,
' ');
587 std::vector<double> eigenValVec = {3. * std::sqrt(fullPCA.
getEigenValues()[0]),
598 reco::ProjectedPointList::const_iterator extremePointListItr = clusterToBreak.getConvexHull().getConvexHullExtremePoints().begin();
602 Eigen::Vector3f edgeVec(secondEdgeHit->getPosition()[0] - firstEdgeHit->
getPosition()[0],
603 secondEdgeHit->getPosition()[1] - firstEdgeHit->
getPosition()[1],
604 secondEdgeHit->getPosition()[2] - firstEdgeHit->
getPosition()[2]);
605 double edgeLen = edgeVec.norm();
618 clusHitPairVector.sort([](
const auto&
left,
const auto&
right){
return left->getArclenToPoca() <
right->getArclenToPoca();});
621 using DistEdgeTuple = std::tuple<float, const reco::EdgeTuple*>;
622 using DistEdgeTupleVec = std::vector<DistEdgeTuple>;
624 DistEdgeTupleVec distEdgeTupleVec;
627 for(
const auto& edge : clusterToBreak.getBestEdgeList())
637 float hitProjection = hitToEdgeVec.dot(edgeVec);
640 if (hitProjection > 0. && hitProjection < edgeLen)
642 Eigen::Vector3f distToHitVec = hitToEdgeVec - hitProjection * edgeVec;
643 float distToHit = distToHitVec.norm();
645 distEdgeTupleVec.emplace_back(distToHit,&edge);
649 std::sort(distEdgeTupleVec.begin(),distEdgeTupleVec.end(),[](
const auto&
left,
const auto&
right){
return std::get<0>(
left) > std::get<0>(
right);});
653 float usedDefectDist(0.);
655 for(
const auto& distEdgeTuple : distEdgeTupleVec)
660 usedDefectDist = std::get<0>(distEdgeTuple);
663 reco::HitPairListPtr::iterator vertexItr = std::find(clusHitPairVector.begin(),clusHitPairVector.end(),edgeHit);
672 if (
makeCandidateCluster(fullPrimaryVec, clusterParams1, clusHitPairVector.begin(), vertexItr, level))
678 if (
makeCandidateCluster(fullPrimaryVec, clusterParams2, vertexItr, clusHitPairVector.end(), level))
break;
682 tempClusterParametersList.clear();
686 if (tempClusterParametersList.empty())
688 std::cout << indent <<
"===> no cluster cands, edgeLen: " << edgeLen <<
", # hits: " << clusHitPairVector.size() <<
", max defect: " << std::get<0>(distEdgeTupleVec.front()) << std::endl;
694 reco::HitPairListPtr::iterator vertexItr = clusHitPairVector.begin();
696 std::advance(vertexItr, clusHitPairVector.size()/2);
702 if (
makeCandidateCluster(fullPrimaryVec, clusterParams1, clusHitPairVector.begin(), vertexItr, level))
708 if (!
makeCandidateCluster(fullPrimaryVec, clusterParams2, vertexItr, clusHitPairVector.end(), level))
709 tempClusterParametersList.clear();
715 for(
auto& clusterParams : tempClusterParametersList)
717 size_t curOutputClusterListSize = outputClusterList.size();
719 positionItr =
subDivideCluster(clusterParams, fullPCA, positionItr, outputClusterList, level+4);
721 std::cout << indent <<
"Output cluster list prev: " << curOutputClusterListSize <<
", now: " << outputClusterList.size() << std::endl;
725 if (curOutputClusterListSize < outputClusterList.size())
continue;
730 std::set<const reco::ClusterHit2D*> hitSet;
733 for(
const auto& hit3D : clusterParams.getHitPairListPtr())
735 for(
const auto& hit2D : hit3D->getHits())
737 if (hit2D) hitSet.insert(hit2D);
742 for(
const auto& hit2D : hitSet)
745 clusterParams.UpdateParameters(hit2D);
748 std::cout << indent <<
"*********>>> storing new subcluster of size " << clusterParams.getHitPairListPtr().size() << std::endl;
750 positionItr = outputClusterList.insert(positionItr,clusterParams);
761 int num3DHits = clusterParams.getHitPairListPtr().size();
762 int numEdges = clusterParams.getBestEdgeList().size();
763 float cosToLast = newPrimaryVec.dot(lastPrimaryVec);
764 double eigen2To1Ratio = eigenValVec[0] / eigenValVec[1];
765 double eigen1To0Ratio = eigenValVec[1] / eigenValVec[2];
766 double eigen2To0Ratio = eigenValVec[2] / eigenValVec[2];
776 fSubMaxDefect->Fill(std::get<0>(distEdgeTupleVec.front()), 1.);
void PCAAnalysis_calc3DDocas(const reco::HitPairListPtr &hitPairVector, const reco::PrincipalComponents &pca) const
const Eigen::Vector3f getPosition() const
const EigenValues & getEigenValues() const
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
PrincipalComponentsAlg fPCAAlg
reco::ClusterParametersList::iterator subDivideCluster(reco::ClusterParameters &cluster, reco::PrincipalComponents &lastPCA, reco::ClusterParametersList::iterator positionItr, reco::ClusterParametersList &outputClusterList, int level=0) const
Use PCA to try to find path in cluster.
std::tuple< const reco::ClusterHit3D *, const reco::ClusterHit3D *, double > EdgeTuple
std::list< const reco::ClusterHit3D * > HitPairListPtr
bool makeCandidateCluster(Eigen::Vector3f &, reco::ClusterParameters &, reco::HitPairListPtr::iterator, reco::HitPairListPtr::iterator, int) const
size_t fMinTinyClusterSize
Minimum size for a "tiny" cluster.
bool fFillHistograms
Histogram definitions.
BEGIN_PROLOG could also be cout
std::list< ClusterParameters > ClusterParametersList
const EigenVectors & getEigenVectors() const