DigiSetting PSD bug fix, add NeutronGamma analyzer

This commit is contained in:
Ryan Tang 2024-08-20 14:59:22 -04:00
parent 5ebff17f89
commit 6a9f254289
6 changed files with 354 additions and 38 deletions

View File

@ -437,6 +437,10 @@ int Digitizer::ProgramBoard_PSD(){
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0xF, 0xAAAA); ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0xF, 0xAAAA);
} }
// ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::DPPAlgorithmControl) + 0x7000 , 0x001 ); // baseline 16 sample
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PSD::TriggerThreshold) + 0x7000 , 100 );
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PreTrigger) + 0x7000 , 20 ); ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PreTrigger) + 0x7000 , 20 );
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::RecordLength_G) + 0x7000 , 80 ); ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::RecordLength_G) + 0x7000 , 80 );

View File

@ -3847,16 +3847,16 @@ void DigiSettingsPanel::UpdateSettings_PSD(){
chkRejOverRange[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::Bit_DPPAlgorithmControl_PSD::RejectOverRange)); chkRejOverRange[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::Bit_DPPAlgorithmControl_PSD::RejectOverRange));
chkTestPule[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::Bit_DPPAlgorithmControl_PSD::InternalTestPulse)); chkTestPule[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::Bit_DPPAlgorithmControl_PSD::InternalTestPulse));
chkDisableOppositePulse[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::Bit_DPPAlgorithmControl_PSD::DisableOppositePolarityInhibitZeroCrossingOnCFD));
chkDisableSelfTrigger[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::Bit_DPPAlgorithmControl_PSD::DisableSelfTrigger));
chkRejPileUp[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::Bit_DPPAlgorithmControl_PSD::RejectPileup));
chkPileUpInGate[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::Bit_DPPAlgorithmControl_PSD::PileupWithinGate));
chkDisableTriggerHysteresis[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::Bit_DPPAlgorithmControl_PSD::DisableTriggerHysteresis));
uint32_t dpp2 = digi[ID]->GetSettingFromMemory(DPP::PSD::DPPAlgorithmControl2_G, ch); uint32_t dpp2 = digi[ID]->GetSettingFromMemory(DPP::PSD::DPPAlgorithmControl2_G, ch);
chkDisableOppositePulse[ID][ch]->setChecked( Digitizer::ExtractBits(dpp2, DPP::Bit_DPPAlgorithmControl_PSD::DisableOppositePolarityInhibitZeroCrossingOnCFD)); chkMarkSaturation[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::PSD::Bit_DPPAlgorithmControl2::MarkSaturation));
chkDisableSelfTrigger[ID][ch]->setChecked( Digitizer::ExtractBits(dpp2, DPP::Bit_DPPAlgorithmControl_PSD::DisableSelfTrigger)); chkResetTimestampByTRGIN[ID][ch]->setChecked( Digitizer::ExtractBits(dpp, DPP::PSD::Bit_DPPAlgorithmControl2::ResetTimestampByTRGIN));
chkRejPileUp[ID][ch]->setChecked( Digitizer::ExtractBits(dpp2, DPP::Bit_DPPAlgorithmControl_PSD::RejectPileup));
chkPileUpInGate[ID][ch]->setChecked( Digitizer::ExtractBits(dpp2, DPP::Bit_DPPAlgorithmControl_PSD::PileupWithinGate));
chkDisableTriggerHysteresis[ID][ch]->setChecked( Digitizer::ExtractBits(dpp2, DPP::Bit_DPPAlgorithmControl_PSD::DisableTriggerHysteresis));
chkMarkSaturation[ID][ch]->setChecked( Digitizer::ExtractBits(dpp2, DPP::PSD::Bit_DPPAlgorithmControl2::MarkSaturation));
chkResetTimestampByTRGIN[ID][ch]->setChecked( Digitizer::ExtractBits(dpp2, DPP::PSD::Bit_DPPAlgorithmControl2::ResetTimestampByTRGIN));
UpdateComboBoxBit(cbLocalTriggerValid[ID][ch], dpp2, DPP::PSD::Bit_DPPAlgorithmControl2::LocalTrigValidMode); UpdateComboBoxBit(cbLocalTriggerValid[ID][ch], dpp2, DPP::PSD::Bit_DPPAlgorithmControl2::LocalTrigValidMode);
UpdateComboBoxBit(cbAdditionLocalTrigValid[ID][ch], dpp2, DPP::PSD::Bit_DPPAlgorithmControl2::AdditionLocalTrigValid); UpdateComboBoxBit(cbAdditionLocalTrigValid[ID][ch], dpp2, DPP::PSD::Bit_DPPAlgorithmControl2::AdditionLocalTrigValid);

View File

@ -20,8 +20,9 @@
#include "analyzers/EncoreAnalyzer.h" #include "analyzers/EncoreAnalyzer.h"
#include "analyzers/MUSICAnalyzer.h" #include "analyzers/MUSICAnalyzer.h"
#include "analyzers/RAISOR.h" #include "analyzers/RAISOR.h"
#include "analyzers/NeutronGamma.h"
std::vector<std::string> onlineAnalyzerList = {"Coincident","Splie-Pole", "Encore", "RAISOR", "MUSICS"}; std::vector<std::string> onlineAnalyzerList = {"Coincident","Splie-Pole", "Encore", "RAISOR", "MUSICS", "Neutron-Gamma"};
FSUDAQ::FSUDAQ(QWidget *parent) : QMainWindow(parent){ FSUDAQ::FSUDAQ(QWidget *parent) : QMainWindow(parent){
DebugPrint("%s", "FSUDAQ"); DebugPrint("%s", "FSUDAQ");
@ -34,7 +35,7 @@ FSUDAQ::FSUDAQ(QWidget *parent) : QMainWindow(parent){
scalar = nullptr; scalar = nullptr;
scope = nullptr; scope = nullptr;
digiSettings = nullptr; digiSettings = nullptr;
canvas = nullptr; singleHistograms = nullptr;
histThread = nullptr; histThread = nullptr;
onlineAnalyzer = nullptr; onlineAnalyzer = nullptr;
runTimer = new QTimer(); runTimer = new QTimer();
@ -91,7 +92,7 @@ FSUDAQ::FSUDAQ(QWidget *parent) : QMainWindow(parent){
bnCanvas = new QPushButton("Online Histograms", this); bnCanvas = new QPushButton("Online Histograms", this);
layout->addWidget(bnCanvas, 1, 2); layout->addWidget(bnCanvas, 1, 2);
connect(bnCanvas, &QPushButton::clicked, this, &FSUDAQ::OpenCanvas); connect(bnCanvas, &QPushButton::clicked, this, &FSUDAQ::OpenSingleHistograms);
bnSync = new QPushButton("Sync Boards", this); bnSync = new QPushButton("Sync Boards", this);
layout->addWidget(bnSync, 2, 1); layout->addWidget(bnSync, 2, 1);
@ -333,7 +334,7 @@ FSUDAQ::~FSUDAQ(){
delete histThread; delete histThread;
} }
if( canvas ) delete canvas; if( singleHistograms ) delete singleHistograms;
if( onlineAnalyzer ) delete onlineAnalyzer; if( onlineAnalyzer ) delete onlineAnalyzer;
@ -741,12 +742,12 @@ void FSUDAQ::OpenDigitizers(){
QCoreApplication::processEvents(); //to prevent Qt said application not responding. QCoreApplication::processEvents(); //to prevent Qt said application not responding.
} }
canvas = new SingleSpectra(digi, nDigi, rawDataPath); singleHistograms = new SingleSpectra(digi, nDigi, rawDataPath);
histThread = new TimingThread(this); histThread = new TimingThread(this);
histThread->SetWaitTimeinSec(canvas->GetMaxFillTime()/1000.); histThread->SetWaitTimeinSec(singleHistograms->GetMaxFillTime()/1000.);
connect(histThread, &TimingThread::timeUp, this, [=](){ connect(histThread, &TimingThread::timeUp, this, [=](){
if( canvas == nullptr && !canvas->IsFillHistograms()) return; if( singleHistograms == nullptr && !singleHistograms->IsFillHistograms()) return;
canvas->FillHistograms(); singleHistograms->FillHistograms();
}); });
LogMsg("====== <font style=\"color: blue;\"><b>" + QString("Done. Opened %1 digitizer(s).").arg(nDigi) + "</b></font> ====="); LogMsg("====== <font style=\"color: blue;\"><b>" + QString("Done. Opened %1 digitizer(s).").arg(nDigi) + "</b></font> =====");
@ -799,10 +800,10 @@ void FSUDAQ::CloseDigitizers(){
} }
if( canvas ){ if( singleHistograms ){
canvas->close(); singleHistograms->close();
delete canvas; delete singleHistograms;
canvas = nullptr; singleHistograms = nullptr;
} }
if( digiSettings ){ if( digiSettings ){
@ -1180,7 +1181,7 @@ void FSUDAQ::StartACQ(){
} }
lbScalarACQStatus->setText("<font style=\"color: green;\"><b>ACQ On</b></font>"); lbScalarACQStatus->setText("<font style=\"color: green;\"><b>ACQ On</b></font>");
if( canvas != nullptr ) histThread->start(); if( singleHistograms != nullptr ) histThread->start();
bnStartACQ->setEnabled(false); bnStartACQ->setEnabled(false);
bnStartACQ->setStyleSheet(""); bnStartACQ->setStyleSheet("");
@ -1256,11 +1257,11 @@ void FSUDAQ::StopACQ(){
if( onlineAnalyzer ) onlineAnalyzer->StopThread(); if( onlineAnalyzer ) onlineAnalyzer->StopThread();
if( canvas && histThread->isRunning()){ if( singleHistograms && histThread->isRunning()){
histThread->Stop(); histThread->Stop();
histThread->quit(); histThread->quit();
histThread->wait(); histThread->wait();
canvas->ClearInternalDataCount(); singleHistograms->ClearInternalDataCount();
} }
lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>"); lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>");
@ -1752,7 +1753,7 @@ void FSUDAQ::OpenScope(){
if( digiSettings ) digiSettings->setEnabled(!onOff); if( digiSettings ) digiSettings->setEnabled(!onOff);
if( canvas ){ if( singleHistograms ){
if( onOff) { if( onOff) {
histThread->start(); histThread->start();
}else{ }else{
@ -1760,7 +1761,7 @@ void FSUDAQ::OpenScope(){
histThread->Stop(); histThread->Stop();
histThread->quit(); histThread->quit();
histThread->wait(); histThread->wait();
canvas->ClearInternalDataCount(); singleHistograms->ClearInternalDataCount();
} }
} }
} }
@ -1802,15 +1803,15 @@ void FSUDAQ::OpenDigiSettings(){
//*************************************************************** //***************************************************************
//*************************************************************** //***************************************************************
void FSUDAQ::OpenCanvas(){ void FSUDAQ::OpenSingleHistograms(){
DebugPrint("%s", "FSUDAQ"); DebugPrint("%s", "FSUDAQ");
if( canvas == nullptr ) { if( singleHistograms == nullptr ) {
canvas = new SingleSpectra(digi, nDigi, rawDataPath); singleHistograms = new SingleSpectra(digi, nDigi, rawDataPath);
canvas->show(); singleHistograms->show();
}else{ }else{
canvas->show(); singleHistograms->show();
canvas->activateWindow(); singleHistograms->activateWindow();
canvas->LoadSetting(); singleHistograms->LoadSetting();
} }
} }
@ -1830,6 +1831,7 @@ void FSUDAQ::OpenAnalyzer(){
if( id == 2 ) onlineAnalyzer = new Encore(digi, nDigi); if( id == 2 ) onlineAnalyzer = new Encore(digi, nDigi);
if( id == 3 ) onlineAnalyzer = new RAISOR(digi, nDigi); if( id == 3 ) onlineAnalyzer = new RAISOR(digi, nDigi);
if( id == 4 ) onlineAnalyzer = new MUSIC(digi, nDigi); if( id == 4 ) onlineAnalyzer = new MUSIC(digi, nDigi);
if( id == 5 ) onlineAnalyzer = new NeutronGamma(digi, nDigi, rawDataPath);
if( id >= 0 ) onlineAnalyzer->show(); if( id >= 0 ) onlineAnalyzer->show();
}else{ }else{
@ -1840,6 +1842,7 @@ void FSUDAQ::OpenAnalyzer(){
if( id == 2 ) onlineAnalyzer = new Encore(digi, nDigi); if( id == 2 ) onlineAnalyzer = new Encore(digi, nDigi);
if( id == 3 ) onlineAnalyzer = new RAISOR(digi, nDigi); if( id == 3 ) onlineAnalyzer = new RAISOR(digi, nDigi);
if( id == 4 ) onlineAnalyzer = new MUSIC(digi, nDigi); if( id == 4 ) onlineAnalyzer = new MUSIC(digi, nDigi);
if( id == 4 ) onlineAnalyzer = new NeutronGamma(digi, nDigi, rawDataPath);
if( id >= 0 ){ if( id >= 0 ){
onlineAnalyzer->show(); onlineAnalyzer->show();

View File

@ -36,9 +36,9 @@ public:
delete digiSettings; delete digiSettings;
digiSettings = nullptr; digiSettings = nullptr;
} }
if( canvas ) { if( singleHistograms ) {
delete canvas; delete singleHistograms;
canvas = nullptr; singleHistograms = nullptr;
} }
if( onlineAnalyzer ) { if( onlineAnalyzer ) {
delete onlineAnalyzer; delete onlineAnalyzer;
@ -76,7 +76,7 @@ private slots:
void OpenDigiSettings(); void OpenDigiSettings();
void OpenCanvas(); void OpenSingleHistograms();
void OpenAnalyzer(); void OpenAnalyzer();
@ -193,7 +193,7 @@ private:
DigiSettingsPanel * digiSettings; DigiSettingsPanel * digiSettings;
//@----- SingleSpectra //@----- SingleSpectra
SingleSpectra * canvas; SingleSpectra * singleHistograms;
TimingThread * histThread; TimingThread * histThread;
//@----- Analyzer //@----- Analyzer

View File

@ -45,6 +45,7 @@ HEADERS += ClassData.h \
analyzers/SplitPoleAnalyzer.h \ analyzers/SplitPoleAnalyzer.h \
analyzers/EncoreAnalyzer.h \ analyzers/EncoreAnalyzer.h \
analyzers/MUSICAnalyzer.h \ analyzers/MUSICAnalyzer.h \
analyzers/NeutronGamma.h \
analyzers/RAISOR.h analyzers/RAISOR.h
SOURCES += ClassDigitizer.cpp \ SOURCES += ClassDigitizer.cpp \
DigiSettingsPanel.cpp \ DigiSettingsPanel.cpp \

308
analyzers/NeutronGamma.h Normal file
View File

@ -0,0 +1,308 @@
#ifndef NEUTRONGAMMA_H
#define NEUTRONGAMMA_H
/***********************************\
*
* This Analyzer does not use event builder,
* this simply use the energy_short and energy_long for each data.
*
*************************************/
#include <QMainWindow>
#include <QChart>
#include <QChartView>
#include <QLabel>
#include <QPushButton>
#include <QCheckBox>
#include <QLineEdit>
#include <QGridLayout>
#include <QGroupBox>
#include <QVector>
#include <QRandomGenerator>
#include "Analyser.h"
//^====================================================
//^====================================================
class NeutronGamma : public Analyzer{
Q_OBJECT
public:
NeutronGamma(Digitizer ** digi, unsigned int nDigi, QString rawDataPath, QMainWindow * parent = nullptr): Analyzer(digi, nDigi, parent){
this->digi = digi;
this->nDigi = nDigi;
this->settingPath = rawDataPath + "/NG_HistogramSettings.txt";
SetUpdateTimeInSec(1.0);
isSignalSlotActive = false;
SetUpCanvas();
ClearInternalDataCount();
};
~NeutronGamma(){
// for( unsigned int i = 0; i < nDigi; i++ ){
// for( int ch = 0; ch < digi[i]->GetNumInputCh(); ch++){
// delete hist2D[i][ch];
// }
// }
delete hist2D;
}
void ClearInternalDataCount();
// void LoadSetting();
// void SaveSetting();
public slots:
void UpdateHistograms();
private:
QVector<int> generateNonRepeatedCombination(int size);
void SetUpCanvas();
Digitizer ** digi;
unsigned short nDigi;
Histogram2D * hist2D;
RComboBox * cbDigi;
RComboBox * cbCh;
QGroupBox * histBox;
QGridLayout * histLayout;
int lastFilledIndex[MaxNDigitizer][MaxNChannels];
int loopFilledIndex[MaxNDigitizer][MaxNChannels];
bool fillHistograms;
QString settingPath;
unsigned short maxFillTimeinMilliSec;
unsigned short maxFillTimePerDigi;
bool isSignalSlotActive;
};
inline void NeutronGamma::SetUpCanvas(){
setWindowTitle("Neutron-Gamma Separation");
QScreen * screen = QGuiApplication::primaryScreen();
QRect screenGeo = screen->geometry();
if( screenGeo.width() < 1000 || screenGeo.height() < 800) {
setGeometry(0, 0, screenGeo.width() - 100, screenGeo.height() - 100);
}else{
setGeometry(0, 0, 1000, 800);
}
QWidget * layoutWidget = new QWidget(this);
setCentralWidget(layoutWidget);
QVBoxLayout * layout = new QVBoxLayout(layoutWidget);
layoutWidget->setLayout(layout);
{//^==================================
QGroupBox * controlBox = new QGroupBox("Control", this);
layout->addWidget(controlBox);
QGridLayout * ctrlLayout = new QGridLayout(controlBox);
controlBox->setLayout(ctrlLayout);
cbDigi = new RComboBox(this);
for( unsigned int i = 0; i < nDigi; i++) cbDigi->addItem("Digi-" + QString::number( digi[i]->GetSerialNumber() ), i);
ctrlLayout->addWidget(cbDigi, 0, 0, 1, 2);
connect( cbDigi, &RComboBox::currentIndexChanged, this, [=](int index){
isSignalSlotActive = false;
cbCh->clear();
cbCh->addItem("All Ch", digi[index]->GetNumInputCh() );
for( int i = 0; i < digi[index]->GetNumInputCh(); i++) cbCh->addItem("ch-" + QString::number( i ), i);
hist2D->Clear();
isSignalSlotActive = true;
});
cbCh = new RComboBox(this);
for( int i = 0; i < digi[0]->GetNumInputCh(); i++) cbCh->addItem("ch-" + QString::number( i ), i);
ctrlLayout->addWidget(cbCh, 0, 2, 1, 2);
// connect( cbCh, &RComboBox::currentIndexChanged, this, &SingleSpectra::ChangeHistView);
connect( cbCh, &RComboBox::currentIndexChanged, this, [=](){
hist2D->Clear();
});
QCheckBox * chkIsFillHistogram = new QCheckBox("Fill Histograms", this);
ctrlLayout->addWidget(chkIsFillHistogram, 0, 8);
connect(chkIsFillHistogram, &QCheckBox::stateChanged, this, [=](int state){ fillHistograms = state;});
chkIsFillHistogram->setChecked(false);
fillHistograms = false;
QLabel * lbSettingPath = new QLabel( settingPath , this);
ctrlLayout->addWidget(lbSettingPath, 1, 0, 1, 8);
}
{//^====================================
histBox = new QGroupBox("Histgrams", this);
layout->addWidget(histBox, 10);
histLayout = new QGridLayout(histBox);
histBox->setLayout(histLayout);
double eMax = 50000;
double eMin = 0;
double nBin = 1000;
// for( unsigned int i = 0; i < MaxNDigitizer; i++){
// if( i >= nDigi ) continue;
// for( int j = 0; j < digi[i]->GetNumInputCh(); j++){
// if( i < nDigi ) {
// hist2D[i][j] = new Histogram2D("Digi-" + QString::number(digi[i]->GetSerialNumber()), "Long Energy [ch]", "Short Energy [ch]", nBin, eMin, eMax, nBin, eMin, eMax);
// }else{
// hist2D[i][j] = nullptr;
// }
// }
// }
// histLayout->addWidget(hist2D[0][0], 0, 0);
hist2D = new Histogram2D("Neutron-Gamma", "PSD = (l-s)/l", "Short Energy [ch]", nBin, eMin, eMax, nBin, 0, 1);
histLayout->addWidget(hist2D, 0, 0);
}
}
inline void NeutronGamma::ClearInternalDataCount(){
for( unsigned int i = 0; i < nDigi; i++){
for( int ch = 0; ch < MaxRegChannel ; ch++) {
lastFilledIndex[i][ch] = -1;
loopFilledIndex[i][ch] = 0;
}
}
}
inline void NeutronGamma::UpdateHistograms(){
if( !fillHistograms ) return;
if( this->isVisible() == false ) return;
int ID = cbDigi->currentData().toInt();
int ch = cbCh->currentData().toInt();
int lastIndex = digi[ID]->GetData()->GetDataIndex(ch);
if( lastIndex < 0 ) return;
int loopIndex = digi[ID]->GetData()->GetLoopIndex(ch);
int temp1 = lastIndex + loopIndex * digi[ID]->GetData()->GetDataSize();
int temp2 = lastFilledIndex[ID][ch] + loopFilledIndex[ID][ch] * digi[ID]->GetData()->GetDataSize() + 1;
if( temp1 - temp2 > digi[ID]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k
temp2 = temp1 - digi[ID]->GetData()->GetDataSize();
lastFilledIndex[ID][ch] = lastIndex;
lastFilledIndex[ID][ch] = loopIndex - 1;
}
for( int j = 0 ; j <= temp1 - temp2; j ++){
lastFilledIndex[ID][ch] ++;
if( lastFilledIndex[ID][ch] > digi[ID]->GetData()->GetDataSize() ) {
lastFilledIndex[ID][ch] = 0;
loopFilledIndex[ID][ch] ++;
}
uShort data_long = digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch]);
uShort data_short = digi[ID]->GetData()->GetEnergy2(ch, lastFilledIndex[ID][ch]);
// printf(" ch: %d, last fill idx : %d | %d \n", ch, lastFilledIndex[ID][ch], data);
double psd = (data_long - data_short) *1.0 / data_long;
hist2D->Fill(data_long, psd);
}
hist2D->UpdatePlot();
}
/*
void NeutronGamma::UpdateHistograms(){
if( !fillHistograms ) return;
timespec t0, t1;
QVector<int> randomDigiList = generateNonRepeatedCombination(nDigi);
for( int i = 0; i < nDigi; i++){
int ID = randomDigiList[i];
QVector<int> randomChList = generateNonRepeatedCombination(digi[ID]->GetNumInputCh());
digiMTX[ID].lock();
clock_gettime(CLOCK_REALTIME, &t0);
for( int k = 0; k < digi[ID]->GetNumInputCh(); k ++ ){
int ch = randomChList[k];
int lastIndex = digi[ID]->GetData()->GetDataIndex(ch);
// printf("--- ch %2d | last index %d \n", ch, lastIndex);
if( lastIndex < 0 ) continue;
int loopIndex = digi[ID]->GetData()->GetLoopIndex(ch);
int temp1 = lastIndex + loopIndex * digi[ID]->GetData()->GetDataSize();
int temp2 = lastFilledIndex[ID][ch] + loopFilledIndex[ID][ch] * digi[ID]->GetData()->GetDataSize() + 1;
// printf("loopIndx : %d | ID now : %d, ID old : %d \n", loopIndex, temp1, temp2);
if( temp1 <= temp2 ) continue;
if( temp1 - temp2 > digi[ID]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k
temp2 = temp1 - digi[ID]->GetData()->GetDataSize();
lastFilledIndex[ID][ch] = lastIndex;
lastFilledIndex[ID][ch] = loopIndex - 1;
}
// printf("ch %d | regulated ID now %d new %d | last fill idx %d\n", ch, temp2, temp1, lastFilledIndex[ID][ch]);
for( int j = 0 ; j <= temp1 - temp2; j ++){
lastFilledIndex[ID][ch] ++;
if( lastFilledIndex[ID][ch] > digi[ID]->GetData()->GetDataSize() ) {
lastFilledIndex[ID][ch] = 0;
loopFilledIndex[ID][ch] ++;
}
uShort data_long = digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch]);
uShort data_short = digi[ID]->GetData()->GetEnergy2(ch, lastFilledIndex[ID][ch]);
// printf(" ch: %d, last fill idx : %d | %d \n", ch, lastFilledIndex[ID][ch], data);
hist2D[ID][ch]->Fill(data_long, data_short);
}
if( histVisibility[ID][ch] ) hist2D[ID][ch]->UpdatePlot();
clock_gettime(CLOCK_REALTIME, &t1);
if( t1.tv_nsec - t0.tv_nsec + (t1.tv_sec - t0.tv_sec)*1e9 > maxFillTimePerDigi * 1e6 ) break;
}
digiMTX[ID].unlock();
}
}
*/
inline QVector<int> NeutronGamma::generateNonRepeatedCombination(int size) {
QVector<int> combination;
for (int i = 0; i < size; ++i) combination.append(i);
for (int i = 0; i < size - 1; ++i) {
int j = QRandomGenerator::global()->bounded(i, size);
combination.swapItemsAt(i, j);
}
return combination;
}
#endif