when data rate > 10k/sec, histogram will only fill the latest 10k data

This commit is contained in:
Ryan Tang 2024-03-21 16:57:34 -04:00
parent 5c26d60a58
commit 66f3ba2f02

View File

@ -206,16 +206,22 @@ void SingleSpectra::FillHistograms(){
digiMTX[i].lock();
for( int ch = 0; ch < digi[i]->GetNumInputCh(); ch ++ ){
int lastIndex = digi[i]->GetData()->GetDataIndex(ch);
if( lastIndex < 0 ) continue;
int loopIndex = digi[i]->GetData()->GetLoopIndex(ch);
int temp1 = lastIndex + loopIndex * digi[i]->GetData()->GetDataSize();
int temp2 = lastFilledIndex[i][ch] + loopFilledIndex[i][ch] * digi[i]->GetData()->GetDataSize();
// printf("%d |%d %d \n", ch, temp2, temp1);
if( lastIndex < 0 ) continue;
if( temp1 <= temp2 ) continue;
if( temp1 - temp2 > digi[i]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k
temp2 = temp1 - digi[i]->GetData()->GetDataSize();
lastFilledIndex[i][ch] = lastIndex;
lastFilledIndex[i][ch] = loopIndex - 1;
}
for( int j = 0 ; j <= temp1 - temp2; j ++){
lastFilledIndex[i][ch] ++;
if( lastFilledIndex[i][ch] > digi[i]->GetData()->GetDataSize() ) {
@ -223,9 +229,7 @@ void SingleSpectra::FillHistograms(){
loopFilledIndex[i][ch] ++;
}
hist[i][ch]->Fill( digi[i]->GetData()->GetEnergy(ch, lastFilledIndex[i][ch]));
hist2D[i]->Fill(ch, digi[i]->GetData()->GetEnergy(ch, lastFilledIndex[i][ch]));
}
if( histVisibility[i][ch] ) hist[i][ch]->UpdatePlot();
if( hist2DVisibility[i] ) hist2D[i]->UpdatePlot();