CFEL - ASG Software Suite  2.5.0
CASS
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
cass::pixeldetector::CommonData Class Reference

Data used commonly for one AdvancedDetector. More...

#include <common_data.h>

+ Collaboration diagram for cass::pixeldetector::CommonData:

Public Types

typedef std::tr1::shared_ptr< CommonDatashared_pointer
 typedef a shared pointer of this More...
 
typedef std::map< std::string, shared_pointerinstancesmap_t
 typedef describing the instances of the helper More...
 
typedef std::vector< char > mask_t
 a mask is a vector of bools More...
 

Public Member Functions

void loadSettings (CASSSettings &s)
 load the settings of this common object More...
 
void generateMaps (const Frame &frame)
 generate the maps from the frame data with help of the functors More...
 
void createCorMap ()
 create the correction map More...
 
void saveOffsetNoiseMaps ()
 save offset and noise maps More...
 
void saveGainMap ()
 save gain map More...
 
void saveHotPixMask ()
 save hot pixel mask More...
 

Static Public Member Functions

static shared_pointer instance (const instancesmap_t::key_type &detector)
 static function creating instance of this. More...
 
static void controlCalibration (const std::string &command)
 issue a command to the map creators of all instances More...
 

Public Attributes

QReadWriteLock lock
 lock to synchronize read and write acces to the common data More...
 
size_t columns
 the width of the maps More...
 
size_t rows
 the height of the maps More...
 
Detector::frame_t offsetMap
 the offset map More...
 
Detector::frame_t noiseMap
 the noise map More...
 
mask_t mask
 the detector mask More...
 
mask_t hotpixels
 the hotpixel mask More...
 
Detector::frame_t gain_cteMap
 the gain + cte map More...
 
Detector::frame_t correctionMap
 the correction map More...
 
int32_t detectorId
 the id of the detector that contains the frames whos maps we have here More...
 
std::string detectorname
 the name of the detector whos maps are contained in this class instance More...
 

Private Member Functions

 CommonData ()
 prevent people from constructing other than using instance(). More...
 
 CommonData (const instancesmap_t::key_type &detname)
 private constructor. More...
 
 CommonData (const CommonData &)
 prevent copy-construction More...
 
CommonDataoperator= (const CommonData &)
 prevent assingment More...
 

Private Attributes

std::tr1::shared_ptr< MapCreatorBase_offsetnoiseMapcreator
 functor to create the Maps More...
 
std::tr1::function< void(const std::string &, CommonData &)> _saveNoiseOffsetTo
 function to write the offset maps More...
 
std::string _outputOffsetFilename
 output filename for the offset and noise maps More...
 
std::string _inputOffsetFilename
 input filename of the offset and noise map More...
 
bool _settingsLoaded
 switch to tell that load settins for this common data was already running More...
 
std::tr1::shared_ptr< MapCreatorBase_gainCreator
 functor to create the Maps More...
 
std::tr1::function< void(const std::string &, CommonData &)> _saveGainTo
 function to write the gain map More...
 
std::string _inputGainFilename
 the gain correction input filename More...
 
std::string _outputGainFilename
 the gain correction output filename More...
 
std::tr1::function< void(const std::string &, CommonData &)> _saveHotPixTo
 function to write the hot pixel mask More...
 
std::string _inputHotPixFilename
 the hot pixel mask input filename More...
 
std::string _outputHotPixFilename
 the hot pixel mask output filename More...
 
std::pair< Detector::pixel_t, Detector::pixel_t_noiseRange
 the range in adu for masking noisy pixels More...
 
bool _autoNoiseThreshold
 flag whether the noise threshold should be automatically determined More...
 
Detector::pixel_t _autoMultiplier
 the multiplier about which the automatically determined threshold will be defined More...
 

Static Private Attributes

static instancesmap_t _instances
 the helperclass instances. More...
 
static QMutex _mutex
 mutex to lock the creation of an instance More...
 

Detailed Description

Data used commonly for one AdvancedDetector.

This class hold the data for one AdvancedDetector. There can be multiple instances of the AdvancedDetector which should use only one common data for e.g. offsetmaps. This data is contained in this class. To ensure that one AdvancedDetector will get only one instance the static function CommonData::instance will return only a new instance when the name does not exist yet.

User definable Parameters:

PixelDetectors/%name%/CorrectionMaps/{MapCreatorType}
The type of functor that will create the maps used for correcting the frames from individual frames. See Map-Creators List for a list of all possible values. Default is "none".

PixelDetectors/%name%/CorrectionMaps/{InputOffsetNoiseFilename}
The filename containing the saved noise and offset maps. Default is "darkcal_%detectorId%.lnk". Which is a link to the most recent darkcalibration file. If no file is found, the offset will be set to 0 and the noise will be set to 4000. When the user has chosen a "NoisyPixelThreshold" lower than 4000 this will result in a completly masked frame.

PixelDetectors/%name%/CorrectionMaps/{InputOffsetNoiseFiletype}
The filetype that the values are stored in. Default is "hll". Options are:

  • "hll": the filetype used by the semi conductor lab.
  • "cass": the filetype formerly used in CASS.

PixelDetectors/%name%/CorrectionMaps/{OutputOffsetNoiseFilename}
The filename where the offset and noise values will be written to. If the name is "darkcal", the name will be build by the detector id and the current date and time when it was written. Also when writing a link to the written file will be created like this: "darkcal_%detectorID%.lnk". When the name differs from "darkcal", the values will be written only to the given filename. See cass::pixeldetector::CommonData::saveOffsetNoiseMaps for more details. Default is "darkcal".

PixelDetectors/%name%/CorrectionMaps/{OutputOffsetNoiseFiletype}
The filetype that the noise and offset values are stored to. Default is "hll". Options are:

  • "hll": the filetype used by the semi conductor lab.
  • "cass": the filetype formerly used in CASS.

PixelDetectors/%name%/CorrectionMaps/{GainMapCreatorType}
The type of functor that will create the gain used for correcting the frames from individual frames. See Gainmap-Creators List for a list of all possible values. Default is "none".

PixelDetectors/%name%/CorrectionMaps/{InputGainFilename}
The filename containing the gain (/cte) values. Default is "gain_\%detectorId\%.lnk".

PixelDetectors/%name%/CorrectionMaps/{InputGainFiletype}
The filetype that the gain (/cte) values are stored in. Default is "hll". Options are:

  • "hll": the filetype used by the semi conductor lab.
  • "cass": the filetype used by CASS.

PixelDetectors/%name%/CorrectionMaps/{OutputGainFilename}
The filename where the gain (/cte) values will be written to. If the name is "gain", the name will be build by the detector id and the current date and time when it was written. Also when writing a link to the written file will be created like this: "gain_\%detectorID\%.lnk". When the name differs from "gain", the values will be written only to the given filename. See cass::pixeldetector::CommonData::saveGainMap for more details. Default is "gain".

PixelDetectors/%name%/CorrectionMaps/{OutputGainFiletype}
The filetype that the gain (/cte) values are stored in. Default is "cass". Options are:

  • "cass": the filetype used by CASS.

PixelDetectors/%name%/CorrectionMaps/{NoisyPixelThreshold | LowerNoisyPixelThreshold}
The boundaries to identify noisy pixels. Will be used when creating the correction map. When the noise of the pixel is outside these exclusive bounds the pixel will be masked. If NoisyPixelThreshold is -1, good values for the bound will be determined from the noise map. Default is 40000 | 0

PixelDetectors/%name%/CorrectionMaps/{AutoMultiplier}
When automatically determining the noise threshold, this is the multiplier by which the autovalue is determined. $ NoisyPixelThreshold = mean_noise + AutoMultiplier + stdv_noise $. $ LowerNoisyPixelThreshold = mean_noise - AutoMultiplier + stdv_noise $. Default is 4.

PixelDetectors/%name%/CorrectionMaps/{nColumns}

PixelDetectors/%name%/CorrectionMaps/{nRows}

Author
Lutz Foucar

Definition at line 136 of file common_data.h.

Member Typedef Documentation

typedef describing the instances of the helper

Definition at line 143 of file common_data.h.

typedef std::vector<char> cass::pixeldetector::CommonData::mask_t

a mask is a vector of bools

Definition at line 146 of file common_data.h.

typedef a shared pointer of this

Definition at line 140 of file common_data.h.

Constructor & Destructor Documentation

cass::pixeldetector::CommonData::CommonData ( )
inlineprivate

prevent people from constructing other than using instance().

Definition at line 313 of file common_data.h.

CommonData::CommonData ( const instancesmap_t::key_type &  detname)
private

private constructor.

unused

Parameters
detnamethe name of the detector

Definition at line 553 of file common_data.cpp.

cass::pixeldetector::CommonData::CommonData ( const CommonData )
inlineprivate

prevent copy-construction

Definition at line 324 of file common_data.h.

Member Function Documentation

void CommonData::controlCalibration ( const std::string &  command)
static

issue a command to the map creators of all instances

Parameters
commandthe command to issue

Definition at line 534 of file common_data.cpp.

References cass::Log::add(), and cass::Log::DEBUG1.

void CommonData::createCorMap ( )

create the correction map

will create the correction map from the mask, noise and cte/gain values with the help of the cass::pixeldetector::createCorrectionMap function

the correction value for a pixel is calculated using the following formular:

\[ corval = ctegain \times corval \times maskval \times \begin{cases} 0, & \text{if } noise < noisethreshold \\ 1, & \text{otherwise} \\ \end{cases} \]

Note
we do not need to lock this function since, it will be called by the map creators only. And their operators are still locked by this classes createMaps function that will envoke the functors.
Todo:
make this a friend and protected so only functions that we allow can call it.

reset the correction map before generating the correction values

Definition at line 807 of file common_data.cpp.

References _autoMultiplier, _autoNoiseThreshold, _noiseRange, cass::Log::add(), correctionMap, detectorId, gain_cteMap, hotpixels, cass::Log::INFO, mask, noise, noiseMap, and cass::toString().

Referenced by cass::pixeldetector::isSameSize(), and loadSettings().

void CommonData::generateMaps ( const Frame frame)

generate the maps from the frame data with help of the functors

There are several ways of creating the maps available. For a detailed list see this classes help.

Parameters
frameThe frame data to create the maps from

Definition at line 722 of file common_data.cpp.

References _gainCreator, _offsetnoiseMapcreator, _settingsLoaded, cass::pixeldetector::Frame::columns, correctionMap, cass::pixeldetector::Frame::data, detectorname, gain_cteMap, hotpixels, mask, noiseMap, offsetMap, cass::pixeldetector::Frame::rows, and cass::toString().

CommonData::shared_pointer CommonData::instance ( const instancesmap_t::key_type &  detector)
static

static function creating instance of this.

return the instance of the common data used with the advanced detector with the name detector. If the instance is not yet inside the _instances map the helper instance will be created one and put into the _instances map. So that later calls to this will return the same shared pointer.

Returns
instance of the common data
Parameters
detectorkey (name) of the detector to find it in the _instances map

Definition at line 522 of file common_data.cpp.

References cass::Log::add(), cass::Log::DEBUG0, and detector.

Referenced by cass::pixeldetector::commonmode::CalculatorBase::load(), cass::pixeldetector::AboveNoiseFinder::loadSettings(), cass::pixeldetector::HLLProcessor::loadSettings(), cass::pixeldetector::OnlineFixedCreator::loadSettings(), cass::pixeldetector::FixedMaps::loadSettings(), cass::pixeldetector::GainCalibration::loadSettings(), cass::pixeldetector::MovingMaps::loadSettings(), cass::pixeldetector::OnlineFixedCreatorCommonMode::loadSettings(), cass::pixeldetector::AdvancedDetector::loadSettings(), and cass::pixeldetector::HotPixelsFinder::loadSettings().

void CommonData::loadSettings ( CASSSettings s)

load the settings of this common object

See the description of this class for the list of possible variables that will be loaded via this function. Once all parameters are loaded it will load the Mask for this detector. See pixeldetector::createCASSMask for options creating the mask. Also the correction map for this dector is created once all information has been loaded. See createCorrectionMap for details.

Parameters
sthe object to load the settings for the common data from.

try do deduce the frame size from the detectorname, if it can't be deduced read it from the settings file and resize the maps accordingly.

load info for getting the right cor value from the noise maps

setup how the offset/noise maps will be created

setup how and where the offset/noise maps will be read from. If offset filename is a link, try to deduce the real filename

setup how and where the offset/noise maps will be written to

setup how the offset/noise maps will be created

setup how and from where the gain file will be read and read it

setup how and where the gain map will be written to

setup how and from where the hot pixels mask file will be read and read it

setup how and where the gain map will be written to

create the user mask and generate the correction map

Definition at line 561 of file common_data.cpp.

References _autoMultiplier, _autoNoiseThreshold, _gainCreator, _inputGainFilename, _inputHotPixFilename, _inputOffsetFilename, _noiseRange, _offsetnoiseMapcreator, _outputGainFilename, _outputHotPixFilename, _outputOffsetFilename, _saveGainTo, _saveHotPixTo, _saveNoiseOffsetTo, _settingsLoaded, cass::Log::add(), QSettings::beginGroup(), columns, correctionMap, cass::pixeldetector::createCASSMask(), createCorMap(), detectorId, detectorname, QSettings::endGroup(), cass::pixeldetector::DetectorName::fromSettings(), QString::fromStdString(), gain_cteMap, hotpixels, cass::pixeldetector::MapCreatorBase::instance(), mask, noiseMap, offsetMap, cass::pixeldetector::readCASSGainFile(), cass::pixeldetector::readCASSHotPixFile(), cass::pixeldetector::readCASSOffsetFile(), cass::pixeldetector::readHLLGainFile(), cass::pixeldetector::readHLLOffsetFile(), rows, cass::pixeldetector::saveCASSGainFile(), cass::pixeldetector::saveCASSHotPixFile(), cass::pixeldetector::saveCASSOffsetFile(), cass::pixeldetector::saveHLLOffsetFile(), cass::pixeldetector::Frame::shapeFromName(), cass::toString(), QSettings::value(), cass::Log::VERBOSEINFO, and cass::Log::WARNING.

CommonData& cass::pixeldetector::CommonData::operator= ( const CommonData )
inlineprivate

prevent assingment

Definition at line 327 of file common_data.h.

void CommonData::saveGainMap ( )

save gain map

save the gain calibration to file in the user chosen fileformat. See cass::pixeldetector::saveCASSGaiFile for details.

If the filename is "gain" for the gain calibration file, the detector id and the current time will be appended to the filename. A link to the created files will be generated. The name of the link will be called "gain_\%detectorID\%.lnk". In case the links exist, try to remove it first.

Definition at line 761 of file common_data.cpp.

References _outputGainFilename, _saveGainTo, QDateTime::currentDateTime(), detectorId, QFile::exists(), QString::fromStdString(), QFile::link(), QFile::remove(), and cass::toString().

void CommonData::saveHotPixMask ( )

save hot pixel mask

save the hot pixel mask to file in the user chosen fileformat.

If the filename is "hotpix" for the gain calibration file, the detector id and the current time will be appended to the filename. A link to the created files will be generated. The name of the link will be called "hotpix_\%detectorID\%.lnk". In case the link exist, try to remove it first.

Definition at line 784 of file common_data.cpp.

References _outputHotPixFilename, _saveHotPixTo, QDateTime::currentDateTime(), detectorId, QFile::exists(), QString::fromStdString(), QFile::link(), QFile::remove(), and cass::toString().

void CommonData::saveOffsetNoiseMaps ( )

save offset and noise maps

save the offset and noise calibratioin to file in the user chosen fileformat. See cass::pixeldetector::saveCASSOffsetFile or cass::pixeldetector::saveHLLOffsetFile for details.

If the filename is "darkcal" for the darkcalibration file, the detector id and the current time will be appended the filename. A link to the created files will be generated. The name of the link will be called "darkcal_\%detectorID\%.lnk". In case the link exists, try to remove it first.

Definition at line 738 of file common_data.cpp.

References _outputOffsetFilename, _saveNoiseOffsetTo, QDateTime::currentDateTime(), detectorId, QFile::exists(), QString::fromStdString(), QFile::link(), QFile::remove(), and cass::toString().

Member Data Documentation

Detector::pixel_t cass::pixeldetector::CommonData::_autoMultiplier
private

the multiplier about which the automatically determined threshold will be defined

Definition at line 383 of file common_data.h.

Referenced by createCorMap(), and loadSettings().

bool cass::pixeldetector::CommonData::_autoNoiseThreshold
private

flag whether the noise threshold should be automatically determined

Definition at line 380 of file common_data.h.

Referenced by createCorMap(), and loadSettings().

std::tr1::shared_ptr<MapCreatorBase> cass::pixeldetector::CommonData::_gainCreator
private

functor to create the Maps

Definition at line 356 of file common_data.h.

Referenced by generateMaps(), and loadSettings().

std::string cass::pixeldetector::CommonData::_inputGainFilename
private

the gain correction input filename

Definition at line 362 of file common_data.h.

Referenced by loadSettings().

std::string cass::pixeldetector::CommonData::_inputHotPixFilename
private

the hot pixel mask input filename

Definition at line 371 of file common_data.h.

Referenced by loadSettings().

std::string cass::pixeldetector::CommonData::_inputOffsetFilename
private

input filename of the offset and noise map

Definition at line 350 of file common_data.h.

Referenced by loadSettings().

CommonData::instancesmap_t CommonData::_instances
staticprivate

the helperclass instances.

the instances of this class put into map one instance for each available detector

Definition at line 334 of file common_data.h.

QMutex CommonData::_mutex
staticprivate

mutex to lock the creation of an instance

Definition at line 337 of file common_data.h.

std::pair<Detector::pixel_t,Detector::pixel_t> cass::pixeldetector::CommonData::_noiseRange
private

the range in adu for masking noisy pixels

Definition at line 377 of file common_data.h.

Referenced by createCorMap(), and loadSettings().

std::tr1::shared_ptr<MapCreatorBase> cass::pixeldetector::CommonData::_offsetnoiseMapcreator
private

functor to create the Maps

Definition at line 341 of file common_data.h.

Referenced by generateMaps(), and loadSettings().

std::string cass::pixeldetector::CommonData::_outputGainFilename
private

the gain correction output filename

Definition at line 365 of file common_data.h.

Referenced by loadSettings(), and saveGainMap().

std::string cass::pixeldetector::CommonData::_outputHotPixFilename
private

the hot pixel mask output filename

Definition at line 374 of file common_data.h.

Referenced by loadSettings(), and saveHotPixMask().

std::string cass::pixeldetector::CommonData::_outputOffsetFilename
private

output filename for the offset and noise maps

Definition at line 347 of file common_data.h.

Referenced by loadSettings(), and saveOffsetNoiseMaps().

std::tr1::function<void(const std::string&,CommonData&)> cass::pixeldetector::CommonData::_saveGainTo
private

function to write the gain map

Definition at line 359 of file common_data.h.

Referenced by loadSettings(), and saveGainMap().

std::tr1::function<void(const std::string&,CommonData&)> cass::pixeldetector::CommonData::_saveHotPixTo
private

function to write the hot pixel mask

Definition at line 368 of file common_data.h.

Referenced by loadSettings(), and saveHotPixMask().

std::tr1::function<void(const std::string&,CommonData&)> cass::pixeldetector::CommonData::_saveNoiseOffsetTo
private

function to write the offset maps

Definition at line 344 of file common_data.h.

Referenced by loadSettings(), and saveOffsetNoiseMaps().

bool cass::pixeldetector::CommonData::_settingsLoaded
private

switch to tell that load settins for this common data was already running

Definition at line 353 of file common_data.h.

Referenced by generateMaps(), and loadSettings().

size_t cass::pixeldetector::CommonData::columns
Detector::frame_t cass::pixeldetector::CommonData::correctionMap

the correction map

this map contains the correction values calculated from the mask, the gain and cte map. With this values the indivdual pixels will be mulitplied in the HLL like processing of the frame

Definition at line 303 of file common_data.h.

Referenced by createCorMap(), generateMaps(), cass::pixeldetector::isSameSize(), and loadSettings().

int32_t cass::pixeldetector::CommonData::detectorId

the id of the detector that contains the frames whos maps we have here

Definition at line 306 of file common_data.h.

Referenced by createCorMap(), loadSettings(), saveGainMap(), saveHotPixMask(), and saveOffsetNoiseMaps().

std::string cass::pixeldetector::CommonData::detectorname

the name of the detector whos maps are contained in this class instance

Definition at line 309 of file common_data.h.

Referenced by generateMaps(), cass::pixeldetector::isSameSize(), and loadSettings().

Detector::frame_t cass::pixeldetector::CommonData::gain_cteMap

the gain + cte map

this is a matrix of values containing correction factors for each individual pixel of the frame

Definition at line 295 of file common_data.h.

Referenced by createCorMap(), generateMaps(), cass::pixeldetector::isSameSize(), loadSettings(), cass::pixeldetector::readCASSGainFile(), cass::pixeldetector::readHLLGainFile(), and cass::pixeldetector::saveCASSGainFile().

mask_t cass::pixeldetector::CommonData::hotpixels

the hotpixel mask

a negative value masks pixels permanently. Positive values indicate how many frames this pixel was high. If its not high anymore the mask value will be reset to 0.

Definition at line 288 of file common_data.h.

Referenced by createCorMap(), generateMaps(), cass::pixeldetector::isSameSize(), loadSettings(), cass::pixeldetector::readCASSHotPixFile(), and cass::pixeldetector::saveCASSHotPixFile().

QReadWriteLock cass::pixeldetector::CommonData::lock
mask_t cass::pixeldetector::CommonData::mask
Detector::frame_t cass::pixeldetector::CommonData::noiseMap

the noise map

the noise map is the standart deviation of the mean value of indidual pixels for a given number of frames

Definition at line 273 of file common_data.h.

Referenced by createCorMap(), generateMaps(), cass::pixeldetector::isSameSize(), loadSettings(), cass::pixeldetector::readCASSOffsetFile(), cass::pixeldetector::readHLLOffsetFile(), cass::pixeldetector::saveCASSOffsetFile(), and cass::pixeldetector::saveHLLOffsetFile().

Detector::frame_t cass::pixeldetector::CommonData::offsetMap

the offset map

the offset map is the mean value of the individual pixels for given number of frames

Definition at line 266 of file common_data.h.

Referenced by generateMaps(), cass::pixeldetector::isSameSize(), loadSettings(), cass::pixeldetector::readCASSOffsetFile(), cass::pixeldetector::readHLLOffsetFile(), cass::pixeldetector::saveCASSOffsetFile(), and cass::pixeldetector::saveHLLOffsetFile().

size_t cass::pixeldetector::CommonData::rows

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