lsst.jointcal  master-gc935ebf72c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FastFinder.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #ifndef LSST_JOINTCAL_FAST_FINDER_H
3 #define LSST_JOINTCAL_FAST_FINDER_H
4 
5 #include <vector>
7 
8 namespace lsst {
9 namespace jointcal {
10 
30 class FastFinder {
32  // private :
33 public:
34  const BaseStarList baselist; // shallow copy of the initial list of stars (not used, acts as a
35  // conservatory). The need is arguable.
36  unsigned count; // total number of objects (size of input list stars).
37  /* the sorted pointer array: It does not seem very wise to use smart
38  pointers here because reference counts will uselessly jump around
39  during sorting */
40  // Unfortunately we *must* use shared_ptr here because the return value of findClosest is used to pass
41  // ownership
42  std::vector<std::shared_ptr<const BaseStar>> stars;
43  unsigned nslice; // number of (X) slices
44  std::vector<unsigned> index; // index in "stars" of first object of each slice.
45  double xmin, xmax, xstep; // x bounds, slice size
46 
47  typedef decltype(stars)::value_type stars_element;
48  typedef decltype(stars)::const_iterator pstar;
49 
50 public:
52  FastFinder(const BaseStarList &list, const unsigned nXSlice = 100);
53 
55  std::shared_ptr<const BaseStar> findClosest(const Point &where, const double maxDist,
56  bool (*SkipIt)(const BaseStar &) = nullptr) const;
57 
59  std::shared_ptr<const BaseStar> secondClosest(const Point &where, const double maxDist,
60  std::shared_ptr<const BaseStar> &closest,
61  bool (*SkipIt)(const BaseStar &) = nullptr) const;
62 
64  void dump() const;
65 
68 
69  class Iterator {
70  public: // could be made private, but what for??
73  double yStart, yEnd; // Y limits ( for all stripes)
74  /* pointers to the first and beyond last stars in the y range for
75  the current stripe : */
77  pstar null_value; // with pointers being iterators, the null value is not NULL
78 
79  void check() const;
80 
81  public:
82  Iterator(const FastFinder &f, const Point &where, double maxDist);
83  void operator++();
84  stars_element operator*() const;
85  };
86 
87  Iterator beginScan(const Point &where, double maxDist) const;
88 
89  void findRangeInSlice(const int iSlice, const double yStart, const double yEnd, pstar &start,
90  pstar &end) const;
91  pstar locateYStart(pstar begin, pstar end, double yVal) const;
92  pstar locateYEnd(pstar begin, pstar end, double yVal) const;
93 };
94 } // namespace jointcal
95 } // namespace lsst
96 #endif // LSST_JOINTCAL_FAST_FINDER_H
stars_element operator*() const
Definition: FastFinder.cc:182
A point in a plane.
Definition: Point.h:13
decltype(stars) typedef::const_iterator pstar
Definition: FastFinder.h:48
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.
Definition: FastFinder.cc:60
std::vector< std::shared_ptr< const BaseStar > > stars
Definition: FastFinder.h:42
pstar locateYStart(pstar begin, pstar end, double yVal) const
Definition: FastFinder.cc:111
Iterator(const FastFinder &f, const Point &where, double maxDist)
Definition: FastFinder.cc:157
The base class for handling stars. Used by all matching routines.
Definition: BaseStar.h:26
std::lists of Stars.
Definition: StarList.h:35
Iterator meant to traverse objects within some limiting distance.
Definition: FastFinder.h:69
FastFinder(const BaseStarList &list, const unsigned nXSlice=100)
Constructor.
Definition: FastFinder.cc:14
const BaseStarList baselist
Definition: FastFinder.h:34
void dump() const
mostly for debugging
Definition: FastFinder.cc:54
This is an auxillary class for matching objects from starlists.
Definition: FastFinder.h:31
std::vector< unsigned > index
Definition: FastFinder.h:44
decltype(stars) typedef::value_type stars_element
Definition: FastFinder.h:47
std::shared_ptr< const BaseStar > secondClosest(const Point &where, const double maxDist, std::shared_ptr< const BaseStar > &closest, bool(*SkipIt)(const BaseStar &)=nullptr) const
Definition: FastFinder.cc:78
pstar locateYEnd(pstar begin, pstar end, double yVal) const
Definition: FastFinder.cc:129
void findRangeInSlice(const int iSlice, const double yStart, const double yEnd, pstar &start, pstar &end) const
Definition: FastFinder.cc:145
Iterator beginScan(const Point &where, double maxDist) const
Definition: FastFinder.cc:151