combine SplitPoleAnalyzer.cpp/h into 1 single file

This commit is contained in:
splitPoleDAQ 2023-06-12 16:41:03 -04:00
parent 0b22ccc5ef
commit 922b09f89a
3 changed files with 66 additions and 75 deletions

View File

@ -48,5 +48,4 @@ SOURCES += ClassDigitizer.cpp \
SingleSpectra.cpp \
OnlineEventBuilder.cpp \
Analyser.cpp \
qcustomplot.cpp \
SplitPoleAnalyzer.cpp
qcustomplot.cpp

View File

@ -1,68 +0,0 @@
#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();
}

View File

@ -7,10 +7,10 @@
* It is a template for other analyzer.
*
* Any new analyzer add to added to FSUDAQ.cpp
* in FSUDAQ.cpp, in OpenAnalyzer()
* 1) add include header
* 2) in OpenAnalyzer(), change the new
*
* add the source files in FSUDAQ_Qt6.pro
* then compile
* add the source file in FSUDAQ_Qt6.pro then compile
* >qmake6 FSUDAQ_Qt6.pro
* >make
*
@ -22,8 +22,16 @@
class SplitPole : public Analyzer{
Q_OBJECT
public:
SplitPole(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr);
~SplitPole();
SplitPole(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
SetDigiID(0); // define which digitizer to build event
SetUpdateTimeInSec(1.0);
oeb = GetEventBuilder(); // get the event builder pointer from mother class;
SetUpCanvas();
}
/// ~SplitPole(); // comment out = defalt destructor
void SetUpCanvas();
@ -34,10 +42,62 @@ private:
OnlineEventBuilder * oeb;
// declaie histograms
Histogram2D * h2;
Histogram1D * h1;
};
inline 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("Split Pole PID", "x", "y", 400, 0, 10000, 400, 0, 10000, this);
//layout is inheriatge from Analyzer
layout->addWidget(h2, 0, 0);
h1 = new Histogram1D("Spectrum", "x", 400, 0, 10000, this);
layout->addWidget(h1, 0, 1);
}
inline void SplitPole::UpdateHistograms(){
BuildEvents(); // call the event builder to build events
//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();
}
#endif