2021-07-13 16:36:41 -04:00
|
|
|
/*
|
2021-12-13 12:28:56 -05:00
|
|
|
EVBApp.cpp
|
2021-07-13 16:36:41 -04:00
|
|
|
Class which represents the API of the event building environment. Wraps together the core concepts
|
|
|
|
of the event builder, from conversion to plotting. Even intended to be able to archive data.
|
|
|
|
Currently under development.
|
|
|
|
|
|
|
|
Written by G.W. McCann Oct. 2020
|
|
|
|
*/
|
2021-12-18 15:40:53 -05:00
|
|
|
#include "EventBuilder.h"
|
2021-07-13 16:36:41 -04:00
|
|
|
#include <cstdlib>
|
2021-12-13 12:28:56 -05:00
|
|
|
#include "EVBApp.h"
|
2021-07-13 16:36:41 -04:00
|
|
|
#include "RunCollector.h"
|
|
|
|
#include "CompassRun.h"
|
|
|
|
#include "SlowSort.h"
|
|
|
|
#include "FastSort.h"
|
|
|
|
#include "SFPAnalyzer.h"
|
|
|
|
#include "SFPPlotter.h"
|
|
|
|
|
2021-12-15 12:08:12 -05:00
|
|
|
namespace EventBuilder {
|
|
|
|
|
|
|
|
EVBApp::EVBApp() :
|
|
|
|
m_rmin(0), m_rmax(0), m_ZT(0), m_AT(0), m_ZP(0), m_AP(0), m_ZE(0), m_AE(0), m_ZR(0), m_AR(0),
|
2021-12-16 17:38:58 -05:00
|
|
|
m_B(0), m_Theta(0), m_BKE(0), m_progressFraction(0.1), m_workspace("none"), m_mapfile("none"), m_shiftfile("none"),
|
2021-12-18 15:40:53 -05:00
|
|
|
m_cutList("none"), m_scalerfile("none"), m_SlowWindow(0), m_FastWindowIonCh(0), m_FastWindowSABRE(0)
|
|
|
|
{
|
2021-12-16 17:38:58 -05:00
|
|
|
SetProgressCallbackFunc(BIND_PROGRESS_CALLBACK_FUNCTION(EVBApp::DefaultProgressCallback));
|
2021-07-13 16:36:41 -04:00
|
|
|
}
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
EVBApp::~EVBApp()
|
2021-12-13 12:28:56 -05:00
|
|
|
{
|
2021-07-13 16:36:41 -04:00
|
|
|
}
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-16 17:38:58 -05:00
|
|
|
void EVBApp::DefaultProgressCallback(long curVal, long totalVal)
|
|
|
|
{
|
2021-12-18 15:40:53 -05:00
|
|
|
double fraction = ((double)curVal)/totalVal;
|
2021-12-16 17:38:58 -05:00
|
|
|
EVB_INFO("Percent of run built: {0}", fraction*100);
|
|
|
|
}
|
|
|
|
|
2021-12-15 12:08:12 -05:00
|
|
|
bool EVBApp::ReadConfigFile(const std::string& fullpath)
|
2021-12-13 12:28:56 -05:00
|
|
|
{
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Reading in EVB configuration from file {0}...", fullpath);
|
2021-12-15 12:08:12 -05:00
|
|
|
std::ifstream input(fullpath);
|
|
|
|
if(!input.is_open())
|
|
|
|
{
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_WARN("Read of EVB config failed, unable to open input file!");
|
2021-12-15 12:08:12 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
std::string junk;
|
|
|
|
|
|
|
|
std::getline(input, junk);
|
|
|
|
input>>junk>>m_workspace;
|
|
|
|
input>>junk;
|
|
|
|
std::getline(input, junk);
|
|
|
|
std::getline(input, junk);
|
|
|
|
input>>junk>>m_mapfile;
|
|
|
|
input>>junk>>m_scalerfile;
|
|
|
|
input>>junk>>m_cutList;
|
|
|
|
input>>junk>>m_ZT>>junk>>m_AT;
|
|
|
|
input>>junk>>m_ZP>>junk>>m_AP;
|
|
|
|
input>>junk>>m_ZE>>junk>>m_AE;
|
|
|
|
input>>junk>>m_B;
|
|
|
|
input>>junk>>m_BKE;
|
|
|
|
input>>junk>>m_Theta;
|
|
|
|
input>>junk;
|
|
|
|
std::getline(input, junk);
|
|
|
|
std::getline(input, junk);
|
|
|
|
input>>junk>>m_shiftfile;
|
|
|
|
input>>junk>>m_SlowWindow;
|
|
|
|
input>>junk>>m_FastWindowIonCh;
|
|
|
|
input>>junk>>m_FastWindowSABRE;
|
|
|
|
input>>junk;
|
|
|
|
std::getline(input, junk);
|
|
|
|
std::getline(input, junk);
|
|
|
|
input>>junk>>m_rmin;
|
|
|
|
input>>junk>>m_rmax;
|
|
|
|
|
|
|
|
input.close();
|
|
|
|
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Successfully loaded EVB config.");
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
return true;
|
2021-07-13 16:36:41 -04:00
|
|
|
}
|
|
|
|
|
2021-12-15 12:08:12 -05:00
|
|
|
void EVBApp::WriteConfigFile(const std::string& fullpath)
|
2021-12-13 12:28:56 -05:00
|
|
|
{
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Writing EVB config to file {0}...",fullpath);
|
2021-12-15 12:08:12 -05:00
|
|
|
std::ofstream output(fullpath);
|
|
|
|
if(!output.is_open())
|
|
|
|
{
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_WARN("Failed to write to config to file {0}, unable to open file!", fullpath);
|
2021-12-15 12:08:12 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
output<<"-------Data Location----------"<<std::endl;
|
|
|
|
output<<"WorkspaceDirectory: "<<m_workspace<<std::endl;
|
|
|
|
output<<"-------------------------------"<<std::endl;
|
|
|
|
output<<"------Experimental Inputs------"<<std::endl;
|
|
|
|
output<<"ChannelMapFile: "<<m_mapfile<<std::endl;
|
|
|
|
output<<"ScalerFile: "<<m_scalerfile<<std::endl;
|
|
|
|
output<<"CutListFile: "<<m_cutList<<std::endl;
|
|
|
|
output<<"ZT: "<<m_ZT<<std::endl;
|
|
|
|
output<<"AT: "<<m_AT<<std::endl;
|
|
|
|
output<<"ZP: "<<m_ZP<<std::endl;
|
|
|
|
output<<"AP: "<<m_AP<<std::endl;
|
|
|
|
output<<"ZE: "<<m_ZE<<std::endl;
|
|
|
|
output<<"AE: "<<m_AE<<std::endl;
|
|
|
|
output<<"BField(G): "<<m_B<<std::endl;
|
|
|
|
output<<"BeamKE(MeV): "<<m_BKE<<std::endl;
|
|
|
|
output<<"Theta(deg): "<<m_Theta<<std::endl;
|
|
|
|
output<<"-------------------------------"<<std::endl;
|
|
|
|
output<<"-------Timing Information------"<<std::endl;
|
|
|
|
output<<"BoardOffsetFile: "<<m_shiftfile<<std::endl;
|
|
|
|
output<<"SlowCoincidenceWindow(ps): "<<m_SlowWindow<<std::endl;
|
|
|
|
output<<"FastCoincidenceWindow_IonCh(ps): "<<m_FastWindowIonCh<<std::endl;
|
|
|
|
output<<"FastCoincidenceWindow_SABRE(ps): "<<m_FastWindowSABRE<<std::endl;
|
|
|
|
output<<"-------------------------------"<<std::endl;
|
|
|
|
output<<"--------Run Information--------"<<std::endl;
|
|
|
|
output<<"MinRun: "<<m_rmin<<std::endl;
|
|
|
|
output<<"MaxRun: "<<m_rmax<<std::endl;
|
|
|
|
output<<"-------------------------------"<<std::endl;
|
|
|
|
|
|
|
|
output.close();
|
|
|
|
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Successfully wrote config to file.");
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-07-13 16:36:41 -04:00
|
|
|
}
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
void EVBApp::PlotHistograms()
|
2021-12-13 12:28:56 -05:00
|
|
|
{
|
2021-12-15 12:08:12 -05:00
|
|
|
std::string analyze_dir = m_workspace+"/analyzed/";
|
|
|
|
std::string plot_file = m_workspace+"/histograms/run_"+std::to_string(m_rmin)+"_"+std::to_string(m_rmax)+".root";
|
|
|
|
SFPPlotter grammer;
|
2021-12-16 17:38:58 -05:00
|
|
|
grammer.SetProgressCallbackFunc(m_progressCallback);
|
|
|
|
grammer.SetProgressFraction(m_progressFraction);
|
2021-12-15 12:08:12 -05:00
|
|
|
grammer.ApplyCutlist(m_cutList);
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Generating histograms from analyzed runs [{0}, {1}] with Cut List {2}...", m_rmin, m_rmax, m_cutList);
|
|
|
|
EVB_INFO("Output file will be named {0}",plot_file);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
grabber.SetSearchParams(analyze_dir, "", ".root", m_rmin, m_rmax);
|
|
|
|
if(grabber.GrabFilesInRange())
|
|
|
|
{
|
|
|
|
grammer.Run(grabber.GetFileList(), plot_file);
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Finished.");
|
2021-12-15 12:08:12 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_ERROR("Unable to find analyzed run files at EVBApp::PlotHistograms()!");
|
2021-12-15 12:08:12 -05:00
|
|
|
}
|
2021-07-13 16:36:41 -04:00
|
|
|
}
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
void EVBApp::Convert2RawRoot()
|
2021-12-13 12:28:56 -05:00
|
|
|
{
|
2021-12-15 14:36:24 -05:00
|
|
|
int sys_return;
|
2021-12-15 12:08:12 -05:00
|
|
|
std::string rawroot_dir = m_workspace+"/raw_root/";
|
|
|
|
std::string unpack_dir = m_workspace+"/temp_binary/";
|
|
|
|
std::string binary_dir = m_workspace+"/raw_binary/";
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Converting binary archives to ROOT files over run range [{0}, {1}]",m_rmin,m_rmax);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
grabber.SetSearchParams(binary_dir, "", ".tar.gz",0,1000);
|
|
|
|
|
|
|
|
std::string rawfile, binfile;
|
|
|
|
std::string unpack_command, wipe_command;
|
|
|
|
|
|
|
|
CompassRun converter(unpack_dir);
|
|
|
|
converter.SetShiftMap(m_shiftfile);
|
|
|
|
converter.SetScalerInput(m_scalerfile);
|
2021-12-16 17:38:58 -05:00
|
|
|
converter.SetProgressCallbackFunc(m_progressCallback);
|
|
|
|
converter.SetProgressFraction(m_progressFraction);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Beginning conversion...");
|
2021-12-15 12:08:12 -05:00
|
|
|
for(int i=m_rmin; i<=m_rmax; i++)
|
|
|
|
{
|
|
|
|
binfile = grabber.GrabFile(i);
|
|
|
|
if(binfile == "")
|
|
|
|
continue;
|
|
|
|
converter.SetRunNumber(i);
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Converting file {0}...", binfile);
|
2021-12-15 12:08:12 -05:00
|
|
|
rawfile = rawroot_dir + "compass_run_"+ std::to_string(i) + ".root";
|
|
|
|
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
2022-05-19 14:32:58 -04:00
|
|
|
wipe_command = "rm -r "+unpack_dir+"*.BIN";
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 14:36:24 -05:00
|
|
|
sys_return = system(unpack_command.c_str());
|
2021-12-15 12:08:12 -05:00
|
|
|
converter.Convert2RawRoot(rawfile);
|
2021-12-15 14:36:24 -05:00
|
|
|
sys_return = system(wipe_command.c_str());
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
}
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Conversion complete.");
|
2021-07-13 16:36:41 -04:00
|
|
|
}
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
void EVBApp::MergeROOTFiles()
|
2021-12-13 12:28:56 -05:00
|
|
|
{
|
2021-12-15 12:08:12 -05:00
|
|
|
std::string merge_file = m_workspace+"/merged/run_"+std::to_string(m_rmin)+"_"+std::to_string(m_rmax)+".root";
|
|
|
|
std::string file_dir = m_workspace+"/analyzed/";
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Merging ROOT files into single file for runs in range [{0}, {1}]", m_rmin, m_rmax);
|
|
|
|
EVB_INFO("Merged file will be named {0}", merge_file);
|
2021-12-15 12:08:12 -05:00
|
|
|
std::string prefix = "";
|
|
|
|
std::string suffix = ".root";
|
|
|
|
grabber.SetSearchParams(file_dir, prefix, suffix,m_rmin,m_rmax);
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Starting merge...");
|
2021-12-15 12:08:12 -05:00
|
|
|
if(!grabber.Merge_TChain(merge_file))
|
|
|
|
{
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_ERROR("Unable to find files for merge at EVBApp::MergeROOTFiles()!");
|
2021-12-15 12:08:12 -05:00
|
|
|
return;
|
|
|
|
}
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Finished.");
|
2021-07-13 16:36:41 -04:00
|
|
|
}
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
void EVBApp::Convert2SortedRoot()
|
2021-12-13 12:28:56 -05:00
|
|
|
{
|
2021-12-15 14:36:24 -05:00
|
|
|
int sys_return;
|
2021-12-15 12:08:12 -05:00
|
|
|
std::string sortroot_dir = m_workspace+"/sorted/";
|
|
|
|
std::string unpack_dir = m_workspace+"/temp_binary/";
|
|
|
|
std::string binary_dir = m_workspace+"/raw_binary/";
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Converting binary archives to event built ROOT files over run range [{0}, {1}]",m_rmin,m_rmax);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
|
|
|
|
|
|
|
|
std::string sortfile, binfile;
|
|
|
|
std::string unpack_command, wipe_command;
|
|
|
|
|
|
|
|
CompassRun converter(unpack_dir);
|
|
|
|
converter.SetShiftMap(m_shiftfile);
|
|
|
|
converter.SetScalerInput(m_scalerfile);
|
2021-12-16 17:38:58 -05:00
|
|
|
converter.SetProgressCallbackFunc(m_progressCallback);
|
|
|
|
converter.SetProgressFraction(m_progressFraction);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Beginning conversion...");
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 17:35:31 -05:00
|
|
|
int count=0;
|
2021-12-15 12:08:12 -05:00
|
|
|
for(int i=m_rmin; i<= m_rmax; i++)
|
|
|
|
{
|
|
|
|
binfile = grabber.GrabFile(i);
|
|
|
|
if(binfile == "")
|
|
|
|
continue;
|
|
|
|
converter.SetRunNumber(i);
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Converting file {0}...",binfile);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
sortfile = sortroot_dir +"run_"+std::to_string(i)+ ".root";
|
|
|
|
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
2022-05-19 14:32:58 -04:00
|
|
|
wipe_command = "rm -r "+unpack_dir+"*.BIN";
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 14:36:24 -05:00
|
|
|
sys_return = system(unpack_command.c_str());
|
2021-12-15 12:08:12 -05:00
|
|
|
converter.Convert2SortedRoot(sortfile, m_mapfile, m_SlowWindow);
|
2021-12-15 14:36:24 -05:00
|
|
|
sys_return = system(wipe_command.c_str());
|
2021-12-15 17:35:31 -05:00
|
|
|
count++;
|
2021-12-15 12:08:12 -05:00
|
|
|
}
|
2021-12-15 17:35:31 -05:00
|
|
|
if(count==0)
|
|
|
|
EVB_WARN("Conversion failed, no archives were found!");
|
|
|
|
else
|
|
|
|
EVB_INFO("Conversion complete.");
|
2021-07-13 16:36:41 -04:00
|
|
|
}
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
void EVBApp::Convert2FastSortedRoot() {
|
2021-12-15 14:36:24 -05:00
|
|
|
int sys_return;
|
2021-12-15 12:08:12 -05:00
|
|
|
std::string sortroot_dir = m_workspace+"/fast/";
|
|
|
|
std::string unpack_dir = m_workspace+"/temp_binary/";
|
|
|
|
std::string binary_dir = m_workspace+"/raw_binary/";
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Converting binary archives to fast event built ROOT files over run range [{0}, {1}]",m_rmin,m_rmax);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
|
|
|
|
|
|
|
|
std::string sortfile, binfile;
|
|
|
|
std::string unpack_command, wipe_command;
|
|
|
|
|
|
|
|
CompassRun converter(unpack_dir);
|
|
|
|
converter.SetShiftMap(m_shiftfile);
|
|
|
|
converter.SetScalerInput(m_scalerfile);
|
2021-12-16 17:38:58 -05:00
|
|
|
converter.SetProgressCallbackFunc(m_progressCallback);
|
|
|
|
converter.SetProgressFraction(m_progressFraction);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Beginning conversion...");
|
|
|
|
int count=0;
|
2021-12-15 12:08:12 -05:00
|
|
|
for(int i=m_rmin; i<=m_rmax; i++)
|
|
|
|
{
|
|
|
|
binfile = grabber.GrabFile(i);
|
|
|
|
if(binfile == "")
|
|
|
|
continue;
|
|
|
|
converter.SetRunNumber(i);
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Converting file {0}...",binfile);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
|
|
|
|
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
2022-05-19 14:32:58 -04:00
|
|
|
wipe_command = "rm -r "+unpack_dir+"*.BIN";
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 14:36:24 -05:00
|
|
|
sys_return = system(unpack_command.c_str());
|
2021-12-15 12:08:12 -05:00
|
|
|
converter.Convert2FastSortedRoot(sortfile, m_mapfile, m_SlowWindow, m_FastWindowSABRE, m_FastWindowIonCh);
|
2021-12-15 14:36:24 -05:00
|
|
|
sys_return = system(wipe_command.c_str());
|
2021-12-15 17:35:31 -05:00
|
|
|
count++;
|
2021-12-15 12:08:12 -05:00
|
|
|
}
|
2021-12-15 17:35:31 -05:00
|
|
|
if(count==0)
|
|
|
|
EVB_WARN("Conversion failed, no archives were found!");
|
|
|
|
else
|
|
|
|
EVB_INFO("Conversion complete.");
|
2021-12-15 12:08:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void EVBApp::Convert2SlowAnalyzedRoot() {
|
2021-12-15 14:36:24 -05:00
|
|
|
int sys_return;
|
2021-12-15 12:08:12 -05:00
|
|
|
std::string sortroot_dir = m_workspace+"/analyzed/";
|
|
|
|
std::string unpack_dir = m_workspace+"/temp_binary/";
|
|
|
|
std::string binary_dir = m_workspace+"/raw_binary/";
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Converting binary archives to analyzed event built ROOT files over run range [{0}, {1}]",m_rmin,m_rmax);
|
|
|
|
|
2021-12-15 12:08:12 -05:00
|
|
|
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin, m_rmax);
|
|
|
|
|
|
|
|
std::string sortfile, binfile;
|
|
|
|
std::string unpack_command, wipe_command;
|
|
|
|
|
|
|
|
CompassRun converter(unpack_dir);
|
|
|
|
converter.SetShiftMap(m_shiftfile);
|
|
|
|
converter.SetScalerInput(m_scalerfile);
|
2021-12-16 17:38:58 -05:00
|
|
|
converter.SetProgressCallbackFunc(m_progressCallback);
|
|
|
|
converter.SetProgressFraction(m_progressFraction);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Beginning conversion...");
|
|
|
|
int count=0;
|
2021-12-15 12:08:12 -05:00
|
|
|
for(int i=m_rmin; i<=m_rmax; i++)
|
|
|
|
{
|
|
|
|
binfile = grabber.GrabFile(i);
|
|
|
|
if(binfile == "")
|
|
|
|
continue;
|
|
|
|
converter.SetRunNumber(i);
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Converting file {0}...",binfile);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
|
|
|
|
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
2022-05-19 14:32:58 -04:00
|
|
|
wipe_command = "rm -r "+unpack_dir+"*.BIN";
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 14:36:24 -05:00
|
|
|
sys_return = system(unpack_command.c_str());
|
2021-12-15 12:08:12 -05:00
|
|
|
converter.Convert2SlowAnalyzedRoot(sortfile, m_mapfile, m_SlowWindow, m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_BKE, m_B, m_Theta);
|
2021-12-15 14:36:24 -05:00
|
|
|
sys_return = system(wipe_command.c_str());
|
2021-12-15 17:35:31 -05:00
|
|
|
count++;
|
2021-12-15 12:08:12 -05:00
|
|
|
}
|
2021-12-15 17:35:31 -05:00
|
|
|
if(count==0)
|
|
|
|
EVB_WARN("Conversion failed, no archives were found!");
|
|
|
|
else
|
|
|
|
EVB_INFO("Conversion complete.");
|
2021-12-15 12:08:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void EVBApp::Convert2FastAnalyzedRoot()
|
2021-12-13 12:28:56 -05:00
|
|
|
{
|
2021-12-15 14:36:24 -05:00
|
|
|
int sys_return;
|
2021-12-15 12:08:12 -05:00
|
|
|
std::string sortroot_dir = m_workspace+"/analyzed/";
|
|
|
|
std::string unpack_dir = m_workspace+"/temp_binary/";
|
|
|
|
std::string binary_dir = m_workspace+"/raw_binary/";
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Converting binary archives to analyzed fast event built ROOT files over run range [{0}, {1}]",m_rmin,m_rmax);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
|
|
|
|
|
|
|
|
std::string sortfile, binfile;
|
|
|
|
std::string unpack_command, wipe_command;
|
|
|
|
|
|
|
|
CompassRun converter(unpack_dir);
|
|
|
|
converter.SetShiftMap(m_shiftfile);
|
|
|
|
converter.SetScalerInput(m_scalerfile);
|
2021-12-16 17:38:58 -05:00
|
|
|
converter.SetProgressCallbackFunc(m_progressCallback);
|
|
|
|
converter.SetProgressFraction(m_progressFraction);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Beginning conversion...");
|
|
|
|
int count=0;
|
2021-12-15 12:08:12 -05:00
|
|
|
for(int i=m_rmin; i<=m_rmax; i++)
|
|
|
|
{
|
|
|
|
binfile = grabber.GrabFile(i);
|
|
|
|
if(binfile == "")
|
|
|
|
continue;
|
|
|
|
converter.SetRunNumber(i);
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_INFO("Converting file {0}...",binfile);
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
|
|
|
|
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
|
2022-05-19 14:32:58 -04:00
|
|
|
wipe_command = "rm -r "+unpack_dir+"*.BIN";
|
2021-12-15 12:08:12 -05:00
|
|
|
|
2021-12-15 14:36:24 -05:00
|
|
|
sys_return = system(unpack_command.c_str());
|
2021-12-15 12:08:12 -05:00
|
|
|
converter.Convert2FastAnalyzedRoot(sortfile, m_mapfile, m_SlowWindow, m_FastWindowSABRE, m_FastWindowIonCh, m_ZT, m_AT, m_ZP, m_AP, m_ZE, m_AE, m_BKE, m_B, m_Theta);
|
2021-12-15 14:36:24 -05:00
|
|
|
sys_return = system(wipe_command.c_str());
|
2021-12-15 17:35:31 -05:00
|
|
|
count++;
|
2021-12-15 12:08:12 -05:00
|
|
|
}
|
2021-12-15 17:35:31 -05:00
|
|
|
if(count==0)
|
|
|
|
EVB_WARN("Conversion failed, no archives were found!");
|
|
|
|
else
|
|
|
|
EVB_INFO("Conversion complete.");
|
2021-07-13 16:36:41 -04:00
|
|
|
}
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
bool EVBApp::SetKinematicParameters(int zt, int at, int zp, int ap, int ze, int ae, double b, double theta, double bke)
|
2021-12-13 12:28:56 -05:00
|
|
|
{
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
if((at + ap - ae) < 0 || (zt + zp - ze) < 0)
|
|
|
|
{
|
2021-12-15 17:35:31 -05:00
|
|
|
EVB_WARN("Invalid kinematic parameters, nucleon number not conserved! Parameters not set");
|
2021-12-15 12:08:12 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
m_ZT = zt; m_AT = at; m_ZP = zp; m_AP = ap; m_ZE = ze; m_AE = ae;
|
|
|
|
m_B = b; m_Theta = theta; m_BKE = bke;
|
|
|
|
|
|
|
|
m_ZR = (zt + zp - ze);
|
|
|
|
m_AR = (at + ap - ae);
|
2021-12-15 17:35:31 -05:00
|
|
|
|
|
|
|
EVB_TRACE("Kinematic paramters updated.");
|
2021-12-15 12:08:12 -05:00
|
|
|
|
|
|
|
return true;
|
2021-07-13 16:36:41 -04:00
|
|
|
}
|
|
|
|
|
2021-12-15 17:35:31 -05:00
|
|
|
|
2021-12-16 17:38:58 -05:00
|
|
|
void EVBApp::SetRunRange(int rmin, int rmax) { EVB_TRACE("Min Run, max run set to [{0}, {1}]", rmin, rmax); m_rmin = rmin; m_rmax = rmax; }
|
|
|
|
void EVBApp::SetWorkDirectory(const std::string& fullpath) { EVB_TRACE("Workspace set to {0}", fullpath); m_workspace = fullpath; }
|
|
|
|
void EVBApp::SetChannelMap(const std::string& name) { EVB_TRACE("Channel map set to {0}",name); m_mapfile = name; }
|
|
|
|
void EVBApp::SetBoardShiftFile(const std::string& name) { EVB_TRACE("Shift file set to {0}", name); m_shiftfile = name; }
|
|
|
|
void EVBApp::SetSlowCoincidenceWindow(double window) { EVB_TRACE("Slow Coincidence Window set to {0}",window); m_SlowWindow = window; }
|
|
|
|
void EVBApp::SetFastWindowIonChamber(double window) { EVB_TRACE("Fast Coinc. Window Ion Ch. set to {0}",window); m_FastWindowIonCh = window; }
|
|
|
|
void EVBApp::SetFastWindowSABRE(double window) { EVB_TRACE("Fast Coinc. Window SABRE set to {0}",window); m_FastWindowSABRE = window; }
|
|
|
|
void EVBApp::SetCutList(const std::string& name) { EVB_TRACE("Cut List set to {0}", name); m_cutList = name; }
|
|
|
|
void EVBApp::SetScalerFile(const std::string& fullpath) { EVB_TRACE("Scaler file set to {0}", fullpath); m_scalerfile = fullpath; }
|
2021-12-15 17:35:31 -05:00
|
|
|
|
2021-12-15 12:08:12 -05:00
|
|
|
}
|