change the Decimation for QDC to be average of 2^n
This commit is contained in:
parent
84b89cb36a
commit
88823af2c6
55
ClassData.h
55
ClassData.h
|
@ -504,6 +504,8 @@ inline void Data::SaveData(){
|
||||||
uint32_t oldHeader2 = 0;
|
uint32_t oldHeader2 = 0;
|
||||||
uint32_t oldHeader3 = 0;
|
uint32_t oldHeader3 = 0;
|
||||||
|
|
||||||
|
uint16_t average = 0; // to calculate Decimation average
|
||||||
|
|
||||||
for( size_t i = 0; i < numChunk; i++ ){
|
for( size_t i = 0; i < numChunk; i++ ){
|
||||||
|
|
||||||
bdAggWordCount ++;
|
bdAggWordCount ++;
|
||||||
|
@ -513,7 +515,7 @@ inline void Data::SaveData(){
|
||||||
|
|
||||||
if( bdAggWordCount == 1 ) {
|
if( bdAggWordCount == 1 ) {
|
||||||
bdAggSize = word & 0x0FFFFFFF;
|
bdAggSize = word & 0x0FFFFFFF;
|
||||||
// printf("###################### Bd Agg Size : %d\n", bdAggSize);
|
printf("###################### Bd Agg Size : %d\n", bdAggSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fwrite(buffer + i * chunkSize, sizeof(char), chunkSize, outFile);
|
// fwrite(buffer + i * chunkSize, sizeof(char), chunkSize, outFile);
|
||||||
|
@ -529,18 +531,19 @@ inline void Data::SaveData(){
|
||||||
|
|
||||||
if( groupWordCount == 1 ) {
|
if( groupWordCount == 1 ) {
|
||||||
groupAggSize = word & 0x3FFFFFFF;
|
groupAggSize = word & 0x3FFFFFFF;
|
||||||
// printf("============= Coupled Channel Agg Size : %d \n", groupAggSize);
|
printf("============= Coupled Channel Agg Size : %d \n", groupAggSize);
|
||||||
}
|
}
|
||||||
if( groupWordCount == 2 ) {
|
if( groupWordCount == 2 ) {
|
||||||
sampleSize = (word & 0xFFF) * 8;
|
sampleSize = (word & 0xFFF) * 8;
|
||||||
bool isExtra = ( (word >> 28 ) & 0x1 );
|
bool isExtra = ( (word >> 28 ) & 0x1 );
|
||||||
chAggSize = 2 + sampleSize / 2 + isExtra;
|
chAggSize = 2 + sampleSize / 2 + isExtra;
|
||||||
// uint32_t oldWord = word;
|
uint32_t oldWord = word;
|
||||||
word = (word & 0xFFFFF000) + (sampleSize / 8 / Deci); // change the number of sample
|
uint32_t newSampleSize = sampleSize / Deci;
|
||||||
// printf("============= Sample Size : %d | Ch Size : %d | old %08X new %08X\n", sampleSize, chAggSize, oldWord, word);
|
word = (word & 0xFFFFF000) + (newSampleSize / 8 ); // change the number of sample
|
||||||
|
printf("============= Sample Size : %d | Ch Size : %d | old %08X new %08X\n", sampleSize, chAggSize, oldWord, word);
|
||||||
|
|
||||||
int nEvent = (groupAggSize - 2 ) / chAggSize;
|
int nEvent = (groupAggSize - 2 ) / chAggSize;
|
||||||
int newGroupAggSize = 2 + nEvent * ( 2 + sampleSize / Deci / 2 + isExtra );
|
int newGroupAggSize = 2 + nEvent * ( 2 + newSampleSize / 2 + isExtra );
|
||||||
int newBdAggSize = 4 + newGroupAggSize;
|
int newBdAggSize = 4 + newGroupAggSize;
|
||||||
|
|
||||||
//Write board header and Agg header
|
//Write board header and Agg header
|
||||||
|
@ -550,21 +553,22 @@ inline void Data::SaveData(){
|
||||||
fwrite(&oldHeader2, sizeof(uint32_t), 1, outFile);
|
fwrite(&oldHeader2, sizeof(uint32_t), 1, outFile);
|
||||||
fwrite(&oldHeader3, sizeof(uint32_t), 1, outFile);
|
fwrite(&oldHeader3, sizeof(uint32_t), 1, outFile);
|
||||||
|
|
||||||
uint32_t newAggHeader0 = (0x8 << 28) + newGroupAggSize + (decimation << 12); // add decimation factor in the word
|
uint32_t newAggHeader0 = (0x8 << 28) + newGroupAggSize ; // add decimation factor in the word
|
||||||
|
uint32_t newAggHeader1 = word + (decimation << 12); // add decimation factor in the word
|
||||||
fwrite(&newAggHeader0, sizeof(uint32_t), 1, outFile);
|
fwrite(&newAggHeader0, sizeof(uint32_t), 1, outFile);
|
||||||
fwrite(&word, sizeof(uint32_t), 1, outFile);
|
fwrite(&newAggHeader1, sizeof(uint32_t), 1, outFile);
|
||||||
|
|
||||||
// printf(" New Board Agg Size : %d \n", newBdAggSize);
|
// printf(" New Board Agg Size : %d \n", newBdAggSize);
|
||||||
// printf(" New Group Agg Size : %d \n", newGroupAggSize);
|
// printf(" New Group Agg Size : %d \n", newGroupAggSize);
|
||||||
// printf(" nEvent : %d \n", nEvent);
|
// printf(" nEvent : %d \n", nEvent);
|
||||||
// printf(" New Event Agg Size : %d \n", 2 + sampleSize / Deci / 2 + isExtra);
|
// printf(" New Event Agg Size : %d \n", 2 + sampleSize / Deci / 2 + isExtra);
|
||||||
|
|
||||||
// printf("%3d | %08X \n", 1, newHeader0);
|
printf("%3d | %08X \n", 1, newHeader0);
|
||||||
// printf("%3d | %08X \n", 2, oldHeader1);
|
printf("%3d | %08X \n", 2, oldHeader1);
|
||||||
// printf("%3d | %08X \n", 3, oldHeader2);
|
printf("%3d | %08X \n", 3, oldHeader2);
|
||||||
// printf("%3d | %08X \n", 4, oldHeader3);
|
printf("%3d | %08X \n", 4, oldHeader3);
|
||||||
// printf("%3d | %3d | %08X \n", 5, 1, newAggHeader0);
|
printf("%3d | %3d | %08X \n", 5, 1, newAggHeader0);
|
||||||
// printf("%3d | %3d | %08X \n", 6, 2, word);
|
printf("%3d | %3d | %08X \n", 6, 2, newAggHeader1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( groupWordCount > 2 ) {
|
if( groupWordCount > 2 ) {
|
||||||
|
@ -573,17 +577,25 @@ inline void Data::SaveData(){
|
||||||
if( 1 < chWordCount && chWordCount <= chAggSize - 2 ){ // trace
|
if( 1 < chWordCount && chWordCount <= chAggSize - 2 ){ // trace
|
||||||
sampleWordCount ++;
|
sampleWordCount ++;
|
||||||
uint16_t S0 = word & 0xFFFF;
|
uint16_t S0 = word & 0xFFFF;
|
||||||
|
uint16_t S1 = (word >> 16) & 0xFFFF;
|
||||||
|
|
||||||
if( decimation == 1 ){
|
if( decimation == 1 ){
|
||||||
// printf("%3d | %3d | %3d | %3d | %08X | %4X \n", bdAggWordCount, groupWordCount, chWordCount, sampleWordCount, word, S0);
|
average = S0/2 + S1/2;
|
||||||
fwrite(&S0, sizeof(S0), 1, outFile);
|
printf("%3d | %3d | %3d | %3d | %08X | %4X \n", bdAggWordCount, groupWordCount, chWordCount, sampleWordCount, word, average);
|
||||||
}else if( sampleWordCount % decimation == 1) {
|
fwrite(&average, sizeof(average), 1, outFile);
|
||||||
// printf("%3d | %3d | %3d | %3d | %08X | %4X \n", bdAggWordCount, groupWordCount, chWordCount, sampleWordCount, word, S0);
|
}else{
|
||||||
fwrite(&S0, sizeof(S0), 1, outFile);
|
average += S0/Deci + S1/Deci;
|
||||||
|
printf("%3d | %3d | %3d | %3d | %08X | %4X \n", bdAggWordCount, groupWordCount, chWordCount, sampleWordCount, word, average);
|
||||||
|
if( sampleWordCount % (Deci/2) == 0) {
|
||||||
|
// fwrite(&S0, sizeof(S0), 1, outFile);
|
||||||
|
printf(" --> %4X \n", average);
|
||||||
|
fwrite(&average, sizeof(average), 1, outFile);
|
||||||
|
average = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
// printf("%3d | %3d | %3d | %08X \n", bdAggWordCount, groupWordCount, chWordCount, word);
|
printf("%3d | %3d | %3d | %08X \n", bdAggWordCount, groupWordCount, chWordCount, word);
|
||||||
fwrite(&word, sizeof(word), 1, outFile);
|
fwrite(&word, sizeof(word), 1, outFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1292,6 +1304,7 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe
|
||||||
|
|
||||||
//*=================================================
|
//*=================================================
|
||||||
inline int Data::DecodeQDCGroupedChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose){
|
inline int Data::DecodeQDCGroupedChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose){
|
||||||
|
if( verbose ) printf("########## %s \n", __func__);
|
||||||
|
|
||||||
//nw = nw + 1;
|
//nw = nw + 1;
|
||||||
unsigned int word = ReadBuffer(nw, verbose);
|
unsigned int word = ReadBuffer(nw, verbose);
|
||||||
|
@ -1304,7 +1317,7 @@ inline int Data::DecodeQDCGroupedChannelBlock(unsigned int ChannelMask, bool fas
|
||||||
unsigned int nEvents = 0;
|
unsigned int nEvents = 0;
|
||||||
nw = nw + 1; word = ReadBuffer(nw, verbose);
|
nw = nw + 1; word = ReadBuffer(nw, verbose);
|
||||||
unsigned short decimation = (word >> 12) & 0xF ;
|
unsigned short decimation = (word >> 12) & 0xF ;
|
||||||
unsigned int nSample = ( word & 0xFFFF ) * 8;
|
unsigned int nSample = ( word & 0xFFF ) * 8;
|
||||||
unsigned int analogProbe = ( (word >> 22 ) & 0x3 );
|
unsigned int analogProbe = ( (word >> 22 ) & 0x3 );
|
||||||
bool hasWaveForm = ( (word >> 27 ) & 0x1 );
|
bool hasWaveForm = ( (word >> 27 ) & 0x1 );
|
||||||
bool hasExtra = ( (word >> 28 ) & 0x1 );
|
bool hasExtra = ( (word >> 28 ) & 0x1 );
|
||||||
|
|
|
@ -2545,6 +2545,8 @@ void DigiSettingsPanel::SetUpBoard_QDC(){
|
||||||
SetUpSpinBox(sbRecordLength[ID][0], "Record Length [ns] : ", bdCfgLayout[ID], 6, 0, DPP::QDC::RecordLength_W, -1, true);
|
SetUpSpinBox(sbRecordLength[ID][0], "Record Length [ns] : ", bdCfgLayout[ID], 6, 0, DPP::QDC::RecordLength_W, -1, true);
|
||||||
|
|
||||||
SetUpSpinBox( sbSWDecimation[ID], "SW Decimation Factor : ", bdCfgLayout[ID], 7, 0, DPP::DecimationFactor, -1, true);
|
SetUpSpinBox( sbSWDecimation[ID], "SW Decimation Factor : ", bdCfgLayout[ID], 7, 0, DPP::DecimationFactor, -1, true);
|
||||||
|
QLabel * lbDeci = new QLabel("This average trace.", this);
|
||||||
|
bdCfgLayout[ID]->addWidget(lbDeci, 7, 2, 1, 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user