LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Detector.h
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2014 LSST Corporation.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #if !defined(LSST_AFW_CAMERAGEOM_DETECTOR_H)
24 #define LSST_AFW_CAMERAGEOM_DETECTOR_H
25 
26 #include <string>
27 #include <vector>
28 #include <unordered_map>
29 #include "lsst/base.h"
31 #include "lsst/afw/table/AmpInfo.h"
36 
37 namespace lsst {
38 namespace afw {
39 namespace cameraGeom {
40 
49 };
50 
62 class Detector final : public table::io::PersistableFacade<Detector>, public typehandling::Storable {
63 public:
64  typedef ndarray::Array<float const, 2> CrosstalkMatrix;
65 
91  lsst::geom::Box2I const &bbox, lsst::afw::table::AmpInfoCatalog const &ampInfoCatalog,
93  TransformMap::Transforms const &transforms,
94  CrosstalkMatrix const &crosstalk = CrosstalkMatrix(),
95  std::string const &physicalType="");
96 
115  Detector(std::string const &name, int id, DetectorType type, std::string const &serial,
116  lsst::geom::Box2I const &bbox, lsst::afw::table::AmpInfoCatalog const &ampInfoCatalog,
117  Orientation const &orientation, lsst::geom::Extent2D const &pixelSize,
119  CrosstalkMatrix const &crosstalk = CrosstalkMatrix(),
120  std::string const &physicalType="");
121 
122  ~Detector() = default;
123 
124  Detector(Detector const &) = delete;
125  Detector(Detector &&) = delete;
126  Detector &operator=(Detector const &) = delete;
127  Detector &operator=(Detector &&) = delete;
128 
130  std::string getName() const { return _name; }
131 
133  int getId() const { return _id; }
134 
136  DetectorType getType() const { return _type; }
137 
139  std::string getPhysicalType() const { return _physicalType; }
140 
142  std::string getSerial() const { return _serial; }
143 
145  lsst::geom::Box2I getBBox() const { return _bbox; }
146 
149 
151  std::vector<lsst::geom::Point2D> getCorners(CameraSysPrefix const &cameraSysPrefix) const;
152 
154  lsst::geom::Point2D getCenter(CameraSys const &cameraSys) const;
155 
157  lsst::geom::Point2D getCenter(CameraSysPrefix const &cameraSysPrefix) const;
158 
160  table::AmpInfoCatalog const getAmpInfoCatalog() const { return _ampInfoCatalog; }
161 
163  Orientation const getOrientation() const { return _orientation; }
164 
166  lsst::geom::Extent2D getPixelSize() const { return _pixelSize; }
167 
169  std::shared_ptr<TransformMap const> getTransformMap() const { return _transformMap; }
170 
172  bool hasCrosstalk() const {
173  return !(_crosstalk.isEmpty() || _crosstalk.getShape() == ndarray::makeVector(0, 0));
174  }
175 
177  CrosstalkMatrix const getCrosstalk() const { return _crosstalk; }
178 
180  table::AmpInfoCatalog::const_iterator begin() const { return _ampInfoCatalog.begin(); }
181 
183  table::AmpInfoCatalog::const_iterator end() const { return _ampInfoCatalog.end(); }
184 
190  table::AmpInfoRecord const &operator[](size_t i) const { return _ampInfoCatalog.at(i); }
191 
197  table::AmpInfoRecord const &operator[](std::string const &name) const;
198 
212 
224 
228  size_t size() const { return _ampInfoCatalog.size(); }
229 
231  bool hasTransform(CameraSys const &cameraSys) const;
232 
234  bool hasTransform(CameraSysPrefix const &cameraSysPrefix) const;
235 
248  template <typename FromSysT, typename ToSysT>
250  ToSysT const &toSys) const;
251 
260  CameraSys const makeCameraSys(CameraSys const &cameraSys) const { return cameraSys; }
261 
268  CameraSys const makeCameraSys(CameraSysPrefix const &cameraSysPrefix) const {
269  return CameraSys(cameraSysPrefix, _name);
270  }
271 
284  template <typename FromSysT, typename ToSysT>
285  lsst::geom::Point2D transform(lsst::geom::Point2D const &point, FromSysT const &fromSys,
286  ToSysT const &toSys) const;
287 
300  template <typename FromSysT, typename ToSysT>
302  FromSysT const &fromSys, ToSysT const &toSys) const;
303 
305  CameraSys getNativeCoordSys() const { return _nativeSys; }
306 
308  bool isPersistable() const noexcept override { return true; }
309 
310 private:
312 
313  std::string getPersistenceName() const override;
314 
315  std::string getPythonModule() const override;
316 
317  void write(OutputArchiveHandle& handle) const override;
318 
319  std::string _name;
320  int _id;
321  DetectorType _type;
322  std::string _serial;
323  lsst::geom::Box2I _bbox;
324  table::AmpInfoCatalog _ampInfoCatalog;
325  _AmpInfoMap _ampNameIterMap;
326  Orientation _orientation;
327  lsst::geom::Extent2D _pixelSize;
328  CameraSys _nativeSys;
330  CrosstalkMatrix _crosstalk;
331  std::string _physicalType;
332 };
333 } // namespace cameraGeom
334 } // namespace afw
335 } // namespace lsst
336 
337 #endif
table::AmpInfoCatalog const getAmpInfoCatalog() const
Get the amplifier information catalog.
Definition: Detector.h:160
size_t size() const
Get the number of amplifiers.
Definition: Detector.h:228
Camera coordinate system; used as a key in in TransformMap.
Definition: CameraSys.h:83
Detector(std::string const &name, int id, DetectorType type, std::string const &serial, lsst::geom::Box2I const &bbox, lsst::afw::table::AmpInfoCatalog const &ampInfoCatalog, Orientation const &orientation, lsst::geom::Extent2D const &pixelSize, TransformMap::Transforms const &transforms, CrosstalkMatrix const &crosstalk=CrosstalkMatrix(), std::string const &physicalType="")
Make a Detector.
Definition: Detector.cc:36
Basic LSST definitions.
Geometry and electronic information about raw amplifier images.
Definition: AmpInfo.h:79
An object passed to Persistable::write to allow it to persist itself.
table::AmpInfoRecord const & operator[](size_t i) const
Get the amplifier specified by index.
Definition: Detector.h:190
Interface supporting iteration over heterogenous containers.
Definition: Storable.h:56
std::shared_ptr< table::AmpInfoRecord const > _get(int i) const
Get the amplifier specified by index, returning a shared pointer to an AmpInfo record.
Definition: Detector.cc:113
std::string getPhysicalType() const
Get information about the physical type of the device (e.g.
Definition: Detector.h:139
DetectorType getType() const
Get the "type" (really purpose) of the Detector.
Definition: Detector.h:136
Describe a detector&#39;s orientation in the focal plane.
Definition: Orientation.h:52
STL class.
CameraSys const makeCameraSys(CameraSys const &cameraSys) const
Get a coordinate system from a coordinate system (return input unchanged and untested) ...
Definition: Detector.h:260
Orientation const getOrientation() const
Get detector&#39;s orientation in the focal plane.
Definition: Detector.h:163
lsst::geom::Box2I getBBox() const
Get the bounding box.
Definition: Detector.h:145
A base class for image defects.
table::Key< int > type
Definition: Detector.cc:167
std::shared_ptr< TransformMap const > getTransformMap() const
Get the transform registry.
Definition: Detector.h:169
iterator end()
Iterator access.
Definition: Catalog.h:397
Iterator class for CatalogT.
Definition: Catalog.h:38
bool hasTransform(CameraSys const &cameraSys) const
Can this object convert between PIXELS and the specified camera coordinate system?
Definition: Detector.cc:130
bool hasCrosstalk() const
Have we got crosstalk coefficients?
Definition: Detector.h:172
std::vector< lsst::geom::Point2D > getCorners(CameraSys const &cameraSys) const
Get the corners of the detector in the specified camera coordinate system.
Definition: Detector.cc:91
CameraSys const makeCameraSys(CameraSysPrefix const &cameraSysPrefix) const
Get a coordinate system from a detector system prefix (add detector name)
Definition: Detector.h:268
CrosstalkMatrix const getCrosstalk() const
Get the crosstalk coefficients.
Definition: Detector.h:177
table::Point2DKey pixelSize
Definition: Detector.cc:170
table::Box2IKey bbox
Definition: Detector.cc:169
table::AmpInfoCatalog::const_iterator begin() const
Get iterator to beginning of amplifier list.
Definition: Detector.h:180
lsst::geom::Point2D getCenter(CameraSys const &cameraSys) const
Get the center of the detector in the specified camera coordinate system.
Definition: Detector.cc:101
Camera coordinate system prefix.
Definition: CameraSys.h:44
table::Key< std::string > physicalType
Definition: Detector.cc:178
std::string getName() const
Get the detector name.
Definition: Detector.h:130
STL class.
Information about a CCD or other imaging detector.
Definition: Detector.h:62
Detector & operator=(Detector const &)=delete
table::AmpInfoCatalog::const_iterator end() const
Get iterator to end of amplifier list.
Definition: Detector.h:183
int getId() const
Get the detector ID.
Definition: Detector.h:133
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:408
table::Key< std::string > serial
Definition: Detector.cc:168
bool isPersistable() const noexcept override
Detectors are always peristable.
Definition: Detector.h:308
iterator begin()
Iterator access.
Definition: Catalog.h:396
reference at(size_type i) const
Return the record at index i (throws std::out_of_range).
Definition: Catalog.h:450
table::Key< table::Array< float > > crosstalk
Definition: Detector.cc:177
lsst::geom::Extent2D getPixelSize() const
Get size of pixel along (mm)
Definition: Detector.h:166
DetectorType
Type of imaging detector.
Definition: Detector.h:44
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
ndarray::Array< float const, 2 > CrosstalkMatrix
Definition: Detector.h:64
An integer coordinate rectangle.
Definition: Box.h:54
std::string getSerial() const
Get the detector serial "number".
Definition: Detector.h:142
CameraSys getNativeCoordSys() const
The "native" coordinate system of this detector.
Definition: Detector.h:305
lsst::geom::Point2D transform(lsst::geom::Point2D const &point, FromSysT const &fromSys, ToSysT const &toSys) const
Transform a point from one camera system to another.
Definition: Detector.cc:143
std::shared_ptr< afw::geom::TransformPoint2ToPoint2 > getTransform(FromSysT const &fromSys, ToSysT const &toSys) const
Get a Transform from one camera coordinate system, or camera coordinate system prefix, to another.