it seems that all bugs are fixed for online analyzser

This commit is contained in:
splitPoleDAQ 2023-06-12 15:45:16 -04:00
parent 21f19b6ff7
commit 2dc0f494b3
4 changed files with 45 additions and 40 deletions

View File

@ -8,6 +8,9 @@ Analyzer::Analyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent )
this->digi = digi; this->digi = digi;
this->nDigi = nDigi; this->nDigi = nDigi;
setWindowTitle("Online Analyzer");
setGeometry(0, 0, 1000, 800);
oeb = new OnlineEventBuilder * [nDigi]; oeb = new OnlineEventBuilder * [nDigi];
for( unsigned int i = 0; i < nDigi; i++ ) oeb[i] = new OnlineEventBuilder(digi[i]); for( unsigned int i = 0; i < nDigi; i++ ) oeb[i] = new OnlineEventBuilder(digi[i]);
@ -15,9 +18,6 @@ Analyzer::Analyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent )
buildTimerThread->SetWaitTimeinSec(1.0); //^Set event build interval buildTimerThread->SetWaitTimeinSec(1.0); //^Set event build interval
connect( buildTimerThread, &TimingThread::timeUp, this, &Analyzer::UpdateHistograms); connect( buildTimerThread, &TimingThread::timeUp, this, &Analyzer::UpdateHistograms);
setWindowTitle("Online Analyzer");
setGeometry(0, 0, 1000, 800);
QWidget * layoutWidget = new QWidget(this); QWidget * layoutWidget = new QWidget(this);
setCentralWidget(layoutWidget); setCentralWidget(layoutWidget);
layout = new QGridLayout(layoutWidget); layout = new QGridLayout(layoutWidget);
@ -35,18 +35,20 @@ Analyzer::~Analyzer(){
} }
void Analyzer::StartThread(){ void Analyzer::StartThread(){
// printf("%s\n", __func__);
for( unsigned int i = 0; i < nDigi; i++) oeb[i]->ClearEvents(); for( unsigned int i = 0; i < nDigi; i++) oeb[i]->ClearEvents();
buildTimerThread->start(); buildTimerThread->start();
} }
void Analyzer::StopThread(){ void Analyzer::StopThread(){
// printf("%s\n", __func__);
buildTimerThread->Stop(); buildTimerThread->Stop();
buildTimerThread->quit(); buildTimerThread->quit();
buildTimerThread->wait(); buildTimerThread->wait();
} }
//^####################################### below are open to customization
void Analyzer::SetUpCanvas(){ void Analyzer::SetUpCanvas(){
setGeometry(0, 0, 1600, 800); setGeometry(0, 0, 1600, 800);
@ -57,17 +59,6 @@ void Analyzer::SetUpCanvas(){
h1 = new Histogram1D("testing", "x", 400, 0, 10000, this); h1 = new Histogram1D("testing", "x", 400, 0, 10000, this);
layout->addWidget(h1, 0, 1); layout->addWidget(h1, 0, 1);
// std::random_device rd;
// std::mt19937 gen(rd());
// std::normal_distribution<double> distribution(2000.0, 1000);
// for( int i = 0; i < 1000 ; i++ ){
// double x = distribution(gen);
// double y = distribution(gen);
// h2->Fill(x, y);
// h1->Fill(x);
// }
// h1->UpdatePlot();
} }
void Analyzer::UpdateHistograms(){ void Analyzer::UpdateHistograms(){
@ -77,7 +68,7 @@ void Analyzer::UpdateHistograms(){
oeb[0]->BuildEvents(100, false); oeb[0]->BuildEvents(100, false);
digiMTX[0].unlock(); digiMTX[0].unlock();
oeb[0]->PrintStat(); //oeb[0]->PrintStat();
//============ Get events, and do analysis //============ Get events, and do analysis
long eventBuilt = oeb[0]->eventBuilt; long eventBuilt = oeb[0]->eventBuilt;

View File

@ -14,7 +14,7 @@
#include "CAENDigitizerType.h" #include "CAENDigitizerType.h"
#include "macro.h" #include "macro.h"
#define MaxNData 50 /// store 10k events per channels #define MaxNData 10000 /// store 10k events per channels
class Data{ class Data{

View File

@ -47,9 +47,12 @@ public:
QCPColorGradient color; QCPColorGradient color;
color.clearColorStops(); color.clearColorStops();
color.setColorStopAt( 0.0, QColor("white" )); color.setColorStopAt( 0.0, QColor("white" ));
color.setColorStopAt( 0.3, QColor("blue")); color.setColorStopAt( 0.0001, QColor("purple" ));
color.setColorStopAt( 0.4, QColor("green")); color.setColorStopAt( 0.2, QColor("blue"));
color.setColorStopAt( 1.0, QColor("yellow")); color.setColorStopAt( 0.4, QColor("cyan"));
color.setColorStopAt( 0.6, QColor("green"));
color.setColorStopAt( 0.8, QColor("yellow"));
color.setColorStopAt( 1.0, QColor("red"));
colorMap->setGradient(color); colorMap->setGradient(color);
double xPosStart = 0.02; double xPosStart = 0.02;
@ -165,11 +168,13 @@ public:
yAxis->setRangeUpper(yMax); yAxis->setRangeUpper(yMax);
replot(); replot();
usingMenu = false; usingMenu = false;
return;
} }
if( selectedAction == a2 ) { if( selectedAction == a2 ) {
Clear(); Clear();
usingMenu = false; usingMenu = false;
return;
} }
if( selectedAction == a3 ){ if( selectedAction == a3 ){
@ -181,11 +186,13 @@ public:
} }
replot(); replot();
usingMenu = false; usingMenu = false;
return;
} }
if( selectedAction == a4){ if( selectedAction == a4){
rightMouseClickRebin(); rightMouseClickRebin();
usingMenu = false; usingMenu = false;
return;
} }
if( selectedAction == a5 ){ if( selectedAction == a5 ){
@ -194,6 +201,7 @@ public:
isDrawCut= true; isDrawCut= true;
usingMenu = false; usingMenu = false;
numCut ++; numCut ++;
return;
} }
if( selectedAction && numCut > 0 && selectedAction->text().contains("Delete ") ){ if( selectedAction && numCut > 0 && selectedAction->text().contains("Delete ") ){
@ -230,27 +238,12 @@ public:
cutNameList.clear(); cutNameList.clear();
cutEntryList.clear(); cutEntryList.clear();
} }
return;
} }
if( selectedAction && numCut > 0 && selectedAction->text().contains("Clear all Cuts") ){ if( selectedAction && numCut > 0 && selectedAction->text().contains("Clear all Cuts") ){
numCut = 0; ClearAllCuts();
tempCutID = -1; return;
lastPlottableID = -1;
cutList.clear();
cutIDList.clear();
for( int i = cutTextIDList.count() - 1; i >= 0 ; i--){
if( cutTextIDList[i] < 0 ) continue;
removeItem(cutTextIDList[i]);
removePlottable(plottableIDList[i]);
}
replot();
cutTextIDList.clear();
plottableIDList.clear();
cutNameList.clear();
cutEntryList.clear();
} }
if( selectedAction && numCut > 0 && selectedAction->text().contains("Add/Edit names to Cuts") ){ if( selectedAction && numCut > 0 && selectedAction->text().contains("Add/Edit names to Cuts") ){
@ -276,6 +269,7 @@ public:
}); });
} }
dialog.exec(); dialog.exec();
return;
} }
}///================= end of right click }///================= end of right click
@ -357,6 +351,7 @@ public:
txt[i][j]->setText("0"); txt[i][j]->setText("0");
} }
} }
colorMap->data()->clear();
UpdatePlot(); UpdatePlot();
} }
@ -414,6 +409,25 @@ public:
//qDebug() << "Plottable count : " << plottableCount() << ", cutList.count :" << cutList.count() << ", cutID :" << lastPlottableID; //qDebug() << "Plottable count : " << plottableCount() << ", cutList.count :" << cutList.count() << ", cutID :" << lastPlottableID;
} }
void ClearAllCuts(){
numCut = 0;
tempCutID = -1;
lastPlottableID = -1;
cutList.clear();
cutIDList.clear();
for( int i = cutTextIDList.count() - 1; i >= 0 ; i--){
if( cutTextIDList[i] < 0 ) continue;
removeItem(cutTextIDList[i]);
removePlottable(plottableIDList[i]);
}
replot();
cutTextIDList.clear();
plottableIDList.clear();
cutNameList.clear();
cutEntryList.clear();
}
QList<QPolygonF> GetCutList() const{return cutList;} // this list may contain empty element QList<QPolygonF> GetCutList() const{return cutList;} // this list may contain empty element
QList<int> GetCutEntryList() const{ return cutEntryList;} QList<int> GetCutEntryList() const{ return cutEntryList;}
void PrintCutEntry() const{ void PrintCutEntry() const{

View File

@ -14,7 +14,7 @@ Use another class to hold the event data and methods.
#include "macro.h" #include "macro.h"
#include "ClassDigitizer.h" #include "ClassDigitizer.h"
#define MaxNEvent 30 #define MaxNEvent 5000
struct dataPoint{ struct dataPoint{
unsigned short ch; unsigned short ch;