LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
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::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. More...
 

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. More...
 

Static Public Attributes

static Factory const registration
 

Protected Types

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

Detailed Description

Definition at line 234 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 ( )
inline

Definition at line 237 of file Detector.cc.

237 : PersistableFactory("Detector") {}
PersistableFactory(std::string const &name)
Constructor for the factory.
Definition: Persistable.cc:74

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,
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,
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 }
table::Key< std::string > name
Definition: Amplifier.cc:116
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.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ 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 239 of file Detector.cc.

240  {
241  // N.b. can't use "auto const keys" as cctor is deleted
242  auto const & keys = PersistenceHelper(catalogs.front().getSchema());
243 
244  LSST_ARCHIVE_ASSERT(catalogs.size() == 2u);
245  LSST_ARCHIVE_ASSERT(catalogs.front().getSchema() == keys.schema);
246  LSST_ARCHIVE_ASSERT(catalogs.front().size() == 1u);
247  auto const & record = catalogs.front().front();
248 
249  AmpVector amps;
250  amps.reserve(catalogs.back().size());
251  for (auto const & record : catalogs.back()) {
252  amps.push_back(Amplifier::Builder::fromRecord(record).finish());
253  }
254 
255  auto flattenedMatrix = record.get(keys.crosstalk);
256  ndarray::Array<float, 2, 2> crosstalk;
257  if (!flattenedMatrix.isEmpty()) {
258  crosstalk = ndarray::allocate(amps.size(), amps.size());
259  ndarray::flatten<1>(crosstalk) = flattenedMatrix;
260  }
261 
262  // get values for not-always-present fields if present
263  const auto physicalType = keys.physicalType.isValid() ? record.get(keys.physicalType) : "";
264  Fields fields = {
265  record.get(keys.name),
266  record.get(keys.id),
267  static_cast<DetectorType>(record.get(keys.type)),
268  record.get(keys.serial),
269  record.get(keys.bbox),
270  Orientation(
271  record.get(keys.fpPosition),
272  record.get(keys.refPoint),
273  record.get(keys.yaw),
274  record.get(keys.pitch),
275  record.get(keys.roll)
276  ),
277  lsst::geom::Extent2D(record.get(keys.pixelSize)),
278  crosstalk,
280  };
281 
283  new Detector(
284  std::move(fields),
285  archive.get<TransformMap>(record.get(keys.transformMap)),
286  std::move(amps)
287  )
288  );
289  }
table::Key< std::string > physicalType
Definition: Detector.cc:174
table::Key< table::Array< float > > crosstalk
Definition: Detector.cc:173
#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
T move(T... args)
DetectorType
Type of imaging detector.
Definition: Detector.h:44
Extent< double, 2 > Extent2D
Definition: Extent.h:400

Member Data Documentation

◆ registration

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

Definition at line 291 of file Detector.cc.


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