From 8ecfe5e3f8131a03b2e103d12d3c728eae259a75 Mon Sep 17 00:00:00 2001 From: gwm17 Date: Wed, 13 Jul 2022 10:26:37 -0400 Subject: [PATCH] Big update. Finish implementation of EVBWorkspace. Remove unnecessary includes. Note that std::filesystem clashes with ROOT GUI libs. --- etc/ScalerFile_Feb2021_SABRE.txt | 3 +- src/CMakeLists.txt | 2 +- src/EventBuilder.h | 2 - src/evb/CMakeLists.txt | 1 + src/evb/ChannelMap.cpp | 1 - src/evb/CompassFile.cpp | 2 - src/evb/CompassRun.cpp | 31 ++- src/evb/CompassRun.h | 9 +- src/evb/CutHandler.cpp | 1 - src/evb/EVBApp.cpp | 341 ++++++++++++++++--------------- src/evb/EVBApp.h | 36 +--- src/evb/EVBParameters.h | 34 +++ src/evb/EVBWorkspace.cpp | 114 +++++++++-- src/evb/EVBWorkspace.h | 43 ++-- src/evb/FP_kinematics.cpp | 1 - src/evb/FastSort.cpp | 1 - src/evb/FlagHandler.cpp | 1 - src/evb/Logger.cpp | 1 - src/evb/MassLookup.cpp | 1 - src/evb/OrderChecker.cpp | 1 - src/evb/RunCollector.cpp | 1 - src/evb/SFPAnalyzer.cpp | 1 - src/evb/SFPPlotter.cpp | 1 - src/evb/ShiftMap.cpp | 1 - src/evb/SlowSort.cpp | 1 - src/evb/Stopwatch.cpp | 1 - src/guidict/EVBMainFrame.cpp | 157 ++++++-------- src/guidict/EVBMainFrame.h | 11 +- 28 files changed, 427 insertions(+), 373 deletions(-) create mode 100644 src/evb/EVBParameters.h diff --git a/etc/ScalerFile_Feb2021_SABRE.txt b/etc/ScalerFile_Feb2021_SABRE.txt index a2f4e92..f8682ba 100644 --- a/etc/ScalerFile_Feb2021_SABRE.txt +++ b/etc/ScalerFile_Feb2021_SABRE.txt @@ -1,4 +1,3 @@ Format: scaler_param_name assoc_binary_file_name_without_runID NOTE: As of this version, scalers are pure counting parameters (the total events will be counted and saved as a TParameter with the data) -CH0@V1730_89_Data t1 -CH5@V1730_89_Data t2 \ No newline at end of file +Data_CH5@V1730_89 beamint diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8937bc4..967f02a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ add_subdirectory(spsdict) -add_subdirectory(guidict) add_subdirectory(evb) +add_subdirectory(guidict) add_executable(EventBuilder) diff --git a/src/EventBuilder.h b/src/EventBuilder.h index 43014e2..ea5c218 100644 --- a/src/EventBuilder.h +++ b/src/EventBuilder.h @@ -10,8 +10,6 @@ #include #include #include -#include - //ROOT #include diff --git a/src/evb/CMakeLists.txt b/src/evb/CMakeLists.txt index e40ec0c..5b48c2a 100644 --- a/src/evb/CMakeLists.txt +++ b/src/evb/CMakeLists.txt @@ -44,6 +44,7 @@ target_sources(EventBuilderCore PRIVATE SlowSort.h EVBWorkspace.cpp EVBWorkspace.h + EVBParameters.h ) target_link_libraries(EventBuilderCore PUBLIC diff --git a/src/evb/ChannelMap.cpp b/src/evb/ChannelMap.cpp index fcbdc8d..943ba0b 100644 --- a/src/evb/ChannelMap.cpp +++ b/src/evb/ChannelMap.cpp @@ -6,7 +6,6 @@ Written by G.W. McCann Oct. 2020 */ -#include "EventBuilder.h" #include "ChannelMap.h" namespace EventBuilder { diff --git a/src/evb/CompassFile.cpp b/src/evb/CompassFile.cpp index 67e7313..80b1d9e 100644 --- a/src/evb/CompassFile.cpp +++ b/src/evb/CompassFile.cpp @@ -8,7 +8,6 @@ Written by G.W. McCann Oct. 2020 */ -#include "EventBuilder.h" #include "CompassFile.h" namespace EventBuilder { @@ -44,7 +43,6 @@ namespace EventBuilder { m_hitUsedFlag = true; m_filename = filename; m_file->open(m_filename, std::ios::binary | std::ios::in); - m_file->seekg(0, std::ios_base::end); m_size = m_file->tellg(); if(m_size == 2) diff --git a/src/evb/CompassRun.cpp b/src/evb/CompassRun.cpp index 1f2e587..0637f3f 100644 --- a/src/evb/CompassRun.cpp +++ b/src/evb/CompassRun.cpp @@ -9,9 +9,7 @@ Updated to also handle scaler data. -- GWM Oct. 2020 */ -#include "EventBuilder.h" #include "CompassRun.h" -#include "RunCollector.h" #include "SlowSort.h" #include "FastSort.h" #include "SFPAnalyzer.h" @@ -20,10 +18,10 @@ namespace EventBuilder { - CompassRun::CompassRun(const EVBParameters& params) : - m_params(params) + CompassRun::CompassRun(const EVBParameters& params, const std::shared_ptr& workspace) : + m_params(params), m_workspace(workspace) { - m_tempDir = m_params.workspaceDir / "temp_binary"; + m_smap.SetFile(m_params.timeShiftFile); } CompassRun::~CompassRun() {} @@ -45,7 +43,7 @@ namespace EventBuilder { while(input>>filename) { input>>varname; - filename = m_tempDir.string()+filename+"_run_"+std::to_string(m_runNum)+".BIN"; + filename = m_workspace->GetTempDir()+filename+"_run_"+std::to_string(m_runNum)+".BIN"; m_scaler_map[filename] = TParameter(varname.c_str(), init); } input.close(); @@ -53,17 +51,14 @@ namespace EventBuilder { bool CompassRun::GetBinaryFiles() { - std::string prefix = ""; - std::string suffix = ".BIN"; //binaries - RunCollector grabber(m_directory, prefix, suffix); - grabber.GrabAllFiles(); - + auto files = m_workspace->GetTempFiles(); + m_datafiles.clear(); //so that the CompassRun can be reused - m_datafiles.reserve(grabber.GetFileList().size()); + m_datafiles.reserve(files.size()); //NOTE: This line is mandatory. We need the memory preallocated to avoid any move semantics with the filestreams. bool scalerd; m_totalHits = 0; //reset total run size - for(auto& entry : grabber.GetFileList()) + for(auto& entry : files) { //Handle scaler files, if they exist if(m_scaler_flag) @@ -132,9 +127,10 @@ namespace EventBuilder { std::pair earliestHit = std::make_pair(CompassHit(), nullptr); for(unsigned int i=startIndex; iFill(); - if(killFlag) break; + if(killFlag) + break; } } diff --git a/src/evb/CompassRun.h b/src/evb/CompassRun.h index d630883..c0a1d8f 100644 --- a/src/evb/CompassRun.h +++ b/src/evb/CompassRun.h @@ -12,20 +12,19 @@ #include "CompassFile.h" #include "DataStructs.h" -#include "RunCollector.h" #include "ShiftMap.h" #include "ProgressCallback.h" +#include "EVBWorkspace.h" +#include "EVBParameters.h" #include namespace EventBuilder { - struct EVBParameters; //Foward decl to avoid recursive includes - class CompassRun { public: - CompassRun(const EVBParameters& params); + CompassRun(const EVBParameters& params, const std::shared_ptr& workspace); ~CompassRun(); inline void SetRunNumber(int n) { m_runNum = n; } void Convert2RawRoot(const std::string& name); @@ -44,7 +43,7 @@ namespace EventBuilder { void ReadScalerData(const std::string& filename); EVBParameters m_params; - std::filesystem::path m_tempDir; + std::shared_ptr m_workspace; std::vector m_datafiles; unsigned int startIndex; //this is the file we start looking at; increases as we finish files. diff --git a/src/evb/CutHandler.cpp b/src/evb/CutHandler.cpp index 520f98f..c3a4cbd 100644 --- a/src/evb/CutHandler.cpp +++ b/src/evb/CutHandler.cpp @@ -1,4 +1,3 @@ -#include "EventBuilder.h" #include "CutHandler.h" namespace EventBuilder { diff --git a/src/evb/EVBApp.cpp b/src/evb/EVBApp.cpp index 4fb2670..a2a4fff 100644 --- a/src/evb/EVBApp.cpp +++ b/src/evb/EVBApp.cpp @@ -6,20 +6,15 @@ Written by G.W. McCann Oct. 2020 */ -#include "EventBuilder.h" #include #include "EVBApp.h" -#include "RunCollector.h" #include "CompassRun.h" -#include "SlowSort.h" -#include "FastSort.h" -#include "SFPAnalyzer.h" #include "SFPPlotter.h" namespace EventBuilder { EVBApp::EVBApp() : - m_progressFraction(0.1) + m_workspace(nullptr), m_progressFraction(0.1) { SetProgressCallbackFunc(BIND_PROGRESS_CALLBACK_FUNCTION(EVBApp::DefaultProgressCallback)); } @@ -34,6 +29,18 @@ namespace EventBuilder { EVB_INFO("Percent of run built: {0}", fraction*100); } + void EVBApp::SetParameters(const EVBParameters& params) + { + if(m_params.workspaceDir != params.workspaceDir) + { + m_workspace.reset(new EVBWorkspace(params.workspaceDir)); + if(!m_workspace->IsValid()) + EVB_ERROR("Unable to process new parameters due to bad workspace"); + } + + m_params = params; + } + bool EVBApp::ReadConfigFile(const std::string& fullpath) { EVB_INFO("Reading in EVB configuration from file {0}...", fullpath); @@ -47,6 +54,12 @@ namespace EventBuilder { std::getline(input, junk); input>>junk>>m_params.workspaceDir; + m_workspace.reset(new EVBWorkspace(m_params.workspaceDir)); //frees underlying and sets to new pointer + if(!m_workspace->IsValid()) + { + EVB_ERROR("Unable to process input configuration due to bad workspace."); + return false; + } input>>junk; std::getline(input, junk); std::getline(input, junk); @@ -126,8 +139,12 @@ namespace EventBuilder { void EVBApp::PlotHistograms() { - std::string analyze_dir = m_params.workspaceDir+"/analyzed/"; - std::string plot_file = m_params.workspaceDir+"/histograms/run_"+std::to_string(m_params.runMin)+"_"+std::to_string(m_params.runMax)+".root"; + if(m_workspace == nullptr || !m_workspace->IsValid()) + { + EVB_ERROR("Unable to preform event building request due to bad workspace."); + } + + std::string plot_file = m_workspace->GetHistogramDir()+"run_"+std::to_string(m_params.runMin)+"_"+std::to_string(m_params.runMax)+".root"; SFPPlotter grammer; grammer.SetProgressCallbackFunc(m_progressCallback); grammer.SetProgressFraction(m_progressFraction); @@ -135,10 +152,10 @@ namespace EventBuilder { EVB_INFO("Generating histograms from analyzed runs [{0}, {1}] with Cut List {2}...", m_params.runMin, m_params.runMax, m_params.cutListFile); EVB_INFO("Output file will be named {0}",plot_file); - grabber.SetSearchParams(analyze_dir, "", ".root", m_params.runMin, m_params.runMax); - if(grabber.GrabFilesInRange()) + auto files = m_workspace->GetAnalyzedRunRange(m_params.runMin, m_params.runMax); + if(files.size() > 0) { - grammer.Run(grabber.GetFileList(), plot_file); + grammer.Run(files, plot_file); EVB_INFO("Finished."); } else @@ -149,54 +166,56 @@ namespace EventBuilder { void EVBApp::Convert2RawRoot() { - int sys_return; - std::string rawroot_dir = m_params.workspaceDir+"/raw_root/"; - std::string unpack_dir = m_params.workspaceDir+"/temp_binary/"; - std::string binary_dir = m_params.workspaceDir+"/raw_binary/"; - EVB_INFO("Converting binary archives to ROOT files over run range [{0}, {1}]",m_params.runMin,m_params.runMax); + if(m_workspace == nullptr || !m_workspace->IsValid()) + { + EVB_ERROR("Unable to preform event building request due to bad workspace."); + } + + std::string rawroot_dir = m_workspace->GetSortedDir(); + EVB_INFO("Converting binary archives to ROOT files over run range [{0}, {1}]", m_params.runMin, m_params.runMax); - grabber.SetSearchParams(binary_dir, "", ".tar.gz",0,1000); + std::string rawfile; - std::string rawfile, binfile; - std::string unpack_command, wipe_command; - - CompassRun converter(m_params); + CompassRun converter(m_params, m_workspace); converter.SetProgressCallbackFunc(m_progressCallback); converter.SetProgressFraction(m_progressFraction); EVB_INFO("Beginning conversion..."); + int count = 0; for(int i=m_params.runMin; i<=m_params.runMax; i++) { - binfile = grabber.GrabFile(i); - if(binfile == "") - continue; - converter.SetRunNumber(i); - EVB_INFO("Converting file {0}...", binfile); rawfile = rawroot_dir + "compass_run_"+ std::to_string(i) + ".root"; - unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir; - wipe_command = "rm -r "+unpack_dir+"*.BIN"; - - sys_return = system(unpack_command.c_str()); - converter.Convert2RawRoot(rawfile); - sys_return = system(wipe_command.c_str()); - + EVB_INFO("Converting file {0}...", rawfile); + m_workspace->ClearTempDirectory(); //In case something weird happened + if(m_workspace->UnpackBinaryRunToTemp(i)) + { + converter.SetRunNumber(i); + converter.Convert2RawRoot(rawfile); + ++count; + } + m_workspace->ClearTempDirectory(); } - EVB_INFO("Conversion complete."); + + if(count != 0) + EVB_INFO("Conversion complete."); + else + EVB_WARN("Nothing converted, no files found in the range [{0}, {1}]", m_params.runMin, m_params.runMax); } void EVBApp::MergeROOTFiles() { - std::string merge_file = m_params.workspaceDir+"/merged/run_"+std::to_string(m_params.runMin)+"_"+std::to_string(m_params.runMax)+".root"; - std::string file_dir = m_params.workspaceDir.string()+"/analyzed/"; + if(m_workspace == nullptr || !m_workspace->IsValid()) + { + EVB_ERROR("Unable to preform event building request due to bad workspace."); + } + + std::string merge_file = m_workspace->GetMergedDir()+"run_"+std::to_string(m_params.runMin)+"_"+std::to_string(m_params.runMax)+".root"; EVB_INFO("Merging ROOT files into single file for runs in range [{0}, {1}]", m_params.runMin, m_params.runMax); EVB_INFO("Merged file will be named {0}", merge_file); - std::string prefix = ""; - std::string suffix = ".root"; - grabber.SetSearchParams(file_dir, prefix, suffix,m_params.runMin,m_params.runMax); EVB_INFO("Starting merge..."); - if(!grabber.Merge_TChain(merge_file)) + if(!m_workspace->MergeAnalyzedFiles(merge_file, m_params.runMin, m_params.runMax)) { - EVB_ERROR("Unable to find files for merge at EVBApp::MergeROOTFiles()!"); + EVB_ERROR("Unable to merge at EVBApp::MergeROOTFiles()!"); return; } EVB_INFO("Finished."); @@ -204,169 +223,157 @@ namespace EventBuilder { void EVBApp::Convert2SortedRoot() { - int sys_return; - std::string sortroot_dir = m_params.workspaceDir+"/sorted/"; - std::string unpack_dir = m_params.workspaceDir+"/temp_binary/"; - std::string binary_dir = m_params.workspaceDir+"/raw_binary/"; - EVB_INFO("Converting binary archives to event built ROOT files over run range [{0}, {1}]",m_params.runMin,m_params.runMax); - - grabber.SetSearchParams(binary_dir,"",".tar.gz",m_params.runMin,m_params.runMax); - - std::string sortfile, binfile; - std::string unpack_command, wipe_command; - - CompassRun converter(m_params); - converter.SetProgressCallbackFunc(m_progressCallback); - converter.SetProgressFraction(m_progressFraction); - - EVB_INFO("Beginning conversion..."); - - int count=0; - for(int i=m_params.runMin; i<= m_params.runMax; i++) + if(m_workspace == nullptr || !m_workspace->IsValid()) { - binfile = grabber.GrabFile(i); - if(binfile == "") - continue; - converter.SetRunNumber(i); - EVB_INFO("Converting file {0}...",binfile); - - sortfile = sortroot_dir +"run_"+std::to_string(i)+ ".root"; - unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir; - wipe_command = "rm -r "+unpack_dir+"*.BIN"; - - sys_return = system(unpack_command.c_str()); - converter.Convert2SortedRoot(sortfile); - sys_return = system(wipe_command.c_str()); - count++; + EVB_ERROR("Unable to preform event building request due to bad workspace."); } - if(count==0) - EVB_WARN("Conversion failed, no archives were found!"); - else - EVB_INFO("Conversion complete."); - } + + std::string sortroot_dir = m_workspace->GetBuiltDir(); + EVB_INFO("Converting binary archives to event built ROOT files over run range [{0}, {1}]", m_params.runMin, m_params.runMax); - void EVBApp::Convert2FastSortedRoot() { - int sys_return; - std::string sortroot_dir = m_params.workspaceDir+"/fast/"; - std::string unpack_dir = m_params.workspaceDir+"/temp_binary/"; - std::string binary_dir = m_params.workspaceDir+"/raw_binary/"; - EVB_INFO("Converting binary archives to fast event built ROOT files over run range [{0}, {1}]",m_params.runMin,m_params.runMax); - - grabber.SetSearchParams(binary_dir,"",".tar.gz",m_params.runMin,m_params.runMax); - - std::string sortfile, binfile; - std::string unpack_command, wipe_command; - - CompassRun converter(m_params); + std::string sortfile; + + CompassRun converter(m_params, m_workspace); converter.SetProgressCallbackFunc(m_progressCallback); converter.SetProgressFraction(m_progressFraction); - + EVB_INFO("Beginning conversion..."); - int count=0; + int count = 0; for(int i=m_params.runMin; i<=m_params.runMax; i++) { - binfile = grabber.GrabFile(i); - if(binfile == "") - continue; - converter.SetRunNumber(i); - EVB_INFO("Converting file {0}...",binfile); - - sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root"; - unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir; - wipe_command = "rm -r "+unpack_dir+"*.BIN"; - - sys_return = system(unpack_command.c_str()); - converter.Convert2FastSortedRoot(sortfile); - sys_return = system(wipe_command.c_str()); - count++; + sortfile = sortroot_dir + "run_"+ std::to_string(i) + ".root"; + EVB_INFO("Converting file {0}...", sortfile); + m_workspace->ClearTempDirectory(); //In case something weird happened + if(m_workspace->UnpackBinaryRunToTemp(i)) + { + converter.SetRunNumber(i); + converter.Convert2SortedRoot(sortfile); + EVB_INFO("Finished converting"); + ++count; + } + m_workspace->ClearTempDirectory(); } - if(count==0) - EVB_WARN("Conversion failed, no archives were found!"); - else + + if(count != 0) EVB_INFO("Conversion complete."); + else + EVB_WARN("Nothing converted, no files found in the range [{0}, {1}]", m_params.runMin, m_params.runMax); } - void EVBApp::Convert2SlowAnalyzedRoot() { - int sys_return; - std::string sortroot_dir = m_params.workspaceDir+"/analyzed/"; - std::string unpack_dir = m_params.workspaceDir+"/temp_binary/"; - std::string binary_dir = m_params.workspaceDir+"/raw_binary/"; + void EVBApp::Convert2FastSortedRoot() + { + if(m_workspace == nullptr || !m_workspace->IsValid()) + { + EVB_ERROR("Unable to preform event building request due to bad workspace."); + } + + std::string sortroot_dir = m_workspace->GetBuiltDir(); + EVB_INFO("Converting binary archives to fast event built ROOT files over run range [{0}, {1}]", m_params.runMin, m_params.runMax); + + + std::string sortfile; + + CompassRun converter(m_params, m_workspace); + converter.SetProgressCallbackFunc(m_progressCallback); + converter.SetProgressFraction(m_progressFraction); + + EVB_INFO("Beginning conversion..."); + int count = 0; + for(int i=m_params.runMin; i<=m_params.runMax; i++) + { + sortfile = sortroot_dir + "run_"+ std::to_string(i) + ".root"; + EVB_INFO("Converting file {0}...", sortfile); + m_workspace->ClearTempDirectory(); //In case something weird happened + if(m_workspace->UnpackBinaryRunToTemp(i)) + { + converter.SetRunNumber(i); + converter.Convert2FastSortedRoot(sortfile); + ++count; + } + m_workspace->ClearTempDirectory(); + } + + if(count != 0) + EVB_INFO("Conversion complete."); + else + EVB_WARN("Nothing converted, no files found in the range [{0}, {1}]", m_params.runMin, m_params.runMax); + } + + void EVBApp::Convert2SlowAnalyzedRoot() + { + if(m_workspace == nullptr || !m_workspace->IsValid()) + { + EVB_ERROR("Unable to preform event building request due to bad workspace."); + } + + std::string sortroot_dir = m_workspace->GetAnalyzedDir(); EVB_INFO("Converting binary archives to analyzed event built ROOT files over run range [{0}, {1}]",m_params.runMin,m_params.runMax); - grabber.SetSearchParams(binary_dir,"",".tar.gz",m_params.runMin, m_params.runMax); + std::string sortfile; - std::string sortfile, binfile; - std::string unpack_command, wipe_command; - - CompassRun converter(m_params); + CompassRun converter(m_params, m_workspace); converter.SetProgressCallbackFunc(m_progressCallback); converter.SetProgressFraction(m_progressFraction); - + EVB_INFO("Beginning conversion..."); - int count=0; + int count = 0; for(int i=m_params.runMin; i<=m_params.runMax; i++) { - binfile = grabber.GrabFile(i); - if(binfile == "") - continue; - converter.SetRunNumber(i); - EVB_INFO("Converting file {0}...",binfile); - - sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root"; - unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir; - wipe_command = "rm -r "+unpack_dir+"*.BIN"; - - sys_return = system(unpack_command.c_str()); - converter.Convert2SlowAnalyzedRoot(sortfile); - sys_return = system(wipe_command.c_str()); - count++; + sortfile = sortroot_dir + "run_"+ std::to_string(i) + ".root"; + EVB_INFO("Converting file {0}...", sortfile); + m_workspace->ClearTempDirectory(); //In case something weird happened + if(m_workspace->UnpackBinaryRunToTemp(i)) + { + converter.SetRunNumber(i); + converter.Convert2SlowAnalyzedRoot(sortfile); + ++count; + } + m_workspace->ClearTempDirectory(); } - if(count==0) - EVB_WARN("Conversion failed, no archives were found!"); - else + + if(count != 0) EVB_INFO("Conversion complete."); + else + EVB_WARN("Nothing converted, no files found in the range [{0}, {1}]", m_params.runMin, m_params.runMax); } void EVBApp::Convert2FastAnalyzedRoot() { - int sys_return; - std::string sortroot_dir = m_params.workspaceDir+"/analyzed/"; - std::string unpack_dir = m_params.workspaceDir+"/temp_binary/"; - std::string binary_dir = m_params.workspaceDir+"/raw_binary/"; + if(m_workspace == nullptr || !m_workspace->IsValid()) + { + EVB_ERROR("Unable to preform event building request due to bad workspace."); + } + + std::string sortroot_dir = m_workspace->GetAnalyzedDir(); EVB_INFO("Converting binary archives to analyzed fast event built ROOT files over run range [{0}, {1}]",m_params.runMin,m_params.runMax); - grabber.SetSearchParams(binary_dir,"",".tar.gz",m_params.runMin,m_params.runMax); - std::string sortfile, binfile; - std::string unpack_command, wipe_command; + std::string sortfile; - CompassRun converter(m_params); + CompassRun converter(m_params, m_workspace); converter.SetProgressCallbackFunc(m_progressCallback); converter.SetProgressFraction(m_progressFraction); - + EVB_INFO("Beginning conversion..."); - int count=0; + int count = 0; for(int i=m_params.runMin; i<=m_params.runMax; i++) { - binfile = grabber.GrabFile(i); - if(binfile == "") - continue; - converter.SetRunNumber(i); - EVB_INFO("Converting file {0}...",binfile); - - sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root"; - unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir; - wipe_command = "rm -r "+unpack_dir+"*.BIN"; - - sys_return = system(unpack_command.c_str()); - converter.Convert2FastAnalyzedRoot(sortfile); - sys_return = system(wipe_command.c_str()); - count++; + sortfile = sortroot_dir + "run_"+ std::to_string(i) + ".root"; + EVB_INFO("Converting file {0}...", sortfile); + m_workspace->ClearTempDirectory(); //In case something weird happened + if(m_workspace->UnpackBinaryRunToTemp(i)) + { + converter.SetRunNumber(i); + converter.Convert2FastAnalyzedRoot(sortfile); + ++count; + } + m_workspace->ClearTempDirectory(); } - if(count==0) - EVB_WARN("Conversion failed, no archives were found!"); - else + + if(count != 0) EVB_INFO("Conversion complete."); + else + EVB_WARN("Nothing converted, no files found in the range [{0}, {1}]", m_params.runMin, m_params.runMax); } } \ No newline at end of file diff --git a/src/evb/EVBApp.h b/src/evb/EVBApp.h index 8cae221..859bbf7 100644 --- a/src/evb/EVBApp.h +++ b/src/evb/EVBApp.h @@ -9,37 +9,11 @@ #ifndef EVBAPP_H #define EVBAPP_H -#include "RunCollector.h" +#include "EVBParameters.h" +#include "EVBWorkspace.h" #include "ProgressCallback.h" namespace EventBuilder { - - struct EVBParameters - { - std::filesystem::path workspaceDir = ""; - std::filesystem::path channelMapFile = ""; - std::filesystem::path timeShiftFile = ""; - std::filesystem::path cutListFile = ""; - std::filesystem::path scalerFile = ""; - - int runMin = 0; - int runMax = 0; - - double slowCoincidenceWindow = 3.0e6; - double fastCoincidenceWindowIonCh = 0.0; - double fastCoincidenceWindowSABRE = 0.0; - - int ZT = 6; - int AT = 12; - int ZP = 1; - int AP = 2; - int ZE = 1; - int AE = 1; - - double BField = 7.8; //kG - double spsAngle = 15.0; //degrees - double beamEnergy = 16.0; //MeV - }; class EVBApp { public: @@ -52,13 +26,13 @@ namespace EventBuilder { void PlotHistograms(); void MergeROOTFiles(); + void Convert2RawRoot(); void Convert2SortedRoot(); void Convert2FastSortedRoot(); - void Convert2RawRoot(); void Convert2SlowAnalyzedRoot(); void Convert2FastAnalyzedRoot(); - inline void SetParameters(const EVBParameters& params) { m_params = params; } + void SetParameters(const EVBParameters& params); inline EVBParameters& GetParameters() { return m_params; } void DefaultProgressCallback(long curVal, long totalVal); @@ -78,7 +52,7 @@ namespace EventBuilder { private: EVBParameters m_params; - RunCollector grabber; + std::shared_ptr m_workspace; double m_progressFraction; ProgressCallbackFunc m_progressCallback; diff --git a/src/evb/EVBParameters.h b/src/evb/EVBParameters.h new file mode 100644 index 0000000..551336c --- /dev/null +++ b/src/evb/EVBParameters.h @@ -0,0 +1,34 @@ +#ifndef EVB_PARAMETERS_H +#define EVB_PARAMETERS_H + +namespace EventBuilder { + + struct EVBParameters + { + std::string workspaceDir = ""; + std::string channelMapFile = ""; + std::string timeShiftFile = ""; + std::string cutListFile = ""; + std::string scalerFile = ""; + + int runMin = 0; + int runMax = 0; + + double slowCoincidenceWindow = 3.0e6; + double fastCoincidenceWindowIonCh = 0.0; + double fastCoincidenceWindowSABRE = 0.0; + + int ZT = 6; + int AT = 12; + int ZP = 1; + int AP = 2; + int ZE = 1; + int AE = 1; + + double BField = 7.8; //kG + double spsAngle = 15.0; //degrees + double beamEnergy = 16.0; //MeV + }; +} + +#endif \ No newline at end of file diff --git a/src/evb/EVBWorkspace.cpp b/src/evb/EVBWorkspace.cpp index 11f3074..e0675b8 100644 --- a/src/evb/EVBWorkspace.cpp +++ b/src/evb/EVBWorkspace.cpp @@ -1,8 +1,11 @@ #include "EVBWorkspace.h" +#include +#include +#include namespace EventBuilder { - static bool CheckSubDirectory(const std::filesystem::path& path) + static bool CheckSubDirectory(const std::string& path) { bool status = true; EVB_TRACE("Checking subdirectory {0}", path); @@ -11,7 +14,7 @@ namespace EventBuilder { status = std::filesystem::create_directory(path); if(!status) { - EVB_ERROR("Unable to create subdirectory {0}. Please check the pathing.", path.string()); + EVB_ERROR("Unable to create subdirectory {0}. Please check the pathing.", path); return status; } EVB_INFO("Created subdirectory {0}", path); @@ -21,7 +24,7 @@ namespace EventBuilder { return status; } - EVBWorkspace::EVBWorkspace(const std::filesystem::path& workspace) : + EVBWorkspace::EVBWorkspace(const std::string& workspace) : m_isValid(false), m_workspace(workspace) { Init(); @@ -34,27 +37,27 @@ namespace EventBuilder { m_isValid = true; if(!std::filesystem::exists(m_workspace)) { - EVB_TRACE("Workspace {0} does not exist. Attempting to create the workspace directory...", m_workspace.string()); + EVB_TRACE("Workspace {0} does not exist. Attempting to create the workspace directory...", m_workspace); m_isValid = std::filesystem::create_directory(m_workspace); if(!m_isValid) { - EVB_ERROR("Unable to create workspace {0}. Please check the pathing.", m_workspace.string()); + EVB_ERROR("Unable to create workspace {0}. Please check the pathing.", m_workspace); return; } - EVB_INFO("Created workspace directory {0}.", m_workspace.string()); + EVB_INFO("Created workspace directory {0}.", m_workspace); } else - EVB_INFO("Found workspace directory {0}.", m_workspace.string()); + EVB_INFO("Found workspace directory {0}.", m_workspace); EVB_TRACE("Looking for required workspace subdirectories..."); - m_binaryDir = m_workspace / "raw_binary"; - m_tempDir = m_workspace / "temp_binary"; - m_sortedDir = m_workspace / "sorted"; - m_builtDir = m_workspace / "built"; - m_analyzedDir = m_workspace / "analyzed"; - m_histogramDir = m_workspace / "histograms"; - m_cutDir = m_workspace / "cuts"; + m_binaryDir = m_workspace + "raw_binary/"; + m_tempDir = m_workspace + "temp_binary/"; + m_sortedDir = m_workspace + "sorted/"; + m_builtDir = m_workspace + "built/"; + m_analyzedDir = m_workspace + "analyzed/"; + m_histogramDir = m_workspace + "histograms/"; + m_cutDir = m_workspace + "cuts/"; //Check all subdirectories. Terminate if any of them are bad m_isValid = CheckSubDirectory(m_binaryDir); @@ -92,6 +95,20 @@ namespace EventBuilder { return ""; } + std::string EVBWorkspace::GetAnalyzedRun(int run) + { + std::string file; + std::string runID = "run_" + std::to_string(run) + ".root"; + for(auto& entry : std::filesystem::directory_iterator(m_analyzedDir)) + { + if(entry.is_regular_file() && entry.path().filename().string() == runID) + { + return entry.path().string(); + } + } + return ""; + } + std::vector EVBWorkspace::GetBinaryRunRange(int runMin, int runMax) { std::vector list; @@ -104,6 +121,29 @@ namespace EventBuilder { return list; } + std::vector EVBWorkspace::GetAnalyzedRunRange(int runMin, int runMax) + { + std::vector list; + std::string temp; + for(int run=runMin; run<=runMax; run++) + temp = GetAnalyzedRun(run); + if(!temp.empty()) + list.push_back(temp); + + return list; + } + + bool EVBWorkspace::UnpackBinaryRunToTemp(int run) + { + std::string runfile = GetBinaryRun(run); + std::string unpack_command = "tar -xzf "+runfile+" --directory "+m_tempDir; + int sys_return = system(unpack_command.c_str()); + if(sys_return == 0) + return true; + else + return false; + } + std::vector EVBWorkspace::GetTempFiles() { std::vector list; @@ -115,4 +155,50 @@ namespace EventBuilder { return list; } + + bool EVBWorkspace::ClearTempDirectory() + { + std::vector files; + for(auto& entry : std::filesystem::directory_iterator(m_tempDir)) + { + if(entry.is_regular_file()) + files.push_back(entry.path()); + else + EVB_WARN("Detected non-file element in temp directory {0} named {1}", m_tempDir, entry.path().string()); + } + + for(size_t i=0; iIsOpen()) + { + EVB_ERROR("Could not open output file {0} for merge", outputname); + output->Close(); + return false; + } + + TChain* chain = new TChain("SPSTree", "SPSTree"); + for(auto& entry : files) + chain->Add(entry.c_str()); + chain->Merge(output, 0, "fast"); + output->Close(); + return true; + } } \ No newline at end of file diff --git a/src/evb/EVBWorkspace.h b/src/evb/EVBWorkspace.h index ac7790f..91ee784 100644 --- a/src/evb/EVBWorkspace.h +++ b/src/evb/EVBWorkspace.h @@ -6,36 +6,45 @@ namespace EventBuilder { class EVBWorkspace { public: - EVBWorkspace(const std::filesystem::path& workspace); + EVBWorkspace(const std::string& workspace); ~EVBWorkspace(); inline const bool IsValid() const { return m_isValid; } - inline std::filesystem::path GetBinaryDir() const { return m_binaryDir; } - inline std::filesystem::path GetTempDir() const { return m_tempDir; } - inline std::filesystem::path GetSortedDir() const { return m_sortedDir; } - inline std::filesystem::path GetBuiltDir() const { return m_builtDir; } - inline std::filesystem::path GetAnalyzedDir() const { return m_analyzedDir; } - inline std::filesystem::path GetHistogramDir() const { return m_histogramDir; } - inline std::filesystem::path GetCutDir() const { return m_cutDir; } + inline std::string GetBinaryDir() const { return m_binaryDir; } + inline std::string GetTempDir() const { return m_tempDir; } + inline std::string GetSortedDir() const { return m_sortedDir; } + inline std::string GetBuiltDir() const { return m_builtDir; } + inline std::string GetAnalyzedDir() const { return m_analyzedDir; } + inline std::string GetHistogramDir() const { return m_histogramDir; } + inline std::string GetCutDir() const { return m_cutDir; } + inline std::string GetMergedDir() const { return m_mergedDir; } std::vector GetBinaryRunRange(int runMin, int runMax); - std::string GetBinaryRun(int run); + std::vector GetAnalyzedRunRange(int runMin, int runMax); + + bool UnpackBinaryRunToTemp(int run); //Currently Linux/MacOS only. Windows support to come. std::vector GetTempFiles(); + bool ClearTempDirectory(); + //Maybe offload to another class? Idk. Feel like EVBWorkspace shouldn't know about ROOT + bool MergeAnalyzedFiles(const std::string& outputname, int runMin, int runMax); private: void Init(); + std::string GetBinaryRun(int run); + std::string GetAnalyzedRun(int run); bool m_isValid; - std::filesystem::path m_workspace; + std::string m_workspace; - std::filesystem::path m_binaryDir; - std::filesystem::path m_tempDir; - std::filesystem::path m_sortedDir; - std::filesystem::path m_builtDir; - std::filesystem::path m_analyzedDir; - std::filesystem::path m_histogramDir; - std::filesystem::path m_cutDir; + std::string m_binaryDir; + std::string m_tempDir; + std::string m_sortedDir; + std::string m_builtDir; + std::string m_analyzedDir; + std::string m_histogramDir; + std::string m_cutDir; + std::string m_mergedDir; }; } diff --git a/src/evb/FP_kinematics.cpp b/src/evb/FP_kinematics.cpp index 88b892b..5a6cdfa 100644 --- a/src/evb/FP_kinematics.cpp +++ b/src/evb/FP_kinematics.cpp @@ -31,7 +31,6 @@ */ -#include "EventBuilder.h" #include #include "MassLookup.h" #include "FP_kinematics.h" diff --git a/src/evb/FastSort.cpp b/src/evb/FastSort.cpp index 1452b70..3f8a7c4 100644 --- a/src/evb/FastSort.cpp +++ b/src/evb/FastSort.cpp @@ -1,4 +1,3 @@ -#include "EventBuilder.h" #include "FastSort.h" namespace EventBuilder { diff --git a/src/evb/FlagHandler.cpp b/src/evb/FlagHandler.cpp index 52b0cb0..5ae547a 100644 --- a/src/evb/FlagHandler.cpp +++ b/src/evb/FlagHandler.cpp @@ -1,4 +1,3 @@ -#include "EventBuilder.h" #include "FlagHandler.h" namespace EventBuilder { diff --git a/src/evb/Logger.cpp b/src/evb/Logger.cpp index b3b76e3..3fdcdee 100644 --- a/src/evb/Logger.cpp +++ b/src/evb/Logger.cpp @@ -1,4 +1,3 @@ -#include "EventBuilder.h" #include "spdlog/sinks/stdout_color_sinks.h" namespace EventBuilder { diff --git a/src/evb/MassLookup.cpp b/src/evb/MassLookup.cpp index 4352589..972f5de 100644 --- a/src/evb/MassLookup.cpp +++ b/src/evb/MassLookup.cpp @@ -8,7 +8,6 @@ of this map (MASS) for use throughout code it is included into. Written by G.W. McCann Aug. 2020 */ -#include "EventBuilder.h" #include "MassLookup.h" namespace EventBuilder { diff --git a/src/evb/OrderChecker.cpp b/src/evb/OrderChecker.cpp index 4beddb7..0032a30 100644 --- a/src/evb/OrderChecker.cpp +++ b/src/evb/OrderChecker.cpp @@ -5,7 +5,6 @@ Written by G.W. McCann Oct. 2020 */ -#include "EventBuilder.h" #include "OrderChecker.h" namespace EventBuilder { diff --git a/src/evb/RunCollector.cpp b/src/evb/RunCollector.cpp index 3c983e1..725afb1 100644 --- a/src/evb/RunCollector.cpp +++ b/src/evb/RunCollector.cpp @@ -1,4 +1,3 @@ -#include "EventBuilder.h" #include "RunCollector.h" #include #include diff --git a/src/evb/SFPAnalyzer.cpp b/src/evb/SFPAnalyzer.cpp index a4524bc..d645f88 100644 --- a/src/evb/SFPAnalyzer.cpp +++ b/src/evb/SFPAnalyzer.cpp @@ -9,7 +9,6 @@ * * Position calibrations swapped as of Aug. 2021 due to detector fixes -- GWM */ -#include "EventBuilder.h" #include "SFPAnalyzer.h" namespace EventBuilder { diff --git a/src/evb/SFPPlotter.cpp b/src/evb/SFPPlotter.cpp index b19da12..3752199 100644 --- a/src/evb/SFPPlotter.cpp +++ b/src/evb/SFPPlotter.cpp @@ -6,7 +6,6 @@ *Created Jan 2020 by GWM */ -#include "EventBuilder.h" #include "SFPPlotter.h" #include diff --git a/src/evb/ShiftMap.cpp b/src/evb/ShiftMap.cpp index 91b8eda..b7c56e5 100644 --- a/src/evb/ShiftMap.cpp +++ b/src/evb/ShiftMap.cpp @@ -9,7 +9,6 @@ Written by G.W. McCann Oct. 2020 */ -#include "EventBuilder.h" #include "ShiftMap.h" namespace EventBuilder { diff --git a/src/evb/SlowSort.cpp b/src/evb/SlowSort.cpp index c4e7489..e58b7c7 100644 --- a/src/evb/SlowSort.cpp +++ b/src/evb/SlowSort.cpp @@ -7,7 +7,6 @@ * *Refurbished and updated Jan 2020 GWM */ -#include "EventBuilder.h" #include "SlowSort.h" namespace EventBuilder { diff --git a/src/evb/Stopwatch.cpp b/src/evb/Stopwatch.cpp index 95feb6e..8447d56 100644 --- a/src/evb/Stopwatch.cpp +++ b/src/evb/Stopwatch.cpp @@ -5,7 +5,6 @@ Written by G.W. McCann Oct. 2020 */ -#include "EventBuilder.h" #include "Stopwatch.h" namespace EventBuilder { diff --git a/src/guidict/EVBMainFrame.cpp b/src/guidict/EVBMainFrame.cpp index 1e5203f..e2203e3 100644 --- a/src/guidict/EVBMainFrame.cpp +++ b/src/guidict/EVBMainFrame.cpp @@ -29,7 +29,6 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) : TGLabel* workLabel = new TGLabel(WorkFrame, "Workspace Directory:"); fWorkField = new TGTextEntry(WorkFrame, new TGTextBuffer(120), WorkDir); fWorkField->Resize(w*0.25, fWorkField->GetDefaultHeight()); - fWorkField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateWorkdir()"); fOpenWorkButton = new TGTextButton(WorkFrame, "Open"); fOpenWorkButton->Connect("Clicked()","EVBMainFrame",this,"DoOpenWorkdir()"); WorkFrame->AddFrame(workLabel, lhints); @@ -40,7 +39,6 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) : TGLabel* cmaplabel = new TGLabel(CMapFrame, "Channel Map File:"); fCMapField = new TGTextEntry(CMapFrame, new TGTextBuffer(120), Cmap); fCMapField->Resize(w*0.25, fCMapField->GetDefaultHeight()); - fCMapField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateCMap()"); fOpenCMapButton = new TGTextButton(CMapFrame, "Open"); fOpenCMapButton->Connect("Clicked()","EVBMainFrame",this,"DoOpenCMapfile()"); CMapFrame->AddFrame(cmaplabel, lhints); @@ -51,7 +49,6 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) : TGLabel* smaplabel = new TGLabel(SMapFrame, "Board Shift File:"); fSMapField = new TGTextEntry(SMapFrame, new TGTextBuffer(120), Smap); fSMapField->Resize(w*0.25, fSMapField->GetDefaultHeight()); - fSMapField->Connect("ReturnPressed()","EVBMainFrame",this,"UpdateSMap()"); fOpenSMapButton = new TGTextButton(SMapFrame, "Open"); fOpenSMapButton->Connect("Clicked()","EVBMainFrame",this,"DoOpenSMapfile()"); SMapFrame->AddFrame(smaplabel, lhints); @@ -61,7 +58,6 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) : 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()"); fOpenScalerButton = new TGTextButton(ScalerFrame, "Open"); fOpenScalerButton->Connect("Clicked()","EVBMainFrame", this, "DoOpenScalerfile()"); ScalerFrame->AddFrame(sclabel, lhints); @@ -71,7 +67,6 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) : 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()"); fOpenCutButton = new TGTextButton(CutFrame, "Open"); fOpenCutButton->Connect("Clicked()","EVBMainFrame",this,"DoOpenCutfile()"); CutFrame->AddFrame(clabel, lhints); @@ -250,8 +245,8 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) : 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); + m_builder.SetProgressCallbackFunc(BIND_PROGRESS_CALLBACK_FUNCTION(EVBMainFrame::SetProgressBarPosition)); + m_builder.SetProgressFraction(0.01); SetWindowName("GWM Event Builder"); MapSubwindows(); Resize(); @@ -291,7 +286,12 @@ void EVBMainFrame::HandleMenuSelection(int id) void EVBMainFrame::DoOpenWorkdir() { - new FileViewFrame(gClient->GetRoot(), this, MAIN_W*0.5, MAIN_H, this, WorkDir); + new TGFileDialog(gClient->GetRoot(), this, kDOpen, fInfo); + if(fInfo->fFilename) + { + std::string path_wtrailer = fInfo->fFilename + std::string("/"); + DisplayWorkdir(path_wtrailer.c_str()); + } } void EVBMainFrame::DoOpenCMapfile() @@ -335,37 +335,37 @@ void EVBMainFrame::DoRun() { case EventBuilder::EVBApp::Operation::Plot : { - RunPlot(); + m_builder.PlotHistograms(); break; } case EventBuilder::EVBApp::Operation::Convert : { - fBuilder.Convert2RawRoot(); + m_builder.Convert2RawRoot(); break; } case EventBuilder::EVBApp::Operation::Merge : { - fBuilder.MergeROOTFiles(); + m_builder.MergeROOTFiles(); break; } case EventBuilder::EVBApp::Operation::ConvertSlow : { - fBuilder.Convert2SortedRoot(); + m_builder.Convert2SortedRoot(); break; } case EventBuilder::EVBApp::Operation::ConvertFast : { - fBuilder.Convert2FastSortedRoot(); + m_builder.Convert2FastSortedRoot(); break; } case EventBuilder::EVBApp::Operation::ConvertSlowA : { - fBuilder.Convert2SlowAnalyzedRoot(); + m_builder.Convert2SlowAnalyzedRoot(); break; } case EventBuilder::EVBApp::Operation::ConvertFastA : { - fBuilder.Convert2FastAnalyzedRoot(); + m_builder.Convert2FastAnalyzedRoot(); break; } } @@ -380,126 +380,97 @@ void EVBMainFrame::HandleTypeSelection(int box, int entry) bool EVBMainFrame::SetParameters() { - fBuilder.SetRunRange(fRMinField->GetIntNumber(), fRMaxField->GetIntNumber()); - fBuilder.SetSlowCoincidenceWindow(fSlowWindowField->GetNumber()); - fBuilder.SetFastWindowIonChamber(fFastICField->GetNumber()); - fBuilder.SetFastWindowSABRE(fFastSABREField->GetNumber()); - UpdateWorkdir(); - UpdateSMap(); - UpdateCMap(); - UpdateScaler(); - UpdateCut(); - bool test = fBuilder.SetKinematicParameters(fZTField->GetIntNumber(), fATField->GetIntNumber(), - fZPField->GetIntNumber(), fAPField->GetIntNumber(), - fZEField->GetIntNumber(), fAEField->GetIntNumber(), - fBField->GetNumber(), fThetaField->GetNumber(), - fBKEField->GetNumber()); - return test; + m_parameters.runMin = fRMinField->GetIntNumber(); + m_parameters.runMax = fRMaxField->GetIntNumber(); + m_parameters.slowCoincidenceWindow = fSlowWindowField->GetNumber(); + m_parameters.fastCoincidenceWindowIonCh = fFastICField->GetNumber(); + m_parameters.fastCoincidenceWindowSABRE = fFastSABREField->GetNumber(); + m_parameters.workspaceDir = fWorkField->GetText(); + m_parameters.channelMapFile = fCMapField->GetText(); + m_parameters.scalerFile = fScalerField->GetText(); + m_parameters.timeShiftFile = fSMapField->GetText(); + m_parameters.cutListFile = fCutField->GetText(); + m_parameters.ZT = fZTField->GetIntNumber(); + m_parameters.AT = fATField->GetIntNumber(); + m_parameters.ZP = fZPField->GetIntNumber(); + m_parameters.AP = fAPField->GetIntNumber(); + m_parameters.ZE = fZEField->GetIntNumber(); + m_parameters.AE = fAEField->GetIntNumber(); + m_parameters.BField = fBField->GetNumber(); + m_parameters.beamEnergy = fBKEField->GetNumber(); + m_parameters.spsAngle = fThetaField->GetNumber(); + + m_builder.SetParameters(m_parameters); + return true; } void EVBMainFrame::DisplayWorkdir(const char* dir) { fWorkField->SetText(dir); - fBuilder.SetWorkDirectory(dir); + SetParameters(); } void EVBMainFrame::DisplayCMap(const char* file) { fCMapField->SetText(file); - fBuilder.SetChannelMap(file); + SetParameters(); } void EVBMainFrame::DisplaySMap(const char* file) { fSMapField->SetText(file); - fBuilder.SetBoardShiftFile(file); + SetParameters(); } void EVBMainFrame::DisplayScaler(const char* file) { fScalerField->SetText(file); - fBuilder.SetScalerFile(file); + SetParameters(); } void EVBMainFrame::DisplayCut(const char* file) { fCutField->SetText(file); - fBuilder.SetCutList(file); + SetParameters(); } void EVBMainFrame::SaveConfig(const char* file) { std::string filename = file; - fBuilder.WriteConfigFile(filename); + m_builder.WriteConfigFile(filename); } void EVBMainFrame::LoadConfig(const char* file) { std::string filename = file; - fBuilder.ReadConfigFile(filename); + m_builder.ReadConfigFile(filename); + m_parameters = m_builder.GetParameters(); - fWorkField->SetText(fBuilder.GetWorkDirectory().c_str()); - fCMapField->SetText(fBuilder.GetChannelMap().c_str()); - fSMapField->SetText(fBuilder.GetBoardShiftFile().c_str()); - fCutField->SetText(fBuilder.GetCutList().c_str()); - fScalerField->SetText(fBuilder.GetScalerFile().c_str()); + fWorkField->SetText(m_parameters.workspaceDir.c_str()); + fCMapField->SetText(m_parameters.channelMapFile.c_str()); + fSMapField->SetText(m_parameters.timeShiftFile.c_str()); + fCutField->SetText(m_parameters.cutListFile.c_str()); + fScalerField->SetText(m_parameters.scalerFile.c_str()); - fZTField->SetIntNumber(fBuilder.GetTargetZ()); - fATField->SetIntNumber(fBuilder.GetTargetA()); - fZPField->SetIntNumber(fBuilder.GetProjectileZ()); - fAPField->SetIntNumber(fBuilder.GetProjectileA()); - fZEField->SetIntNumber(fBuilder.GetEjectileZ()); - fAEField->SetIntNumber(fBuilder.GetEjectileA()); - fBKEField->SetNumber(fBuilder.GetBeamKE()); - fBField->SetNumber(fBuilder.GetBField()); - fThetaField->SetNumber(fBuilder.GetTheta()); + fZTField->SetIntNumber(m_parameters.ZT); + fATField->SetIntNumber(m_parameters.AT); + fZPField->SetIntNumber(m_parameters.ZP); + fAPField->SetIntNumber(m_parameters.AP); + fZEField->SetIntNumber(m_parameters.ZE); + fAEField->SetIntNumber(m_parameters.AE); + fBKEField->SetNumber(m_parameters.beamEnergy); + fBField->SetNumber(m_parameters.BField); + fThetaField->SetNumber(m_parameters.spsAngle); - fSlowWindowField->SetNumber(fBuilder.GetSlowCoincidenceWindow()); - fFastSABREField->SetNumber(fBuilder.GetFastWindowSABRE()); - fFastICField->SetNumber(fBuilder.GetFastWindowIonChamber()); + fSlowWindowField->SetNumber(m_parameters.slowCoincidenceWindow); + fFastSABREField->SetNumber(m_parameters.fastCoincidenceWindowSABRE); + fFastICField->SetNumber(m_parameters.fastCoincidenceWindowIonCh); - fRMaxField->SetIntNumber(fBuilder.GetRunMax()); - fRMinField->SetIntNumber(fBuilder.GetRunMin()); + fRMaxField->SetIntNumber(m_parameters.runMax); + fRMinField->SetIntNumber(m_parameters.runMin); } -void EVBMainFrame::UpdateWorkdir() -{ - const char* dir = fWorkField->GetText(); - fBuilder.SetWorkDirectory(dir); -} - -void EVBMainFrame::UpdateSMap() -{ - const char* file = fSMapField->GetText(); - fBuilder.SetBoardShiftFile(file); -} - -void EVBMainFrame::UpdateCMap() -{ - const char* file = fCMapField->GetText(); - fBuilder.SetChannelMap(file); -} - -void EVBMainFrame::UpdateScaler() -{ - const char* file = fScalerField->GetText(); - fBuilder.SetScalerFile(file); -} - -void EVBMainFrame::UpdateCut() -{ - const char* file = fCutField->GetText(); - fBuilder.SetCutList(file); -} - -void EVBMainFrame::RunPlot() -{ - fBuilder.PlotHistograms(); -} - -void EVBMainFrame::RunMerge(const char* file, const char* dir) {} - void EVBMainFrame::DisableAllInput() { fRunButton->SetState(kButtonDisabled); diff --git a/src/guidict/EVBMainFrame.h b/src/guidict/EVBMainFrame.h index 0afb519..3ab2419 100644 --- a/src/guidict/EVBMainFrame.h +++ b/src/guidict/EVBMainFrame.h @@ -1,6 +1,7 @@ #ifndef EVBMAINFRAME_H #define EVBMAINFRAME_H +#include "../EventBuilder.h" #include #include #include @@ -38,13 +39,6 @@ public: void DisplayCut(const char* file); void SaveConfig(const char* file); void LoadConfig(const char* file); - void UpdateWorkdir(); - void UpdateCMap(); - void UpdateSMap(); - void UpdateScaler(); - void UpdateCut(); - void RunPlot(); - void RunMerge(const char* dir, const char* file); void DisableAllInput(); void EnableAllInput(); void SetProgressBarPosition(long value, long total); @@ -98,7 +92,8 @@ private: TGFileInfo* fInfo; - EventBuilder::EVBApp fBuilder; + EventBuilder::EVBApp m_builder; + EventBuilder::EVBParameters m_parameters; int counter; UInt_t MAIN_W, MAIN_H;