clean up FSQDAQ.h/cpp a bit

This commit is contained in:
carina@hades 2022-09-28 17:54:33 -04:00
parent 58cb570542
commit f29dfb1438
4 changed files with 103 additions and 78 deletions

View File

@ -36,22 +36,19 @@ enum MenuIdentifiers{
}; };
///make static members ///make static members
Digitizer ** MainWindow::digi = NULL; Digitizer ** MainWindow::digi = NULL;
DigitizerPHA ** MainWindow::pha = NULL;
DigitizerPSD ** MainWindow::psd = NULL;
TGTextEdit * MainWindow::teLog = NULL; TGTextEdit * MainWindow::teLog = NULL;
TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL; TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL;
MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
nDigi = 0; nDigi = 0;
nPSD = 0;
nPHA = 0;
/// Create a main frame /// Create a main frame
fMain = new TGMainFrame(p,w,h); fMain = new TGMainFrame(p,w,h);
///fMain->SetWMPosition(500, 500); //does not work ///fMain->SetWMPosition(500, 500); //does not work
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());
@ -85,31 +82,54 @@ 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));
{///================= Create a horizontal frame widget with buttons
TGGroupFrame * group0 = new TGGroupFrame(hframe, "Hahaha", kHorizontalFrame); hframe->AddFrame(group0 );
TGHorizontalFrame *hfg0 = new TGHorizontalFrame(group0,200,30); group0->AddFrame(hfg0 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
TGLayoutHints * uniLayoutHints = new TGLayoutHints(kLHintsNormal, 2,2,10,0); ///left, right, top, bottom TGLayoutHints * uniLayoutHints = new TGLayoutHints(kLHintsNormal, 2,2,10,0); ///left, right, top, bottom
///================= Create a horizontal frame widget with buttons bOpenDigitizers = new TGTextButton(hfg0,"Open Digitizers"); hfg0->AddFrame(bOpenDigitizers, uniLayoutHints);
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,200,40);
fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
///================= Open digitizers
bOpenDigitizers = new TGTextButton(hframe,"Open Digitizers");
bOpenDigitizers->Connect("Clicked()","MainWindow",this,"OpenDigitizers()"); bOpenDigitizers->Connect("Clicked()","MainWindow",this,"OpenDigitizers()");
hframe->AddFrame(bOpenDigitizers, uniLayoutHints);
///================= Start Run TGTextButton *bStartRun = new TGTextButton(hfg0,"Start Run"); hfg0->AddFrame(bStartRun, uniLayoutHints);
TGTextButton *bStartRun = new TGTextButton(hframe,"Start Run"); hframe->AddFrame(bStartRun, uniLayoutHints); bStartRun->Connect("Clicked()", "MainWindow", this, "StartRun()");
///================= Stop Run TGTextButton *bStopRun = new TGTextButton(hfg0,"Stop Run"); hfg0->AddFrame(bStopRun, uniLayoutHints);
TGTextButton *bStopRun = new TGTextButton(hframe,"Stop Run"); hframe->AddFrame(bStopRun, uniLayoutHints); bStopRun->Connect("Clicked()", "MainWindow", this, "StopRun()");
///================= signal Channel group TGCheckButton* bSaveData = new TGCheckButton(hfg0, "ACQ Start/Arm", 1); hfg0->AddFrame(bSaveData, uniLayoutHints);
TGGroupFrame * group1 = new TGGroupFrame(hframe, "Single Channel", kHorizontalFrame); bSaveData->SetState(kButtonDown);
hframe->AddFrame(group1 ); }
TGHorizontalFrame *hframe1 = new TGHorizontalFrame(group1,200,30); {///================= sigle Channel group
group1->AddFrame(hframe1 ); TGGroupFrame * group1 = new TGGroupFrame(hframe, "Single Channel", kHorizontalFrame); hframe->AddFrame(group1 );
TGHorizontalFrame *hfg1 = new TGHorizontalFrame(group1,200,30); group1->AddFrame(hfg1 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
///================= Create canvas widget TGLayoutHints * haha = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 2, 10, 0); ///left, right, top, bottom
TGLabel * lb0 = new TGLabel(hfg1, "Board"); hfg1->AddFrame(lb0, haha);
TGNumberEntry * boardIDEntry = new TGNumberEntry(hfg1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hfg1->AddFrame(boardIDEntry, haha);
boardIDEntry->SetWidth(50);
//boardIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nBoard-1);
TGLabel * lb1 = new TGLabel(hfg1, "Channel"); hfg1->AddFrame(lb1, haha);
TGNumberEntry* chIDEntry = new TGNumberEntry(hfg1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); hfg1->AddFrame(chIDEntry, haha);
chIDEntry->SetWidth(50);
TGLabel * lbMode = new TGLabel(hfg1, "Mode"); hfg1->AddFrame(lbMode, haha);
TGComboBox* cbMode = new TGComboBox(hfg1); hfg1->AddFrame(cbMode, haha);
cbMode->AddEntry("Energy Hist", 0);
cbMode->AddEntry("Ocs.", 1);
cbMode->Select(1, false);
cbMode->Resize(80, 20);
}
///================= canvas widget
fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,900,400); fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,900,400);
fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,10)); fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,10));
///================= Log massage ///================= Log massage
@ -141,9 +161,9 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
LogMsg("Please \"Open Digitizers\" to start."); LogMsg("Please \"Open Digitizers\" to start.");
HandleMenu(M_DIGITIZER_OPEN); //HandleMenu(M_DIGITIZER_OPEN);
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);
@ -259,6 +279,7 @@ void MainWindow::HandleMenu(Int_t id){
void MainWindow::OpenDigitizers(){ void MainWindow::OpenDigitizers(){
LogMsg("============= detect digitizers"); LogMsg("============= detect digitizers");
vector<int> DPPType;
DPPType.clear(); DPPType.clear();
portID.clear(); portID.clear();
boardID.clear(); boardID.clear();
@ -276,8 +297,6 @@ void MainWindow::OpenDigitizers(){
boardID.push_back(board); boardID.push_back(board);
serialNum.push_back(dig->GetSerialNumber()); serialNum.push_back(dig->GetSerialNumber());
dig->CloseDigitizer(); dig->CloseDigitizer();
if( dig->GetDPPType() == V1730_DPP_PHA_CODE ) nPHA ++;
if( dig->GetDPPType() == V1730_DPP_PSD_CODE ) nPSD ++;
} }
} }
} }
@ -286,9 +305,6 @@ void MainWindow::OpenDigitizers(){
for( int i = 0 ; i < nDigi ; i++){ for( int i = 0 ; i < nDigi ; i++){
LogMsg(Form("port: %d, board: %d, DPP Type : %d", portID[i], boardID[i], DPPType[i])); LogMsg(Form("port: %d, board: %d, DPP Type : %d", portID[i], boardID[i], DPPType[i]));
} }
LogMsg(Form("Number of PHA : %d", nPHA));
LogMsg(Form("Number of PSD : %d", nPSD));
if( nDigi > 0 ) { if( nDigi > 0 ) {
LogMsg(Form("============= Connect %d digitizer(s)...", nDigi)); LogMsg(Form("============= Connect %d digitizer(s)...", nDigi));
@ -339,6 +355,22 @@ void MainWindow::GoodBye(){
} }
void MainWindow::StartRun(){
LogMsg(Form("%s",__func__));
if( digi == NULL) return;
digi[0]->StartACQ();
}
void MainWindow::StopRun(){
LogMsg(Form("%s",__func__));
if( digi == NULL) return;
}
void MainWindow::OpenChannelSetting(Int_t boardID){ void MainWindow::OpenChannelSetting(Int_t boardID){
printf("#### %s \n", __func__); printf("#### %s \n", __func__);
@ -406,7 +438,7 @@ void MainWindow::PlotTrace(){
printf("0----------%d \n", traceLength); printf("0----------%d \n", traceLength);
if( traceLength == 0 ) { if( traceLength == 0 ) {
LogMsg("no trace"); LogMsg((char *)"no trace");
}else{ }else{
for( int i = 0; i < traceLength ; i++) { for( int i = 0; i < traceLength ; i++) {
//printf("%d, ", (data->Waveform1[0][0])[i]); //printf("%d, ", (data->Waveform1[0][0])[i]);

View File

@ -48,14 +48,10 @@ private:
TGTextButton *bOpenDigitizers; TGTextButton *bOpenDigitizers;
unsigned short nDigi; unsigned short nDigi;
vector<int> DPPType;
vector<int> portID; vector<int> portID;
vector<int> boardID; vector<int> boardID;
vector<int> serialNum; vector<int> serialNum;
static Digitizer ** digi; static Digitizer ** digi;
unsigned short nPHA, nPSD;
static DigitizerPHA ** pha;
static DigitizerPSD ** psd;
BoardSetting * boardSetting; BoardSetting * boardSetting;
ChannelSettingPHA * channelSettingPHA; ChannelSettingPHA * channelSettingPHA;
@ -68,14 +64,11 @@ private:
//TThread * fillHistThread; //TThread * fillHistThread;
//static TH1F * hEnergy[MAXMOD][MAXCH]; //static TH1F * hEnergy[MAXMOD][MAXCH];
//static TH1F * hChannel[MAXMOD]; //static TH1F * hChannel[MAXMOD];
//static bool isEnergyHistFilled;
TGraph * gAnaTrace1; /// analogy trace 1 TGraph * gAnaTrace1; /// analogy trace 1
TGraph * gAnaTrace2; /// analogy trace 2 TGraph * gAnaTrace2; /// analogy trace 2
TGraph * gDigiTrace1; /// digital trace 1 TGraph * gDigiTrace1; /// digital trace 1
TGraph * gDigiTrace2; /// digital trace 1 TGraph * gDigiTrace2; /// digital trace 1
//TGTextEditor * configEditor;
public: public:
MainWindow(const TGWindow *p, UInt_t w, UInt_t h); MainWindow(const TGWindow *p, UInt_t w, UInt_t h);
@ -89,9 +82,9 @@ public:
//void GetBaseLine(); //void GetBaseLine();
//void Scope(); //void Scope();
//void FitTrace(); //void FitTrace();
//void StartRun(); void StartRun();
//static void * SaveData(void* ptr ); /// thread //static void * SaveData(void* ptr ); /// thread
//void StopRun(); void StopRun();
//void OpenScalar(); //void OpenScalar();
//static void * FillHistogram(void * ptr); /// thread //static void * FillHistogram(void * ptr); /// thread
//void ChangeMod(); //void ChangeMod();

View File

@ -46,12 +46,12 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
NChannel = 16 ;// digi[0]->GetNChannel(); NChannel = 16 ;// digi[0]->GetNChannel();
TGLabel * lb1 = new TGLabel(hframe0, "Channel :"); hframe0->AddFrame(lb1, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4)); TGLabel * lb1 = new TGLabel(hframe0, "Channel :"); hframe0->AddFrame(lb1, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
chIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); chIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); hframe0->AddFrame(chIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
chIDEntry->SetWidth(50); chIDEntry->SetWidth(50);
chIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, -1, NChannel-1); chIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, -1, NChannel-1);
chIDEntry->SetNumber(0, false); chIDEntry->SetNumber(0, false);
chIDEntry->Connect("Modified()", "ChannelSettingPHA", this, "ChangeCh()"); chIDEntry->Connect("Modified()", "ChannelSettingPHA", this, "ChangeCh()");
hframe0->AddFrame(chIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
TGTextButton* bSetAllChannels = new TGTextButton(hframe0, "Set All Channels", 1); hframe0->AddFrame(bSetAllChannels, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4)); TGTextButton* bSetAllChannels = new TGTextButton(hframe0, "Set All Channels", 1); hframe0->AddFrame(bSetAllChannels, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
bSetAllChannels->SetState(kButtonUp); bSetAllChannels->SetState(kButtonUp);

View File

@ -173,7 +173,7 @@ int main(int argc, char* argv[]){
ElapsedTime = CurrentTime - PreviousTime; /// milliseconds ElapsedTime = CurrentTime - PreviousTime; /// milliseconds
if( ElapsedTime > 1000 ){ if( ElapsedTime > 1000 ){
system("clear"); int temp = system("clear");
data->PrintStat(); data->PrintStat();
PreviousTime = CurrentTime; PreviousTime = CurrentTime;
} }