413 static int histCount(0);
414 const double maxTheta(M_PI);
415 const double thetaBinSize(maxTheta /
double(
m_thetaBins));
419 Eigen::Vector3f pcaCenter(
426 double maxRho = std::sqrt(eigenVal0 * eigenVal0 + eigenVal1 * eigenVal1) * 2. / 3.;
427 double rhoBinSize = maxRho / double(
m_rhoBins);
429 if (rhoBinSize < rhoBinSizeMin) rhoBinSize = rhoBinSizeMin;
435 size_t maxBinCount(0);
436 int nAccepted3DHits(0);
439 for (reco::HitPairListPtr::const_iterator hit3DItr = hitPairListPtr.begin();
440 hit3DItr != hitPairListPtr.end();
446 if (!(hit3D->getStatusBits() & 0x10000000))
continue;
450 Eigen::Vector3f hit3DPosition(
451 hit3D->getPosition()[0], hit3D->getPosition()[1], hit3D->getPosition()[2]);
452 Eigen::Vector3f pcaToHitVec = hit3DPosition - pcaCenter;
453 Eigen::Vector3f pcaToHitPlaneVec(pcaToHitVec.dot(planeVec0), pcaToHitVec.dot(planeVec1), 0.);
454 double xPcaToHit = pcaToHitPlaneVec[0];
455 double yPcaToHit = pcaToHitPlaneVec[1];
458 AccumulatorValues accValue(pcaToHitPlaneVec, hit3DItr);
462 for (
int thetaIdx = 0; thetaIdx <
m_thetaBins; thetaIdx++) {
464 double theta = thetaBinSize * double(thetaIdx);
467 double rho = xPcaToHit * std::cos(theta) + yPcaToHit * std::sin(theta);
470 int rhoIdx = std::round(rho / rhoBinSize);
473 BinIndex binIndex(rhoIdx, thetaIdx);
475 rhoThetaAccumulatorBinMap[binIndex].addAccumulatorValue(accValue);
477 if (rhoThetaAccumulatorBinMap[binIndex].getAccumulatorValues().
size() > maxBinCount)
478 maxBinCount = rhoThetaAccumulatorBinMap[binIndex].getAccumulatorValues().size();
484 std::ostringstream ostr;
485 ostr <<
"Hough Histogram " << histCount++;
486 m_Canvases.emplace_back(
new TCanvas(ostr.str().c_str(), ostr.str().c_str(), 1000, 1000));
488 std::ostringstream ostr2;
491 m_Canvases.back()->GetFrame()->SetFillColor(46);
500 TPad*
p =
new TPad(ostr2.str().c_str(), ostr2.str().c_str(), zmin,
xmin, zmax, xmax);
501 p->SetBit(kCanDelete);
502 p->Range(zmin, xmin, zmax, xmax);
503 p->SetFillStyle(4000);
507 TH2D* houghHist =
new TH2D(
"HoughHist",
516 for (
const auto& rhoThetaMap : rhoThetaAccumulatorBinMap) {
517 houghHist->Fill(rhoThetaMap.first.first,
518 rhoThetaMap.first.second + 0.5,
519 rhoThetaMap.second.getAccumulatorValues().size());
522 houghHist->SetBit(kCanDelete);
534 std::list<RhoThetaAccumulatorBinMap::iterator> binIndexList;
536 for (RhoThetaAccumulatorBinMap::iterator mapItr = rhoThetaAccumulatorBinMap.begin();
537 mapItr != rhoThetaAccumulatorBinMap.end();
539 binIndexList.push_back(mapItr);
541 binIndexList.sort(SortBinIndexList());
543 for (
auto& mapItr : binIndexList) {
546 if (mapItr->second.isInCluster())
continue;
553 if (mapItr->second.getAccumulatorValues().size() < thresholdLo) {
554 mapItr->second.setNoise();
559 thresholdHi = std::max(
566 HoughRegionQuery(curBin, rhoThetaAccumulatorBinMap, neighborhood, thresholdHi);
573 curBin, neighborhood, houghCluster, rhoThetaAccumulatorBinMap, thresholdHi);
577 if (!houghClusters.empty()) houghClusters.sort(SortHoughClusterList(rhoThetaAccumulatorBinMap));
geo::Geometry const * m_geometry
std::vector< TVirtualPad * > m_Pads
View pads in current canvas.
std::size_t size(FixedBins< T, C > const &) noexcept
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
void expandHoughCluster(BinIndex &curBin, HoughCluster &neighborPts, HoughCluster &houghCluster, RhoThetaAccumulatorBinMap &rhoThetaAccumulatorBinMap, size_t threshold) const
const EigenValues & getEigenValues() const
void HoughRegionQuery(BinIndex &curBin, RhoThetaAccumulatorBinMap &rhoThetaAccumulatorBinMap, HoughCluster &neighborPts, size_t threshold) const
const Eigen::Vector3f & getAvePosition() const
std::list< BinIndex > HoughCluster
std::pair< int, int > BinIndex
std::vector< std::unique_ptr< TCanvas > > m_Canvases
Graphical trace canvases.
const EigenVectors & getEigenVectors() const