Added progress callback system to avoid infecting evb with gui components. Switched in ROOT made file gui where possible, reorganzied main window to be prettier

This commit is contained in:
Gordon McCann 2021-12-16 17:38:58 -05:00
parent bd9e2cb520
commit 8c6278217c
11 changed files with 272 additions and 258 deletions

View File

@ -11,6 +11,7 @@
#include <TGTextViewStream.h>
#include <TGProgressBar.h>
#include <TTimer.h>
#include <TGFileDialog.h>
#include <TGComboBox.h>
#include "../evb/EVBApp.h"
@ -46,6 +47,7 @@ public:
void RunMerge(const char* dir, const char* file);
void DisableAllInput();
void EnableAllInput();
void SetProgressBarPosition(long value, long total);
enum WidgetId
@ -94,6 +96,8 @@ private:
TGPopupMenu *fFileMenu;
TGFileInfo* fInfo;
EventBuilder::EVBApp fBuilder;
int counter;

View File

@ -19,13 +19,12 @@
namespace EventBuilder {
CompassRun::CompassRun() :
m_directory(""), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_pb(nullptr)
m_directory(""), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_progressFraction(0.1)
{
}
CompassRun::CompassRun(const std::string& dir) :
m_directory(dir), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_pb(nullptr)
m_directory(dir), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_progressFraction(0.1)
{
}
@ -186,12 +185,7 @@ namespace EventBuilder {
return;
}
unsigned int count = 0, flush = m_totalHits*0.1, flush_count = 0;
if(m_pb)
{
flush = m_totalHits*0.01;
SetProgressBar();
}
unsigned int count = 0, flush = m_totalHits*m_progressFraction, flush_count = 0;
startIndex = 0; //Reset the startIndex
if(flush == 0)
@ -201,18 +195,9 @@ namespace EventBuilder {
count++;
if(count == flush)
{ //Progress Log
if(m_pb)
{
m_pb->Increment(count);
gSystem->ProcessEvents();
count=0;
}
else
{
count = 0;
flush_count++;
EVB_INFO("Percent of run built: {0} %",flush_count*10);
}
count = 0;
flush_count++;
m_progressCallback(flush_count*flush, m_totalHits);
}
if(!GetHitsFromFiles())
@ -248,12 +233,7 @@ namespace EventBuilder {
return;
}
unsigned int count = 0, flush = m_totalHits*0.1, flush_count = 0;
if(m_pb)
{
flush = m_totalHits*0.01;
SetProgressBar();
}
unsigned int count = 0, flush = m_totalHits*m_progressFraction, flush_count = 0;
startIndex = 0;
SlowSort coincidizer(window, mapfile);
@ -265,18 +245,9 @@ namespace EventBuilder {
count++;
if(count == flush)
{
if(m_pb)
{
m_pb->Increment(count);
gSystem->ProcessEvents();
count=0;
}
else
{
count = 0;
flush_count++;
EVB_INFO("Percent of run built: {0} %",flush_count*10);
}
count = 0;
flush_count++;
m_progressCallback(count, m_totalHits);
}
if(!GetHitsFromFiles())
@ -324,12 +295,7 @@ namespace EventBuilder {
return;
}
unsigned int count = 0, flush = m_totalHits*0.1, flush_count = 0;
if(m_pb)
{
flush = m_totalHits*0.01;
SetProgressBar();
}
unsigned int count = 0, flush = m_totalHits*m_progressFraction, flush_count = 0;
startIndex = 0;
CoincEvent this_event;
@ -347,18 +313,9 @@ namespace EventBuilder {
count++;
if(count == flush)
{
if(m_pb)
{
m_pb->Increment(count);
gSystem->ProcessEvents();
count=0;
}
else
{
count = 0;
flush_count++;
EVB_INFO("Percent of run built: {0} %",flush_count*10);
}
count = 0;
flush_count++;
m_progressCallback(count, m_totalHits);
}
if(!GetHitsFromFiles())
@ -419,12 +376,7 @@ namespace EventBuilder {
return;
}
unsigned int count = 0, flush = m_totalHits*0.1, flush_count = 0;
if(m_pb)
{
flush = m_totalHits*0.01;
SetProgressBar();
}
unsigned int count = 0, flush = m_totalHits*m_progressFraction, flush_count = 0;
startIndex = 0;
CoincEvent this_event;
@ -451,18 +403,9 @@ namespace EventBuilder {
count++;
if(count == flush)
{
if(m_pb)
{
m_pb->Increment(count);
gSystem->ProcessEvents();
count=0;
}
else
{
count = 0;
flush_count++;
EVB_INFO("Percent of run built: {0} %",flush_count*10);
}
count = 0;
flush_count++;
m_progressCallback(count, m_totalHits);
}
if(!GetHitsFromFiles())
@ -521,12 +464,7 @@ namespace EventBuilder {
return;
}
unsigned int count = 0, flush = m_totalHits*0.1, flush_count = 0;
if(m_pb)
{
flush = m_totalHits*0.01;
SetProgressBar();
}
unsigned int count = 0, flush = m_totalHits*m_progressFraction, flush_count = 0;
startIndex = 0;
CoincEvent this_event;
@ -557,18 +495,9 @@ namespace EventBuilder {
count++;
if(count == flush)
{
if(m_pb)
{
m_pb->Increment(count);
gSystem->ProcessEvents();
count=0;
}
else
{
count = 0;
flush_count++;
EVB_INFO("Percent of run built: {0} %",flush_count*10);
}
count = 0;
flush_count++;
m_progressCallback(flush_count*flush, m_totalHits);
}
if(!GetHitsFromFiles())
@ -610,13 +539,4 @@ namespace EventBuilder {
analyzer.ClearHashTable();
output->Close();
}
void CompassRun::SetProgressBar()
{
m_pb->SetMax(m_totalHits);
m_pb->SetMin(0);
m_pb->SetPosition(0);
gSystem->ProcessEvents();
}
}

View File

@ -14,9 +14,8 @@
#include "DataStructs.h"
#include "RunCollector.h"
#include "ShiftMap.h"
#include "ProgressCallback.h"
#include <TParameter.h>
#include <TGProgressBar.h>
#include <TSystem.h>
namespace EventBuilder {
@ -39,14 +38,14 @@ namespace EventBuilder {
void Convert2FastAnalyzedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window,
int zt, int at, int zp, int ap, int ze, int ae, double bke, double b, double theta);
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
inline void SetProgressCallbackFunc(const ProgressCallbackFunc& function) { m_progressCallback = function; }
inline void SetProgressFraction(double frac) { m_progressFraction = frac; }
private:
bool GetBinaryFiles();
bool GetHitsFromFiles();
void SetScalers();
void ReadScalerData(const std::string& filename);
void SetProgressBar();
std::string m_directory, m_scalerinput;
std::vector<CompassFile> m_datafiles;
@ -66,8 +65,8 @@ namespace EventBuilder {
//Scaler switch
bool m_scaler_flag;
//GUI progress bar, if attached
TGProgressBar* m_pb;
ProgressCallbackFunc m_progressCallback;
double m_progressFraction;
};
}

View File

@ -19,15 +19,21 @@ namespace EventBuilder {
EVBApp::EVBApp() :
m_rmin(0), m_rmax(0), m_ZT(0), m_AT(0), m_ZP(0), m_AP(0), m_ZE(0), m_AE(0), m_ZR(0), m_AR(0),
m_B(0), m_Theta(0), m_BKE(0), m_workspace("none"), m_mapfile("none"), m_shiftfile("none"),
m_cutList("none"), m_SlowWindow(0), m_FastWindowIonCh(0), m_FastWindowSABRE(0), m_pb(nullptr)
{
m_B(0), m_Theta(0), m_BKE(0), m_progressFraction(0.1), m_workspace("none"), m_mapfile("none"), m_shiftfile("none"),
m_cutList("none"), m_SlowWindow(0), m_FastWindowIonCh(0), m_FastWindowSABRE(0) {
SetProgressCallbackFunc(BIND_PROGRESS_CALLBACK_FUNCTION(EVBApp::DefaultProgressCallback));
}
EVBApp::~EVBApp()
{
}
void EVBApp::DefaultProgressCallback(long curVal, long totalVal)
{
double fraction = curVal/totalVal;
EVB_INFO("Percent of run built: {0}", fraction*100);
}
bool EVBApp::ReadConfigFile(const std::string& fullpath)
{
EVB_INFO("Reading in EVB configuration from file {0}...", fullpath);
@ -123,12 +129,12 @@ namespace EventBuilder {
std::string analyze_dir = m_workspace+"/analyzed/";
std::string plot_file = m_workspace+"/histograms/run_"+std::to_string(m_rmin)+"_"+std::to_string(m_rmax)+".root";
SFPPlotter grammer;
grammer.SetProgressCallbackFunc(m_progressCallback);
grammer.SetProgressFraction(m_progressFraction);
grammer.ApplyCutlist(m_cutList);
EVB_INFO("Generating histograms from analyzed runs [{0}, {1}] with Cut List {2}...", m_rmin, m_rmax, m_cutList);
EVB_INFO("Output file will be named {0}",plot_file);
if(m_pb)
grammer.AttachProgressBar(m_pb);
grabber.SetSearchParams(analyze_dir, "", ".root", m_rmin, m_rmax);
if(grabber.GrabFilesInRange())
{
@ -157,8 +163,8 @@ namespace EventBuilder {
CompassRun converter(unpack_dir);
converter.SetShiftMap(m_shiftfile);
converter.SetScalerInput(m_scalerfile);
if(m_pb)
converter.AttachProgressBar(m_pb);
converter.SetProgressCallbackFunc(m_progressCallback);
converter.SetProgressFraction(m_progressFraction);
EVB_INFO("Beginning conversion...");
for(int i=m_rmin; i<=m_rmax; i++)
@ -214,8 +220,8 @@ namespace EventBuilder {
CompassRun converter(unpack_dir);
converter.SetShiftMap(m_shiftfile);
converter.SetScalerInput(m_scalerfile);
if(m_pb)
converter.AttachProgressBar(m_pb);
converter.SetProgressCallbackFunc(m_progressCallback);
converter.SetProgressFraction(m_progressFraction);
EVB_INFO("Beginning conversion...");
@ -258,8 +264,8 @@ namespace EventBuilder {
CompassRun converter(unpack_dir);
converter.SetShiftMap(m_shiftfile);
converter.SetScalerInput(m_scalerfile);
if(m_pb)
converter.AttachProgressBar(m_pb);
converter.SetProgressCallbackFunc(m_progressCallback);
converter.SetProgressFraction(m_progressFraction);
EVB_INFO("Beginning conversion...");
int count=0;
@ -301,8 +307,8 @@ namespace EventBuilder {
CompassRun converter(unpack_dir);
converter.SetShiftMap(m_shiftfile);
converter.SetScalerInput(m_scalerfile);
if(m_pb)
converter.AttachProgressBar(m_pb);
converter.SetProgressCallbackFunc(m_progressCallback);
converter.SetProgressFraction(m_progressFraction);
EVB_INFO("Beginning conversion...");
int count=0;
@ -345,8 +351,8 @@ namespace EventBuilder {
CompassRun converter(unpack_dir);
converter.SetShiftMap(m_shiftfile);
converter.SetScalerInput(m_scalerfile);
if(m_pb)
converter.AttachProgressBar(m_pb);
converter.SetProgressCallbackFunc(m_progressCallback);
converter.SetProgressFraction(m_progressFraction);
EVB_INFO("Beginning conversion...");
int count=0;
@ -393,14 +399,14 @@ namespace EventBuilder {
}
void EVBApp::SetRunRange(int rmin, int rmax) { EVB_TRACE("Min Run, max run set to [{0}, {1}]", rmin, rmax); m_rmin = rmin; m_rmax = rmax; }
void EVBApp::SetWorkDirectory(const std::string& fullpath) { EVB_TRACE("Workspace set to {0}", fullpath); m_workspace = fullpath; }
void EVBApp::SetChannelMap(const std::string& name) { EVB_TRACE("Channel map set to {0}",name); m_mapfile = name; }
void EVBApp::SetBoardShiftFile(const std::string& name) { EVB_TRACE("Shift file set to {0}", name); m_shiftfile = name; }
void EVBApp::SetSlowCoincidenceWindow(double window) { EVB_TRACE("Slow Coincidence Window set to {0}",window); m_SlowWindow = window; }
void EVBApp::SetFastWindowIonChamber(double window) { EVB_TRACE("Fast Coinc. Window Ion Ch. set to {0}",window); m_FastWindowIonCh = window; }
void EVBApp::SetFastWindowSABRE(double window) { EVB_TRACE("Fast Coinc. Window SABRE set to {0}",window); m_FastWindowSABRE = window; }
void EVBApp::SetCutList(const std::string& name) { EVB_TRACE("Cut List set to {0}", name); m_cutList = name; }
void EVBApp::SetScalerFile(const std::string& fullpath) { EVB_TRACE("Scaler file set to {0}", fullpath); m_scalerfile = fullpath; }
void EVBApp::SetRunRange(int rmin, int rmax) { EVB_TRACE("Min Run, max run set to [{0}, {1}]", rmin, rmax); m_rmin = rmin; m_rmax = rmax; }
void EVBApp::SetWorkDirectory(const std::string& fullpath) { EVB_TRACE("Workspace set to {0}", fullpath); m_workspace = fullpath; }
void EVBApp::SetChannelMap(const std::string& name) { EVB_TRACE("Channel map set to {0}",name); m_mapfile = name; }
void EVBApp::SetBoardShiftFile(const std::string& name) { EVB_TRACE("Shift file set to {0}", name); m_shiftfile = name; }
void EVBApp::SetSlowCoincidenceWindow(double window) { EVB_TRACE("Slow Coincidence Window set to {0}",window); m_SlowWindow = window; }
void EVBApp::SetFastWindowIonChamber(double window) { EVB_TRACE("Fast Coinc. Window Ion Ch. set to {0}",window); m_FastWindowIonCh = window; }
void EVBApp::SetFastWindowSABRE(double window) { EVB_TRACE("Fast Coinc. Window SABRE set to {0}",window); m_FastWindowSABRE = window; }
void EVBApp::SetCutList(const std::string& name) { EVB_TRACE("Cut List set to {0}", name); m_cutList = name; }
void EVBApp::SetScalerFile(const std::string& fullpath) { EVB_TRACE("Scaler file set to {0}", fullpath); m_scalerfile = fullpath; }
}

View File

@ -10,12 +10,13 @@
#define EVBAPP_H
#include "RunCollector.h"
#include <TGProgressBar.h>
#include "ProgressCallback.h"
namespace EventBuilder {
class EVBApp {
public:
EVBApp();
~EVBApp();
@ -62,8 +63,10 @@ namespace EventBuilder {
inline std::string GetBoardShiftFile() const { return m_shiftfile; }
inline std::string GetCutList() const { return m_cutList; }
inline std::string GetScalerFile() const { return m_scalerfile; }
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
void DefaultProgressCallback(long curVal, long totalVal);
inline void SetProgressCallbackFunc(const ProgressCallbackFunc& function) { m_progressCallback = function; }
inline void SetProgressFraction(double frac) { m_progressFraction = frac; }
enum Operation
{
@ -81,6 +84,7 @@ namespace EventBuilder {
int m_rmin, m_rmax;
int m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_ZR, m_AR;
double m_B, m_Theta, m_BKE;
double m_progressFraction;
std::string m_workspace;
std::string m_mapfile, m_shiftfile;
@ -92,8 +96,8 @@ namespace EventBuilder {
double m_FastWindowSABRE;
RunCollector grabber;
TGProgressBar* m_pb;
ProgressCallbackFunc m_progressCallback;
};

View File

@ -0,0 +1,14 @@
#ifndef PROGRESSCALLBACK_H
#define PROGRESSCALLBACK_H
#include <functional>
#define BIND_PROGRESS_CALLBACK_FUNCTION(func) std::bind(&func, this, std::placeholders::_1, std::placeholders::_2)
namespace EventBuilder {
using ProgressCallbackFunc = std::function<void(long, long)>;
}
#endif

View File

@ -12,10 +12,9 @@
namespace EventBuilder {
/*Generates storage and initializes pointers*/
SFPPlotter::SFPPlotter()
SFPPlotter::SFPPlotter() :
event_address(new ProcessedEvent()), m_progressFraction(0.1)
{
event_address = new ProcessedEvent();
m_pb = nullptr;
}
SFPPlotter::~SFPPlotter()
@ -248,12 +247,7 @@ namespace EventBuilder {
THashTable* table = new THashTable();
long blentries = chain->GetEntries();
long count=0, flush_val=blentries*0.1, flush_count=0;
if(m_pb)
{
flush_val = blentries*0.01;
SetProgressBar(blentries);
}
long count=0, flush_val=blentries*m_progressFraction, flush_count=0;
for(long i=0; i<chain->GetEntries(); i++)
@ -261,15 +255,9 @@ namespace EventBuilder {
count++;
if(count == flush_val)
{
if(m_pb) {
m_pb->Increment(count);
gSystem->ProcessEvents();
count = 0;
} else {
flush_count++;
count=0;
EVB_INFO("Percent of data processed: {0} %",flush_count*10);
}
flush_count++;
count=0;
m_progressCallback(flush_count*flush_val, blentries);
}
chain->GetEntry(i);
MakeUncutHistograms(*event_address, table);
@ -287,14 +275,5 @@ namespace EventBuilder {
outfile->Close();
delete outfile;
}
void SFPPlotter::SetProgressBar(long total)
{
m_pb->SetMax(total);
m_pb->SetMin(0);
m_pb->SetPosition(0);
gSystem->ProcessEvents();
}
}

View File

@ -10,8 +10,8 @@
#define SFPCLEANER_H
#include "DataStructs.h"
#include "ProgressCallback.h"
#include "CutHandler.h"
#include <TGProgressBar.h>
namespace EventBuilder {
@ -20,12 +20,12 @@ namespace EventBuilder {
public:
SFPPlotter();
~SFPPlotter();
inline void AttachProgressBar(TGProgressBar* pb) { m_pb = pb; }
inline void ApplyCutlist(const std::string& listname) { cutter.SetCuts(listname); }
void Run(const std::vector<std::string>& files, const std::string& output);
inline void SetProgressCallbackFunc(const ProgressCallbackFunc& function) { m_progressCallback = function; }
inline void SetProgressFraction(double frac) { m_progressFraction = frac; }
private:
void SetProgressBar(long total);
void Chain(const std::vector<std::string>& files); //Form TChain
void MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table);
void MakeCutHistograms(const ProcessedEvent& ev, THashTable* table);
@ -40,7 +40,8 @@ namespace EventBuilder {
/*Cuts*/
CutHandler cutter;
TGProgressBar* m_pb; //GUI progress
ProgressCallbackFunc m_progressCallback;
double m_progressFraction;
};

View File

@ -11,6 +11,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
SetCleanup(kDeepCleanup);
MAIN_W = w; MAIN_H = h;
fInfo = new TGFileInfo();
//Organization hints
TGLayoutHints *fchints = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,5,5,5,5);
TGLayoutHints *fhints = new TGLayoutHints(kLHintsExpandX|kLHintsCenterY,5,5,5,5);
@ -21,11 +22,10 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
//Make the containers and link up all signals/slots
TGVerticalFrame *InputFrame = new TGVerticalFrame(this, w, h*0.9);
TGGroupFrame* pathGroup = new TGGroupFrame(this, "Working Paths");
TGVerticalFrame *NameFrame = new TGVerticalFrame(pathGroup, w, h*0.3);
TGVerticalFrame *NameFrame = new TGVerticalFrame(InputFrame, w, h*0.4);
TGHorizontalFrame *WorkFrame = new TGHorizontalFrame(NameFrame, w, h*0.1);
TGHorizontalFrame *WorkFrame = new TGHorizontalFrame(NameFrame, w, h*0.06);
TGLabel* workLabel = new TGLabel(WorkFrame, "Workspace Directory:");
fWorkField = new TGTextEntry(WorkFrame, new TGTextBuffer(120), WorkDir);
fWorkField->Resize(w*0.25, fWorkField->GetDefaultHeight());
@ -36,7 +36,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
WorkFrame->AddFrame(fWorkField, fhints);
WorkFrame->AddFrame(fOpenWorkButton, bhints);
TGHorizontalFrame *CMapFrame = new TGHorizontalFrame(NameFrame, w, h*0.1);
TGHorizontalFrame *CMapFrame = new TGHorizontalFrame(NameFrame, w, h*0.06);
TGLabel* cmaplabel = new TGLabel(CMapFrame, "Channel Map File:");
fCMapField = new TGTextEntry(CMapFrame, new TGTextBuffer(120), Cmap);
fCMapField->Resize(w*0.25, fCMapField->GetDefaultHeight());
@ -47,7 +47,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
CMapFrame->AddFrame(fCMapField, fhints);
CMapFrame->AddFrame(fOpenCMapButton, bhints);
TGHorizontalFrame *SMapFrame = new TGHorizontalFrame(NameFrame, w, h*0.1);
TGHorizontalFrame *SMapFrame = new TGHorizontalFrame(NameFrame, w, h*0.06);
TGLabel* smaplabel = new TGLabel(SMapFrame, "Board Shift File:");
fSMapField = new TGTextEntry(SMapFrame, new TGTextBuffer(120), Smap);
fSMapField->Resize(w*0.25, fSMapField->GetDefaultHeight());
@ -58,7 +58,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
SMapFrame->AddFrame(fSMapField, fhints);
SMapFrame->AddFrame(fOpenSMapButton, bhints);
TGHorizontalFrame *ScalerFrame = new TGHorizontalFrame(NameFrame, w, h*0.1);
TGHorizontalFrame *ScalerFrame = new TGHorizontalFrame(NameFrame, w, h*0.06);
TGLabel* sclabel = new TGLabel(ScalerFrame, "Scaler File: ");
fScalerField = new TGTextEntry(ScalerFrame, new TGTextBuffer(120), Scaler);
fScalerField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateScaler()");
@ -68,7 +68,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
ScalerFrame->AddFrame(fScalerField, fhints);
ScalerFrame->AddFrame(fOpenScalerButton, bhints);
TGHorizontalFrame *CutFrame = new TGHorizontalFrame(NameFrame, w, h*0.1);
TGHorizontalFrame *CutFrame = new TGHorizontalFrame(NameFrame, w, h*0.06);
TGLabel* clabel = new TGLabel(CutFrame, "Cut List: ");
fCutField = new TGTextEntry(CutFrame, new TGTextBuffer(120), Cut);
fCutField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateCut()");
@ -84,62 +84,108 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
NameFrame->AddFrame(ScalerFrame, fhints);
NameFrame->AddFrame(CutFrame, fhints);
pathGroup->AddFrame(NameFrame, fhints);
TGHorizontalFrame *ParamFrame = new TGHorizontalFrame(InputFrame, w, h*0.1);
TGLabel *bkelabel = new TGLabel(ParamFrame, "Beam KE (MeV):");
fBKEField = new TGNumberEntryField(ParamFrame, Bke, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative);
TGLabel *bfieldlabel = new TGLabel(ParamFrame, "B-Field (G):");
fBField = new TGNumberEntryField(ParamFrame, BField, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative);
TGLabel *thetalabel = new TGLabel(ParamFrame, "Angle (deg):");
fThetaField = new TGNumberEntryField(ParamFrame, Theta, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative);
TGLabel *ztlabel = new TGLabel(ParamFrame, "ZT:");
fZTField = new TGNumberEntryField(ParamFrame, ZT, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
TGLabel *atlabel = new TGLabel(ParamFrame, "AT:");
fATField = new TGNumberEntryField(ParamFrame, AT, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
TGLabel *zplabel = new TGLabel(ParamFrame, "ZP:");
fZPField = new TGNumberEntryField(ParamFrame, ZP, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
TGLabel *aplabel = new TGLabel(ParamFrame, "AP:");
fAPField = new TGNumberEntryField(ParamFrame, AP, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
TGLabel *zelabel = new TGLabel(ParamFrame, "ZE:");
fZEField = new TGNumberEntryField(ParamFrame, ZE, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
TGLabel *aelabel = new TGLabel(ParamFrame, "AE:");
fAEField = new TGNumberEntryField(ParamFrame, AE, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
ParamFrame->AddFrame(bkelabel, lhints);
ParamFrame->AddFrame(fBKEField, fhints);
ParamFrame->AddFrame(bfieldlabel, lhints);
ParamFrame->AddFrame(fBField, fhints);
ParamFrame->AddFrame(thetalabel, lhints);
ParamFrame->AddFrame(fThetaField, fhints);
ParamFrame->AddFrame(ztlabel, lhints);
ParamFrame->AddFrame(fZTField, fhints);
ParamFrame->AddFrame(atlabel, lhints);
ParamFrame->AddFrame(fATField, fhints);
ParamFrame->AddFrame(zplabel, lhints);
ParamFrame->AddFrame(fZPField, fhints);
ParamFrame->AddFrame(aplabel, lhints);
ParamFrame->AddFrame(fAPField, fhints);
ParamFrame->AddFrame(zelabel, lhints);
ParamFrame->AddFrame(fZEField, fhints);
ParamFrame->AddFrame(aelabel, lhints);
ParamFrame->AddFrame(fAEField, fhints);
TGHorizontalFrame *WindowFrame = new TGHorizontalFrame(InputFrame, w, h*0.1);
TGLabel *slowlabel = new TGLabel(WindowFrame, "Slow Coincidence Window (ps):");
fSlowWindowField = new TGNumberEntryField(WindowFrame, SlowWind, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
TGLabel *fasticlabel = new TGLabel(WindowFrame, "Fast Coincidence Window IC (ps):");
fFastICField = new TGNumberEntryField(WindowFrame, FastWind_IC, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
TGLabel *fastsabrelabel = new TGLabel(WindowFrame, "Fast Coincidence Window SABRE (ps):");
fFastSABREField = new TGNumberEntryField(WindowFrame, FastWind_Sabre, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
WindowFrame->AddFrame(slowlabel, lhints);
WindowFrame->AddFrame(fSlowWindowField, fhints);
WindowFrame->AddFrame(fasticlabel, lhints);
WindowFrame->AddFrame(fFastICField, fhints);
WindowFrame->AddFrame(fastsabrelabel, lhints);
WindowFrame->AddFrame(fFastSABREField, fhints);
TGHorizontalFrame *ParamFrame = new TGHorizontalFrame(this, w, h*0.4);
TGHorizontalFrame *RunFrame = new TGHorizontalFrame(InputFrame, w, h*0.1);
TGLabel *typelabel = new TGLabel(RunFrame, "Operation Type:");
fTypeBox = new TGComboBox(RunFrame, TypeBox);
TGGroupFrame* reactionGroup = new TGGroupFrame(ParamFrame, "Reaction Inputs");
TGHorizontalFrame* reactionFrame = new TGHorizontalFrame(reactionGroup, w*0.7, h*0.5);
TGVerticalFrame* targFrame = new TGVerticalFrame(reactionFrame, w*0.175, h*0.5);
TGHorizontalFrame* zTargFrame = new TGHorizontalFrame(targFrame, w*0.3, h*0.2);
TGLabel *ztlabel = new TGLabel(zTargFrame, "ZT:");
fZTField = new TGNumberEntryField(zTargFrame, ZT, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
zTargFrame->AddFrame(ztlabel, lhints);
zTargFrame->AddFrame(fZTField, fhints);
TGHorizontalFrame* aTargFrame = new TGHorizontalFrame(targFrame, w*0.175, h*0.2);
TGLabel *atlabel = new TGLabel(aTargFrame, "AT:");
fATField = new TGNumberEntryField(aTargFrame, AT, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
aTargFrame->AddFrame(atlabel, lhints);
aTargFrame->AddFrame(fATField, fhints);
targFrame->AddFrame(zTargFrame, fhints);
targFrame->AddFrame(aTargFrame, fhints);
TGVerticalFrame* projFrame = new TGVerticalFrame(reactionFrame, w*0.175, h*0.4);
TGHorizontalFrame* zProjFrame = new TGHorizontalFrame(projFrame, w*0.175, h*0.2);
TGLabel *zplabel = new TGLabel(zProjFrame, "ZP:");
fZPField = new TGNumberEntryField(zProjFrame, ZP, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
zProjFrame->AddFrame(zplabel, lhints);
zProjFrame->AddFrame(fZPField, fhints);
TGHorizontalFrame* aProjFrame = new TGHorizontalFrame(projFrame, w*0.175, h*0.2);
TGLabel *aplabel = new TGLabel(aProjFrame, "AP:");
fAPField = new TGNumberEntryField(aProjFrame, AP, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
aProjFrame->AddFrame(aplabel, lhints);
aProjFrame->AddFrame(fAPField, fhints);
projFrame->AddFrame(zProjFrame, fhints);
projFrame->AddFrame(aProjFrame, fhints);
TGVerticalFrame* ejectFrame = new TGVerticalFrame(reactionFrame, w*0.175, h*0.4);
TGHorizontalFrame* zEjectFrame = new TGHorizontalFrame(ejectFrame, w*0.175, h*0.2);
TGLabel *zelabel = new TGLabel(zEjectFrame, "ZE:");
fZEField = new TGNumberEntryField(zEjectFrame, ZE, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
zEjectFrame->AddFrame(zelabel, lhints);
zEjectFrame->AddFrame(fZEField, fhints);
TGHorizontalFrame* aEjectFrame = new TGHorizontalFrame(ejectFrame, w*0.175, h*0.2);
TGLabel *aelabel = new TGLabel(aEjectFrame, "AE:");
fAEField = new TGNumberEntryField(aEjectFrame, AE, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
aEjectFrame->AddFrame(aelabel, lhints);
aEjectFrame->AddFrame(fAEField, fhints);
ejectFrame->AddFrame(zEjectFrame, fhints);
ejectFrame->AddFrame(aEjectFrame, fhints);
TGVerticalFrame* extraFrame = new TGVerticalFrame(reactionFrame, w*0.175, h*0.4);
TGHorizontalFrame* beamFrame = new TGHorizontalFrame(extraFrame, w*0.175, h*0.15);
TGLabel *bkelabel = new TGLabel(beamFrame, "Beam KE (MeV):");
fBKEField = new TGNumberEntryField(beamFrame, Bke, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative);
beamFrame->AddFrame(bkelabel, lhints);
beamFrame->AddFrame(fBKEField, fhints);
TGHorizontalFrame* bfFrame = new TGHorizontalFrame(extraFrame, w*0.175, h*0.15);
TGLabel *bfieldlabel = new TGLabel(bfFrame, "B-Field (G):");
fBField = new TGNumberEntryField(bfFrame, BField, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative);
bfFrame->AddFrame(bfieldlabel, lhints);
bfFrame->AddFrame(fBField, fhints);
TGHorizontalFrame* thetaFrame = new TGHorizontalFrame(extraFrame, w*0.175, h*0.15);
TGLabel *thetalabel = new TGLabel(thetaFrame, "Angle (deg):");
fThetaField = new TGNumberEntryField(thetaFrame, Theta, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative);
thetaFrame->AddFrame(thetalabel, lhints);
thetaFrame->AddFrame(fThetaField, fhints);
extraFrame->AddFrame(beamFrame, fhints);
extraFrame->AddFrame(bfFrame, fhints);
extraFrame->AddFrame(thetaFrame, fhints);
reactionFrame->AddFrame(targFrame, fhints);
reactionFrame->AddFrame(projFrame, fhints);
reactionFrame->AddFrame(ejectFrame, fhints);
reactionFrame->AddFrame(extraFrame, fhints);
reactionGroup->AddFrame(reactionFrame, fhints);
TGGroupFrame* eventGroup = new TGGroupFrame(ParamFrame, "Event Inputs");
TGVerticalFrame* eventFrame = new TGVerticalFrame(eventGroup, w*0.3, h*0.5);
TGHorizontalFrame *slowFrame = new TGHorizontalFrame(eventFrame, w*0.4, h*0.1);
TGLabel *slowlabel = new TGLabel(slowFrame, "Slow Coincidence Window (ps):");
fSlowWindowField = new TGNumberEntryField(slowFrame, SlowWind, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
slowFrame->AddFrame(slowlabel, lhints);
slowFrame->AddFrame(fSlowWindowField, fhints);
TGHorizontalFrame* fastICFrame = new TGHorizontalFrame(eventFrame, w*0.3, h*0.1);
TGLabel *fasticlabel = new TGLabel(fastICFrame, "Fast Coincidence Window IC (ps):");
fFastICField = new TGNumberEntryField(fastICFrame, FastWind_IC, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
fastICFrame->AddFrame(fasticlabel, lhints);
fastICFrame->AddFrame(fFastICField, fhints);
TGHorizontalFrame* fastSABREFrame = new TGHorizontalFrame(eventFrame, w*0.3, h*0.1);
TGLabel *fastsabrelabel = new TGLabel(fastSABREFrame, "Fast Coincidence Window SABRE (ps):");
fFastSABREField = new TGNumberEntryField(fastSABREFrame, FastWind_Sabre, 0, TGNumberEntry::kNESReal, TGNumberEntry::kNEANonNegative);
fastSABREFrame->AddFrame(fastsabrelabel, lhints);
fastSABREFrame->AddFrame(fFastSABREField, fhints);
TGHorizontalFrame *opFrame = new TGHorizontalFrame(eventFrame, w*0.3, h*0.1);
TGLabel *typelabel = new TGLabel(opFrame, "Operation Type:");
fTypeBox = new TGComboBox(opFrame, TypeBox);
//Needs modification for new conversion based sorting GWM -- Dec 2020
fTypeBox->AddEntry("Convert Slow", EventBuilder::EVBApp::Operation::ConvertSlow);
fTypeBox->AddEntry("Convert Fast", EventBuilder::EVBApp::Operation::ConvertFast);
@ -150,32 +196,44 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
fTypeBox->AddEntry("Plot", EventBuilder::EVBApp::Operation::Plot);
fTypeBox->Resize(200,20);
fTypeBox->Connect("Selected(Int_t, Int_t)","EVBMainFrame",this,"HandleTypeSelection(Int_t,Int_t)");
TGLabel *rminlabel = new TGLabel(RunFrame, "Min Run:");
fRMinField = new TGNumberEntryField(RunFrame, RMin, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
TGLabel *rmaxlabel = new TGLabel(RunFrame, "Max Run:");
fRMaxField = new TGNumberEntryField(RunFrame, RMax, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
fRunButton = new TGTextButton(RunFrame, "Run!");
opFrame->AddFrame(typelabel, lhints);
opFrame->AddFrame(fTypeBox, fhints);
TGHorizontalFrame* rminFrame = new TGHorizontalFrame(eventFrame, w*0.3, h*0.1);
TGLabel *rminlabel = new TGLabel(rminFrame, "Min Run:");
fRMinField = new TGNumberEntryField(rminFrame, RMin, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
rminFrame->AddFrame(rminlabel, lhints);
rminFrame->AddFrame(fRMinField, fhints);
TGHorizontalFrame* rmaxFrame = new TGHorizontalFrame(eventFrame, w*0.3, h*0.1);
TGLabel *rmaxlabel = new TGLabel(rmaxFrame, "Max Run:");
fRMaxField = new TGNumberEntryField(rmaxFrame, RMax, 0, TGNumberEntry::kNESInteger, TGNumberEntry::kNEANonNegative);
rmaxFrame->AddFrame(rmaxlabel, lhints);
rmaxFrame->AddFrame(fRMaxField, fhints);
fRunButton = new TGTextButton(eventFrame, "Run!");
fRunButton->SetState(kButtonDisabled);
fRunButton->Connect("Clicked()","EVBMainFrame",this,"DoRun()");
RunFrame->AddFrame(typelabel, lhints);
RunFrame->AddFrame(fTypeBox, fhints);
RunFrame->AddFrame(rminlabel, lhints);
RunFrame->AddFrame(fRMinField, fhints);
RunFrame->AddFrame(rmaxlabel, lhints);
RunFrame->AddFrame(fRMaxField, fhints);
RunFrame->AddFrame(fRunButton, bhints);
eventFrame->AddFrame(slowFrame, fhints);
eventFrame->AddFrame(fastICFrame, fhints);
eventFrame->AddFrame(fastSABREFrame, fhints);
eventFrame->AddFrame(opFrame, fhints);
eventFrame->AddFrame(rminFrame, fhints);
eventFrame->AddFrame(rmaxFrame, fhints);
eventFrame->AddFrame(fRunButton, bhints);
InputFrame->AddFrame(NameFrame, fhints);
InputFrame->AddFrame(ParamFrame, fhints);
InputFrame->AddFrame(WindowFrame, fhints);
InputFrame->AddFrame(RunFrame, fhints);
eventGroup->AddFrame(eventFrame,fhints);
ParamFrame->AddFrame(reactionGroup, fhints);
ParamFrame->AddFrame(eventGroup, new TGLayoutHints(kLHintsExpandY|kLHintsLeft,5,5,5,5));
TGVerticalFrame *PBFrame = new TGVerticalFrame(this, w, h*0.1);
TGLabel *pbLabel = new TGLabel(PBFrame, "Build Progress");
fProgressBar = new TGHProgressBar(PBFrame, TGProgressBar::kFancy, w);
fProgressBar->ShowPosition();
fProgressBar->SetBarColor("lightblue");
fBuilder.AttachProgressBar(fProgressBar);
//fBuilder.AttachProgressBar(fProgressBar);
PBFrame->AddFrame(pbLabel, lhints);
PBFrame->AddFrame(fProgressBar, fhints);
@ -188,9 +246,12 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
menuBar->AddPopup("File", fFileMenu, mhints);
AddFrame(menuBar, new TGLayoutHints(kLHintsTop|kLHintsLeft,0,0,0,0));
AddFrame(InputFrame, fchints);
AddFrame(pathGroup, new TGLayoutHints(kLHintsTop|kLHintsExpandX,5,5,5,5));
AddFrame(ParamFrame, new TGLayoutHints(kLHintsCenterX|kLHintsExpandY,5,5,5,5));
AddFrame(PBFrame, fpbhints);
fBuilder.SetProgressCallbackFunc(BIND_PROGRESS_CALLBACK_FUNCTION(EVBMainFrame::SetProgressBarPosition));
fBuilder.SetProgressFraction(0.01);
SetWindowName("GWM Event Builder");
MapSubwindows();
Resize();
@ -201,6 +262,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
EVBMainFrame::~EVBMainFrame()
{
Cleanup();
delete fInfo;
delete this;
}
@ -212,36 +274,46 @@ void EVBMainFrame::CloseWindow()
void EVBMainFrame::HandleMenuSelection(int id)
{
if(id == M_Save_Config)
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, M_Save_Config);
{
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, fInfo);
SaveConfig(fInfo->fFilename);
}
else if(id == M_Load_Config)
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, M_Load_Config);
{
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, fInfo);
LoadConfig(fInfo->fFilename);
}
else if(id == M_Exit)
CloseWindow();
}
void EVBMainFrame::DoOpenWorkdir()
{
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, WorkDir);
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H, this, WorkDir);
}
void EVBMainFrame::DoOpenCMapfile()
{
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Cmap);
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, fInfo);
DisplayCMap(fInfo->fFilename);
}
void EVBMainFrame::DoOpenSMapfile()
{
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Smap);
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, fInfo);
DisplaySMap(fInfo->fFilename);
}
void EVBMainFrame::DoOpenScalerfile()
{
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Scaler);
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, fInfo);
DisplayScaler(fInfo->fFilename);
}
void EVBMainFrame::DoOpenCutfile()
{
new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H*0.25, this, Cut);
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, fInfo);
DisplayCut(fInfo->fFilename);
}
void EVBMainFrame::DoRun()
@ -494,3 +566,11 @@ void EVBMainFrame::EnableAllInput()
fFastSABREField->SetState(true);
}
void EVBMainFrame::SetProgressBarPosition(long val, long total)
{
fProgressBar->SetMin(0);
fProgressBar->SetMax(total);
fProgressBar->SetPosition(val);
gSystem->ProcessEvents();
}

View File

@ -11,6 +11,7 @@
#include <TGTextViewStream.h>
#include <TGProgressBar.h>
#include <TTimer.h>
#include <TGFileDialog.h>
#include <TGComboBox.h>
#include "../evb/EVBApp.h"
@ -46,6 +47,7 @@ public:
void RunMerge(const char* dir, const char* file);
void DisableAllInput();
void EnableAllInput();
void SetProgressBarPosition(long value, long total);
enum WidgetId
@ -94,6 +96,8 @@ private:
TGPopupMenu *fFileMenu;
TGFileInfo* fInfo;
EventBuilder::EVBApp fBuilder;
int counter;

View File

@ -36,7 +36,7 @@ FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, U
/*Layout orgainization hints*/
TGLayoutHints *fhints = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY,5,5,5,5);
TGLayoutHints *thints = new TGLayoutHints(kLHintsExpandX|kLHintsCenterY,5,5,5,5);
TGLayoutHints *thints = new TGLayoutHints(kLHintsExpandX|kLHintsBottom,5,5,5,5);
TGLayoutHints *fchints = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,5,5,5,5);
TGLayoutHints *lhints = new TGLayoutHints(kLHintsLeft|kLHintsTop,5,5,5,5);
TGLayoutHints *fbhints = new TGLayoutHints(kLHintsCenterX|kLHintsBottom,5,5,5,5);
@ -49,7 +49,7 @@ FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, U
fContents->Connect("DoubleClicked(TGFrame*,Int_t)","FileViewFrame",this,"DoDoubleClick(TGLVEntry*,Int_t)");
/*Add in text options*/
TGVerticalFrame *NameFrame = new TGVerticalFrame(fMain, w, h*0.25);
TGHorizontalFrame *NameFrame = new TGHorizontalFrame(fMain, w, h*0.25);
TGLabel *nameLabel;
if(dirFlag)
nameLabel = new TGLabel(NameFrame, "Dir:");
@ -71,8 +71,8 @@ FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, U
ButtonFrame->AddFrame(fCancelButton, fhints);
fMain->AddFrame(fViewer, fchints);
fMain->AddFrame(NameFrame, thints);
fMain->AddFrame(ButtonFrame, fbhints);
fMain->AddFrame(NameFrame, thints);
/*Send signal to appropriate location*/
if(type == EVBMainFrame::WorkDir)
@ -92,7 +92,10 @@ FileViewFrame::FileViewFrame(const TGWindow* p, const TGFrame* main, UInt_t w, U
else if(type == EVBMainFrame::PlotF)
Connect("SendText(const char*)","EVBMainFrame",parent,"RunPlot(const char*)");
fMain->SetWindowName("Select File");
if(dirFlag)
fMain->SetWindowName("Select Directory");
else
fMain->SetWindowName("Select File");
fMain->MapSubwindows();
fMain->Resize();
fMain->CenterOnParent();