25 using tr1::placeholders::_1;
26 using tr1::placeholders::_2;
34 _statistics.resize(frame.
data.size(),make_pair(0,0.));
35 vector<statistics_t>::iterator stat(_statistics.begin());
36 vector<statistics_t>::const_iterator statEnd(_statistics.end());
38 Detector::frame_t::const_iterator
pixel(frame.
data.begin());
39 Detector::frame_t::const_iterator
offset(_commondata->offsetMap.begin());
45 const size_t length(commonMode.width());
46 const size_t parts(frame.
data.size() / length);
48 for (
size_t part(0); part < parts; ++part)
51 for (
size_t i(0); i < length; ++i, ++stat, ++
pixel, ++idx)
55 if (pixval < _range.first || _range.second < pixval)
58 double &ave((*stat).second);
59 const double N(static_cast<double>(++(*stat).first));
60 ave = ave + (pixval - ave)/N;
67 vector<statistics_t> statcpy(_statistics);
68 const size_t medianPos(0.5*statcpy.size());
69 nth_element(statcpy.begin(),statcpy.begin() + medianPos, statcpy.end(),
70 std::tr1::bind(less<statistics_t::first_type>(),
71 std::tr1::bind<statistics_t::first_type>(&statistics_t::first,_1),
72 std::tr1::bind<statistics_t::first_type>(&statistics_t::first,_2)));
73 if (statcpy[medianPos].first < _minMedianCounts || _counter == _nFrames)
81 stat = _statistics.begin();
82 while (stat != statEnd)
85 if (s.first < _minPhotonCount)
88 ave = ave + (s.second - ave)/count;
96 Detector::frame_t::iterator gain(_commondata->gain_cteMap.begin());
97 stat = _statistics.begin();
98 while (stat != statEnd)
101 *gain++ = (s.first < _minPhotonCount) ? _constGain : ave/s.second;
106 _commondata->saveGainMap();
107 fill(_statistics.begin(),_statistics.end(),make_pair(0,0.));
116 _minPhotonCount = s.
value(
"MinimumPhotonCount",50).toInt();
117 _minMedianCounts = s.
value(
"MinimumMedianCounts",200).toInt();
118 _range = make_pair(s.
value(
"MinADURange",0).toUInt(),
119 s.
value(
"MaxADURange",1000).toUInt());
120 _writeFile = s.
value(
"SaveCalibration",
true).toBool();
122 _nFrames = s.
value(
"NbrFrames",-1).toInt();
123 if (s.
value(
"StartInstantly",
false).toBool())
127 string commonmodetype (s.
value(
"CommonModeCalculationType",
"none").toString().toStdString());
129 _commonModeCalculator->loadSettings(s);
136 Log::add(
Log::INFO,
"GainCalibration::controlCalibration(): start collecting statistics for gain calibration'");
std::pair< int, double > statistics_t
define a conatiner for a statistics of a pixel
contains a gain calibration functor
void loadSettings(CASSSettings &s)
load the settings of this creator
static void add(Level level, const std::string &line)
add a string to the log
float pixel_t
define a pixel of the pixel detector
void controlCalibration(const std::string &unused)
start the gain calibration
static std::string fromSettings(const CASSSettings &s)
retrieve it from the casssettings
void generateCalibration(const Frame &frame)
generate gain calibration data
value(const QString &key, const QVariant &defaultValue=QVariant()
static shared_pointer instance(const std::string &type)
create an instance of the requested functor
void doNothing(const Frame &)
a function that just returns and does nothing
A Frame of an advance Pixel Detector.
Detector::frame_t data
the frame data
contains the common data for one advanced pixeldetector
file contains specialized class that do the settings for cass
static shared_pointer instance(const instancesmap_t::key_type &detector)
static function creating instance of this.
contains a logger for cass
int16_t pixel
define a pixel
base class for all common mode calculators
beginGroup(const QString &prefix)