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
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 }}}
std::vector< geom::Point2D > getCorners(CameraSys const &cameraSys) const
Definition: Detector.cc:56
table::Key< std::string > name
Definition: ApCorrMap.cc:71
Geometry and electronic information about raw amplifier images.
Definition: AmpInfo.h:77
geom::Box2I _bbox
bounding box
Definition: Detector.h:264
std::string const & _name
Definition: Mask.cc:678
A custom container class for records, based on std::vector.
Definition: Catalog.h:94
CameraSysPrefix const PIXELS
Definition: CameraSys.cc:33
lsst::afw::table::AmpInfoRecord const & operator[](size_t i) const
Definition: Detector.h:142
CoordSysT getNativeCoordSys() const
Definition: TransformMap.h:112
bool contains(CoordSysT const &coordSys) const
CameraPoint transform(CameraPoint const &fromCameraPoint, CameraSys const &toSys) const
Definition: Detector.h:223
CameraPoint getCenter(CameraSys const &cameraSys) const
Definition: Detector.cc:65
Transforms::const_iterator end() const
Definition: TransformMap.h:144
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:401
An integer coordinate rectangle.
Definition: Box.h:53
CameraPoint makeCameraPoint(geom::Point2D point, CameraSys cameraSys) const
Definition: Detector.h:187
CameraTransformMap _transformMap
registry of coordinate transforms
Definition: Detector.h:269
Point2D transform(Point2D const &fromPoint, CoordSysT const &fromSys, CoordSysT const &toCoordSys) const
geom::Box2I const & _bbox
Definition: fits_io_mpl.h:80
int _id
Definition: Mask.cc:679
CameraSys const makeCameraSys(CameraSys const &cameraSys) const
Definition: Detector.h:209
Iterator class for CatalogT.
Definition: Catalog.h:34
std::map< CameraSys, boost::shared_ptr< XYTransform const > > Transforms
Definition: TransformMap.h:67
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)
Definition: Detector.cc:31
std::vector< Point2D > getCorners() const
table::AmpInfoCatalog _ampInfoCatalog
list of amplifier data
Definition: Detector.h:265
bool hasTransform(CameraSys const &cameraSys) const
Definition: Detector.cc:84
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Transforms::const_iterator begin() const
Definition: TransformMap.h:142
Virtual base class for 2D transforms.
Definition: XYTransform.h:48
#define CONST_PTR(...)
Definition: base.h:47
A floating-point coordinate rectangle geometry.
Definition: Box.h:271
_AmpInfoMap _ampNameIterMap
map of amplifier name: catalog iterator
Definition: Detector.h:266
std::string _name
name of detector&#39;s location in the camera
Definition: Detector.h:260