10 #include "cetlib/search_path.h" 11 #include "cetlib/cpu_timer.h" 73 float closestApproach(
const TVector3&,
const TVector3&,
const TVector3&,
const TVector3&, TVector3&, TVector3&)
const;
89 m_pcaAlg(pset.get<
fhicl::ParameterSet>(
"PrincipalComponentsAlg"))
127 cet::cpu_timer theClockBuildClusters;
133 clusterParametersList.sort([](
auto&
left,
auto&
right){
return left.getFullPCA().getEigenValues()[0] >
right.getFullPCA().getEigenValues()[0];});
139 while(firstClusterItr != clusterParametersList.end())
147 std::cout <<
"+++++++++++++++++++++++++++++++ Checking PCA for cluster # " << clusCntr++ <<
" +++++++++++++++++++++++++++" << std::endl;
153 while(nextClusterItr != clusterParametersList.end())
164 nextClusterItr = clusterParametersList.erase(nextClusterItr);
167 nextClusterItr = firstClusterItr;
180 theClockBuildClusters.stop();
185 mf::LogDebug(
"Cluster3D") <<
">>>>> Merge clusters done, found " << clusterParametersList.size() <<
" clusters" << std::endl;
193 bool consistent(
false);
210 TVector3 firstPosToNextPos = nextCenter - firstCenter;
218 if (firstPosToNextPos.Dot(firstAxis0) < 0.) firstAxis0 = -firstAxis0;
221 double arcLenToNextDoca = firstPosToNextPos.Dot(firstAxis0);
224 TVector3 firstAxisDocaPos = firstCenter + arcLenToNextDoca * firstAxis0;
227 TVector3 nextDocaVec = nextCenter - firstAxisDocaPos;
230 double docaVecProj1 = std::fabs(firstAxis1.Dot(nextDocaVec));
231 double docaVecProj2 = std::fabs(firstAxis2.Dot(nextDocaVec));
239 double firstToNextDist = firstPosToNextPos.Mag();
240 double cosAngFTNtoAxis0 = arcLenToNextDoca / firstToNextDist;
241 double docaVecProj1Cut =
std::max( 1., (1. + 2. * cosAngFTNtoAxis0) * firstEigenVals[1]);
242 double docaVecProj2Cut =
std::max(0.5, (1. + 2. * cosAngFTNtoAxis0) * firstEigenVals[2]);
244 std::cout <<
" ==> Check in tube, doca: " << nextDocaVec.Mag() <<
", proj: " << docaVecProj1 <<
"/" << docaVecProj2 <<
", cut: " << docaVecProj1Cut <<
"/" << docaVecProj2Cut <<
", eigen: " << firstEigenVals[0] <<
"/" << firstEigenVals[1] <<
"/" << firstEigenVals[2] <<
", arcLenToNextDoca: " << arcLenToNextDoca <<
", cos(ang): " << cosAngFTNtoAxis0 << std::endl;
247 if (docaVecProj1 < docaVecProj1Cut && docaVecProj2 < docaVecProj2Cut) consistent =
true;
261 if (firstPosToNextPos.Dot(nextAxis0) < 0.) nextAxis0 = -nextAxis0;
264 float lineDoca =
closestApproach(firstCenter, firstAxis0, nextCenter, nextAxis0, firstPoca, nextPoca);
267 double arcLenToFirstPoca = (firstPoca - firstCenter).Dot(firstAxis0);
268 double arcLenToNextPoca = (nextPoca - nextCenter ).Dot(nextAxis0);
270 std::cout <<
" - arcLenToFirstPoca: " << arcLenToFirstPoca <<
", arcLenToNextPoca: " << arcLenToNextPoca <<
", first/Next dist: " << firstToNextDist << std::endl;
275 if (arcLenToFirstPoca >= 0. && arcLenToFirstPoca < firstToNextDist && arcLenToNextPoca <= 0. && arcLenToNextPoca > -firstToNextDist)
280 double nextArcLenCut = (1. + 5. * cosAngFTNtoAxis0) * nextEigenVal0;
282 std::cout <<
" - linedoca: " << lineDoca <<
", cosAngFTNtoAxis0: " << cosAngFTNtoAxis0 <<
", nextEigenVal0: " << nextEigenVal0 <<
", nextArcLenCut: " << nextArcLenCut << std::endl;
285 if (lineDoca < firstEigenVals[1] && -arcLenToNextPoca < nextArcLenCut) consistent =
true;
371 hitPairListPtr.push_back(
hit);
373 for(
const auto* hit2D :
hit->getHits())
382 std::cout <<
" **>> orig center: " << origCenter[0] <<
"/" << origCenter[1] <<
"/" << origCenter[2] << std::endl;
383 std::cout <<
" orig vector: " << origAxis0[0] <<
"/" << origAxis0[1] <<
"/" << origAxis0[2] << std::endl;
384 std::cout <<
" orig eigen: " << origEigen[0] <<
"/" << origEigen[1] <<
"/" << origEigen[2] << std::endl;
395 std::cout <<
" >>>> new center: " << newCenter[0] <<
"/" << newCenter[1] <<
"/" << newCenter[2] << std::endl;
396 std::cout <<
" new vector: " << newAxis0[0] <<
"/" << newAxis0[1] <<
"/" << newAxis0[2] << std::endl;
397 std::cout <<
" new eigen: " << newEigen[0] <<
"/" << newEigen[1] <<
"/" << newEigen[2] <<
", cos orig to new: " << origAxis0.Dot(newAxis0) << std::endl;
400 if (newEigen[0] > 0.8 * origEigen[0] && newEigen[1] * origEigen[0] < 5. * newEigen[0] * origEigen[1])
409 for(
const auto& pair : nextEdgeMap) firstEdgeMap[pair.first] = pair.second;
415 firstClusterParams = clusterParams;
425 const TVector3& P1,
const TVector3& u1,
427 TVector3& poca1)
const 430 TVector3 w0 = P0 - P1;
436 float den(a * c - b * b);
438 float arcLen0 = (b *
e - c *
d) / den;
439 float arcLen1 = (a *
e - b *
d) / den;
441 poca0 = P0 + arcLen0 * u0;
442 poca1 = P1 + arcLen1 * u1;
444 return (poca0 - poca1).Mag();
void ModifyClusters(reco::ClusterParametersList &) const override
Scan an input collection of clusters and modify those according to the specific implementing algorith...
void configure(fhicl::ParameterSet const &pset) override
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
void PCAAnalysis_3D(const reco::HitPairListPtr &hitPairList, reco::PrincipalComponents &pca, bool skeletonOnly=false) const
float closestApproach(const TVector3 &, const TVector3 &, const TVector3 &, const TVector3 &, TVector3 &, TVector3 &) const
~ClusterMergeAlg()
Destructor.
geo::Geometry * m_geometry
Declaration of signal hit object.
reco::PrincipalComponents & getSkeletonPCA()
const float * getAvePosition() const
reco::Hit3DToEdgeMap & getHit3DToEdgeMap()
reco::HitPairListPtr & getHitPairListPtr()
IClusterModAlg interface class definiton.
PrincipalComponentsAlg m_pcaAlg
bool mergeClusters(reco::ClusterParameters &, reco::ClusterParameters &) const
float getTimeToExecute() const override
If monitoring, recover the time to execute a particular function.
reco::PrincipalComponents & getFullPCA()
T get(std::string const &key) const
ClusterMergeAlg(const fhicl::ParameterSet &)
Constructor.
std::list< const reco::ClusterHit3D * > HitPairListPtr
void UpdateParameters(const reco::ClusterHit2D *hit)
The geometry of one entire detector, as served by art.
Detector simulation of raw signals on wires.
This header file defines the interface to a principal components analysis designed to be used within ...
Encapsulate the geometry of a wire.
bool consistentClusters(const reco::PrincipalComponents &, const reco::PrincipalComponents &) const
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Utility object to perform functions of association.
const float * getEigenValues() const
Encapsulate the construction of a single detector plane.
bool m_enableMonitoring
Data members to follow.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
This provides an art tool interface definition for 3D Cluster algorithms.
double m_minEigenToProcess
Don't look anymore at clusters below this size.
std::unordered_map< const reco::ClusterHit3D *, reco::EdgeList > Hit3DToEdgeMap
art framework interface to geometry description
std::list< ClusterParameters > ClusterParametersList
const EigenVectors & getEigenVectors() const
double m_minCosAxisAng
minimum Cos(angle) cut value