add software Trapezoide filter, updated SplitPoleAnalyzer UI
This commit is contained in:
parent
f1e6034128
commit
b1d0253e4f
20
FSUDAQ.h
20
FSUDAQ.h
|
@ -28,10 +28,22 @@ public:
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
void closeEvent(QCloseEvent * event){
|
void closeEvent(QCloseEvent * event){
|
||||||
if( scope ) scope->close();
|
if( scope ) {
|
||||||
if( digiSettings ) digiSettings->close();
|
delete scope;
|
||||||
if( canvas ) canvas->close();
|
scope = nullptr;
|
||||||
if( onlineAnalyzer ) onlineAnalyzer->close();
|
}
|
||||||
|
if( digiSettings ) {
|
||||||
|
delete digiSettings;
|
||||||
|
digiSettings = nullptr;
|
||||||
|
}
|
||||||
|
if( canvas ) {
|
||||||
|
delete canvas;
|
||||||
|
canvas = nullptr;
|
||||||
|
}
|
||||||
|
if( onlineAnalyzer ) {
|
||||||
|
delete onlineAnalyzer;
|
||||||
|
onlineAnalyzer = nullptr;
|
||||||
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
65
Scope.cpp
65
Scope.cpp
|
@ -6,6 +6,44 @@
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
|
QVector<QPointF> Scope::TrapezoidFilter(QVector<QPointF> data, int baseLineEndS, int riseTimeS, int flatTopS, float decayTime_ns){
|
||||||
|
|
||||||
|
QVector<QPointF> trapezoid;
|
||||||
|
trapezoid.clear();
|
||||||
|
|
||||||
|
///find baseline;
|
||||||
|
double baseline = 0;
|
||||||
|
for( int i = 0; i < baseLineEndS; i++){
|
||||||
|
baseline += data[i].y();
|
||||||
|
}
|
||||||
|
baseline = baseline*1./baseLineEndS;
|
||||||
|
|
||||||
|
int length = data.size();
|
||||||
|
|
||||||
|
double pn = 0.;
|
||||||
|
double sn = 0.;
|
||||||
|
for( int i = 0; i < length ; i++){
|
||||||
|
|
||||||
|
double dlk = data[i].y() - baseline;
|
||||||
|
if( i - riseTimeS >= 0 ) dlk -= data[i - riseTimeS].y() - baseline;
|
||||||
|
if( i - flatTopS - riseTimeS >= 0 ) dlk -= data[i - flatTopS - riseTimeS].y() - baseline;
|
||||||
|
if( i - flatTopS - 2*riseTimeS >= 0) dlk += data[i - flatTopS - 2*riseTimeS].y() - baseline;
|
||||||
|
|
||||||
|
if( i == 0 ){
|
||||||
|
pn = dlk;
|
||||||
|
sn = pn + dlk*decayTime_ns;
|
||||||
|
}else{
|
||||||
|
pn = pn + dlk;
|
||||||
|
sn = sn + pn + dlk*decayTime_ns;
|
||||||
|
}
|
||||||
|
|
||||||
|
trapezoid.append(QPointF(data[i].x(), sn / decayTime_ns / riseTimeS));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return trapezoid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow * parent) : QMainWindow(parent){
|
Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow * parent) : QMainWindow(parent){
|
||||||
|
|
||||||
|
@ -29,6 +67,31 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
|
||||||
plot->addSeries(dataTrace[i]);
|
plot->addSeries(dataTrace[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// testing software trapezoid filter
|
||||||
|
// FILE * fileIn = fopen("wave.txt", "r");
|
||||||
|
// if( fileIn != nullptr ){
|
||||||
|
|
||||||
|
// char buf[500];
|
||||||
|
// int v1, v2;
|
||||||
|
|
||||||
|
// QVector<QPointF> points;
|
||||||
|
// QVector<QPointF> points1;
|
||||||
|
// while( fgets(buf, sizeof(buf), fileIn) != nullptr ){
|
||||||
|
|
||||||
|
// if (sscanf(buf, "%d, %d", &v1, &v2) == 2) {
|
||||||
|
// points.append(QPointF(v1, v2 + 7000));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// fclose(fileIn);
|
||||||
|
|
||||||
|
// points1 = TrapezoidFilter(points, 400/16, 100, 200, 1000);
|
||||||
|
|
||||||
|
// dataTrace[0]->replace(points);
|
||||||
|
// dataTrace[1]->replace(points1);
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
dataTrace[0]->setPen(QPen(Qt::red, 2));
|
dataTrace[0]->setPen(QPen(Qt::red, 2));
|
||||||
dataTrace[1]->setPen(QPen(Qt::blue, 2));
|
dataTrace[1]->setPen(QPen(Qt::blue, 2));
|
||||||
dataTrace[2]->setPen(QPen(Qt::darkYellow, 1));
|
dataTrace[2]->setPen(QPen(Qt::darkYellow, 1));
|
||||||
|
@ -955,7 +1018,7 @@ void Scope::UpdateSpinBox(RSpinBox * &sb, const Reg para){
|
||||||
void Scope::UpdatePanelFromMomeory(){
|
void Scope::UpdatePanelFromMomeory(){
|
||||||
|
|
||||||
enableSignalSlot = false;
|
enableSignalSlot = false;
|
||||||
printf("==== %s \n", __func__);
|
printf("==== Scope::%s \n", __func__);
|
||||||
|
|
||||||
int ch = cbScopeCh->currentIndex();
|
int ch = cbScopeCh->currentIndex();
|
||||||
|
|
||||||
|
|
2
Scope.h
2
Scope.h
|
@ -37,6 +37,8 @@ public:
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<QPointF> TrapezoidFilter(QVector<QPointF> data, int baseLineEndS, int riseTimeS, int flatTopS, float decayTime_ns );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void StartScope();
|
void StartScope();
|
||||||
void StopScope();
|
void StopScope();
|
||||||
|
|
|
@ -51,7 +51,9 @@ public:
|
||||||
|
|
||||||
hit.CalZoffset(sbBfield->value());
|
hit.CalZoffset(sbBfield->value());
|
||||||
|
|
||||||
hit.Clear();
|
FillConstants();
|
||||||
|
|
||||||
|
hit.ClearData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,11 +94,14 @@ private:
|
||||||
QLineEdit * leGSRho;
|
QLineEdit * leGSRho;
|
||||||
QLineEdit * leZoffset;
|
QLineEdit * leZoffset;
|
||||||
|
|
||||||
|
RSpinBox * sbRhoOffset;
|
||||||
|
RSpinBox * sbRhoScale;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void SplitPole::FillConstants(){
|
inline void SplitPole::FillConstants(){
|
||||||
leQValue->setText(QString::number(hit.GetQ0()));
|
leQValue->setText(QString::number(hit.GetQ0()));
|
||||||
leGSRho->setText(QString::number(hit.GetRho0()));
|
leGSRho->setText(QString::number(hit.GetRho0()*1000));
|
||||||
leZoffset->setText(QString::number(hit.GetZoffset()));
|
leZoffset->setText(QString::number(hit.GetZoffset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,34 +216,66 @@ inline void SplitPole::SetUpCanvas(){
|
||||||
boxLayout->addWidget(runAnalyzer, 4, 1);
|
boxLayout->addWidget(runAnalyzer, 4, 1);
|
||||||
|
|
||||||
|
|
||||||
|
QFrame *separator = new QFrame(box);
|
||||||
|
separator->setFrameShape(QFrame::HLine);
|
||||||
|
separator->setFrameShadow(QFrame::Sunken);
|
||||||
|
boxLayout->addWidget(separator, 5, 0, 1, 4);
|
||||||
|
|
||||||
|
|
||||||
QLabel * lbMassTablePath = new QLabel("Mass Table Path : ", box);
|
QLabel * lbMassTablePath = new QLabel("Mass Table Path : ", box);
|
||||||
lbMassTablePath->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
lbMassTablePath->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||||
boxLayout->addWidget(lbMassTablePath, 5, 0);
|
boxLayout->addWidget(lbMassTablePath, 6, 0);
|
||||||
leMassTablePath = new QLineEdit(QString::fromStdString(massData),box);
|
leMassTablePath = new QLineEdit(QString::fromStdString(massData),box);
|
||||||
leMassTablePath->setEnabled(false);
|
leMassTablePath->setReadOnly(true);
|
||||||
boxLayout->addWidget(leMassTablePath, 5, 1, 1, 3);
|
boxLayout->addWidget(leMassTablePath, 6, 1, 1, 3);
|
||||||
|
|
||||||
QLabel * lbQValue = new QLabel("Q-Value [MeV] ", box);
|
QLabel * lbQValue = new QLabel("Q-Value [MeV] ", box);
|
||||||
lbQValue->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
lbQValue->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||||
boxLayout->addWidget(lbQValue, 6, 0);
|
boxLayout->addWidget(lbQValue, 7, 0);
|
||||||
leQValue = new QLineEdit(box);
|
leQValue = new QLineEdit(box);
|
||||||
leQValue->setEnabled(false);
|
leQValue->setReadOnly(true);
|
||||||
boxLayout->addWidget(leQValue, 6, 1);
|
boxLayout->addWidget(leQValue, 7, 1);
|
||||||
|
|
||||||
QLabel * lbGDRho = new QLabel("G.S. Rho [mm] ", box);
|
QLabel * lbGDRho = new QLabel("G.S. Rho [mm] ", box);
|
||||||
lbGDRho->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
lbGDRho->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||||
boxLayout->addWidget(lbGDRho, 6, 2);
|
boxLayout->addWidget(lbGDRho, 7, 2);
|
||||||
leGSRho = new QLineEdit(box);
|
leGSRho = new QLineEdit(box);
|
||||||
leGSRho->setEnabled(false);
|
leGSRho->setReadOnly(true);
|
||||||
boxLayout->addWidget(leGSRho, 6, 3);
|
boxLayout->addWidget(leGSRho, 7, 3);
|
||||||
|
|
||||||
QLabel * lbZoffset = new QLabel("Z-offset [mm] ", box);
|
QLabel * lbZoffset = new QLabel("Z-offset [mm] ", box);
|
||||||
lbZoffset->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
lbZoffset->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||||
boxLayout->addWidget(lbZoffset, 7, 0);
|
boxLayout->addWidget(lbZoffset, 8, 0);
|
||||||
leZoffset = new QLineEdit(box);
|
leZoffset = new QLineEdit(box);
|
||||||
leZoffset->setEnabled(false);
|
leZoffset->setReadOnly(true);
|
||||||
boxLayout->addWidget(leZoffset, 7, 1);
|
boxLayout->addWidget(leZoffset, 8, 1);
|
||||||
|
|
||||||
|
|
||||||
|
QFrame *separator1 = new QFrame(box);
|
||||||
|
separator1->setFrameShape(QFrame::HLine);
|
||||||
|
separator1->setFrameShadow(QFrame::Sunken);
|
||||||
|
boxLayout->addWidget(separator1, 9, 0, 1, 4);
|
||||||
|
|
||||||
|
|
||||||
|
QLabel * lbRhoOffset = new QLabel("Rho-offset [mm] ", box);
|
||||||
|
lbRhoOffset->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||||
|
boxLayout->addWidget(lbRhoOffset, 10, 0);
|
||||||
|
sbRhoOffset = new RSpinBox(box);
|
||||||
|
sbRhoOffset->setDecimals(2);
|
||||||
|
sbRhoOffset->setSingleStep(1);
|
||||||
|
sbRhoOffset->setValue(0);
|
||||||
|
boxLayout->addWidget(sbRhoOffset, 10, 1);
|
||||||
|
|
||||||
|
QLabel * lbRhoScale = new QLabel("Rho-Scaling ", box);
|
||||||
|
lbRhoScale->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||||
|
boxLayout->addWidget(lbRhoScale, 10, 2);
|
||||||
|
sbRhoScale = new RSpinBox(box);
|
||||||
|
sbRhoScale->setDecimals(2);
|
||||||
|
sbRhoScale->setSingleStep(0.01);
|
||||||
|
sbRhoScale->setMinimum(0.5);
|
||||||
|
sbRhoScale->setMaximum(1.5);
|
||||||
|
sbRhoScale->setValue(1.0);
|
||||||
|
boxLayout->addWidget(sbRhoScale, 10, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
//============ histograms
|
//============ histograms
|
||||||
|
@ -255,7 +292,7 @@ inline void SplitPole::SetUpCanvas(){
|
||||||
h1->AddDataList("Test", Qt::red); // add another histogram in h1, Max Data List is 10
|
h1->AddDataList("Test", Qt::red); // add another histogram in h1, Max Data List is 10
|
||||||
layout->addWidget(h1, 1, 1);
|
layout->addWidget(h1, 1, 1);
|
||||||
|
|
||||||
h1g = new Histogram1D("Spectrum (gated)", "x", 300, 30, 70, this);
|
h1g = new Histogram1D("Spectrum (PID gated)", "Ex", 300, -2, 10, this);
|
||||||
layout->addWidget(h1g, 2, 1);
|
layout->addWidget(h1g, 2, 1);
|
||||||
|
|
||||||
layout->setColumnStretch(0, 1);
|
layout->setColumnStretch(0, 1);
|
||||||
|
@ -293,7 +330,7 @@ inline void SplitPole::UpdateHistograms(){
|
||||||
//if( event.size() < 9 ) return;
|
//if( event.size() < 9 ) return;
|
||||||
if( event.size() == 0 ) return;
|
if( event.size() == 0 ) return;
|
||||||
|
|
||||||
hit.Clear();
|
hit.ClearData();
|
||||||
|
|
||||||
for( int k = 0; k < (int) event.size(); k++ ){
|
for( int k = 0; k < (int) event.size(); k++ ){
|
||||||
//event[k].Print();
|
//event[k].Print();
|
||||||
|
|
|
@ -61,7 +61,7 @@ class SplitPoleHit{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SplitPoleHit(){
|
SplitPoleHit(){
|
||||||
Clear();
|
ClearData();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int eSR; unsigned long long tSR;
|
unsigned int eSR; unsigned long long tSR;
|
||||||
|
@ -163,7 +163,7 @@ public:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear(){
|
void ClearData(){
|
||||||
eSR = 0; tSR = 0;
|
eSR = 0; tSR = 0;
|
||||||
eSL = 0; tSL = 0;
|
eSL = 0; tSL = 0;
|
||||||
eFR = 0; tFR = 0;
|
eFR = 0; tFR = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user