修改三维视图显示
This commit is contained in:
parent
aaf6883f4d
commit
93225c466e
|
|
@ -1,25 +1,17 @@
|
|||
#include "ConformityAnalysis.h"
|
||||
#include "ui_ConformityAnalysis.h"
|
||||
#include <QDebug>
|
||||
#include <GlobalDefine.h>
|
||||
|
||||
ConformityAnalysis::ConformityAnalysis(QWidget *parent) :
|
||||
MeasureAnalysisView(parent),
|
||||
ui(new Ui::ConformityAnalysis)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
memset(m_boardChannel, 0, sizeof(m_boardChannel)); // 新增
|
||||
//// // 获取当前可执行文件的路径
|
||||
//// QString executablePath = QCoreApplication::applicationDirPath() + "/test.csv";
|
||||
// connect(ui->widget,SIGNAL(Signal_ClickedBoard(int,int)),this,SLOT(slot_ClickedBoard(int,int)));
|
||||
// connect(ui->widget,SIGNAL(Signal_InitialState()),this,SLOT(slot_InitialState()));
|
||||
//// qDebug()<<"可执行文件:"<< executablePath;
|
||||
// setCsvFile(m_fileName);
|
||||
// readCsv();
|
||||
// handleBoard();
|
||||
// m_FirstParticle = statisticsFirstParticleQuantity();
|
||||
// setAllBoardData();
|
||||
// calculateFirstSecondRange();
|
||||
// setThreeUiData();
|
||||
// generateSurfaceData(m_CoincidenceEventVector);
|
||||
connect(ui->widget,SIGNAL(Signal_ClickedBoard(int,int)),this,SLOT(slot_ClickedBoard(int,int)));
|
||||
connect(ui->widget,SIGNAL(Signal_InitialState()),this,SLOT(slot_InitialState()));
|
||||
|
||||
}
|
||||
|
||||
ConformityAnalysis::~ConformityAnalysis()
|
||||
|
|
@ -37,7 +29,6 @@ void ConformityAnalysis::SetAnalyzeDataFilename(const QMap<QString, QVariant> &d
|
|||
QStringList ch_count_data_name = data_files_set.keys();
|
||||
int conformCount = ui->comboBox->currentIndex() + 2;
|
||||
for (const QString& ch_count_data_name : ch_count_data_name) {
|
||||
qDebug()<<data_files_set[ch_count_data_name];
|
||||
if(conformCount == ch_count_data_name.toInt())
|
||||
{
|
||||
setCsvFile(data_files_set[ch_count_data_name].toString());
|
||||
|
|
@ -47,14 +38,9 @@ void ConformityAnalysis::SetAnalyzeDataFilename(const QMap<QString, QVariant> &d
|
|||
setAllBoardData();
|
||||
calculateFirstSecondRange();
|
||||
setThreeUiData();
|
||||
generateSurfaceData(m_CoincidenceEventVector);
|
||||
|
||||
generateSurfaceData(_spectrumDataList);
|
||||
}
|
||||
}
|
||||
|
||||
// QString path = data_files_set.first().toString();
|
||||
// qDebug()<<path;
|
||||
// setCsvFile(path);
|
||||
}
|
||||
|
||||
void ConformityAnalysis::setCsvFile(QString fileName)
|
||||
|
|
@ -66,35 +52,21 @@ void ConformityAnalysis::readCsv()
|
|||
{
|
||||
qDebug()<<m_fileName;
|
||||
// 创建 CSVReader 对象,指定列数(5列)
|
||||
io::CSVReader<5> reader(m_fileName.toStdString());
|
||||
qDebug()<<"板卡号:";
|
||||
// 符合事件变量
|
||||
int id = 0;
|
||||
std::vector<F2t9Order::SpectrumData> SpectrumDataList;
|
||||
// 逐行读取数据
|
||||
io::CSVReader<5> reader(QStrToSysPath(m_fileName));
|
||||
reader.read_header(io::ignore_extra_column, "事件ID","板卡号", "通道号", "能量(KeV)", "时间计数");
|
||||
// 逐行读取数据
|
||||
while (true)
|
||||
{
|
||||
int comply = 0;
|
||||
F2t9Order::SpectrumData SpectrumData;
|
||||
bool flag = reader.read_row(/*EventData.coincidence_order*/comply,SpectrumData.board_id, SpectrumData.channel_id, SpectrumData.energy,SpectrumData.timestamp);
|
||||
qDebug()<<"符合事件:"<<comply<<"板卡号:"<<SpectrumData.board_id<<"通道号:"<<SpectrumData.board_id<<"能量:"<<SpectrumData.energy<<"时间戳:"<<SpectrumData.timestamp;
|
||||
if(!flag)
|
||||
particleCoincidenceEvent *SpectrumData = new particleCoincidenceEvent;
|
||||
bool flag = reader.read_row(SpectrumData->eventId,SpectrumData->board, SpectrumData->channel, SpectrumData->energy,SpectrumData->timeCounter);
|
||||
|
||||
if(!flag)
|
||||
{
|
||||
break;
|
||||
}
|
||||
SpectrumDataList.push_back(SpectrumData);
|
||||
if(comply != id)
|
||||
{
|
||||
F2t9Order::CoincidenceEvent EventData;
|
||||
EventData.coincidence_order = comply;
|
||||
EventData.events = SpectrumDataList;
|
||||
m_CoincidenceEventVector.push_back(EventData);
|
||||
qDebug()<<"符合事件里面的vector:"<<EventData.events.size();
|
||||
id = EventData.coincidence_order;
|
||||
SpectrumDataList.clear();
|
||||
}
|
||||
// qDebug()<< SpectrumData->eventId << " " << SpectrumData->board<<" "<<SpectrumData->channel;
|
||||
_spectrumDataList.push_back(SpectrumData);
|
||||
}
|
||||
qDebug()<<"符合事件数:"<<m_CoincidenceEventVector.size();
|
||||
}
|
||||
|
||||
void ConformityAnalysis::slot_InitialState()
|
||||
|
|
@ -102,13 +74,13 @@ void ConformityAnalysis::slot_InitialState()
|
|||
setAllBoardData();
|
||||
calculateFirstSecondRange();
|
||||
setThreeUiData();
|
||||
generateSurfaceData(m_CoincidenceEventVector);
|
||||
generateSurfaceData(_spectrumDataList);
|
||||
}
|
||||
|
||||
void ConformityAnalysis::slot_ClickedBoard(int board,int channel)
|
||||
{
|
||||
//获取当前板卡的初级粒子数据
|
||||
std::vector<F2t9Order::CoincidenceEvent> data = handleBasicSubordinate(m_CoincidenceEventVector,board,channel);
|
||||
QVector<particleCoincidenceEvent*> data = handleBasicSubordinate(board,channel);
|
||||
if(data.size() <= 0) return;
|
||||
generateSurfaceData(data);
|
||||
m_subordinate = handleSubordinate(data, board, channel);
|
||||
|
|
@ -125,12 +97,9 @@ void ConformityAnalysis::slot_ClickedBoard(int board,int channel)
|
|||
|
||||
void ConformityAnalysis::handleBoard()
|
||||
{
|
||||
for (int i = 0; i < m_CoincidenceEventVector.size(); i++)
|
||||
for(auto spetruData:_spectrumDataList)
|
||||
{
|
||||
for(auto spetruData:m_CoincidenceEventVector.at(i).events)
|
||||
{
|
||||
m_boardChannel[spetruData.channel_id][spetruData.board_id]++;
|
||||
}
|
||||
m_boardChannel[spetruData->board][spetruData->channel]++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -146,16 +115,18 @@ QMap<QString, int> ConformityAnalysis::statisticsFirstParticleQuantity()
|
|||
firstParticleCount[key] = 0;
|
||||
}
|
||||
}
|
||||
if (_spectrumDataList.empty()) return firstParticleCount;
|
||||
|
||||
int eventId = 0;
|
||||
// 遍历所有符合事件
|
||||
for (const auto& event : m_CoincidenceEventVector)
|
||||
for (const auto& event : _spectrumDataList)
|
||||
{
|
||||
if (event.events.empty()) continue;
|
||||
|
||||
// 第一个事件是初级粒子
|
||||
const auto& firstParticle = event.events[0];
|
||||
int boardId = firstParticle.board_id + 1; // 转换为1-based
|
||||
int channelId = firstParticle.channel_id + 1; // 转换为1-based
|
||||
|
||||
const auto& firstParticle = event;
|
||||
int boardId = firstParticle->board + 1;
|
||||
int channelId = firstParticle->channel + 1;
|
||||
if(firstParticle->eventId == eventId) continue;
|
||||
eventId = firstParticle->eventId;
|
||||
if (boardId >= 1 && boardId <= 8 && channelId >= 1 && channelId <= 4) {
|
||||
QString key = QString("widget_%1_%2").arg(boardId).arg(channelId);
|
||||
firstParticleCount[key]++;
|
||||
|
|
@ -164,23 +135,38 @@ QMap<QString, int> ConformityAnalysis::statisticsFirstParticleQuantity()
|
|||
return firstParticleCount;
|
||||
}
|
||||
|
||||
std::vector<F2t9Order::CoincidenceEvent> ConformityAnalysis::handleBasicSubordinate(std::vector<F2t9Order::CoincidenceEvent> &eventData, int Board, int Channel)
|
||||
QVector<particleCoincidenceEvent*> ConformityAnalysis::handleBasicSubordinate(int Board, int Channel)
|
||||
{
|
||||
std::vector<F2t9Order::CoincidenceEvent> EventVector;//所有的初级粒子符合事件
|
||||
for (int i = 0; i < eventData.size(); i++)
|
||||
QVector<particleCoincidenceEvent*> EventVector;//所有的初级粒子符合事件
|
||||
int eventId = 0;
|
||||
for(auto data:_spectrumDataList)
|
||||
{
|
||||
F2t9Order::CoincidenceEvent EventData = eventData.at(i);
|
||||
F2t9Order::SpectrumData data = EventData.events.at(0);
|
||||
if (data.board_id == Board - 1&& data.channel_id == Channel - 1)
|
||||
if(eventId == data->eventId)
|
||||
{
|
||||
EventVector.push_back(data);
|
||||
}
|
||||
|
||||
if(data->board == Board - 1&& data->channel == Channel - 1)
|
||||
{
|
||||
EventVector.push_back(EventData);
|
||||
m_beginVector.push_back(data);
|
||||
EventVector.push_back(data);
|
||||
eventId = data->eventId;
|
||||
}
|
||||
}
|
||||
// for (int i = 0; i < eventData.size(); i++)
|
||||
// {
|
||||
// F2t9Order::CoincidenceEvent EventData = eventData.at(i);
|
||||
// F2t9Order::SpectrumData data = EventData.events.at(0);
|
||||
// if (data.board_id == Board - 1&& data.channel_id == Channel - 1)
|
||||
// {
|
||||
// EventVector.push_back(EventData);
|
||||
// m_beginVector.push_back(data);
|
||||
// }
|
||||
// }
|
||||
return EventVector;
|
||||
}
|
||||
|
||||
QMap<QString, int> ConformityAnalysis::handleSubordinate(std::vector<F2t9Order::CoincidenceEvent> &eventData,int Board, int Channel)
|
||||
QMap<QString, int> ConformityAnalysis::handleSubordinate(QVector<particleCoincidenceEvent*> &eventData,int Board, int Channel)
|
||||
{
|
||||
m_secondVector.clear();
|
||||
QMap<QString, int> data;
|
||||
|
|
@ -190,23 +176,42 @@ QMap<QString, int> ConformityAnalysis::handleSubordinate(std::vector<F2t9Order::
|
|||
{
|
||||
QString key = QString("widget_%1_%2").arg(board).arg(channel);
|
||||
data[key] = 0;
|
||||
for (int j = 0; j < eventData.size(); j++)
|
||||
for(auto dataSpectrum : eventData)
|
||||
{
|
||||
std::vector<F2t9Order::SpectrumData> dataVector = eventData.at(j).events;
|
||||
for (int k = 0; k < dataVector.size(); k++)
|
||||
if (dataSpectrum->board == Board - 1 && dataSpectrum->channel == Channel - 1)
|
||||
continue;
|
||||
if (dataSpectrum->board == board - 1 && dataSpectrum->channel == channel - 1)
|
||||
{
|
||||
F2t9Order::SpectrumData dataSpectrum = dataVector.at(k);
|
||||
if (dataSpectrum.board_id == Board - 1 && dataSpectrum.channel_id == Channel - 1)
|
||||
continue;
|
||||
if (dataSpectrum.board_id == board - 1 && dataSpectrum.channel_id == channel - 1)
|
||||
{
|
||||
data[key]++;
|
||||
m_secondVector.push_back(dataSpectrum);
|
||||
}
|
||||
data[key]++;
|
||||
m_secondVector.push_back(dataSpectrum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for (int board = 1; board <= 8; ++board)
|
||||
// {
|
||||
// for (int channel = 1; channel <= 4; ++channel)
|
||||
// {
|
||||
// QString key = QString("widget_%1_%2").arg(board).arg(channel);
|
||||
// data[key] = 0;
|
||||
// for (int j = 0; j < eventData.size(); j++)
|
||||
// {
|
||||
// std::vector<F2t9Order::SpectrumData> dataVector = eventData.at(j).events;
|
||||
// for (int k = 0; k < dataVector.size(); k++)
|
||||
// {
|
||||
// F2t9Order::SpectrumData dataSpectrum = dataVector.at(k);
|
||||
// if (dataSpectrum.board_id == Board - 1 && dataSpectrum.channel_id == Channel - 1)
|
||||
// continue;
|
||||
// if (dataSpectrum.board_id == board - 1 && dataSpectrum.channel_id == channel - 1)
|
||||
// {
|
||||
// data[key]++;
|
||||
// m_secondVector.push_back(dataSpectrum);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
@ -227,23 +232,21 @@ void ConformityAnalysis::calculateFirstSecondRange()
|
|||
|
||||
double minSecondVal = 11111111.1111;
|
||||
double maxSecondVal = 0.0;
|
||||
for (int i = 0; i < m_CoincidenceEventVector.size(); i++)
|
||||
|
||||
m_iComply = _spectrumDataList.size();
|
||||
for (int j = 0; j < _spectrumDataList.size(); j++)
|
||||
{
|
||||
F2t9Order::CoincidenceEvent data = m_CoincidenceEventVector.at(i);
|
||||
m_iComply += data.events.size();
|
||||
for (int j = 0; j < data.events.size(); j++)
|
||||
particleCoincidenceEvent *spectrum = _spectrumDataList.at(j);
|
||||
if (j == 0)
|
||||
{
|
||||
F2t9Order::SpectrumData spectrum = data.events.at(j);
|
||||
if (j == 0)
|
||||
{
|
||||
if (spectrum.energy < minFirstVal) minFirstVal = spectrum.energy;
|
||||
if (spectrum.energy > maxFirstVal) maxFirstVal = spectrum.energy;
|
||||
continue;
|
||||
}
|
||||
if (spectrum.energy < minSecondVal) minSecondVal = spectrum.energy;
|
||||
if (spectrum.energy > maxSecondVal) maxSecondVal = spectrum.energy;
|
||||
if (spectrum->energy < minFirstVal) minFirstVal = spectrum->energy;
|
||||
if (spectrum->energy > maxFirstVal) maxFirstVal = spectrum->energy;
|
||||
continue;
|
||||
}
|
||||
if (spectrum->energy < minSecondVal) minSecondVal = spectrum->energy;
|
||||
if (spectrum->energy > maxSecondVal) maxSecondVal = spectrum->energy;
|
||||
}
|
||||
|
||||
m_dFirstStart = minFirstVal;
|
||||
m_dFirstEnd = maxFirstVal;
|
||||
m_dSecondStart = minSecondVal;
|
||||
|
|
@ -274,25 +277,34 @@ void ConformityAnalysis::setThreeUiData()
|
|||
ui->widget_3D->setComplyWithEvent(m_iComply);
|
||||
}
|
||||
|
||||
void ConformityAnalysis::generateSurfaceData(const std::vector<F2t9Order::CoincidenceEvent>& events)
|
||||
void ConformityAnalysis::generateSurfaceData(const QVector<particleCoincidenceEvent*> events)
|
||||
{
|
||||
m_surfaceData.clear();
|
||||
if (events.empty()) return;
|
||||
int eventId = 0;
|
||||
|
||||
float primaryEnergy = 0.0f;
|
||||
float secondaryEnergySum = 0.0f;
|
||||
for (const auto& event : events)
|
||||
{
|
||||
if (event.events.empty()) continue;
|
||||
|
||||
float primaryEnergy = event.events[0].energy;
|
||||
|
||||
float secondaryEnergySum = 0.0f;
|
||||
for (size_t i = 1; i < event.events.size(); i++) {
|
||||
secondaryEnergySum += event.events[i].energy;
|
||||
if(eventId != event->eventId)
|
||||
{
|
||||
SurfacePoint point;
|
||||
point.primaryEnergy = primaryEnergy;
|
||||
point.secondaryEnergySum = secondaryEnergySum;
|
||||
point.count = 1;
|
||||
m_surfaceData.append(point);
|
||||
primaryEnergy = 0.0f;
|
||||
secondaryEnergySum = 0.0f;
|
||||
primaryEnergy = event->energy;
|
||||
eventId = event->eventId;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
secondaryEnergySum += event->energy;
|
||||
}
|
||||
SurfacePoint point;
|
||||
point.primaryEnergy = primaryEnergy;
|
||||
point.secondaryEnergySum = secondaryEnergySum;
|
||||
point.count = 1;
|
||||
|
||||
m_surfaceData.append(point);
|
||||
}
|
||||
ui->widget_3D->setSurfaceData(m_surfaceData);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,22 @@
|
|||
#include "csv.h"
|
||||
#include "CoincidenceSpectrumProcess.h"
|
||||
#include "MeasureAnalysisView.h"
|
||||
|
||||
#include <QVector>
|
||||
using namespace CoincidenceSpectrum;
|
||||
|
||||
namespace Ui {
|
||||
class ConformityAnalysis;
|
||||
}
|
||||
|
||||
typedef struct particleCoincidenceEvent
|
||||
{
|
||||
int eventId;//事件ID
|
||||
int board;//板卡号
|
||||
int channel;//通道号
|
||||
double energy;//能量
|
||||
qulonglong timeCounter;//时间计数
|
||||
}PARTICLECOINCIDENCEEVENT;
|
||||
|
||||
class ConformityAnalysis : public MeasureAnalysisView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -22,8 +31,8 @@ class ConformityAnalysis : public MeasureAnalysisView
|
|||
private:
|
||||
QMap<QString, int> m_FirstParticle;
|
||||
QMap<QString, int> m_subordinate;
|
||||
std::vector<F2t9Order::SpectrumData> m_beginVector;
|
||||
std::vector<F2t9Order::SpectrumData> m_secondVector;
|
||||
QVector<particleCoincidenceEvent*> m_beginVector;
|
||||
QVector<particleCoincidenceEvent*> m_secondVector;
|
||||
QVector<SurfacePoint> m_surfaceData;
|
||||
|
||||
public:
|
||||
|
|
@ -48,9 +57,9 @@ private:
|
|||
//统计每个板卡的初级粒子计数
|
||||
QMap<QString, int> statisticsFirstParticleQuantity();
|
||||
//处理当前板卡初级粒子信息
|
||||
std::vector<F2t9Order::CoincidenceEvent> handleBasicSubordinate(std::vector<F2t9Order::CoincidenceEvent> &eventData,int Board, int Channel);
|
||||
QVector<particleCoincidenceEvent*> handleBasicSubordinate(int Board, int Channel);
|
||||
//处理次级粒子信息
|
||||
QMap<QString,int> handleSubordinate(std::vector<F2t9Order::CoincidenceEvent> &eventData, int Board, int Channel);
|
||||
QMap<QString,int> handleSubordinate(QVector<particleCoincidenceEvent*> &eventData, int Board, int Channel);
|
||||
// 获取最大值
|
||||
int getMaxValue();
|
||||
//计算全部的初级粒子范围 和 次级粒子范围
|
||||
|
|
@ -60,7 +69,7 @@ private:
|
|||
//设置符合事件相关信息
|
||||
void setThreeUiData();
|
||||
//全部谱图数据处理
|
||||
void generateSurfaceData(const std::vector<F2t9Order::CoincidenceEvent>& events);
|
||||
void generateSurfaceData(const QVector<particleCoincidenceEvent*> events);
|
||||
|
||||
private:
|
||||
Ui::ConformityAnalysis *ui;
|
||||
|
|
@ -71,8 +80,7 @@ private:
|
|||
|
||||
int m_boardChannel[MAX_BOARD][MAX_CHANNEL];
|
||||
|
||||
|
||||
|
||||
QVector<particleCoincidenceEvent*> _spectrumDataList;//所有的能谱符合处理
|
||||
double m_dFirstStart = 0.0;//初级粒子起始能量
|
||||
double m_dFirstEnd = 0.0;//初级粒子终止能量
|
||||
double m_dSecondStart = 0.0;//初级粒子起始能量
|
||||
|
|
|
|||
|
|
@ -188,9 +188,9 @@ void ThreeDDisplay::_updateSurfaceData()
|
|||
m_dataProxy->resetArray(dataArray);
|
||||
|
||||
// 设置轴范围
|
||||
//m_surface->axisX()->setRange(minPrimary, maxPrimary);
|
||||
//m_surface->axisY()->setRange(0, getMaxCount(dataMatrix));
|
||||
//m_surface->axisZ()->setRange(minSecondary, maxSecondary);
|
||||
// m_surface->axisX()->setRange(minPrimary, maxPrimary);
|
||||
// m_surface->axisY()->setRange(0, getMaxCount(dataMatrix));
|
||||
// m_surface->axisZ()->setRange(minSecondary, maxSecondary);
|
||||
if (flag)
|
||||
{
|
||||
qDebug()<< maxPrimary << maxSecondary;
|
||||
|
|
@ -204,7 +204,13 @@ void ThreeDDisplay::_updateSurfaceData()
|
|||
|
||||
float ThreeDDisplay::getMaxCount(const QVector<QVector<float> > &dataMatrix)
|
||||
{
|
||||
return 0.0;
|
||||
float maxVal = 0;
|
||||
for (const auto& row : dataMatrix) {
|
||||
for (float val : row) {
|
||||
maxVal = std::max(maxVal, val);
|
||||
}
|
||||
}
|
||||
return maxVal + 1; // 加1以便显示
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -276,6 +282,7 @@ void ThreeDDisplay::_resetView()
|
|||
|
||||
void ThreeDDisplay::setSurfaceData(const QVector<SurfacePoint> &surfaceData)
|
||||
{
|
||||
m_surfaceData.clear();
|
||||
m_surfaceData = surfaceData;
|
||||
_updateSurfaceData();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user