Commit cb6eb173 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

Jungfrau: GainPedCorr uses now PSI approach:

* corr = (adc_val - ped) / gain
* Allow updating calibration gains
* AveImgProc uses raw adc_val data,
  used as source in pedestal map update
parent df7bd0a0
Pipeline #48094 failed with stages
in 11 minutes and 48 seconds
......@@ -67,9 +67,9 @@ class Jungfrau : public Model
struct Map16Data {
static constexpr MapType Type = Map16;
static constexpr double DefaultCoeffs[3][2] = {
{ 0.011555, 965.5},
{-0.302124, 5519.0},
{-4.254403, 64882.8},
{ 8.654262e+1, -83556.9},
{-3.309899e+0, 18267.3},
{-2.350506e-1, 15250.7},
};
static constexpr Data::TYPE DataType = Data::UINT16;
using Pixel = unsigned short;
......@@ -78,9 +78,9 @@ class Jungfrau : public Model
struct Map32Data {
static constexpr MapType Type = Map32;
static constexpr double DefaultCoeffs[3][2] = {
{ 0.999952, 0.4}, // effectively {1, 0}
{ -26.144935, 394047.3}, // G0 x26
{-368.163215, 5531211.9}, // G1 x14
{ 1.000048e+0, -0.4}, // effectively {1, 0}
{-3.824832e-2, 15071.6}, // G0 x26
{-2.716186e-3, 15023.8}, // G1 x14
};
static constexpr Data::TYPE DataType = Data::UINT32;
using Pixel = unsigned int;
......@@ -424,7 +424,7 @@ class Jungfrau : public Model
virtual void updateImageSize(Size size, bool raw);
virtual void clear();
virtual bool consumesRawData() { return false; }
virtual bool consumesRawData() { return true; }
virtual void processFrame(Data& data);
void readAveMap(Data& ave_map, FrameType& nb_frames,
......
......@@ -128,7 +128,7 @@ void Jungfrau::GainPed::Impl<M>::processFrame(Data& data, Data& proc)
*dst = std::numeric_limits<P>::max() - 0x10;
continue;
}
*dst = coeffs[gain][0][i] * adc + coeffs[gain][1][i];
*dst = (adc - coeffs[gain][1][i]) / coeffs[gain][0][i];
DEB_TRACE() << DEB_VAR1(*dst);
}
}
......@@ -499,7 +499,7 @@ void Jungfrau::AveImgProc::processFrameFunct(Data& data)
unsigned int *acc = (unsigned int *) m_acc.data();
double *ave = (double *) m.ave_map.data();
for (int i = 0; i < m_pixels; ++i, ++src, ++acc, ++ave) {
*acc += *src;
*acc += *src & 0x3fff;
*ave = *acc / m_nb_frames;
}
m.ave_map.frameNumber = frame;
......@@ -510,13 +510,8 @@ void Jungfrau::AveImgProc::processFrameFunct(Data& data)
void Jungfrau::AveImgProc::processFrame(Data& data)
{
DEB_MEMBER_FUNCT();
GainPed& gain_ped = m_jungfrau->m_gain_ped_img_proc->m_gain_ped;
GainPed::MapType map_type;
gain_ped.getMapType(map_type);
if (map_type == GainPed::Map16)
processFrameFunct<GainPed::Map16Data>(data);
else
processFrameFunct<GainPed::Map32Data>(data);
Data raw = m_jungfrau->getRawData(data);
processFrameFunct<GainPed::Map16Data>(raw);
}
void Jungfrau::AveImgProc::readAveMap(Data& ave_map, FrameType& nb_frames,
......@@ -1050,13 +1045,8 @@ void Jungfrau::doSetImgProcConfig(std::string config, bool force)
img_proc_list.push_back(m_gain_adc_map_img_proc);
}
if (checkConfigAndDelete("ave")) {
if (do_gain_ped_corr) {
DEB_TRACE() << "Adding ave";
img_proc_list.push_back(m_ave_img_proc);
} else {
DEB_TRACE() << "Ignoring ave";
m_ave_img_proc->clear();
}
DEB_TRACE() << "Adding ave";
img_proc_list.push_back(m_ave_img_proc);
}
if (!config_list.empty())
THROW_HW_ERROR(InvalidValue) << "Invalid " << DEB_VAR1(config);
......
......@@ -105,10 +105,21 @@ void Receiver::setCPUAffinity(const RecvCPUAffinity& recv_affinity)
CPUAffinity aff = recv_affinity.all();
int max_node;
vector<unsigned long> mlist;
typedef vector<unsigned long> NumaNodeList;
NumaNodeList mlist;
aff.getNUMANodeMask(mlist, max_node);
if (mlist.size() != 1)
THROW_HW_ERROR(Error) << DEB_VAR1(mlist.size());
if (mlist.size() > 1) {
bool ok = true;
NumaNodeList::iterator it, end = mlist.end();
for (it = mlist.begin() + 1; ok && (it != end); ++it)
ok = (*it == 0);
if (!ok) {
PrettyList<NumaNodeList> pretty_list(mlist);
THROW_HW_ERROR(Error) << "Recv " << m_idx << " "
<< "uses more than one node:"
<< pretty_list;
}
}
unsigned long& fifo_node_mask = mlist[0];
int c = bitset<64>(fifo_node_mask).count();
if (c != 1)
......
......@@ -435,15 +435,15 @@ class SlsDetectorJungfrauClass(SlsDetectorClass):
'gain_0_calib_map':
[[PyTango.DevDouble,
PyTango.IMAGE,
PyTango.READ, 8192, 8192]],
PyTango.READ_WRITE, 8192, 8192]],
'gain_1_calib_map':
[[PyTango.DevDouble,
PyTango.IMAGE,
PyTango.READ, 8192, 8192]],
PyTango.READ_WRITE, 8192, 8192]],
'gain_2_calib_map':
[[PyTango.DevDouble,
PyTango.IMAGE,
PyTango.READ, 8192, 8192]],
PyTango.READ_WRITE, 8192, 8192]],
'ped_0_calib_map':
[[PyTango.DevDouble,
PyTango.IMAGE,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment