added Utility Menu, add channels scalar histogram

This commit is contained in:
Ryan Tang 2022-04-13 16:22:10 -04:00
parent 6632ba5d3f
commit bb9923c065
6 changed files with 49 additions and 8 deletions

View File

@ -78,6 +78,7 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 *
modIDEntry->SetWidth(50); modIDEntry->SetWidth(50);
modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1); modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1);
modIDEntry->Connect("Modified()", "ChannelSetting", this, "ChangeMod()"); modIDEntry->Connect("Modified()", "ChannelSetting", this, "ChangeMod()");
if( pixie->GetNumModule() == 1 ) modIDEntry->SetState(false);
hframe0->AddFrame(modIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); hframe0->AddFrame(modIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
TGLabel * lb1 = new TGLabel(hframe0, "Channel :"); TGLabel * lb1 = new TGLabel(hframe0, "Channel :");

View File

@ -48,6 +48,8 @@ ModuleSetting::ModuleSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pi
modIDEntry->SetWidth(50); modIDEntry->SetWidth(50);
modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1); modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1);
modIDEntry->Connect("Modified()", "ModuleSetting", this, "ChangeMod()"); modIDEntry->Connect("Modified()", "ModuleSetting", this, "ChangeMod()");
if( pixie->GetNumModule() == 1 ) modIDEntry->SetState(false);
hframe0->AddFrame(modIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); hframe0->AddFrame(modIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
int modID = modIDEntry->GetNumber(); int modID = modIDEntry->GetNumber();

View File

@ -9,7 +9,6 @@
#include <TGLabel.h> #include <TGLabel.h>
#include <TGNumberEntry.h> #include <TGNumberEntry.h>
#include <TGraph.h> #include <TGraph.h>
#include <TGTextEditor.h>
#include <TAxis.h> #include <TAxis.h>
#include <TF1.h> #include <TF1.h>
@ -27,7 +26,9 @@ enum MenuIdentifiers{
M_EXIT, M_EXIT,
M_CH_SETTINGS_SUMMARY, M_CH_SETTINGS_SUMMARY,
M_CH_SETTING, M_CH_SETTING,
M_MODULE_SETTINGS M_MODULE_SETTINGS,
M_FINDPEAKS,
M_SHOW_CHANNELS_RATE
}; };
@ -40,6 +41,7 @@ TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL;
TGNumberEntry * MainWindow::modIDEntry = NULL; TGNumberEntry * MainWindow::modIDEntry = NULL;
TGNumberEntry * MainWindow::chEntry = NULL; TGNumberEntry * MainWindow::chEntry = NULL;
TH1F * MainWindow::hEnergy[MAXMOD][MAXCH]={NULL}; TH1F * MainWindow::hEnergy[MAXMOD][MAXCH]={NULL};
TH1F * MainWindow::hChannel[MAXMOD]={NULL};
bool MainWindow::isEnergyHistFilled = false; bool MainWindow::isEnergyHistFilled = false;
MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
@ -57,6 +59,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
for( int j = 0; j < MAXCH ; j++){ for( int j = 0; j < MAXCH ; j++){
hEnergy[i][j] = new TH1F(Form("hEnergy%02d_%02d", i, j), Form("Energy mod:%2d ch:%02d (down scaled)", i, j), 200, 0, 160000); hEnergy[i][j] = new TH1F(Form("hEnergy%02d_%02d", i, j), Form("Energy mod:%2d ch:%02d (down scaled)", i, j), 200, 0, 160000);
} }
hChannel[i] = new TH1F(Form("hChannel%02d", i), Form("Channel Stat. mod:%2d (down scaled)", i), MAXCH, 0, MAXCH);
} }
/// Create a main frame /// Create a main frame
@ -64,15 +67,14 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t 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());
fMenuFile->AddEntry("&Open...", M_FILE_OPEN); fMenuFile->AddEntry("&Open Pixie16.config", M_FILE_OPEN);
fMenuFile->AddSeparator(); fMenuFile->AddSeparator();
fMenuFile->AddEntry("E&xit", M_EXIT); fMenuFile->AddEntry("E&xit", M_EXIT);
fMenuFile->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuFile->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
@ -81,10 +83,15 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMenuSettings->AddEntry("&Channel Setting", M_CH_SETTING); fMenuSettings->AddEntry("&Channel Setting", M_CH_SETTING);
fMenuSettings->AddSeparator(); fMenuSettings->AddSeparator();
fMenuSettings->AddEntry("Digitizer &Settings", M_MODULE_SETTINGS); fMenuSettings->AddEntry("Digitizer &Settings", M_MODULE_SETTINGS);
fMenuSettings->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuSettings->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&Settings", fMenuSettings, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); fMenuBar->AddPopup("&Settings", fMenuSettings, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
fMenuUtility = new TGPopupMenu(gClient->GetRoot());
fMenuUtility->AddEntry("Plot Channels Rate", M_SHOW_CHANNELS_RATE);
fMenuSettings->AddSeparator();
fMenuUtility->AddEntry("Find &Peaks", M_FINDPEAKS);
fMenuUtility->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&Utility", fMenuUtility, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 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
@ -106,6 +113,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
modIDEntry->SetWidth(50); modIDEntry->SetWidth(50);
modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1); modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1);
modIDEntry->Connect("Modified()", "MainWindow", this, "ChangeMod()"); modIDEntry->Connect("Modified()", "MainWindow", this, "ChangeMod()");
if( pixie->GetNumModule() == 1 ) modIDEntry->SetState(false);
hframe1->AddFrame(modIDEntry, uniLayoutHints); hframe1->AddFrame(modIDEntry, uniLayoutHints);
TGLabel * lb2 = new TGLabel(hframe1, "Ch :"); TGLabel * lb2 = new TGLabel(hframe1, "Ch :");
@ -252,6 +260,8 @@ MainWindow::~MainWindow() {
delete gTrace; delete gTrace;
delete configEditor;
/// Clean up used widgets: frames, buttons, layout hints /// Clean up used widgets: frames, buttons, layout hints
fMain->Cleanup(); fMain->Cleanup();
delete fMain; delete fMain;
@ -264,6 +274,8 @@ void MainWindow::HandleMenu(Int_t id){
///========================= File Open ///========================= File Open
case M_FILE_OPEN:{ case M_FILE_OPEN:{
configEditor = new TGTextEditor("Pixie16.config", gClient->GetRoot(), 1200);
}break; }break;
///========================= Exit ///========================= Exit
@ -303,6 +315,24 @@ void MainWindow::HandleMenu(Int_t id){
}break; }break;
///====================== Show channel rate;
case M_SHOW_CHANNELS_RATE:{
int modID = modIDEntry->GetNumber();
fEcanvas->GetCanvas()->cd();
hChannel[modID]->Draw();
fEcanvas->GetCanvas()->Update();
}break;
///====================== Fit Gaussian
case M_FINDPEAKS:{
LogMsg("[Find Peaks] Not impelmented");
}break;
} }
} }
@ -326,6 +356,7 @@ void MainWindow::GetADCTrace() {
} }
gTrace->GetXaxis()->SetTitle("time [us]"); gTrace->GetXaxis()->SetTitle("time [us]");
gTrace->GetXaxis()->SetRangeUser(0, pixie->GetADCTraceLength()*dt); gTrace->GetXaxis()->SetRangeUser(0, pixie->GetADCTraceLength()*dt);
gTrace->SetTitle(Form("Trace mod:%d ch:%0d", modID, ch));
fEcanvas->GetCanvas()->cd(); fEcanvas->GetCanvas()->cd();
gTrace->Draw("APL"); gTrace->Draw("APL");
@ -351,6 +382,7 @@ void MainWindow::GetBaseLine(){
gTrace->SetPoint(i, baselineTime[i]*1000, baseline[i]); gTrace->SetPoint(i, baselineTime[i]*1000, baseline[i]);
} }
gTrace->GetXaxis()->SetTitle("time [ns]"); gTrace->GetXaxis()->SetTitle("time [ns]");
gTrace->SetTitle(Form("Baseline mod:%d ch:%0d", modID, ch));
fEcanvas->GetCanvas()->cd(); fEcanvas->GetCanvas()->cd();
gTrace->Draw("APL"); gTrace->Draw("APL");
@ -699,6 +731,7 @@ void * MainWindow::FillHistogram(void *ptr){
for( unsigned int i = 0; i < nData; i++){ for( unsigned int i = 0; i < nData; i++){
///printf("%3u| %2u, %3u, %7u, %llu \n", i, mods[i], channels[i], energies[i], timestamps[i]); ///printf("%3u| %2u, %3u, %7u, %llu \n", i, mods[i], channels[i], energies[i], timestamps[i]);
hEnergy[mods[i]][channels[i]]->Fill(energies[i]); hEnergy[mods[i]][channels[i]]->Fill(energies[i]);
hChannel[mods[i]]->Fill(channels[i]);
} }
isEnergyHistFilled = true; isEnergyHistFilled = true;
pixie->SetFIFOisUsed(true); pixie->SetFIFOisUsed(true);

View File

@ -10,6 +10,7 @@
#include <TH1F.h> #include <TH1F.h>
#include <TGraph.h> #include <TGraph.h>
#include <TBenchmark.h> #include <TBenchmark.h>
#include <TGTextEditor.h>
#include "Pixie16Class.h" #include "Pixie16Class.h"
#include "global_macro.h" #include "global_macro.h"
@ -30,7 +31,7 @@ private:
static TRootEmbeddedCanvas *fEcanvas; static TRootEmbeddedCanvas *fEcanvas;
TGMenuBar *fMenuBar; TGMenuBar *fMenuBar;
TGPopupMenu *fMenuFile, *fMenuSettings; TGPopupMenu *fMenuFile, *fMenuSettings, *fMenuUtility;
static TGNumberEntry * modIDEntry, *chEntry; static TGNumberEntry * modIDEntry, *chEntry;
@ -55,9 +56,12 @@ private:
TThread * fillHistThread; TThread * fillHistThread;
static TH1F * hEnergy[MAXMOD][MAXCH]; static TH1F * hEnergy[MAXMOD][MAXCH];
static TH1F * hChannel[MAXMOD];
static bool isEnergyHistFilled; static bool isEnergyHistFilled;
TGraph * gTrace; TGraph * gTrace;
TGTextEditor * configEditor;
public: public:

View File

@ -35,6 +35,7 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16
modIDEntry->SetWidth(50); modIDEntry->SetWidth(50);
modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1); modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1);
modIDEntry->Connect("Modified()", "SettingsSummary", this, "ChangeMod()"); modIDEntry->Connect("Modified()", "SettingsSummary", this, "ChangeMod()");
if( pixie->GetNumModule() == 1 ) modIDEntry->SetState(false);
hframe->AddFrame(modIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); hframe->AddFrame(modIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4));
TGLabel * lb2 = new TGLabel(hframe, "Setting File :"); TGLabel * lb2 = new TGLabel(hframe, "Setting File :");

View File

@ -1016,7 +1016,7 @@
"ChanNum": 0, "ChanNum": 0,
"CoincPattern": 0, "CoincPattern": 0,
"CoincWait": 0, "CoincWait": 0,
"ControlTask": 5, "ControlTask": 23,
"CrateID": 0, "CrateID": 0,
"FIFOLength": 8188, "FIFOLength": 8188,
"FastFilterRange": 0, "FastFilterRange": 0,