LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Pixel.h
Go to the documentation of this file.
1 #ifndef MeasAlgoShapeletPixel_H
2 #define MeasAlgoShapeletPixel_H
3 
4 //#define PIXELLIST_USE_POOL
5 
6 #include <complex>
7 #include <string>
8 #if 0
9 #include "lsst/meas/algorithms/shapelet/Image.h"
10 #include "lsst/meas/algorithms/shapelet/Transformation.h"
11 #endif
14 
15 #ifdef __INTEL_COMPILER
16 #pragma warning (disable : 1418)
17 #endif
18 #include "boost/shared_ptr.hpp"
19 #ifdef __INTEL_COMPILER
20 #pragma warning (default : 1418)
21 #endif
22 
23 #ifdef PIXELLIST_USE_POOL
24 #define PIXELLIST_BLOCK 1024*1024*100 // 100 MB per block
25 #include "PoolAllocator.h"
26 #endif
27 
28 namespace lsst {
29 namespace meas {
30 namespace algorithms {
31 namespace shapelet {
32 
33  class Pixel
34  {
35  public :
36 
37  Pixel() : _pos(0.), _flux(0.), _inverseSigma(0.) {}
38 
39  Pixel(double u, double v, double flux, double inverseSigma) :
40  _pos(u,v), _flux(flux), _inverseSigma(inverseSigma) {}
41 
42  Pixel(std::complex<double> z, double flux, double inverseSigma) :
43  _pos(z), _flux(flux), _inverseSigma(inverseSigma) {}
44 
45  ~Pixel() {}
46 
47  std::complex<double> getPos() const { return _pos; }
48 
49  double getFlux() const { return _flux; }
50 
51  double getInverseSigma() const { return _inverseSigma; }
52 
53  void setPos(const std::complex<double>& pos) { _pos = pos; }
54 
55  void setFlux(const double flux) { _flux = flux; }
56 
57  void setInverseSigma(const double inverseSigma)
58  { _inverseSigma = inverseSigma; }
59 
60  private :
61 
62  std::complex<double> _pos;
63  double _flux;
64  double _inverseSigma;
65  };
66 
67  // Most of these methods are not (intrinsically) thread-safe,
68  // since they might be using my pool allocator, so they need to
69  // be wrapped in a critical block.
70  // Therefore, all the methods for PixelList are defined in Pixel_omp.cpp.
71 
72  class PixelList
73  {
74  public :
75 
76  PixelList();
77  PixelList(const int n);
78  PixelList(const PixelList& rhs);
79  PixelList& operator=(const PixelList& rhs);
80  ~PixelList();
81 
82  void usePool();
83 
84  // These mimic the same functionality of a std::vector<Pixel>
85  size_t size() const;
86  void reserve(const int n);
87  size_t capacity() const;
88  void resize(const int n);
89  void clear();
90  void push_back(const Pixel& p);
91  Pixel& operator[](const int i);
92  const Pixel& operator[](const int i) const;
93  void sort(const Position& cen);
94 
95  private :
96 
98  boost::shared_ptr<std::vector<Pixel> > _v1;
99 #ifdef PIXELLIST_USE_POOL
100  typedef PoolAllocator<Pixel,PIXELLIST_BLOCK> PoolAllocPixel;
101  boost::shared_ptr<std::vector<Pixel,PoolAllocPixel> > _v2;
102 #else
103  boost::shared_ptr<std::vector<Pixel> > _v2;
104 #endif
105 
106  };
107 
108 #if 0
109  void getPixList(
110  const Image<double>& im, PixelList& pix,
111  const Position cen, double sky, double noise, double gain,
112  const Image<double>* weightImage, const Transformation& trans,
113  double aperture, double xOffset, double yOffset, long& flag);
114 
115  double getLocalSky(
116  const Image<double>& bkg,
117  const Position cen, const Transformation& trans,
118  double aperture, double xOffset, double yOffset, long& flag);
119 #endif
120 
121  void getSubPixList(
122  PixelList& pix, const PixelList& allPix,
123  std::complex<double> cen_offset, std::complex<double> shear,
124  double aperture, long& flag);
125 
126  inline void getSubPixList(
127  PixelList& pix, const PixelList& allPix,
128  std::complex<double> cen_offset, double aperture, long& flag)
129  { getSubPixList(pix,allPix,cen_offset,0.,aperture,flag); }
130 
131  inline void getSubPixList(
132  PixelList& pix, const PixelList& allPix,
133  double aperture, long& flag)
134  { getSubPixList(pix,allPix,0.,0.,aperture,flag); }
135 
136 
137 }}}}
138 
139 #endif
std::complex< double > getPos() const
Definition: Pixel.h:47
void setFlux(const double flux)
Definition: Pixel.h:55
boost::shared_ptr< std::vector< Pixel > > _v2
Definition: Pixel.h:103
Pixel(std::complex< double > z, double flux, double inverseSigma)
Definition: Pixel.h:42
void setPos(const std::complex< double > &pos)
Definition: Pixel.h:53
std::complex< double > _pos
Definition: Pixel.h:62
void setInverseSigma(const double inverseSigma)
Definition: Pixel.h:57
void getSubPixList(PixelList &pix, const PixelList &allPix, std::complex< double > cen_offset, std::complex< double > shear, double aperture, long &flag)
Definition: Pixel.cc:254
boost::shared_ptr< std::vector< Pixel > > _v1
Definition: Pixel.h:98
PixelList & operator=(const PixelList &rhs)
Definition: Pixel_omp.cc:48
Pixel(double u, double v, double flux, double inverseSigma)
Definition: Pixel.h:39