CFEL - ASG Software Suite
2.5.0
CASS
|
pixel detector calibrations More...
#include <pixel_detector_calibration.h>
Public Member Functions | |
pp330 (const name_t &) | |
constructor. More... | |
virtual void | process (const CASSEvent &, result_t &) |
overwrite default behaviour don't do anything More... | |
virtual void | loadSettings (size_t) |
load the settings of this pp More... | |
virtual void | aboutToQuit () |
write the calibrations before quitting More... | |
virtual void | processCommand (std::string command) |
react on when the gui clients tell this to start the calibration More... | |
![]() | |
AccumulatingProcessor (const name_t &name) | |
constructor More... | |
virtual | ~AccumulatingProcessor () |
virtual destructor More... | |
virtual void | processEvent (const CASSEvent &evt) |
process the event More... | |
virtual const result_t & | result (const CASSEvent::id_t) |
retrieve a result. More... | |
virtual void | releaseEvent (const CASSEvent &) |
overwrite default behaviour to do nothing More... | |
virtual void | createHistList (result_t::shared_pointer result) |
create the list of results More... | |
![]() | |
Processor (const name_t &name) | |
constructor More... | |
virtual | ~Processor () |
virtual destructor More... | |
result_t::shared_pointer | resultCopy (const uint64_t eventid) |
retrieve histogram for id More... | |
virtual void | load () |
load the general settings More... | |
const names_t & | dependencies () |
Define all processors keys a processor depends on. More... | |
void | clearDependencies () |
clear the dependenies More... | |
void | clearHistograms () |
clear the histograms More... | |
const name_t | name () const |
retrieve the name of this processor More... | |
bool | hide () const |
retrieve the hide flag of this processor More... | |
const std::string & | comment () const |
retrieve the comment of this processor More... | |
Protected Member Functions | |
void | loadCalibration () |
write the calibration data to file More... | |
void | writeCalibration () |
write the calibration data to file More... | |
void | setBadPixMap () |
set up the bad pixel map More... | |
void | cummulativeUpdate (result_t::const_iterator image, result_t::iterator meanAr, result_t::iterator stdvAr, result_t::iterator nValsAr, const size_t sizeOfImage) |
a cummulative average and variance calculation More... | |
void | movingUpdate (result_t::const_iterator image, result_t::iterator meanAr, result_t::iterator stdvAr, result_t::iterator nValsAr, const size_t sizeOfImage) |
a moving exponential average and variance calculation More... | |
![]() | |
virtual void | createHistList (result_t::shared_pointer result) |
create result list. More... | |
void | setupGeneral () |
general setup of the processor More... | |
bool | setupCondition (bool defaultConditionType=true) |
setup the condition. More... | |
shared_pointer | setupDependency (const std::string &depVarName, const name_t &name="") |
setup the dependecy. More... | |
Private Types | |
enum | { MEAN, STDV, NVALS, BADPIX, nbrOfOutputs } |
define the position of the beginning of the different maps More... | |
typedef std::tr1::function< void(result_t::const_iterator, result_t::iterator, result_t::iterator, result_t::iterator, const size_t)> | updateFunc_t |
define the function More... | |
Private Attributes | |
updateFunc_t | _updateStatistics |
the function that will update the statistics More... | |
size_t | _meanBeginOffset |
the offset to the first point of the mean array in the result More... | |
size_t | _meanEndOffset |
the offset to one beyond the last point of the mean array in the result More... | |
size_t | _stdvBeginOffset |
the offset to the first point of the stdv array in the result More... | |
size_t | _stdvEndOffset |
the offset to one beyond the last point of the stdv array in the result More... | |
size_t | _bPixBeginOffset |
the offset to the first point of the bad pixels array in the result More... | |
size_t | _bPixEndOffset |
the offset to one beyond the last point of the bad pixels array in the result More... | |
size_t | _nValBeginOffset |
the offset to the first point of the counts array in the result More... | |
size_t | _nValEndOffset |
the offset to the first point of the counts array in the result More... | |
float | _NoiseLowerBound |
the lower noise boundary when determining bad pixels More... | |
float | _NoiseUpperBound |
the upper noise boundary when determining bad pixels More... | |
float | _autoNoiseSNR |
the signal to noise ratio that determines the noise boundaries in case of automatically determining the boundaries from the noise values statistics More... | |
float | _autoNoiseSNRStat |
the signal to noise ratio that determines which values will be taken into account when automatically determining the boundaries from the noise values statistics More... | |
float | _OffsetLowerBound |
the lower offset boundary when determining bad pixels More... | |
float | _OffsetUpperBound |
the upper offset boundary when determining bad pixels More... | |
float | _autoOffsetSNR |
the signal to noise ratio that determines the offset boundaries in case of automatically determining the boundaries from the noise values statistics More... | |
float | _autoOffsetSNRStat |
the signal to noise ratio that determines which values will be taken into account when automatically determining the boundaries from the offset values statistics More... | |
float | _minNbrPixels |
minimum number of pixels in the trainig set that are part of the distribution More... | |
shared_pointer | _image |
the raw image More... | |
bool | _train |
flag telling whether training is needed More... | |
std::vector< result_t::shared_pointer > | _trainstorage |
the storage for the training images More... | |
size_t | _minTrainImages |
the minimum nbr of images necessary for training More... | |
bool | _write |
flag to tell whether the calibration should be written More... | |
float | _snr |
the value above which outliers are removed from the distribution More... | |
std::string | _filename |
the filename that is used to save the calibration More... | |
std::string | _infilename |
the filename that is used to load the calibration More... | |
bool | _resetBadPixel |
flag to tell when the bad pixel should be reset More... | |
size_t | _counter |
counter to count the total amount of images More... | |
bool | _update |
flag to tell whether the calibration should be updated after the training has completed. More... | |
int | _updatePeriod |
the period after which the data should be autosaved More... | |
float | _alpha |
the alpha value for the moving average and stdv More... | |
uint32_t | _lastwritten |
the time_t value of the last time the calibration was written More... | |
uint32_t | _updateWritePeriod |
the update time period in s More... | |
Additional Inherited Members | |
![]() | |
typedef std::tr1::shared_ptr< Processor > | shared_pointer |
a shared pointer of this More... | |
typedef std::string | name_t |
define the name type More... | |
typedef std::list< name_t > | names_t |
define the list of names More... | |
typedef CachedList::item_type | result_t |
define the results More... | |
typedef CachedList::item_sp | resultsp_t |
define the shared pointer to the result More... | |
![]() | |
result_t::shared_pointer | _result |
the result that accumulates the events More... | |
size_t | _nbrEventsAccumulated |
the number of events the processor has accumulated More... | |
![]() | |
const name_t | _name |
the processors name More... | |
bool | _hide |
flag to tell whether this pp should be hidden in the dropdown list More... | |
std::string | _comment |
optional comment that one can add to a processor. More... | |
CachedList | _resultList |
the list of results More... | |
names_t | _dependencies |
the list of dependencies More... | |
shared_pointer | _condition |
pointer to the processor that will contain the condition More... | |
pixel detector calibrations
Processor/%name%/{RawImage}
the raw image of the pixel detector
Processor/%name%/{OutputFilename}
the name of the file where the calibration will be written to. Default is "NotSet", in which case a filename will be automatically generated from the time and name of the Processor and a link to the autogenerated file name will be created which has the same name but without the time.
Processor/%name%/{WriteCal}
Flag to tell whether the calibration should be written. Default is true.
Processor/%name%/{Train}
Flag to tell whether training should be done. Default is true
Processor/%name%/{NbrTrainingImages}
The Number of images used for the training. Default is 200
Processor/%name%/{SNR}
The signal to noise value that indicates whether a pixel is an outlier of the distribution of pixels in the trainingset and should not be considered. Default is 4.
Processor/%name%/{SNRNoiseAutoBoundaries}
The signal to noise ratio for determining the boundary values of bad pixels from the noise map. If this value is negative the manual set values will be taken from the values below. Otherwise the mean value and the standart deviation of all noise values will be calculated and boundaries are set to
Default is 4.
Processor/%name%/{SNRNoiseAutoBoundariesStat}
In case of using auto generation of the boundaries this signal to \ noise ratio determines which values will be taken when calculating the mean and stdv of the distribution. Default is 4.
Processor/%name%/{NoiseLowerBoundary|NoiseUpperBoundary}
In case the SNRNoiseAutoBoundaries is negative these values will be taken to determine the bad pixels from the noise map. Default is 0|3.
Processor/%name%/{SNROffsetAutoBoundaries}
The signal to noise ratio for determining the boundary values of bad pixels from the offset map. If this value is negative the manual set values will be taken from the values below. Otherwise the mean value and the standart deviation of all noise values will be calculated and boundaries are set to
Default is -1.
Processor/%name%/{SNROffsetAutoBoundariesStat}
In case of using auto generation of the boundaries this signal to \ noise ratio determines which values will be taken when calculating the mean and stdv of the distribution. Default is 4.
Processor/%name%/{OffsetLowerBoundary|OffsetUpperBoundary}
In case the SNROffsetAutoBoundaries is negative these values will be taken to determine the bad pixels from the offset map. Default is -1e20|1e20.
Processor/%name%/{MinNbrPixels}
The minimum amount of pixels of the trainingset that are required for the individual pixel. The value is given in percent of the total amount of pixels available. If the amount is lower than this value, the pixel will be marked as bad. Default is 90
Processor/%name%/{InputFilename}
The input filname of the calibration file. If it is "NotSet" it assumes a filename of "\%name\%.lnk" and tries to find the link target. If it can't find it, it will skip loading of the calibration file. This also happens if another filename is given, but the file can't be opened or the size of the images in the file and the Rawimages differ. Program execution won't be stopped only an error is written into the log file. Default is "NotSet"
Processor/%name%/{ResetBadPixels}
When set to true, it will reset a bad pixel to good if the pixel is within the checks for beeing good (with in the Noise range and enough good values). Default is false, which keeps it marked as bad.
Processor/%name%/{UpdateCalibration}
Flag to tell whether after the training has completed that the calibration should be updated with more images. Default is true.
Processor/%name%/{UpdateCalibrationType}
The type of update used. Default value is "cummulative". Possible values are:
Processor/%name%/{NbrOfImages}
In case of using the moving update type, this tells how many images should be considered in the exponential moving average and standart deviation estimation.
Processor/%name%/{UpdateBadPixPeriod}
After how many received images should the bad pixel map be updated If negative, no updates will be made. Default is -1.
Processor/%name%/{WritePeriod}
When automagically updating the dark, this gives the time in seconds between two writings of the darkcalibration file. Note that a manual call to the training will force writing even though the time between two writes has not ellapsed. Default is 0, which causes no auto writing
Definition at line 125 of file pixel_detector_calibration.h.
|
private |
define the function
Definition at line 193 of file pixel_detector_calibration.h.
|
private |
define the position of the beginning of the different maps
Enumerator | |
---|---|
MEAN | |
STDV | |
NVALS | |
BADPIX | |
nbrOfOutputs |
Definition at line 200 of file pixel_detector_calibration.h.
pp330::pp330 | ( | const name_t & | name | ) |
constructor.
Definition at line 38 of file pixel_detector_calibration.cpp.
References loadSettings().
|
virtual |
write the calibrations before quitting
Reimplemented from cass::Processor.
Definition at line 341 of file pixel_detector_calibration.cpp.
References _write, and writeCalibration().
|
protected |
a cummulative average and variance calculation
[in] | image | reference to the image array |
if pixel is outlier skip pixel
Definition at line 362 of file pixel_detector_calibration.cpp.
References _snr.
Referenced by loadSettings().
|
protected |
write the calibration data to file
If offset filename is a link, try to deduce the real filename Otherwise check if file exists
in case the previous was just a link set the info the real name and get the creation data
read the data from the file
check if data is of the right size
copy it to the result container
set the number of fills to the number of training images
set up the bad pixel map
Definition at line 144 of file pixel_detector_calibration.cpp.
References _infilename, _lastwritten, _meanBeginOffset, _minTrainImages, _nValBeginOffset, _nValEndOffset, cass::AccumulatingProcessor::_result, _stdvBeginOffset, cass::Log::add(), cass::Result< T >::begin(), QFileInfo::created(), cass::Log::ERROR, QFileInfo::exists(), QString::fromStdString(), QFileInfo::isSymLink(), cass::Processor::name(), nbrOfOutputs, cass::AccumulatingProcessor::result(), setBadPixMap(), QFileInfo::setFile(), cass::Result< T >::shape(), size, QFileInfo::symLinkTarget(), cass::toString(), and cass::Log::VERBOSEINFO.
Referenced by loadSettings().
|
virtual |
load the settings of this pp
load parameters from the ini file
set up the type of update
reset the variables
determine the offset of the output arrays from the size of the input image
in case we want updating and no calibration was loaded or the last calibration is too outdated (now - _lastwritten > _updateWritePeriod), we need to start training now
Reimplemented from cass::Processor.
Definition at line 45 of file pixel_detector_calibration.cpp.
References _alpha, _autoNoiseSNR, _autoNoiseSNRStat, _autoOffsetSNR, _autoOffsetSNRStat, _bPixBeginOffset, _bPixEndOffset, cass::Processor::_condition, _counter, _filename, _image, _infilename, _lastwritten, _meanBeginOffset, _meanEndOffset, _minNbrPixels, _minTrainImages, _NoiseLowerBound, _NoiseUpperBound, _nValBeginOffset, _nValEndOffset, _OffsetLowerBound, _OffsetUpperBound, _resetBadPixel, _snr, _stdvBeginOffset, _stdvEndOffset, _train, _trainstorage, _update, _updatePeriod, _updateStatistics, _updateWritePeriod, _write, cass::Log::add(), BADPIX, QSettings::beginGroup(), cass::AccumulatingProcessor::createHistList(), cummulativeUpdate(), QDateTime::currentDateTime(), QString::fromStdString(), QDateTime::fromTime_t(), cass::Log::INFO, loadCalibration(), MEAN, movingUpdate(), cass::Processor::name(), nbrOfOutputs, NVALS, cass::Processor::setupCondition(), cass::Processor::setupDependency(), cass::Processor::setupGeneral(), STDV, cass::toString(), and QSettings::value().
Referenced by pp330().
|
protected |
a moving exponential average and variance calculation
taken from http://mathforum.org/kb/message.jspa?messageID=1637905
[in] | image | reference to the image array |
if pixel is outlier skip pixel
update the estimate of the mean and stdv
Definition at line 391 of file pixel_detector_calibration.cpp.
Referenced by loadSettings().
overwrite default behaviour don't do anything
mask bad pixels based upon the calibration
write the calibration
reset the training variables
add current image to statistics of the calibration
update the bad pix map and the file if requested
Reimplemented from cass::Processor.
Definition at line 418 of file pixel_detector_calibration.cpp.
References _counter, _image, _lastwritten, _meanBeginOffset, _minTrainImages, _nValBeginOffset, _snr, _stdvBeginOffset, _train, _trainstorage, _update, _updatePeriod, _updateStatistics, _updateWritePeriod, _write, cass::Log::add(), cass::CummulativeStatisticsNoOutlier< Type >::addDatum(), cass::Result< T >::begin(), cass::Result< T >::clone(), QDateTime::currentDateTime(), cass::CASSEvent::id(), cass::Log::INFO, cass::Result< T >::lock, cass::CummulativeStatisticsNoOutlier< Type >::mean(), cass::Processor::name(), cass::CummulativeStatisticsNoOutlier< Type >::nbrPointsUsed(), setBadPixMap(), cass::Result< T >::shape(), cass::CummulativeStatisticsNoOutlier< Type >::stdv(), and writeCalibration().
|
virtual |
react on when the gui clients tell this to start the calibration
command | The command that was issued by the gui clients |
if the command orders us to start the darkcal, clear all variables and start the calibration
Reimplemented from cass::Processor.
Definition at line 347 of file pixel_detector_calibration.cpp.
References _counter, _train, _trainstorage, cass::Log::add(), cass::Log::INFO, and cass::Processor::name().
|
protected |
set up the bad pixel map
get iterators to the mean, mask, nVals and stdv values
boundaries for bad pixels based upon the noise map
calculate the value boundaries for bad pixels from the statistics of the stdv values remove outliers when calculating the mean and stdv
boundaries for bad pixels based upon the offset map
calculate the value boundaries for bad pixels from the statistics of the stdv values
set all pixels as bad, whos noise or offset value is an outlier of the statistics of the noise values, or offset values.
set bad pixel or reset if requested
Definition at line 270 of file pixel_detector_calibration.cpp.
References _autoNoiseSNR, _autoNoiseSNRStat, _autoOffsetSNR, _autoOffsetSNRStat, _bPixBeginOffset, _counter, _meanBeginOffset, _meanEndOffset, _minNbrPixels, _NoiseLowerBound, _NoiseUpperBound, _nValBeginOffset, _OffsetLowerBound, _OffsetUpperBound, _resetBadPixel, cass::AccumulatingProcessor::_result, _stdvBeginOffset, _stdvEndOffset, cass::Log::add(), cass::CummulativeStatisticsNoOutlier< Type >::addDistribution(), cass::Result< T >::begin(), cass::Log::INFO, cass::CummulativeStatisticsNoOutlier< Type >::mean(), cass::Processor::name(), nbrOfOutputs, cass::AccumulatingProcessor::result(), cass::Result< T >::shape(), cass::CummulativeStatisticsNoOutlier< Type >::stdv(), and cass::toString().
Referenced by loadCalibration(), and process().
|
protected |
write the calibration data to file
check if a proper name is given otherwise autogenerate a name from the name of the processor and the current time
write the calibration to the file
remember when this was written
if no proper filename was given, create a link to the current file with a more general filename
Definition at line 216 of file pixel_detector_calibration.cpp.
References _filename, _lastwritten, _meanBeginOffset, _meanEndOffset, cass::AccumulatingProcessor::_result, _stdvBeginOffset, _stdvEndOffset, cass::Result< T >::begin(), QDateTime::currentDateTime(), QFile::exists(), QString::fromStdString(), QFile::link(), cass::Processor::name(), nbrOfOutputs, QFile::remove(), cass::AccumulatingProcessor::result(), cass::Result< T >::shape(), QDateTime::toString(), and QDateTime::toTime_t().
Referenced by aboutToQuit(), and process().
|
private |
the alpha value for the moving average and stdv
Definition at line 302 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and movingUpdate().
|
private |
the signal to noise ratio that determines the noise boundaries in case of automatically determining the boundaries from the noise values statistics
Definition at line 235 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
the signal to noise ratio that determines which values will be taken into account when automatically determining the boundaries from the noise values statistics
Definition at line 241 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
the signal to noise ratio that determines the offset boundaries in case of automatically determining the boundaries from the noise values statistics
Definition at line 252 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
the signal to noise ratio that determines which values will be taken into account when automatically determining the boundaries from the offset values statistics
Definition at line 258 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
the offset to the first point of the bad pixels array in the result
Definition at line 215 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
the offset to one beyond the last point of the bad pixels array in the result
Definition at line 218 of file pixel_detector_calibration.h.
Referenced by loadSettings().
|
private |
counter to count the total amount of images
Definition at line 291 of file pixel_detector_calibration.h.
Referenced by loadSettings(), process(), processCommand(), and setBadPixMap().
|
private |
the filename that is used to save the calibration
Definition at line 282 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and writeCalibration().
|
private |
the raw image
Definition at line 264 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and process().
|
private |
the filename that is used to load the calibration
Definition at line 285 of file pixel_detector_calibration.h.
Referenced by loadCalibration(), and loadSettings().
|
private |
the time_t value of the last time the calibration was written
Definition at line 305 of file pixel_detector_calibration.h.
Referenced by loadCalibration(), loadSettings(), process(), and writeCalibration().
|
private |
the offset to the first point of the mean array in the result
Definition at line 203 of file pixel_detector_calibration.h.
Referenced by loadCalibration(), loadSettings(), process(), setBadPixMap(), and writeCalibration().
|
private |
the offset to one beyond the last point of the mean array in the result
Definition at line 206 of file pixel_detector_calibration.h.
Referenced by loadSettings(), setBadPixMap(), and writeCalibration().
|
private |
minimum number of pixels in the trainig set that are part of the distribution
Definition at line 261 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
the minimum nbr of images necessary for training
Definition at line 273 of file pixel_detector_calibration.h.
Referenced by loadCalibration(), loadSettings(), and process().
|
private |
the lower noise boundary when determining bad pixels
Definition at line 227 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
the upper noise boundary when determining bad pixels
Definition at line 230 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
the offset to the first point of the counts array in the result
Definition at line 221 of file pixel_detector_calibration.h.
Referenced by loadCalibration(), loadSettings(), process(), and setBadPixMap().
|
private |
the offset to the first point of the counts array in the result
Definition at line 224 of file pixel_detector_calibration.h.
Referenced by loadCalibration(), and loadSettings().
|
private |
the lower offset boundary when determining bad pixels
Definition at line 244 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
the upper offset boundary when determining bad pixels
Definition at line 247 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
flag to tell when the bad pixel should be reset
Definition at line 288 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and setBadPixMap().
|
private |
the value above which outliers are removed from the distribution
Definition at line 279 of file pixel_detector_calibration.h.
Referenced by cummulativeUpdate(), loadSettings(), movingUpdate(), and process().
|
private |
the offset to the first point of the stdv array in the result
Definition at line 209 of file pixel_detector_calibration.h.
Referenced by loadCalibration(), loadSettings(), process(), setBadPixMap(), and writeCalibration().
|
private |
the offset to one beyond the last point of the stdv array in the result
Definition at line 212 of file pixel_detector_calibration.h.
Referenced by loadSettings(), setBadPixMap(), and writeCalibration().
|
private |
flag telling whether training is needed
Definition at line 267 of file pixel_detector_calibration.h.
Referenced by loadSettings(), process(), and processCommand().
|
private |
the storage for the training images
Definition at line 270 of file pixel_detector_calibration.h.
Referenced by loadSettings(), process(), and processCommand().
|
private |
flag to tell whether the calibration should be updated after the training has completed.
Definition at line 296 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and process().
|
private |
the period after which the data should be autosaved
Definition at line 299 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and process().
|
private |
the function that will update the statistics
Definition at line 196 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and process().
|
private |
the update time period in s
Definition at line 308 of file pixel_detector_calibration.h.
Referenced by loadSettings(), and process().
|
private |
flag to tell whether the calibration should be written
Definition at line 276 of file pixel_detector_calibration.h.
Referenced by aboutToQuit(), loadSettings(), and process().