11 #include "cetlib/search_path.h" 12 #include "cetlib/cpu_timer.h" 82 float closestApproach(
const TVector3&,
const TVector3&,
const TVector3&,
const TVector3&, TVector3&, TVector3&)
const;
98 m_pcaAlg(pset.get<
fhicl::ParameterSet>(
"PrincipalComponentsAlg"))
141 cet::cpu_timer theClockBuildClusters;
147 clusterParametersList.sort([](
auto&
left,
auto&
right){
return left.getFullPCA().getEigenValues()[0] >
right.getFullPCA().getEigenValues()[0];});
153 while(firstClusterItr != clusterParametersList.end())
167 while(nextClusterItr != clusterParametersList.end())
178 nextClusterItr = clusterParametersList.erase(nextClusterItr);
181 nextClusterItr = firstClusterItr;
194 theClockBuildClusters.stop();
199 mf::LogDebug(
"Cluster3D") <<
">>>>> Merge clusters done, found " << clusterParametersList.size() <<
" clusters" << std::endl;
207 bool consistent(
false);
224 TVector3 firstPosToNextPos = nextCenter - firstCenter;
232 if (firstPosToNextPos.Dot(firstAxis0) < 0.) firstAxis0 = -firstAxis0;
235 double arcLenToNextDoca = firstPosToNextPos.Dot(firstAxis0);
238 TVector3 firstAxisDocaPos = firstCenter + arcLenToNextDoca * firstAxis0;
241 TVector3 nextDocaVec = nextCenter - firstAxisDocaPos;
244 double docaVecProj1 = std::fabs(firstAxis1.Dot(nextDocaVec));
245 double docaVecProj2 = std::fabs(firstAxis2.Dot(nextDocaVec));
253 double firstToNextDist = firstPosToNextPos.Mag();
254 double cosAngFTNtoAxis0 = arcLenToNextDoca / firstToNextDist;
255 double docaVecProj1Cut =
std::max( 1., (1. + 2. * cosAngFTNtoAxis0) * firstEigenVals[1]);
256 double docaVecProj2Cut =
std::max(0.5, (1. + 2. * cosAngFTNtoAxis0) * firstEigenVals[2]);
261 if (docaVecProj1 < docaVecProj1Cut && docaVecProj2 < docaVecProj2Cut) consistent =
true;
275 if (firstPosToNextPos.Dot(nextAxis0) < 0.) nextAxis0 = -nextAxis0;
278 float lineDoca =
closestApproach(firstCenter, firstAxis0, nextCenter, nextAxis0, firstPoca, nextPoca);
281 double arcLenToFirstPoca = (firstPoca - firstCenter).Dot(firstAxis0);
282 double arcLenToNextPoca = (nextPoca - nextCenter ).Dot(nextAxis0);
289 if (arcLenToFirstPoca >= 0. && arcLenToFirstPoca < firstToNextDist && arcLenToNextPoca <= 0. && arcLenToNextPoca > -firstToNextDist)
294 double nextArcLenCut = (1. + 5. * cosAngFTNtoAxis0) * nextEigenVal0;
299 if (lineDoca < firstEigenVals[1] && -arcLenToNextPoca < nextArcLenCut) consistent =
true;
385 hitPairListPtr.push_back(
hit);
387 for(
const auto* hit2D :
hit->getHits())
423 for(
const auto& pair : nextEdgeMap) firstEdgeMap[pair.first] = pair.second;
429 firstClusterParams = clusterParams;
439 const TVector3& P1,
const TVector3& u1,
441 TVector3& poca1)
const 444 TVector3 w0 = P0 - P1;
450 float den(a * c - b * b);
452 float arcLen0 = (b *
e - c *
d) / den;
453 float arcLen1 = (a *
e - b *
d) / den;
455 poca0 = P0 + arcLen0 * u0;
456 poca1 = P1 + arcLen1 * u1;
458 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
void initializeHistograms(art::TFileDirectory &) override
Interface for initializing histograms if they are desired Note that the idea is to put hisgtograms in...
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