mirror of
https://github.com/sesps/SPS_SABRE_EventBuilder.git
synced 2024-11-22 10:08:50 -05:00
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:
parent
935e6be0f6
commit
4ae9ecadac
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -19,6 +19,7 @@ objs/
|
|||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
*.make
|
||||
*.yaml
|
||||
Makefile
|
||||
event_log.txt
|
||||
.DS_Store
|
||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -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
|
||||
|
|
|
@ -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)
|
|
@ -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})
|
||||
set_target_properties(EventBuilderCore PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${EVB_LIBRARY_DIR})
|
||||
|
||||
target_compile_definitions(EventBuilderCore PRIVATE YAML_CPP_STATIC_DEFINE)
|
|
@ -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<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);
|
||||
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----------"<<std::endl;
|
||||
output<<"WorkspaceDirectory: "<<m_params.workspaceDir<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
output<<"------Experimental Inputs------"<<std::endl;
|
||||
output<<"ChannelMapFile: "<<m_params.channelMapFile<<std::endl;
|
||||
output<<"ScalerFile: "<<m_params.scalerFile<<std::endl;
|
||||
output<<"CutListFile: "<<m_params.cutListFile<<std::endl;
|
||||
output<<"ZT: "<<m_params.ZT<<std::endl;
|
||||
output<<"AT: "<<m_params.AT<<std::endl;
|
||||
output<<"ZP: "<<m_params.ZP<<std::endl;
|
||||
output<<"AP: "<<m_params.AP<<std::endl;
|
||||
output<<"ZE: "<<m_params.ZE<<std::endl;
|
||||
output<<"AE: "<<m_params.AE<<std::endl;
|
||||
output<<"BField(G): "<<m_params.BField<<std::endl;
|
||||
output<<"BeamKE(MeV): "<<m_params.beamEnergy<<std::endl;
|
||||
output<<"Theta(deg): "<<m_params.spsAngle<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
output<<"-------Timing Information------"<<std::endl;
|
||||
output<<"BoardOffsetFile: "<<m_params.timeShiftFile<<std::endl;
|
||||
output<<"SlowCoincidenceWindow(ps): "<<m_params.slowCoincidenceWindow<<std::endl;
|
||||
output<<"FastCoincidenceWindow_IonCh(ps): "<<m_params.fastCoincidenceWindowIonCh<<std::endl;
|
||||
output<<"FastCoincidenceWindow_SABRE(ps): "<<m_params.fastCoincidenceWindowSABRE<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
output<<"--------Run Information--------"<<std::endl;
|
||||
output<<"MinRun: "<<m_params.runMin<<std::endl;
|
||||
output<<"MaxRun: "<<m_params.runMax<<std::endl;
|
||||
output<<"-------------------------------"<<std::endl;
|
||||
|
||||
|
||||
YAML::Emitter yamlStream;
|
||||
yamlStream << YAML::BeginMap;
|
||||
yamlStream << YAML::Key << "WorkspaceDir" << YAML::Value << m_params.workspaceDir;
|
||||
yamlStream << YAML::Key << "ChannelMap" << YAML::Value << m_params.channelMapFile;
|
||||
yamlStream << YAML::Key << "ScalerFile" << YAML::Value << m_params.scalerFile;
|
||||
yamlStream << YAML::Key << "CutListFile" << YAML::Value << m_params.cutListFile;
|
||||
yamlStream << YAML::Key << "TimeShiftFile" << YAML::Value << m_params.timeShiftFile;
|
||||
yamlStream << YAML::Key << "SlowCoincidenceWindow(ps)" << YAML::Value << m_params.slowCoincidenceWindow;
|
||||
yamlStream << YAML::Key << "FastCoincidenceWinowIonCh(ps)" << YAML::Value << m_params.fastCoincidenceWindowIonCh;
|
||||
yamlStream << YAML::Key << "FastCoincidenceWinowSABRE(ps)" << YAML::Value << m_params.fastCoincidenceWindowSABRE;
|
||||
yamlStream << YAML::Key << "ZT" << YAML::Value << m_params.ZT;
|
||||
yamlStream << YAML::Key << "AT" << YAML::Value << m_params.AT;
|
||||
yamlStream << YAML::Key << "ZP" << YAML::Value << m_params.ZP;
|
||||
yamlStream << YAML::Key << "AP" << YAML::Value << m_params.AP;
|
||||
yamlStream << YAML::Key << "ZE" << YAML::Value << m_params.ZE;
|
||||
yamlStream << YAML::Key << "AE" << YAML::Value << m_params.AE;
|
||||
yamlStream << YAML::Key << "BField(kG)" << YAML::Value << m_params.BField;
|
||||
yamlStream << YAML::Key << "BeamEnergy(MeV)" << YAML::Value << m_params.beamEnergy;
|
||||
yamlStream << YAML::Key << "SPSAngle(deg)" << YAML::Value << m_params.spsAngle;
|
||||
yamlStream << YAML::Key << "MinRun" << YAML::Value << m_params.runMin;
|
||||
yamlStream << YAML::Key << "MaxRun" << YAML::Value << m_params.runMax;
|
||||
yamlStream << YAML::EndMap;
|
||||
|
||||
output << yamlStream.c_str();
|
||||
|
||||
output.close();
|
||||
|
||||
EVB_INFO("Successfully wrote config to file.");
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace EventBuilder {
|
|||
SFPAnalyzer::SFPAnalyzer(int zt, int at, int zp, int ap, int ze, int ae, double ep,
|
||||
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();
|
||||
rootObj = new THashTable();
|
||||
GetWeights();
|
||||
|
|
|
@ -136,7 +136,7 @@ EVBMainFrame::EVBMainFrame(const TGWindow* p, UInt_t w, UInt_t h) :
|
|||
beamFrame->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);
|
||||
|
|
|
@ -97,7 +97,5 @@ private:
|
|||
|
||||
int counter;
|
||||
UInt_t MAIN_W, MAIN_H;
|
||||
|
||||
|
||||
};
|
||||
#endif
|
||||
|
|
1
vendor/yaml-cpp
vendored
Submodule
1
vendor/yaml-cpp
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit c73ee34704c512ebe915b283645aefa9f424a22f
|
Loading…
Reference in New Issue
Block a user