68 std::vector<recob::Seed> ReturnVector;
71 std::vector<recob::SpacePoint> spts;
76 if (
int(spts.size()) <
fMinPointsInSeed) {
return std::vector<recob::Seed>(); }
84 std::vector<std::vector<std::vector<int>>> OrgHits(3);
85 for (
size_t n = 0;
n != 3; ++
n)
90 std::vector<std::vector<int>> SpacePointsPerHit(HitsFlat.size(), std::vector<int>());
91 std::vector<std::vector<int>> HitsPerSpacePoint(spts.size(), std::vector<int>());
99 std::vector<char> HitStatus(HitsFlat.size(), 0);
103 for (
size_t i = 0; i != HitsFlat.size(); ++i) {
104 OrgHits[HitsFlat.at(i)->View()][HitsFlat.at(i)->Channel()].push_back(i);
109 for (
size_t iSP = 0; iSP != spts.size(); ++iSP) {
112 for (
size_t iH = 0; iH != HitsThisSP.size(); ++iH) {
114 uint32_t ThisChannel = HitsThisSP.at(iH)->Channel();
115 float ThisTime = HitsThisSP.at(iH)->PeakTime();
118 for (
size_t iOrg = 0; iOrg != OrgHits[ThisView][ThisChannel].size(); ++iOrg) {
119 if (fabs(ThisTime - HitsFlat.at(OrgHits[ThisView][ThisChannel][iOrg])->PeakTime()) <
121 SpacePointsPerHit.at(OrgHits[ThisView][ThisChannel][iOrg]).push_back(iSP);
122 HitsPerSpacePoint.at(iSP).push_back(OrgHits[ThisView][ThisChannel][iOrg]);
142 std::vector<char> PointStatus(spts.size(), 0);
144 std::vector<std::map<geo::View_t, std::vector<int>>> WhichHitsPerSeed;
146 bool KeepChopping =
true;
148 while (KeepChopping) {
150 std::vector<int> PointsUsed;
161 for (
size_t iP = 0; iP != PointsUsed.size(); ++iP) {
162 for (
size_t iH = 0; iH != HitsPerSpacePoint.at(PointsUsed.at(iP)).
size(); ++iH) {
163 int UsedHitID = HitsPerSpacePoint.at(PointsUsed.at(iP)).at(iH);
164 HitStatus[UsedHitID] = 2;
167 PointStatus[PointsUsed.at(0)] = 1;
173 std::vector<char> HitStatusGood;
175 for (
size_t r = 0;
r != (
unsigned int)
fRefits; ++
r) {
179 HitStatusGood = HitStatus;
181 std::vector<int> PresentHitList;
182 for (
size_t iH = 0; iH != HitStatus.size(); ++iH) {
183 if (HitStatus[iH] == 2) { PresentHitList.push_back(iH); }
185 double pt[3],
dir[3],
err[3];
190 TVector3 Center, Direction;
191 std::vector<double> ViewRMS;
192 std::vector<int> HitsPerView;
194 detProp, HitsFlat, PresentHitList, Center, Direction, ViewRMS, HitsPerView);
196 Direction = Direction.Unit() * TheSeed.
GetLength();
198 int nViewsWithHits(0);
199 for (
size_t n = 0;
n != 3; ++
n) {
201 dir[
n] = Direction[
n];
206 if (HitsPerView[
n] > 0) nViewsWithHits++;
209 if (nViewsWithHits < 2) TheSeed.
SetValidity(
false);
218 HitStatus = HitStatusGood;
231 WhichHitsPerSeed.push_back(std::map<
geo::View_t, std::vector<int>>());
233 art::PtrVector<recob::Hit> HitsWithThisSeed;
234 for (
size_t iH = 0; iH != HitStatus.size(); ++iH) {
235 if (HitStatus.at(iH) == 2) {
236 WhichHitsPerSeed.at(WhichHitsPerSeed.size() - 1)[HitsFlat[iH]->View()].push_back(iH);
237 HitsWithThisSeed.push_back(HitsFlat.at(iH));
238 HitStatus.at(iH) = 1;
240 for (
size_t iSP = 0; iSP != SpacePointsPerHit.at(iH).size(); ++iSP) {
241 PointStatus[SpacePointsPerHit.at(iH).at(iSP)] = 1;
247 ReturnVector.push_back(TheSeed);
248 CataloguedHits.push_back(HitsWithThisSeed);
251 HitsWithThisSeed.clear();
255 PointStatus.at(PointsUsed.at(0)) = 2;
258 int TotalSPsUsed = 0;
259 for (
size_t i = 0; i != PointStatus.size(); ++i) {
260 if (PointStatus[i] != 0) TotalSPsUsed++;
263 if ((
int(spts.size()) - TotalSPsUsed) <
fMinPointsInSeed) KeepChopping =
false;
265 if ((PointStatus[0] == 3) || (PointStatus.size() == 0)) KeepChopping =
false;
269 if ((ReturnVector.size() >= StopAfter) && (StopAfter > 0))
break;
277 if (ReturnVector.size() == 0) {
278 std::vector<int> ListAllHits;
279 for (
size_t i = 0; i != HitsFlat.size(); ++i) {
280 ListAllHits.push_back(i);
283 TVector3 SeedCenter(0, 0, 0);
284 TVector3 SeedDirection(0, 0, 0);
286 std::vector<double> ViewRMS;
287 std::vector<int> HitsPerView;
289 std::vector<art::PtrVector<recob::Hit>> HitsInThisCollection(3);
292 detProp, HitsFlat, ListAllHits, SeedCenter, SeedDirection, ViewRMS, HitsPerView);
294 bool ThrowOutSeed =
false;
296 double PtArray[3], DirArray[3];
297 int nViewsWithHits(0);
298 for (
size_t n = 0;
n != 3; ++
n) {
299 PtArray[
n] = SeedCenter[
n];
300 DirArray[
n] = SeedDirection[
n];
301 if (HitsPerView[
n] > 0) nViewsWithHits++;
305 if (nViewsWithHits < 2 || (nViewsWithHits < 3 && !
fAllow2DSeeds)) ThrowOutSeed =
true;
313 for (
size_t i = 0; i != HitStatus.size(); ++i) {
314 if (HitStatus.at(i) == 2) ListAllHits.push_back(i);
316 std::vector<int> HitsPerView;
318 detProp, HitsFlat, ListAllHits, SeedCenter, SeedDirection, ViewRMS, HitsPerView);
320 int nViewsWithHits(0);
321 for (
size_t n = 0;
n != 3; ++
n) {
322 PtArray[
n] = SeedCenter[
n];
323 DirArray[
n] = SeedDirection[
n];
325 if (HitsPerView[
n] > 0) nViewsWithHits++;
328 if (nViewsWithHits < 2 || (nViewsWithHits < 3 && !
fAllow2DSeeds)) ThrowOutSeed =
true;
334 if (
fMaxViewRMS.at(j) < ViewRMS.at(j)) { ThrowOutSeed =
true; }
339 if ((!ThrowOutSeed) && (TheSeed.
IsValid())) {
340 ReturnVector.push_back(TheSeed);
341 art::PtrVector<recob::Hit> HitsThisSeed;
342 for (
size_t i = 0; i != ListAllHits.size(); ++i) {
343 HitsThisSeed.push_back(HitsFlat.at(ListAllHits.at(i)));
345 CataloguedHits.push_back(HitsThisSeed);
350 SpacePointsPerHit.clear();
351 HitsPerSpacePoint.clear();
356 for (
size_t i = 0; i != ReturnVector.size(); ++i) {
357 double CrazyValue = 1000000;
358 double Length = ReturnVector.at(i).GetLength();
359 if (!((Length >
fLengthCut) && (Length < CrazyValue))) {
360 ReturnVector.erase(ReturnVector.begin() + i);
361 CataloguedHits.erase(CataloguedHits.begin() + i);
std::vector< double > fPitches
float Length(const PFPStruct &pfp)
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
EResult err(const char *call)
void GetPoint(double *Pt, double *Err) const
std::size_t size(FixedBins< T, C > const &) noexcept
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
void SetPoint(double *Pt, double *Err)
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
void SetValidity(bool Validity)
void GetDirection(double *Dir, double *Err) const
void SetDirection(double *Dir, double *Err)
std::vector< double > fMaxViewRMS