added SW Decimation on the Digi setting panle for QDC. this setting is not saved in setting file

This commit is contained in:
Ryan Tang 2024-10-14 17:47:11 -04:00
parent 2f55f6ecb5
commit 256390ffaf
4 changed files with 42 additions and 6 deletions

View File

@ -105,7 +105,7 @@ class Data{
//^================= Saving data
bool OpenSaveFile(std::string fileNamePrefix); // return false when fail
std::string GetOutFileName() const {return outFileName;}
void SetDecimationFactor(unsigned short factor) { decimation = factor; }
void SetDecimationFactor(unsigned short factor) { decimation = factor; printf("Set Decimation Factor to be %d\n", factor);}
void SaveData();
void CloseSaveFile();
unsigned int GetFileSize() const {return outFileSize;}
@ -500,7 +500,6 @@ inline void Data::SaveData(){
int sampleSize = 0;
int chAggSize = 0;
uint32_t oldHeader0 = 0;
uint32_t oldHeader1 = 0;
uint32_t oldHeader2 = 0;
uint32_t oldHeader3 = 0;
@ -520,7 +519,6 @@ inline void Data::SaveData(){
// fwrite(buffer + i * chunkSize, sizeof(char), chunkSize, outFile);
// fwrite(&word, sizeof(word), 1, outFile);
if( bdAggWordCount == 1 ) oldHeader0 = word;
if( bdAggWordCount == 2 ) oldHeader1 = word;
if( bdAggWordCount == 3 ) oldHeader2 = word;
if( bdAggWordCount == 4 ) oldHeader3 = word;
@ -537,8 +535,7 @@ inline void Data::SaveData(){
sampleSize = (word & 0xFFF) * 8;
bool isExtra = ( (word >> 28 ) & 0x1 );
chAggSize = 2 + sampleSize / 2 + isExtra;
uint32_t oldWord = word;
// uint32_t oldWord = word;
word = (word & 0xFFFFF000) + (sampleSize / 8 / Deci); // change the number of sample
// printf("============= Sample Size : %d | Ch Size : %d | old %08X new %08X\n", sampleSize, chAggSize, oldWord, word);
@ -874,6 +871,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDe
}
}
if( hasWaveForm ){
printf("Sample Size : %d | Decimation: %d \n", nSample, decimation);
printf("...... Analog Probe 1 : ");
switch (analogProbe1 ){
case 0 : printf("Input \n"); break;
@ -1114,6 +1112,7 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe
}
}
if( hasWaveForm ){
printf("Sample Size : %d | Decimation: %d \n", nSample, decimation);
printf(".... digital Probe 1 : ");
switch(digitalProbe1){
case 0 : printf("Long gate \n"); break;
@ -1316,7 +1315,7 @@ inline int Data::DecodeQDCGroupedChannelBlock(unsigned int ChannelMask, bool fas
if( verbose >= 2 ) {
printf("Charge : %d, Time: %d, Wave : %d, Extra: %d\n", hasEnergy, hasTimeStamp, hasWaveForm, hasExtra);
if( hasWaveForm ){
printf("Sample Size : %d .... analog Probe (%d): ", nSample, analogProbe);
printf("Sample Size : %d | Decimation %d .... analog Probe (%d): ", nSample, decimation, analogProbe);
switch(analogProbe){
case 0 : printf("Input\n"); break;
case 1 : printf("Smoothed Input\n"); break;

View File

@ -2534,6 +2534,40 @@ void DigiSettingsPanel::SetUpBoard_QDC(){
SetUpSpinBox(sbNumEventAgg[ID][0], "Event pre Agg. : ", bdCfgLayout[ID], 5, 0, DPP::QDC::NumberEventsPerAggregate, -1, true);
SetUpSpinBox(sbRecordLength[ID][0], "Record Length [ns] : ", bdCfgLayout[ID], 6, 0, DPP::QDC::RecordLength_W, -1, true);
QLabel * lbSWDeci = new QLabel("SW Decimation Factor :", this);
lbSWDeci->setAlignment(Qt::AlignRight | Qt::AlignCenter);
bdCfgLayout[ID]->addWidget(lbSWDeci, 7, 0);
cbSWDecimation[ID] = new RComboBox(this);
bdCfgLayout[ID]->addWidget(cbSWDecimation[ID], 7, 1);
cbSWDecimation[ID]->addItem("No Deci.", 0);
cbSWDecimation[ID]->addItem("Factor 2", 1);
cbSWDecimation[ID]->addItem("Factor 4", 2);
cbSWDecimation[ID]->addItem("Factor 8", 3);
cbSWDecimation[ID]->addItem("Factor 16", 4);
cbSWDecimation[ID]->addItem("Factor 32", 5);
cbSWDecimation[ID]->addItem("Factor 64", 6);
cbSWDecimation[ID]->addItem("Factor 128", 7);
connect(cbSWDecimation[ID], &RComboBox::currentIndexChanged, this, [=](){
if( !enableSignalSlot ) return;
unsigned short factor = cbSWDecimation[ID]->currentData().toInt();
int deci = pow(2, factor);
int sampleSize = sbRecordLength[ID][0]->value() / digi[ID]->GetTick2ns();
if( sampleSize / deci <= 2 ) {
SendLogMsg("Tried to set waveform decimation to be " + QString::number(deci) + ", which make the number of trace less than 2. Abort.");
cbSWDecimation[ID]->setCurrentIndex(0);
}else{
SendLogMsg("Set waveform decimation to be " + QString::number(deci) + ".");
digi[ID]->GetData()->SetDecimationFactor(factor);
}
});
}
void DigiSettingsPanel::SetUpChannel_QDC(){

View File

@ -125,6 +125,8 @@ private:
QGridLayout * bdTriggerLayout[MaxNDigitizer];
QGridLayout * bdLVDSLayout[MaxNDigitizer];
RComboBox * cbSWDecimation[MaxNDigitizer]; // software decimation
QCheckBox * chkAutoDataFlush[MaxNDigitizer];
QCheckBox * chkDecimateTrace[MaxNDigitizer];
QCheckBox * chkTrigPropagation[MaxNDigitizer];

View File

@ -1803,6 +1803,7 @@ void FSUDAQ::OpenDigiSettings(){
digiSettings = new DigiSettingsPanel(digi, nDigi, rawDataPath);
//connect(scope, &Scope::SendLogMsg, this, &FSUDAQ::LogMsg);
connect(digiSettings, &DigiSettingsPanel::UpdateOtherPanels, this, [=](){ UpdateAllPanels(2); });
connect(digiSettings, &DigiSettingsPanel::SendLogMsg, this, &FSUDAQ::LogMsg);
digiSettings->show();
}else{