Merge remote-tracking branch 'origin' into raisor

This commit is contained in:
RAISOR Group 2024-06-04 12:00:14 -05:00
commit cf2cf51095
16 changed files with 621 additions and 232 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@ FSUDAQ_Qt6
test
test_indep
programSettings.txt
a4818_list.txt
EventBuilder
EventBuilderNew
EventBuilder2

View File

@ -160,6 +160,7 @@
"fstream": "cpp",
"Analyzer.C": "cpp",
"process_Run.C": "cpp",
"EncoreAnalyzer.C": "cpp"
"EncoreAnalyzer.C": "cpp",
"qfiledialog": "cpp"
}
}

View File

@ -113,9 +113,9 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
}
if( ret == 0 ){
if( LinkType == CAEN_DGTZ_USB ) printf("Open digitizer via USB, board : %d\n", boardID);
if( LinkType == CAEN_DGTZ_OpticalLink ) printf("Open digitizer via Optical Link, port : %d, board : %d\n", portID, boardID);
if( LinkType == CAEN_DGTZ_USB_A4818 ) printf("Open digitizer via A4818, port : %d, board : %d\n", portID, boardID);
if( LinkType == CAEN_DGTZ_USB ) printf("### Open digitizer via USB, board : %d\n", boardID);
if( LinkType == CAEN_DGTZ_OpticalLink ) printf("### Open digitizer via Optical Link, port : %d, board : %d\n", portID, boardID);
if( LinkType == CAEN_DGTZ_USB_A4818 ) printf("### Open digitizer via A4818, port : %d, board : %d\n", portID, boardID);
}
if (ret != 0) {
@ -1258,40 +1258,40 @@ std::string Digitizer::GetDPPString(int DPPType){
void Digitizer::ErrorMsg(std::string header){
switch (ret){
///case CAEN_DGTZ_Success : /** 0 */ printf("%s | Operation completed successfully.\n", header.c_str()); break;
case CAEN_DGTZ_CommError : /** -1 */ printf("%s %d | %d, Communication Error.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_GenericError : /** -2 */ printf("%s %d | %d, Unspecified error.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidParam : /** -3 */ printf("%s %d | %d, Invalid parameter.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidLinkType : /** -4 */ printf("%s %d | %d, Invalid Link Type.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidHandle : /** -5 */ printf("%s %d | %d, Invalid device handler.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_MaxDevicesError : /** -6 */ printf("%s %d | %d, Maximum number of devices exceeded.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_BadBoardType : /** -7 */ printf("%s %d | %d, Operation not allowed on this type of board.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_BadInterruptLev : /** -8 */ printf("%s %d | %d, The interrupt level is not allowed.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_BadEventNumber : /** -9 */ printf("%s %d | %d, The event number is bad.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_ReadDeviceRegisterFail : /** -10 */ printf("%s %d | %d, Unable to read the registry.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_WriteDeviceRegisterFail : /** -11 */ printf("%s %d | %d, Unable to write the registry.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidChannelNumber : /** -13 */ printf("%s %d | %d, The channel number is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_ChannelBusy : /** -14 */ printf("%s %d | %d, The channel is busy.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_FPIOModeInvalid : /** -15 */ printf("%s %d | %d, Invalid FPIO mode.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_WrongAcqMode : /** -16 */ printf("%s %d | %d, Wrong Acquistion mode.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_FunctionNotAllowed : /** -17 */ printf("%s %d | %d, This function is not allowed on this module.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_Timeout : /** -18 */ printf("%s %d | %d, Communication Timeout.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidBuffer : /** -19 */ printf("%s %d | %d, The buffer is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_EventNotFound : /** -20 */ printf("%s %d | %d, The event is not found.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidEvent : /** -21 */ printf("%s %d | %d, The event is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_OutOfMemory : /** -22 */ printf("%s %d | %d, Out of memory.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_CalibrationError : /** -23 */ printf("%s %d | %d, Unable to calibrate the board.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_DigitizerNotFound : /** -24 */ printf("%s %d | %d, Unbale to open the digitizer.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_DigitizerAlreadyOpen : /** -25 */ printf("%s %d | %d, The digitizer is already open.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_DigitizerNotReady : /** -26 */ printf("%s %d | %d, The digitizer is not ready.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InterruptNotConfigured : /** -27 */ printf("%s %d | %d, The digitizer has no IRQ configured.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_DigitizerMemoryCorrupted: /** -28 */ printf("%s %d | %d, The digitizer flash memory is corrupted.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_DPPFirmwareNotSupported : /** -29 */ printf("%s %d | %d, The digitier DPP firmware is not supported in this lib version.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidLicense : /** -30 */ printf("%s %d | %d, Invalid firmware licence.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidDigitizerStatus : /** -31 */ printf("%s %d | %d, The digitizer is found in a corrupted status.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_UnsupportedTrace : /** -32 */ printf("%s %d | %d, The given trace is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidProbe : /** -33 */ printf("%s %d | %d, The given probe is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_UnsupportedBaseAddress : /** -34 */ printf("%s %d | %d, The base address is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_NotYetImplemented : /** -99 */ printf("%s %d | %d, The function is not yet implemented.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_CommError : /** -1 */ printf("%s digi-%d | %d, Communication Error.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_GenericError : /** -2 */ printf("%s digi-%d | %d, Unspecified error.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidParam : /** -3 */ printf("%s digi-%d | %d, Invalid parameter.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidLinkType : /** -4 */ printf("%s digi-%d | %d, Invalid Link Type.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidHandle : /** -5 */ printf("%s digi-%d | %d, Invalid device handler.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_MaxDevicesError : /** -6 */ printf("%s digi-%d | %d, Maximum number of devices exceeded.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_BadBoardType : /** -7 */ printf("%s digi-%d | %d, Operation not allowed on this type of board.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_BadInterruptLev : /** -8 */ printf("%s digi-%d | %d, The interrupt level is not allowed.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_BadEventNumber : /** -9 */ printf("%s digi-%d | %d, The event number is bad.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_ReadDeviceRegisterFail : /** -10 */ printf("%s digi-%d | %d, Unable to read the registry.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_WriteDeviceRegisterFail : /** -11 */ printf("%s digi-%d | %d, Unable to write the registry.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidChannelNumber : /** -13 */ printf("%s digi-%d | %d, The channel number is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_ChannelBusy : /** -14 */ printf("%s digi-%d | %d, The channel is busy.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_FPIOModeInvalid : /** -15 */ printf("%s digi-%d | %d, Invalid FPIO mode.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_WrongAcqMode : /** -16 */ printf("%s digi-%d | %d, Wrong Acquistion mode.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_FunctionNotAllowed : /** -17 */ printf("%s digi-%d | %d, This function is not allowed on this module.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_Timeout : /** -18 */ printf("%s digi-%d | %d, Communication Timeout.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidBuffer : /** -19 */ printf("%s digi-%d | %d, The buffer is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_EventNotFound : /** -20 */ printf("%s digi-%d | %d, The event is not found.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidEvent : /** -21 */ printf("%s digi-%d | %d, The event is invalid.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_OutOfMemory : /** -22 */ printf("%s digi-%d | %d, Out of memory.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_CalibrationError : /** -23 */ printf("%s digi-%d | %d, Unable to calibrate the board.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_DigitizerNotFound : /** -24 */ printf("%s digi-%d | %d, Unbale to open the digitizer.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_DigitizerAlreadyOpen : /** -25 */ printf("%s digi-%d | %d, The digitizer is already open.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_DigitizerNotReady : /** -26 */ printf("%s digi-%d | %d, The digitizer is not ready.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InterruptNotConfigured : /** -27 */ printf("%s digi-%d | %d, The digitizer has no IRQ configured.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_DigitizerMemoryCorrupted: /** -28 */ printf("%s digi-%d | %d, The digitizer flash memory is corrupted.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_DPPFirmwareNotSupported : /** -29 */ printf("%s digi-%d | %d, The digitier DPP firmware is not supported in this lib version.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidLicense : /** -30 */ printf("%s digi-%d | %d, Invalid firmware licence.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidDigitizerStatus : /** -31 */ printf("%s digi-%d | %d, The digitizer is found in a corrupted status.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_UnsupportedTrace : /** -32 */ printf("%s digi-%d | %d, The given trace is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_InvalidProbe : /** -33 */ printf("%s digi-%d | %d, The given probe is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_UnsupportedBaseAddress : /** -34 */ printf("%s digi-%d | %d, The base address is not supported.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
case CAEN_DGTZ_NotYetImplemented : /** -99 */ printf("%s digi-%d | %d, The function is not yet implemented.\n", header.c_str(), BoardInfo.SerialNumber, ret); break;
}
}
@ -1339,8 +1339,10 @@ void Digitizer::SetOptimialAggOrg(){
}
uint32_t EventAgg = ReadRegister(DPP::QDC::NumberEventsPerAggregate, 0);
if( EventAgg == 0 ) WriteRegister(DPP::QDC::NumberEventsPerAggregate, 30);
uint32_t chMask = ReadRegister(DPP::QDC::GroupEnableMask);
uint32_t RecordLen = ReadRegister(DPP::QDC::RecordLength_R, 0);
if( RecordLen == 0 ) SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 0, -1);
uint32_t AggRead = ReadRegister(DPP::MaxAggregatePerBlockTransfer);
uint32_t boardCfg = ReadRegister(DPP::BoardConfiguration);
@ -1359,7 +1361,9 @@ void Digitizer::SetOptimialAggOrg(){
printf(" Record Length (bit) : %u = %u sample = %u ns\n", RecordLen, RecordLen*8, RecordLen*8*16);
printf("==============================================================\n");
int eventSize = 6 + 2 * Ex + traceOn * RecordLen * 8; // sample
printf(" estimated event size : %d sample \n", eventSize);
double maxAggOrg = log2( MemorySizekSample * 1024 / eventSize / EventAgg );
printf(" max Agg. Org. should be less than %.2f\n", maxAggOrg);
uint32_t aggOrg = std::floor(maxAggOrg) ;

View File

@ -90,6 +90,7 @@ class Digitizer{
bool IsConnected() {return isConnected;}
void DisableBoard() {softwareDisable = true;}
void EnableBoard() {softwareDisable = false;}
bool IsBoardDisabled() const {return softwareDisable;}
void PrintBoard();

View File

@ -5,6 +5,7 @@
#include <QMutex>
#include <QWaitCondition>
#include <QMessageBox>
#include <QCoreApplication>
#include "macro.h"
#include "ClassDigitizer.h"
@ -35,9 +36,13 @@ public:
stop = false;
readCount = 0;
clock_gettime(CLOCK_REALTIME, &t0);
ta = t0;
// ta = t0;
t1 = t0;
digiMTX[ID].lock();
digi->ReadACQStatus();
digiMTX[ID].unlock();
printf("ReadDataThread for digi-%d running.\n", digi->GetSerialNumber());
do{
@ -77,20 +82,20 @@ public:
digi->ReadACQStatus();
digiMTX[ID].unlock();
t2 = t1;
// QCoreApplication::processEvents();
}
if( isSaveData && !stop ) {
clock_gettime(CLOCK_REALTIME, &tb);
if( tb.tv_sec - ta.tv_sec > 2 ) {
digiMTX[ID].lock();
emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetData()->GetTotalFileSize()/1024./1024., 'f', 4) + " MB [" + QString::number(tb.tv_sec-t0.tv_sec) + " sec]");
//emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetData()->GetTotalFileSize()/1024./1024., 'f', 4) + " MB [" + QString::number(tb.tv_sec-t0.tv_sec) + " sec] (" + QString::number(readCount) + ")");
digiMTX[ID].unlock();
// readCount = 0;
ta = tb;
}
}
// if( isSaveData && !stop ) {
// clock_gettime(CLOCK_REALTIME, &tb);
// if( tb.tv_sec - ta.tv_sec > 2 ) {
// digiMTX[ID].lock();
// emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetData()->GetTotalFileSize()/1024./1024., 'f', 4) + " MB [" + QString::number(tb.tv_sec-t0.tv_sec) + " sec]");
// //emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetData()->GetTotalFileSize()/1024./1024., 'f', 4) + " MB [" + QString::number(tb.tv_sec-t0.tv_sec) + " sec] (" + QString::number(readCount) + ")");
// digiMTX[ID].unlock();
// // readCount = 0;
// ta = tb;
// }
// }
}while(!stop);
printf("ReadDataThread for digi-%d stopped.\n", digi->GetSerialNumber());
}
@ -104,7 +109,6 @@ private:
bool isSaveData;
bool isScope;
unsigned long readCount;
};
//^#======================================================= Timing Thread

View File

@ -97,8 +97,17 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
SetUpInfo("Ch. Mem. Size ", memStr.toStdString() , infoLayout[ID], 3, 2);
uint32_t boardInfo = digi[ID]->GetSettingFromMemory(DPP::BoardInfo_R);
printf("----------- boardInfo : 0x%08X \n", boardInfo);
SetUpInfo("Board Type ", ((boardInfo >> 16) & 0xFF) == 0x10 ? "16-ch VME" : "8-ch Bd.", infoLayout[ID], 3, 4);
// printf("----------- boardInfo : 0x%08X \n", boardInfo);
std::string boardInfoStr;
unsigned short boardTypeNumber = (boardInfo & 0xFF);
switch (boardTypeNumber){
case 0x04 : boardInfoStr = "64-ch VME"; break;
case 0x0E : boardInfoStr = ((boardInfo >> 16) & 0xFF) == 0x10 ? "16-ch VME" : "8-ch Bd."; break;
case 0x0B : boardInfoStr = ((boardInfo >> 16) & 0xFF) == 0x10 ? "16-ch VME" : "8-ch Bd."; break;
default : boardInfoStr = "unknown";
}
SetUpInfo("Board Type ", boardInfoStr, infoLayout[ID], 3, 4);
}
@ -219,9 +228,17 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
connect(bnLoadSettings, &QPushButton::clicked, this, &DigiSettingsPanel::LoadSetting);
rowID ++; //---------------------------
bnSendSoftwareTriggerSignal = new QPushButton("Send SW Trigger Signal", this);
buttonLayout->addWidget(bnSendSoftwareTriggerSignal, rowID, 0);
connect(bnSendSoftwareTriggerSignal, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(DPP::SoftwareTrigger_W, 1); UpdateBoardAndChannelsStatus();});
// bnSendSoftwareTriggerSignal = new QPushButton("Send SW Trigger Signal", this);
// buttonLayout->addWidget(bnSendSoftwareTriggerSignal, rowID, 0);
// connect(bnSendSoftwareTriggerSignal, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(DPP::SoftwareTrigger_W, 1); UpdateBoardAndChannelsStatus();});
bnSetNoTrace = new QPushButton("Set No Trace", this);
buttonLayout->addWidget(bnSetNoTrace, rowID, 0);
connect(bnSetNoTrace, &QPushButton::clicked, this, [=](){
for( unsigned int i = 0; i < nDigi; i++){
chkTraceRecording[i]->setChecked(false);
}
});
bhAutoSetEventPulling = new QPushButton("Autoset Reading Conf.", this);
buttonLayout->addWidget(bhAutoSetEventPulling, rowID, 1);
@ -330,7 +347,6 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
ID = index;
//if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) UpdatePanelFromMemory();
UpdatePanelFromMemory();
}
});
@ -1376,6 +1392,27 @@ void DigiSettingsPanel::SetUpChannelMask(unsigned int digiID){
});
}
QLabel * blank = new QLabel(" ", this);
chLayout->addWidget(blank, 1, nChGrp );
cbDigiEnable[digiID] = new QCheckBox("Enable Digitizer",this);
cbDigiEnable[digiID]->setChecked(true);
chLayout->addWidget(cbDigiEnable[digiID], 1, nChGrp + 2 );
connect(cbDigiEnable[digiID], &QCheckBox::stateChanged, this, [=](int state){
if( state == Qt::Checked ){
digi[digiID]->EnableBoard();
cbDigiEnable[digiID]->setStyleSheet("");
tabWidget->setTabText(digiID, "Digi-" + QString::number(digi[digiID]->GetSerialNumber()));
}else{
digi[digiID]->DisableBoard();
cbDigiEnable[digiID]->setStyleSheet("color: red");
tabWidget->setTabText(digiID, "Digi-" + QString::number(digi[digiID]->GetSerialNumber()) + "(D)");
}
UpdateBoardAndChannelsStatus();
});
}
void DigiSettingsPanel::SetUpACQReadOutTab(){
@ -2280,7 +2317,7 @@ void DigiSettingsPanel::SetUpChannel_PSD(){
SetUpSpinBox(sbThreshold[ID][ch], "", tabLayout, ch + 1, 2, DPP::PSD::TriggerThreshold, ch);
SetUpComboBoxBit(cbTrigMode[ID][ch], "", tabLayout, ch + 1, 4, DPP::Bit_DPPAlgorithmControl_PHA::ListTrigMode, DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::TriggerMode, 1, ch);
SetUpSpinBox(sbTriggerHoldOff[ID][ch], "", tabLayout, ch + 1, 6, DPP::PSD::TriggerHoldOffWidth, ch);
SetUpComboBoxBit(cbLocalTriggerValid[ID][ch], "", tabLayout, ch + 1, 8, DPP::PSD::Bit_DPPAlgorithmControl2::ListLocalTrigValidMode, DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::LocalTrigValidMode, 1, ch);
SetUpComboBoxBit(cbLocalTriggerValid[ID][ch], "", tabLayout, ch + 1, 8, DPP::PSD::Bit_DPPAlgorithmControl2::ListLocalTrigValidMode, DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::LocalTrigValidMode, 1, ch);
}
if( i == 1 ){
@ -2290,8 +2327,8 @@ void DigiSettingsPanel::SetUpChannel_PSD(){
QLabel * lb1 = new QLabel("Trig. Counter Flag [G]", this); lb1->setAlignment(Qt::AlignHCenter); tabLayout->addWidget(lb1, 0, 6);
}
SetUpSpinBox(sbShapedTrigWidth[ID][ch], "", tabLayout, ch + 1, 1, DPP::PSD::ShapedTriggerWidth, ch);
SetUpComboBoxBit(cbLocalShapedTrigger[ID][ch], "", tabLayout, ch + 1, 3, DPP::PSD::Bit_DPPAlgorithmControl2::ListLocalShapeTrigMode, DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode, 1, ch);
SetUpComboBoxBit(cbTrigCount[ID][ch], "", tabLayout, ch + 1, 5, DPP::PSD::Bit_DPPAlgorithmControl2::ListTrigCounter, DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::TriggerCounterFlag, 1, ch);
SetUpComboBoxBit(cbLocalShapedTrigger[ID][ch], "", tabLayout, ch + 1, 3, DPP::PSD::Bit_DPPAlgorithmControl2::ListLocalShapeTrigMode, DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode, 1, ch);
SetUpComboBoxBit(cbTrigCount[ID][ch], "", tabLayout, ch + 1, 5, DPP::PSD::Bit_DPPAlgorithmControl2::ListTrigCounter, DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::TriggerCounterFlag, 1, ch);
}
if( i == 2 ){

View File

@ -106,7 +106,8 @@ private:
QPushButton * bnProgramPreDefined;
QPushButton * bnClearBuffer;
QPushButton * bnSendSoftwareTriggerSignal;
// QPushButton * bnSendSoftwareTriggerSignal;
QPushButton * bnSetNoTrace;
QPushButton * bhAutoSetEventPulling;
//QPushButton * bnSendSoftwareClockSyncSignal;
QPushButton * bnSaveSettings;
@ -134,6 +135,7 @@ private:
RComboBox * cbDigiProbe2[MaxNDigitizer];
QPushButton * bnChEnableMask[MaxNDigitizer][MaxRegChannel];
QCheckBox * cbDigiEnable[MaxNDigitizer];
RComboBox * cbAggOrg[MaxNDigitizer];
RSpinBox * sbAggNum[MaxNDigitizer];
QCheckBox * chkEnableExternalTrigger[MaxNDigitizer];

View File

@ -47,6 +47,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
runRecord = nullptr;
model = nullptr;
influx = nullptr;
scalarCount = 0;
QWidget * mainLayoutWidget = new QWidget(this);
setCentralWidget(mainLayoutWidget);
@ -64,7 +65,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
// cbOpenDigitizers->addItem("Open Digitizers (default program)", 2);
// cbOpenDigitizers->addItem("Open Digitizers + load Settings", 3);
//cbOpenDigitizers->addItem("Open Digitizers via USB", 3);
cbOpenDigitizers->addItem("Open Digitizers via A4818", 4);
cbOpenDigitizers->addItem("Open Digitizers via A4818(s)", 4);
layout->addWidget(cbOpenDigitizers, 0, 0);
connect(cbOpenDigitizers, &RComboBox::currentIndexChanged, this, &MainWindow::OpenDigitizers);
@ -296,6 +297,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
CheckElog();
LogMsg("====== <font style=\"color: blue;\"><b>FSU DAQ is ready.</b></font> ======");
}
MainWindow::~MainWindow(){
@ -358,7 +363,6 @@ void MainWindow::OpenDataPath(){
LoadLastRunFile();
}
void MainWindow::OpenRecord(){
@ -580,16 +584,38 @@ void MainWindow::OpenDigitizers(){
// return;
// }
QString a4818PID = "26006";
QStringList a4818PIDs;
if( cbOpenDigitizers->currentData().toInt() == 4 ) {
bool ok;
a4818PID = QInputDialog::getText(nullptr, "A4818 PID", "Can be found on the A4818:", QLineEdit::Normal, "", &ok);
QString a4818Path = QDir::current().absolutePath() + "/a4818_list.txt";
LogMsg("Looking <b>" + a4818Path + "</b>");
if ( !ok || a4818PID.isEmpty()) {
LogMsg("User cancel or fail to connect A4818 without PID");
QFile file(a4818Path);
if( !file.open(QIODevice::Text | QIODevice::ReadOnly) ) {
LogMsg("<b>" + a4818Path + "</b> not found.");
LogMsg("Please create such file and put the a4818 PIDs inseperate lines.");
return;
}else{
QTextStream in(&file);
QString line = in.readLine();
while( !line.isNull()){
a4818PIDs.push_back(line);
line = in.readLine();
}
}
if( a4818PIDs.isEmpty()){
LogMsg("<b>" + a4818Path + "</b> is empty.");
cbOpenDigitizers->setCurrentIndex(0);
return;
}else{
if( a4818PIDs.size() > 4){
LogMsg("There are more than 4 a4818, please edit the MaxNPorts in macro.h and recompile.");
}
}
}
@ -602,8 +628,12 @@ void MainWindow::OpenDigitizers(){
logMsgHTMLMode = false;
nDigi = 0;
std::vector<std::pair<int, int>> portList; //boardID, portID
for(int port = 0; port < MaxNPorts; port++){
if( cbOpenDigitizers->currentData().toInt() == 4 ) port = a4818PID.toInt();
if( cbOpenDigitizers->currentData().toInt() == 4 ) { //for A4818
for( int i = 0; i < std::min((int)a4818PIDs.size(), MaxNPorts); i++){
int port = a4818PIDs.at(i).toInt();
for( int board = 0; board < MaxNBoards; board ++){ /// max number of diasy chain
Digitizer dig;
dig.OpenDigitizer(board, port);
@ -611,13 +641,29 @@ void MainWindow::OpenDigitizers(){
nDigi++;
portList.push_back(std::pair(board, port));
LogMsg(QString("... Found at port: %1, board: %2. SN: %3 %4").arg(port).arg(board).arg(dig.GetSerialNumber(), 3, 10, QChar(' ')).arg(dig.GetDPPString().c_str()));
}//else{
//LogMsg(QString("... Nothing at port: %1, board: %2.").arg(port).arg(board));
//}
}
dig.CloseDigitizer();
QCoreApplication::processEvents(); //to prevent Qt said application not responding.
}
}
}else{ // optical fiber
for(int port = 0; port < MaxNPorts; port++){
for( int board = 0; board < MaxNBoards; board ++){ /// max number of diasy chain
Digitizer dig;
dig.OpenDigitizer(board, port);
if( dig.IsConnected() ){
nDigi++;
portList.push_back(std::pair(board, port));
LogMsg(QString("... Found at port: %1, board: %2. SN: %3 %4").arg(port).arg(board).arg(dig.GetSerialNumber(), 3, 10, QChar(' ')).arg(dig.GetDPPString().c_str()));
}
dig.CloseDigitizer();
QCoreApplication::processEvents(); //to prevent Qt said application not responding.
}
}
}
logMsgHTMLMode = true;
if( nDigi == 0 ) {
@ -695,7 +741,7 @@ void MainWindow::OpenDigitizers(){
canvas->FillHistograms();
});
LogMsg(QString("Done. Opened %1 digitizer(s).").arg(nDigi));
LogMsg("====== <font style=\"color: blue;\"><b>" + QString("Done. Opened %1 digitizer(s).").arg(nDigi) + "</b></font> =====");
WaitForDigitizersOpen(false);
bnStartACQ->setStyleSheet("background-color: green;");
@ -838,6 +884,7 @@ void MainWindow::SetupScalar(){
lbLastUpdateTime = nullptr;
lbScalarACQStatus = nullptr;
lbTotalFileSize = nullptr;
scalarThread = new TimingThread(scalar);
scalarThread->SetWaitTimeinSec(1.0);
@ -848,11 +895,12 @@ void MainWindow::SetupScalar(){
if( digi[k]->GetNumInputCh() > maxNChannel ) maxNChannel = digi[k]->GetNumInputCh();
}
scalar->setGeometry(0, 0, 100 + nDigi * 200, 200 + maxNChannel * 20);
scalar->setGeometry(0, 0, 50 + nDigi * 240, 160 + maxNChannel * 25);
if( lbLastUpdateTime == nullptr ){
lbLastUpdateTime = new QLabel("Last update : NA", scalar);
lbScalarACQStatus = new QLabel("ACQ status", scalar);
lbTotalFileSize = new QLabel("Total File Size", scalar);
}
lbLastUpdateTime->setAlignment(Qt::AlignRight);
@ -863,13 +911,17 @@ void MainWindow::SetupScalar(){
scalarLayout->removeWidget(lbScalarACQStatus);
scalarLayout->addWidget(lbScalarACQStatus, 0, 1 + nDigi);
int rowID = 3;
///==== create the header row
lbTotalFileSize->setAlignment(Qt::AlignCenter);
scalarLayout->removeWidget(lbTotalFileSize);
scalarLayout->addWidget(lbTotalFileSize, 1, 0, 1, 1 + 2*nDigi);
///==== create the header row
int rowID = 4;
for( int ch = 0; ch < maxNChannel; ch++){
if( ch == 0 ){
QLabel * lbCH_H = new QLabel("Ch", scalar);
lbCH_H->setAlignment(Qt::AlignCenter);
scalarLayout->addWidget(lbCH_H, rowID, 0);
}
@ -884,22 +936,16 @@ void MainWindow::SetupScalar(){
leAccept = new QLineEdit**[nDigi];
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
rowID = 2;
leTrigger[iDigi] = new QLineEdit *[digi[iDigi]->GetNumInputCh()];
leAccept[iDigi] = new QLineEdit *[digi[iDigi]->GetNumInputCh()];
uint32_t chMask = digi[iDigi]->GetRegChannelMask();
for( int ch = 0; ch < digi[iDigi]->GetNumInputCh(); ch++){
if( ch == 0 ){
QWidget * hBox = new QWidget(scalar);
QHBoxLayout * hBoxLayout = new QHBoxLayout(hBox);
scalarLayout->addWidget(hBox, rowID, 2*iDigi+1, 1, 2);
lbAggCount[iDigi] = new QLabel("AggCount/ReadCount", scalar);
lbAggCount[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter);
hBoxLayout->addWidget(lbAggCount[iDigi]);
QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar);
lbDigi->setAlignment(Qt::AlignRight | Qt::AlignCenter);
// QLabel * lbDigi = new QLabel(QString::number(digi[iDigi]->GetSerialNumber()), scalar);
// lbDigi->setAlignment(Qt::AlignRight | Qt::AlignCenter);
lbDigi->setAlignment(Qt::AlignCenter);
hBoxLayout->addWidget(lbDigi);
runStatus[iDigi] = new QPushButton("", scalar);
@ -909,24 +955,42 @@ void MainWindow::SetupScalar(){
runStatus[iDigi]->setToolTipDuration(-1);
hBoxLayout->addWidget(runStatus[iDigi]);
rowID ++;
rowID = 3;
QWidget * hBox2 = new QWidget(scalar);
QHBoxLayout * hBoxLayout2 = new QHBoxLayout(hBox2);
scalarLayout->addWidget(hBox2, rowID, 2*iDigi+1, 1, 2);
lbAggCount[iDigi] = new QLabel("AggCount/ReadCount", scalar);
lbAggCount[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter);
hBoxLayout2->addWidget(lbAggCount[iDigi]);
lbFileSize[iDigi] = new QLabel("File Size", scalar);
lbFileSize[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter);
hBoxLayout2->addWidget(lbFileSize[iDigi]);
rowID = 4;
QLabel * lbA = new QLabel("Trig. [Hz]", scalar);
lbA->setAlignment(Qt::AlignCenter);
scalarLayout->addWidget(lbA, rowID, 2*iDigi+1);
QLabel * lbB = new QLabel("Accp. [Hz]", scalar);
lbB->setAlignment(Qt::AlignCenter);
scalarLayout->addWidget(lbB, rowID, 2*iDigi+2);
}
leTrigger[iDigi] = new QLineEdit *[digi[iDigi]->GetNumInputCh()];
leAccept[iDigi] = new QLineEdit *[digi[iDigi]->GetNumInputCh()];
for( int ch = 0; ch < digi[iDigi]->GetNumInputCh(); ch++){
rowID ++;
leTrigger[iDigi][ch] = new QLineEdit(scalar);
leTrigger[iDigi][ch]->setReadOnly(true);
leTrigger[iDigi][ch]->setFixedSize(120, 25);
leTrigger[iDigi][ch]->setAlignment(Qt::AlignRight);
scalarLayout->addWidget(leTrigger[iDigi][ch], rowID, 2*iDigi+1);
leAccept[iDigi][ch] = new QLineEdit(scalar);
leAccept[iDigi][ch]->setReadOnly(true);
leAccept[iDigi][ch]->setFixedSize(120, 25);
leAccept[iDigi][ch]->setAlignment(Qt::AlignRight);
leAccept[iDigi][ch]->setStyleSheet("background-color: #F0F0F0;");
@ -987,7 +1051,9 @@ void MainWindow::UpdateScalar(){
// digi[0]->GetData()->PrintAllData();
lbLastUpdateTime->setText("Last update: " + QDateTime::currentDateTime().toString("MM.dd hh:mm:ss"));
// lbLastUpdateTime->setText("Last update: " + QDateTime::currentDateTime().toString("MM.dd hh:mm:ss"));
lbLastUpdateTime->setText(QDateTime::currentDateTime().toString("MM/dd hh:mm:ss"));
scalarCount ++;
uint64_t totalFileSize = 0;
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
@ -996,9 +1062,9 @@ void MainWindow::UpdateScalar(){
uint32_t acqStatus = digi[iDigi]->GetACQStatusFromMemory();
//printf("Digi-%d : acq on/off ? : %d \n", digi[iDigi]->GetSerialNumber(), (acqStatus >> 2) & 0x1 );
if( ( acqStatus >> 2 ) & 0x1 ){
runStatus[iDigi]->setStyleSheet("background-color : green;");
if( runStatus[iDigi]->styleSheet() == "") runStatus[iDigi]->setStyleSheet("background-color : green;");
}else{
runStatus[iDigi]->setStyleSheet("");
if( runStatus[iDigi]->styleSheet() != "") runStatus[iDigi]->setStyleSheet("");
}
if(digiSettings && digiSettings->isVisible() && digiSettings->GetTabID() == iDigi) digiSettings->UpdateACQStatus(acqStatus);
@ -1009,6 +1075,7 @@ void MainWindow::UpdateScalar(){
blockCountStr += "/" + QString::number(readDataThread[iDigi]->GetReadCount());
readDataThread[iDigi]->SetReadCountZero();
lbAggCount[iDigi]->setText(blockCountStr);
lbFileSize[iDigi]->setText(QString::number(digi[iDigi]->GetData()->GetTotalFileSize()/1024./1024., 'f', 3) + " MB");
digi[iDigi]->GetData()->CalTriggerRate(); //this will reset NumEventDecode & AggCount
if( chkSaveData->isChecked() ) totalFileSize += digi[iDigi]->GetData()->GetTotalFileSize();
@ -1024,16 +1091,22 @@ void MainWindow::UpdateScalar(){
leAccept[iDigi][i]->setText(b);
if( influx && a != "inf" ){
influx->AddDataPoint("Rate,Bd="+std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + QString::number(i).rightJustified(2, '0').toStdString() + " value=" + a.toStdString());
influx->AddDataPoint("TrigRate,Bd="+std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + QString::number(i).rightJustified(2, '0').toStdString() + " value=" + a.toStdString());
}
}
}
digiMTX[iDigi].unlock();
}
if( influx ){
lbTotalFileSize->setText("Total Data Size : " + QString::number(totalFileSize/1024./1024., 'f', 3) + " MB");
repaint();
scalar->repaint();
if( influx && scalarCount >= 3){
if( chkSaveData->isChecked() ) {
influx->AddDataPoint("RunID value=" + std::to_string(runID));
influx->AddDataPoint("FileSize value=" + std::to_string(totalFileSize));
@ -1041,6 +1114,7 @@ void MainWindow::UpdateScalar(){
//nflux->PrintDataPoints();
influx->WriteData(dataBaseName.toStdString());
influx->ClearDataPointsBuffer();
scalarCount = 0;
}
}
@ -1106,6 +1180,7 @@ void MainWindow::StartACQ(){
bnStopACQ->setStyleSheet("background-color: red;");
bnOpenScope->setEnabled(false);
cbAutoRun->setEnabled(false);
bnSync->setEnabled(false);
if( digiSettings ) digiSettings->setEnabled(false);
@ -1135,6 +1210,9 @@ void MainWindow::StartACQ(){
void MainWindow::StopACQ(){
DebugPrint("%s", "FSUDAQ");
QCoreApplication::processEvents();
if( digi == nullptr ) return;
bool commentResult = true;
@ -1184,6 +1262,7 @@ void MainWindow::StopACQ(){
bnStopACQ->setStyleSheet("");
bnOpenScope->setEnabled(true);
cbAutoRun->setEnabled(true);
bnSync->setEnabled(true);
if( scalar ){
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){
@ -1224,6 +1303,9 @@ void MainWindow::StopACQ(){
chkSaveData->setEnabled(true);
bnDigiSettings->setEnabled(true);
repaint();
printf("================ end of %s \n", __func__);
}
void MainWindow::AutoRun(){
@ -1634,7 +1716,8 @@ void MainWindow::WriteRunTimestamp(bool isStartRun){
//***************************************************************
//***************************************************************
void MainWindow::OpenScope(){
DebugPrint("%s", "FSUDAQ");
QCoreApplication::processEvents();
if( scope == nullptr ) {
scope = new Scope(digi, nDigi, readDataThread);
connect(scope, &Scope::SendLogMsg, this, &MainWindow::LogMsg);
@ -1707,7 +1790,6 @@ void MainWindow::OpenDigiSettings(){
digiSettings->show();
digiSettings->activateWindow();
}
}
//***************************************************************
@ -1727,6 +1809,7 @@ void MainWindow::OpenCanvas(){
//***************************************************************
void MainWindow::OpenAnalyzer(){
DebugPrint("%s", "FSUDAQ");
int id = cbAnalyzer->currentData().toInt();
if( id < 0 ) return;
@ -1895,6 +1978,8 @@ void MainWindow::SetUpInflux(){
void MainWindow::CheckElog(){
DebugPrint("%s", "FSUDAQ");
LogMsg("---- Checking elog... please wait....");
printf("---- Checking elog... please wait....\n");
if( elogIP != "" && elogName != "" && elogUser != "" && elogPWD != "" ){
WriteElog("Testing communication.", "Testing communication.", "Other", 0);
AppendElog("test append elog.");
@ -1907,16 +1992,18 @@ void MainWindow::CheckElog(){
if( elogID >= 0 ) {
LogMsg("Elog testing OK.");
printf("Elog testing OK.\n");
return;
}
//QMessageBox::information(nullptr, "Information", "Elog write Fail.\nPlease set the elog User and PWD in the programSettings.txt.\nline 6 = user.\nline 7 = pwd.");
LogMsg("Elog testing Fail");
printf("Elog testing Fail\n");
if( elogIP == "" ) LogMsg("no elog IP");
if( elogName == "" ) LogMsg("no elog Name");
if( elogUser == "" ) LogMsg("no elog User name. Please set it in the programSettings.txt, line 6.");
if( elogPWD == "" ) LogMsg("no elog User pwd. Please set it in the programSettings.txt, line 7.");
if( elogID < 0 ) LogMsg("Possible elog IP, Name, User name, or pwd incorrect");
if( elogID < 0 ) LogMsg("Possible elog IP, Name, User name, pwd incorrect, or elog not installed.");
leElogIP->setEnabled(false);
leElogName->setEnabled(false);

View File

@ -135,6 +135,7 @@ private:
QLineEdit * leDatabaseName;
QPushButton * bnLock;
QString influxToken;
short scalarCount;
//@----- Elog
QString elogIP;
@ -171,6 +172,8 @@ private:
QLabel * lbLastUpdateTime;
QLabel * lbScalarACQStatus;
QLabel * lbAggCount[MaxNDigitizer];
QLabel * lbFileSize[MaxNDigitizer];
QLabel * lbTotalFileSize;
//@----- Run Record
QMainWindow * runRecord;

View File

@ -49,10 +49,13 @@ public:
colorScale->setType(QCPAxis::atRight);
colorMap->setColorScale(colorScale);
QCPColorGradient color;
color.setNanHandling(QCPColorGradient::NanHandling::nhNanColor);
color.setNanColor(QColor("white"));
color.clearColorStops();
color.setColorStopAt( 0.0, QColor("white" ));
color.setColorStopAt( 0.000001, QColor("purple" ));
// color.setColorStopAt( 0.0, QColor("white" ));
color.setColorStopAt( 0.0, QColor("purple" ));
color.setColorStopAt( 0.2, QColor("blue"));
color.setColorStopAt( 0.4, QColor("cyan"));
color.setColorStopAt( 0.6, QColor("green"));
@ -187,20 +190,23 @@ public:
void SetXTitle(QString xTitle) { xAxis->setLabel(xTitle); }
void SetYTitle(QString yTitle) { yAxis->setLabel(yTitle); }
void Rebin(int xbin, double xmin, double xmax, int ybin, double ymin, double ymax);
void RebinY(int ybin, double ymin, double ymax);
void SetChannelMap(bool onOff, int tickStep = 1) { isChannelMap = onOff; this->tickStep = tickStep;}
void UpdatePlot(){
QCPColorGradient color;
color.clearColorStops();
color.setColorStopAt( 0.0, QColor("white" ));
color.setColorStopAt( 1.0/entry[1][1], QColor("purple" ));
color.setColorStopAt( 0.2, QColor("blue"));
color.setColorStopAt( 0.4, QColor("cyan"));
color.setColorStopAt( 0.6, QColor("green"));
color.setColorStopAt( 0.8, QColor("yellow"));
color.setColorStopAt( 1.0, QColor("red"));
colorMap->setGradient(color);
// QCPColorGradient color;
// color.clearColorStops();
// color.setNanColor(QColor("white"));
// // color.setColorStopAt( 0.0, QColor("white" ));
// // color.setColorStopAt( 1.0/entry[1][1], QColor("purple" ));
// color.setColorStopAt( 0.0, QColor("purple" ));
// color.setColorStopAt( 0.2, QColor("blue"));
// color.setColorStopAt( 0.4, QColor("cyan"));
// color.setColorStopAt( 0.6, QColor("green"));
// color.setColorStopAt( 0.8, QColor("yellow"));
// color.setColorStopAt( 1.0, QColor("red"));
// colorMap->setGradient(color);
colorMap->rescaleDataRange();
@ -287,7 +293,11 @@ inline void Histogram2D::Fill(double x, double y){
if( xk == 1 && yk == 1 ) {
double value = colorMap->data()->cell(xIndex, yIndex);
if( std::isnan(value) ){
colorMap->data()->setCell(xIndex, yIndex, 1);
}else{
colorMap->data()->setCell(xIndex, yIndex, value + 1);
}
for( int i = 0; i < cutList.count(); i++){
if( cutList[i].isEmpty() ) continue;
@ -309,6 +319,12 @@ inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, do
colorMap->data()->setSize(xBin, yBin);
colorMap->data()->setRange(QCPRange(xMin, xMax), QCPRange(yMin, yMax));
for( int i = 0; i < xBin; i++){
for( int j = 0; j < yBin; j++){
colorMap->data()->setCell(i, j, NAN);
}
}
if( isChannelMap ){
QCPAxis * xAxis = colorMap->keyAxis();
xAxis->ticker()->setTickCount(xbin/tickStep);
@ -324,6 +340,10 @@ inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, do
}
inline void Histogram2D::RebinY(int ybin, double ymin, double ymax){
Rebin(xBin-2, xMin, xMax, ybin, ymin, ymax);
}
inline void Histogram2D::Clear(){
DebugPrint("%s", "Histogram2D");
for( int i = 0; i < 3; i ++){
@ -335,6 +355,11 @@ inline void Histogram2D::Clear(){
colorMap->data()->clear();
colorMap->data()->setSize(xBin, yBin);
colorMap->data()->setRange(QCPRange(xMin, xMax), QCPRange(yMin, yMax));
for( int i = 0; i < xBin; i++){
for( int j = 0; j < yBin; j++){
colorMap->data()->setCell(i, j, NAN);
}
}
UpdatePlot();
}

135
Scope.cpp
View File

@ -68,31 +68,6 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
plot->addSeries(dataTrace[i]);
}
// testing software trapezoid filter
// FILE * fileIn = fopen("wave.txt", "r");
// if( fileIn != nullptr ){
// char buf[500];
// int v1, v2;
// QVector<QPointF> points;
// QVector<QPointF> points1;
// while( fgets(buf, sizeof(buf), fileIn) != nullptr ){
// if (sscanf(buf, "%d, %d", &v1, &v2) == 2) {
// points.append(QPointF(v1, v2 + 7000));
// }
// }
// fclose(fileIn);
// points1 = TrapezoidFilter(points, 400/16, 100, 200, 1000);
// dataTrace[0]->replace(points);
// dataTrace[1]->replace(points1);
// }
dataTrace[0]->setPen(QPen(Qt::red, 2));
dataTrace[1]->setPen(QPen(Qt::blue, 2));
dataTrace[2]->setPen(QPen(Qt::darkYellow, 1));
@ -191,7 +166,6 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
});
bnReadSettingsFromBoard = new QPushButton("Refresh Settings", this);
layout->addWidget(bnReadSettingsFromBoard, rowID, 2);
connect(bnReadSettingsFromBoard, &QPushButton::clicked, this, &Scope::ReadSettingsFromBoard);
@ -257,18 +231,21 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
layout->addWidget(bnScopeStart, rowID, 0);
connect(bnScopeStart, &QPushButton::clicked, this, [=](){this->StartScope();});
chkSoleRun = new QCheckBox("Only this channel", this);
layout->addWidget(chkSoleRun, rowID, 1);
bnScopeStop = new QPushButton("Stop", this);
layout->addWidget(bnScopeStop, rowID, 1);
layout->addWidget(bnScopeStop, rowID, 2);
connect(bnScopeStop, &QPushButton::clicked, this, &Scope::StopScope);
QLabel * lbTriggerRate = new QLabel("Trigger Rate [Hz] : ", this);
lbTriggerRate->setAlignment(Qt::AlignCenter | Qt::AlignRight);
layout->addWidget(lbTriggerRate, rowID, 2);
layout->addWidget(lbTriggerRate, rowID, 3);
leTriggerRate = new QLineEdit(this);
leTriggerRate->setAlignment(Qt::AlignRight);
leTriggerRate->setReadOnly(true);
layout->addWidget(leTriggerRate, rowID, 3);
layout->addWidget(leTriggerRate, rowID, 4);
QPushButton * bnClose = new QPushButton("Close", this);
layout->addWidget(bnClose, rowID, 6);
@ -365,6 +342,59 @@ void Scope::StartScope(){
//TODO set other channel to be no trace;
emit UpdateOtherPanels();
if( chkSoleRun->isChecked() ){
int ID = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
oldDigi = ID;
oldCh = ch;
//save present settings, channleMap, trigger condition
traceOn[ID] = digi[ID]->IsRecordTrace();
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1);
chMask = digi[ID]->GetSettingFromMemory(DPP::RegChannelEnableMask);
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PHA_CODE ){
dppAlg = digi[ID]->GetSettingFromMemory(DPP::DPPAlgorithmControl, ch);
dppAlg2 = digi[ID]->GetSettingFromMemory(DPP::PHA::DPPAlgorithmControl2_G, ch);
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::TriggerMode, 0, ch);
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::DisableSelfTrigger, 0, ch);
digi[ID]->SetBits(DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode, 0, ch);
digi[ID]->SetBits(DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::LocalTrigValidMode, 0, ch);
}
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ){
dppAlg = digi[ID]->GetSettingFromMemory(DPP::DPPAlgorithmControl, ch);
dppAlg2 = digi[ID]->GetSettingFromMemory(DPP::PSD::DPPAlgorithmControl2_G, ch);
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::TriggerMode, 0, ch);
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::DisableSelfTrigger, 0, ch);
digi[ID]->SetBits(DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode, 0, ch);
digi[ID]->SetBits(DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::LocalTrigValidMode, 0, ch);
}
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
dppAlg = digi[ID]->GetSettingFromMemory(DPP::QDC::DPPAlgorithmControl, ch);
digi[ID]->SetBits(DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::TriggerMode, 0, ch); //set self-triiger
}
digi[ID]->WriteRegister(DPP::RegChannelEnableMask, (1 << ch));
//=========== start
digi[ID]->WriteRegister(DPP::SoftwareClear_W, 1);
readDataThread[ID]->SetScopeMode(true);
readDataThread[ID]->SetSaveData(false);
digi[ID]->StartACQ();
readDataThread[ID]->start();
}else{
for( int iDigi = (int)nDigi-1 ; iDigi >= 0; iDigi --){
traceOn[iDigi] = digi[iDigi]->IsRecordTrace(); //remember setting
@ -390,6 +420,8 @@ void Scope::StartScope(){
// printf("----- readDataThread running ? %d.\n", readDataThread[iDigi]->isRunning());
}
}
updateTraceThread->start();
updateScalarThread->start();
@ -398,6 +430,8 @@ void Scope::StartScope(){
bnScopeStop->setEnabled(true);
bnScopeStop->setStyleSheet("background-color: red;");
chkSoleRun->setEnabled(false);
EnableControl(false);
TellACQOnOff(true);
@ -419,12 +453,50 @@ void Scope::StopScope(){
updateScalarThread->quit();
updateScalarThread->exit();
if( chkSoleRun->isChecked() ){
//int ID = cbScopeDigi->currentIndex();
int ID = oldDigi;
if( readDataThread[ID]->isRunning() ){
readDataThread[ID]->Stop();
readDataThread[ID]->quit();
readDataThread[ID]->wait();
readDataThread[ID]->SetScopeMode(false);
}
digiMTX[ID].lock();
digi[ID]->StopACQ();
digi[ID]->ReadACQStatus();
digiMTX[ID].unlock();
//restore setting
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[ID], -1);
digi[ID]->WriteRegister(DPP::RegChannelEnableMask, chMask);
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PHA_CODE ){
digi[ID]->WriteRegister(DPP::DPPAlgorithmControl, dppAlg, oldCh);
digi[ID]->WriteRegister(DPP::PHA::DPPAlgorithmControl2_G, dppAlg2, oldCh);
}
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ){
digi[ID]->WriteRegister(DPP::DPPAlgorithmControl, dppAlg, oldCh);
digi[ID]->WriteRegister(DPP::PSD::DPPAlgorithmControl2_G, dppAlg2, oldCh);
}
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
digi[ID]->WriteRegister(DPP::QDC::DPPAlgorithmControl, dppAlg, oldCh);
}
}else{
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){
if( readDataThread[iDigi]->isRunning() ){
readDataThread[iDigi]->Stop();
readDataThread[iDigi]->quit();
readDataThread[iDigi]->wait();
readDataThread[iDigi]->SetScopeMode(false);
}
digiMTX[iDigi].lock();
digi[iDigi]->StopACQ();
@ -437,6 +509,8 @@ void Scope::StopScope(){
}
}
emit UpdateOtherPanels();
bnScopeStart->setEnabled(true);
@ -444,6 +518,7 @@ void Scope::StopScope(){
bnScopeStop->setEnabled(false);
bnScopeStop->setStyleSheet("");
chkSoleRun->setEnabled(true);
runStatus->setStyleSheet("");
EnableControl(true);
@ -1230,7 +1305,7 @@ void Scope::UpdatePanel_QDC(){
sbDCOffset->setValue((1.0 - haha * 1.0 / 0xFFFF) * 100 );
//UpdateSpinBox(sbReordLength, DPP::QDC::RecordLength);
sbReordLength->setValue(digi[ID]->ReadQDCRecordLength());
sbReordLength->setValue(digi[ID]->ReadQDCRecordLength() * 8 * 16);
UpdateSpinBox(sbPreTrigger, DPP::QDC::PreTrigger);
UpdateSpinBox(sbShortGate, DPP::QDC::GateWidth);

View File

@ -80,9 +80,12 @@ private:
bool isACQStarted;
int tick2ns;
int factor; // whether dual trace or not
bool traceOn[MaxNDigitizer];
int AggPerRead[MaxNDigitizer];
bool traceOn[MaxNDigitizer];
uint32_t dppAlg, dppAlg2, chMask; //for single channel run
unsigned short oldCh, oldDigi;
ReadDataThread ** readDataThread;
TimingThread * updateTraceThread;
TimingThread * updateScalarThread;
@ -105,6 +108,7 @@ private:
QGroupBox * settingGroup;
QGridLayout * settingLayout;
QCheckBox * chkSoleRun;
QPushButton * runStatus;
/// common to PSD and PHA

View File

@ -1,11 +1,9 @@
#include "SingleSpectra.h"
#include <QValueAxis>
#include <QRandomGenerator>
#include <QGroupBox>
#include <QStandardItemModel>
#include <QLabel>
#include <QRandomGenerator>
SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawDataPath, QMainWindow * parent) : QMainWindow(parent){
DebugPrint("%s", "SingleSpectra");
@ -13,11 +11,12 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
this->nDigi = nDigi;
this->rawDataPath = rawDataPath;
maxFillTimeinMilliSec = 500;
maxFillTimeinMilliSec = 1000;
maxFillTimePerDigi = maxFillTimeinMilliSec/nDigi;
isSignalSlotActive = true;
setWindowTitle("1-D Histograms");
setWindowTitle("Single Histograms");
setGeometry(0, 0, 1000, 800);
//setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint );
@ -69,15 +68,103 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
for( unsigned int i = 0; i < nDigi; i++){
for( int j = 0; j < digi[i]->GetNumInputCh(); j++){
if( hist[i][j] ) hist[i][j]->Clear();
// lastFilledIndex[i][j] = -1;
// loopFilledIndex[i][j] = 0;
}
if( hist2D[i] ) hist2D[i]->Clear();
}
});
QPushButton * bnRebinDigi = new QPushButton("Rebin Energy", this);
ctrlLayout->addWidget(bnRebinDigi, 0, 6, 1, 2);
connect(bnRebinDigi, &QPushButton::clicked, this, [=](){
int ID = cbDigi->currentIndex();
int ch = cbCh->currentIndex();
int a_Bin;
float a_Min, a_Max;
if( ch >= 0 ){
a_Bin = hist[ID][ch]->GetNBin();
a_Min = hist[ID][ch]->GetXMin();
a_Max = hist[ID][ch]->GetXMax();
}else{
a_Bin = hist2D[ID]->GetYNBin();
a_Min = hist2D[ID]->GetYMin();
a_Max = hist2D[ID]->GetYMax();
}
//pop up a dialog for nBin and ranhe
QDialog dialog(this);
dialog.setWindowTitle("Rebin histograms");
QFormLayout layout(&dialog);
QLabel * info = new QLabel(&dialog);
info->setStyleSheet("color:red;");
info->setText("This will also clear histogram!!");
layout.addRow(info);
QStringList nameList = {"Num. Bin", "x-Min", "x-Max"};
QLineEdit* lineEdit[3];
for (int i = 0; i < 3; ++i) {
lineEdit[i] = new QLineEdit(&dialog);
layout.addRow(nameList[i] + " : ", lineEdit[i]);
}
lineEdit[0]->setText(QString::number(a_Bin));
lineEdit[1]->setText(QString::number(a_Min));
lineEdit[2]->setText(QString::number(a_Max));
QLabel * msg = new QLabel(&dialog);
msg->setStyleSheet("color:red;");
layout.addRow(msg);
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);
layout.addRow(&buttonBox);
double number[3];
QObject::connect(&buttonBox, &QDialogButtonBox::accepted, [&]() {
int OKcount = 0;
bool conversionOk = true;
for( int i = 0; i < 3; i++ ){
number[i] = lineEdit[i]->text().toDouble(&conversionOk);
if( conversionOk ){
OKcount++;
}else{
msg->setText(nameList[i] + " is invalid.");
return;
}
}
if( OKcount == 3 ) {
if( number[2] > number[1] ) {
dialog.accept();
}else{
msg->setText(nameList[2] + " is smaller than " + nameList[1]);
}
}
});
QObject::connect(&buttonBox, &QDialogButtonBox::rejected, [&]() { dialog.reject();});
if( dialog.exec() == QDialog::Accepted ){
if( hist2D[ID] ) {
hist2D[ID]->RebinY((int)number[0], number[1], number[2]);
hist2D[ID]->rescaleAxes();
hist2D[ID]->UpdatePlot();
}
for( int j = 0; j < digi[ID]->GetNumInputCh(); j++){
if( hist[ID][j] ) {
hist[ID][j]->Rebin((int)number[0], number[1], number[2]);
hist[ID][j]->UpdatePlot();
}
}
}
});
QCheckBox * chkIsFillHistogram = new QCheckBox("Fill Histograms", this);
ctrlLayout->addWidget(chkIsFillHistogram, 0, 6);
ctrlLayout->addWidget(chkIsFillHistogram, 0, 8);
connect(chkIsFillHistogram, &QCheckBox::stateChanged, this, [=](int state){ fillHistograms = state;});
chkIsFillHistogram->setChecked(false);
fillHistograms = false;
@ -205,47 +292,69 @@ void SingleSpectra::FillHistograms(){
// DebugPrint("%s", "SingleSpectra");
if( !fillHistograms ) return;
unsigned short maxFillTimePerDigi = maxFillTimeinMilliSec/nDigi;
timespec t0, t1;
for( int i = 0; i < nDigi; i++){
QVector<int> randomDigiList = generateNonRepeatedCombination(nDigi);
// qDebug() << randomDigiList;
for( int i = 0; i < nDigi; i++){
int ID = randomDigiList[i];
QVector<int> randomChList = generateNonRepeatedCombination(digi[ID]->GetNumInputCh());
// qDebug() << randomChList;
digiMTX[ID].lock();
// digi[ID]->GetData()->PrintAllData();
digiMTX[i].lock();
clock_gettime(CLOCK_REALTIME, &t0);
for( int ch = 0; ch < digi[i]->GetNumInputCh(); ch ++ ){
int lastIndex = digi[i]->GetData()->GetDataIndex(ch);
for( int k = 0; k < digi[ID]->GetNumInputCh(); k ++ ){
int ch = randomChList[k];
int lastIndex = digi[ID]->GetData()->GetDataIndex(ch);
// printf("--- ch %2d | last index %d \n", ch, lastIndex);
if( lastIndex < 0 ) continue;
int loopIndex = digi[i]->GetData()->GetLoopIndex(ch);
int loopIndex = digi[ID]->GetData()->GetLoopIndex(ch);
int temp1 = lastIndex + loopIndex * digi[i]->GetData()->GetDataSize();
int temp2 = lastFilledIndex[i][ch] + loopFilledIndex[i][ch] * digi[i]->GetData()->GetDataSize();
int temp1 = lastIndex + loopIndex * digi[ID]->GetData()->GetDataSize();
int temp2 = lastFilledIndex[ID][ch] + loopFilledIndex[ID][ch] * digi[ID]->GetData()->GetDataSize() + 1;
// printf("loopIndx : %d | ID now : %d, ID old : %d \n", loopIndex, temp1, temp2);
// printf("%d |%d %d \n", ch, temp2, temp1);
if( temp1 <= temp2 ) continue;
if( temp1 - temp2 > digi[i]->GetData()->GetDataSize() ) { //DefaultDataSize = 10k
temp2 = temp1 - digi[i]->GetData()->GetDataSize();
lastFilledIndex[i][ch] = lastIndex;
lastFilledIndex[i][ch] = loopIndex - 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;
}
// printf("ch %d | regulated ID now %d new %d | last fill idx %d\n", ch, temp2, temp1, lastFilledIndex[ID][ch]);
for( int j = 0 ; j <= temp1 - temp2; j ++){
lastFilledIndex[i][ch] ++;
if( lastFilledIndex[i][ch] > digi[i]->GetData()->GetDataSize() ) {
lastFilledIndex[i][ch] = 0;
loopFilledIndex[i][ch] ++;
lastFilledIndex[ID][ch] ++;
if( lastFilledIndex[ID][ch] > digi[ID]->GetData()->GetDataSize() ) {
lastFilledIndex[ID][ch] = 0;
loopFilledIndex[ID][ch] ++;
}
hist[i][ch]->Fill( digi[i]->GetData()->GetEnergy(ch, lastFilledIndex[i][ch]));
hist2D[i]->Fill(ch, digi[i]->GetData()->GetEnergy(ch, lastFilledIndex[i][ch]));
uShort data = digi[ID]->GetData()->GetEnergy(ch, lastFilledIndex[ID][ch]);
// printf(" ch: %d, last fill idx : %d | %d \n", ch, lastFilledIndex[ID][ch], data);
hist[ID][ch]->Fill( data );
hist2D[ID]->Fill(ch, data);
}
if( histVisibility[i][ch] ) hist[i][ch]->UpdatePlot();
if( hist2DVisibility[i] ) hist2D[i]->UpdatePlot();
if( histVisibility[ID][ch] ) hist[ID][ch]->UpdatePlot();
clock_gettime(CLOCK_REALTIME, &t1);
if( t1.tv_nsec - t0.tv_nsec + (t1.tv_sec - t0.tv_sec)*1e9 > maxFillTimePerDigi * 1e6 ) break;
}
digiMTX[i].unlock();
if( hist2DVisibility[ID] ) hist2D[ID]->UpdatePlot();
digiMTX[ID].unlock();
}
}
@ -340,3 +449,14 @@ void SingleSpectra::LoadSetting(){
}
}
QVector<int> SingleSpectra::generateNonRepeatedCombination(int size) {
QVector<int> combination;
for (int i = 0; i < size; ++i) combination.append(i);
for (int i = 0; i < size - 1; ++i) {
int j = QRandomGenerator::global()->bounded(i, size);
combination.swapItemsAt(i, j);
}
return combination;
}

View File

@ -10,6 +10,8 @@
#include <QLineEdit>
#include <QGridLayout>
#include <QGroupBox>
#include <QVector>
#include <QRandomGenerator>
#include "macro.h"
#include "ClassDigitizer.h"
@ -38,6 +40,8 @@ public:
void SetMaxFillTime(unsigned short milliSec) { maxFillTimeinMilliSec = milliSec;}
unsigned short GetMaxFillTime() const {return maxFillTimeinMilliSec;};
QVector<int> generateNonRepeatedCombination(int size);
public slots:
void FillHistograms();
void ChangeHistView();
@ -70,6 +74,7 @@ private:
QString rawDataPath;
unsigned short maxFillTimeinMilliSec;
unsigned short maxFillTimePerDigi;
bool isSignalSlotActive;

View File

@ -11,7 +11,7 @@
#define MaxRecordLength 0x3fff * 8
#define MaxSaveFileSize 1024 * 1024 * 1024 * 2
#define MaxDisplayTraceTimeLength 10000 //ns
#define MaxDisplayTraceTimeLength 20000 //ns
#define ScopeUpdateMiliSec 200 // msec
#define MaxNumberOfTrace 5 // in an event

View File

@ -1,14 +1,34 @@
#include "FSUDAQ.h"
#include <QApplication>
#include <QMessageBox>
#include <QProcess>
#include <QPushButton>
#include <QFile>
#include "FSUDAQ.h"
#include <QObject>
#include <QDebug>
#include <sys/resource.h>
// class CustomApplication : public QApplication{
// public:
// CustomApplication(int &argc, char **argv) : QApplication(argc, argv) {}
// protected:
// bool notify(QObject *receiver, QEvent *event) override{
// qDebug() << event->type() << "Receiver:" << receiver;
// return QApplication::notify(receiver, event);
// }
// };
int main(int argc, char *argv[]){
// CustomApplication a(argc, argv);
QApplication a(argc, argv);
setpriority(PRIO_PROCESS, 0, -20);
bool isLock = false;
int pid = 0;
QFile lockFile(DAQLockFile);