28 #include "TDecompSVD.h" 46 m_minAllowedCosAng(0.7),
47 m_pcaAlg(pset.get<
fhicl::ParameterSet>(
"PrincipalComponentsAlg"))
76 bool foundGoodSeed(
false);
88 if (eigenVal0 > 5. && eigenVal1 > 0.001)
103 hit3DList.resize(hitPairListPtr.size());
105 std::copy(hitPairListPtr.begin(), hitPairListPtr.end(), hit3DList.begin());
116 checkList.resize(hitPairListPtr.size());
118 std::copy(hitPairListPtr.begin(), hitPairListPtr.end(), checkList.begin());
120 std::reverse(checkList.begin(), checkList.end());
135 double seedDir[3] = {seedPca.getEigenVectors()[0][0], seedPca.getEigenVectors()[0][1], seedPca.getEigenVectors()[0][2]};
136 double seedStart[3] = {hit3DList.front()->getX(), hit3DList.front()->getY(), hit3DList.front()->getZ()};
138 if (hit3DList.size() > 10)
144 LineFit2DHits(hit3DList, seedStart[0], newSeedPos, newSeedDir, chiDOF);
149 double cosAng = seedDir[0]*newSeedDir[0]+seedDir[1]*newSeedDir[1]+seedDir[2]*newSeedDir[2];
151 if (cosAng < 0.) newSeedDir *= -1.;
153 seedStart[0] = newSeedPos[0];
154 seedStart[1] = newSeedPos[1];
155 seedStart[2] = newSeedPos[2];
156 seedDir[0] = newSeedDir[0];
157 seedDir[1] = newSeedDir[1];
158 seedDir[2] = newSeedDir[2];
162 for(
const auto& hit3D : hit3DList) hit3D->setStatusBit(0x40000000);
164 seedHitPairVec.emplace_back(std::pair<recob::Seed, reco::HitPairListPtr>(
recob::Seed(seedStart, seedDir), hit3DList));
166 foundGoodSeed =
true;
171 return foundGoodSeed;
176 bool foundGoodSeedHits(
false);
179 std::set<const reco::ClusterHit2D*> hit2DSet;
182 double lastArcLen = hit3DList.front()->getArclenToPoca();
187 while(++lastItr != hit3DList.end())
198 for(
const auto& hit2D : hit3D->
getHits())
200 hit2DSet.insert(hit2D);
210 if (startItr != hit3DList.begin()) hit3DList.erase(hit3DList.begin(), startItr);
211 if (lastItr != hit3DList.end() ) hit3DList.erase(lastItr, hit3DList.end());
226 double cosAng = primarySeedAxis.Dot(planeVec0);
234 return foundGoodSeedHits;
242 double& ChiDOF)
const 265 std::set<const reco::ClusterHit2D*> hit2DSet;
267 for(
const auto& hit3D : hit3DList)
269 for(
const auto& hit2D : hit3D->getHits()) hit2DSet.insert(hit2D);
272 if(hit2DSet.size() < 4)
return;
274 const unsigned int nvars = 4;
275 unsigned int npts = 3 * hit3DList.size();
277 TMatrixD A(npts, nvars);
280 unsigned short ninpl[3] = {0};
281 unsigned short nok = 0;
282 unsigned short iht(0), cstat, tpc, ipl;
283 double x, cw,
sw, off;
286 for (
const auto&
hit : hit2DSet)
303 x =
hit->getXPosition() - XOrigin;
309 w[iht] = wireID.
Wire - off;
314 if(ninpl[ipl] == 2) ++nok;
324 TVectorD tVec = svd.Solve(w, ok);
329 if(npts <= 4)
return;
331 double ypr, zpr, diff;
333 for (
const auto&
hit : hit2DSet)
343 x =
hit->getXPosition() - XOrigin;
344 ypr = tVec[0] + tVec[2] *
x;
345 zpr = tVec[1] + tVec[3] *
x;
346 diff = ypr * cw + zpr * sw - (wireID.
Wire - off);
347 ChiDOF += diff * diff;
352 ChiDOF /= (float)(npts - 4);
354 double norm = sqrt(1 + tVec[2] * tVec[2] + tVec[3] * tVec[3]);
356 Dir[1] = tVec[2] /
norm;
357 Dir[2] = tVec[3] /
norm;
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
std::vector< SeedHitPairListPair > SeedHitPairListPairVec
Define a comparator which will sort hits by arc length along a PCA axis.
void PCAAnalysis_calc3DDocas(const reco::HitPairListPtr &hitPairVector, const reco::PrincipalComponents &pca) const
bool getHitsAtEnd(reco::HitPairListPtr &hit3DList, reco::PrincipalComponents &seedPca) const
Separate function to find hits at the ends of the input hits.
void PCAAnalysis_3D(const reco::HitPairListPtr &hitPairList, reco::PrincipalComponents &pca, bool skeletonOnly=false) const
void flipAxis(size_t axis)
void reconfigure(fhicl::ParameterSet const &pset)
a handler for the case where the algorithm control parameters are to be reset
Declaration of signal hit object.
virtual bool findTrackSeeds(reco::HitPairListPtr &hitPairListPtr, reco::PrincipalComponents &inputPCA, SeedHitPairListPairVec &seedHitMap) const
Given the list of hits this will search for candidate Seed objects and return them.
CryostatID_t Cryostat
Index of cryostat.
geo::Geometry * m_geometry
WireID_t Wire
Index of the wire within its plane.
PrincipalComponentsAlg m_pcaAlg
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
This is an algorithm for finding recob::Seed objects in 3D clusters.
Define a comparator which will sort hits by the absolute value of arc length so hits are ordered clos...
virtual void reconfigure(fhicl::ParameterSet const &pset)
a handler for the case where the algorithm control parameters are to be reset
T get(std::string const &key) const
std::list< const reco::ClusterHit3D * > HitPairListPtr
PlaneID_t Plane
Index of the plane within its TPC.
Detector simulation of raw signals on wires.
Encapsulate the geometry of a wire.
double m_minAllowedCosAng
The minimum cos(ang) between input and seed axes.
virtual ~PCASeedFinderAlg()
Destructor.
PCASeedFinderAlg(fhicl::ParameterSet const &pset)
Constructor.
const float * getEigenValues() const
Encapsulate the construction of a single detector plane.
float getArclenToPoca() const
TPCID_t TPC
Index of the TPC within its cryostat.
void LineFit2DHits(const reco::HitPairListPtr &hitList, double XOrigin, TVector3 &Pos, TVector3 &Dir, double &ChiDOF) const
const ClusterHit2DVec & getHits() const
art framework interface to geometry description
const EigenVectors & getEigenVectors() const