diff --git a/.gitignore b/.gitignore index ae28796..622369a 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ objs/ *.sublime-project *.sublime-workspace *.make +*.yaml Makefile event_log.txt .DS_Store diff --git a/.gitmodules b/.gitmodules index 18a8e2a..9ff459d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "vendor/spdlog"] path = vendor/spdlog url = https://github.com/gabime/spdlog.git +[submodule "vendor/yaml-cpp"] + path = vendor/yaml-cpp + url = https://github.com/jbeder/yaml-cpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a6e47c..e7e8f74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,4 +17,5 @@ find_package(ROOT REQUIRED COMPONENTS Gui) set(EVB_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(EVB_LIBRARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib) +add_subdirectory(vendor/yaml-cpp) add_subdirectory(src) \ No newline at end of file diff --git a/src/evb/CMakeLists.txt b/src/evb/CMakeLists.txt index 0f864c3..f505629 100644 --- a/src/evb/CMakeLists.txt +++ b/src/evb/CMakeLists.txt @@ -1,6 +1,10 @@ add_library(EventBuilderCore STATIC) -target_include_directories(EventBuilderCore SYSTEM PUBLIC ../../vendor/spdlog/include ${ROOT_INCLUDE_DIRS} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ +target_include_directories(EventBuilderCore + 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) @@ -48,6 +52,9 @@ target_sources(EventBuilderCore PRIVATE target_link_libraries(EventBuilderCore PUBLIC SPSDict ${ROOT_LIBRARIES} + yaml-cpp ) -set_target_properties(EventBuilderCore PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${EVB_LIBRARY_DIR}) \ No newline at end of file +set_target_properties(EventBuilderCore PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${EVB_LIBRARY_DIR}) + +target_compile_definitions(EventBuilderCore PRIVATE YAML_CPP_STATIC_DEFINE) \ No newline at end of file diff --git a/src/evb/EVBApp.cpp b/src/evb/EVBApp.cpp index a2a4fff..1347e25 100644 --- a/src/evb/EVBApp.cpp +++ b/src/evb/EVBApp.cpp @@ -10,6 +10,7 @@ #include "EVBApp.h" #include "CompassRun.h" #include "SFPPlotter.h" +#include "yaml-cpp/yaml.h" namespace EventBuilder { @@ -44,51 +45,44 @@ namespace EventBuilder { bool EVBApp::ReadConfigFile(const std::string& fullpath) { EVB_INFO("Reading in EVB configuration from file {0}...", fullpath); - std::ifstream input(fullpath); - if(!input.is_open()) + YAML::Node data; + 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; } - std::string junk; + m_params.workspaceDir = data["WorkspaceDir"].as(); + m_params.channelMapFile = data["ChannelMap"].as(); + m_params.scalerFile = data["ScalerFile"].as(); + m_params.cutListFile = data["CutListFile"].as(); + m_params.timeShiftFile = data["TimeShiftFile"].as(); + m_params.slowCoincidenceWindow = data["SlowCoincidenceWindow(ps)"].as(); + m_params.fastCoincidenceWindowIonCh = data["FastCoincidenceWinowIonCh(ps)"].as(); + m_params.fastCoincidenceWindowSABRE = data["FastCoincidenceWinowSABRE(ps)"].as(); + m_params.ZT = data["ZT"].as(); + m_params.AT = data["AT"].as(); + m_params.ZP = data["ZP"].as(); + m_params.AP = data["AP"].as(); + m_params.ZE = data["ZE"].as(); + m_params.AE = data["AE"].as(); + m_params.BField = data["BField(kG)"].as(); + m_params.beamEnergy = data["BeamEnergy(MeV)"].as(); + m_params.spsAngle = data["SPSAngle(deg)"].as(); + m_params.runMin = data["MinRun"].as(); + m_params.runMax = data["MaxRun"].as(); - std::getline(input, junk); - input>>junk>>m_params.workspaceDir; - m_workspace.reset(new EVBWorkspace(m_params.workspaceDir)); //frees underlying and sets to new pointer + EVB_INFO("Successfully loaded EVB config."); + + m_workspace.reset(new EVBWorkspace(m_params.workspaceDir)); 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); - 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; } @@ -102,35 +96,32 @@ namespace EventBuilder { EVB_WARN("Failed to write to config to file {0}, unable to open file!", fullpath); return; } - - output<<"-------Data Location----------"<AddFrame(bkelabel, lhints); beamFrame->AddFrame(fBKEField, fhints); 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); bfFrame->AddFrame(bfieldlabel, lhints); bfFrame->AddFrame(fBField, fhints); diff --git a/src/guidict/EVBMainFrame.h b/src/guidict/EVBMainFrame.h index 3ab2419..afc510c 100644 --- a/src/guidict/EVBMainFrame.h +++ b/src/guidict/EVBMainFrame.h @@ -97,7 +97,5 @@ private: int counter; UInt_t MAIN_W, MAIN_H; - - }; #endif diff --git a/vendor/yaml-cpp b/vendor/yaml-cpp new file mode 160000 index 0000000..c73ee34 --- /dev/null +++ b/vendor/yaml-cpp @@ -0,0 +1 @@ +Subproject commit c73ee34704c512ebe915b283645aefa9f424a22f