LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Public Member Functions | List of all members
lsst::meas::base::CentroidChecker Class Reference

#include <CentroidUtilities.h>

Public Member Functions

 CentroidChecker (afw::table::Schema &schema, std::string const &name, bool inside=true, double maxDistFromPeak=-1.0)
 Check source record for an centroid algorithm called name, noting if the centroid already set by the algorithm is outside the footprint attached to the record. More...
 
bool operator() (afw::table::SourceRecord &record) const
 Set the centroid to the first footprint if the centroid is either more than _dist pixels from the footprint center, or if it is outside the footprint. More...
 

Detailed Description

Definition at line 190 of file CentroidUtilities.h.

Constructor & Destructor Documentation

◆ CentroidChecker()

lsst::meas::base::CentroidChecker::CentroidChecker ( afw::table::Schema schema,
std::string const &  name,
bool  inside = true,
double  maxDistFromPeak = -1.0 
)

Check source record for an centroid algorithm called name, noting if the centroid already set by the algorithm is outside the footprint attached to the record.

If that is the case, we should: (1) set the general failure flag for the algorithm (2) set the algorithmName + "_flag_resetToPeak" flag (3) change the value of the centroid to the footprint Peak

Secondly, check to see if the centroid is more than "dist" pixels from the footprint peak, and similarly modify the centroi value to the peak in that case

Parameters
[in,out]schemaSchema to which the flag_resetToPeak is to be added
[in]nameThe name of the algorithm we will be checking
[in]doFootprintCheckCheck if centroid is within footprint
[in]maxDistFromPeakCheck if centroid is more than dist from footprint peak

Definition at line 174 of file CentroidUtilities.cc.

176  : _doFootprintCheck(doFootprintCheck), _maxDistFromPeak(maxDistFromPeak) {
177  _resetKey = schema.addField<afw::table::Flag>(schema.join(name, "flag_resetToPeak"),
178  "set if CentroidChecker reset the centroid");
179  _failureKey = schema.find<afw::table::Flag>(schema.join(name, "flag")).key;
180  _xKey = schema.find<CentroidElement>(schema.join(name, "x")).key;
181  _yKey = schema.find<CentroidElement>(schema.join(name, "y")).key;
182 }
table::Schema schema
Definition: Camera.cc:161
Key< U > key
Definition: Schema.cc:281
double CentroidElement
Definition: constants.h:56

Member Function Documentation

◆ operator()()

bool lsst::meas::base::CentroidChecker::operator() ( afw::table::SourceRecord record) const

Set the centroid to the first footprint if the centroid is either more than _dist pixels from the footprint center, or if it is outside the footprint.

Definition at line 186 of file CentroidUtilities.cc.

186  {
187  CentroidElement x = record.get(_xKey);
188  CentroidElement y = record.get(_yKey);
189 
190  if (!_doFootprintCheck && _maxDistFromPeak < 0.0) {
191  return false;
192  }
193  PTR(afw::detection::Footprint) footprint = record.getFootprint();
194  if (!footprint) {
195  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "No Footprint attached to record");
196  }
197  if (footprint->getPeaks().empty()) {
198  throw LSST_EXCEPT(pex::exceptions::RuntimeError, "Footprint has no peaks; cannot verify centroid.");
199  }
200  CentroidElement footX = footprint->getPeaks().front().getFx();
201  CentroidElement footY = footprint->getPeaks().front().getFy();
202  double distsq = (x - footX) * (x - footX) + (y - footY) * (y - footY);
203  if ((_doFootprintCheck && !footprint->contains(geom::Point2I(geom::Point2D(x, y)))) ||
204  ((_maxDistFromPeak > 0) && (distsq > _maxDistFromPeak * _maxDistFromPeak))) {
205  record.set(_xKey, footX);
206  record.set(_yKey, footY);
207  record.set(_failureKey, true);
208  record.set(_resetKey, true);
209  return true;
210  }
211  return false;
212 }
#define PTR(...)
Definition: base.h:41
int y
Definition: SpanSet.cc:49
Point< double, 2 > Point2D
Definition: Point.h:324
Point< int, 2 > Point2I
Definition: Point.h:321
double x
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::detection::Footprint Footprint
Definition: Source.h:61
double CentroidElement
Definition: constants.h:56

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