108 lines
5.3 KiB
C++
108 lines
5.3 KiB
C++
#include "XeConUncer.h"
|
|
#include <QtMath>
|
|
bool CXeConUncer::CalcXeConUncer(XeConUncerI &_input, XeConUncerO &_output, global::XeType& _output_Xetype)
|
|
{
|
|
const int cu_grp_num = 2;//浓度和不确定度组数据 2数为一组
|
|
const int pos_con=0; //浓度偏移
|
|
const int pos_uncer=1; //不确定度偏移
|
|
const int cts_grp_num = 3; ////气体,样品扣除探测器本地谱数据计数 [n..0]计数 [n..1]偏差 [n..2]关键水平
|
|
const int pos_cts = 0;
|
|
// const int pos_vari = 1;
|
|
const int pos_level = 2;
|
|
const int max_g_s = 6*cts_grp_num+pos_level; //气体,样品扣除探测器本地谱数据应包含的数据大小
|
|
bool bError = false;
|
|
if(8*cu_grp_num+pos_uncer>=_input.ROI_con_uncer.size()||max_g_s>=_input.s_netXe.size()||max_g_s>=_input.g_netXe.size())
|
|
{
|
|
return false;
|
|
}
|
|
_output.Xe135_con = _input.ROI_con_uncer[2*cu_grp_num+pos_con];
|
|
_output.Xe135_uncer=_input.ROI_con_uncer[2*cu_grp_num+pos_uncer];
|
|
_output.Xe131m_con= _input.ROI_con_uncer[5*cu_grp_num+pos_con];
|
|
_output.Xe131m_uncer= _input.ROI_con_uncer[5*cu_grp_num+pos_uncer];
|
|
_output.Xe133m_con= _input.ROI_con_uncer[6*cu_grp_num+pos_con];
|
|
_output.Xe133m_uncer= _input.ROI_con_uncer[6*cu_grp_num+pos_uncer];
|
|
double dVarsum=0.0;
|
|
//第n组计数 和 关键水平比较
|
|
if(_input.s_netXe[5*cts_grp_num+pos_cts]>=_input.s_netXe[5*cts_grp_num+pos_level]||_input.g_netXe[5*cts_grp_num+pos_cts]>=_input.g_netXe[5*cts_grp_num+pos_level])
|
|
{
|
|
if(_input.s_netXe[6*cts_grp_num+pos_cts]>=_input.s_netXe[6*cts_grp_num+pos_level]||_input.g_netXe[6*cts_grp_num+pos_cts]>=_input.g_netXe[6*cts_grp_num+pos_level])
|
|
{
|
|
dVarsum = CalcUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcUncer(_input.ROI_con_uncer[7*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcUncer(_input.ROI_con_uncer[8*cu_grp_num+pos_uncer],bError);
|
|
_output.Xe133_con = (CalcConUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_con],_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcConUncer(_input.ROI_con_uncer[7*cu_grp_num+pos_con],_input.ROI_con_uncer[7*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcConUncer(_input.ROI_con_uncer[8*cu_grp_num+pos_con],_input.ROI_con_uncer[8*cu_grp_num+pos_uncer],bError) \
|
|
)/dVarsum;
|
|
_output_Xetype = global::both;
|
|
}
|
|
else
|
|
{
|
|
dVarsum = CalcUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcUncer(_input.ROI_con_uncer[7*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcUncer(_input.ROI_con_uncer[9*cu_grp_num+pos_uncer],bError);
|
|
_output.Xe133_con = (CalcConUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_con],_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcConUncer(_input.ROI_con_uncer[7*cu_grp_num+pos_con],_input.ROI_con_uncer[7*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcConUncer(_input.ROI_con_uncer[9*cu_grp_num+pos_con],_input.ROI_con_uncer[9*cu_grp_num+pos_uncer],bError) \
|
|
)/dVarsum;
|
|
_output_Xetype = global::_131m;
|
|
}
|
|
}
|
|
else if(_input.s_netXe[6*cts_grp_num+pos_cts]>=_input.s_netXe[6*cts_grp_num+pos_level]||_input.g_netXe[6*cts_grp_num+pos_cts]>=_input.g_netXe[6*cts_grp_num+pos_level])
|
|
{
|
|
dVarsum = CalcUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcUncer(_input.ROI_con_uncer[8*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcUncer(_input.ROI_con_uncer[10*cu_grp_num+pos_uncer],bError);
|
|
_output.Xe133_con = (CalcConUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_con],_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcConUncer(_input.ROI_con_uncer[8*cu_grp_num+pos_con],_input.ROI_con_uncer[8*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcConUncer(_input.ROI_con_uncer[10*cu_grp_num+pos_con],_input.ROI_con_uncer[10*cu_grp_num+pos_uncer],bError) \
|
|
)/dVarsum;
|
|
_output_Xetype = global::_133m;
|
|
}
|
|
else
|
|
{
|
|
dVarsum = CalcUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcUncer(_input.ROI_con_uncer[4*cu_grp_num+pos_uncer],bError);
|
|
_output.Xe133_con = (CalcConUncer(_input.ROI_con_uncer[3*cu_grp_num+pos_con],_input.ROI_con_uncer[3*cu_grp_num+pos_uncer],bError)+ \
|
|
CalcConUncer(_input.ROI_con_uncer[4*cu_grp_num+pos_con],_input.ROI_con_uncer[4*cu_grp_num+pos_uncer],bError) \
|
|
)/dVarsum;
|
|
_output_Xetype = global::none;
|
|
}
|
|
if((1/dVarsum)<0)
|
|
{
|
|
return false;
|
|
}
|
|
_output.Xe133_uncer = qSqrt(1/dVarsum);
|
|
if(bError)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
double CXeConUncer::CalcUncer(double _uncer,bool& _bError)
|
|
{
|
|
double rData=0.0;
|
|
if(_uncer == 0.0)
|
|
{
|
|
_bError = true;
|
|
}
|
|
else
|
|
{
|
|
rData=1/(_uncer*_uncer);
|
|
}
|
|
return rData;
|
|
}
|
|
double CXeConUncer::CalcConUncer(double _con,double _uncer,bool& _bError)
|
|
{
|
|
double rData=0.0;
|
|
if(_uncer == 0.0)
|
|
{
|
|
_bError = true;
|
|
}
|
|
else
|
|
{
|
|
rData = _con/(_uncer*_uncer);
|
|
}
|
|
return rData;
|
|
}
|