From 2da3d179ee45427dab6a2d9af239c7485259c373 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 25 Feb 2020 18:22:18 +0100 Subject: [PATCH] gotthard2 gain plot in gui --- slsDetectorGui/forms/form_tab_plot.ui | 23 ++++++- slsDetectorGui/include/qDrawPlot.h | 5 ++ .../slsDetectorPlotting/include/SlsQt1DPlot.h | 2 + slsDetectorGui/src/qDrawPlot.cpp | 68 +++++++++++++++++-- slsDetectorGui/src/qTabPlot.cpp | 9 +++ 5 files changed, 101 insertions(+), 6 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index 0be85085f..346610440 100755 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -822,7 +822,7 @@ Displays minimum, maximum and sum of values for each plot. - 3 + 5 @@ -1360,6 +1360,27 @@ Displays minimum, maximum and sum of values for each plot. + + + + false + + + + 0 + 0 + + + + <nobr> +Displays minimum, maximum and sum of values for each plot. +<nobr> + + + Gain Plot + + + diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index b6b8a2b5d..906617416 100755 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -98,6 +98,8 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { SlsQt1DPlot *plot1d{nullptr}; QVector hists1d; + SlsQt1DPlot *gainplot1d{nullptr}; + SlsQtH1D * gainhist1d{nullptr}; SlsQt2DPlot *plot2d{nullptr}; SlsQt2DPlot *gainplot2d{nullptr}; QFutureWatcher *acqResultWatcher; @@ -124,6 +126,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { int nHists{1}; double *datax1d{nullptr}; std::vector datay1d; + double *gainDatay1d{nullptr}; double *data2d{nullptr}; double *gainData{nullptr}; @@ -161,4 +164,6 @@ class qDrawPlot : public QWidget, private Ui::PlotObject { const static int npixelsx_jctb = 400; int npixelsy_jctb{0}; uint32_t pixelMask{0}; + uint32_t gainMask{0}; + int gainOffset{0}; }; diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h index 686e31ccf..99e86fea6 100755 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h +++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h @@ -132,6 +132,7 @@ class SlsQt1DPlot:public QwtPlot{ void DisableZoom(bool disable); void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);Update();}; void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);Update();}; + void SetYStep (int step) {ystep = step;}; void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);}; void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);}; double GetXMinimum(){return hist_list->Hist()->GetXMin();}; @@ -157,6 +158,7 @@ class SlsQt1DPlot:public QwtPlot{ QwtPlotMarker *hline; QwtPlotMarker *vline; bool disableZoom{false}; + int ystep{0}; void SetupZoom(); void UnknownStuff(); diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 89054db12..f6b4c7d49 100755 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -32,6 +32,8 @@ qDrawPlot::~qDrawPlot() { delete [] datax1d; for (auto &it : datay1d) delete [] it; + if (gainDatay1d) + delete [] gainDatay1d; if (data2d) delete [] data2d; if (gainData) @@ -39,6 +41,10 @@ qDrawPlot::~qDrawPlot() { if (plot1d) delete plot1d; + if (gainhist1d) + delete gainhist1d; + if (gainplot1d) + delete gainplot1d; if (plot2d) delete plot2d; if (gainplot2d) @@ -56,11 +62,17 @@ void qDrawPlot::SetupWidgetWindow() { case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::MOENCH: pixelMask = ((1 << 14) - 1); - FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask << std::dec; + gainMask = (3 << 14); + gainOffset = 14; + FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask + << ", Gain Mask:" << gainMask << ", Gain Offset:" << std::dec << gainOffset; break; case slsDetectorDefs::GOTTHARD2: pixelMask = ((1 << 12) - 1); - FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask << std::dec; + gainMask = (3 << 12); + gainOffset = 12; + FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask + << ", Gain Mask:" << gainMask << ", Gain Offset:" << std::dec << gainOffset; break; default: break; @@ -160,6 +172,29 @@ void qDrawPlot::SetupPlots() { h->Attach(plot1d); plot1d->hide(); + if (gainDatay1d) + delete[] gainDatay1d; + gainDatay1d = new double[nPixelsX]; + // default display data + for (unsigned int px = 0; px < nPixelsX; ++px) { + gainDatay1d[px] = 0; + } + // set gain hist + gainhist1d = new SlsQtH1D("", nPixelsX, datax1d, gainDatay1d); + gainhist1d->SetLineColor(0); + gainhist1d->setStyleLinesorDots(isLines); + gainhist1d->setSymbolMarkers(isMarkers); + // setup 1d gain plot + gainplot1d = new SlsQt1DPlot(boxPlot); + //gainplot1d->setFont(QFont("Sans Serif", 3, 20)); + gainplot1d->SetTitle(""); + gainplot1d->axisScaleDraw(QwtPlot::xBottom)->enableComponent(QwtScaleDraw::Labels, false); + gainplot1d->axisScaleDraw(QwtPlot::xBottom)->enableComponent(QwtScaleDraw::Ticks, false); + gainplot1d->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtScaleDraw::Labels, false); + gainplot1d->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtScaleDraw::Ticks, false); + gainhist1d->Attach(gainplot1d); + gainplot1d->hide(); + // setup 2d data if (data2d) delete [] data2d; @@ -208,6 +243,7 @@ void qDrawPlot::SetupPlots() { int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1; plotLayout->addWidget(plot1d, 0, 0, ratio, ratio); plotLayout->addWidget(plot2d, 0, 0, ratio, ratio); + plotLayout->addWidget(gainplot1d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop); plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop); } @@ -216,6 +252,10 @@ void qDrawPlot::resizeEvent(QResizeEvent *event) { gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO); } + if (gainplot1d->isVisible()) { + gainplot1d->setFixedWidth(plot1d->width() / qDefs::DATA_GAIN_PLOT_RATIO); + gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO); + } event->accept(); } @@ -547,6 +587,9 @@ void qDrawPlot::DetachHists() { for (QVector::iterator h = hists1d.begin(); h != hists1d.end(); ++h) { (*h)->Detach(plot1d); } + if (gainhist1d) { + gainhist1d->Detach(gainplot1d); + } } void qDrawPlot::StartAcquisition() { @@ -666,7 +709,8 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra unsigned int nPixels = nPixelsX * (is1d ? 1 : nPixelsY); double* rawData = new double[nPixels]; if (hasGainData) { - toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange, gainData); + toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange, + is1d ? gainDatay1d : gainData); isGainDataExtracted = true; } else { toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange); @@ -819,6 +863,20 @@ void qDrawPlot::Update1dPlot() { h->Attach(plot1d); } } + if (isGainDataExtracted) { + gainhist1d->SetData(nPixelsX, datax1d, gainDatay1d); + gainhist1d->SetLineColor(0); + gainhist1d->setStyleLinesorDots(isLines); + gainhist1d->setSymbolMarkers(isMarkers); + gainhist1d->Attach(gainplot1d); + if (!gainplot1d->isVisible()) { + gainplot1d->setFixedWidth(plot1d->width() / qDefs::DATA_GAIN_PLOT_RATIO); + gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO); + gainplot1d->show(); + } + } else if (gainplot1d->isVisible()) { + gainplot1d->hide(); + } if (xyRangeChanged) { Update1dXYRange(); xyRangeChanged = false; @@ -832,7 +890,7 @@ void qDrawPlot::Update2dPlot() { plot2d->SetYTitle(yTitle2d); plot2d->SetZTitle(zTitle2d); plot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, data2d); - if (isGainDataExtracted) { + if (isGainDataExtracted) { gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData); if (!gainplot2d->isVisible()) { gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO); @@ -925,7 +983,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data if (gaindest != NULL) { for (ichan = 0; ichan < size; ++ichan) { uint16_t temp = (*((u_int16_t *)source)); - gaindest[ichan] = ((temp & 0xC000) >> 14); + gaindest[ichan] = ((temp & gainMask) >> gainOffset); dest[ichan] = (temp & pixelMask); source += 2; } diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index e9322eafa..2bd73a927 100755 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -60,8 +60,11 @@ void qTabPlot::SetupWidgetWindow() { switch(det->getDetectorType().squash()) { case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::MYTHEN3: + is1d = true; + break; case slsDetectorDefs::GOTTHARD2: is1d = true; + chkGainPlot1D->setEnabled(true); break; case slsDetectorDefs::EIGER: chkGapPixels->setEnabled(true); @@ -128,6 +131,8 @@ void qTabPlot::Initialization() { //gainplot if (chkGainPlot->isEnabled()) connect(chkGainPlot, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool))); + if (chkGainPlot1D->isEnabled()) + connect(chkGainPlot1D, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool))); // gap pixels if (chkGapPixels->isEnabled()) connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); @@ -579,6 +584,9 @@ void qTabPlot::Refresh() { case slsDetectorDefs::MOENCH: chkGainPlot->setEnabled(true); break; + case slsDetectorDefs::GOTTHARD2: + chkGainPlot1D->setEnabled(true); + break; default: break; } @@ -586,6 +594,7 @@ void qTabPlot::Refresh() { boxPlotType->setEnabled(false); boxFrequency->setEnabled(false); chkGainPlot->setEnabled(false); + chkGainPlot1D->setEnabled(false); chkGapPixels->setEnabled(false); }