From 1bbfeff5711cfb6ddb3b85cb4948c122d6470c40 Mon Sep 17 00:00:00 2001 From: splitPoleDAQ Date: Mon, 28 Aug 2023 15:02:56 -0400 Subject: [PATCH] various fixes --- ClassData.h | 8 +++++--- FSUDAQ.cpp | 34 +++++++++++++++++++++++++--------- FSUDAQ.h | 4 +++- README.md | 8 +++++++- RegisterAddress.h | 8 ++++---- analyzers/EncoreAnalyzer.h | 1 + analyzers/Isotope.h | 2 +- analyzers/SplitPoleAnalyzer.h | 8 ++++++++ 8 files changed, 54 insertions(+), 19 deletions(-) diff --git a/ClassData.h b/ClassData.h index 01349b2..f573409 100644 --- a/ClassData.h +++ b/ClassData.h @@ -177,6 +177,8 @@ inline void Data::ClearData(){ NumEventsDecoded[ch] = 0; NumNonPileUpDecoded[ch] = 0; + TotNumEvents[ch] = 0 ; + calIndexes[ch][0] = -1; calIndexes[ch][1] = -1; } @@ -262,7 +264,7 @@ inline void Data::PrintStat() const{ printf(" this is roll-over fake event or no events.\n"); return; } - printf("%2s | %6s | %9s | %9s | %6s | %6s(%4s)\n", "ch", "# Evt.", "Rate [Hz]", "N-PileUp", "Tot. Evt.", "index", "loop"); + printf("%2s | %6s | %9s | %9s | %6s | %6s(%4s)\n", "ch", "# Evt.", "Rate [Hz]", "Accept", "Tot. Evt.", "index", "loop"); printf("---+--------+-----------+-----------+----------\n"); for(int ch = 0; ch < MaxNChannels; ch++){ printf("%2d | %6d | %9.2f | %9.2f | %6lu | %6d(%2d)\n", ch, NumEventsDecoded[ch], TriggerRate[ch], NonPileUpRate[ch], TotNumEvents[ch], DataIndex[ch], LoopIndex[ch]); @@ -422,7 +424,7 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){ TriggerRate[ch] = (NumEventsDecoded[ch]-1)/sec; //printf("%d %d| %d | %llu, %.3e | %.2f\n", indexStart, DataIndex[ch], NumEventsDecoded[ch], dTime, sec , TriggerRate[ch]); - NonPileUpRate[ch] = (NumNonPileUpDecoded[ch]-1)/sec; + NonPileUpRate[ch] = (NumNonPileUpDecoded[ch])/sec; }else{ // look in to the data in the memory, not just this agg. @@ -437,7 +439,6 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){ unsigned long long dTime = Timestamp[ch][calIndexes[ch][1]] - Timestamp[ch][calIndexes[ch][0]]; double sec = dTime * tick2ns / 1e9; - //printf(" %10llu %10llu, %f = %f sec, rate = %f \n", Timestamp[ch][calIndexes[ch][0]], Timestamp[ch][calIndexes[ch][1]], tick2ns, sec, nEvent / sec); TriggerRate[ch] = nEvent / sec; @@ -445,6 +446,7 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){ for( int i = calIndexes[ch][0] ; i <= calIndexes[ch][0] + nEvent; i++ ) { if( PileUp[ch][i % MaxNData] ) pileUpCount ++; } + //printf("%2d | %10llu %10llu, %.0f = %f sec, rate = %f, nEvent %d pileUp %d \n", ch, Timestamp[ch][calIndexes[ch][0]], Timestamp[ch][calIndexes[ch][1]], tick2ns, sec, nEvent / sec, nEvent, pileUpCount); NonPileUpRate[ch] = (nEvent - pileUpCount)/sec; diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 3446329..8981e01 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -63,9 +63,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ layout->addWidget(bnOpenScope, 1, 1); connect(bnOpenScope, &QPushButton::clicked, this, &MainWindow::OpenScope); - bnAnalyzer = new QPushButton("Online Analyzer", this); - layout->addWidget(bnAnalyzer, 0, 2); - connect(bnAnalyzer, &QPushButton::clicked, this, &MainWindow::OpenAnalyzer); + cbAnalyzer = new RComboBox(this); + layout->addWidget(cbAnalyzer, 0, 2); + cbAnalyzer->addItem("Choose Online Analyzer", -1); + cbAnalyzer->addItem("Split-Pole", 0); + cbAnalyzer->addItem("Encore", 1); + connect(cbAnalyzer, &RComboBox::currentIndexChanged, this, &MainWindow::OpenAnalyzer); bnCanvas = new QPushButton("Online 1D Histograms", this); layout->addWidget(bnCanvas, 1, 2); @@ -735,7 +738,7 @@ void MainWindow::WaitForDigitizersOpen(bool onOff){ bnStopACQ->setStyleSheet(""); chkSaveData->setEnabled(!onOff); bnCanvas->setEnabled(!onOff); - bnAnalyzer->setEnabled(!onOff); + cbAnalyzer->setEnabled(!onOff); cbAutoRun->setEnabled(chkSaveData->isChecked()); bnSync->setEnabled(false); @@ -1427,17 +1430,30 @@ void MainWindow::OpenCanvas(){ //*************************************************************** //*************************************************************** void MainWindow::OpenAnalyzer(){ + int id = cbAnalyzer->currentData().toInt(); + + if( id < 0 ) return; if( onlineAnalyzer == nullptr ) { //onlineAnalyzer = new Analyzer(digi, nDigi); - //onlineAnalyzer = new SplitPole(digi, nDigi); - onlineAnalyzer = new Encore(digi, nDigi); - onlineAnalyzer->show(); + if( id == 0 ) onlineAnalyzer = new SplitPole(digi, nDigi); + if( id == 1 ) onlineAnalyzer = new Encore(digi, nDigi); + if( id >= 0 ) onlineAnalyzer->show(); }else{ - onlineAnalyzer->show(); - onlineAnalyzer->activateWindow(); + + delete onlineAnalyzer; + + if( id == 0 ) onlineAnalyzer = new SplitPole(digi, nDigi); + if( id == 1 ) onlineAnalyzer = new Encore(digi, nDigi); + + if( id >= 0 ){ + onlineAnalyzer->show(); + onlineAnalyzer->activateWindow(); + } } + cbAnalyzer->setCurrentIndex(0); + } //*************************************************************** diff --git a/FSUDAQ.h b/FSUDAQ.h index 51994e0..88851f4 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -94,7 +94,9 @@ private: QPushButton * bnCloseDigitizers; QPushButton * bnOpenScope; QPushButton * bnDigiSettings; - QPushButton * bnAnalyzer; + //QPushButton * bnAnalyzer; + + RComboBox * cbAnalyzer; QPushButton * bnOpenScaler; QPushButton * bnStartACQ; diff --git a/README.md b/README.md index 19bedbb..fc5646f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ An online analyzer class is created as a template for online analysis. An exampl Notice that, when the FSUDAQ is started, the online analyzer is a null pointer, no event will be built. Once the online anlyzer is created and opened, event will be built, event the window is closed. - # Operation When programSettings.txt is presented in the same folder as the FSUDAQ_Qt, the program will load it can config the following @@ -39,6 +38,12 @@ the following additional functions are planned and I am working on them - support V1740 DPP-QDC +# ToDo + +- Gaussians fitting for 1D Histogram +- log scale for 1D and 2D Histogram +- Improve the color scheme for 2D histogram + # Required / Development enviroment Ubuntu 22.04 @@ -100,6 +105,7 @@ Those file can be compiled using # Known Issues +* DC offset issue. When porgram default settings, the DC offset is not the same for all channels. * for PHA firmware, when the peak average changed, the Events per Agg need to be changed. # Known Bugs diff --git a/RegisterAddress.h b/RegisterAddress.h index 443b0c1..7823e21 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -624,8 +624,8 @@ namespace DPP { {"OR", 7}}; const std::vector> ListLocalTrigValidMode = {{"Disabled", 0}, - {"Crossed", 4}, - {"Equal", 5}, + {"Crossed Trigger", 4}, + {"Both from Mother board", 5}, {"AND", 6}, {"OR", 7}}; @@ -699,8 +699,8 @@ namespace DPP { {"OR", 7}}; const std::vector> ListLocalTrigValidMode = {{"Disabled", 0}, - {"Crossed", 4}, - {"Equal", 5}, + {"Crossed Trigger", 4}, + {"Both from Mother board", 5}, {"AND", 6}, {"OR", 7}}; diff --git a/analyzers/EncoreAnalyzer.h b/analyzers/EncoreAnalyzer.h index 19eebe0..bb0b299 100644 --- a/analyzers/EncoreAnalyzer.h +++ b/analyzers/EncoreAnalyzer.h @@ -92,6 +92,7 @@ inline void Encore::SetUpCanvas(){ inline void Encore::UpdateHistograms(){ + if( this->isVisible() == false ) return; if( runAnalyzer->isChecked() == false ) return; BuildEvents(); // call the event builder to build events diff --git a/analyzers/Isotope.h b/analyzers/Isotope.h index d2aa94b..5d1ac2b 100644 --- a/analyzers/Isotope.h +++ b/analyzers/Isotope.h @@ -25,7 +25,7 @@ const double mp = 938.2720813; // MeV/c^2 const double mn = 939.56542052; // MeV/c^2 const double amu = 931.0; -const string massData="mass20.txt"; +const string massData="analyzers/mass20.txt"; // about the mass**.txt // Mass Excess = (ATOMIC MASS - A)*amu | e.g. n : (1.088664.91585E-6-1)*amu diff --git a/analyzers/SplitPoleAnalyzer.h b/analyzers/SplitPoleAnalyzer.h index 8cc12d1..31d7d91 100644 --- a/analyzers/SplitPoleAnalyzer.h +++ b/analyzers/SplitPoleAnalyzer.h @@ -249,6 +249,8 @@ private: RSpinBox * sbEnergy; RSpinBox * sbAngle; + QCheckBox * runAnalyzer; + }; @@ -334,6 +336,9 @@ inline void SplitPole::SetUpCanvas(){ hit.CalZoffset(leTarget->text(), leBeam->text(), leRecoil->text(), sbBfield->value(), sbAngle->value(), sbEnergy->value()); }); + runAnalyzer = new QCheckBox("Run Analyzer", this); + boxLayout->addWidget(runAnalyzer, 4, 1); + } //============ histograms @@ -403,6 +408,9 @@ inline void SplitPole::SetUpCanvas(){ inline void SplitPole::UpdateHistograms(){ + if( this->isVisible() == false ) return; + if( runAnalyzer->isChecked() == false ) return; + BuildEvents(); // call the event builder to build events //============ Get events, and do analysis