diff --git a/SingleSpectra.cpp b/SingleSpectra.cpp index d8da715..801449b 100644 --- a/SingleSpectra.cpp +++ b/SingleSpectra.cpp @@ -204,28 +204,39 @@ void SingleSpectra::FillHistograms(){ // DebugPrint("%s", "SingleSpectra"); if( !fillHistograms ) return; + printf("=====================%s\n", __func__); + timespec t0, t1; QVector randomDigiList = generateNonRepeatedCombination(nDigi); + // qDebug() << randomDigiList; + for( int i = 0; i < nDigi; i++){ int ID = randomDigiList[i]; QVector randomChList = generateNonRepeatedCombination(digi[ID]->GetNumInputCh()); + // qDebug() << randomChList; + digiMTX[ID].lock(); + + // digi[ID]->GetData()->PrintAllData(); + 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(); + 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); - // printf("%d |%d %d \n", ch, temp2, temp1); if( temp1 <= temp2 ) continue; if( temp1 - temp2 > digi[ID]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k @@ -233,6 +244,8 @@ void SingleSpectra::FillHistograms(){ 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] ++; @@ -240,8 +253,13 @@ void SingleSpectra::FillHistograms(){ lastFilledIndex[ID][ch] = 0; loopFilledIndex[ID][ch] ++; } - hist[ID][ch]->Fill( digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch])); - hist2D[ID]->Fill(ch, digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch])); + + uShort data = digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch]); + + // printf(" ch: %d, last fill idx : %d | %d \n", ch, lastFilledIndex[ID][ch], data); + + hist[ID][ch]->Fill( data ); + hist2D[ID]->Fill(ch, data); } if( histVisibility[ID][ch] ) hist[ID][ch]->UpdatePlot(); if( hist2DVisibility[ID] ) hist2D[ID]->UpdatePlot();