3 #include "lsst/log/Log.h" 8 LOG_LOGGER _log = LOG_GET(
"jointcal.FastFinder");
15 : baselist(list), count(list.size()), stars(count), nslice(nXSlice), index(nslice + 1) {
16 if (
count == 0)
return;
20 for (
auto const &ci : list) {
39 for (
unsigned islice = 1; islice <
nslice; ++islice) {
40 double xend = xmin + (islice)*
xstep;
41 while (istar <
count &&
stars[istar]->x < xend) ++istar;
42 index[islice] = istar;
45 for (
unsigned islice = 0; islice <
nslice; ++islice) {
48 return (E1->y < E2->y);
55 for (
unsigned i = 0; i <
count; ++i) {
61 bool (*SkipIt)(
const BaseStar &))
const {
62 if (
count == 0)
return nullptr;
64 if (*it ==
nullptr)
return nullptr;
65 std::shared_ptr<const BaseStar> pbest;
66 double minDist2 = maxDist * maxDist;
67 for (; *it !=
nullptr; ++it) {
68 if (SkipIt && SkipIt(**it))
continue;
70 if (dist2 < minDist2) {
79 std::shared_ptr<const BaseStar> &closest,
80 bool (*SkipIt)(
const BaseStar &))
const {
82 if (
count == 0)
return nullptr;
84 if (*it ==
nullptr)
return nullptr;
85 std::shared_ptr<const BaseStar> pbest1;
86 std::shared_ptr<const BaseStar> pbest2;
87 double minDist1_2 = maxDist * maxDist;
88 double minDist2_2 = maxDist * maxDist;
89 for (; *it !=
nullptr; ++it) {
90 if (SkipIt && SkipIt(**it))
continue;
92 if (dist2 < minDist1_2) {
94 minDist2_2 = minDist1_2;
97 }
else if (dist2 < minDist2_2) {
112 if (begin ==
stars.end() || begin == end)
return stars.end();
113 int span = end - begin - 1;
115 int half_span = span / 2;
116 pstar middle = begin + half_span;
117 if ((*middle)->y < yVal) {
121 span -= (span - half_span);
131 int span = end - begin - 1;
133 int half_span = span / 2;
134 pstar middle = end - half_span;
135 if ((*middle)->y > yVal) {
139 span -= (span - half_span);
158 : finder(F), null_value(F.
stars.end()) {
175 yEnd = where.
y + maxDist;
205 LOGLS_ERROR(_log,
"Error in FastFinder " << *
current <<
" " << *(
finder.
stars.begin()) <<
' '
const FastFinder & finder
decltype(stars) typedef ::const_iterator pstar
std::vector< std::shared_ptr< const BaseStar > > stars
Iterator(const FastFinder &f, const Point &where, double maxDist)
void dump() const
mostly for debugging
pstar locateYEnd(pstar begin, pstar end, double yVal) const
The base class for handling stars. Used by all matching routines.
std::shared_ptr< const BaseStar > findClosest(const Point &where, const double maxDist, bool(*SkipIt)(const BaseStar &)=nullptr) const
Find the closest with some rejection capability.
FastFinder::Iterator Iterator
Class for a simple mapping implementing a generic Gtransfo.
Iterator beginScan(const Point &where, double maxDist) const
Iterator meant to traverse objects within some limiting distance.
FastFinder(const BaseStarList &list, const unsigned nXSlice=100)
Constructor.
pstar locateYStart(pstar begin, pstar end, double yVal) const
void findRangeInSlice(const int iSlice, const double yStart, const double yEnd, pstar &start, pstar &end) const
This is an auxillary class for matching objects from starlists.
std::vector< unsigned > index
decltype(stars) typedef ::value_type stars_element
std::shared_ptr< const BaseStar > secondClosest(const Point &where, const double maxDist, std::shared_ptr< const BaseStar > &closest, bool(*SkipIt)(const BaseStar &)=nullptr) const
double computeDist2(const Point &other) const
distance squared to other
stars_element operator*() const
Fast locator in starlists.