replace OnlineEventBuilder with MultiBuilder. OnlineEventBuidler is obsolete

This commit is contained in:
splitPoleDAQ 2023-06-14 15:41:26 -04:00
parent b62f452d06
commit 0611cbe0ea
6 changed files with 63 additions and 26 deletions

View File

@ -11,8 +11,10 @@ Analyzer::Analyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent )
setWindowTitle("Online Analyzer");
setGeometry(0, 0, 1000, 800);
oeb = new OnlineEventBuilder * [nDigi];
for( unsigned int i = 0; i < nDigi; i++ ) oeb[i] = new OnlineEventBuilder(digi[i]);
//oeb = new OnlineEventBuilder * [nDigi];
//for( unsigned int i = 0; i < nDigi; i++ ) oeb[i] = new OnlineEventBuilder(digi[i]);
mb = new MultiBuilder(digi, nDigi);
buildTimerThread = new TimingThread(this);
buildTimerThread->SetWaitTimeinSec(1.0); //^Set event build interval
@ -29,13 +31,17 @@ Analyzer::Analyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent )
}
Analyzer::~Analyzer(){
for( unsigned int i = 0; i < nDigi; i++ ) delete oeb[i];
delete [] oeb;
// for( unsigned int i = 0; i < nDigi; i++ ) delete oeb[i];
// delete [] oeb;
delete mb;
}
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();
mb->ClearEvents();
buildTimerThread->start();
}
@ -49,9 +55,13 @@ void Analyzer::StopThread(){
void Analyzer::BuildEvents(){
//Set with digitizer to be event build
digiMTX[digiID].lock();
oeb[digiID]->BuildEvents(100, false);
digiMTX[digiID].unlock();
// digiMTX[digiID].lock();
// oeb[digiID]->BuildEvents(100, false);
// digiMTX[digiID].unlock();
for( unsigned int i = 0; i < nDigi; i++ ) digiMTX[digiID].lock();
mb->BuildEvents(0, 0, 0);
for( unsigned int i = 0; i < nDigi; i++ ) digiMTX[digiID].unlock();
}

View File

@ -15,7 +15,8 @@
#include "ClassDigitizer.h"
#include "CustomThreads.h"
#include "CustomWidgets.h"
#include "OnlineEventBuilder.h"
//#include "OnlineEventBuilder.h"
#include "MultiBuilder.h"
/**************************************
@ -42,7 +43,10 @@ public:
virtual void SetUpCanvas();
OnlineEventBuilder * GetEventBuilder() {return oeb[digiID];}
//OnlineEventBuilder * GetEventBuilder() {return oeb[digiID];}
MultiBuilder * GetEventBuilder() { return mb;}
public slots:
void StartThread();
@ -65,7 +69,10 @@ private:
int digiID; // the digi that will event
double waitTimeinSec;
OnlineEventBuilder ** oeb;
//OnlineEventBuilder ** oeb;
MultiBuilder * mb;
TimingThread * buildTimerThread;
};

View File

@ -36,6 +36,7 @@ HEADERS += ClassData.h \
Scope.h \
SingleSpectra.h \
OnlineEventBuilder.h \
MultiBuilder.h \
Analyser.h \
qcustomplot.h \
SplitPoleAnalyzer.h
@ -47,5 +48,6 @@ SOURCES += ClassDigitizer.cpp \
Scope.cpp \
SingleSpectra.cpp \
OnlineEventBuilder.cpp \
MultiBuilder.cpp \
Analyser.cpp \
qcustomplot.cpp

View File

@ -2,6 +2,18 @@
#include <algorithm>
MultiBuilder::MultiBuilder(Digitizer ** digi, unsigned int nDigi) : nData(nDigi){
data = new Data *[nData];
for( unsigned int i = 0; i < nData; i++){
data[i] = digi[i]->GetData();
typeList.push_back(digi[i]->GetDPPType());
timeWindow = 100;
ClearEvents();
}
}
MultiBuilder::MultiBuilder(Data ** inData, std::vector<int> type) : nData(type.size()){
data = inData;
typeList = type;

View File

@ -2,6 +2,7 @@
#define MuLTI_BUILDER_H
#include "ClassData.h"
#include "ClassDigitizer.h"
#define MaxNEvent 5000 // circular
@ -20,16 +21,16 @@ public:
Clear();
}
EventMember operator = (EventMember e){
bd = e.bd;
ch = e.ch;
energy = e.energy;
energy2 = e.energy2;
timestamp = e.timestamp;
fineTime = e.fineTime;
trace = e.trace;
return *this;
}
// EventMember operator = (EventMember e){
// bd = e.bd;
// ch = e.ch;
// energy = e.energy;
// energy2 = e.energy2;
// timestamp = e.timestamp;
// fineTime = e.fineTime;
// trace = e.trace;
// return *this;
// }
void Clear(){
bd = 0;
@ -47,6 +48,7 @@ public:
class MultiBuilder {
public:
MultiBuilder(Digitizer ** digi, unsigned int nDigi);
MultiBuilder(Data ** inData, std::vector<int> type);
~MultiBuilder();

View File

@ -27,7 +27,9 @@ public:
SetDigiID(0); // define which digitizer to build event
SetUpdateTimeInSec(1.0);
oeb = GetEventBuilder(); // get the event builder pointer from mother class;
//evtbder = GetEventBuilder(); // get the event builder pointer from mother class;
evtbder = GetEventBuilder();
SetUpCanvas();
}
@ -40,7 +42,8 @@ public slots:
private:
OnlineEventBuilder * oeb;
//OnlineEventBuilder * evtbder;
MultiBuilder *evtbder;
// declaie histograms
Histogram2D * h2;
@ -70,10 +73,10 @@ inline void SplitPole::UpdateHistograms(){
//oeb->PrintStat();
//============ Get events, and do analysis
long eventBuilt = oeb->eventBuilt;
long eventBuilt = evtbder->eventBuilt;
if( eventBuilt == 0 ) return;
long eventIndex = oeb->eventIndex;
long eventIndex = evtbder->eventIndex;
long eventStart = eventIndex - eventBuilt + 1;
if(eventStart < 0 ) eventStart += MaxNEvent;
@ -81,7 +84,8 @@ inline void SplitPole::UpdateHistograms(){
unsigned short e1 = 0, e2 = 0;
for( long i = eventStart ; i <= eventIndex; i ++ ){
std::vector<dataPoint> event = oeb->events[i];
//std::vector<dataPoint> event = evtbder->events[i];
std::vector<EventMember> event = evtbder->events[i];
for( int k = 0; k < (int) event.size(); k++ ){
if( event[k].ch == 9 ) e1 = event[k].energy;