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