lsst.afw  14.0-40-g0271be365
CameraSys.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_CAMERASYS_H)
24 #define LSST_AFW_CAMERAGEOM_CAMERASYS_H
25 
26 #include <functional>
27 #include <string>
28 #include <ostream>
29 #include <sstream>
30 
31 namespace lsst {
32 namespace afw {
33 namespace cameraGeom {
34 
45 public:
46  explicit CameraSysPrefix(std::string const &sysName
47  )
48  : _sysName(sysName) {}
49 
53  std::string getSysName() const { return _sysName; };
54 
55  bool operator==(CameraSysPrefix const &rhs) const { return _sysName == rhs.getSysName(); }
56 
57  bool operator!=(CameraSysPrefix const &rhs) const { return !(*this == rhs); }
58 
68  size_t hash() const noexcept;
69 
70 private:
71  std::string _sysName;
72 };
73 
77 class CameraSys {
78 public:
82  explicit CameraSys(std::string const &sysName,
83  std::string const &detectorName = ""
84  )
85  : _sysName(sysName), _detectorName(detectorName){};
86 
90  explicit CameraSys(CameraSysPrefix const &sysPrefix,
91  std::string const &detectorName = ""
92  )
93  : _sysName(sysPrefix.getSysName()), _detectorName(detectorName){};
94 
96  CameraSys() : _sysName("?"), _detectorName(){};
97 
101  std::string getSysName() const { return _sysName; };
102 
106  std::string getDetectorName() const { return _detectorName; };
107 
111  bool hasDetectorName() const { return !_detectorName.empty(); }
112 
113  bool operator==(CameraSys const &rhs) const {
114  return _sysName == rhs.getSysName() && _detectorName == rhs.getDetectorName();
115  }
116 
117  bool operator!=(CameraSys const &rhs) const { return !(*this == rhs); }
118 
119  // less-than operator required for use in std::map
120  bool operator<(CameraSys const &rhs) const {
121  if (_sysName == rhs.getSysName()) {
122  return _detectorName < rhs.getDetectorName();
123  } else {
124  return _sysName < rhs.getSysName();
125  }
126  }
127 
136  size_t hash() const noexcept;
137 
138 private:
139  std::string _sysName;
140  std::string _detectorName;
141 };
142 
143 // *** Standard camera coordinate systems ***
144 
150 extern CameraSys const FOCAL_PLANE;
151 
156 extern CameraSys const FIELD_ANGLE;
157 
165 extern CameraSysPrefix const PIXELS;
166 
182 extern CameraSysPrefix const TAN_PIXELS;
183 
190 extern CameraSysPrefix const ACTUAL_PIXELS;
191 
192 std::ostream &operator<<(std::ostream &os, CameraSysPrefix const &detSysPrefix);
193 
194 std::ostream &operator<<(std::ostream &os, CameraSys const &cameraSys);
195 }
196 }
197 }
198 
199 namespace std {
200 template <>
201 struct hash<lsst::afw::cameraGeom::CameraSysPrefix> {
202  size_t operator()(lsst::afw::cameraGeom::CameraSysPrefix const &obj) const noexcept { return obj.hash(); }
203 };
204 
205 template <>
206 struct hash<lsst::afw::cameraGeom::CameraSys> {
207  size_t operator()(lsst::afw::cameraGeom::CameraSys const &obj) const noexcept { return obj.hash(); }
208 };
209 }
210 
211 #endif
Camera coordinate system; used as a key in in TransformMap.
Definition: CameraSys.h:77
bool operator!=(CameraSysPrefix const &rhs) const
Definition: CameraSys.h:57
std::string getSysName() const
Get coordinate system name.
Definition: CameraSys.h:53
CameraSysPrefix const PIXELS
Nominal pixels on the detector (unbinned) This ignores manufacturing imperfections, "tree ring" distortions and all other such effects.
Definition: CameraSys.cc:33
std::ostream & operator<<(std::ostream &os, CameraPoint const &cameraPoint)
Definition: CameraPoint.cc:29
STL namespace.
bool operator!=(CameraSys const &rhs) const
Definition: CameraSys.h:117
bool hasDetectorName() const
Does this have a non-blank detector name?
Definition: CameraSys.h:111
CameraSysPrefix const ACTUAL_PIXELS
The actual pixels where the photon lands and electrons are generated (unbinned) This takes into accou...
Definition: CameraSys.cc:37
CameraSys(std::string const &sysName, std::string const &detectorName="")
Construct a CameraSys from a sysName and a detectorName.
Definition: CameraSys.h:82
STL class.
CameraSys()
default constructor so SWIG can wrap a vector of pairs containing these
Definition: CameraSys.h:96
std::string getSysName() const
Get coordinate system name.
Definition: CameraSys.h:101
A base class for image defects.
std::string getDetectorName() const
Get detector name, or "" if not a detector-specific coordinate system.
Definition: CameraSys.h:106
bool operator==(CameraSysPrefix const &rhs) const
Definition: CameraSys.h:55
bool operator==(CameraSys const &rhs) const
Definition: CameraSys.h:113
size_t hash() const noexcept
Hash function for this object.
Definition: CameraSys.cc:39
bool operator<(CameraSys const &rhs) const
Definition: CameraSys.h:120
Camera coordinate system prefix.
Definition: CameraSys.h:44
CameraSys(CameraSysPrefix const &sysPrefix, std::string const &detectorName="")
Construct a CameraSys from a CameraSysPrefix and a detectorName.
Definition: CameraSys.h:90
CameraSysPrefix(std::string const &sysName)
Definition: CameraSys.h:46
CameraSys const FIELD_ANGLE
Field angle coordinates: Angular x,y offset from the optic axis (radians).
Definition: CameraSys.cc:31
CameraSysPrefix const TAN_PIXELS
Tangent-plane pixels on the detector (unbinned)
Definition: CameraSys.cc:35
size_t operator()(lsst::afw::cameraGeom::CameraSysPrefix const &obj) const noexcept
Definition: CameraSys.h:202
size_t operator()(lsst::afw::cameraGeom::CameraSys const &obj) const noexcept
Definition: CameraSys.h:207
STL class.
CameraSys const FOCAL_PLANE
Focal plane coordinates: Rectilinear x, y (and z when talking about the location of a detector) on th...
Definition: CameraSys.cc:29