Switch to using YAML as our config saving format, integrate yaml-cpp. Switch B-field input to kG instead of G

This commit is contained in:
Gordon McCann 2022-07-13 11:59:11 -04:00
parent 935e6be0f6
commit 4ae9ecadac
9 changed files with 74 additions and 72 deletions

1
.gitignore vendored
View File

@ -19,6 +19,7 @@ objs/
*.sublime-project *.sublime-project
*.sublime-workspace *.sublime-workspace
*.make *.make
*.yaml
Makefile Makefile
event_log.txt event_log.txt
.DS_Store .DS_Store

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "vendor/spdlog"] [submodule "vendor/spdlog"]
path = vendor/spdlog path = vendor/spdlog
url = https://github.com/gabime/spdlog.git url = https://github.com/gabime/spdlog.git
[submodule "vendor/yaml-cpp"]
path = vendor/yaml-cpp
url = https://github.com/jbeder/yaml-cpp.git

View File

@ -17,4 +17,5 @@ find_package(ROOT REQUIRED COMPONENTS Gui)
set(EVB_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(EVB_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(EVB_LIBRARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib) set(EVB_LIBRARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
add_subdirectory(vendor/yaml-cpp)
add_subdirectory(src) add_subdirectory(src)

View File

@ -1,6 +1,10 @@
add_library(EventBuilderCore STATIC) add_library(EventBuilderCore STATIC)
target_include_directories(EventBuilderCore SYSTEM PUBLIC ../../vendor/spdlog/include ${ROOT_INCLUDE_DIRS} target_include_directories(EventBuilderCore
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ SYSTEM PUBLIC ../../vendor/spdlog/include
${ROOT_INCLUDE_DIRS}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../
../vendor/yaml-cpp/include/
) )
target_precompile_headers(EventBuilderCore PRIVATE ../EventBuilder.h) target_precompile_headers(EventBuilderCore PRIVATE ../EventBuilder.h)
@ -48,6 +52,9 @@ target_sources(EventBuilderCore PRIVATE
target_link_libraries(EventBuilderCore PUBLIC target_link_libraries(EventBuilderCore PUBLIC
SPSDict SPSDict
${ROOT_LIBRARIES} ${ROOT_LIBRARIES}
yaml-cpp
) )
set_target_properties(EventBuilderCore PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${EVB_LIBRARY_DIR}) set_target_properties(EventBuilderCore PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${EVB_LIBRARY_DIR})
target_compile_definitions(EventBuilderCore PRIVATE YAML_CPP_STATIC_DEFINE)

View File

@ -10,6 +10,7 @@
#include "EVBApp.h" #include "EVBApp.h"
#include "CompassRun.h" #include "CompassRun.h"
#include "SFPPlotter.h" #include "SFPPlotter.h"
#include "yaml-cpp/yaml.h"
namespace EventBuilder { namespace EventBuilder {
@ -44,51 +45,44 @@ namespace EventBuilder {
bool EVBApp::ReadConfigFile(const std::string& fullpath) bool EVBApp::ReadConfigFile(const std::string& fullpath)
{ {
EVB_INFO("Reading in EVB configuration from file {0}...", fullpath); EVB_INFO("Reading in EVB configuration from file {0}...", fullpath);
std::ifstream input(fullpath); YAML::Node data;
if(!input.is_open()) try
{ {
EVB_WARN("Read of EVB config failed, unable to open input file!"); data = YAML::LoadFile(fullpath);
}
catch(YAML::ParserException& e)
{
EVB_ERROR("Read of EVB config failed, unable to open input file!");
return false; return false;
} }
std::string junk; m_params.workspaceDir = data["WorkspaceDir"].as<std::string>();
m_params.channelMapFile = data["ChannelMap"].as<std::string>();
m_params.scalerFile = data["ScalerFile"].as<std::string>();
m_params.cutListFile = data["CutListFile"].as<std::string>();
m_params.timeShiftFile = data["TimeShiftFile"].as<std::string>();
m_params.slowCoincidenceWindow = data["SlowCoincidenceWindow(ps)"].as<double>();
m_params.fastCoincidenceWindowIonCh = data["FastCoincidenceWinowIonCh(ps)"].as<double>();
m_params.fastCoincidenceWindowSABRE = data["FastCoincidenceWinowSABRE(ps)"].as<double>();
m_params.ZT = data["ZT"].as<int>();
m_params.AT = data["AT"].as<int>();
m_params.ZP = data["ZP"].as<int>();
m_params.AP = data["AP"].as<int>();
m_params.ZE = data["ZE"].as<int>();
m_params.AE = data["AE"].as<int>();
m_params.BField = data["BField(kG)"].as<double>();
m_params.beamEnergy = data["BeamEnergy(MeV)"].as<double>();
m_params.spsAngle = data["SPSAngle(deg)"].as<double>();
m_params.runMin = data["MinRun"].as<int>();
m_params.runMax = data["MaxRun"].as<int>();
std::getline(input, junk); EVB_INFO("Successfully loaded EVB config.");
input>>junk>>m_params.workspaceDir;
m_workspace.reset(new EVBWorkspace(m_params.workspaceDir)); //frees underlying and sets to new pointer m_workspace.reset(new EVBWorkspace(m_params.workspaceDir));
if(!m_workspace->IsValid()) if(!m_workspace->IsValid())
{ {
EVB_ERROR("Unable to process input configuration due to bad workspace."); EVB_ERROR("Unable to process input configuration due to bad workspace.");
return false; return false;
} }
input>>junk;
std::getline(input, junk);
std::getline(input, junk);
input>>junk>>m_params.channelMapFile;
input>>junk>>m_params.scalerFile;
input>>junk>>m_params.cutListFile;
input>>junk>>m_params.ZT>>junk>>m_params.AT;
input>>junk>>m_params.ZP>>junk>>m_params.AP;
input>>junk>>m_params.ZE>>junk>>m_params.AE;
input>>junk>>m_params.BField;
input>>junk>>m_params.beamEnergy;
input>>junk>>m_params.spsAngle;
input>>junk;
std::getline(input, junk);
std::getline(input, junk);
input>>junk>>m_params.timeShiftFile;
input>>junk>>m_params.slowCoincidenceWindow;
input>>junk>>m_params.fastCoincidenceWindowIonCh;
input>>junk>>m_params.fastCoincidenceWindowSABRE;
input>>junk;
std::getline(input, junk);
std::getline(input, junk);
input>>junk>>m_params.runMin;
input>>junk>>m_params.runMax;
input.close();
EVB_INFO("Successfully loaded EVB config.");
return true; return true;
} }
@ -102,35 +96,32 @@ namespace EventBuilder {
EVB_WARN("Failed to write to config to file {0}, unable to open file!", fullpath); EVB_WARN("Failed to write to config to file {0}, unable to open file!", fullpath);
return; return;
} }
output<<"-------Data Location----------"<<std::endl; YAML::Emitter yamlStream;
output<<"WorkspaceDirectory: "<<m_params.workspaceDir<<std::endl; yamlStream << YAML::BeginMap;
output<<"-------------------------------"<<std::endl; yamlStream << YAML::Key << "WorkspaceDir" << YAML::Value << m_params.workspaceDir;
output<<"------Experimental Inputs------"<<std::endl; yamlStream << YAML::Key << "ChannelMap" << YAML::Value << m_params.channelMapFile;
output<<"ChannelMapFile: "<<m_params.channelMapFile<<std::endl; yamlStream << YAML::Key << "ScalerFile" << YAML::Value << m_params.scalerFile;
output<<"ScalerFile: "<<m_params.scalerFile<<std::endl; yamlStream << YAML::Key << "CutListFile" << YAML::Value << m_params.cutListFile;
output<<"CutListFile: "<<m_params.cutListFile<<std::endl; yamlStream << YAML::Key << "TimeShiftFile" << YAML::Value << m_params.timeShiftFile;
output<<"ZT: "<<m_params.ZT<<std::endl; yamlStream << YAML::Key << "SlowCoincidenceWindow(ps)" << YAML::Value << m_params.slowCoincidenceWindow;
output<<"AT: "<<m_params.AT<<std::endl; yamlStream << YAML::Key << "FastCoincidenceWinowIonCh(ps)" << YAML::Value << m_params.fastCoincidenceWindowIonCh;
output<<"ZP: "<<m_params.ZP<<std::endl; yamlStream << YAML::Key << "FastCoincidenceWinowSABRE(ps)" << YAML::Value << m_params.fastCoincidenceWindowSABRE;
output<<"AP: "<<m_params.AP<<std::endl; yamlStream << YAML::Key << "ZT" << YAML::Value << m_params.ZT;
output<<"ZE: "<<m_params.ZE<<std::endl; yamlStream << YAML::Key << "AT" << YAML::Value << m_params.AT;
output<<"AE: "<<m_params.AE<<std::endl; yamlStream << YAML::Key << "ZP" << YAML::Value << m_params.ZP;
output<<"BField(G): "<<m_params.BField<<std::endl; yamlStream << YAML::Key << "AP" << YAML::Value << m_params.AP;
output<<"BeamKE(MeV): "<<m_params.beamEnergy<<std::endl; yamlStream << YAML::Key << "ZE" << YAML::Value << m_params.ZE;
output<<"Theta(deg): "<<m_params.spsAngle<<std::endl; yamlStream << YAML::Key << "AE" << YAML::Value << m_params.AE;
output<<"-------------------------------"<<std::endl; yamlStream << YAML::Key << "BField(kG)" << YAML::Value << m_params.BField;
output<<"-------Timing Information------"<<std::endl; yamlStream << YAML::Key << "BeamEnergy(MeV)" << YAML::Value << m_params.beamEnergy;
output<<"BoardOffsetFile: "<<m_params.timeShiftFile<<std::endl; yamlStream << YAML::Key << "SPSAngle(deg)" << YAML::Value << m_params.spsAngle;
output<<"SlowCoincidenceWindow(ps): "<<m_params.slowCoincidenceWindow<<std::endl; yamlStream << YAML::Key << "MinRun" << YAML::Value << m_params.runMin;
output<<"FastCoincidenceWindow_IonCh(ps): "<<m_params.fastCoincidenceWindowIonCh<<std::endl; yamlStream << YAML::Key << "MaxRun" << YAML::Value << m_params.runMax;
output<<"FastCoincidenceWindow_SABRE(ps): "<<m_params.fastCoincidenceWindowSABRE<<std::endl; yamlStream << YAML::EndMap;
output<<"-------------------------------"<<std::endl;
output<<"--------Run Information--------"<<std::endl; output << yamlStream.c_str();
output<<"MinRun: "<<m_params.runMin<<std::endl;
output<<"MaxRun: "<<m_params.runMax<<std::endl;
output<<"-------------------------------"<<std::endl;
output.close(); output.close();
EVB_INFO("Successfully wrote config to file."); EVB_INFO("Successfully wrote config to file.");

View File

@ -17,7 +17,7 @@ namespace EventBuilder {
SFPAnalyzer::SFPAnalyzer(int zt, int at, int zp, int ap, int ze, int ae, double ep, SFPAnalyzer::SFPAnalyzer(int zt, int at, int zp, int ap, int ze, int ae, double ep,
double angle, double b) double angle, double b)
{ {
zfp = Delta_Z(zt, at, zp, ap, ze, ae, ep, angle, b); zfp = Delta_Z(zt, at, zp, ap, ze, ae, ep, angle, b*1000.0); //Convert kG to G
event_address = new CoincEvent(); event_address = new CoincEvent();
rootObj = new THashTable(); rootObj = new THashTable();
GetWeights(); GetWeights();

View File

@ -136,7 +136,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
beamFrame->AddFrame(bkelabel, lhints); beamFrame->AddFrame(bkelabel, lhints);
beamFrame->AddFrame(fBKEField, fhints); beamFrame->AddFrame(fBKEField, fhints);
TGHorizontalFrame* bfFrame = new TGHorizontalFrame(extraFrame, w*0.175, h*0.15); TGHorizontalFrame* bfFrame = new TGHorizontalFrame(extraFrame, w*0.175, h*0.15);
TGLabel *bfieldlabel = new TGLabel(bfFrame, "B-Field (G):"); TGLabel *bfieldlabel = new TGLabel(bfFrame, "B-Field (kG):");
fBField = new TGNumberEntryField(bfFrame, BField, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative); fBField = new TGNumberEntryField(bfFrame, BField, 0, TGNumberEntry::kNESRealFour, TGNumberEntry::kNEANonNegative);
bfFrame->AddFrame(bfieldlabel, lhints); bfFrame->AddFrame(bfieldlabel, lhints);
bfFrame->AddFrame(fBField, fhints); bfFrame->AddFrame(fBField, fhints);

View File

@ -97,7 +97,5 @@ private:
int counter; int counter;
UInt_t MAIN_W, MAIN_H; UInt_t MAIN_W, MAIN_H;
}; };
#endif #endif

1
vendor/yaml-cpp vendored Submodule

@ -0,0 +1 @@
Subproject commit c73ee34704c512ebe915b283645aefa9f424a22f