std io replaced with spdlog, some minor cleanup here and there.

This commit is contained in:
Gordon McCann 2021-12-15 17:35:31 -05:00
parent c6213aa1ef
commit bd9e2cb520
15 changed files with 154 additions and 198 deletions

View File

@ -26,7 +26,7 @@
#include <TCutG.h>
//Mine
#include "evb/Logger.h"
#include "Logger.h"
#endif

View File

@ -175,23 +175,25 @@ namespace EventBuilder {
if(!m_smap.IsValid())
{
std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl;
std::cerr<<"Shifts will be locked to 0"<<std::endl;
EVB_WARN("Bad shift map ({0}) at CompassRun::Convert(), shifts all set to 0.", m_smap.GetFilename());
}
SetScalers();
if(!GetBinaryFiles())
{
std::cerr<<"Unable to open a file!"<<std::endl;
EVB_ERROR("Unable to find binary files at CompassRun::Convert(), exiting!");
return;
}
unsigned int count = 0, flush = m_totalHits*0.1, flush_count = 0;
if(m_pb)
{
flush = m_totalHits*0.01;
SetProgressBar();
}
startIndex = 0; //Reset the startIndex
unsigned int count = 0, flush = m_totalHits*0.01, flush_count = 0;
if(flush == 0)
flush = 1;
while(true)
@ -209,7 +211,7 @@ namespace EventBuilder {
{
count = 0;
flush_count++;
std::cout<<"\rPercent of run built: "<<flush_count*10<<"%"<<std::flush;
EVB_INFO("Percent of run built: {0} %",flush_count*10);
}
}
@ -235,25 +237,27 @@ namespace EventBuilder {
if(!m_smap.IsValid())
{
std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl;
std::cerr<<"Shifts will be locked to 0"<<std::endl;
EVB_WARN("Bad shift map ({0}) at CompassRun::Convert2SortedRoot(), shifts all set to 0.", m_smap.GetFilename());
}
SetScalers();
if(!GetBinaryFiles())
{
std::cerr<<"Unable to open a file!"<<std::endl;
EVB_ERROR("Unable to find binary files at CompassRun::Convert2SortedRoot(), exiting!");
return;
}
unsigned int count = 0, flush = m_totalHits*0.1, flush_count = 0;
if(m_pb)
{
flush = m_totalHits*0.01;
SetProgressBar();
}
startIndex = 0;
SlowSort coincidizer(window, mapfile);
bool killFlag = false;
unsigned int count = 0, flush = m_totalHits*0.01, flush_count = 0;
if(flush == 0)
flush = 1;
while(true)
@ -271,7 +275,7 @@ namespace EventBuilder {
{
count = 0;
flush_count++;
std::cout<<"\rPercent of run built: "<<flush_count*10<<"%"<<std::flush;
EVB_INFO("Percent of run built: {0} %",flush_count*10);
}
}
@ -309,20 +313,23 @@ namespace EventBuilder {
if(!m_smap.IsValid())
{
std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl;
std::cerr<<"Shifts will be locked to 0"<<std::endl;
EVB_WARN("Bad shift map ({0}) at CompassRun::Convert2FastSortedRoot(), shifts all set to 0.", m_smap.GetFilename());
}
SetScalers();
if(!GetBinaryFiles())
{
std::cerr<<"Unable to open a file!"<<std::endl;
EVB_ERROR("Unable to find binary files at CompassRun::Convert2FastSortedRoot(), exiting!");
return;
}
unsigned int count = 0, flush = m_totalHits*0.1, flush_count = 0;
if(m_pb)
{
flush = m_totalHits*0.01;
SetProgressBar();
}
startIndex = 0;
CoincEvent this_event;
@ -333,7 +340,6 @@ namespace EventBuilder {
FlagHandler flagger;
bool killFlag = false;
unsigned int count = 0, flush = m_totalHits*0.01, flush_count = 0;
if(flush == 0)
flush = 1;
while(true)
@ -351,7 +357,7 @@ namespace EventBuilder {
{
count = 0;
flush_count++;
std::cout<<"\rPercent of run built: "<<flush_count*10<<"%"<<std::flush;
EVB_INFO("Percent of run built: {0} %",flush_count*10);
}
}
@ -402,20 +408,23 @@ namespace EventBuilder {
if(!m_smap.IsValid())
{
std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl;
std::cerr<<"Shifts will be locked to 0"<<std::endl;
EVB_WARN("Bad shift map ({0}) at CompassRun::Convert2SlowAnalyzedRoot(), shifts all set to 0.", m_smap.GetFilename());
}
SetScalers();
if(!GetBinaryFiles())
{
std::cerr<<"Unable to open a file!"<<std::endl;
EVB_ERROR("Unable to find binary files at CompassRun::Convert2SlowAnalyzedRoot(), exiting!");
return;
}
unsigned int count = 0, flush = m_totalHits*0.1, flush_count = 0;
if(m_pb)
{
flush = m_totalHits*0.01;
SetProgressBar();
}
startIndex = 0;
CoincEvent this_event;
@ -435,7 +444,6 @@ namespace EventBuilder {
parvec.emplace_back("Theta", theta);
bool killFlag = false;
unsigned int count = 0, flush = m_totalHits*0.01, flush_count = 0;
if(flush == 0)
flush = 1;
while(true)
@ -453,7 +461,7 @@ namespace EventBuilder {
{
count = 0;
flush_count++;
std::cout<<"\rPercent of run built: "<<flush_count*10<<"%"<<std::flush;
EVB_INFO("Percent of run built: {0} %",flush_count*10);
}
}
@ -502,20 +510,23 @@ namespace EventBuilder {
if(!m_smap.IsValid())
{
std::cerr<<"Bad shift map at CompassRun::Convert()."<<std::endl;
std::cerr<<"Shifts will be locked to 0"<<std::endl;
EVB_WARN("Bad shift map ({0}) at CompassRun::Convert2FastAnalyzedRoot(), shifts all set to 0.", m_smap.GetFilename());
}
SetScalers();
if(!GetBinaryFiles())
{
std::cerr<<"Unable to open a file!"<<std::endl;
EVB_ERROR("Unable to find binary files at CompassRun::Convert2FastAnalyzedRoot(), exiting!");
return;
}
unsigned int count = 0, flush = m_totalHits*0.1, flush_count = 0;
if(m_pb)
{
flush = m_totalHits*0.01;
SetProgressBar();
}
startIndex = 0;
CoincEvent this_event;
@ -539,7 +550,6 @@ namespace EventBuilder {
FlagHandler flagger;
bool killFlag = false;
unsigned int count = 0, flush = m_totalHits*0.01, flush_count = 0;
if(flush == 0)
flush = 1;
while(true)
@ -557,7 +567,7 @@ namespace EventBuilder {
{
count = 0;
flush_count++;
std::cout<<"\rPercent of run built: "<<flush_count*10<<"%"<<std::flush;
EVB_INFO("Percent of run built: {0} %",flush_count*10);
}
}

View File

@ -53,9 +53,7 @@ namespace EventBuilder {
else
{
validFlag = false;
std::cerr<<"CutHandler has encountered a bad cut at file: "<<file<<"."<<std::endl;
std::cerr<<"The file either does not exist or does not contain a TCutG named CUTG"<<std::endl;
std::cerr<<"Cuts will not be used."<<std::endl;
EVB_WARN("CutHandler::SetCuts has encountered a bad file ({0}). The file either does not exist or doesn't contain a TCutG CUTG. Cuts ignored.", fname);
return;
}
}
@ -92,7 +90,7 @@ namespace EventBuilder {
auto yentry = varmap.find(y);
if(xentry == varmap.end() || yentry == varmap.end())
{
std::cerr<<"Unmapped variable called in CutHandler::IsInside()! Var names: "<<xentry->first<<" , "<<yentry->first<<std::endl;
EVB_WARN("Unmapped variable names at CutHandler::IsInside() (x:{0}, y:{1})! Cut not applied.", xentry->first, yentry->first);
return false;
}

View File

@ -30,11 +30,11 @@ namespace EventBuilder {
bool EVBApp::ReadConfigFile(const std::string& fullpath)
{
std::cout<<"Reading in configuration from file: "<<fullpath<<std::endl;
EVB_INFO("Reading in EVB configuration from file {0}...", fullpath);
std::ifstream input(fullpath);
if(!input.is_open())
{
std::cout<<"Read failed! Unable to open input file!"<<std::endl;
EVB_WARN("Read of EVB config failed, unable to open input file!");
return false;
}
std::string junk;
@ -68,7 +68,7 @@ namespace EventBuilder {
input.close();
std::cout<<"Completed."<<std::endl;
EVB_INFO("Successfully loaded EVB config.");
return true;
}
@ -76,11 +76,11 @@ namespace EventBuilder {
void EVBApp::WriteConfigFile(const std::string& fullpath)
{
std::cout<<"Writing out configuration to file: "<<fullpath<<std::endl;
EVB_INFO("Writing EVB config to file {0}...",fullpath);
std::ofstream output(fullpath);
if(!output.is_open())
{
std::cout<<"Write failed! Unable to open output file!"<<std::endl;
EVB_WARN("Failed to write to config to file {0}, unable to open file!", fullpath);
return;
}
@ -114,7 +114,7 @@ namespace EventBuilder {
output.close();
std::cout<<"Completed."<<std::endl;
EVB_INFO("Successfully wrote config to file.");
}
@ -124,28 +124,21 @@ namespace EventBuilder {
std::string plot_file = m_workspace+"/histograms/run_"+std::to_string(m_rmin)+"_"+std::to_string(m_rmax)+".root";
SFPPlotter grammer;
grammer.ApplyCutlist(m_cutList);
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
std::cout<<"Generating a histogram file from analyzed files"<<std::endl;
std::cout<<"Analyzed directory: "<<analyze_dir<<std::endl;
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
std::cout<<"Cut List File: "<<m_cutList<<std::endl;
std::cout<<"Histogram File: "<<plot_file<<std::endl;
EVB_INFO("Generating histograms from analyzed runs [{0}, {1}] with Cut List {2}...", m_rmin, m_rmax, m_cutList);
EVB_INFO("Output file will be named {0}",plot_file);
if(m_pb)
grammer.AttachProgressBar(m_pb);
grabber.SetSearchParams(analyze_dir, "", ".root", m_rmin, m_rmax);
if(grabber.GrabFilesInRange())
{
std::cout<<"Working...";
grammer.Run(grabber.GetFileList(), plot_file);
std::cout<<" Complete."<<std::endl;
EVB_INFO("Finished.");
}
else
{
std::cout<<"Unable to find files at PlotHistograms"<<std::endl;
EVB_ERROR("Unable to find analyzed run files at EVBApp::PlotHistograms()!");
}
std::cout<<"-------------------------------------------"<<std::endl;
}
void EVBApp::Convert2RawRoot()
@ -154,18 +147,10 @@ namespace EventBuilder {
std::string rawroot_dir = m_workspace+"/raw_root/";
std::string unpack_dir = m_workspace+"/temp_binary/";
std::string binary_dir = m_workspace+"/raw_binary/";
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
EVB_INFO("Converting binary archives to ROOT files over run range [{0}, {1}]",m_rmin,m_rmax);
grabber.SetSearchParams(binary_dir, "", ".tar.gz",0,1000);
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
std::string rawfile, binfile;
std::string unpack_command, wipe_command;
@ -175,16 +160,14 @@ namespace EventBuilder {
if(m_pb)
converter.AttachProgressBar(m_pb);
std::cout<<"Beginning conversion..."<<std::endl;
EVB_INFO("Beginning conversion...");
for(int i=m_rmin; i<=m_rmax; i++)
{
binfile = grabber.GrabFile(i);
if(binfile == "")
continue;
converter.SetRunNumber(i);
std::cout<<"Converting file: "<<binfile<<std::endl;
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";
@ -194,31 +177,25 @@ namespace EventBuilder {
sys_return = system(wipe_command.c_str());
}
std::cout<<std::endl<<"Conversion complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl;
EVB_INFO("Conversion complete.");
}
void EVBApp::MergeROOTFiles()
{
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/";
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
std::cout<<"Merging ROOT files into single ROOT file"<<std::endl;
std::cout<<"Workspace directory: "<<m_workspace<<std::endl;
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
std::cout<<"Output file: "<<merge_file<<std::endl;
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);
std::string prefix = "";
std::string suffix = ".root";
grabber.SetSearchParams(file_dir, prefix, suffix,m_rmin,m_rmax);
std::cout<<"Beginning the merge...";
EVB_INFO("Starting merge...");
if(!grabber.Merge_TChain(merge_file))
{
std::cout<<"Unable to find files at MergeROOTFiles"<<std::endl;
EVB_ERROR("Unable to find files for merge at EVBApp::MergeROOTFiles()!");
return;
}
std::cout<<" Complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl;
EVB_INFO("Finished.");
}
void EVBApp::Convert2SortedRoot()
@ -227,19 +204,10 @@ namespace EventBuilder {
std::string sortroot_dir = m_workspace+"/sorted/";
std::string unpack_dir = m_workspace+"/temp_binary/";
std::string binary_dir = m_workspace+"/raw_binary/";
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
EVB_INFO("Converting binary archives to event built ROOT files over run range [{0}, {1}]",m_rmin,m_rmax);
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
std::string sortfile, binfile;
std::string unpack_command, wipe_command;
@ -249,15 +217,16 @@ namespace EventBuilder {
if(m_pb)
converter.AttachProgressBar(m_pb);
std::cout<<"Beginning conversion..."<<std::endl;
EVB_INFO("Beginning conversion...");
int count=0;
for(int i=m_rmin; i<= m_rmax; i++)
{
binfile = grabber.GrabFile(i);
if(binfile == "")
continue;
converter.SetRunNumber(i);
std::cout<<"Converting file: "<<binfile<<std::endl;
EVB_INFO("Converting file {0}...",binfile);
sortfile = sortroot_dir +"run_"+std::to_string(i)+ ".root";
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
@ -266,10 +235,12 @@ namespace EventBuilder {
sys_return = system(unpack_command.c_str());
converter.Convert2SortedRoot(sortfile, m_mapfile, m_SlowWindow);
sys_return = system(wipe_command.c_str());
count++;
}
std::cout<<std::endl<<"Conversion complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl;
if(count==0)
EVB_WARN("Conversion failed, no archives were found!");
else
EVB_INFO("Conversion complete.");
}
void EVBApp::Convert2FastSortedRoot() {
@ -277,19 +248,10 @@ namespace EventBuilder {
std::string sortroot_dir = m_workspace+"/fast/";
std::string unpack_dir = m_workspace+"/temp_binary/";
std::string binary_dir = m_workspace+"/raw_binary/";
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
EVB_INFO("Converting binary archives to fast event built ROOT files over run range [{0}, {1}]",m_rmin,m_rmax);
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
std::string sortfile, binfile;
std::string unpack_command, wipe_command;
@ -299,15 +261,15 @@ namespace EventBuilder {
if(m_pb)
converter.AttachProgressBar(m_pb);
std::cout<<"Beginning conversion..."<<std::endl;
EVB_INFO("Beginning conversion...");
int count=0;
for(int i=m_rmin; i<=m_rmax; i++)
{
binfile = grabber.GrabFile(i);
if(binfile == "")
continue;
converter.SetRunNumber(i);
std::cout<<"Converting file: "<<binfile<<std::endl;
EVB_INFO("Converting file {0}...",binfile);
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
@ -316,10 +278,12 @@ namespace EventBuilder {
sys_return = system(unpack_command.c_str());
converter.Convert2FastSortedRoot(sortfile, m_mapfile, m_SlowWindow, m_FastWindowSABRE, m_FastWindowIonCh);
sys_return = system(wipe_command.c_str());
count++;
}
std::cout<<std::endl<<"Conversion complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl;
if(count==0)
EVB_WARN("Conversion failed, no archives were found!");
else
EVB_INFO("Conversion complete.");
}
void EVBApp::Convert2SlowAnalyzedRoot() {
@ -327,17 +291,9 @@ namespace EventBuilder {
std::string sortroot_dir = m_workspace+"/analyzed/";
std::string unpack_dir = m_workspace+"/temp_binary/";
std::string binary_dir = m_workspace+"/raw_binary/";
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
EVB_INFO("Converting binary archives to analyzed event built ROOT files over run range [{0}, {1}]",m_rmin,m_rmax);
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin, m_rmax);
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
std::string sortfile, binfile;
std::string unpack_command, wipe_command;
@ -348,15 +304,15 @@ namespace EventBuilder {
if(m_pb)
converter.AttachProgressBar(m_pb);
std::cout<<"Beginning conversion..."<<std::endl;
EVB_INFO("Beginning conversion...");
int count=0;
for(int i=m_rmin; i<=m_rmax; i++)
{
binfile = grabber.GrabFile(i);
if(binfile == "")
continue;
converter.SetRunNumber(i);
std::cout<<"Converting file: "<<binfile<<std::endl;
EVB_INFO("Converting file {0}...",binfile);
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
@ -365,10 +321,12 @@ namespace EventBuilder {
sys_return = system(unpack_command.c_str());
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);
sys_return = system(wipe_command.c_str());
count++;
}
std::cout<<std::endl<<"Conversion complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl;
if(count==0)
EVB_WARN("Conversion failed, no archives were found!");
else
EVB_INFO("Conversion complete.");
}
void EVBApp::Convert2FastAnalyzedRoot()
@ -377,21 +335,10 @@ namespace EventBuilder {
std::string sortroot_dir = m_workspace+"/analyzed/";
std::string unpack_dir = m_workspace+"/temp_binary/";
std::string binary_dir = m_workspace+"/raw_binary/";
std::cout<<"-------------GWM Event Builder-------------"<<std::endl;
std::cout<<"Converting Binary file Archive to ROOT file"<<std::endl;
std::cout<<"Binary Archive Directory: "<<binary_dir<<std::endl;
std::cout<<"Temporary Unpack Directory: "<<unpack_dir<<std::endl;
std::cout<<"Timestamp Shift File: "<<m_shiftfile<<std::endl;
std::cout<<"Channel Map File: "<<m_mapfile<<std::endl;
std::cout<<"Slow Coincidence Window(ps): "<<m_SlowWindow<<std::endl;
std::cout<<"Fast Ion Chamber Coincidence Window(ps): "<<m_FastWindowIonCh<<std::endl;
std::cout<<"Fast SABRE Coincidence Window(ps): "<<m_FastWindowSABRE<<std::endl;
std::cout<<"Min Run: "<<m_rmin<<" Max Run: "<<m_rmax<<std::endl;
EVB_INFO("Converting binary archives to analyzed fast event built ROOT files over run range [{0}, {1}]",m_rmin,m_rmax);
grabber.SetSearchParams(binary_dir,"",".tar.gz",m_rmin,m_rmax);
std::cout<<"Workspace Directory: "<<m_workspace<<std::endl;
std::string sortfile, binfile;
std::string unpack_command, wipe_command;
@ -401,15 +348,15 @@ namespace EventBuilder {
if(m_pb)
converter.AttachProgressBar(m_pb);
std::cout<<"Beginning conversion..."<<std::endl;
EVB_INFO("Beginning conversion...");
int count=0;
for(int i=m_rmin; i<=m_rmax; i++)
{
binfile = grabber.GrabFile(i);
if(binfile == "")
continue;
converter.SetRunNumber(i);
std::cout<<"Converting file: "<<binfile<<std::endl;
EVB_INFO("Converting file {0}...",binfile);
sortfile = sortroot_dir + "run_" + std::to_string(i) + ".root";
unpack_command = "tar -xzf "+binfile+" --directory "+unpack_dir;
@ -418,10 +365,12 @@ namespace EventBuilder {
sys_return = system(unpack_command.c_str());
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);
sys_return = system(wipe_command.c_str());
count++;
}
std::cout<<std::endl<<"Conversion complete."<<std::endl;
std::cout<<"-------------------------------------------"<<std::endl;
if(count==0)
EVB_WARN("Conversion failed, no archives were found!");
else
EVB_INFO("Conversion complete.");
}
bool EVBApp::SetKinematicParameters(int zt, int at, int zp, int ap, int ze, int ae, double b, double theta, double bke)
@ -429,7 +378,7 @@ namespace EventBuilder {
if((at + ap - ae) < 0 || (zt + zp - ze) < 0)
{
std::cout<<"Invalid Parameters at SetKinematicParameters"<<std::endl;
EVB_WARN("Invalid kinematic parameters, nucleon number not conserved! Parameters not set");
return false;
}
m_ZT = zt; m_AT = at; m_ZP = zp; m_AP = ap; m_ZE = ze; m_AE = ae;
@ -437,8 +386,21 @@ namespace EventBuilder {
m_ZR = (zt + zp - ze);
m_AR = (at + ap - ae);
EVB_TRACE("Kinematic paramters updated.");
return true;
}
void EVBApp::SetRunRange(int rmin, int rmax) { EVB_TRACE("Min Run, max run set to [{0}, {1}]", rmin, rmax); m_rmin = rmin; m_rmax = rmax; }
void EVBApp::SetWorkDirectory(const std::string& fullpath) { EVB_TRACE("Workspace set to {0}", fullpath); m_workspace = fullpath; }
void EVBApp::SetChannelMap(const std::string& name) { EVB_TRACE("Channel map set to {0}",name); m_mapfile = name; }
void EVBApp::SetBoardShiftFile(const std::string& name) { EVB_TRACE("Shift file set to {0}", name); m_shiftfile = name; }
void EVBApp::SetSlowCoincidenceWindow(double window) { EVB_TRACE("Slow Coincidence Window set to {0}",window); m_SlowWindow = window; }
void EVBApp::SetFastWindowIonChamber(double window) { EVB_TRACE("Fast Coinc. Window Ion Ch. set to {0}",window); m_FastWindowIonCh = window; }
void EVBApp::SetFastWindowSABRE(double window) { EVB_TRACE("Fast Coinc. Window SABRE set to {0}",window); m_FastWindowSABRE = window; }
void EVBApp::SetCutList(const std::string& name) { EVB_TRACE("Cut List set to {0}", name); m_cutList = name; }
void EVBApp::SetScalerFile(const std::string& fullpath) { EVB_TRACE("Scaler file set to {0}", fullpath); m_scalerfile = fullpath; }
}

View File

@ -30,31 +30,31 @@ namespace EventBuilder {
void Convert2SlowAnalyzedRoot();
void Convert2FastAnalyzedRoot();
inline void SetRunRange(int rmin, int rmax) { m_rmin = rmin; m_rmax = rmax; };
inline void SetWorkDirectory(const std::string& fullpath) { m_workspace = fullpath; };
inline void SetChannelMap(const std::string& name) { m_mapfile = name; };
inline void SetBoardShiftFile(const std::string& name) { m_shiftfile = name; };
inline void SetSlowCoincidenceWindow(double window) { m_SlowWindow = window; };
inline void SetFastWindowIonChamber(double window) { m_FastWindowIonCh = window; };
inline void SetFastWindowSABRE(double window) { m_FastWindowSABRE = window; };
inline void SetCutList(const std::string& name) { m_cutList = name; };
inline void SetScalerFile(const std::string& fullpath) { m_scalerfile = fullpath; };
void SetRunRange(int rmin, int rmax);
void SetWorkDirectory(const std::string& fullpath);
void SetChannelMap(const std::string& name);
void SetBoardShiftFile(const std::string& name);
void SetSlowCoincidenceWindow(double window);
void SetFastWindowIonChamber(double window);
void SetFastWindowSABRE(double window);
void SetCutList(const std::string& name);
void SetScalerFile(const std::string& fullpath);
bool SetKinematicParameters(int zt, int at, int zp, int ap, int ze, int ae, double b, double theta, double bke);
inline int GetRunMin() const {return m_rmin;}
inline int GetRunMax() const {return m_rmax;}
inline std::string GetWorkDirectory() const {return m_workspace;}
inline int GetTargetZ() const {return m_ZT;}
inline int GetTargetA() const {return m_AT;}
inline int GetProjectileZ() const {return m_ZP;}
inline int GetProjectileA() const {return m_AP;}
inline int GetEjectileZ() const {return m_ZE;}
inline int GetEjectileA() const {return m_AE;}
inline int GetResidualZ() const {return m_ZR;}
inline int GetResidualA() const {return m_AR;}
inline double GetBField() const {return m_B;}
inline double GetBeamKE() const {return m_BKE;}
inline double GetTheta() const {return m_Theta;}
inline int GetRunMin() const { return m_rmin; }
inline int GetRunMax() const { return m_rmax; }
inline std::string GetWorkDirectory() const { return m_workspace; }
inline int GetTargetZ() const { return m_ZT; }
inline int GetTargetA() const { return m_AT; }
inline int GetProjectileZ() const { return m_ZP; }
inline int GetProjectileA() const { return m_AP; }
inline int GetEjectileZ() const { return m_ZE; }
inline int GetEjectileA() const { return m_AE; }
inline int GetResidualZ() const { return m_ZR; }
inline int GetResidualA() const { return m_AR; }
inline double GetBField() const { return m_B; }
inline double GetBeamKE() const { return m_BKE; }
inline double GetTheta() const { return m_Theta; }
inline double GetSlowCoincidenceWindow() const { return m_SlowWindow; }
inline double GetFastWindowIonChamber() const { return m_FastWindowIonCh; }
inline double GetFastWindowSABRE() const { return m_FastWindowSABRE; }

View File

@ -70,7 +70,7 @@ namespace EventBuilder {
if (MT*MP*ME*MR == 0)
{
std::cerr << "***WARNING: error loading one or more masses; returning 0\n";
EVB_WARN("Illegal mass at FP_kinematics::Delta_Z! Returning offset of 0.");
return 0;
}

View File

@ -43,7 +43,7 @@ namespace EventBuilder {
}
}
else
std::cerr<<"Unable to open mass.txt at MassLookup! Prepare for errors."<<std::endl;
EVB_ERROR("Mass file could not be loaded ({0}). Crashing inbound.",filepath);
}
MassLookup::~MassLookup() {}
@ -55,7 +55,7 @@ namespace EventBuilder {
auto data = massTable.find(key);
if(data == massTable.end())
{
std::cerr<<"Invaild nucleus at MassLookup! Returning mass of 0"<<std::endl;
EVB_WARN("Invalid nucleus (Z,A) ({0},{1}) at MassLookup::FindMass; returning zero.",Z,A);
return 0;
}
return data->second;
@ -67,7 +67,7 @@ namespace EventBuilder {
auto data = elementTable.find(Z);
if(data == elementTable.end())
{
std::cerr<<"Invaild nucleus at MassLookup! Returning empty symbol"<<std::endl;
EVB_WARN("Invalid nucleus (Z,A) ({0},{1}) at MassLookup::FindSymbol; returning empty string.",Z,A);
return "";
}
std::string fullsymbol = std::to_string(A) + data->second;

View File

@ -31,7 +31,7 @@ namespace EventBuilder {
tree->GetEntry();
if(prevStamp >= ts)
{
std::cerr<<"Bad order at entry "<<i<<" out of "<<tree->GetEntries()<<std::endl;
EVB_WARN("Bad order at entry {0} out of {1}",i,tree->GetEntries());
return false;
}
}

View File

@ -45,7 +45,7 @@ namespace EventBuilder {
if(!flist) //Make sure list is real. If not, means no directory
{
std::cerr<<"Unable to find any files in directory; check name given to the input.txt"<<std::endl;
EVB_WARN("RunCollector::GrabAllFiles() unable to find any files in directory {0}",m_directory);
return false;
}
@ -70,7 +70,7 @@ namespace EventBuilder {
return true;
else
{
std::cerr<<"Unable to find files with matching run name in directory; check input.txt"<<std::endl;
EVB_WARN("RunCollector::GrabAllFiles() unable to find any files in directory {0} which match run pattern",m_directory);
return false;
}
}
@ -117,7 +117,7 @@ namespace EventBuilder {
if(!flist)
{
std::cerr<<"Unable to find any files in directory; check name given to input.txt"<<std::endl;
EVB_WARN("RunCollector::GrabFilesInRange() unable to find any files in directory {0}",m_directory);
return false;
}
@ -148,7 +148,7 @@ namespace EventBuilder {
return true;
else
{
std::cerr<<"Unable to find files with matching run name in directory; check input.txt"<<std::endl;
EVB_WARN("RunCollector::GrabAllFiles() unable to find any files in directory {0} which match run pattern and were in run range",m_directory);
return false;
}
@ -167,9 +167,7 @@ namespace EventBuilder {
std::string clump = "hadd "+outname;
for(unsigned int i=0; i<m_filelist.size(); i++)
clump += " "+m_filelist[i];
std::cout<<"Merging runs into single file..."<<std::endl;
sys_return = std::system(clump.c_str());
std::cout<<"Finished merging"<<std::endl;
return true;
}
else
@ -182,9 +180,7 @@ namespace EventBuilder {
std::string clump = "hadd "+outname;
for(unsigned int i=0; i<m_filelist.size(); i++)
clump += " "+m_filelist[i];
std::cout<<"Merging runs "<<m_minRun<<" to "<<m_maxRun<<" into a single file..."<<std::endl;
sys_return = std::system(clump.c_str());
std::cout<<"Finished merging"<<std::endl;
return true;
}
else
@ -192,7 +188,7 @@ namespace EventBuilder {
}
if(!sys_return)
std::cerr<<"How did i even get here?"<<std::endl;
EVB_ERROR("How did i even get here?");
return false;
}
@ -209,9 +205,7 @@ namespace EventBuilder {
{
for(unsigned int i=0; i<m_filelist.size(); i++)
chain->Add(m_filelist[i].c_str());
std::cout<<"Merging runs into single file..."<<std::endl;
chain->Merge(output,0,"fast");
std::cout<<"Finished merging"<<std::endl;
return true;
}
else
@ -223,9 +217,7 @@ namespace EventBuilder {
{
for(unsigned int i=0; i<m_filelist.size(); i++)
chain->Add(m_filelist[i].c_str());
std::cout<<"Merging runs "<<m_minRun<<" to "<<m_maxRun<<" into a single file..."<<std::endl;
chain->Merge(output,0,"fast");
std::cout<<"Finished merging"<<std::endl;
return true;
} else
return false;

View File

@ -44,7 +44,7 @@ namespace EventBuilder {
{
w1 = (Wire_Dist()/2.0-zfp)/Wire_Dist();
w2 = 1.0-w1;
std::cout<<"w1: "<<w1<<" w2: "<<w2<<std::endl;
EVB_INFO("Calculated X-Avg weights of w1={0} and w2={1}",w1,w2);
}
/*2D histogram fill wrapper for use with THashTable (faster)*/

View File

@ -248,11 +248,13 @@ namespace EventBuilder {
THashTable* table = new THashTable();
long blentries = chain->GetEntries();
if(m_pb)
long count=0, flush_val=blentries*0.1, flush_count=0;
if(m_pb)
{
flush_val = blentries*0.01;
SetProgressBar(blentries);
std::cout<<"Total number of events: "<<blentries<<std::endl;
}
long count=0, flush_val=blentries*0.01, flush_count=0;
for(long i=0; i<chain->GetEntries(); i++)
{
@ -266,14 +268,13 @@ namespace EventBuilder {
} else {
flush_count++;
count=0;
std::cout<<"\rPercent of data processed: "<<flush_count*10<<"%"<<std::flush;
EVB_INFO("Percent of data processed: {0} %",flush_count*10);
}
}
chain->GetEntry(i);
MakeUncutHistograms(*event_address, table);
if(cutter.IsValid()) MakeCutHistograms(*event_address, table);
}
std::cout<<std::endl;
outfile->cd();
table->Write();
if(cutter.IsValid())

View File

@ -142,11 +142,7 @@ namespace EventBuilder {
if(channel_info == cmap.End())
{
std::cout<<std::endl;
std::cout<<"------Data Assignment Error!-------"<<std::endl;
std::cout<<"Global channel number "<<gchan<<" found in data stream, but not assigned in ChannelMap!"<<std::endl;
std::cout<<"Skipping this hit..."<<std::endl;
std::cout<<"-----------------------------------"<<std::endl;
EVB_WARN("At SlowSort::ProcessEvent() -- Data Assignment Error! Global channel {0} found but not assigned in ChannelMap! Skipping data.",gchan);
continue;
}
@ -164,12 +160,8 @@ namespace EventBuilder {
}
else
{
std::cout<<std::endl;
std::cout<<"------Data Assignment Error!-------"<<std::endl;
std::cout<<"Channel is present in channel map, but does not have a variable assigned in variable map!"<<std::endl;
std::cout<<"global channel number: "<<gchan<<" channel detector type: "<<channel_info->second.type<<" attribute: "<<channel_info->second.attribute<<std::endl;
std::cout<<"Skipping this hit..."<<std::endl;
std::cout<<"-----------------------------------"<<std::endl;
EVB_WARN("At SlowSort::ProcessEvent() -- Data Assignment Error! Channel ({0}, {1}, {2}) exists in ChannelMap, but does not have an assigned variable! Skipping data.",
gchan, channel_info->second.type, channel_info->second.attribute);
}
}
//Organize the SABRE data in descending energy order

View File

@ -4,6 +4,7 @@
int main(int argc, char** argv)
{
EventBuilder::Logger::Init();
EnforceDictionaryLinked();
TApplication app("app", &argc, argv);
UInt_t h = 400;

View File

@ -5,7 +5,7 @@ add_custom_command(TARGET GUIDict
POST_BUILD
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/libGUIDict_rdict.pcm ${CMAKE_INSTALL_PREFIX}/lib/
VERBATIM)
target_include_directories(GUIDict PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PCH_DIR} ${SPDLOG_INCLUDE})
target_include_directories(GUIDict PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PCH_DIR} ${SPDLOG_INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}/../evb)
target_precompile_headers(GUIDict PUBLIC ${PCH_DIR}/EventBuilder.h)
set_target_properties(GUIDict PROPERTIES PUBLIC_HEADER "EVBMainFrame.h;FileViewFrame.h")
target_link_libraries(GUIDict

View File

@ -5,7 +5,7 @@ add_custom_command(TARGET SPSDict
POST_BUILD
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/libSPSDict_rdict.pcm ${CMAKE_INSTALL_PREFIX}/lib/
VERBATIM)
target_include_directories(SPSDict PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PCH_DIR} ${SPDLOG_INCLUDE})
target_include_directories(SPSDict PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PCH_DIR} ${SPDLOG_INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}/../evb)
target_precompile_headers(SPSDict PUBLIC ${PCH_DIR}/EventBuilder.h)
set_target_properties(SPSDict PROPERTIES PUBLIC_HEADER "DataStructs.h")
target_link_libraries(SPSDict