added triggerSummary, next consider save a copy of setting in memory

This commit is contained in:
carina@hades 2022-10-05 14:28:55 -04:00
parent 97413b41dd
commit 30a48743cb
9 changed files with 300 additions and 85 deletions

View File

@ -27,6 +27,7 @@ class Data{
uint32_t BufferSize; uint32_t BufferSize;
unsigned short NumEvents[MaxNChannels]; unsigned short NumEvents[MaxNChannels];
double TriggerRate[MaxNChannels]; /// Hz
unsigned long TotNumEvents[MaxNChannels]; unsigned long TotNumEvents[MaxNChannels];
unsigned long long Timestamp[MaxNChannels][MaxNData]; unsigned long long Timestamp[MaxNChannels][MaxNData];
unsigned short Energy[MaxNChannels][MaxNData]; unsigned short Energy[MaxNChannels][MaxNData];
@ -45,11 +46,11 @@ class Data{
~Data(); ~Data();
void AllocateMemory(); void AllocateMemory();
void FreeMemory();
void SetSaveWaveformToMemory(bool OnOff) { this->SaveWaveformToMemory = OnOff; } void SetSaveWaveformToMemory(bool OnOff) { this->SaveWaveformToMemory = OnOff; }
void ClearData(); void ClearData();
void ClearTriggerRate();
void SaveBuffer(const char * fileName); void SaveBuffer(const char * fileName);
@ -87,18 +88,14 @@ inline Data::Data(){
buffer = NULL; buffer = NULL;
for ( int i = 0; i < MaxNChannels; i++) TotNumEvents[i] = 0; for ( int i = 0; i < MaxNChannels; i++) TotNumEvents[i] = 0;
ClearData(); ClearData();
ClearTriggerRate();
SaveWaveformToMemory = true; SaveWaveformToMemory = true;
nw = 0; nw = 0;
saveFileIndex = 0; saveFileIndex = 0;
} }
inline Data::~Data(){ inline Data::~Data(){
FreeMemory(); delete buffer;
///if( buffer != NULL ) delete buffer;
///for( int i = 0 ; i < MaxNChannels; i++){
/// delete Events [i];
/// delete Waveform [i];
///}
} }
inline void Data::AllocateMemory(){ inline void Data::AllocateMemory(){
@ -113,11 +110,7 @@ inline void Data::AllocateMemory(){
} }
inline void Data::ClearTriggerRate(){ for( int i = 0 ; i < MaxNChannels; i++) TriggerRate[i] = 0.0; }
inline void Data::FreeMemory(){
printf("======= Free memory\n");
//delete buffer;
}
inline void Data::ClearData(){ inline void Data::ClearData(){
@ -127,6 +120,7 @@ inline void Data::ClearData(){
for( int i = 0 ; i < MaxNChannels; i++){ for( int i = 0 ; i < MaxNChannels; i++){
NumEvents[i] = 0; NumEvents[i] = 0;
///TriggerRate[i] = 0.0;
for( int j = 0; j < MaxNData; j++){ for( int j = 0; j < MaxNData; j++){
Timestamp[i][j] = 0; Timestamp[i][j] = 0;
Energy[i][j] = 0; Energy[i][j] = 0;
@ -181,10 +175,7 @@ inline void Data::PrintStat(){
printf("%2s | %6s | %9s | %6s\n", "ch", "# Evt.", "Rate [Hz]", "Tot. Evt."); printf("%2s | %6s | %9s | %6s\n", "ch", "# Evt.", "Rate [Hz]", "Tot. Evt.");
printf("---+--------+-----------+----------\n"); printf("---+--------+-----------+----------\n");
for(int ch = 0; ch < MaxNChannels; ch++){ for(int ch = 0; ch < MaxNChannels; ch++){
unsigned long long dTime = Timestamp[ch][NumEvents[ch]-1] - Timestamp[ch][0]; printf("%2d | %6d | %9.2f | %6lu\n", ch, NumEvents[ch], TriggerRate[ch], TotNumEvents[ch]);
double sec = dTime * ch2ns / 1e9;
printf("%2d | %6d | %9.2f | %6lu\n", ch, NumEvents[ch], NumEvents[ch]/sec, TotNumEvents[ch]);
} }
printf("---+--------+-----------+----------\n"); printf("---+--------+-----------+----------\n");
@ -253,6 +244,15 @@ inline void Data::DecodeBuffer(int verbose){
} }
nw++; nw++;
}while(true); }while(true);
///Calculate trigger rate
for(int ch = 0; ch < MaxNChannels; ch++){
unsigned long long dTime = Timestamp[ch][NumEvents[ch]-1] - Timestamp[ch][0];
double sec = dTime * ch2ns / 1e9;
TriggerRate[ch] = NumEvents[ch]/sec;
}
} }
inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose){ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose){

View File

@ -82,8 +82,8 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMain->Connect("CloseWindow()", "MainWindow", this, "GoodBye()"); fMain->Connect("CloseWindow()", "MainWindow", this, "GoodBye()");
{///======================= menu {///======================= menu
fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame); fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame); fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
fMenuFile = new TGPopupMenu(gClient->GetRoot()); fMenuFile = new TGPopupMenu(gClient->GetRoot());
fMenuFile->AddEntry("&Open File", M_FILE_OPEN); fMenuFile->AddEntry("&Open File", M_FILE_OPEN);
fMenuFile->AddSeparator(); fMenuFile->AddSeparator();
@ -100,15 +100,12 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMenuDigitizers->AddEntry("&Channel Settings (PHA)", M_CH_SETTING_PHA); fMenuDigitizers->AddEntry("&Channel Settings (PHA)", M_CH_SETTING_PHA);
fMenuDigitizers->AddEntry("&Channel Settings (PSD)", M_CH_SETTING_PSD); fMenuDigitizers->AddEntry("&Channel Settings (PSD)", M_CH_SETTING_PSD);
fMenuDigitizers->AddEntry("&Register Setting", M_REGISTER_SETTING); fMenuDigitizers->AddEntry("&Register Setting", M_REGISTER_SETTING);
fMenuDigitizers->AddSeparator(); //fMenuDigitizers->AddSeparator();
fMenuDigitizers->AddEntry("&Program Settings", M_PROGRAM_SETTINGS); //fMenuDigitizers->AddEntry("&Program Settings", M_PROGRAM_SETTINGS);
fMenuDigitizers->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuDigitizers->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&Digitizers", fMenuDigitizers, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); fMenuBar->AddPopup("&Digitizers", fMenuDigitizers, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
fMenuDigitizers->DisableEntry( M_TRIGGER_SUMMARY); fMenuDigitizers->DisableEntry( M_REGISTER_SETTING);
fMenuDigitizers->DisableEntry( M_LOAD_SETTINGS);
//fMenuDigitizers->DisableEntry( M_BOARD_SETTINGS);
//fMenuDigitizers->DisableEntry( M_CH_SETTING);
fMenuUtility = new TGPopupMenu(gClient->GetRoot()); fMenuUtility = new TGPopupMenu(gClient->GetRoot());
fMenuUtility->AddEntry("Plot Channels Rate", M_SHOW_CHANNELS_RATE); fMenuUtility->AddEntry("Plot Channels Rate", M_SHOW_CHANNELS_RATE);
@ -116,6 +113,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMenuUtility->AddEntry("Find &Peaks", M_FINDPEAKS); fMenuUtility->AddEntry("Find &Peaks", M_FINDPEAKS);
fMenuUtility->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuUtility->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&Utility", fMenuUtility, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); fMenuBar->AddPopup("&Utility", fMenuUtility, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
} }
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2)); TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
@ -224,7 +222,8 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
//HandleMenu(M_BOARD_SETTINGS); //HandleMenu(M_BOARD_SETTINGS);
//HandleMenu(M_CH_SETTING_PHA); //HandleMenu(M_CH_SETTING_PHA);
//HandleMenu(M_CH_SETTING_PSD); //HandleMenu(M_CH_SETTING_PSD);
HandleMenu(M_REGISTER_SETTING); //HandleMenu(M_REGISTER_SETTING);
HandleMenu(M_TRIGGER_SUMMARY);
gAnaTrace1 = new TGraph(); gAnaTrace1 = new TGraph();
gAnaTrace2 = new TGraph(); gAnaTrace2 = new TGraph();
@ -262,7 +261,7 @@ MainWindow::~MainWindow() {
delete channelSettingPSD; delete channelSettingPSD;
delete registerSetting; delete registerSetting;
//delete scalarPanel; delete triggerSummary;
//delete saveDataThread; //delete saveDataThread;
delete fillHistThread; delete fillHistThread;
@ -289,7 +288,6 @@ void MainWindow::HandleMenu(Int_t id){
OpenDigitizers(); OpenDigitizers();
//fMenuDigitizers->EnableEntry( M_TRIGGER_SUMMARY);
//fMenuDigitizers->EnableEntry( M_BOARD_SETTINGS); //fMenuDigitizers->EnableEntry( M_BOARD_SETTINGS);
//fMenuDigitizers->EnableEntry( M_CH_SETTING); //fMenuDigitizers->EnableEntry( M_CH_SETTING);
@ -304,9 +302,9 @@ void MainWindow::HandleMenu(Int_t id){
///========================= Exit ///========================= Exit
case M_EXIT: GoodBye(); break; case M_EXIT: GoodBye(); break;
///========================= Channel setting summary ///========================= Trigger summary
case M_TRIGGER_SUMMARY: { case M_TRIGGER_SUMMARY: {
triggerSummary = new TriggerSummary(gClient->GetRoot(), 600, 600, digi, nDigi);
}break; }break;
///========================= Channel setting ///========================= Channel setting
@ -403,8 +401,8 @@ void MainWindow::OpenDigitizers(){
} }
fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN); fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN);
fMenuDigitizers->EnableEntry( M_LOAD_SETTINGS); fMenuDigitizers->EnableEntry( M_LOAD_SETTINGS);
fMenuDigitizers->EnableEntry( M_TRIGGER_SUMMARY); fMenuDigitizers->EnableEntry( M_TRIGGER_SUMMARY);
bOpenDigitizers->SetEnabled(false); bOpenDigitizers->SetEnabled(false);
bStartRun->SetEnabled(true); bStartRun->SetEnabled(true);
@ -472,6 +470,11 @@ void MainWindow::StopRun(){
digi[0]->StopACQ(); digi[0]->StopACQ();
//Save last bit of buffer;
///===== clear data;
digi[0]->GetData()->ClearTriggerRate();
bStartRun->SetEnabled(true); bStartRun->SetEnabled(true);
bStopRun->SetEnabled(false); bStopRun->SetEnabled(false);
dataPrefix->SetEnabled(true); dataPrefix->SetEnabled(true);
@ -487,8 +490,7 @@ void MainWindow::StopRun(){
} }
void MainWindow::OpenChannelSetting(Int_t boardID){ void MainWindow::OpenChannelSetting(Int_t boardID){
if( digi == NULL ) return;
printf("#### %s \n", __func__);
if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ){ if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ){
channelSettingPHA = new ChannelSettingPHA(gClient->GetRoot(), 600, 600, digi, nDigi, boardID); channelSettingPHA = new ChannelSettingPHA(gClient->GetRoot(), 600, 600, digi, nDigi, boardID);
@ -714,7 +716,7 @@ void * MainWindow::FillHistogram(void * ptr){
///Fill Channel Count ///Fill Channel Count
for( int i = 0 ; i < digi[boardID]->GetNChannel(); i++){ for( int i = 0 ; i < digi[boardID]->GetNChannel(); i++){
hChannel[boardID]->Fill(i, data->NumEvents[i]); for( int j = 0; j < data->NumEvents[i]; j++) hChannel[boardID]->Fill(i);
} }
///Fill Energy histogram ///Fill Energy histogram

View File

@ -12,7 +12,6 @@
#include <TGTextEditor.h> #include <TGTextEditor.h>
#include <TGTextEntry.h> #include <TGTextEntry.h>
#include "CAENDigitizer.h" #include "CAENDigitizer.h"
#include "macro.h" #include "macro.h"
@ -22,9 +21,8 @@
#include "channelSettingPHA.h" #include "channelSettingPHA.h"
#include "channelSettingPSD.h" #include "channelSettingPSD.h"
#include "registerSetting.h" #include "registerSetting.h"
#include "triggerSummary.h"
///#include "settingsSummary.h"
///#include "scalarPanel.h"
class TGWindow; class TGWindow;
class TGMainFrame; class TGMainFrame;
class TRootEmbeddedCanvas; class TRootEmbeddedCanvas;
@ -63,9 +61,8 @@ private:
ChannelSettingPHA * channelSettingPHA; ChannelSettingPHA * channelSettingPHA;
ChannelSettingPSD * channelSettingPSD; ChannelSettingPSD * channelSettingPSD;
RegisterSetting * registerSetting; RegisterSetting * registerSetting;
TriggerSummary * triggerSummary;
//ScalarPanel * scalarPanel;
//
//TThread * saveDataThread; //TThread * saveDataThread;
TThread * fillHistThread; TThread * fillHistThread;
@ -101,4 +98,5 @@ public:
void OpenChannelSetting(Int_t); void OpenChannelSetting(Int_t);
void LogMsg(char * ); void LogMsg(char * );
void GoodBye(); void GoodBye();
}; };

View File

@ -12,7 +12,7 @@ CAENLIBS = -lCAENDigitizer
ROOTLIBS = `root-config --cflags --glibs` ROOTLIBS = `root-config --cflags --glibs`
#OBJS = channelSettingPSD.o channelSettingPHA.o boardSetting.o ClassDigitizer.o DigitizerPHA.o DigitizerPSD.o FSUDAQ.o #OBJS = channelSettingPSD.o channelSettingPHA.o boardSetting.o ClassDigitizer.o DigitizerPHA.o DigitizerPSD.o FSUDAQ.o
OBJS = registerSetting.o channelSettingPSD.o channelSettingPHA.o boardSetting.o ClassDigitizer.o FSUDAQ.o OBJS = triggerSummary.o registerSetting.o channelSettingPSD.o channelSettingPHA.o boardSetting.o ClassDigitizer.o FSUDAQ.o
######################################################################### #########################################################################
@ -44,7 +44,6 @@ FSUDAQ : FSUDAQDict.cxx $(OBJS)
FSUDAQDict.cxx : FSUDAQ.h FSUDAQLinkDef.h FSUDAQDict.cxx : FSUDAQ.h FSUDAQLinkDef.h
@echo "----------- creating pcm and cxx for root" @echo "----------- creating pcm and cxx for root"
# @rootcling -f FSUDAQDict.cxx -c FSUDAQ.h -p FSUDAQLinkDef.h $(CAENLIBS)
@rootcling -f FSUDAQDict.cxx -c FSUDAQ.h -p FSUDAQLinkDef.h @rootcling -f FSUDAQDict.cxx -c FSUDAQ.h -p FSUDAQLinkDef.h
FSUDAQ.o : FSUDAQ.h FSUDAQ.cpp FSUDAQDict.cxx FSUDAQ.o : FSUDAQ.h FSUDAQ.cpp FSUDAQDict.cxx
@ -67,6 +66,10 @@ registerSetting.o : registerSetting.h registerSetting.cpp
@echo "----------- creating registerSetting.o" @echo "----------- creating registerSetting.o"
$(CC) $(COPTS) -c registerSetting.cpp $(ROOTLIBS) $(CC) $(COPTS) -c registerSetting.cpp $(ROOTLIBS)
triggerSummary.o : triggerSummary.h triggerSummary.cpp
@echo "----------- creating triggerSummary.o"
$(CC) $(COPTS) -c triggerSummary.cpp $(ROOTLIBS)
#CutsCreator: $(OBJS3) src/CutsCreator.c #CutsCreator: $(OBJS3) src/CutsCreator.c
# g++ -std=c++17 -pthread src/CutsCreator.c -o CutsCreator $(ROOTLIBS) # g++ -std=c++17 -pthread src/CutsCreator.c -o CutsCreator $(ROOTLIBS)

View File

@ -669,8 +669,11 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
///===== LVSD ///===== LVSD
TGHorizontalFrame * hframeLVSD = new TGHorizontalFrame(vframe); vframe->AddFrame(hframeLVSD, new TGLayoutHints(kLHintsCenterY , 5,5,3,4)); TGHorizontalFrame * hframeNote1 = new TGHorizontalFrame(vframe); vframe->AddFrame(hframeNote1, new TGLayoutHints(kLHintsCenterY , 5,5,0,0));
TGLabel * lbLVSD = new TGLabel(hframeLVSD, "LVSD Control is not impletmented."); hframeLVSD->AddFrame(lbLVSD, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 5, 5, 3, 2)); TGLabel * lbNote1 = new TGLabel(hframeNote1, "LVSD Control is not impletmented."); hframeNote1->AddFrame(lbNote1, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 5, 5, 0, 0));
TGHorizontalFrame * hframeNote2 = new TGHorizontalFrame(vframe); vframe->AddFrame(hframeNote2, new TGLayoutHints(kLHintsCenterY , 5,5,0,0));
TGLabel * lbNote2 = new TGLabel(hframeNote2, "Trigger Validation Mask only for 0x8180."); hframeNote2->AddFrame(lbNote2, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 5, 5, 0, 0));
///==================== Read digitizer Setting ///==================== Read digitizer Setting
ChangeBoard(); ChangeBoard();
@ -855,7 +858,7 @@ void BoardSetting::ChangeBoard(){
bGLBSoftwareTrigger->SetState( (( tempBits >> 31) & 0x1 ) == 0 ? kButtonUp : kButtonDown, false); bGLBSoftwareTrigger->SetState( (( tempBits >> 31) & 0x1 ) == 0 ? kButtonUp : kButtonDown, false);
/// Trigger Validation Mask /// Trigger Validation Mask
tempBits = digi[boardID]->ReadRegister(Register::DPP::TriggerValidationMask); tempBits = digi[boardID]->ReadRegister(Register::DPP::TriggerValidationMask_G);
for( int i = 0; i < 8; i++){ for( int i = 0; i < 8; i++){
cbTRGValMskCh[i]->SetState( ((tempBits >> i ) & 0x1) == 0 ? kButtonUp : kButtonDown , false); cbTRGValMskCh[i]->SetState( ((tempBits >> i ) & 0x1) == 0 ? kButtonUp : kButtonDown , false);
} }
@ -1222,7 +1225,7 @@ void BoardSetting::SetTriggerValidMask(){ /// same for PHA and PSD
printf("bit : 0x%x \n", bit); printf("bit : 0x%x \n", bit);
digi[boardID]->WriteRegister(Register::DPP::TriggerValidationMask, bit ); digi[boardID]->WriteRegister(Register::DPP::TriggerValidationMask_G, bit );
} }
void BoardSetting::SetTRGOUTMask(){ /// same for PHA and PSD void BoardSetting::SetTRGOUTMask(){ /// same for PHA and PSD

View File

@ -60,7 +60,6 @@ RegisterSetting::RegisterSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitize
} }
{///==================== Controls {///==================== Controls
TGHorizontalFrame *hframeAll = new TGHorizontalFrame(vframe, w, 50 ); vframe->AddFrame(hframeAll, layoutHints); TGHorizontalFrame *hframeAll = new TGHorizontalFrame(vframe, w, 50 ); vframe->AddFrame(hframeAll, layoutHints);
bSetALLChannel = new TGCheckButton(hframeAll, "Set ALL Channels", 1); hframeAll->AddFrame(bSetALLChannel, haha); bSetALLChannel = new TGCheckButton(hframeAll, "Set ALL Channels", 1); hframeAll->AddFrame(bSetALLChannel, haha);
@ -85,7 +84,7 @@ RegisterSetting::RegisterSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitize
TGLabel * lbCh[MaxNChannels]; TGLabel * lbCh[MaxNChannels];
for( int i = 0; i < digi[boardID]->GetNChannel(); i++){ for( int i = 0; i < ( digi == NULL ? MaxNChannels : digi[boardID]->GetNChannel() ); i++){
lbCh[i] = new TGLabel(vframe0, Form("%02d", i)); vframe0->AddFrame(lbCh[i], new TGLayoutHints(kLHintsRight, 5,5,3,2)); lbCh[i] = new TGLabel(vframe0, Form("%02d", i)); vframe0->AddFrame(lbCh[i], new TGLayoutHints(kLHintsRight, 5,5,3,2));
@ -139,15 +138,18 @@ RegisterSetting::~RegisterSetting(){
} }
void RegisterSetting::ChangeBoard(){ void RegisterSetting::ChangeBoard(){
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber(); int DPPType = V1730_DPP_PHA_CODE;
if( digi != NULL ){
int boardID = boardIDEntry->GetNumber();
DPPType = digi[boardID]->GetDPPType();
}
cbName->RemoveAll(); cbName->RemoveAll();
cbName->AddEntry("Address NOT Exist", 0); cbName->AddEntry("Address NOT Exist", 0);
if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE){ /// PHA if( DPPType == V1730_DPP_PHA_CODE){ /// PHA
cbName->AddEntry("DPP::PHA::DataFlush_W" , Register::DPP::PHA::DataFlush_W ); cbName->AddEntry("DPP::PHA::DataFlush_W" , Register::DPP::PHA::DataFlush_W );
cbName->AddEntry("DPP::PHA::ChannelStopAcquisition" , Register::DPP::PHA::ChannelStopAcquisition ); cbName->AddEntry("DPP::PHA::ChannelStopAcquisition" , Register::DPP::PHA::ChannelStopAcquisition );
cbName->AddEntry("DPP::PHA::RCCR2SmoothingFactor" , Register::DPP::PHA::RCCR2SmoothingFactor ); cbName->AddEntry("DPP::PHA::RCCR2SmoothingFactor" , Register::DPP::PHA::RCCR2SmoothingFactor );
@ -165,7 +167,7 @@ void RegisterSetting::ChangeBoard(){
cbName->AddEntry("DPP::PHA::FineGain" , Register::DPP::PHA::FineGain ); cbName->AddEntry("DPP::PHA::FineGain" , Register::DPP::PHA::FineGain );
} }
if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE){ /// PSD if( DPPType == V1730_DPP_PSD_CODE){ /// PSD
cbName->AddEntry("DPP::PSD::CFDSetting" , Register::DPP::PSD::CFDSetting ); cbName->AddEntry("DPP::PSD::CFDSetting" , Register::DPP::PSD::CFDSetting );
cbName->AddEntry("DPP::PSD::ForcedDataFlush_W" , Register::DPP::PSD::ForcedDataFlush_W ); cbName->AddEntry("DPP::PSD::ForcedDataFlush_W" , Register::DPP::PSD::ForcedDataFlush_W );
cbName->AddEntry("DPP::PSD::ChargeZeroSuppressionThreshold", Register::DPP::PSD::ChargeZeroSuppressionThreshold ); cbName->AddEntry("DPP::PSD::ChargeZeroSuppressionThreshold", Register::DPP::PSD::ChargeZeroSuppressionThreshold );
@ -184,7 +186,7 @@ void RegisterSetting::ChangeBoard(){
} }
if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE || digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE){ if( DPPType == V1730_DPP_PSD_CODE || DPPType == V1730_DPP_PHA_CODE){
cbName->AddEntry("DPP::RecordLength_G" , Register::DPP::RecordLength_G ); cbName->AddEntry("DPP::RecordLength_G" , Register::DPP::RecordLength_G );
cbName->AddEntry("DPP::InputDynamicRange" , Register::DPP::InputDynamicRange ); cbName->AddEntry("DPP::InputDynamicRange" , Register::DPP::InputDynamicRange );
cbName->AddEntry("DPP::NumberEventsPerAggregate_G" , Register::DPP::NumberEventsPerAggregate_G ); cbName->AddEntry("DPP::NumberEventsPerAggregate_G" , Register::DPP::NumberEventsPerAggregate_G );
@ -289,13 +291,13 @@ std::string RegisterSetting::GetRegisterName(uint32_t address){
} }
void RegisterSetting::UpdateRegister(){ void RegisterSetting::UpdateRegister(){
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
uint32_t address = cbName->GetSelected(); uint32_t address = cbName->GetSelected();
txtAddress->SetText(Form("0x%04X", address), false); txtAddress->SetText(Form("0x%04X", address), false);
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
///check is the register readable ///check is the register readable
std::string haha = cbName->GetSelectedEntry()->GetTitle(); std::string haha = cbName->GetSelectedEntry()->GetTitle();
int type = haha.back(); int type = haha.back();
@ -382,9 +384,6 @@ void RegisterSetting::SetTxtValueUnit(uint32_t address, int ch){
if( digi == NULL ) return; if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber(); int boardID = boardIDEntry->GetNumber();
std::string unit = "";
float valueUnit = 0;
int ch2ns = (int) digi[boardID]->GetCh2ns(); int ch2ns = (int) digi[boardID]->GetCh2ns();
txtValueUnit[ch]->SetText(""); txtValueUnit[ch]->SetText("");
@ -430,27 +429,34 @@ void RegisterSetting::SetTxtValueUnit(uint32_t address, int ch){
} }
lbValueUnit->SetText("Value [ns]"); lbValueUnit->SetText("Value [ns]");
} }
} }
if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE){ /// PSD if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE){ /// PSD
if( address == Register::DPP::PSD::CFDSetting ){ if( address == Register::DPP::PSD::ChargeZeroSuppressionThreshold ||
address == Register::DPP::PSD::TriggerThreshold ||
} address == Register::DPP::PSD::FixedBaseline
if( address == Register::DPP::PSD::ChargeZeroSuppressionThreshold ){ ){
} txtValueUnit[ch]->SetText(Form("%d", value[ch]));
if( address == Register::DPP::PSD::ShortGateWidth ){ lbValueUnit->SetText("Value [LSB]");
} }
if( address == Register::DPP::PSD::LongGateWidth ){} if( address == Register::DPP::PSD::ShortGateWidth ||
if( address == Register::DPP::PSD::GateOffset ){} address == Register::DPP::PSD::LongGateWidth ||
if( address == Register::DPP::PSD::TriggerThreshold ){} address == Register::DPP::PSD::GateOffset
if( address == Register::DPP::PSD::FixedBaseline ){} ){
if( address == Register::DPP::PSD::TriggerLatency ){} txtValueUnit[ch]->SetText(Form("%d", ch2ns * value[ch]));
if( address == Register::DPP::PSD::ShapedTriggerWidth ){} lbValueUnit->SetText("Value [ns]");
if( address == Register::DPP::PSD::TriggerHoldOffWidth ){} }
if( address == Register::DPP::PSD::ThresholdForPSDCut ){} if( address == Register::DPP::PSD::TriggerLatency ||
if( address == Register::DPP::PSD::PurGapThreshold ){} address == Register::DPP::PSD::ShapedTriggerWidth ||
if( address == Register::DPP::PSD::EarlyBaselineFreeze ){} address == Register::DPP::PSD::TriggerHoldOffWidth ||
address == Register::DPP::PSD::EarlyBaselineFreeze
){
txtValueUnit[ch]->SetText(Form("%d", 4* ch2ns * value[ch]));
lbValueUnit->SetText("Value [ns]");
}
if( address == Register::DPP::PSD::PurGapThreshold ){
//TODO
}
} }
@ -479,9 +485,6 @@ void RegisterSetting::SetTxtValueUnit(uint32_t address, int ch){
lbValueUnit->SetText("Value [%]"); lbValueUnit->SetText("Value [%]");
} }
} }
} }
unsigned int RegisterSetting::ConvertHexToDec(const char * text){ unsigned int RegisterSetting::ConvertHexToDec(const char * text){
@ -507,7 +510,6 @@ void RegisterSetting::TypeRegisterAddress(){
} }
} }
void RegisterSetting::ChangeValue(){ void RegisterSetting::ChangeValue(){
printf("=============%s\n", __func__); printf("=============%s\n", __func__);
@ -578,3 +580,6 @@ void RegisterSetting::SendChangeSignal(){
Emit("SendChangeSignal()"); Emit("SendChangeSignal()");
} }
void RegisterSetting::LogMsg(TString msg){
Emit("LogMsg(char*)", msg.Data());
}

View File

@ -60,7 +60,7 @@ class RegisterSetting{
void SetAllChannels(); void SetAllChannels();
void SendChangeSignal(); // *SIGNAL* void SendChangeSignal(); // *SIGNAL*
void LogMsg(TString msg); // *SIGNAL*
}; };

157
triggerSummary.cpp Normal file
View File

@ -0,0 +1,157 @@
#include <TApplication.h>
#include <TGClient.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
#include <TRootEmbeddedCanvas.h>
#include <TGTableContainer.h>
#include <TGFileDialog.h>
#include "triggerSummary.h"
Digitizer ** TriggerSummary::digi = NULL;
int TriggerSummary::nDigi = 0;
bool TriggerSummary::updateFlag = true;
TGTextEntry * TriggerSummary::txtTrigger[MaxNBoards][MaxNChannels] = {NULL};
TGTextEntry * TriggerSummary::txtThreshold[MaxNBoards][MaxNChannels] = {NULL};
TGNumberEntry * TriggerSummary::numUpdateTime = NULL;
TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard){
this->nDigi = nBoard;
this->digi = digi;
fMain = new TGMainFrame(p,w,h);
fMain->SetWindowName("Scalar Panel");
fMain->Connect("CloseWindow()", "TriggerSummary", this, "CloseWindow()");
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain); fMain->AddFrame(hframe);
TGLayoutHints * kaka = new TGLayoutHints(kLHintsLeft, 0,0,0,0); /// left, right, top, bottom
TGGroupFrame * gBD[nDigi];
TGLabel * lbCh[nDigi][MaxNChannels];
for( int bd = 0; bd < nDigi; bd++){
gBD[bd] = new TGGroupFrame(hframe, Form("Board-%02d", bd), kHorizontalFrame); hframe->AddFrame(gBD[bd], new TGLayoutHints( kLHintsExpandY, 5, 0, 5, 5));
TGVerticalFrame * vframe0 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe0, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0));
TGVerticalFrame * vframe1 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe1, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0));
TGVerticalFrame * vframe2 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe2, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0));
TGLabel * lbCh0 = new TGLabel(vframe0, "ch"); vframe0->AddFrame(lbCh0, new TGLayoutHints(kLHintsCenterY, 0,5,3,2));
TGLabel * lbTrigger = new TGLabel(vframe1, "Trig.[Hz]"); vframe1->AddFrame(lbTrigger, new TGLayoutHints(kLHintsCenterY, 5,5,3,2));
TGLabel * lbThreshold = new TGLabel(vframe2, "Thres."); vframe2->AddFrame(lbThreshold, new TGLayoutHints(kLHintsCenterY, 5,5,3,2));
for( int ch = 0; ch < (digi == NULL ? MaxNChannels: digi[bd]->GetNChannel()); ch++){
lbCh[bd][ch] = new TGLabel(vframe0, Form("%02d", ch)); vframe0->AddFrame(lbCh[bd][ch], new TGLayoutHints(kLHintsCenterY, 0,5,3,2));
txtTrigger[bd][ch] = new TGTextEntry(vframe1, ""); vframe1->AddFrame(txtTrigger[bd][ch], kaka);
txtTrigger[bd][ch]->Resize(50,20);
txtTrigger[bd][ch]->SetEnabled(false);
txtTrigger[bd][ch]->SetAlignment(kTextRight);
txtThreshold[bd][ch] = new TGTextEntry(vframe2, ""); vframe2->AddFrame(txtThreshold[bd][ch], kaka);
txtThreshold[bd][ch]->Resize(50,20);
txtThreshold[bd][ch]->SetAlignment(kTextRight);
txtThreshold[bd][ch]->Connect("ReturnPressed()", "TriggerSummary", this, "SetThreshold()");
value[bd][ch] = 0;
if( digi != NULL ){
if( digi[bd]->GetDPPType() == V1730_DPP_PSD_CODE ) value[bd][ch] = digi[bd]->ReadRegister(Register::DPP::PSD::TriggerThreshold, ch);
if( digi[bd]->GetDPPType() == V1730_DPP_PHA_CODE ) value[bd][ch] = digi[bd]->ReadRegister(Register::DPP::PHA::TriggerThreshold, ch);
}
txtThreshold[bd][ch]->SetText(Form("%d", value[bd][ch]), false);
}
}
TGHorizontalFrame * hframeSetting = new TGHorizontalFrame(fMain); fMain->AddFrame(hframeSetting, new TGLayoutHints(kLHintsExpandX));
TGLabel * lbUpDateTime = new TGLabel(hframeSetting, "Update Period [msec]:");
hframeSetting->AddFrame(lbUpDateTime, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
numUpdateTime = new TGNumberEntry(hframeSetting, 500, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
hframeSetting->AddFrame(numUpdateTime, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
numUpdateTime->Resize(50, 20);
fMain->MapSubwindows();
fMain->Resize(fMain->GetDefaultSize());
fMain->MapWindow();
updateFlag = true;
if( digi != NULL ){
printf("-------- %s thread\n", __func__);
thread = new TThread("hahaha", UpdateTriggerRate, (void *) 0);
thread->Run();
}
}
TriggerSummary::~TriggerSummary(){
printf("Close %s \n", __func__);
for(int i = 0; i < nDigi; i++){
for(int j = 0; j < MaxNChannels; j++){
delete txtTrigger[i][j];
delete txtThreshold[i][j];
}
}
delete numUpdateTime;
updateFlag = false;
usleep(1000 * 1000);
///delete thread; /// Don;t delete the thread, otherwise, thread will not run after close and reopen.
fMain->Cleanup();
delete fMain;
}
void * TriggerSummary::UpdateTriggerRate(void * ptr){
while( updateFlag){
for( int bd = 0; bd < nDigi; bd++){
for( int ch = 0; ch < digi[bd]->GetNChannel(); ch++){
txtTrigger[bd][ch]->SetText(Form("%.2f", digi[bd]->GetData()->TriggerRate[ch]));
}
}
usleep(numUpdateTime->GetNumber() * 1000);
}
}
void TriggerSummary::SetThreshold(){
if( digi == NULL ) return;
for( int bd = 0; bd < nDigi; bd++){
for( int ch = 0; ch < digi[bd]->GetNChannel(); ch++){
unsigned short haha = atoi( txtThreshold[bd][ch]->GetText());
if( value[bd][ch] != haha ){
if( digi[bd]->GetDPPType() == V1730_DPP_PSD_CODE ) {
digi[bd]->WriteRegister(Register::DPP::PSD::TriggerThreshold, haha, ch);
value[bd][ch] = digi[bd]->ReadRegister(Register::DPP::PSD::TriggerThreshold, ch);
}
if( digi[bd]->GetDPPType() == V1730_DPP_PHA_CODE ) {
digi[bd]->WriteRegister(Register::DPP::PHA::TriggerThreshold, haha, ch);
value[bd][ch] = digi[bd]->ReadRegister(Register::DPP::PHA::TriggerThreshold, ch);
}
txtThreshold[bd][ch]->SetText(Form("%d", value[bd][ch]), false);
}
}
}
}

47
triggerSummary.h Normal file
View File

@ -0,0 +1,47 @@
#ifndef TRIGGER_SUMMARY_H
#define TRIGGER_SUMMARY_H
#include <TQObject.h>
#include <RQ_OBJECT.h>
#include <TGNumberEntry.h>
#include <TGButton.h>
#include <TGComboBox.h>
#include <TThread.h>
#include <TGLabel.h>
#include "ClassDigitizer.h"
#include "macro.h"
class TGWindow;
class TGMainFrame;
class TriggerSummary{
RQ_OBJECT("TriggerSummary")
private:
TGMainFrame * fMain;
static int nDigi;
static Digitizer ** digi;
static TGTextEntry * txtTrigger[MaxNBoards][MaxNChannels];
static TGTextEntry * txtThreshold[MaxNBoards][MaxNChannels];
TThread * thread;
static bool updateFlag;
static TGNumberEntry * numUpdateTime;
unsigned short value[MaxNBoards][MaxNChannels];
public:
TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard);
virtual ~TriggerSummary();
void CloseWindow() { delete this;}
static void * UpdateTriggerRate(void *ptr);
void SetThreshold();
void SetThreshold(int boardID, int ch, unsigned short val) { value[boardID][ch] = val; }
};
#endif