249 lines
6.9 KiB
C++
249 lines
6.9 KiB
C++
#include <TApplication.h>
|
|
#include <TGClient.h>
|
|
#include <TCanvas.h>
|
|
#include <TF1.h>
|
|
#include <TRandom.h>
|
|
#include <TGButton.h>
|
|
#include <TRootEmbeddedCanvas.h>
|
|
#include <TGMenu.h>
|
|
#include <TGLabel.h>
|
|
#include <TGNumberEntry.h>
|
|
#include <TGraph.h>
|
|
#include <TAxis.h>
|
|
#include <TF1.h>
|
|
#include <unistd.h>
|
|
#include <ctime>
|
|
#include "DigitizerPHA.h"
|
|
#include "DigitizerPSD.h"
|
|
#include "FSUDAQ.h"
|
|
enum MenuIdentifiers{
|
|
|
|
M_FILE_OPEN,
|
|
M_EXIT,
|
|
M_CH_SETTINGS_SUMMARY,
|
|
M_CH_SETTING,
|
|
M_MODULE_SETTINGS,
|
|
M_PROGRAM_SETTINGS,
|
|
M_FINDPEAKS,
|
|
M_SHOW_CHANNELS_RATE
|
|
|
|
};
|
|
//TODO timed Run, //pixie->SetDigitizerPresetRunTime(100000, 0);
|
|
///make static members
|
|
DigitizerPHA * MainWindow::digi = NULL;
|
|
TGTextEdit * MainWindow::teLog = NULL;
|
|
TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL;
|
|
MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
|
|
|
digi = new DigitizerPHA(0,0);
|
|
|
|
/// Create a main frame
|
|
fMain = new TGMainFrame(p,w,h);
|
|
///fMain->SetWMPosition(500, 500); //does not work
|
|
fMain->Connect("CloseWindow()", "MainWindow", this, "GoodBye()");
|
|
///======================= menu
|
|
fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame);
|
|
fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
|
|
fMenuFile = new TGPopupMenu(gClient->GetRoot());
|
|
fMenuFile->AddEntry("&Open Pixie16.config", M_FILE_OPEN);
|
|
fMenuFile->AddSeparator();
|
|
fMenuFile->AddEntry("E&xit", M_EXIT);
|
|
fMenuFile->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
|
|
fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
|
|
|
|
fMenuSettings = new TGPopupMenu(gClient->GetRoot());
|
|
fMenuSettings->AddEntry("&Settings Summary", M_CH_SETTINGS_SUMMARY);
|
|
fMenuSettings->AddEntry("&Channel Setting", M_CH_SETTING);
|
|
fMenuSettings->AddSeparator();
|
|
fMenuSettings->AddEntry("&Digitizer Settings", M_MODULE_SETTINGS);
|
|
fMenuSettings->AddSeparator();
|
|
fMenuSettings->AddEntry("Program Settings", M_PROGRAM_SETTINGS);
|
|
fMenuSettings->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
|
|
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
|
|
/// Create a horizontal frame widget with buttons
|
|
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,200,40);
|
|
fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
|
|
|
|
///================= signal Channel group
|
|
TGGroupFrame * group1 = new TGGroupFrame(hframe, "Single Channel", kHorizontalFrame);
|
|
hframe->AddFrame(group1 );
|
|
|
|
TGHorizontalFrame *hframe1 = new TGHorizontalFrame(group1,200,30);
|
|
group1->AddFrame(hframe1 );
|
|
|
|
///================= Create canvas widget
|
|
fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,900,400);
|
|
fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,10));
|
|
///================= Log massage
|
|
TGGroupFrame * groupLog = new TGGroupFrame(fMain, "Log Message", kHorizontalFrame);
|
|
fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsCenterX, 5,5,0,5) );
|
|
|
|
teLog = new TGTextEdit(groupLog, w, 100);
|
|
groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsNormal, 0,0,10,0));
|
|
/// Set a name to the main frame
|
|
fMain->SetWindowName("Pixie16 DAQ");
|
|
/// Map all subwindows of main frame
|
|
fMain->MapSubwindows();
|
|
/// Initialize the layout algorithm
|
|
fMain->Resize(fMain->GetDefaultSize());
|
|
fMain->SetWMPosition(200, 200); //does not work??
|
|
|
|
/// Map main frame
|
|
fMain->MapWindow();
|
|
|
|
/// setup thread
|
|
//saveDataThread = new TThread("hahaha", SaveData, (void *) 1);
|
|
//fillHistThread = new TThread("kakaka", FillHistogram, (void *) 1);
|
|
|
|
///settingsSummary = NULL;
|
|
///moduleSetting = NULL;
|
|
///channelSetting = NULL;
|
|
///scalarPanel = NULL;
|
|
|
|
///bStopRun->SetEnabled(false);
|
|
|
|
LogMsg("Boot OK and ready to run.");
|
|
|
|
///HandleMenu(M_CH_SETTINGS_SUMMARY);
|
|
|
|
}
|
|
MainWindow::~MainWindow() {
|
|
delete fMenuBar;
|
|
delete fMenuFile;
|
|
delete fMenuSettings;
|
|
delete fMenuUtility;
|
|
|
|
//delete modIDEntry;
|
|
//delete chEntry;
|
|
//delete tePath;
|
|
delete teLog;
|
|
|
|
//delete bStartRun;
|
|
//delete bStopRun;
|
|
//delete bFitTrace;
|
|
|
|
delete digi;
|
|
|
|
//delete settingsSummary;
|
|
//delete moduleSetting;
|
|
//delete channelSetting;
|
|
//delete scalarPanel;
|
|
//
|
|
//delete saveDataThread;
|
|
//delete fillHistThread;
|
|
//
|
|
//delete gTrace;
|
|
//
|
|
//delete configEditor;
|
|
|
|
/// Clean up used widgets: frames, buttons, layout hints
|
|
fMain->Cleanup();
|
|
delete fMain;
|
|
}
|
|
void MainWindow::HandleMenu(Int_t id){
|
|
switch(id){
|
|
|
|
///========================= File Open
|
|
case M_FILE_OPEN:{
|
|
|
|
|
|
}break;
|
|
|
|
///========================= Exit
|
|
case M_EXIT: GoodBye(); break;
|
|
|
|
///========================= Channel setting summary
|
|
case M_CH_SETTINGS_SUMMARY: {
|
|
|
|
}break;
|
|
|
|
case M_CH_SETTING:{
|
|
|
|
}break;
|
|
|
|
///========================= Module setting
|
|
case M_MODULE_SETTINGS:{
|
|
|
|
}break;
|
|
///========================= Program setting
|
|
case M_PROGRAM_SETTINGS:{
|
|
LogMsg("[Program settings] Not impelmented");
|
|
}break;
|
|
|
|
///====================== Show channel rate;
|
|
case M_SHOW_CHANNELS_RATE:{
|
|
|
|
}break;
|
|
|
|
|
|
///====================== Fit Gaussian
|
|
case M_FINDPEAKS:{
|
|
|
|
LogMsg("[Find Peaks] Not impelmented");
|
|
|
|
}break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Double_t standardPulse(Double_t *x, Double_t * par){
|
|
|
|
/// par[0] = start time
|
|
/// par[1] = rise time
|
|
/// par[2] = decay time
|
|
/// par[3] = amplitude
|
|
/// par[4] = baseline
|
|
|
|
Double_t z = x[0] - par[0];
|
|
|
|
if( z <= 0 ) {
|
|
return par[4];
|
|
}else{
|
|
return par[3]*(1-TMath::Exp(-1*z/par[1]))*TMath::Exp(-1*z/par[2]) + par[4];
|
|
}
|
|
}
|
|
|
|
void MainWindow::GoodBye(){
|
|
|
|
//pixie->CloseDigitizers();
|
|
|
|
printf("----- bye bye ---- \n");
|
|
|
|
gApplication->Terminate(0);
|
|
|
|
}
|
|
|
|
void MainWindow::LogMsg(TString msg){
|
|
|
|
time_t now = time(0);
|
|
tm * ltm = localtime(&now);
|
|
int year = 1900 + ltm->tm_year;
|
|
int month = 1 + ltm->tm_mon;
|
|
int day = ltm->tm_mday;
|
|
int hour = ltm->tm_hour;
|
|
int minute = ltm->tm_min;
|
|
int secound = ltm->tm_sec;
|
|
|
|
teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] ", year, month, day, hour, minute, secound) + msg);
|
|
teLog->LineDown();
|
|
teLog->ShowBottom();
|
|
}
|
|
|
|
//############################################
|
|
int main(int argc, char **argv) {
|
|
printf(" Welcome to pixie16 DQ \n");
|
|
|
|
TApplication theApp("App",&argc,argv);
|
|
new MainWindow(gClient->GetRoot(),800,800);
|
|
theApp.Run();
|
|
return 0;
|
|
}
|