This commit is contained in:
splitPoleDAQ 2023-05-30 10:08:39 -04:00
parent 5b58083fb3
commit c8a2912182
8 changed files with 64 additions and 19 deletions

View File

@ -152,6 +152,7 @@
"variant": "cpp",
"qmainwindow": "cpp",
"qchartview": "cpp",
"qthread": "cpp"
"qthread": "cpp",
"qrandomgenerator": "cpp"
}
}

View File

@ -836,6 +836,8 @@ void MainWindow::StartACQ(){
bnStopACQ->setEnabled(true);
bnOpenScope->setEnabled(false);
if( onlineAnalyzer ) onlineAnalyzer->StartThread();
{//^=== elog and database
if( influx ){
influx->AddDataPoint("RunID value=" + std::to_string(runID));
@ -888,6 +890,8 @@ void MainWindow::StopACQ(){
scalarThread->wait();
}
if( onlineAnalyzer ) onlineAnalyzer->StopThread();
if( histThread->isRunning()){
histThread->Stop();
histThread->quit();

View File

@ -6,13 +6,11 @@ TEMPLATE = app
TARGET = FSUDAQ_Qt6
INCLUDEPATH += .
#QT += core widgets charts webenginewidgets
QT += core widgets charts
#QMAKE_CXXFLAGS += `root-config --cflags --glibs`
#LIBS += -lCAENDigitizer `root-config --cflags --glibs`
QMAKE_CXXFLAGS += -g
LIBS += -lCAENDigitizer -lcurl
QMAKE_CXXFLAGS += -g `root-config --cflags --glibs`
LIBS += -lCAENDigitizer -lcurl `root-config --cflags --glibs`
# You can make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.

View File

@ -38,30 +38,38 @@ OnlineAnalyzer::~OnlineAnalyzer(){
}
void OnlineAnalyzer::StartThread(){
buildTimerThread->start();
}
void OnlineAnalyzer::StopThread(){
buildTimerThread->Stop();
buildTimerThread->quit();
buildTimerThread->wait();
}
void OnlineAnalyzer::SetUpCanvas(){
//TODO a simple way to set it at once
Histogram2D * h2 = new Histogram2D("testing", -10, 10, -10, 10);
h2 = new Histogram2D("testing", 0, 4000, 0, 4000);
RChartView * h2View = new RChartView(h2->GetChart());
h2View->SetVRange(-10, 10); // this only set the reset key 'r'
h2View->SetHRange(-10, 10);
h2->SetMarkerSize(2);
h2View->SetVRange(0, 4000); // this only set the reset key 'r'
h2View->SetHRange(0, 4000);
layout->addWidget(h2View);
std::random_device rd;
std::mt19937 gen(rd());
std::normal_distribution<double> distribution(0.0, 2.0);
for( int i = 0; i < 1000 ; i++ ){
h2->Fill(distribution(gen), distribution(gen));
}
//Histogram * h1 = new Histogram("h1", 0, 5000, 200);
// std::random_device rd;
// std::mt19937 gen(rd());
// std::normal_distribution<double> distribution(0.0, 2.0);
// for( int i = 0; i < 1000 ; i++ ){
// h2->Fill(distribution(gen), distribution(gen));
// }
}
@ -69,10 +77,34 @@ void OnlineAnalyzer::UpdateHistograms(){
//Set with digitizer to be event build
digiMTX[0].lock();
oeb[0]->BuildEvents(100);
//digi[0]->GetData()->PrintAllData();
oeb[0]->BuildEvents(100, true);
digiMTX[0].unlock();
//============ Get events, and do analysis
long eventBuilt = oeb[0]->eventbuilt;
printf("------------- eventBuilt %ld \n", 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;
int count = 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 == 3 ) e1 = event[k].energy;
if( event[k].ch == 4 ) e2 = event[k].energy;
}
h2->Fill(e1, e2);
count ++;
if( count > 500 ) break;
}
}

View File

@ -34,7 +34,7 @@ derivative class should define the SetUpCanvas() and UpdateHistogram();
//^==============================================
//^==============================================
class Histogram2D{
class Histogram2D{ //TODO, cannot handle more then 3000 datapoint
public:
Histogram2D(QString title, double xMin, double xMax, double yMin, double yMax){
@ -114,5 +114,8 @@ private:
QGridLayout * layout;
//======================== custom histograms
Histogram2D * h2;
};
#endif

View File

@ -79,11 +79,15 @@ void OnlineEventBuilder::BuildEvents(unsigned short timeWindow, bool verbose){
if( earlistCh == -1 || nExhaushedCh == nCh) return; /// no data
eventbuilt = 0;
//======= Start building event
do{
eventIndex ++;
if( eventIndex >= MaxNEvent ) eventIndex = 0;
eventbuilt ++;
unsigned long long dT =0;
dataPoint dp = {0, 0, 0};

View File

@ -31,6 +31,7 @@ public:
void BuildEvents(unsigned short timeWindow, bool verbose = false);
long eventIndex;
long eventbuilt;
std::vector<dataPoint> events[MaxNEvent]; // should be a cirular memory, store energy
unsigned short GetTimeWindow() const { return timeWindow;}

View File

@ -16,12 +16,14 @@ CAENCOmm_v1.5.3
CAENDigitizer_v2.17.1
`sudo apt install qt6-base-dev libcurl4-openssl-dev libqt6charts6-dev elog`
`sudo apt install qt6-base-dev libcurl4-openssl-dev libqt6charts6-dev qt6-webengine-dev elog`
The elog installed using apt is 3.1.3. If a higher version is needed. Please go to https://elog.psi.ch/elog/
The libcurl4 is need for pushing data to InfluxDB v1.8
# Compile
use `qmake6 -project ` to generate the *.pro