Use PCA to try to find path in cluster.
247 std::cout <<
indent <<
">>> breakIntoTinyBits with " << clusterToBreak.getHitPairListPtr().size() <<
" input hits " <<
std::endl;
254 bool storeCurrentCluster(
true);
258 if (clusterToBreak.getBestEdgeList().size() > 6 &&
259 clusterToBreak.getHitPairListPtr().size() > size_t(2 * minimumClusterSize))
269 clusHitPairVector.sort([](
const auto&
left,
const auto&
right){
return left->getArclenToPoca() <
right->getArclenToPoca();});
273 std::vector<const reco::ClusterHit3D*> vertexHitVec;
275 std::cout <<
indent <<
"+> Breaking cluster, convex hull has " << bestEdgeList.size() <<
" edges to work with" <<
std::endl;
277 for(
const auto& edge : bestEdgeList)
279 vertexHitVec.push_back(std::get<0>(edge));
280 vertexHitVec.push_back(std::get<1>(edge));
284 std::sort(vertexHitVec.begin(),vertexHitVec.end(),[](
const auto&
left,
const auto&
right){
return left->getArclenToPoca() <
right->getArclenToPoca();});
287 using Hit3DItrPair = std::pair<reco::HitPairListPtr::iterator,reco::HitPairListPtr::iterator>;
288 using VertexPairList = std::list<Hit3DItrPair>;
290 VertexPairList vertexPairList;
293 for(
const auto& hit3D : vertexHitVec)
297 if (vertexItr == clusHitPairVector.end())
299 std::cout <<
indent <<
">>>>>>>>>>>>>>>>> Hit not found in input list, cannot happen? <<<<<<<<<<<<<<<<<<<" <<
std::endl;
303 std::cout <<
indent <<
"+> -- Distance from first to current vertex point: " <<
std::distance(firstHitItr,vertexItr) <<
" first: " << *firstHitItr <<
", vertex: " << *vertexItr;
306 if (
std::distance(firstHitItr,vertexItr) > minimumClusterSize)
308 vertexPairList.emplace_back(Hit3DItrPair(firstHitItr,vertexItr));
309 firstHitItr = vertexItr;
311 std::cout <<
" ++ made pair ";
320 std::cout <<
indent <<
"+> loop over vertices done, remant distance: " <<
std::distance(firstHitItr,clusHitPairVector.end()) <<
std::endl;
323 if (!vertexPairList.empty() &&
std::distance(firstHitItr,clusHitPairVector.end()) < minimumClusterSize)
324 vertexPairList.back().second = clusHitPairVector.end();
326 vertexPairList.emplace_back(Hit3DItrPair(firstHitItr,clusHitPairVector.end()));
329 std::cout <<
indent <<
"+> ---> breaking cluster into " << vertexPairList.size() <<
" subclusters" <<
std::endl;
331 if (vertexPairList.size() > 1)
333 storeCurrentCluster =
false;
336 for(
auto& hit3DItrPair : vertexPairList)
344 hitPairListPtr.resize(
std::distance(hit3DItrPair.first,hit3DItrPair.second));
347 std::copy(hit3DItrPair.first,hit3DItrPair.second,hitPairListPtr.begin());
358 std::cout <<
indent <<
"+> -- >> cluster has a valid Full PCA" <<
std::endl;
365 if (fullPrimaryVec.dot(newPrimaryVec) < 0.)
367 for(
size_t vecIdx = 0; vecIdx < 3; vecIdx++) newFullPCA.
flipAxis(vecIdx);
380 if (storeCurrentCluster)
385 std::set<const reco::ClusterHit2D*> hitSet;
388 for(
const auto& hit3D : clusterToBreak.getHitPairListPtr())
390 for(
const auto& hit2D : hit3D->getHits())
392 if (hit2D) hitSet.insert(hit2D);
397 for(
const auto& hit2D : hitSet)
400 clusterToBreak.UpdateParameters(hit2D);
403 std::cout <<
indent <<
"*********>>> storing new subcluster of size " << clusterToBreak.getHitPairListPtr().size() <<
std::endl;
405 positionItr = outputClusterList.insert(positionItr,clusterToBreak);
410 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
reco::PrincipalComponents & getFullPCA()
size_t m_minTinyClusterSize
Minimum size for a "tiny" cluster.
std::list< const reco::ClusterHit3D * > HitPairListPtr
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
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
const EigenVectors & getEigenVectors() const
QTextStream & endl(QTextStream &s)