35CameraSys
const getNativeCameraSys() {
return FOCAL_PLANE; }
47 auto nativePoint =
transform(point, cameraSys, getNativeCameraSys());
50 for (
auto const &item :
getIdMap()) {
51 auto detector = item.second;
52 auto pointPixels = detector->transform(nativePoint, getNativeCameraSys(),
PIXELS);
63 auto nativePointList =
transform(pointList, cameraSys, getNativeCameraSys());
66 auto const &detector = item.second;
67 auto pointPixelsList = detector->transform(nativePointList, getNativeCameraSys(),
PIXELS);
68 for (
std::size_t i = 0; i < pointPixelsList.size(); ++i) {
69 auto const &pointPixels = pointPixelsList[i];
75 return detectorListList;
106 Detector::InCameraBuilder
const & detector
108 return detector._connections;
114class PersistenceHelper {
117 static PersistenceHelper
const & get() {
118 static PersistenceHelper
const instance;
123 table::Key<std::string> name;
129 PersistenceHelper() :
131 name(
schema.addField<
std::string>(
"name",
"Camera name",
"", 0)),
133 "Fully-qualified name of a Python PupilFactory class",
135 transformMap(
schema.addField<int>(
"transformMap",
"archive ID for Camera's TransformMap"))
139 PersistenceHelper(PersistenceHelper
const &) =
delete;
140 PersistenceHelper(PersistenceHelper &&) =
delete;
142 PersistenceHelper & operator=(PersistenceHelper
const &) =
delete;
143 PersistenceHelper & operator=(PersistenceHelper &&) =
delete;
151 auto const & keys = PersistenceHelper::get();
153 auto record = cat.
addNew();
154 record->set(keys.name,
getName());
163 Factory() : table::io::PersistableFactory(
"Camera") {}
190 auto const & keys = PersistenceHelper::get();
192 auto const & cat = catalogs[1];
195 auto const & record = cat.front();
196 _name = record.get(keys.name);
197 _pupilFactoryName = record.get(keys.pupilFactoryName);
198 _transformMap = archive.
get<
TransformMap>(record.get(keys.transformMap));
212 for (
auto const & pair : camera.getIdMap()) {
217 for (
auto const & connection : camera.getTransformMap()->getConnections()) {
226 if (connection.fromSys.hasDetectorName()) {
227 assert(connection.toSys.getDetectorName() == connection.fromSys.getDetectorName());
228 auto detector = (*this)[connection.fromSys.getDetectorName()];
229 assert(connection.fromSys == detector->getNativeCoordSys());
230 detector->setTransformFromPixelsTo(
CameraSysPrefix(connection.toSys.getSysName()),
231 connection.transform);
233 assert(connection.fromSys == getNativeCameraSys());
234 if (!connection.toSys.hasDetectorName()) {
235 _connections.push_back(connection);
253 for (
auto const & pair :
getIdMap()) {
254 auto const & detectorBuilder = *pair.second;
257 for (
auto const &connection : detectorConnections) {
259 allDetConnections.
push_back(tmpConnection);
263 if ((
std::find(allDetConnections.
begin(), allDetConnections.
end(), connection) == allDetConnections.
end())
264 && (
std::find(allDetConnections.
begin(), allDetConnections.
end(), invConnection) == allDetConnections.
end()) ) {
268 detectorBuilder.getOrientation().makeFpPixelTransform(detectorBuilder.getPixelSize()),
269 getNativeCameraSys(),
270 detectorBuilder.getNativeCoordSys()
275 getDetectorBuilderConnections(detectorBuilder).begin(),
276 getDetectorBuilderConnections(detectorBuilder).
end());
283 for (
auto const & pair :
getIdMap()) {
284 auto const & detectorBuilder = *pair.second;
299template <
typename Iter>
300Iter findConnection(Iter first, Iter last,
CameraSys const & toSys) {
303 [&toSys](
auto const & connection) {
304 return connection.toSys == toSys;
318 (boost::format(
"%s should be added to Detector %s, not Camera") %
322 auto iter = findConnection(_connections.begin(), _connections.end(), toSys);
323 if (iter == _connections.end()) {
324 _connections.push_back(
333 auto iter = findConnection(_connections.begin(), _connections.end(), toSys);
334 if (iter != _connections.end()) {
335 _connections.erase(iter);
342 auto detector = makeDetectorBuilder(name,
id);
343 BaseCollection::add(detector);
352template class PersistableFacade<cameraGeom::Camera>;
table::Key< std::string > pupilFactoryName
table::Key< int > transformMap
table::Key< int > detector
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
A helper class for creating and modifying cameras.
void setTransformFromFocalPlaneTo(CameraSys const &toSys, std::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > transform)
Set the transformation from FOCAL_PLANE to the given coordinate system.
Builder(std::string const &name)
Construct a Builder for a completely new Camera with the given name.
virtual ~Builder() noexcept
std::shared_ptr< Detector::InCameraBuilder > add(std::string const &name, int id)
Add a new Detector with the given name and ID.
bool discardTransformFromFocalPlaneTo(CameraSys const &toSys)
Remove any transformation from FOCAL_PLANE to the given coordinate system.
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
An immutable representation of a camera.
Camera(Camera const &)=delete
std::shared_ptr< TransformMap const > getTransformMap() const noexcept
Obtain the transform registry.
std::string getPupilFactoryName() const
Return the fully-qualified name of the Python class that provides this Camera's PupilFactory.
std::string getName() const
Return the name of the camera.
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
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.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
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.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
std::shared_ptr< afw::geom::TransformPoint2ToPoint2 > getTransform(CameraSys const &fromSys, CameraSys const &toSys) const
Get a transform from one CameraSys to another.
Camera coordinate system; used as a key in in TransformMap.
bool hasDetectorName() const noexcept
Does this have a non-blank detector name?
std::string getSysName() const
Get coordinate system name.
std::string getDetectorName() const
Get detector name, or "" if not a detector-specific coordinate system.
Camera coordinate system prefix.
A helper class that allows the properties of a detector to be modified in the course of modifying a f...
std::size_t size() const noexcept
Get the number of detectors.
IdMap const & getIdMap() const noexcept
Get a map keyed and ordered by ID.
void add(std::shared_ptr< Detector::InCameraBuilder > detector)
Add a detector to the collection.
An immutable collection of Detectors that can be accessed by name or ID.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
A vector of catalogs used by Persistable.
An object passed to Persistable::write to allow it to persist itself.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
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...
A base class for factory classes used to reconstruct objects from records.
A floating-point coordinate rectangle geometry.
bool contains(Point2D const &point) const noexcept
Return true if the box contains the point.
Reports errors in the logical structure of the program.
CameraSys const FOCAL_PLANE
Focal plane coordinates: Position on a 2-d planar approximation to the focal plane (x,...
CameraSysPrefix const PIXELS
Pixel coordinates: Nominal position on the entry surface of a given detector (x, y unbinned pixels).