From 922b09f89ac3778d5ccca624f7aef7355b69ebf9 Mon Sep 17 00:00:00 2001 From: splitPoleDAQ Date: Mon, 12 Jun 2023 16:41:03 -0400 Subject: [PATCH] combine SplitPoleAnalyzer.cpp/h into 1 single file --- FSUDAQ_Qt6.pro | 3 +- SplitPoleAnalyzer.cpp | 68 ----------------------------------------- SplitPoleAnalyzer.h | 70 +++++++++++++++++++++++++++++++++++++++---- 3 files changed, 66 insertions(+), 75 deletions(-) delete mode 100644 SplitPoleAnalyzer.cpp diff --git a/FSUDAQ_Qt6.pro b/FSUDAQ_Qt6.pro index 4e24d7a..f13dea1 100644 --- a/FSUDAQ_Qt6.pro +++ b/FSUDAQ_Qt6.pro @@ -48,5 +48,4 @@ SOURCES += ClassDigitizer.cpp \ SingleSpectra.cpp \ OnlineEventBuilder.cpp \ Analyser.cpp \ - qcustomplot.cpp \ - SplitPoleAnalyzer.cpp + qcustomplot.cpp diff --git a/SplitPoleAnalyzer.cpp b/SplitPoleAnalyzer.cpp deleted file mode 100644 index 454ccde..0000000 --- a/SplitPoleAnalyzer.cpp +++ /dev/null @@ -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 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(); - -} \ No newline at end of file diff --git a/SplitPoleAnalyzer.h b/SplitPoleAnalyzer.h index 04c844d..dea378a 100644 --- a/SplitPoleAnalyzer.h +++ b/SplitPoleAnalyzer.h @@ -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 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 \ No newline at end of file