15 #include <QtCore/QTime>
16 #include <QtCore/QtGlobal>
30 using tr1::placeholders::_1;
35 Log::add(
Log::INFO,
"OnlineFixedCreator::controlCalibration(): Start collecting '" +
36 toString(_nbrFrames) +
"' frames for calibration");
44 if (_framecounter < _nbrFrames)
48 specialstorage_t::iterator storagePixel(_specialstorage.begin());
49 specialstorage_t::const_iterator lastStoragePixel(_specialstorage.end());
50 Detector::frame_t::const_iterator
pixel(frame.
data.begin()) ;
51 while(storagePixel != lastStoragePixel)
52 (*storagePixel++).push_back(*
pixel++);
60 "' frames. Starting to generate the offset and noise map");
61 specialstorage_t::iterator storagePixels(_specialstorage.begin());
62 specialstorage_t::const_iterator lastStoragePixels(_specialstorage.end());
63 Detector::frame_t::iterator
offset(_commondata->offsetMap.begin());
64 Detector::frame_t::iterator
noise(_commondata->noiseMap.begin());
65 for (;storagePixels != lastStoragePixels; ++
offset, ++
noise, ++storagePixels)
68 specialstorage_t::value_type::iterator
pixel(storagePixels->begin());
69 specialstorage_t::value_type::const_iterator lastPixel(storagePixels->end());
70 size_t accumulatedValues(0);
77 tmp_offset += ((*
pixel - tmp_offset) / accumulatedValues);
78 tmp_noise += ((*
pixel - old_offset)*(*
pixel - tmp_offset));
81 *noise = sqrt(tmp_noise/(accumulatedValues-1));
82 if(qFuzzyCompare(*noise,0.f))
84 cout << tmp_noise<<
" "<< tmp_offset <<
" "<<accumulatedValues<<endl;
86 toString(distance(_specialstorage.begin(), storagePixels))
87 +
"' is 0 after the first iteration.");
90 pixel = storagePixels->begin();
91 accumulatedValues = 0;
98 if ((pixel_wo_offset < maxNoise))
102 tmp_offset += ((*
pixel - tmp_offset) / accumulatedValues);
103 tmp_noise += ((*
pixel - old_offset)*(*
pixel - tmp_offset));
107 *noise = sqrt(tmp_noise/(accumulatedValues-1));
108 if(accumulatedValues == 0)
110 toString(distance(_specialstorage.begin(), storagePixels))
111 +
"' did not find any pixel below the maximum Noise of '" +
113 if(qFuzzyCompare(*noise,0.f))
115 toString(distance(_specialstorage.begin(), storagePixels))
122 _commondata->saveOffsetNoiseMaps();
123 _commondata->createCorMap();
125 _specialstorage.clear();
127 Log::add(
Log::INFO,
"OnlineFixedCreator::buildAndCalc(): Done creating maps: it took " +
137 _nbrFrames = s.
value(
"NbrFrames",200).toUInt();
139 _writeMaps = s.
value(
"WriteMaps",
true).toBool();
140 if(s.
value(
"StartInstantly",
false).toBool())
143 toString(_nbrFrames) +
"' frames for calibration");
148 _multiplier = s.
value(
"Multiplier",4).toFloat();
156 Log::add(
Log::INFO,
"OnlineFixedCreatorCommonMode::controlCalibration(): Start collecting '" +
157 toString(_nbrFrames) +
"' frames for calibration");
165 if (_framecounter < _nbrFrames)
168 _storage.push_back(frame.
data);
176 "' frames. Starting to generate the offset and noise map");
177 Detector::frame_t::iterator
offset(_commondata->offsetMap.begin());
178 Detector::frame_t::const_iterator offsetEnd(_commondata->offsetMap.end());
179 Detector::frame_t::iterator
noise(_commondata->noiseMap.begin());
183 storage_t::iterator storagePixels(_storage.begin());
184 storage_t::const_iterator lastStoragePixels(_storage.end());
185 size_t accumulatedValues(0);
188 for (;storagePixels != lastStoragePixels; ++storagePixels)
193 tmp_offset += ((pixel - tmp_offset) / accumulatedValues);
194 tmp_noise += ((pixel - old_offset)*(pixel - tmp_offset));
197 *noise = sqrt(tmp_noise/(accumulatedValues-1));
198 if(qFuzzyCompare(*noise,0.f))
200 toString(idx) +
"' is 0 after the first iteration.");
202 storagePixels = _storage.begin();
203 accumulatedValues = 0;
207 for (;storagePixels != lastStoragePixels; ++storagePixels)
211 if ((pixel_wo_offset < maxNoise))
215 tmp_offset += ((pixel - tmp_offset) / accumulatedValues);
216 tmp_noise += ((pixel - old_offset)*(pixel - tmp_offset));
220 *noise = sqrt(tmp_noise/(accumulatedValues-1));
221 if(accumulatedValues == 0)
224 +
"' did not find any pixel below the maximum Noise of '" +
226 if(qFuzzyCompare(*noise,0.f))
231 _commondata->createCorMap();
234 offset = _commondata->offsetMap.begin();
235 noise = _commondata->noiseMap.begin();
241 storage_t::iterator storagePixels(_storage.begin());
242 storage_t::const_iterator lastStoragePixels(_storage.end());
243 size_t accumulatedValues(0);
247 for (;storagePixels != lastStoragePixels; ++storagePixels)
249 if ((idx %
width) == 0)
250 commonmodeLevel = calcCommonMode(storagePixels->begin()+idx,idx);
254 if ((corectedpixel < maxNoise))
258 tmp_offset += ((pixel_wo_commonmode - tmp_offset) / accumulatedValues);
259 tmp_noise += ((pixel_wo_commonmode - old_offset)*(pixel_wo_commonmode - tmp_offset));
268 _commondata->saveOffsetNoiseMaps();
269 _commondata->createCorMap();
273 Log::add(
Log::INFO,
"OnlineFixedCreatorCommonMode::buildAndCalc(): Done creating maps: it took " +
283 _nbrFrames = s.
value(
"NbrFrames",200).toUInt();
285 _writeMaps = s.
value(
"WriteMaps",
true).toBool();
286 if(s.
value(
"StartInstantly",
false).toBool())
288 Log::add(
Log::INFO,
"OnlineFixedCreatorTest::loadSettings(): Start collecting '" +
289 toString(_nbrFrames) +
"' frames for calibration");
294 _multiplier = s.
value(
"Multiplier",4).toFloat();
295 string commonmodetype (s.
value(
"CommonModeCalculationType",
"simpleMean").toString().toStdString());
297 _commonModeCalculator->loadSettings(s);
void doNothing(const Frame &)
a function that just returns and does nothing
contains base class for all common mode calculators.
void controlCalibration(const std::string &unused)
start accumulating the maps
void loadSettings(CASSSettings &s)
load the settings of this creator
void loadSettings(CASSSettings &s)
load the settings of this creator
void buildAndCalc(const Frame &frame)
build up storage and then calculate the maps
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 accumulating the maps
size_t width() const
retrieve the number of pixels (or the width of calculation
uint16_t rows
how many rows
uint16_t columns
how many columns
static std::string fromSettings(const CASSSettings &s)
retrieve it from the casssettings
std::string toString(const Type &t)
convert any type to a string
value(const QString &key, const QVariant &defaultValue=QVariant()
static shared_pointer instance(const std::string &type)
create an instance of the requested functor
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 correction map creators that work fast easy for online purposes.
contains a logger for cass
int16_t pixel
define a pixel
void doNothing(const Frame &)
a function that just returns and does nothing
base class for all common mode calculators
void buildAndCalc(const Frame &frame)
build up storage and then calculate the maps
beginGroup(const QString &prefix)
set up how to create the noise