added SplitPoleAnalyzer.h

This commit is contained in:
splitPoleDAQ 2023-06-12 16:32:01 -04:00
parent 2dc0f494b3
commit 0b22ccc5ef
6 changed files with 140 additions and 55 deletions

View File

@ -26,7 +26,6 @@ Analyzer::Analyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent )
// QPushButton * bnSetting = new QPushButton("Settings", this); // QPushButton * bnSetting = new QPushButton("Settings", this);
// layout->addWidget(bnSetting); // layout->addWidget(bnSetting);
SetUpCanvas();
} }
Analyzer::~Analyzer(){ Analyzer::~Analyzer(){
@ -47,56 +46,22 @@ void Analyzer::StopThread(){
buildTimerThread->wait(); buildTimerThread->wait();
} }
void Analyzer::BuildEvents(){
//Set with digitizer to be event build
digiMTX[digiID].lock();
oeb[digiID]->BuildEvents(100, false);
digiMTX[digiID].unlock();
}
//^####################################### below are open to customization //^####################################### below are open to customization
void Analyzer::SetUpCanvas(){ void Analyzer::SetUpCanvas(){
setGeometry(0, 0, 1600, 800);
h2 = new Histogram2D("testing", "x", "y", 400, 0, 10000, 400, 0, 10000, this);
layout->addWidget(h2, 0, 0);
h1 = new Histogram1D("testing", "x", 400, 0, 10000, this);
layout->addWidget(h1, 0, 1);
} }
void Analyzer::UpdateHistograms(){ void Analyzer::UpdateHistograms(){
//Set with digitizer to be event build
digiMTX[0].lock();
oeb[0]->BuildEvents(100, false);
digiMTX[0].unlock();
//oeb[0]->PrintStat();
//============ Get events, and do analysis
long eventBuilt = oeb[0]->eventBuilt;
if( eventBuilt == 0 ) return;
long eventIndex = oeb[0]->eventIndex;
long eventStart = eventIndex - eventBuilt + 1;
if(eventStart < 0 ) eventStart += MaxNEvent;
unsigned short e1 = 0, e2 = 0;
for( long i = eventStart ; i <= eventIndex; i ++ ){
std::vector<dataPoint> event = oeb[0]->events[i];
for( int k = 0; k < (int) event.size(); k++ ){
if( event[k].ch == 9 ) e1 = event[k].energy;
if( event[k].ch == 10 ) e2 = event[k].energy;
}
h2->Fill(e1, e2);
h1->Fill(e1);
}
h2->UpdatePlot();
h1->UpdatePlot();
h2->PrintCutEntry();
} }

View File

@ -42,27 +42,31 @@ public:
virtual void SetUpCanvas(); virtual void SetUpCanvas();
OnlineEventBuilder * GetEventBuilder() {return oeb[digiID];}
public slots: public slots:
void StartThread(); void StartThread();
void StopThread(); void StopThread();
virtual void UpdateHistograms(); // where event-building, analysis, and ploting
private slots: private slots:
virtual void UpdateHistograms(); // where event-building, analysis, and ploting
protected:
QGridLayout * layout;
void BuildEvents();
void SetDigiID(int ID) { digiID = ID;}
void SetUpdateTimeInSec(double sec = 1.0) {waitTimeinSec = sec; buildTimerThread->SetWaitTimeinSec(waitTimeinSec);}
private: private:
Digitizer ** digi; Digitizer ** digi;
unsigned short nDigi; unsigned short nDigi;
int digiID; // the digi that will event
double waitTimeinSec;
OnlineEventBuilder ** oeb; OnlineEventBuilder ** oeb;
TimingThread * buildTimerThread; TimingThread * buildTimerThread;
QGridLayout * layout;
//======================== custom histograms
Histogram2D * h2;
Histogram1D * h1;
}; };
#endif #endif

View File

@ -14,6 +14,8 @@
#include <QProcess> #include <QProcess>
#include <QMessageBox> #include <QMessageBox>
#include "SplitPoleAnalyzer.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
setWindowTitle("FSU DAQ"); setWindowTitle("FSU DAQ");
@ -1127,7 +1129,8 @@ void MainWindow::OpenCanvas(){
void MainWindow::OpenAnalyzer(){ void MainWindow::OpenAnalyzer(){
if( onlineAnalyzer == nullptr ) { if( onlineAnalyzer == nullptr ) {
onlineAnalyzer = new Analyzer(digi, nDigi); //onlineAnalyzer = new Analyzer(digi, nDigi);
onlineAnalyzer = new SplitPole(digi, nDigi);
onlineAnalyzer->show(); onlineAnalyzer->show();
}else{ }else{
onlineAnalyzer->show(); onlineAnalyzer->show();

View File

@ -37,7 +37,8 @@ HEADERS += ClassData.h \
SingleSpectra.h \ SingleSpectra.h \
OnlineEventBuilder.h \ OnlineEventBuilder.h \
Analyser.h \ Analyser.h \
qcustomplot.h qcustomplot.h \
SplitPoleAnalyzer.h
SOURCES += ClassDigitizer.cpp \ SOURCES += ClassDigitizer.cpp \
DigiSettingsPanel.cpp \ DigiSettingsPanel.cpp \
FSUDAQ.cpp \ FSUDAQ.cpp \
@ -47,4 +48,5 @@ SOURCES += ClassDigitizer.cpp \
SingleSpectra.cpp \ SingleSpectra.cpp \
OnlineEventBuilder.cpp \ OnlineEventBuilder.cpp \
Analyser.cpp \ Analyser.cpp \
qcustomplot.cpp qcustomplot.cpp \
SplitPoleAnalyzer.cpp

68
SplitPoleAnalyzer.cpp Normal file
View File

@ -0,0 +1,68 @@
#include "SplitPoleAnalyzer.h"
SplitPole::SplitPole(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent): Analyzer(digi, nDigi, parent){
SetDigiID(0);
SetUpdateTimeInSec(1.0);
oeb = GetEventBuilder();
SetUpCanvas();
}
SplitPole::~SplitPole(){
}
void SplitPole::SetUpCanvas(){
setGeometry(0, 0, 1600, 800);
// the "this" make the histogram a child of the SplitPole class. When SplitPole destory, all childs destory as well.
h2 = new Histogram2D("testing", "x", "y", 400, 0, 10000, 400, 0, 10000, this);
//layout is inheriatge from Analyzer
layout->addWidget(h2, 0, 0);
h1 = new Histogram1D("testing", "x", 400, 0, 10000, this);
layout->addWidget(h1, 0, 1);
}
void SplitPole::UpdateHistograms(){
BuildEvents();
//oeb->PrintStat();
//============ Get events, and do analysis
long eventBuilt = oeb->eventBuilt;
if( eventBuilt == 0 ) return;
long eventIndex = oeb->eventIndex;
long eventStart = eventIndex - eventBuilt + 1;
if(eventStart < 0 ) eventStart += MaxNEvent;
//============ Processing data and fill histograms
unsigned short e1 = 0, e2 = 0;
for( long i = eventStart ; i <= eventIndex; i ++ ){
std::vector<dataPoint> event = oeb->events[i];
for( int k = 0; k < (int) event.size(); k++ ){
if( event[k].ch == 9 ) e1 = event[k].energy;
if( event[k].ch == 10 ) e2 = event[k].energy;
}
h2->Fill(e1, e2);
h1->Fill(e1);
}
h2->UpdatePlot();
h1->UpdatePlot();
h2->PrintCutEntry();
}

43
SplitPoleAnalyzer.h Normal file
View File

@ -0,0 +1,43 @@
#ifndef SPLITPOLEANLAYZER_H
#define SPLITPOLEANLAYZER_H
/*********************************************
* This is online analyzer for Split-Pole at FSU
*
* It is a template for other analyzer.
*
* Any new analyzer add to added to FSUDAQ.cpp
* in FSUDAQ.cpp, in OpenAnalyzer()
*
* add the source files in FSUDAQ_Qt6.pro
* then compile
* >qmake6 FSUDAQ_Qt6.pro
* >make
*
* ******************************************/
#include "Analyser.h"
class SplitPole : public Analyzer{
Q_OBJECT
public:
SplitPole(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr);
~SplitPole();
void SetUpCanvas();
public slots:
void UpdateHistograms();
private:
OnlineEventBuilder * oeb;
Histogram2D * h2;
Histogram1D * h1;
};
#endif