fix:自建台站beta分析修改
This commit is contained in:
parent
5719c210ca
commit
b4b2b38fa0
|
@ -75,6 +75,8 @@ public class SelfParameterInit {
|
||||||
nuclide.setYield(Double.valueOf(attribute.getNodeValue()));
|
nuclide.setYield(Double.valueOf(attribute.getNodeValue()));
|
||||||
} else if (attribute.getNodeName().equalsIgnoreCase("energy")) {
|
} else if (attribute.getNodeName().equalsIgnoreCase("energy")) {
|
||||||
nuclide.setEnergy(Double.valueOf(attribute.getNodeValue()));
|
nuclide.setEnergy(Double.valueOf(attribute.getNodeValue()));
|
||||||
|
} else if (attribute.getNodeName().equalsIgnoreCase("half_life")) {
|
||||||
|
nuclide.setHalflife(Double.valueOf(attribute.getNodeValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StrUtil.isNotBlank(nuclide.getName()) && Objects.nonNull(nuclide.getEnergy())) {
|
if (StrUtil.isNotBlank(nuclide.getName()) && Objects.nonNull(nuclide.getEnergy())) {
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.jeecg.modules.base.entity.original;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储 自建台站 β-γ符合谱中#b_self_attenuation 数据块中。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("ORIGINAL.GARDS_SELF_ATTENUATION")
|
||||||
|
public class GardsSelfAttenuation implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 样品id
|
||||||
|
*/
|
||||||
|
@TableField(value = "SAMPLE_ID")
|
||||||
|
private Integer sampleId;
|
||||||
|
/**
|
||||||
|
* 感兴趣区编号
|
||||||
|
*/
|
||||||
|
@TableField(value = "ROI")
|
||||||
|
private Integer roi;
|
||||||
|
/**
|
||||||
|
* 核素名称
|
||||||
|
*/
|
||||||
|
@TableField(value = "NUCLIDE_NAME")
|
||||||
|
private String nuclideName;
|
||||||
|
|
||||||
|
// todo 补充三个 氙参数,三个 氮参数
|
||||||
|
|
||||||
|
@TableField(value = "MODDATE")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date moddate;
|
||||||
|
}
|
|
@ -17,6 +17,8 @@ public class NuclideLine implements Serializable {
|
||||||
|
|
||||||
private Double yieldUncert;
|
private Double yieldUncert;
|
||||||
|
|
||||||
|
private Double halflife;
|
||||||
|
|
||||||
private Integer keyFlag;
|
private Integer keyFlag;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.jeecg.modules.exception;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public class AnalyseException extends Exception{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private boolean isDuplicateKeyException = false;
|
||||||
|
|
||||||
|
public AnalyseException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnalyseException(String message, boolean isDuplicateKeyException) {
|
||||||
|
super(message);
|
||||||
|
this.isDuplicateKeyException = isDuplicateKeyException;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.cache.SelfCache;
|
import org.jeecg.common.cache.SelfCache;
|
||||||
|
@ -22,6 +23,7 @@ import org.jeecg.modules.entity.vo.*;
|
||||||
import org.jeecg.modules.native_jni.CalValuesHandler;
|
import org.jeecg.modules.native_jni.CalValuesHandler;
|
||||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||||
import org.jeecg.modules.native_jni.struct.BgBoundary;
|
import org.jeecg.modules.native_jni.struct.BgBoundary;
|
||||||
|
import org.jeecg.modules.native_jni.struct.CalValuesOut;
|
||||||
import org.jeecg.modules.native_jni.struct.CalcBgBoundaryParam;
|
import org.jeecg.modules.native_jni.struct.CalcBgBoundaryParam;
|
||||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
@ -1794,4 +1796,142 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取结算结果需要的参数(峰面积、半衰期、发射几率)
|
||||||
|
* @param gStart RoiLimit Gamma Start
|
||||||
|
* @param gStop RoiLimit Gamma Stop
|
||||||
|
* @param nuclideLinesMap 所有核素信息
|
||||||
|
*/
|
||||||
|
public HashMap<String, Object> getBetaAnalyseNuclideParam(SelfStationVueData sampleData, HashMap<String, NuclideLine> nuclideMap,
|
||||||
|
List<Double> gStart, List<Double> gStop, Map<String,
|
||||||
|
NuclideLines> nuclideLinesMap) {
|
||||||
|
HashMap<String, Object> param = Maps.newHashMap();
|
||||||
|
// 获取峰信息
|
||||||
|
List<PeakInfo> vPeak = null;
|
||||||
|
String mapKey = "";
|
||||||
|
// 遍历roiLimit
|
||||||
|
for (int g = 0; g < gStart.size(); g++) {
|
||||||
|
HashMap<String, Object> nuclideParam = Maps.newHashMap();
|
||||||
|
String nuclideName = "";
|
||||||
|
switch (g) {
|
||||||
|
case 0:
|
||||||
|
nuclideName = "Xe131M";
|
||||||
|
mapKey = "XE-131m";
|
||||||
|
vPeak = sampleData.getROIOnePHDFile().getVPeak();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
nuclideName = "Xe133M";
|
||||||
|
mapKey = "XE-133m";
|
||||||
|
vPeak = sampleData.getROITwoPHDFile().getVPeak();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
nuclideName = "Xe133";
|
||||||
|
mapKey = "XE-133";
|
||||||
|
vPeak = sampleData.getROIThreePHDFile().getVPeak();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
nuclideName = "Xe135";
|
||||||
|
mapKey = "XE-135";
|
||||||
|
vPeak = sampleData.getROIFourPHDFile().getVPeak();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发射几率
|
||||||
|
nuclideParam.put("yield", nuclideMap.get(nuclideName).getYield().toString());
|
||||||
|
// 半衰期
|
||||||
|
nuclideParam.put("halflife", nuclideMap.get(nuclideName).getHalflife().toString());
|
||||||
|
// baseline 计数,这里使用的energy是固定的 从配置文件中取出
|
||||||
|
nuclideParam.put("baseline",this.getBetaAnalyseBaseLineCount(sampleData, nuclideName, nuclideMap.get(nuclideName).getEnergy()));
|
||||||
|
|
||||||
|
for (PeakInfo info : vPeak) {
|
||||||
|
double energy = info.energy;
|
||||||
|
// 找匹配roi范围的 energy
|
||||||
|
if (energy > gStart.get(g) && energy < gStop.get(g)) {
|
||||||
|
double area = info.area;
|
||||||
|
// 峰如果没有识别到核素则跳过
|
||||||
|
if (info.nuclides.contains(nuclideName)) {
|
||||||
|
NuclideLines nuclideLines = nuclideLinesMap.get(nuclideName);
|
||||||
|
// 峰面积
|
||||||
|
nuclideParam.put("area", area+"");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 没有峰信息 核素=未识别 不计算活度浓度
|
||||||
|
if (!nuclideParam.containsKey("area")) {
|
||||||
|
nuclideParam.put("area", "0");
|
||||||
|
}
|
||||||
|
param.put(mapKey, nuclideParam);
|
||||||
|
}
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到 baseline计数
|
||||||
|
* @param sampleData 谱数据
|
||||||
|
* @param nuclideName 核素名称
|
||||||
|
* @param energy 能量
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public double getBetaAnalyseBaseLineCount(SelfStationVueData sampleData,String nuclideName, Double energy) {
|
||||||
|
double baseLineCount = 0;
|
||||||
|
String currentText = null;
|
||||||
|
List<Double> vBase = null;
|
||||||
|
PHDFile phd = null;
|
||||||
|
// 获取baseline
|
||||||
|
switch (nuclideName) {
|
||||||
|
case "Xe131M":
|
||||||
|
phd = sampleData.getROIOnePHDFile();
|
||||||
|
break;
|
||||||
|
case "Xe133M":
|
||||||
|
phd = sampleData.getROITwoPHDFile();
|
||||||
|
break;
|
||||||
|
case "Xe133":
|
||||||
|
phd = sampleData.getROIThreePHDFile();
|
||||||
|
break;
|
||||||
|
case "Xe135":
|
||||||
|
phd = sampleData.getROIFourPHDFile();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (null == phd) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
vBase = phd.getVBase();
|
||||||
|
currentText = StrUtil.isNotBlank(phd.getNewEner()) ? phd.getNewEner() : phd.getUsedEner();
|
||||||
|
// 得到baseline count范围
|
||||||
|
double fwhm = 0;
|
||||||
|
// 公式参数
|
||||||
|
ParameterInfo m_curParam = sampleData.getMapResoPara().get(currentText);
|
||||||
|
int p_size = m_curParam.getP().size()-1;
|
||||||
|
if(p_size >= 2 && m_curParam.getP().get(1) > 0 && m_curParam.getP().get(2) > 0) {
|
||||||
|
// Square root of polynomial: y = sqrt(a0+a1*x+a2*x^2+a3*x^3 )
|
||||||
|
fwhm = m_curParam.getP().get(1) + energy * m_curParam.getP().get(2);
|
||||||
|
// equation += "FWHM = ("+NumberFormatUtil.numberFormat(String.valueOf(m_curParam.getP().get(1)))+" + E * "+NumberFormatUtil.numberFormat(String.valueOf(m_curParam.getP().get(2)));
|
||||||
|
for(int i=3; i<=p_size; i++) {
|
||||||
|
fwhm += (Math.pow(energy, (i-1)) * m_curParam.getP().get(i));
|
||||||
|
// equation += " + E<sup style=\"vertical-align:super;\">"+(i-1)+"</sup> * "+NumberFormatUtil.numberFormat(String.valueOf(m_curParam.getP().get(i)));
|
||||||
|
}
|
||||||
|
fwhm = Math.pow(fwhm, 0.5);
|
||||||
|
// equation += ")<sup style=\"vertical-align:super;\">"+1+"/"+2+"</sup>";
|
||||||
|
}
|
||||||
|
// 通过energy带入到FHWM公式中,将结果energy转化channel,加减1.25之后取这个范围之内的baseline进行加和
|
||||||
|
List<Double> energyList = Lists.newLinkedList();
|
||||||
|
energyList.add(energy - (fwhm - 1.25));
|
||||||
|
CalValuesOut energyToChannel = CalValuesHandler.energyToChannel(energyList, phd.getUsedEnerPara().getP());
|
||||||
|
long begin = Math.round(energyToChannel.counts.get(0));
|
||||||
|
Console.log("nuclide:{},energy:{},fwhmL:{},beginChannel:{}",nuclideName, energy, (fwhm - 1.25), begin);
|
||||||
|
energyList = Lists.newLinkedList();
|
||||||
|
energyList.add(energy + (fwhm + 1.25));
|
||||||
|
energyToChannel = CalValuesHandler.energyToChannel(energyList, phd.getUsedEnerPara().getP());
|
||||||
|
long end = Math.round(energyToChannel.counts.get(0));
|
||||||
|
Console.log("nuclide:{},energy:{},fwhmR:{},endChannel:{}",nuclideName, energy, (fwhm + 1.25), end);
|
||||||
|
if (begin >= 0 && end <= vBase.size()) {
|
||||||
|
for (long i = begin; i < end; i++) {
|
||||||
|
baseLineCount += vBase.get((int)i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return baseLineCount;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.jeecg.modules.base.enums.CalType;
|
||||||
import org.jeecg.modules.base.enums.SampleFileHeader;
|
import org.jeecg.modules.base.enums.SampleFileHeader;
|
||||||
import org.jeecg.modules.entity.*;
|
import org.jeecg.modules.entity.*;
|
||||||
import org.jeecg.modules.entity.vo.*;
|
import org.jeecg.modules.entity.vo.*;
|
||||||
|
import org.jeecg.modules.exception.AnalyseException;
|
||||||
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
|
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
|
||||||
import org.jeecg.modules.native_jni.CalValuesHandler;
|
import org.jeecg.modules.native_jni.CalValuesHandler;
|
||||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||||
|
@ -2606,11 +2607,12 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
|
||||||
result.setSuccess(true);
|
result.setSuccess(true);
|
||||||
result.setResult(resultMap);
|
result.setResult(resultMap);
|
||||||
selfStationData.setBAnalyed(true);
|
selfStationData.setBAnalyed(true);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException | AnalyseException e) {
|
||||||
Log.error("analyse error:", e);
|
Log.error("analyse error:", e);
|
||||||
result.error500(StrUtil.replace(e.getMessage(), "%s", "ROI"));
|
result.error500(StrUtil.replace(e.getMessage(), "%s", "ROI"));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
Log.error("analyse error:", e);
|
||||||
|
result.error500("analyse error!");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2621,7 +2623,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
|
||||||
* @param nuclideLinesMap 核素信息
|
* @param nuclideLinesMap 核素信息
|
||||||
* @throws JsonProcessingException
|
* @throws JsonProcessingException
|
||||||
*/
|
*/
|
||||||
private List<GardsXeResultsSpectrum> betaAnalyse(SelfStationData selfStationData, Map<String, NuclideLines> nuclideLinesMap) throws JsonProcessingException {
|
private List<GardsXeResultsSpectrum> betaAnalyse(SelfStationData selfStationData, Map<String, NuclideLines> nuclideLinesMap) throws Exception {
|
||||||
SelfStationVueData sampleData = selfStationData.getSampleVueData();
|
SelfStationVueData sampleData = selfStationData.getSampleVueData();
|
||||||
EnergySpectrumStruct struct = selfStationData.getSampleStruct();
|
EnergySpectrumStruct struct = selfStationData.getSampleStruct();
|
||||||
String phdPath = selfStationData.getSampleFilePathName();
|
String phdPath = selfStationData.getSampleFilePathName();
|
||||||
|
@ -2630,7 +2632,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
|
||||||
HashMap<String, NuclideLine> nuclideMap = selfParameter.getNuclideMap();
|
HashMap<String, NuclideLine> nuclideMap = selfParameter.getNuclideMap();
|
||||||
|
|
||||||
// 获取峰面积、半衰期、发射几率
|
// 获取峰面积、半衰期、发射几率
|
||||||
HashMap<String, Object> nuclideParam = this.getBetaAnalyseNuclideParam(sampleData, nuclideMap, struct.POI_G_y1, struct.POI_G_y2, nuclideLinesMap);
|
HashMap<String, Object> nuclideParam = selfStationUtil.getBetaAnalyseNuclideParam(sampleData, nuclideMap, struct.POI_G_y1, struct.POI_G_y2, nuclideLinesMap);
|
||||||
Console.log(JSON.toJSONString(nuclideParam));
|
Console.log(JSON.toJSONString(nuclideParam));
|
||||||
// 调用beta分析算法
|
// 调用beta分析算法
|
||||||
String resultStr = EnergySpectrumHandler.selfBgAnalyse(phdPath, JSON.toJSONString(nuclideParam));
|
String resultStr = EnergySpectrumHandler.selfBgAnalyse(phdPath, JSON.toJSONString(nuclideParam));
|
||||||
|
@ -2642,7 +2644,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
|
||||||
for (GardsXeResultsSpectrum xeData:xeDataList) {
|
for (GardsXeResultsSpectrum xeData:xeDataList) {
|
||||||
Double conc = xeData.getConc();
|
Double conc = xeData.getConc();
|
||||||
Double mdc = xeData.getMdc();
|
Double mdc = xeData.getMdc();
|
||||||
if (conc < 0){
|
if (conc <= 0){
|
||||||
xeData.setColor("red");
|
xeData.setColor("red");
|
||||||
xeData.setNidFlag(0);
|
xeData.setNidFlag(0);
|
||||||
} else if (0<conc && conc < mdc) {
|
} else if (0<conc && conc < mdc) {
|
||||||
|
@ -2661,138 +2663,6 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
|
||||||
return xeDataList;
|
return xeDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取结算结果需要的参数(峰面积、半衰期、发射几率)
|
|
||||||
* @param gStart RoiLimit Gamma Start
|
|
||||||
* @param gStop RoiLimit Gamma Stop
|
|
||||||
* @param nuclideLinesMap 所有核素信息
|
|
||||||
*/
|
|
||||||
private HashMap<String, Object> getBetaAnalyseNuclideParam(SelfStationVueData sampleData, HashMap<String, NuclideLine> nuclideMap,
|
|
||||||
List<Double> gStart, List<Double> gStop, Map<String,
|
|
||||||
NuclideLines> nuclideLinesMap) {
|
|
||||||
HashMap<String, Object> param = Maps.newHashMap();
|
|
||||||
// 获取峰信息
|
|
||||||
List<PeakInfo> vPeak = null;
|
|
||||||
String mapKey = "";
|
|
||||||
// 遍历roiLimit
|
|
||||||
for (int g = 0; g < gStart.size(); g++) {
|
|
||||||
HashMap<String, Object> nuclideParam = Maps.newHashMap();
|
|
||||||
String nuclideName = "";
|
|
||||||
switch (g) {
|
|
||||||
case 0:
|
|
||||||
nuclideName = "Xe131M";
|
|
||||||
mapKey = "XE-131m";
|
|
||||||
vPeak = sampleData.getROIOnePHDFile().getVPeak();
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
nuclideName = "Xe133M";
|
|
||||||
mapKey = "XE-133m";
|
|
||||||
vPeak = sampleData.getROITwoPHDFile().getVPeak();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
nuclideName = "Xe133";
|
|
||||||
mapKey = "XE-133";
|
|
||||||
vPeak = sampleData.getROIThreePHDFile().getVPeak();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
nuclideName = "Xe135";
|
|
||||||
mapKey = "XE-135";
|
|
||||||
vPeak = sampleData.getROIFourPHDFile().getVPeak();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// 发射几率
|
|
||||||
nuclideParam.put("yield", nuclideMap.get(nuclideName).getYield().toString());
|
|
||||||
// baseline 计数,这里使用的energy是固定的 从配置文件中取出
|
|
||||||
nuclideParam.put("baseline",this.getBetaAnalyseBaseLineCount(sampleData, nuclideName,
|
|
||||||
nuclideMap.get(nuclideName).getEnergy())+"");
|
|
||||||
for (PeakInfo info : vPeak) {
|
|
||||||
// 峰核素的energy
|
|
||||||
double energy = info.energy;
|
|
||||||
// 找匹配roi范围的 energy
|
|
||||||
if (energy > gStart.get(g) && energy < gStop.get(g)) {
|
|
||||||
double area = info.area;
|
|
||||||
// 峰如果没有识别到核素则跳过
|
|
||||||
if (info.nuclides.contains(nuclideName)) {
|
|
||||||
NuclideLines nuclideLines = nuclideLinesMap.get(nuclideName);
|
|
||||||
Console.log("halflife:{}",nuclideLines.halflife);
|
|
||||||
// 峰面积
|
|
||||||
nuclideParam.put("area", area+"");
|
|
||||||
// 半衰期
|
|
||||||
nuclideParam.put("halflife", (nuclideLines.halflife / 24 / 60 / 60) +"");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
param.put(mapKey, nuclideParam);
|
|
||||||
}
|
|
||||||
return param;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 得到 baseline计数
|
|
||||||
* @param sampleData 谱数据
|
|
||||||
* @param nuclideName 核素名称
|
|
||||||
* @param energy 能量
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private double getBetaAnalyseBaseLineCount(SelfStationVueData sampleData,String nuclideName, Double energy) {
|
|
||||||
double baseLineCount = 0;
|
|
||||||
String currentText = null;
|
|
||||||
List<Double> vBase = null;
|
|
||||||
PHDFile phd = null;
|
|
||||||
// 获取baseline
|
|
||||||
switch (nuclideName) {
|
|
||||||
case "Xe131M":
|
|
||||||
phd = sampleData.getROIOnePHDFile();
|
|
||||||
break;
|
|
||||||
case "Xe133M":
|
|
||||||
phd = sampleData.getROITwoPHDFile();
|
|
||||||
break;
|
|
||||||
case "Xe133":
|
|
||||||
phd = sampleData.getROIThreePHDFile();
|
|
||||||
break;
|
|
||||||
case "Xe135":
|
|
||||||
phd = sampleData.getROIFourPHDFile();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (null == phd) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
vBase = phd.getVBase();
|
|
||||||
currentText = StrUtil.isNotBlank(phd.getNewEner()) ? phd.getNewEner() : phd.getUsedEner();
|
|
||||||
// 得到baseline count范围
|
|
||||||
double fwhm = 0;
|
|
||||||
// 公式参数
|
|
||||||
ParameterInfo m_curParam = sampleData.getMapResoPara().get(currentText);
|
|
||||||
int p_size = m_curParam.getP().size()-1;
|
|
||||||
if(p_size >= 2 && m_curParam.getP().get(1) > 0 && m_curParam.getP().get(2) > 0) {
|
|
||||||
// Square root of polynomial: y = sqrt(a0+a1*x+a2*x^2+a3*x^3 )
|
|
||||||
fwhm = m_curParam.getP().get(1) + energy * m_curParam.getP().get(2);
|
|
||||||
// equation += "FWHM = ("+NumberFormatUtil.numberFormat(String.valueOf(m_curParam.getP().get(1)))+" + E * "+NumberFormatUtil.numberFormat(String.valueOf(m_curParam.getP().get(2)));
|
|
||||||
for(int i=3; i<=p_size; i++) {
|
|
||||||
fwhm += (Math.pow(energy, (i-1)) * m_curParam.getP().get(i));
|
|
||||||
// equation += " + E<sup style=\"vertical-align:super;\">"+(i-1)+"</sup> * "+NumberFormatUtil.numberFormat(String.valueOf(m_curParam.getP().get(i)));
|
|
||||||
}
|
|
||||||
fwhm = Math.pow(fwhm, 0.5);
|
|
||||||
// equation += ")<sup style=\"vertical-align:super;\">"+1+"/"+2+"</sup>";
|
|
||||||
}
|
|
||||||
// 通过energy带入到FHWM公式中,将结果energy转化channel,加减1.25之后取这个范围之内的baseline进行加和
|
|
||||||
List<Double> energyList = Lists.newLinkedList();
|
|
||||||
energyList.add(energy - (fwhm - 1.25));
|
|
||||||
CalValuesOut energyToChannel = CalValuesHandler.energyToChannel(energyList, phd.getUsedEnerPara().getP());
|
|
||||||
long begin = Math.round(energyToChannel.counts.get(0));
|
|
||||||
energyList = Lists.newLinkedList();
|
|
||||||
energyList.add(energy + (fwhm + 1.25));
|
|
||||||
energyToChannel = CalValuesHandler.energyToChannel(energyList, phd.getUsedEnerPara().getP());
|
|
||||||
long end = Math.round(energyToChannel.counts.get(0));
|
|
||||||
if (begin >= 0 && end <= vBase.size()) {
|
|
||||||
for (long i = begin; i < end; i++) {
|
|
||||||
baseLineCount += vBase.get((int)i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return baseLineCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result InteractiveTool(Integer sampleId, String fileName, int gammaROINum, HttpServletRequest request) {
|
public Result InteractiveTool(Integer sampleId, String fileName, int gammaROINum, HttpServletRequest request) {
|
||||||
Result result = new Result();
|
Result result = new Result();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user