LSST Applications g0265f82a02+d6b5cd48b5,g02d81e74bb+a41d3748ce,g1470d8bcf6+6be6c9203b,g2079a07aa2+14824f138e,g212a7c68fe+a4f2ea4efa,g2305ad1205+72971fe858,g295015adf3+ab2c85acae,g2bbee38e9b+d6b5cd48b5,g337abbeb29+d6b5cd48b5,g3ddfee87b4+31b3a28dff,g487adcacf7+082e807817,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+b2918d57ae,g5a732f18d5+66d966b544,g64a986408d+a41d3748ce,g858d7b2824+a41d3748ce,g8a8a8dda67+a6fc98d2e7,g99cad8db69+7fe4acdf18,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga8c6da7877+84af8b3ff8,gb0e22166c9+3863383f4c,gb6a65358fc+d6b5cd48b5,gba4ed39666+9664299f35,gbb8dafda3b+d8d527deb2,gc07e1c2157+b2dbe6b631,gc120e1dc64+61440b2abb,gc28159a63d+d6b5cd48b5,gcf0d15dbbd+31b3a28dff,gdaeeff99f8+a38ce5ea23,ge6526c86ff+39927bb362,ge79ae78c31+d6b5cd48b5,gee10cc3b42+a6fc98d2e7,gf1cff7945b+a41d3748ce,v24.1.5.rc1
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
lsst::afw::cameraGeom::Camera::Builder Class Reference

A helper class for creating and modifying cameras. More...

#include <Camera.h>

Inheritance diagram for lsst::afw::cameraGeom::Camera::Builder:
lsst::afw::cameraGeom::DetectorCollectionBase< Detector::InCameraBuilder >

Public Types

using NameMap
 
using IdMap
 
using List
 

Public Member Functions

virtual ~Builder () noexcept
 
 Builder (std::string const &name)
 Construct a Builder for a completely new Camera with the given name.
 
 Builder (Camera const &camera)
 Construct a Builder with the state of an existing Camera.
 
std::shared_ptr< Camera const > finish () const
 Construct a new Camera from the state of the Builder.
 
std::string getName () const
 Return the name of the camera.
 
void setName (std::string const &name)
 Set the name of the camera.
 
std::string getPupilFactoryName () const
 Return the fully-qualified name of the Python class that provides this Camera's PupilFactory.
 
void setPupilFactoryName (std::string const &pupilFactoryName)
 Set the fully-qualified name of the Python class that provides this Camera's PupilFactory.
 
void setTransformFromFocalPlaneTo (CameraSys const &toSys, std::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > transform)
 Set the transformation from FOCAL_PLANE to the given coordinate system.
 
bool discardTransformFromFocalPlaneTo (CameraSys const &toSys)
 Remove any transformation from FOCAL_PLANE to the given coordinate system.
 
std::shared_ptr< Detector::InCameraBuilderadd (std::string const &name, int id)
 Add a new Detector with the given name and ID.
 
void remove (std::string const &name)
 Remove the detector with the given name or ID.
 
void remove (int id)
 
NameMap const & getNameMap () const noexcept
 Get a map keyed and ordered by name.
 
IdMap const & getIdMap () const noexcept
 Get a map keyed and ordered by ID.
 
std::size_t size () const noexcept
 Get the number of detectors.
 
bool empty () const noexcept
 Determine if the collection contains any detectors.
 
std::shared_ptr< Detector::InCameraBuilderoperator[] (std::string const &name) const
 Implement the [name] operator.
 
std::shared_ptr< Detector::InCameraBuilderoperator[] (int id) const
 Implement the [id] operator.
 
std::shared_ptr< Detector::InCameraBuilderget (std::string const &name, std::shared_ptr< Detector::InCameraBuilder > def=nullptr) const
 Retrieve a detector by name, or fall back to a default.
 
std::shared_ptr< Detector::InCameraBuilderget (int id, std::shared_ptr< Detector::InCameraBuilder > def=nullptr) const
 Retrieve a detector by ID, or fall back to a default.
 

Protected Member Functions

void add (std::shared_ptr< Detector::InCameraBuilder > detector)
 Add a detector to the collection.
 

Detailed Description

A helper class for creating and modifying cameras.

Camera and Camera::Builder have no direct inheritance relationship, but both inherit from different specializations of DetectorCollectionBase, so their container-of-detectors interfaces can generally be used the same way in both Python and templated C++.

Definition at line 208 of file Camera.h.

Member Typedef Documentation

◆ IdMap

Definition at line 53 of file DetectorCollection.h.

◆ List

Definition at line 54 of file DetectorCollection.h.

◆ NameMap

Definition at line 52 of file DetectorCollection.h.

Constructor & Destructor Documentation

◆ ~Builder()

lsst::afw::cameraGeom::Camera::Builder::~Builder ( )
virtualdefaultnoexcept

◆ Builder() [1/2]

lsst::afw::cameraGeom::Camera::Builder::Builder ( std::string const & name)
explicit

Construct a Builder for a completely new Camera with the given name.

Definition at line 204 of file Camera.cc.

204: _name(name) {}

◆ Builder() [2/2]

lsst::afw::cameraGeom::Camera::Builder::Builder ( Camera const & camera)
explicit

Construct a Builder with the state of an existing Camera.

Definition at line 206 of file Camera.cc.

206 :
207 _name(camera.getName()),
208 _pupilFactoryName(camera.getPupilFactoryName())
209{
210 // Add Detector Builders for all Detectors; does not (yet) include
211 // coordinate transform information.
212 for (auto const & pair : camera.getIdMap()) {
213 BaseCollection::add(Camera::makeDetectorBuilder(*pair.second));
214 }
215 // Iterate over connections in TransformMap, distributing them between the
216 // Camera Builder and the Detector Builders.
217 for (auto const & connection : camera.getTransformMap()->getConnections()) {
218 // asserts below are on Detector, Camera, and TransformMap invariants:
219 // - Connections should always be from native sys to something else.
220 // - The only connections between full-camera and per-detector sys
221 // should be from the camera native sys (FOCAL_PLANE) to the
222 // detector native sys (PIXELS).
223 // - When TransformMap standardizes connections, it should maintain
224 // these directions, as that's consistent with "pointing away" from
225 // the overall reference sys (the camera native sys).
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);
232 } else {
233 assert(connection.fromSys == getNativeCameraSys());
234 if (!connection.toSys.hasDetectorName()) {
235 _connections.push_back(connection);
236 }
237 // We ignore the FOCAL_PLANE to PIXELS transforms transforms, as
238 // those are always regenerated from the Orientation when we
239 // rebuild the Camera.
240 }
241 }
242}
std::shared_ptr< TransformMap const > getTransformMap() const noexcept
Obtain the transform registry.
Definition Camera.h:120
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.

Member Function Documentation

◆ add() [1/2]

Add a detector to the collection.

Parameters
[in]detectorNew detector to add to the collection.
Exceptions
pex::exceptions::RuntimeErrorThrown if the ID and/or name conflict with those of detectors already in the collection.
Exception Safety
Strong for pex::exceptions::RuntimeError, weak (collection is made empty) otherwise.

Definition at line 135 of file DetectorCollection.cc.

◆ add() [2/2]

std::shared_ptr< Detector::InCameraBuilder > lsst::afw::cameraGeom::Camera::Builder::add ( std::string const & name,
int id )

Add a new Detector with the given name and ID.

This is the only way to create a completely new detector (as opposed to a copy of an existing one), and it permanently sets that Detector's name and ID.

Exceptions
pex::exceptions::RuntimeErrorThrown if the ID and/or name conflict with those of detectors already in the collection.
Exception Safety
Strong for pex::exceptions::RuntimeError, none otherwise.

Definition at line 329 of file Camera.cc.

329 {
330 auto detector = makeDetectorBuilder(name, id);
331 BaseCollection::add(detector);
332 return detector;
333}
table::Key< int > detector

◆ discardTransformFromFocalPlaneTo()

bool lsst::afw::cameraGeom::Camera::Builder::discardTransformFromFocalPlaneTo ( CameraSys const & toSys)

Remove any transformation from FOCAL_PLANE to the given coordinate system.

Parameters
toSysCoordinate system this transform returns points in.
Returns
true if a transform was removed; false otherwise.

Definition at line 320 of file Camera.cc.

320 {
321 auto iter = findConnection(_connections.begin(), _connections.end(), toSys);
322 if (iter != _connections.end()) {
323 _connections.erase(iter);
324 return true;
325 }
326 return false;
327}

◆ empty()

bool lsst::afw::cameraGeom::DetectorCollectionBase< Detector::InCameraBuilder >::empty ( ) const
inlinenoexceptinherited

Determine if the collection contains any detectors.

Definition at line 72 of file DetectorCollection.h.

◆ finish()

std::shared_ptr< Camera const > lsst::afw::cameraGeom::Camera::Builder::finish ( ) const

Construct a new Camera from the state of the Builder.

Definition at line 246 of file Camera.cc.

246 {
247 // Make a big vector of all coordinate transform connections;
248 // start with general transforms for the camera as a whole:
249 std::vector<TransformMap::Connection> connections(_connections);
250 // Loop over detectors and add the transforms from FOCAL_PLANE
251 // to PIXELS (via the Orientation), and then any extra transforms
252 // from PIXELS to other things.
253 for (auto const & pair : getIdMap()) {
254 auto const & detectorBuilder = *pair.second;
255 connections.push_back(
256 TransformMap::Connection{
257 detectorBuilder.getOrientation().makeFpPixelTransform(detectorBuilder.getPixelSize()),
258 getNativeCameraSys(),
259 detectorBuilder.getNativeCoordSys()
260 }
261 );
262 connections.insert(connections.end(),
263 getDetectorBuilderConnections(detectorBuilder).begin(),
264 getDetectorBuilderConnections(detectorBuilder).end());
265 }
266 // Make a single big TransformMap.
267 auto transformMap = TransformMap::make(getNativeCameraSys(), connections);
268 // Make actual Detector objects, giving each the full TransformMap.
269 DetectorList detectors;
270 detectors.reserve(size());
271 for (auto const & pair : getIdMap()) {
272 auto const & detectorBuilder = *pair.second;
273 detectors.push_back(detectorBuilder.finish(transformMap));
274 }
275 return std::shared_ptr<Camera>(new Camera(_name, std::move(detectors), std::move(transformMap),
276 _pupilFactoryName));
277}
int end
table::Key< int > transformMap
Definition Camera.cc:125
T begin(T... args)
Camera(Camera const &)=delete
DetectorCollection::List DetectorList
Definition Camera.h:48
std::size_t size() const noexcept
Get the number of detectors.
static std::shared_ptr< TransformMap const > make(CameraSys const &reference, Transforms const &transforms)
Construct a TransformMap with all transforms relative to a single reference CameraSys.
T move(T... args)
T reserve(T... args)

◆ get() [1/2]

Retrieve a detector by ID, or fall back to a default.

Parameters
[in]iddetector id
[in]defdefault detector to return. This defaults to nullptr.
Returns
pointer to detector entry if the entry exists, else return the default value

Definition at line 110 of file DetectorCollection.cc.

◆ get() [2/2]

Retrieve a detector by name, or fall back to a default.

Parameters
[in]namedetector name
[in]defdefault detector to return. This defaults to nullptr.
Returns
pointer to detector entry if the entry exists, else return the default value

Definition at line 99 of file DetectorCollection.cc.

◆ getIdMap()

IdMap const & lsst::afw::cameraGeom::DetectorCollectionBase< Detector::InCameraBuilder >::getIdMap ( ) const
inlinenoexceptinherited

Get a map keyed and ordered by ID.

Definition at line 62 of file DetectorCollection.h.

◆ getName()

std::string lsst::afw::cameraGeom::Camera::Builder::getName ( ) const
inline

Return the name of the camera.

Definition at line 230 of file Camera.h.

230{ return _name; }

◆ getNameMap()

NameMap const & lsst::afw::cameraGeom::DetectorCollectionBase< Detector::InCameraBuilder >::getNameMap ( ) const
inlinenoexceptinherited

Get a map keyed and ordered by name.

Definition at line 59 of file DetectorCollection.h.

◆ getPupilFactoryName()

std::string lsst::afw::cameraGeom::Camera::Builder::getPupilFactoryName ( ) const
inline

Return the fully-qualified name of the Python class that provides this Camera's PupilFactory.

Definition at line 236 of file Camera.h.

236{ return _pupilFactoryName; }

◆ operator[]() [1/2]

Implement the [id] operator.

Parameters
[in]iddetector name
Returns
pointer to detector entry

Definition at line 88 of file DetectorCollection.cc.

◆ operator[]() [2/2]

Implement the [name] operator.

Parameters
[in]namedetector name
Returns
pointer to detector entry

Definition at line 80 of file DetectorCollection.cc.

◆ remove() [1/2]

void lsst::afw::cameraGeom::Camera::Builder::remove ( int id)
inline

Definition at line 284 of file Camera.h.

◆ remove() [2/2]

void lsst::afw::cameraGeom::Camera::Builder::remove ( std::string const & name)
inline

Remove the detector with the given name or ID.

Wrapped as __delitem__ in Python.

Exceptions
pex::exceptions::NotFoundErrorif no such detector exists.

Definition at line 283 of file Camera.h.

283{ return BaseCollection::remove(name); }

◆ setName()

void lsst::afw::cameraGeom::Camera::Builder::setName ( std::string const & name)
inline

Set the name of the camera.

Definition at line 233 of file Camera.h.

233{ _name = name; }
table::Key< std::string > name
Definition Amplifier.cc:116

◆ setPupilFactoryName()

void lsst::afw::cameraGeom::Camera::Builder::setPupilFactoryName ( std::string const & pupilFactoryName)
inline

Set the fully-qualified name of the Python class that provides this Camera's PupilFactory.

Definition at line 239 of file Camera.h.

239{ _pupilFactoryName = pupilFactoryName; }
table::Key< std::string > pupilFactoryName
Definition Camera.cc:124

◆ setTransformFromFocalPlaneTo()

void lsst::afw::cameraGeom::Camera::Builder::setTransformFromFocalPlaneTo ( CameraSys const & toSys,
std::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > transform )

Set the transformation from FOCAL_PLANE to the given coordinate system.

Parameters
toSysCoordinate system this transform returns points in.
transformTransform from FOCAL_PLANE to toSys.

If a transform already exists from FOCAL_PLANE to toSys, it is overwritten.

Definition at line 299 of file Camera.cc.

302 {
303 if (toSys.hasDetectorName()) {
304 throw LSST_EXCEPT(
305 pex::exceptions::LogicError,
306 (boost::format("%s should be added to Detector %s, not Camera") %
307 toSys.getSysName() % toSys.getDetectorName()).str()
308 );
309 }
310 auto iter = findConnection(_connections.begin(), _connections.end(), toSys);
311 if (iter == _connections.end()) {
312 _connections.push_back(
313 TransformMap::Connection{transform, getNativeCameraSys(), toSys}
314 );
315 } else {
316 iter->transform = transform;
317 }
318}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
table::Key< int > transform

◆ size()

Get the number of detectors.

Renamed to __len__ in Python.

Definition at line 67 of file DetectorCollection.h.


The documentation for this class was generated from the following files: