mirror of
https://github.com/sesps/SPS_SABRE_EventBuilder.git
synced 2024-11-22 10:08:50 -05:00
Big update. Finish implementation of EVBWorkspace. Remove unnecessary includes. Note that std::filesystem clashes with ROOT GUI libs.
This commit is contained in:
parent
22c1647ab1
commit
8ecfe5e3f8
|
@ -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
|
||||
Data_CH5@V1730_89 beamint
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
add_subdirectory(spsdict)
|
||||
add_subdirectory(guidict)
|
||||
add_subdirectory(evb)
|
||||
add_subdirectory(guidict)
|
||||
|
||||
|
||||
add_executable(EventBuilder)
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
//ROOT
|
||||
#include <TROOT.h>
|
||||
|
|
|
@ -44,6 +44,7 @@ target_sources(EventBuilderCore PRIVATE
|
|||
SlowSort.h
|
||||
EVBWorkspace.cpp
|
||||
EVBWorkspace.h
|
||||
EVBParameters.h
|
||||
)
|
||||
|
||||
target_link_libraries(EventBuilderCore PUBLIC
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
Written by G.W. McCann Oct. 2020
|
||||
*/
|
||||
#include "EventBuilder.h"
|
||||
#include "ChannelMap.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<EVBWorkspace>& 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<Long64_t>(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)
|
||||
|
@ -133,8 +128,9 @@ namespace EventBuilder {
|
|||
for(unsigned int i=startIndex; i<m_datafiles.size(); i++)
|
||||
{
|
||||
if(m_datafiles[i].CheckHitHasBeenUsed())
|
||||
{
|
||||
m_datafiles[i].GetNextHit();
|
||||
|
||||
}
|
||||
if(m_datafiles[i].IsEOF())
|
||||
{
|
||||
if(i == startIndex)
|
||||
|
@ -259,7 +255,8 @@ namespace EventBuilder {
|
|||
{
|
||||
event = coincidizer.GetEvent();
|
||||
outtree->Fill();
|
||||
if(killFlag) break;
|
||||
if(killFlag)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <TParameter.h>
|
||||
|
||||
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<EVBWorkspace>& 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<EVBWorkspace> m_workspace;
|
||||
|
||||
std::vector<CompassFile> m_datafiles;
|
||||
unsigned int startIndex; //this is the file we start looking at; increases as we finish files.
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "CutHandler.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
|
|
@ -6,20 +6,15 @@
|
|||
|
||||
Written by G.W. McCann Oct. 2020
|
||||
*/
|
||||
#include "EventBuilder.h"
|
||||
#include <cstdlib>
|
||||
#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/";
|
||||
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());
|
||||
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);
|
||||
sys_return = system(wipe_command.c_str());
|
||||
|
||||
++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::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,60 +223,57 @@ 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/";
|
||||
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 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;
|
||||
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());
|
||||
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);
|
||||
sys_return = system(wipe_command.c_str());
|
||||
count++;
|
||||
EVB_INFO("Finished converting");
|
||||
++count;
|
||||
}
|
||||
if(count==0)
|
||||
EVB_WARN("Conversion failed, no archives were found!");
|
||||
else
|
||||
EVB_INFO("Conversion complete.");
|
||||
m_workspace->ClearTempDirectory();
|
||||
}
|
||||
|
||||
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/";
|
||||
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::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);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -265,40 +281,37 @@ namespace EventBuilder {
|
|||
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());
|
||||
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);
|
||||
sys_return = system(wipe_command.c_str());
|
||||
count++;
|
||||
++count;
|
||||
}
|
||||
if(count==0)
|
||||
EVB_WARN("Conversion failed, no archives were found!");
|
||||
else
|
||||
EVB_INFO("Conversion complete.");
|
||||
m_workspace->ClearTempDirectory();
|
||||
}
|
||||
|
||||
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/";
|
||||
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);
|
||||
|
||||
|
@ -306,41 +319,38 @@ namespace EventBuilder {
|
|||
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());
|
||||
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);
|
||||
sys_return = system(wipe_command.c_str());
|
||||
count++;
|
||||
++count;
|
||||
}
|
||||
if(count==0)
|
||||
EVB_WARN("Conversion failed, no archives were found!");
|
||||
else
|
||||
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::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);
|
||||
|
||||
|
@ -348,25 +358,22 @@ namespace EventBuilder {
|
|||
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());
|
||||
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);
|
||||
sys_return = system(wipe_command.c_str());
|
||||
count++;
|
||||
++count;
|
||||
}
|
||||
if(count==0)
|
||||
EVB_WARN("Conversion failed, no archives were found!");
|
||||
else
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -9,38 +9,12 @@
|
|||
#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<EVBWorkspace> m_workspace;
|
||||
double m_progressFraction;
|
||||
ProgressCallbackFunc m_progressCallback;
|
||||
|
||||
|
|
34
src/evb/EVBParameters.h
Normal file
34
src/evb/EVBParameters.h
Normal file
|
@ -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
|
|
@ -1,8 +1,11 @@
|
|||
#include "EVBWorkspace.h"
|
||||
#include <filesystem>
|
||||
#include <TFile.h>
|
||||
#include <TChain.h>
|
||||
|
||||
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<std::string> EVBWorkspace::GetBinaryRunRange(int runMin, int runMax)
|
||||
{
|
||||
std::vector<std::string> list;
|
||||
|
@ -104,6 +121,29 @@ namespace EventBuilder {
|
|||
return list;
|
||||
}
|
||||
|
||||
std::vector<std::string> EVBWorkspace::GetAnalyzedRunRange(int runMin, int runMax)
|
||||
{
|
||||
std::vector<std::string> 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<std::string> EVBWorkspace::GetTempFiles()
|
||||
{
|
||||
std::vector<std::string> list;
|
||||
|
@ -115,4 +155,50 @@ namespace EventBuilder {
|
|||
|
||||
return list;
|
||||
}
|
||||
|
||||
bool EVBWorkspace::ClearTempDirectory()
|
||||
{
|
||||
std::vector<std::filesystem::path> 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; i<files.size(); i++)
|
||||
{
|
||||
if(!std::filesystem::remove(files[i]))
|
||||
{
|
||||
EVB_ERROR("Unable to clear temp directory {0}! File-like entry {1} could not be deleted. Please manually clear the directory.",
|
||||
m_tempDir, files[i].string());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EVBWorkspace::MergeAnalyzedFiles(const std::string& outputname, int runMin, int runMax)
|
||||
{
|
||||
auto files = GetAnalyzedRunRange(runMin, runMax);
|
||||
if(files.size() == 0)
|
||||
return false;
|
||||
|
||||
TFile* output = TFile::Open(outputname.c_str(), "RECREATE");
|
||||
if(!output->IsOpen())
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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<std::string> GetBinaryRunRange(int runMin, int runMax);
|
||||
std::string GetBinaryRun(int run);
|
||||
std::vector<std::string> GetAnalyzedRunRange(int runMin, int runMax);
|
||||
|
||||
bool UnpackBinaryRunToTemp(int run); //Currently Linux/MacOS only. Windows support to come.
|
||||
std::vector<std::string> 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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "EventBuilder.h"
|
||||
#include <cmath>
|
||||
#include "MassLookup.h"
|
||||
#include "FP_kinematics.h"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "FastSort.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "FlagHandler.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
Written by G.W. McCann Oct. 2020
|
||||
*/
|
||||
#include "EventBuilder.h"
|
||||
#include "OrderChecker.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include "EventBuilder.h"
|
||||
#include "RunCollector.h"
|
||||
#include <TSystemDirectory.h>
|
||||
#include <TSystemFile.h>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
*
|
||||
* Position calibrations swapped as of Aug. 2021 due to detector fixes -- GWM
|
||||
*/
|
||||
#include "EventBuilder.h"
|
||||
#include "SFPAnalyzer.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*Created Jan 2020 by GWM
|
||||
*/
|
||||
|
||||
#include "EventBuilder.h"
|
||||
#include "SFPPlotter.h"
|
||||
#include <TSystem.h>
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
Written by G.W. McCann Oct. 2020
|
||||
*/
|
||||
#include "EventBuilder.h"
|
||||
#include "ShiftMap.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*
|
||||
*Refurbished and updated Jan 2020 GWM
|
||||
*/
|
||||
#include "EventBuilder.h"
|
||||
#include "SlowSort.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
Written by G.W. McCann Oct. 2020
|
||||
*/
|
||||
#include "EventBuilder.h"
|
||||
#include "Stopwatch.h"
|
||||
|
||||
namespace EventBuilder {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef EVBMAINFRAME_H
|
||||
#define EVBMAINFRAME_H
|
||||
|
||||
#include "../EventBuilder.h"
|
||||
#include <TGClient.h>
|
||||
#include <TGWindow.h>
|
||||
#include <TGFrame.h>
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user