rate correction fixed for gui, removed auto made it defalt

This commit is contained in:
Dhanya Maliakal 2016-08-11 13:59:36 +02:00
parent cf74f9b138
commit 4c2d28943f
3 changed files with 253 additions and 272 deletions

View File

@ -87,25 +87,6 @@ Directory where one saves the data.
<property name="verticalSpacing">
<number>4</number>
</property>
<item row="2" column="3">
<widget class="QPushButton" name="btnOutputBrowse">
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
<property name="text">
<string>Browse</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/browse.png</normaloff>:/icons/images/browse.png</iconset>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="dispReadOutputDir">
<property name="focusPolicy">
@ -130,21 +111,6 @@ Directory where one saves the data.
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="dispOutputDir">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblDetector">
<property name="sizePolicy">
@ -203,6 +169,21 @@ Directory where one saves the data.
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="dispOutputDir">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="comboDetector">
<property name="sizePolicy">
@ -235,6 +216,25 @@ Directory where one saves the data.
</property>
</spacer>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="btnOutputBrowse">
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
<property name="text">
<string>Browse</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/browse.png</normaloff>:/icons/images/browse.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@ -320,24 +320,40 @@ Compression using Root. Available only for Gotthard in Expert Mode.
<x>255</x>
<y>21</y>
<width>476</width>
<height>66</height>
<height>76</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="1" column="2">
<widget class="QRadioButton" name="radioAuto">
<item row="1" column="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="chkRate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Auto</string>
<string>Rate:</string>
</property>
</widget>
</item>
<item row="0" column="6">
<item row="0" column="8">
<widget class="QPushButton" name="btnFlatField">
<property name="enabled">
<bool>false</bool>
@ -361,62 +377,7 @@ Compression using Root. Available only for Gotthard in Expert Mode.
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="chkFlatField">
<property name="toolTip">
<string>Flat field corrections.
#flatfield# filename</string>
</property>
<property name="text">
<string>Flat Field File:</string>
</property>
</widget>
</item>
<item row="1" column="4" colspan="3">
<widget class="QDoubleSpinBox" name="spinDeadTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> ns</string>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="chkRate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Rate:</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="4">
<item row="0" column="2" colspan="6">
<widget class="QLineEdit" name="dispFlatField">
<property name="enabled">
<bool>false</bool>
@ -430,13 +391,14 @@ Compression using Root. Available only for Gotthard in Expert Mode.
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QRadioButton" name="radioDeadTime">
<property name="enabled">
<bool>false</bool>
<item row="0" column="0">
<widget class="QCheckBox" name="chkFlatField">
<property name="toolTip">
<string>Flat field corrections.
#flatfield# filename</string>
</property>
<property name="text">
<string>Custom dead time:</string>
<string>Flat Field File:</string>
</property>
</widget>
</item>
@ -456,6 +418,120 @@ Compression using Root. Available only for Gotthard in Expert Mode.
</property>
</spacer>
</item>
<item row="1" column="5">
<widget class="QLabel" name="lblDeadTime">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>2</red>
<green>2</green>
<blue>2</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>119</red>
<green>119</green>
<blue>119</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
<property name="text">
<string>Dead Time:</string>
</property>
</widget>
</item>
<item row="1" column="6" colspan="3">
<widget class="QSpinBox" name="spinDeadTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string>ns</string>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>200000000</number>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QPushButton" name="btnDefaultRate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
<property name="text">
<string>Default</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/calculate.png</normaloff>:/icons/images/calculate.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="Line" name="line">
@ -623,53 +699,10 @@ Compression using Root. Available only for Gotthard in Expert Mode.
</layout>
</widget>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>384</x>
<y>60</y>
<width>348</width>
<height>27</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDoubleSpinBox" name="spinDeadTimeonly">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> ns</string>
</property>
<property name="decimals">
<number>9</number>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<zorder>boxOutDir</zorder>
<zorder>boxCorrection_2</zorder>
<zorder>btnOutputBrowse</zorder>
</widget>
<tabstops>
<tabstop>dispReadOutputDir</tabstop>
@ -677,9 +710,6 @@ Compression using Root. Available only for Gotthard in Expert Mode.
<tabstop>dispFlatField</tabstop>
<tabstop>btnFlatField</tabstop>
<tabstop>chkRate</tabstop>
<tabstop>radioAuto</tabstop>
<tabstop>radioDeadTime</tabstop>
<tabstop>spinDeadTime</tabstop>
</tabstops>
<resources>
<include location="../include/icons.qrc"/>

View File

@ -110,7 +110,10 @@ void UpdateFlatFieldFromServer();
void BrowseFlatFieldPath();
/**rate correction*/
void SetRateCorrection();
void SetRateCorrection(int deadtime=0);
/** default rate correction */
void SetDefaultRateCorrection();
/** update rate correction from server */
void UpdateRateCorrectionFromServer();

View File

@ -46,7 +46,6 @@ void qTabDataOutput::SetupWidgetWindow(){
// Detector Type
detType=myDet->getDetectorsType();
widgetEiger->setVisible(false);
spinDeadTimeonly->setVisible(false);
//rate correction - not for charge integrating detectors
if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER))
@ -56,12 +55,9 @@ void qTabDataOutput::SetupWidgetWindow(){
chkAngular->setEnabled(true);
if(detType == slsDetectorDefs::EIGER){
chkRate->setEnabled(true);
chkTenGiga->setEnabled(true);
widgetEiger->setVisible(true);
spinDeadTimeonly->setVisible(true);
radioAuto->setVisible(false);
radioDeadTime->setVisible(false);
spinDeadTime->setVisible(false);
}
/** error message **/
@ -154,14 +150,10 @@ void qTabDataOutput::Initialization(){
connect(chkFlatField, SIGNAL(toggled(bool)), this, SLOT(SetFlatField()));
connect(btnFlatField, SIGNAL(clicked()), this, SLOT(BrowseFlatFieldPath()));
//rate correction
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
if(detType == slsDetectorDefs::EIGER)
connect(spinDeadTimeonly, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
else{
connect(radioAuto, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
connect(radioDeadTime, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
}
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
connect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection()));
connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
//angular correction
connect(chkAngular, SIGNAL(toggled(bool)), this, SLOT(SetAngularCorrection()));
//discard bad channels
@ -333,81 +325,69 @@ void qTabDataOutput::BrowseFlatFieldPath(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDataOutput::SetRateCorrection(){
if(detType == slsDetectorDefs::EIGER)
disconnect(spinDeadTimeonly, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
else{
disconnect(radioAuto, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
disconnect(radioDeadTime, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
disconnect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
}
void qTabDataOutput::SetRateCorrection(int deadtime){
disconnect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection()));
disconnect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
#ifdef VERBOSE
cout << "Entering Set Rate Correction function" << endl;
#endif
if(chkRate->isChecked()){
if(detType == slsDetectorDefs::EIGER){
spinDeadTimeonly->setEnabled(true);
myDet->setRateCorrection((double)spinDeadTimeonly->value());
if(!btnDefaultRate->isEnabled()){
btnDefaultRate->setEnabled(true);
lblDeadTime->setEnabled(true);
spinDeadTime->setEnabled(true);
}
else{
radioAuto->setEnabled(true);
radioDeadTime->setEnabled(true);
//set auto as default if nothing selected
if(!radioAuto->isChecked()&&!radioDeadTime->isChecked())
radioAuto->setChecked(true);
//auto mode
if(radioAuto->isChecked()){
spinDeadTime->setEnabled(false);
myDet->setRateCorrection(-1);
if(deadtime!=-1){
deadtime = (double)spinDeadTime->value();
#ifdef VERBOSE
cout << "Setting rate corrections with default dead time" << endl;
cout << "Setting rate corrections with custom dead time: " << deadtime << endl;
#endif
}
//custom dead time
else{
spinDeadTime->setEnabled(true);
myDet->setRateCorrection((double)spinDeadTime->value());
}else{;
#ifdef VERBOSE
cout << "Setting rate corrections with dead time "<< spinDeadTime->value() << endl;
cout << "Setting rate corrections with default dead time" << endl;
#endif
}
}
}//unsetting
myDet->setRateCorrection(deadtime);
}//unsetting rate correction
else{
if(detType == slsDetectorDefs::EIGER)
spinDeadTimeonly->setEnabled(false);
else{
radioAuto->setEnabled(false);
radioDeadTime->setEnabled(false);
spinDeadTime->setEnabled(false);
}
//Unsetting rate correction
btnDefaultRate->setEnabled(false);
lblDeadTime->setEnabled(false);
spinDeadTime->setEnabled(false);
myDet->setRateCorrection(0);
#ifdef VERBOSE
cout << "Unsetting rate correction" << endl;
#endif
}
qDefs::checkErrorMessage(myDet,"qTabDataOutput::SetRateCorrection");
//update just the value
double rate = (double)myDet->getRateCorrectionTau();
if(spinDeadTime->isEnabled())
spinDeadTime->setValue((double)rate);
else if(spinDeadTimeonly->isEnabled())
spinDeadTimeonly->setValue((double)rate);
if(detType == slsDetectorDefs::EIGER)
connect(spinDeadTimeonly, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
else{
connect(radioAuto, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
connect(radioDeadTime, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
spinDeadTime->setValue((double)rate);
if(rate == -1){
qDefs::Message(qDefs::WARNING,"Dead time is inconsistent for all detectors. Returned Value: -1.","qTabDataOutput::UpdateRateCorrectionFromServer");
QString errorTip = QString("<nobr>Rate Corrections.</nobr><br>"
"<nobr> #ratecorr# tau in seconds</nobr><br><br>")+
QString("<nobr><font color=\"red\">"
"Dead time is inconsistent for all detectors.</font></nobr>");
chkRate->setToolTip(errorTip);
spinDeadTime->setToolTip(errorTip);
chkRate->setPalette(red);
chkRate->setText("Rate:*");
}else{
QString normalTip = QString("<nobr>Rate Corrections.</nobr><br>"
"<nobr> #ratecorr# tau in seconds</nobr><br><br>");
chkRate->setToolTip(normalTip);
spinDeadTime->setToolTip(normalTip);
chkRate->setPalette(chkDiscardBad->palette());
chkRate->setText("Rate:");
}
connect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection()));
connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
}
@ -415,94 +395,62 @@ void qTabDataOutput::SetRateCorrection(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDataOutput::UpdateRateCorrectionFromServer(){
disconnect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
void qTabDataOutput::SetDefaultRateCorrection(){
SetRateCorrection(-1);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDataOutput::UpdateRateCorrectionFromServer(){
disconnect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
disconnect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection()));
disconnect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
if(detType == slsDetectorDefs::EIGER)
disconnect(spinDeadTimeonly, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
else{
disconnect(radioAuto, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
disconnect(radioDeadTime, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
disconnect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
}
double rate;
rate = (double)myDet->getRateCorrectionTau();
qDefs::checkErrorMessage(myDet,"qTabDataOutput::UpdateRateCorrectionFromServer");
#ifdef VERBOSE
cout << "Getting rate correction from server:" << rate << " : ";
cout << "Getting rate correction from server: " << rate << endl;
#endif
if(rate==0){
#ifdef VERBOSE
cout << "None" << endl;
#endif
chkRate->setChecked(false);
if(detType == slsDetectorDefs::EIGER)
spinDeadTimeonly->setEnabled(false);
else{
radioAuto->setEnabled(false);
radioDeadTime->setEnabled(false);
spinDeadTime->setEnabled(false);
}
btnDefaultRate->setEnabled(false);
lblDeadTime->setEnabled(false);
spinDeadTime->setEnabled(false);
}
else{
chkRate->setChecked(true);
if(detType == slsDetectorDefs::EIGER){
spinDeadTimeonly->setEnabled(true);
spinDeadTimeonly->setValue((double)rate);
}
//mythen
else{
radioAuto->setEnabled(true);
radioDeadTime->setEnabled(true);
chkRate->setChecked(true);
if(rate == -1){
#ifdef VERBOSE
cout << "Auto" << endl;
#endif
spinDeadTime->setEnabled(false);
radioAuto->setChecked(true);
}else{
#ifdef VERBOSE
cout << "Custom" << endl;
#endif
radioDeadTime->setChecked(true);
spinDeadTime->setEnabled(true);
spinDeadTime->setValue((double)rate);
}
}
btnDefaultRate->setEnabled(true);
lblDeadTime->setEnabled(true);
spinDeadTime->setEnabled(true);
spinDeadTime->setValue((double)rate);
}
if(detType == slsDetectorDefs::EIGER && rate == -1){
if(rate == -1){
qDefs::Message(qDefs::WARNING,"Dead time is inconsistent for all detectors. Returned Value: -1.","qTabDataOutput::UpdateRateCorrectionFromServer");
QString errorTip = QString("<nobr>Rate Corrections.</nobr><br>"
"<nobr> #ratecorr# tau in seconds</nobr><br><br>")+
QString("<nobr><font color=\"red\">"
"Dead time is inconsistent for all detectors.</font></nobr>");
chkRate->setToolTip(errorTip);
spinDeadTimeonly->setToolTip(errorTip);
spinDeadTime->setToolTip(errorTip);
chkRate->setPalette(red);
chkRate->setText("Rate:*");
}else{
QString normalTip = QString("<nobr>Rate Corrections.</nobr><br>"
"<nobr> #ratecorr# tau in seconds</nobr><br><br>");
chkRate->setToolTip(normalTip);
spinDeadTimeonly->setToolTip(normalTip);
spinDeadTime->setToolTip(normalTip);
chkRate->setPalette(chkDiscardBad->palette());
chkRate->setText("Rate:");
}
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
if(detType == slsDetectorDefs::EIGER)
disconnect(spinDeadTimeonly, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
else{
connect(radioAuto, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
connect(radioDeadTime, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
}
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection()));
connect(btnDefaultRate, SIGNAL(clicked()), this, SLOT(SetDefaultRateCorrection()));
connect(spinDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
}