LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
Detector.cc
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 #include <sstream>
24 #include <utility>
26 
27 namespace lsst {
28 namespace afw {
29 namespace cameraGeom {
30 
32  std::string const &name,
33  int id,
34  DetectorType type,
35  std::string const &serial,
36  geom::Box2I const &bbox,
37  table::AmpInfoCatalog const &ampInfoCatalog,
38  Orientation const &orientation,
39  geom::Extent2D const & pixelSize,
40  CameraTransformMap::Transforms const &transforms
41 ) :
42  _name(name),
43  _id(id),
44  _type(type),
45  _serial(serial),
46  _bbox(bbox),
47  _ampInfoCatalog(ampInfoCatalog),
48  _ampNameIterMap(),
49  _orientation(orientation),
50  _pixelSize(pixelSize),
51  _transformMap(CameraSys(PIXELS.getSysName(), name), transforms)
52 {
53  _init();
54 }
55 
56 std::vector<geom::Point2D> Detector::getCorners(CameraSys const &cameraSys) const {
57  std::vector<geom::Point2D> fromVec = geom::Box2D(_bbox).getCorners();
58  return _transformMap.transform(fromVec, _transformMap.getNativeCoordSys(), cameraSys);
59 }
60 
61 std::vector<geom::Point2D> Detector::getCorners(CameraSysPrefix const &cameraSysPrefix) const {
62  return getCorners(makeCameraSys(cameraSysPrefix));
63 }
64 
65 CameraPoint Detector::getCenter(CameraSys const &cameraSys) const {
67  return transform(ctrPix, cameraSys);
68 }
69 
70 CameraPoint Detector::getCenter(CameraSysPrefix const &cameraSysPrefix) const {
71  return getCenter(makeCameraSys(cameraSysPrefix));
72 }
73 
74 const table::AmpInfoRecord & Detector::operator[](std::string const &name) const {
75  _AmpInfoMap::const_iterator ampIter = _ampNameIterMap.find(name);
76  if (ampIter == _ampNameIterMap.end()) {
77  std::ostringstream os;
78  os << "Unknown amplifier \"" << name << "\"";
79  throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
80  }
81  return *(ampIter->second);
82 }
83 
84 bool Detector::hasTransform(CameraSys const &cameraSys) const {
85  return _transformMap.contains(cameraSys);
86 }
87 
88 bool Detector::hasTransform(CameraSysPrefix const &cameraSysPrefix) const {
89  return hasTransform(makeCameraSys(cameraSysPrefix));
90 }
91 
92 CONST_PTR(afw::geom::XYTransform) Detector::getTransform(CameraSys const &cameraSys) const {
93  return _transformMap[cameraSys];
94 }
95 
96 CONST_PTR(afw::geom::XYTransform) Detector::getTransform(CameraSysPrefix const &cameraSysPrefix) const {
97  return getTransform(makeCameraSys(cameraSysPrefix));
98 }
99 
100 
102  // make _ampNameIterMap
104  ampIter != _ampInfoCatalog.end(); ++ampIter) {
105  _ampNameIterMap.insert(std::make_pair(ampIter->getName(), ampIter));
106  }
107  if (_ampNameIterMap.size() != _ampInfoCatalog.size()) {
108  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
109  "Invalid ampInfoCatalog: not all amplifier names are unique");
110  }
111 
112  // check detector name in CoordSys in transform registry
113  for (CameraTransformMap::Transforms::const_iterator trIter = _transformMap.begin();
114  trIter != _transformMap.end(); ++trIter) {
115  if (trIter->first.hasDetectorName() && trIter->first.getDetectorName() != _name) {
116  std::ostringstream os;
117  os << "Invalid transformMap: " << trIter->first << " detector name != \"" << _name << "\"";
118  throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
119  }
120  }
121 }
122 
123 }}}
Transforms::const_iterator end() const
Definition: TransformMap.h:144
Camera coordinate system; used as a key in in TransformMap.
Definition: CameraSys.h:77
table::Key< std::string > name
Definition: ApCorrMap.cc:71
table::AmpInfoCatalog _ampInfoCatalog
list of amplifier data
Definition: Detector.h:266
Geometry and electronic information about raw amplifier images.
Definition: AmpInfo.h:77
std::string const & _name
Definition: Mask.cc:678
A custom container class for records, based on std::vector.
Definition: Catalog.h:95
CameraTransformMap _transformMap
registry of coordinate transforms
Definition: Detector.h:270
CameraSysPrefix const PIXELS
Nominal pixels on the detector (unbinned) This ignores manufacturing imperfections, &quot;tree ring&quot; distortions and all other such effects.
Definition: CameraSys.cc:33
std::map< CameraSys, boost::shared_ptr< XYTransform const > > Transforms
Definition: TransformMap.h:67
void _init()
Finish constructing this object.
Definition: Detector.cc:101
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:402
CameraPoint makeCameraPoint(geom::Point2D point, CameraSys cameraSys) const
Make a CameraPoint from a point and a camera system.
Definition: Detector.h:188
Point2D transform(Point2D const &fromPoint, CoordSysT const &fromSys, CoordSysT const &toCoordSys) const
Convert a point from one coordinate system to another.
std::vector< geom::Point2D > getCorners(CameraSys const &cameraSys) const
Get the corners of the detector in the specified coordinate system.
Definition: Detector.cc:56
An integer coordinate rectangle.
Definition: Box.h:53
Describe a detector&#39;s orientation in the focal plane.
Definition: Orientation.h:53
std::string _name
name of detector&#39;s location in the camera
Definition: Detector.h:261
Transforms::const_iterator begin() const
Definition: TransformMap.h:142
bool hasTransform(CameraSys const &cameraSys) const
Does the specified CameraSys exist in the transform registry.
Definition: Detector.cc:84
iterator begin()
Iterator access.
Definition: Catalog.h:392
_AmpInfoMap _ampNameIterMap
map of amplifier name: catalog iterator
Definition: Detector.h:267
lsst::afw::table::AmpInfoRecord const & operator[](size_t i) const
Get the amplifier specified by index.
Definition: Detector.h:143
CameraSys const makeCameraSys(CameraSys const &cameraSys) const
Get a coordinate system from a coordinate system (return input unchanged and untested) ...
Definition: Detector.h:210
geom::Box2I const & _bbox
Definition: fits_io_mpl.h:80
int _id
Definition: Mask.cc:679
Iterator class for CatalogT.
Definition: Catalog.h:35
bool contains(CoordSysT const &coordSys) const
Return true if the coordinate system is supported.
geom::Box2I _bbox
bounding box
Definition: Detector.h:265
Camera coordinate system prefix.
Definition: CameraSys.h:46
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
Information about a CCD or other imaging detector.
Definition: Detector.h:65
iterator end()
Iterator access.
Definition: Catalog.h:393
Virtual base class for 2D transforms.
Definition: XYTransform.h:48
std::vector< Point2D > getCorners() const
Get the corner points.
Detector(std::string const &name, int id, DetectorType type, std::string const &serial, geom::Box2I const &bbox, lsst::afw::table::AmpInfoCatalog const &ampInfoCatalog, Orientation const &orientation, geom::Extent2D const &pixelSize, CameraTransformMap::Transforms const &transforms)
Make a Detector.
Definition: Detector.cc:31
A Point2D with associated camera coordinate system.
Definition: CameraPoint.h:37
CameraPoint getCenter(CameraSys const &cameraSys) const
Get the center of the detector in the specified coordinate system.
Definition: Detector.cc:65
A floating-point coordinate rectangle geometry.
Definition: Box.h:271
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
DetectorType
Type of imaging detector.
Definition: Detector.h:43
CoordSysT getNativeCoordSys() const
Definition: TransformMap.h:112
CameraPoint transform(CameraPoint const &fromCameraPoint, CameraSys const &toSys) const
Convert a CameraPoint from one coordinate system to another.
Definition: Detector.h:224