67 std::vector<recob::Seed> ReturnVector;
70 std::vector<recob::SpacePoint> spts;
75 if (
int(spts.size()) <
fMinPointsInSeed) {
return std::vector<recob::Seed>(); }
83 std::vector<std::vector<std::vector<int>>> OrgHits(3);
84 for (
size_t n = 0;
n != 3; ++
n)
89 std::vector<std::vector<int>> SpacePointsPerHit(HitsFlat.
size(), std::vector<int>());
90 std::vector<std::vector<int>> HitsPerSpacePoint(spts.size(), std::vector<int>());
98 std::vector<char> HitStatus(HitsFlat.
size(), 0);
102 for (
size_t i = 0; i != HitsFlat.
size(); ++i) {
103 OrgHits[HitsFlat.
at(i)->View()][HitsFlat.
at(i)->Channel()].push_back(i);
108 for (
size_t iSP = 0; iSP != spts.size(); ++iSP) {
111 for (
size_t iH = 0; iH != HitsThisSP.
size(); ++iH) {
113 uint32_t ThisChannel = HitsThisSP.
at(iH)->Channel();
114 float ThisTime = HitsThisSP.
at(iH)->PeakTime();
117 for (
size_t iOrg = 0; iOrg != OrgHits[ThisView][ThisChannel].size(); ++iOrg) {
118 if (fabs(ThisTime - HitsFlat.
at(OrgHits[ThisView][ThisChannel][iOrg])->PeakTime()) <
120 SpacePointsPerHit.at(OrgHits[ThisView][ThisChannel][iOrg]).push_back(iSP);
121 HitsPerSpacePoint.at(iSP).push_back(OrgHits[ThisView][ThisChannel][iOrg]);
141 std::vector<char> PointStatus(spts.size(), 0);
143 std::vector<std::map<geo::View_t, std::vector<int>>> WhichHitsPerSeed;
145 bool KeepChopping =
true;
147 while (KeepChopping) {
149 std::vector<int> PointsUsed;
153 FindSeedAtEnd(detProp, spts, PointStatus, PointsUsed, HitsFlat, OrgHits);
160 for (
size_t iP = 0; iP != PointsUsed.size(); ++iP) {
161 for (
size_t iH = 0; iH != HitsPerSpacePoint.at(PointsUsed.at(iP)).
size(); ++iH) {
162 int UsedHitID = HitsPerSpacePoint.at(PointsUsed.at(iP)).at(iH);
163 HitStatus[UsedHitID] = 2;
166 PointStatus[PointsUsed.at(0)] = 1;
167 ConsolidateSeed(detProp, TheSeed, HitsFlat, HitStatus, OrgHits,
false);
172 std::vector<char> HitStatusGood;
178 HitStatusGood = HitStatus;
180 std::vector<int> PresentHitList;
181 for (
size_t iH = 0; iH != HitStatus.size(); ++iH) {
182 if (HitStatus[iH] == 2) { PresentHitList.push_back(iH); }
184 double pt[3],
dir[3],
err[3];
190 std::vector<double> ViewRMS;
191 std::vector<int> HitsPerView;
193 detProp, HitsFlat, PresentHitList, Center, Direction, ViewRMS, HitsPerView);
195 Direction = Direction.Unit() * TheSeed.
GetLength();
197 int nViewsWithHits(0);
198 for (
size_t n = 0;
n != 3; ++
n) {
200 dir[
n] = Direction[
n];
205 if (HitsPerView[
n] > 0) nViewsWithHits++;
208 if (nViewsWithHits < 2) TheSeed.
SetValidity(
false);
217 HitStatus = HitStatusGood;
230 WhichHitsPerSeed.push_back(std::map<
geo::View_t, std::vector<int>>());
233 for (
size_t iH = 0; iH != HitStatus.size(); ++iH) {
234 if (HitStatus.at(iH) == 2) {
235 WhichHitsPerSeed.at(WhichHitsPerSeed.size() - 1)[HitsFlat[iH]->
View()].push_back(iH);
237 HitStatus.at(iH) = 1;
239 for (
size_t iSP = 0; iSP != SpacePointsPerHit.at(iH).size(); ++iSP) {
240 PointStatus[SpacePointsPerHit.at(iH).at(iSP)] = 1;
246 ReturnVector.push_back(TheSeed);
247 CataloguedHits.push_back(HitsWithThisSeed);
250 HitsWithThisSeed.
clear();
254 PointStatus.at(PointsUsed.at(0)) = 2;
257 int TotalSPsUsed = 0;
258 for (
size_t i = 0; i != PointStatus.size(); ++i) {
259 if (PointStatus[i] != 0) TotalSPsUsed++;
262 if ((
int(spts.size()) - TotalSPsUsed) <
fMinPointsInSeed) KeepChopping =
false;
264 if ((PointStatus[0] == 3) || (PointStatus.size() == 0)) KeepChopping =
false;
268 if ((ReturnVector.size() >= StopAfter) && (StopAfter > 0))
break;
276 if (ReturnVector.size() == 0) {
277 std::vector<int> ListAllHits;
278 for (
size_t i = 0; i != HitsFlat.
size(); ++i) {
279 ListAllHits.push_back(i);
282 TVector3 SeedCenter(0, 0, 0);
283 TVector3 SeedDirection(0, 0, 0);
285 std::vector<double> ViewRMS;
286 std::vector<int> HitsPerView;
288 std::vector<art::PtrVector<recob::Hit>> HitsInThisCollection(3);
291 detProp, HitsFlat, ListAllHits, SeedCenter, SeedDirection, ViewRMS, HitsPerView);
293 bool ThrowOutSeed =
false;
295 double PtArray[3], DirArray[3];
296 int nViewsWithHits(0);
297 for (
size_t n = 0;
n != 3; ++
n) {
298 PtArray[
n] = SeedCenter[
n];
299 DirArray[
n] = SeedDirection[
n];
300 if (HitsPerView[
n] > 0) nViewsWithHits++;
304 if (nViewsWithHits < 2 || (nViewsWithHits < 3 && !
fAllow2DSeeds)) ThrowOutSeed =
true;
307 ConsolidateSeed(detProp, TheSeed, HitsFlat, HitStatus, OrgHits,
false);
312 for (
size_t i = 0; i != HitStatus.size(); ++i) {
313 if (HitStatus.at(i) == 2) ListAllHits.push_back(i);
315 std::vector<int> HitsPerView;
317 detProp, HitsFlat, ListAllHits, SeedCenter, SeedDirection, ViewRMS, HitsPerView);
319 int nViewsWithHits(0);
320 for (
size_t n = 0;
n != 3; ++
n) {
321 PtArray[
n] = SeedCenter[
n];
322 DirArray[
n] = SeedDirection[
n];
324 if (HitsPerView[
n] > 0) nViewsWithHits++;
327 if (nViewsWithHits < 2 || (nViewsWithHits < 3 && !
fAllow2DSeeds)) ThrowOutSeed =
true;
333 if (
fMaxViewRMS.at(j) < ViewRMS.at(j)) { ThrowOutSeed =
true; }
338 if ((!ThrowOutSeed) && (TheSeed.
IsValid())) {
339 ReturnVector.push_back(TheSeed);
341 for (
size_t i = 0; i != ListAllHits.size(); ++i) {
342 HitsThisSeed.
push_back(HitsFlat.
at(ListAllHits.at(i)));
344 CataloguedHits.push_back(HitsThisSeed);
349 SpacePointsPerHit.clear();
350 HitsPerSpacePoint.clear();
355 for (
size_t i = 0; i != ReturnVector.size(); ++i) {
356 double CrazyValue = 1000000;
357 double Length = ReturnVector.at(i).GetLength();
358 if (!((Length >
fLengthCut) && (Length < CrazyValue))) {
359 ReturnVector.erase(ReturnVector.begin() + i);
360 CataloguedHits.erase(CataloguedHits.begin() + i);
std::vector< double > fPitches
float Length(const PFPStruct &pfp)
AdcChannelData::View View
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
void GetPoint(double *Pt, double *Err) const
void resize(Vector< T > &vec1, Index n1, const V &val)
recob::Seed FindSeedAtEnd(detinfo::DetectorPropertiesData const &detProp, std::vector< recob::SpacePoint > const &, std::vector< char > &, std::vector< int > &, art::PtrVector< recob::Hit > const &HitsFlat, std::vector< std::vector< std::vector< int >>> &OrgHits) const
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
void ConsolidateSeed(detinfo::DetectorPropertiesData const &detProp, recob::Seed &TheSeed, art::PtrVector< recob::Hit > const &, std::vector< char > &HitStatus, std::vector< std::vector< std::vector< int >>> &OrgHits, bool Extend) const
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
void SetPoint(double *Pt, double *Err)
void push_back(Ptr< U > const &p)
void makeSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
void GetCenterAndDirection(detinfo::DetectorPropertiesData const &detProp, art::PtrVector< recob::Hit > const &HitsFlat, std::vector< int > &HitsToUse, TVector3 &Center, TVector3 &Direction, std::vector< double > &ViewRMS, std::vector< int > &HitsPerView) const
reference at(size_type n)
void err(const char *fmt,...)
void SetValidity(bool Validity)
void GetDirection(double *Dir, double *Err) const
void SetDirection(double *Dir, double *Err)
std::vector< double > fMaxViewRMS