bug fix on MultiBuilder for multiple boards
This commit is contained in:
parent
407924f863
commit
ccd23065dd
18
FSUDAQ.cpp
18
FSUDAQ.cpp
|
@ -199,6 +199,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
cbAutoRun->addItem("Single 30 mins", 30);
|
cbAutoRun->addItem("Single 30 mins", 30);
|
||||||
cbAutoRun->addItem("Single 60 mins", 60);
|
cbAutoRun->addItem("Single 60 mins", 60);
|
||||||
cbAutoRun->addItem("Repeat 60 mins", -60);
|
cbAutoRun->addItem("Repeat 60 mins", -60);
|
||||||
|
cbAutoRun->addItem("Repeat 120 mins", -120);
|
||||||
cbAutoRun->setEnabled(false);
|
cbAutoRun->setEnabled(false);
|
||||||
|
|
||||||
bnStartACQ = new QPushButton("Start ACQ", this);
|
bnStartACQ = new QPushButton("Start ACQ", this);
|
||||||
|
@ -790,8 +791,8 @@ void MainWindow::UpdateScalar(){
|
||||||
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
|
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
|
||||||
digiMTX[iDigi].lock();
|
digiMTX[iDigi].lock();
|
||||||
|
|
||||||
printf("### %d ", iDigi);
|
// printf("### %d ", iDigi);
|
||||||
digi[iDigi]->GetData()->PrintAllData(true, 10);
|
// digi[iDigi]->GetData()->PrintAllData(true, 10);
|
||||||
if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize();
|
if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize();
|
||||||
for( int i = 0; i < digi[iDigi]->GetNChannels(); i++){
|
for( int i = 0; i < digi[iDigi]->GetNChannels(); i++){
|
||||||
if( digi[iDigi]->GetChannelOnOff(i) == true ) {
|
if( digi[iDigi]->GetChannelOnOff(i) == true ) {
|
||||||
|
@ -972,6 +973,13 @@ void MainWindow::StopACQ(){
|
||||||
|
|
||||||
void MainWindow::AutoRun(){ //TODO
|
void MainWindow::AutoRun(){ //TODO
|
||||||
|
|
||||||
|
if( chkSaveData->isChecked() == false){
|
||||||
|
StartACQ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::SetSyncMode(){
|
void MainWindow::SetSyncMode(){
|
||||||
|
@ -981,12 +989,12 @@ void MainWindow::SetSyncMode(){
|
||||||
|
|
||||||
QVBoxLayout * layout = new QVBoxLayout(&dialog);
|
QVBoxLayout * layout = new QVBoxLayout(&dialog);
|
||||||
|
|
||||||
QLabel * lbInfo1 = new QLabel("This will reset 0x8100 and 0x811C \nMaster must be the 1st board.", &dialog);
|
QLabel * lbInfo1 = new QLabel("This will reset 0x8100 and 0x811C \nMaster must be the 1st board.\n (could be 100 ticks offset)", &dialog);
|
||||||
lbInfo1->setStyleSheet("color : red;");
|
lbInfo1->setStyleSheet("color : red;");
|
||||||
|
|
||||||
QPushButton * bnNoSync = new QPushButton("No Sync");
|
QPushButton * bnNoSync = new QPushButton("No Sync");
|
||||||
QPushButton * bnMethod1 = new QPushButton("Software TRG-OUT --> TRG-IN (within 100 ticks)");
|
QPushButton * bnMethod1 = new QPushButton("Software TRG-OUT --> TRG-IN ");
|
||||||
QPushButton * bnMethod2 = new QPushButton("Software TRG-OUT --> S-IN (within 20 ticks)");
|
QPushButton * bnMethod2 = new QPushButton("Software TRG-OUT --> S-IN ");
|
||||||
QPushButton * bnMethod3 = new QPushButton("External TRG-OUT --> S-IN ");
|
QPushButton * bnMethod3 = new QPushButton("External TRG-OUT --> S-IN ");
|
||||||
|
|
||||||
layout->addWidget(lbInfo1, 0);
|
layout->addWidget(lbInfo1, 0);
|
||||||
|
|
|
@ -220,35 +220,40 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
em.Clear();
|
em.Clear();
|
||||||
|
|
||||||
for( int k = 0; k < nData; k++){
|
for( int k = 0; k < nData; k++){
|
||||||
|
int bd = (k + earlistDigi) % nData;
|
||||||
|
|
||||||
|
// printf("##### %d/%d | ", k, nData);
|
||||||
|
// data[k]->PrintAllData(true, 10);
|
||||||
|
|
||||||
for( unsigned int i = 0; i < MaxNChannels; i++){
|
for( unsigned int i = 0; i < MaxNChannels; i++){
|
||||||
int ch = (i + earlistCh ) % MaxNChannels;
|
int ch = (i + earlistCh ) % MaxNChannels;
|
||||||
if( chExhaused[k][ch] ) continue;
|
if( chExhaused[bd][ch] ) continue;
|
||||||
if( loopIndex[k][ch] * MaxNData + nextIndex[k][ch] > data[k]->LoopIndex[ch] * MaxNData + data[k]->DataIndex[ch]) {
|
if( loopIndex[bd][ch] * MaxNData + nextIndex[bd][ch] > data[bd]->LoopIndex[ch] * MaxNData + data[bd]->DataIndex[ch]) {
|
||||||
nExhaushedCh ++;
|
nExhaushedCh ++;
|
||||||
chExhaused[k][ch] = true;
|
chExhaused[bd][ch] = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
unsigned long long time = data[k]->Timestamp[ch][nextIndex[k][ch]];
|
unsigned long long time = data[bd]->Timestamp[ch][nextIndex[bd][ch]];
|
||||||
|
|
||||||
if( time >= earlistTime && (time - earlistTime <= timeWindow) ){
|
if( time >= earlistTime && (time - earlistTime <= timeWindow) ){
|
||||||
em.sn = snList[k];
|
em.sn = snList[bd];
|
||||||
em.bd = k;
|
em.bd = bd;
|
||||||
em.ch = ch;
|
em.ch = ch;
|
||||||
em.energy = data[k]->Energy[ch][nextIndex[k][ch]];
|
em.energy = data[bd]->Energy[ch][nextIndex[bd][ch]];
|
||||||
em.timestamp = time;
|
em.timestamp = time;
|
||||||
em.fineTime = data[k]->fineTime[ch][nextIndex[k][ch]];
|
em.fineTime = data[bd]->fineTime[ch][nextIndex[bd][ch]];
|
||||||
|
|
||||||
if( !skipTrace ) em.trace = data[k]->Waveform1[ch][nextIndex[k][ch]];
|
if( !skipTrace ) em.trace = data[bd]->Waveform1[ch][nextIndex[bd][ch]];
|
||||||
if( typeList[k] == V1730_DPP_PSD_CODE ) em.energy2 = data[k]->Energy2[ch][nextIndex[k][ch]];
|
if( typeList[bd] == V1730_DPP_PSD_CODE ) em.energy2 = data[bd]->Energy2[ch][nextIndex[bd][ch]];
|
||||||
|
|
||||||
events[eventIndex].push_back(em);
|
events[eventIndex].push_back(em);
|
||||||
nextIndex[k][ch]++;
|
nextIndex[bd][ch]++;
|
||||||
if( nextIndex[k][ch] >= MaxNData) {
|
if( nextIndex[bd][ch] >= MaxNData) {
|
||||||
loopIndex[k][ch] ++;
|
loopIndex[bd][ch] ++;
|
||||||
nextIndex[k][ch] = 0;
|
nextIndex[bd][ch] = 0;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
break;
|
break;
|
||||||
|
@ -258,12 +263,13 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
if( timeWindow == 0 ) break;
|
if( timeWindow == 0 ) break;
|
||||||
}
|
}
|
||||||
if( timeWindow == 0 ) break;
|
if( timeWindow == 0 ) break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(events[eventIndex].begin(), events[eventIndex].end(), [](const Hit& a, const Hit& b) {
|
if( timeWindow > 0 ) {
|
||||||
return a.timestamp < b.timestamp;
|
std::sort(events[eventIndex].begin(), events[eventIndex].end(), [](const Hit& a, const Hit& b) {
|
||||||
});
|
return a.timestamp < b.timestamp;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
///Find the next earlist
|
///Find the next earlist
|
||||||
FindEarlistTimeAndCh(verbose);
|
FindEarlistTimeAndCh(verbose);
|
||||||
|
@ -280,7 +286,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
printf("######################### no more event to be built\n");
|
printf("######################### no more event to be built\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("----- next ch : %d, next earlist Time : %llu.\n", earlistCh, earlistTime);
|
printf("----- next bd : %d, ch : %d, next earlist Time : %llu.\n", earlistDigi, earlistCh, earlistTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,30 +327,32 @@ void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){
|
||||||
em.Clear();
|
em.Clear();
|
||||||
|
|
||||||
for( int k = 0; k < nData; k++){
|
for( int k = 0; k < nData; k++){
|
||||||
|
int bd = (k + latestDigi) % nData;
|
||||||
|
|
||||||
for( unsigned int i = 0; i < MaxNChannels; i++){
|
for( unsigned int i = 0; i < MaxNChannels; i++){
|
||||||
int ch = (i + latestCh) % MaxNChannels;
|
int ch = (i + latestCh) % MaxNChannels;
|
||||||
if( chExhaused[k][ch] ) continue;
|
if( chExhaused[bd][ch] ) continue;
|
||||||
//if( nextIndex[k][ch] <= lastBackWardIndex[k][ch] || nextIndex[k][ch] < 0){
|
//if( nextIndex[bd][ch] <= lastBackWardIndex[bd][ch] || nextIndex[bd][ch] < 0){
|
||||||
if( nextIndex[k][ch] < 0){
|
if( nextIndex[bd][ch] < 0){
|
||||||
chExhaused[k][ch] = true;
|
chExhaused[bd][ch] = true;
|
||||||
nExhaushedCh ++;
|
nExhaushedCh ++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
do{
|
do{
|
||||||
|
|
||||||
unsigned long long time = data[k]->Timestamp[ch][nextIndex[k][ch]];
|
unsigned long long time = data[bd]->Timestamp[ch][nextIndex[bd][ch]];
|
||||||
if( time <= latestTime && (latestTime - time <= timeWindow)){
|
if( time <= latestTime && (latestTime - time <= timeWindow)){
|
||||||
em.sn = snList[k];
|
em.sn = snList[bd];
|
||||||
em.bd = k;
|
em.bd = bd;
|
||||||
em.ch = ch;
|
em.ch = ch;
|
||||||
em.energy = data[k]->Energy[ch][nextIndex[k][ch]];
|
em.energy = data[bd]->Energy[ch][nextIndex[bd][ch]];
|
||||||
em.timestamp = time;
|
em.timestamp = time;
|
||||||
if( typeList[k] == V1730_DPP_PSD_CODE ) em.energy2 = data[k]->Energy2[ch][nextIndex[k][ch]];
|
if( typeList[bd] == V1730_DPP_PSD_CODE ) em.energy2 = data[bd]->Energy2[ch][nextIndex[bd][ch]];
|
||||||
|
|
||||||
events[eventIndex].push_back(em);
|
events[eventIndex].push_back(em);
|
||||||
nextIndex[k][ch]--;
|
nextIndex[bd][ch]--;
|
||||||
if( nextIndex[k][ch] < 0 && data[k]->LoopIndex[ch] > 0 ) nextIndex[k][ch] = MaxNData - 1;
|
if( nextIndex[bd][ch] < 0 && data[bd]->LoopIndex[ch] > 0 ) nextIndex[bd][ch] = MaxNData - 1;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
break;
|
break;
|
||||||
|
@ -374,7 +382,7 @@ void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){
|
||||||
printf("######################### no more event to be built\n");
|
printf("######################### no more event to be built\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("----- next ch : %d, next latest Time : %llu.\n", latestCh, latestTime);
|
printf("----- next bd: %d, ch : %d, next latest Time : %llu.\n", latestDigi, latestCh, latestTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user