add ClassData::GetAbsDataIndex()
This commit is contained in:
parent
39f479534e
commit
ae0e0f2c7b
|
@ -52,6 +52,7 @@ class Data{
|
|||
|
||||
int GetLoopIndex(unsigned short ch) const {return LoopIndex[ch];}
|
||||
int GetDataIndex(unsigned short ch) const {return DataIndex[ch];}
|
||||
long GetAbsDataIndex(unsigned short ch) const {return LoopIndex[ch] * dataSize + DataIndex[ch];}
|
||||
|
||||
uShort GetDataSize() const {return dataSize;}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ void SingleSpectra::FillHistograms(){
|
|||
clock_gettime(CLOCK_REALTIME, &ta);
|
||||
|
||||
std::vector<int> digiChList; // (digi*1000 + ch)
|
||||
std::vector<int> digiChLastIndex; // loop * dataSize + index;
|
||||
std::vector<long> digiChLastIndex; // loop * dataSize + index;
|
||||
std::vector<int> digiChAvalibleData;
|
||||
std::vector<bool> digiChFilled;
|
||||
std::vector<int> digiChFilledCount;
|
||||
|
@ -260,10 +260,7 @@ void SingleSpectra::FillHistograms(){
|
|||
|
||||
for( int ID = 0; ID < nDigi; ID++){
|
||||
for( int ch = 0; ch < digi[ID]->GetNumInputCh(); ch++){
|
||||
int lastIndex = digi[ID]->GetData()->GetDataIndex(ch);
|
||||
int loopIndex = digi[ID]->GetData()->GetLoopIndex(ch);
|
||||
|
||||
int temp1 = lastIndex + loopIndex * digi[ID]->GetData()->GetDataSize();
|
||||
int temp1 = digi[ID]->GetData()->GetAbsDataIndex(ch);
|
||||
int temp2 = lastFilledIndex[ID][ch];
|
||||
|
||||
if( temp1 <= temp2 ) continue;
|
||||
|
@ -272,6 +269,9 @@ void SingleSpectra::FillHistograms(){
|
|||
digiChAvalibleData.push_back(temp1-temp2);
|
||||
digiChFilled.push_back(false);
|
||||
digiChFilledCount.push_back(0);
|
||||
|
||||
if( temp1 - temp2 > digi[ID]->GetData()->GetDataSize() ) lastFilledIndex[ID][ch] = temp1 - digi[ID]->GetData()->GetDataSize() ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,9 +302,6 @@ void SingleSpectra::FillHistograms(){
|
|||
// printf("Digi-%2d ch-%2d all filled | %zu\n", ID, ch, digiChList.size());
|
||||
continue;
|
||||
}
|
||||
if( digiChLastIndex[randomValue] - lastFilledIndex[ID][ch] > digi[ID]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k
|
||||
lastFilledIndex[ID][ch] = digiChLastIndex[randomValue] - digi[ID]->GetData()->GetDataSize() ;
|
||||
}
|
||||
|
||||
lastFilledIndex[ID][ch] ++;
|
||||
digiChFilledCount[randomValue]++;
|
||||
|
|
|
@ -74,8 +74,7 @@ private:
|
|||
QGroupBox * histBox;
|
||||
QGridLayout * histLayout;
|
||||
|
||||
int lastFilledIndex[MaxNDigitizer][MaxNChannels];
|
||||
int loopFilledIndex[MaxNDigitizer][MaxNChannels];
|
||||
int lastFilledIndex[MaxNDigitizer][MaxNChannels];// absolute data index = loop * dataSize + index
|
||||
|
||||
bool fillHistograms;
|
||||
|
||||
|
@ -178,7 +177,6 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,36 +188,25 @@ inline void NeutronGamma::UpdateHistograms(){
|
|||
int ID = cbDigi->currentData().toInt();
|
||||
int ch = cbCh->currentData().toInt();
|
||||
|
||||
int lastIndex = digi[ID]->GetData()->GetDataIndex(ch);
|
||||
if( lastIndex < 0 ) return;
|
||||
if( digi[ID]->GetData()->GetDataIndex(ch) < 0 ) return;
|
||||
|
||||
int loopIndex = digi[ID]->GetData()->GetLoopIndex(ch);
|
||||
int dataAvalible = digi[ID]->GetData()->GetAbsDataIndex(ch) - lastFilledIndex[ID][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;
|
||||
if( dataAvalible > digi[ID]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k
|
||||
lastFilledIndex[ID][ch] = digi[ID]->GetData()->GetAbsDataIndex(ch) - digi[ID]->GetData()->GetDataSize();
|
||||
}
|
||||
|
||||
for( int j = 0 ; j <= temp1 - temp2; j ++){
|
||||
do{
|
||||
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);
|
||||
}
|
||||
|
||||
}while(lastFilledIndex[ID][ch] <= digi[ID]->GetData()->GetAbsDataIndex(ch));
|
||||
|
||||
hist2D->UpdatePlot();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user