30 namespace cameraGeom {
35 CameraSys
const getNativeCameraSys() {
return FOCAL_PLANE; }
53 Camera
const &camera, CameraSys
const &fromSys, CameraSys
const &toSys) {
55 if (fromSys.hasDetectorName()) {
56 auto det = camera[fromSys.getDetectorName()];
57 return det->getTransformMap()->getTransform(fromSys, toSys);
58 }
else if (toSys.hasDetectorName()) {
59 auto det = camera[toSys.getDetectorName()];
60 return det->getTransformMap()->getTransform(fromSys, toSys);
62 return camera.getTransformMap()->getTransform(fromSys, toSys);
71 _name(name), _transformMap(
std::move(transformMap)), _pupilFactoryName(pupilFactoryName)
78 auto transform = getTransformFromOneTransformMap(*
this, cameraSys, getNativeCameraSys());
79 auto nativePoint =
transform->applyForward(point);
82 for (
auto const &item :
getIdMap()) {
84 auto nativeToPixels =
detector->getTransform(getNativeCameraSys(),
PIXELS);
85 auto pointPixels = nativeToPixels->applyForward(nativePoint);
95 auto transform = getTransformFromOneTransformMap(*
this, cameraSys, getNativeCameraSys());
98 auto nativePointList =
transform->applyForward(pointList);
100 for (
auto const &item:
getIdMap()) {
102 auto nativeToPixels =
detector->getTransform(getNativeCameraSys(),
PIXELS);
103 auto pointPixelsList = nativeToPixels->applyForward(nativePointList);
104 for (
std::size_t i = 0; i < pointPixelsList.size(); ++i) {
105 auto const &pointPixels = pointPixelsList[i];
107 detectorListList[i].push_back(
detector);
111 return detectorListList;
132 auto fromSysToNative = getTransformFromOneTransformMap(*
this, fromSys, getNativeCameraSys());
133 auto nativeToToSys = getTransformFromOneTransformMap(*
this, getNativeCameraSys(), toSys);
134 return fromSysToNative->then(*nativeToToSys);
153 class PersistenceHelper {
156 static PersistenceHelper
const &
get() {
157 static PersistenceHelper
const instance;
168 PersistenceHelper() :
170 name(schema.addField<
std::string>(
"name",
"Camera name",
"", 0)),
171 pupilFactoryName(schema.addField<
std::string>(
"pupilFactoryName",
172 "Fully-qualified name of a Python PupilFactory class",
174 transformMap(schema.addField<int>(
"transformMap",
"archive ID for Camera's TransformMap"))
176 schema.getCitizen().markPersistent();
179 PersistenceHelper(PersistenceHelper
const &) =
delete;
180 PersistenceHelper(PersistenceHelper &&) =
delete;
182 PersistenceHelper &
operator=(PersistenceHelper
const &) =
delete;
183 PersistenceHelper &
operator=(PersistenceHelper &&) =
delete;
193 Factory() : table::io::PersistableFactory(
"Camera") {}
213 auto const &
keys = PersistenceHelper::get();
215 auto const & cat = catalogs[1];
218 auto const & record = cat.front();
219 _name = record.get(
keys.name);
220 _pupilFactoryName = record.get(
keys.pupilFactoryName);
225 std::string Camera::getPersistenceName()
const {
return "Camera"; }
229 auto const &
keys = PersistenceHelper::get();
231 auto record = cat.
addNew();
243 template class PersistableFacade<cameraGeom::Camera>;
Camera coordinate system; used as a key in in TransformMap.
int put(Persistable const *obj, bool permissive=false)
Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArc...
std::shared_ptr< TransformMap const > getTransformMap() const noexcept
Obtain the transform registry.
An object passed to Persistable::write to allow it to persist itself.
DetectorList findDetectors(lsst::geom::Point2D const &point, CameraSys const &cameraSys) const
Find the detectors that cover a point in any camera system.
virtual ~Camera() noexcept
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
CameraSysPrefix const PIXELS
Nominal pixels on the detector (unbinned) This ignores manufacturing imperfections, "tree ring" distortions and all other such effects.
A base class for factory classes used to reconstruct objects from records.
table::Key< int > detector
std::string getName() const
Return the name of the camera.
table::Key< std::string > name
std::vector< DetectorList > findDetectorsList(std::vector< lsst::geom::Point2D > const &pointList, CameraSys const &cameraSys) const
Find the detectors that cover a list of points in any camera system.
table::Key< int > transformMap
A base class for image defects.
Camera(std::string const &name, DetectorList const &detectorList, std::shared_ptr< TransformMap > transformMap, std::string const &pupilFactoryName)
Construct a camera.
std::shared_ptr< Persistable > read(InputArchive const &archive, CatalogVector const &catalogs) const override
Construct a new object from the given InputArchive and vector of catalogs.
static Factory const registration
std::shared_ptr< afw::geom::TransformPoint2ToPoint2 > getTransform(CameraSys const &fromSys, CameraSys const &toSys) const
Get a transform from one CameraSys to another.
lsst::geom::Point2D transform(lsst::geom::Point2D const &point, CameraSys const &fromSys, CameraSys const &toSys) const
Transform a point from one camera coordinate system to another.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
An immutable collection of Detectors that can be accessed by name or ID.
A vector of catalogs used by Persistable.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
IdMap const & getIdMap() const noexcept
Get an unordered map over detector IDs.
table::Key< std::string > pupilFactoryName
Camera & operator=(Camera const &)=delete
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
CameraSys const FOCAL_PLANE
Focal plane coordinates: Rectilinear x, y (and z when talking about the location of a detector) on th...
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
std::string getPupilFactoryName() const
Return the fully-qualified name of the Python class that provides this Camera's PupilFactory.