LSST Applications g0265f82a02+d6b5cd48b5,g02d81e74bb+80768bd682,g04242d3e92+8eaa23c173,g06b2ea86fd+734f9505a2,g2079a07aa2+14824f138e,g212a7c68fe+5f4fc2ea00,g2305ad1205+293ab1327e,g2bbee38e9b+d6b5cd48b5,g337abbeb29+d6b5cd48b5,g3ddfee87b4+8eaa23c173,g487adcacf7+abec5a19c5,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+97ef3b4495,g5a732f18d5+66d966b544,g5d7b63bc56+636c3c3fd8,g64a986408d+80768bd682,g858d7b2824+80768bd682,g8a8a8dda67+a6fc98d2e7,g99cad8db69+6282a5f541,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga8c6da7877+9e3c062e8e,gb0e22166c9+3863383f4c,gb6a65358fc+d6b5cd48b5,gba4ed39666+9664299f35,gbb8dafda3b+60f904e7bc,gc120e1dc64+1bf26d0180,gc28159a63d+d6b5cd48b5,gcf0d15dbbd+8eaa23c173,gd2a12a3803+f8351bc914,gdaeeff99f8+a38ce5ea23,ge79ae78c31+d6b5cd48b5,gee10cc3b42+a6fc98d2e7,gf1cff7945b+80768bd682,v24.1.5.rc1
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | List of all members
lsst::afw::cameraGeom::Detector::Factory Class Reference
Inheritance diagram for lsst::afw::cameraGeom::Detector::Factory:
lsst::afw::table::io::PersistableFactory

Public Member Functions

 Factory (std::string const &name)
 
std::shared_ptr< table::io::Persistableread (InputArchive const &archive, CatalogVector const &catalogs) const override
 Construct a new object from the given InputArchive and vector of catalogs.
 

Static Public Member Functions

static PersistableFactory const & lookup (std::string const &name, std::string const &module="")
 Return the factory that has been registered with the given name.
 

Static Public Attributes

static Factory const registration
 

Protected Types

using InputArchive = io::InputArchive
 
using CatalogVector = io::CatalogVector
 

Detailed Description

Definition at line 225 of file Detector.cc.

Member Typedef Documentation

◆ CatalogVector

using lsst::afw::table::io::PersistableFactory::CatalogVector = io::CatalogVector
protectedinherited

Definition at line 231 of file Persistable.h.

◆ InputArchive

using lsst::afw::table::io::PersistableFactory::InputArchive = io::InputArchive
protectedinherited

Definition at line 230 of file Persistable.h.

Constructor & Destructor Documentation

◆ Factory()

lsst::afw::cameraGeom::Detector::Factory::Factory ( std::string const & name)
inlineexplicit

Definition at line 228 of file Detector.cc.

228: PersistableFactory(name) {}
PersistableFactory(std::string const &name)
Constructor for the factory.

Member Function Documentation

◆ lookup()

PersistableFactory const & lsst::afw::table::io::PersistableFactory::lookup ( std::string const & name,
std::string const & module = "" )
staticinherited

Return the factory that has been registered with the given name.

If the lookup fails and module is not an empty string, we will attempt to import a Python module with that name (this will only work when the C++ is being called from Python) and try again.

Definition at line 76 of file Persistable.cc.

76 {
77 RegistryMap::const_iterator i = getRegistry().find(name);
78 if (i == getRegistry().end()) {
79 if (!module.empty()) {
80 bool success = base::ModuleImporter::import(module);
81 if (!success) {
82 throw LSST_EXCEPT(
83 pex::exceptions::NotFoundError,
84 (boost::format(
85 "PersistableFactory with name '%s' not found, and import of module "
86 "'%s' failed (possibly because Python calls were not available from C++).") %
87 name % module)
88 .str());
89 }
90 i = getRegistry().find(name);
91 if (i == getRegistry().end()) {
92 throw LSST_EXCEPT(
93 pex::exceptions::LogicError,
94 (boost::format(
95 "PersistableFactory with name '%s' not found even after successful import "
96 "of module '%s'. Please report this as a bug in the persistence "
97 "implementation for this object.") %
98 name % module)
99 .str());
100 }
101 } else {
102 throw LSST_EXCEPT(
103 pex::exceptions::LogicError,
104 (boost::format(
105 "PersistableFactory with name '%s' not found, and no Python module to import "
106 "was provided. Please report this as a bug in the persistence implementation "
107 "for this object.") %
108 name)
109 .str());
110 }
111 }
112 return *i->second;
113}
int end
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
static bool import(std::string const &name)
Import the given Python module, and return true if successful.

◆ read()

std::shared_ptr< table::io::Persistable > lsst::afw::cameraGeom::Detector::Factory::read ( InputArchive const & archive,
CatalogVector const & catalogs ) const
inlineoverridevirtual

Construct a new object from the given InputArchive and vector of catalogs.

Implements lsst::afw::table::io::PersistableFactory.

Definition at line 230 of file Detector.cc.

233 {
234 LSST_ARCHIVE_ASSERT(catalogs.size() == 2u);
235 LSST_ARCHIVE_ASSERT(catalogs.front().size() == 1u);
236 auto const & record = catalogs.front().front();
237 int version = getVersion(catalogs);
238 if (version > SERIALIZATION_VERSION) {
239 throw LSST_EXCEPT(
240 pex::exceptions::TypeError,
241 "Cannot read Detector FITS version > " +
242 std::to_string(SERIALIZATION_VERSION)
243 );
244 }
245 auto const & keys = DetectorSchema(version);
246
247 AmpVector amps;
248 amps.reserve(catalogs.back().size());
249 for (auto const & record : catalogs.back()) {
250 amps.push_back(Amplifier::Builder::fromRecord(record).finish());
251 }
252
253 auto flattenedMatrix = record.get(keys.crosstalk);
254 ndarray::Array<float, 2, 2> crosstalk;
255 if (!flattenedMatrix.isEmpty()) {
256 crosstalk = ndarray::allocate(amps.size(), amps.size());
257 ndarray::flatten<1>(crosstalk) = flattenedMatrix;
258 }
259
260 // get values for not-always-present fields if present
261 const auto physicalType = (version >= 1) ? record.get(keys.physicalType) : "";
262
264 if (version >= 2) {
265 fpPosition = record.get(keys.fpPosition);
266 } else {
267 lsst::geom::Point2D fpPosition2(record.get(keys.fpPosition2));
269 }
270
271 Fields fields = {
272 record.get(keys.name),
273 record.get(keys.id),
274 static_cast<DetectorType>(record.get(keys.type)),
275 record.get(keys.serial),
276 record.get(keys.bbox),
277 Orientation(
279 record.get(keys.refPoint),
280 record.get(keys.yaw),
281 record.get(keys.pitch),
282 record.get(keys.roll)
283 ),
284 lsst::geom::Extent2D(record.get(keys.pixelSize)),
285 crosstalk,
287 };
288
290 new Detector(
291 std::move(fields),
292 archive.get<TransformMap>(record.get(keys.transformMap)),
293 std::move(amps)
294 )
295 );
296 }
table::Point3DKey fpPosition
Definition Detector.cc:168
table::Point2DKey fpPosition2
Definition Detector.cc:167
table::Key< std::string > physicalType
Definition Detector.cc:175
table::Key< table::Array< float > > crosstalk
Definition Detector.cc:174
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
Definition Persistable.h:48
static Builder fromRecord(table::BaseRecord const &record)
Construct a new Builder object from the fields in the given record.
Definition Amplifier.cc:286
A coordinate class intended to represent absolute positions.
Definition Point.h:169
T move(T... args)
Extent< double, 2 > Extent2D
Definition Extent.h:400
Point< double, 3 > Point3D
Definition Point.h:325
T to_string(T... args)

Member Data Documentation

◆ registration

Detector::Factory const lsst::afw::cameraGeom::Detector::Factory::registration
static

Definition at line 298 of file Detector.cc.


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