lsst.jointcal  16.0-16-g925333c+7
StarList.cc
Go to the documentation of this file.
1 #ifndef STARLIST__CC
2 #define STARLIST__CC
3 
4 #include "lsst/pex/exceptions.h"
5 
6 #include "lsst/jointcal/Frame.h"
11 
13 
14 namespace lsst {
15 namespace jointcal {
16 
17 template <class Star>
19  typedef StarList<Star>::Element E;
20  this->sort([](const E &e1, const E &e2) { return (e1->getFlux() > e2->getFlux()); });
21 }
22 
23 template <class Star>
24 void StarList<Star>::cutTail(const int nKeep) {
25  int count = 0;
26  auto si = this->begin();
27  for (; si != this->end() && count < nKeep; ++count, ++si)
28  ;
29  while (si != this->end()) {
30  si = this->erase(si);
31  }
32 }
33 
34 template <class Star>
35 void StarList<Star>::extractInFrame(StarList<Star> &out, const Frame &frame) const {
36  for (auto const &star : *this) {
37  if (frame.inFrame(*star)) {
38  out.push_back(std::make_shared<Star>(*star));
39  }
40  }
41 }
42 
43 template <class Star>
45  copy.clearList();
46  for (auto const &si : *this) copy.push_back(std::make_shared<Star>(*si));
47 }
48 
49 // Explicit instantiations
50 template class StarList<BaseStar>;
51 template class StarList<FittedStar>;
52 template class StarList<MeasuredStar>;
53 } // namespace jointcal
54 } // namespace lsst
55 
56 #endif /* STARLIST__CC */
def erase(frame=None)
void extractInFrame(StarList< Star > &out, const Frame &frame) const
copy the part of the std::list which is included in the frame at the end of another std::list ...
Definition: StarList.cc:35
void cutTail(const int nKeep)
cuts the end of the std::list
Definition: StarList.cc:24
std::shared_ptr< Star > push_back(std::shared_ptr< Star > ... args)
std::lists of Stars.
Definition: StarList.h:35
rectangle with sides parallel to axes.
Definition: Frame.h:15
Class for a simple mapping implementing a generic Gtransfo.
int end
T count(T... args)
void clearList()
Clears the std::list.
Definition: StarList.h:69
bool inFrame(double x, double y) const
inside?
Definition: Frame.cc:104
void copyTo(StarList< Star > &copy) const
clears copy and makes a copy of the std::list to copy
Definition: StarList.cc:44
void fluxSort()
a model routine to sort the std::list
Definition: StarList.cc:18
T begin(T... args)
T sort(T... args)