LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
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  void Detector::_init() {
85  // make _ampNameIterMap
87  ampIter != _ampInfoCatalog.end(); ++ampIter) {
88  _ampNameIterMap.insert(std::make_pair(ampIter->getName(), ampIter));
89  }
90  if (_ampNameIterMap.size() != _ampInfoCatalog.size()) {
91  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
92  "Invalid ampInfoCatalog: not all amplifier names are unique");
93  }
94 
95  // check detector name in CoordSys in transform registry
96  for (CameraTransformMap::Transforms::const_iterator trIter = _transformMap.begin();
97  trIter != _transformMap.end(); ++trIter) {
98  if (trIter->first.hasDetectorName() && trIter->first.getDetectorName() != _name) {
99  std::ostringstream os;
100  os << "Invalid transformMap: " << trIter->first << " detector name != \"" << _name << "\"";
101  throw LSST_EXCEPT(pexExcept::InvalidParameterError, os.str());
102  }
103  }
104 }
105 
106 }}}
std::vector< geom::Point2D > getCorners(CameraSys const &cameraSys) const
Definition: Detector.cc:56
int64_t _id
Geometry and electronic information about raw amplifier images.
Definition: AmpInfo.h:76
geom::Box2I _bbox
bounding box
Definition: Detector.h:237
std::string const & _name
Definition: Mask.cc:677
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:141
CoordSysT getNativeCoordSys() const
Definition: TransformMap.h:112
CameraPoint transform(CameraPoint const &fromCameraPoint, CameraSys const &toSys) const
Definition: Detector.h:196
CameraPoint getCenter(CameraSys const &cameraSys) const
Definition: Detector.cc:65
Transforms::const_iterator end() const
Definition: TransformMap.h:144
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
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:160
CameraTransformMap _transformMap
registry of coordinate transforms
Definition: Detector.h:242
Point2D transform(Point2D const &fromPoint, CoordSysT const &fromSys, CoordSysT const &toCoordSys) const
geom::Box2I const & _bbox
Definition: fits_io_mpl.h:80
CameraSys const makeCameraSys(CameraSys const &cameraSys) const
Definition: Detector.h:182
Iterator class for CatalogT.
Definition: Catalog.h:34
std::map< CameraSys, boost::shared_ptr< XYTransform const > > Transforms
Definition: TransformMap.h:67
std::vector< Point2D > getCorners() const
table::AmpInfoCatalog _ampInfoCatalog
list of amplifier data
Definition: Detector.h:238
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Transforms::const_iterator begin() const
Definition: TransformMap.h:142
A floating-point coordinate rectangle geometry.
Definition: Box.h:271
_AmpInfoMap _ampNameIterMap
map of amplifier name: catalog iterator
Definition: Detector.h:239
std::string _name
name of detector&#39;s location in the camera
Definition: Detector.h:233