bugs fix for QDC

This commit is contained in:
carina@hades 2023-10-19 14:29:28 -04:00
parent 5279dfad72
commit 3819e422bd
9 changed files with 85 additions and 86 deletions

View File

@ -503,6 +503,9 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){
unsigned long long t0 = Timestamp[ch][(calIndexes[ch][0]) % MaxNData]; // earlier
unsigned long long t1 = Timestamp[ch][(calIndexes[ch][1]) % MaxNData];; // latest
if( t0 > t1 ) printf("data is not in time order");
double sec = ( t1 - t0 ) * tick2ns / 1e9;
TriggerRate[ch] = nEvent / sec;
@ -517,37 +520,6 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){
//printf("%2d | %10llu %10llu, %.0f = %f sec, rate = %f, nEvent %d pileUp %d \n", ch, tList.front() ,tList.back(), tick2ns, sec, nEvent / sec, nEvent, pileUpCount);
}
// if( calIndexes[ch][0] == -1 ) calIndexes[ch][0] = 0;
// if( calIndexes[ch][0] > -1 && calIndexes[ch][1] == -1 ) calIndexes[ch][1] = DataIndex[ch];
// short nEvent = calIndexes[ch][1] - calIndexes[ch][0] ;
// if( nEvent < 0 ) nEvent += MaxNData;
// printf("ch %2d ----- %d %d | %d \n", ch, calIndexes[ch][0], calIndexes[ch][1], nEvent);
// if( calIndexes[ch][0] > -1 && calIndexes[ch][1] > -1 && nEvent > 2 ){
// unsigned long long dTime = Timestamp[ch][calIndexes[ch][1]] - Timestamp[ch][calIndexes[ch][0]];
// double sec = dTime * tick2ns / 1e9;
// TriggerRate[ch] = nEvent / sec;
// short pileUpCount = 0;
// for( int i = calIndexes[ch][0] ; i <= calIndexes[ch][0] + nEvent; i++ ) {
// if( PileUp[ch][i % MaxNData] ) pileUpCount ++;
// }
// printf("%2d | %10llu %10llu, %.0f = %f sec, rate = %f, nEvent %d pileUp %d \n", ch, Timestamp[ch][calIndexes[ch][0]], Timestamp[ch][calIndexes[ch][1]], tick2ns, sec, nEvent / sec, nEvent, pileUpCount);
// NonPileUpRate[ch] = (nEvent - pileUpCount)/sec;
// calIndexes[ch][0] = calIndexes[ch][1];
// calIndexes[ch][1] = -1;
// }else{
// calIndexes[ch][1] = -1;
// }
}
}

View File

@ -398,15 +398,16 @@ int Digitizer::ProgramBoard_QDC(){
int ret = 0;
WriteRegister(DPP::QDC::NumberEventsPerAggregate, 0x10, -1);
WriteRegister(DPP::QDC::RecordLength, 31, -1); // 248 sample = 3968 ns
WriteRegister(DPP::QDC::RecordLength_W, 16, -1); // 128 sample = 2048 ns
WriteRegister(DPP::QDC::PreTrigger, 60, -1); // at 60 sample = 960 ns
WriteRegister(DPP::QDC::GateWidth, 100/16, -1);
WriteRegister(DPP::QDC::GateOffset, 0, -1);
WriteRegister(DPP::QDC::FixedBaseline, 0, -1);
//WriteRegister(DPP::QDC::DPPAlgorithmControl, 0x300112); // with test pulse
WriteRegister(DPP::QDC::DPPAlgorithmControl, 0x300102); // No test pulse
//WriteRegister(DPP::QDC::DPPAlgorithmControl, 0x300112); // with test pulse, positive
//WriteRegister(DPP::QDC::DPPAlgorithmControl, 0x300102); // No test pulse, positive
WriteRegister(DPP::QDC::DPPAlgorithmControl, 0x310102); // No test pulse, negative
WriteRegister(DPP::QDC::TriggerHoldOffWidth, 100/16, -1);
WriteRegister(DPP::QDC::TRGOUTWidth, 100/16, -1);
@ -771,8 +772,7 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){
}
printf("BoardID : 0x%X = DataFormat \n", GetSettingFromMemory(DPP::BoardID));
//printf("BoardID : 0x%X = DataFormat \n", GetSettingFromMemory(DPP::BoardID));
isSettingFilledinMemeory = true;

View File

@ -4,6 +4,7 @@
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QMessageBox>
#include "macro.h"
#include "ClassDigitizer.h"
@ -116,7 +117,7 @@ class TimingThread : public QThread {
Q_OBJECT
public:
TimingThread(QObject * parent = 0 ) : QThread(parent){
waitTime = 20; // 10 x 100 milisec
waitTime = 20; // multiple of 100 mili sec
stop = false;
}
void Stop() { this->stop = true;}

View File

@ -3051,15 +3051,12 @@ void DigiSettingsPanel::SetUpChannel_QDC(){
}
//&###########################################################
void DigiSettingsPanel::UpdateBoardAndChannelsStatus(){
void DigiSettingsPanel::UpdateACQStatus(uint32_t status){
//*========================================
uint32_t AcqStatus = digi[ID]->ReadRegister(DPP::AcquisitionStatus_R);
leACQStatus[ID]->setText( "0x" + QString::number(AcqStatus, 16).toUpper());
leACQStatus[ID]->setText( "0x" + QString::number(status, 16).toUpper());
for( int i = 0; i < 9; i++){
if( Digitizer::ExtractBits(AcqStatus, {1, ACQToolTip[i].second}) == 0 ){
if( Digitizer::ExtractBits(status, {1, ACQToolTip[i].second}) == 0 ){
bnACQStatus[ID][i]->setStyleSheet("");
bnACQStatus[ID][i]->setToolTip(ACQToolTip[i].first.first);
if(ACQToolTip[i].second == 19 ) bnACQStatus[ID][i]->setStyleSheet("background-color: green;");
@ -3070,26 +3067,14 @@ void DigiSettingsPanel::UpdateBoardAndChannelsStatus(){
}
}
//*========================================
uint32_t BdFailStatus = digi[ID]->ReadRegister(DPP::BoardFailureStatus_R);
leBdFailStatus[ID]->setText( "0x" + QString::number(BdFailStatus, 16).toUpper());
}
void DigiSettingsPanel::UpdateReadOutStatus(uint32_t status){
leReadOutStatus[ID]->setText( "0x" + QString::number(status, 16).toUpper());
for( int i = 0; i < 3; i++){
if( Digitizer::ExtractBits(BdFailStatus, {1, BdFailToolTip[i].second}) == 0 ){
bnBdFailStatus[ID][i]->setStyleSheet("background-color: green;");
bnBdFailStatus[ID][i]->setToolTip(BdFailToolTip[i].first.first);
}else{
bnBdFailStatus[ID][i]->setStyleSheet("background-color: red;");
bnBdFailStatus[ID][i]->setToolTip(BdFailToolTip[i].first.second);
}
}
//*========================================
uint32_t ReadoutStatus = digi[ID]->ReadRegister(DPP::ReadoutStatus_R);
leReadOutStatus[ID]->setText( "0x" + QString::number(ReadoutStatus, 16).toUpper());
for( int i = 0; i < 3; i++){
if( Digitizer::ExtractBits(ReadoutStatus, {1, ReadoutToolTip[i].second}) == 0 ){
if( Digitizer::ExtractBits(status, {1, ReadoutToolTip[i].second}) == 0 ){
if( ReadoutToolTip[i].second != 2 ) {
bnReadOutStatus[ID][i]->setStyleSheet("");
}else{
@ -3105,6 +3090,31 @@ void DigiSettingsPanel::UpdateBoardAndChannelsStatus(){
bnReadOutStatus[ID][i]->setToolTip(ReadoutToolTip[i].first.second);
}
}
}
void DigiSettingsPanel::UpdateBoardAndChannelsStatus(){
//*========================================
uint32_t AcqStatus = digi[ID]->ReadRegister(DPP::AcquisitionStatus_R);
UpdateACQStatus(AcqStatus);
//*========================================
uint32_t ReadoutStatus = digi[ID]->ReadRegister(DPP::ReadoutStatus_R);
UpdateReadOutStatus(ReadoutStatus);
//*========================================
uint32_t BdFailStatus = digi[ID]->ReadRegister(DPP::BoardFailureStatus_R);
leBdFailStatus[ID]->setText( "0x" + QString::number(BdFailStatus, 16).toUpper());
for( int i = 0; i < 3; i++){
if( Digitizer::ExtractBits(BdFailStatus, {1, BdFailToolTip[i].second}) == 0 ){
bnBdFailStatus[ID][i]->setStyleSheet("background-color: green;");
bnBdFailStatus[ID][i]->setToolTip(BdFailToolTip[i].first.first);
}else{
bnBdFailStatus[ID][i]->setStyleSheet("background-color: red;");
bnBdFailStatus[ID][i]->setToolTip(BdFailToolTip[i].first.second);
}
}
//*========================================== Channel Status
for( int i = 0; i < digi[ID]->GetNumRegChannels(); i++){

View File

@ -21,10 +21,13 @@ public:
DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QString rawDataPath, QMainWindow * parent = nullptr);
~DigiSettingsPanel();
public slots:
void UpdatePanelFromMemory();
void ReadSettingsFromBoard();
void UpdateBoardAndChannelsStatus(); // will ReadRegister
void UpdateACQStatus(uint32_t status);
void UpdateReadOutStatus(uint32_t status);
void UpdateBoardAndChannelsStatus(); // directly read from register
void SaveSetting(int opt);
void LoadSetting();

View File

@ -234,16 +234,16 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
connect( bnStartACQ, &QPushButton::clicked, this, &MainWindow::AutoRun);
bnStopACQ = new QPushButton("Stop ACQ", this);
connect( bnStopACQ, &QPushButton::clicked, this, [=](){
if( runTimer->isActive() ){
runTimer->stop();
runTimer->disconnect(runTimerConnection);
}else{
breakAutoRepeat = true;
runTimer->disconnect(runTimerConnection);
}
needManualComment = true;
StopACQ();
});
if( runTimer->isActive() ){
runTimer->stop();
runTimer->disconnect(runTimerConnection);
}else{
breakAutoRepeat = true;
runTimer->disconnect(runTimerConnection);
}
needManualComment = true;
StopACQ();
});
layout->addWidget(lbPrefix, rowID, 0);
layout->addWidget(lePrefix, rowID, 1);
@ -381,7 +381,7 @@ void MainWindow::OpenDataPath(){
SaveProgramSettings();
//TODO Check us the dataPath empty, check is the lastRun.sh exist and load the last run.
LoadLastRunFile();
}
@ -695,7 +695,7 @@ void MainWindow::OpenDigitizers(){
SetupScalar();
}
}
void MainWindow::CloseDigitizers(){
@ -968,8 +968,6 @@ void MainWindow::UpdateScalar(){
}
}
//if( digiSettings && digiSettings->isVisible()) digiSettings->UpdateBoardAndChannelsStatus();
digiMTX[iDigi].unlock();
}
@ -1017,7 +1015,7 @@ void MainWindow::StartACQ(){
readDataThread[i]->start();
}
if( chkSaveData->isChecked() ) SaveLastRunFile();
if( chkSaveData->isChecked() ) SaveLastRunFile();
// printf("------------ wait for 2 sec \n");
// usleep(1000*1000);
@ -1225,20 +1223,23 @@ void MainWindow::SetSyncMode(){
QPushButton * bnNoSync = new QPushButton("No Sync");
QPushButton * bnMethod1 = new QPushButton("Software TRG-OUT --> TRG-IN ");
QPushButton * bnMethod2 = new QPushButton("Software TRG-OUT --> S-IN ");
QPushButton * bnMethod3 = new QPushButton("External TRG-OUT --> S-IN ");
QPushButton * bnMethod3 = new QPushButton("External --> 1st S-IN,\nTRG-OUT --> S-IN ");
QPushButton * bnMethod4 = new QPushButton("External All S-IN ");
layout->addWidget(lbInfo1, 0);
layout->addWidget( bnNoSync, 2);
layout->addWidget(bnMethod1, 3);
layout->addWidget(bnMethod2, 4);
layout->addWidget(bnMethod3, 5);
layout->addWidget(bnMethod4, 6);
bnNoSync->setFixedHeight(40);
bnMethod1->setFixedHeight(40);
bnMethod2->setFixedHeight(40);
bnMethod3->setFixedHeight(40);
bnMethod4->setFixedHeight(40);
connect(bnNoSync, &QPushButton::clicked, [&](){
connect(bnNoSync, &QPushButton::clicked, [&](){ /// No Sync
for(unsigned int i = 0; i < nDigi; i++){
digi[i]->WriteRegister(DPP::AcquisitionControl, 0);
digi[i]->WriteRegister(DPP::FrontPanelIOControl, 0);
@ -1247,7 +1248,7 @@ void MainWindow::SetSyncMode(){
dialog.accept();
});
connect(bnMethod1, &QPushButton::clicked, [&](){
connect(bnMethod1, &QPushButton::clicked, [&](){ /// Software TRG-OUT --> TRG-IN
digi[0]->WriteRegister(DPP::AcquisitionControl, 0);
digi[0]->WriteRegister(DPP::FrontPanelIOControl, 0x10000); //RUN
for(unsigned int i = 1; i < nDigi; i++){
@ -1258,7 +1259,7 @@ void MainWindow::SetSyncMode(){
dialog.accept();
});
connect(bnMethod2, &QPushButton::clicked, [&](){
connect(bnMethod2, &QPushButton::clicked, [&](){ /// Software TRG-OUT --> S-IN
digi[0]->WriteRegister(DPP::AcquisitionControl, 0);
digi[0]->WriteRegister(DPP::FrontPanelIOControl, 0x10000); //RUN
for(unsigned int i = 1; i < nDigi; i++){
@ -1269,7 +1270,8 @@ void MainWindow::SetSyncMode(){
dialog.accept();
});
connect(bnMethod3, &QPushButton::clicked, [&](){
connect(bnMethod3, &QPushButton::clicked, [&](){ ///External TRG-OUT --> S-IN
digi[0]->WriteRegister(DPP::AcquisitionControl, 0x01);
for(unsigned int i = 0; i < nDigi; i++){
digi[i]->WriteRegister(DPP::AcquisitionControl, 0x41);
digi[i]->WriteRegister(DPP::FrontPanelIOControl, 0x30000); // S-IN
@ -1278,6 +1280,15 @@ void MainWindow::SetSyncMode(){
dialog.accept();
});
connect(bnMethod4, &QPushButton::clicked, [&](){ /// External All S-IN
digi[0]->WriteRegister(DPP::AcquisitionControl, 0x01);
for(unsigned int i = 1; i < nDigi; i++){
digi[i]->WriteRegister(DPP::AcquisitionControl, 0x41);
}
if( digiSettings && digiSettings->isVisible() ) digiSettings->UpdatePanelFromMemory();
dialog.accept();
});
dialog.exec();
}

View File

@ -108,6 +108,7 @@ Those file can be compiled using
* DC offset issue. When porgram default settings, the DC offset is not the same for all channels.
* for PHA firmware, when the trigger average changed, the Events per Agg need to be changed.
* Sometimes, the buffer is not in time order, and make the trigger/Accept rate to be nagative. This is nothing to do with the program but the digitizer settings. Recommand reporgram the digitizer.
* for 1740 QDC, RecordLenght is board setting, but readout is indivuial group.
# Known Bugs

View File

@ -787,7 +787,7 @@ namespace DPP {
namespace QDC { // Register already grouped in channel. and there no control for indiviual channel except the Fine DC offset and threshold, so it is like no group
const Reg NumberEventsPerAggregate ("Number of Events per Aggregate", 0x1020, RW::ReadWrite, false, 0x3FF, -1); /// R/W
const Reg RecordLength ("Record Length" , 0x1024, RW::ReadWrite, false, 0x1FFF, 8); /// R/W
const Reg RecordLength ("Record Length_R" , 0x1024, RW::ReadWrite, false, 0x1FFF, 8); /// R/W
const Reg GateWidth ("GateWidth" , 0x1030, RW::ReadWrite, false, 0xFFF, 1); /// R/W
const Reg GateOffset ("GateOfset" , 0x1034, RW::ReadWrite, false, 0xFF, 1); /// R/W
const Reg FixedBaseline ("FixedBaseline" , 0x1038, RW::ReadWrite, false, 0xFFF, -1); /// R/W
@ -811,8 +811,8 @@ namespace DPP {
const Reg TriggerThreshold_sub6 ("Trigger Threshold sub6" , 0x10E8, RW::ReadWrite, false, 0xFFF, -1); /// R/W
const Reg TriggerThreshold_sub7 ("Trigger Threshold sub7" , 0x10EC, RW::ReadWrite, false, 0xFFF, -1); /// R/W
const Reg GroupEnableMask ("Group Enable Mask" , 0x8120, RW::ReadWrite, false, 0xFF, -1); /// R/W
const Reg RecordLength_W ("Record Length_W" , 0x8024, RW::WriteONLY, false, 0x1FFF, 8); /// /W
const Reg GroupEnableMask ("Group Enable Mask" , 0x8120, RW::ReadWrite, false, 0xFF, -1); /// R/W
namespace Bit_DPPAlgorithmControl {
const std::pair<unsigned short, unsigned short> ChargeSensitivity = {3, 0} ; /// length, smallest pos
@ -1025,6 +1025,7 @@ const std::vector<Reg> RegisterBoardList_QDC = {
DPP::BoardConfiguration ,
DPP::AggregateOrganization,
DPP::QDC::NumberEventsPerAggregate,
DPP::QDC::RecordLength_W,
DPP::AcquisitionControl,
DPP::AcquisitionStatus_R,
DPP::SoftwareTrigger_W,