diff --git a/.gitignore b/.gitignore index c4b8f47..f9dd3a7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,7 @@ *.so *.a *.sublime-workspace +Makefile +*.make !.gitignore diff --git a/bin-int/Debug-linux-x86_64/NavProject/main.d b/bin-int/Debug-linux-x86_64/NavProject/main.d new file mode 100644 index 0000000..f123412 --- /dev/null +++ b/bin-int/Debug-linux-x86_64/NavProject/main.d @@ -0,0 +1,129 @@ +bin-int/Debug-linux-x86_64/NavProject/main.o: src/main.cpp \ + src/Navigator.h src/Navigator/Logger.h \ + src/vendor/spdlog/include/spdlog/spdlog.h \ + src/vendor/spdlog/include/spdlog/common.h \ + src/vendor/spdlog/include/spdlog/tweakme.h \ + src/vendor/spdlog/include/spdlog/details/null_mutex.h \ + src/vendor/spdlog/include/spdlog/fmt/fmt.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/core.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/format.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/core.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/format-inl.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/format.h \ + src/vendor/spdlog/include/spdlog/common-inl.h \ + src/vendor/spdlog/include/spdlog/details/registry.h \ + src/vendor/spdlog/include/spdlog/details/registry-inl.h \ + src/vendor/spdlog/include/spdlog/details/periodic_worker.h \ + src/vendor/spdlog/include/spdlog/details/periodic_worker-inl.h \ + src/vendor/spdlog/include/spdlog/logger.h \ + src/vendor/spdlog/include/spdlog/details/log_msg.h \ + src/vendor/spdlog/include/spdlog/details/log_msg-inl.h \ + src/vendor/spdlog/include/spdlog/details/os.h \ + src/vendor/spdlog/include/spdlog/details/os-inl.h \ + src/vendor/spdlog/include/spdlog/details/backtracer.h \ + src/vendor/spdlog/include/spdlog/details/log_msg_buffer.h \ + src/vendor/spdlog/include/spdlog/details/log_msg_buffer-inl.h \ + src/vendor/spdlog/include/spdlog/details/circular_q.h \ + src/vendor/spdlog/include/spdlog/details/backtracer-inl.h \ + src/vendor/spdlog/include/spdlog/logger-inl.h \ + src/vendor/spdlog/include/spdlog/sinks/sink.h \ + src/vendor/spdlog/include/spdlog/formatter.h \ + src/vendor/spdlog/include/spdlog/sinks/sink-inl.h \ + src/vendor/spdlog/include/spdlog/pattern_formatter.h \ + src/vendor/spdlog/include/spdlog/pattern_formatter-inl.h \ + src/vendor/spdlog/include/spdlog/details/fmt_helper.h \ + src/vendor/spdlog/include/spdlog/sinks/ansicolor_sink.h \ + src/vendor/spdlog/include/spdlog/details/console_globals.h \ + src/vendor/spdlog/include/spdlog/sinks/ansicolor_sink-inl.h \ + src/vendor/spdlog/include/spdlog/version.h \ + src/vendor/spdlog/include/spdlog/details/synchronous_factory.h \ + src/vendor/spdlog/include/spdlog/spdlog-inl.h \ + src/vendor/spdlog/include/spdlog/fmt/ostr.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/ostream.h \ + src/Navigator/Application.h + +src/Navigator.h: + +src/Navigator/Logger.h: + +src/vendor/spdlog/include/spdlog/spdlog.h: + +src/vendor/spdlog/include/spdlog/common.h: + +src/vendor/spdlog/include/spdlog/tweakme.h: + +src/vendor/spdlog/include/spdlog/details/null_mutex.h: + +src/vendor/spdlog/include/spdlog/fmt/fmt.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/core.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/format.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/core.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/format-inl.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/format.h: + +src/vendor/spdlog/include/spdlog/common-inl.h: + +src/vendor/spdlog/include/spdlog/details/registry.h: + +src/vendor/spdlog/include/spdlog/details/registry-inl.h: + +src/vendor/spdlog/include/spdlog/details/periodic_worker.h: + +src/vendor/spdlog/include/spdlog/details/periodic_worker-inl.h: + +src/vendor/spdlog/include/spdlog/logger.h: + +src/vendor/spdlog/include/spdlog/details/log_msg.h: + +src/vendor/spdlog/include/spdlog/details/log_msg-inl.h: + +src/vendor/spdlog/include/spdlog/details/os.h: + +src/vendor/spdlog/include/spdlog/details/os-inl.h: + +src/vendor/spdlog/include/spdlog/details/backtracer.h: + +src/vendor/spdlog/include/spdlog/details/log_msg_buffer.h: + +src/vendor/spdlog/include/spdlog/details/log_msg_buffer-inl.h: + +src/vendor/spdlog/include/spdlog/details/circular_q.h: + +src/vendor/spdlog/include/spdlog/details/backtracer-inl.h: + +src/vendor/spdlog/include/spdlog/logger-inl.h: + +src/vendor/spdlog/include/spdlog/sinks/sink.h: + +src/vendor/spdlog/include/spdlog/formatter.h: + +src/vendor/spdlog/include/spdlog/sinks/sink-inl.h: + +src/vendor/spdlog/include/spdlog/pattern_formatter.h: + +src/vendor/spdlog/include/spdlog/pattern_formatter-inl.h: + +src/vendor/spdlog/include/spdlog/details/fmt_helper.h: + +src/vendor/spdlog/include/spdlog/sinks/ansicolor_sink.h: + +src/vendor/spdlog/include/spdlog/details/console_globals.h: + +src/vendor/spdlog/include/spdlog/sinks/ansicolor_sink-inl.h: + +src/vendor/spdlog/include/spdlog/version.h: + +src/vendor/spdlog/include/spdlog/details/synchronous_factory.h: + +src/vendor/spdlog/include/spdlog/spdlog-inl.h: + +src/vendor/spdlog/include/spdlog/fmt/ostr.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/ostream.h: + +src/Navigator/Application.h: diff --git a/bin-int/Debug-linux-x86_64/Navigator/Application.d b/bin-int/Debug-linux-x86_64/Navigator/Application.d new file mode 100644 index 0000000..5b7236f --- /dev/null +++ b/bin-int/Debug-linux-x86_64/Navigator/Application.d @@ -0,0 +1,6 @@ +bin-int/Debug-linux-x86_64/Navigator/Application.o: \ + src/Navigator/Application.cpp src/navpch.h src/Navigator/Application.h + +src/navpch.h: + +src/Navigator/Application.h: diff --git a/bin-int/Debug-linux-x86_64/Navigator/CompassFile.d b/bin-int/Debug-linux-x86_64/Navigator/CompassFile.d new file mode 100644 index 0000000..fe657b7 --- /dev/null +++ b/bin-int/Debug-linux-x86_64/Navigator/CompassFile.d @@ -0,0 +1,11 @@ +bin-int/Debug-linux-x86_64/Navigator/CompassFile.o: \ + src/Navigator/CompassFile.cpp src/navpch.h src/Navigator/CompassFile.h \ + src/Navigator/CompassHit.h src/Navigator/ShiftMap.h + +src/navpch.h: + +src/Navigator/CompassFile.h: + +src/Navigator/CompassHit.h: + +src/Navigator/ShiftMap.h: diff --git a/bin-int/Debug-linux-x86_64/Navigator/CompassRun.d b/bin-int/Debug-linux-x86_64/Navigator/CompassRun.d new file mode 100644 index 0000000..0838edf --- /dev/null +++ b/bin-int/Debug-linux-x86_64/Navigator/CompassRun.d @@ -0,0 +1,14 @@ +bin-int/Debug-linux-x86_64/Navigator/CompassRun.o: \ + src/Navigator/CompassRun.cpp src/navpch.h src/Navigator/CompassRun.h \ + src/Navigator/CompassFile.h src/Navigator/CompassHit.h \ + src/Navigator/ShiftMap.h + +src/navpch.h: + +src/Navigator/CompassRun.h: + +src/Navigator/CompassFile.h: + +src/Navigator/CompassHit.h: + +src/Navigator/ShiftMap.h: diff --git a/bin-int/Debug-linux-x86_64/Navigator/Logger.d b/bin-int/Debug-linux-x86_64/Navigator/Logger.d new file mode 100644 index 0000000..e207d9c --- /dev/null +++ b/bin-int/Debug-linux-x86_64/Navigator/Logger.d @@ -0,0 +1,12 @@ +bin-int/Debug-linux-x86_64/Navigator/Logger.o: src/Navigator/Logger.cpp \ + src/navpch.h src/Navigator/Logger.h \ + src/vendor/spdlog/include/spdlog/sinks/stdout_color_sinks.h \ + src/vendor/spdlog/include/spdlog/sinks/stdout_color_sinks-inl.h + +src/navpch.h: + +src/Navigator/Logger.h: + +src/vendor/spdlog/include/spdlog/sinks/stdout_color_sinks.h: + +src/vendor/spdlog/include/spdlog/sinks/stdout_color_sinks-inl.h: diff --git a/bin-int/Debug-linux-x86_64/Navigator/ShiftMap.d b/bin-int/Debug-linux-x86_64/Navigator/ShiftMap.d new file mode 100644 index 0000000..f349ea7 --- /dev/null +++ b/bin-int/Debug-linux-x86_64/Navigator/ShiftMap.d @@ -0,0 +1,6 @@ +bin-int/Debug-linux-x86_64/Navigator/ShiftMap.o: \ + src/Navigator/ShiftMap.cpp src/navpch.h src/Navigator/ShiftMap.h + +src/navpch.h: + +src/Navigator/ShiftMap.h: diff --git a/bin-int/Debug-linux-x86_64/Navigator/navpch.h b/bin-int/Debug-linux-x86_64/Navigator/navpch.h new file mode 100644 index 0000000..e69de29 diff --git a/bin-int/Debug-linux-x86_64/Navigator/navpch.h.d b/bin-int/Debug-linux-x86_64/Navigator/navpch.h.d new file mode 100644 index 0000000..e6f1f19 --- /dev/null +++ b/bin-int/Debug-linux-x86_64/Navigator/navpch.h.d @@ -0,0 +1,123 @@ +bin-int/Debug-linux-x86_64/Navigator/navpch.h.gch: src/navpch.h \ + src/Navigator/Logger.h src/vendor/spdlog/include/spdlog/spdlog.h \ + src/vendor/spdlog/include/spdlog/common.h \ + src/vendor/spdlog/include/spdlog/tweakme.h \ + src/vendor/spdlog/include/spdlog/details/null_mutex.h \ + src/vendor/spdlog/include/spdlog/fmt/fmt.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/core.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/format.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/core.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/format-inl.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/format.h \ + src/vendor/spdlog/include/spdlog/common-inl.h \ + src/vendor/spdlog/include/spdlog/details/registry.h \ + src/vendor/spdlog/include/spdlog/details/registry-inl.h \ + src/vendor/spdlog/include/spdlog/details/periodic_worker.h \ + src/vendor/spdlog/include/spdlog/details/periodic_worker-inl.h \ + src/vendor/spdlog/include/spdlog/logger.h \ + src/vendor/spdlog/include/spdlog/details/log_msg.h \ + src/vendor/spdlog/include/spdlog/details/log_msg-inl.h \ + src/vendor/spdlog/include/spdlog/details/os.h \ + src/vendor/spdlog/include/spdlog/details/os-inl.h \ + src/vendor/spdlog/include/spdlog/details/backtracer.h \ + src/vendor/spdlog/include/spdlog/details/log_msg_buffer.h \ + src/vendor/spdlog/include/spdlog/details/log_msg_buffer-inl.h \ + src/vendor/spdlog/include/spdlog/details/circular_q.h \ + src/vendor/spdlog/include/spdlog/details/backtracer-inl.h \ + src/vendor/spdlog/include/spdlog/logger-inl.h \ + src/vendor/spdlog/include/spdlog/sinks/sink.h \ + src/vendor/spdlog/include/spdlog/formatter.h \ + src/vendor/spdlog/include/spdlog/sinks/sink-inl.h \ + src/vendor/spdlog/include/spdlog/pattern_formatter.h \ + src/vendor/spdlog/include/spdlog/pattern_formatter-inl.h \ + src/vendor/spdlog/include/spdlog/details/fmt_helper.h \ + src/vendor/spdlog/include/spdlog/sinks/ansicolor_sink.h \ + src/vendor/spdlog/include/spdlog/details/console_globals.h \ + src/vendor/spdlog/include/spdlog/sinks/ansicolor_sink-inl.h \ + src/vendor/spdlog/include/spdlog/version.h \ + src/vendor/spdlog/include/spdlog/details/synchronous_factory.h \ + src/vendor/spdlog/include/spdlog/spdlog-inl.h \ + src/vendor/spdlog/include/spdlog/fmt/ostr.h \ + src/vendor/spdlog/include/spdlog/fmt/bundled/ostream.h + +src/Navigator/Logger.h: + +src/vendor/spdlog/include/spdlog/spdlog.h: + +src/vendor/spdlog/include/spdlog/common.h: + +src/vendor/spdlog/include/spdlog/tweakme.h: + +src/vendor/spdlog/include/spdlog/details/null_mutex.h: + +src/vendor/spdlog/include/spdlog/fmt/fmt.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/core.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/format.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/core.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/format-inl.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/format.h: + +src/vendor/spdlog/include/spdlog/common-inl.h: + +src/vendor/spdlog/include/spdlog/details/registry.h: + +src/vendor/spdlog/include/spdlog/details/registry-inl.h: + +src/vendor/spdlog/include/spdlog/details/periodic_worker.h: + +src/vendor/spdlog/include/spdlog/details/periodic_worker-inl.h: + +src/vendor/spdlog/include/spdlog/logger.h: + +src/vendor/spdlog/include/spdlog/details/log_msg.h: + +src/vendor/spdlog/include/spdlog/details/log_msg-inl.h: + +src/vendor/spdlog/include/spdlog/details/os.h: + +src/vendor/spdlog/include/spdlog/details/os-inl.h: + +src/vendor/spdlog/include/spdlog/details/backtracer.h: + +src/vendor/spdlog/include/spdlog/details/log_msg_buffer.h: + +src/vendor/spdlog/include/spdlog/details/log_msg_buffer-inl.h: + +src/vendor/spdlog/include/spdlog/details/circular_q.h: + +src/vendor/spdlog/include/spdlog/details/backtracer-inl.h: + +src/vendor/spdlog/include/spdlog/logger-inl.h: + +src/vendor/spdlog/include/spdlog/sinks/sink.h: + +src/vendor/spdlog/include/spdlog/formatter.h: + +src/vendor/spdlog/include/spdlog/sinks/sink-inl.h: + +src/vendor/spdlog/include/spdlog/pattern_formatter.h: + +src/vendor/spdlog/include/spdlog/pattern_formatter-inl.h: + +src/vendor/spdlog/include/spdlog/details/fmt_helper.h: + +src/vendor/spdlog/include/spdlog/sinks/ansicolor_sink.h: + +src/vendor/spdlog/include/spdlog/details/console_globals.h: + +src/vendor/spdlog/include/spdlog/sinks/ansicolor_sink-inl.h: + +src/vendor/spdlog/include/spdlog/version.h: + +src/vendor/spdlog/include/spdlog/details/synchronous_factory.h: + +src/vendor/spdlog/include/spdlog/spdlog-inl.h: + +src/vendor/spdlog/include/spdlog/fmt/ostr.h: + +src/vendor/spdlog/include/spdlog/fmt/bundled/ostream.h: diff --git a/bin-int/Debug-linux-x86_64/Navigator/navpch.h.gch b/bin-int/Debug-linux-x86_64/Navigator/navpch.h.gch new file mode 100644 index 0000000..dc8fc9a Binary files /dev/null and b/bin-int/Debug-linux-x86_64/Navigator/navpch.h.gch differ diff --git a/bin/Debug-linux-x86_64/NavProject/NavProject b/bin/Debug-linux-x86_64/NavProject/NavProject new file mode 100755 index 0000000..5f86784 Binary files /dev/null and b/bin/Debug-linux-x86_64/NavProject/NavProject differ diff --git a/navigator.sublime-project b/navigator.sublime-project index adc9cbc..dd94fca 100644 --- a/navigator.sublime-project +++ b/navigator.sublime-project @@ -7,6 +7,6 @@ ], "settings": { - "SublimeLinter.linters.g++.args": ["-c","-Wall","-fsyntax-only","-std=c++17","-include${folder}/src/navpch.h","-Isrc/"] + "SublimeLinter.linters.g++.args": ["-c","-Wall","-fsyntax-only","-std=c++17","-include${folder}/src/navpch.h","-Isrc/", "-Isrc/vendor/spdlog/include"] } } \ No newline at end of file diff --git a/premake5.lua b/premake5.lua new file mode 100644 index 0000000..60bb0e7 --- /dev/null +++ b/premake5.lua @@ -0,0 +1,107 @@ +workspace "Nova" + architecture "x64" + configurations { + "Debug", + "Release" + } + startproject "NavProject" + + + +outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}" +-- External directories to be included +IncludeDirs ={} +IncludeDirs["glfw"] = "src/vendor/glfw/include" +IncludeDirs["ImGui"] = "src/vendor/imgui" + +include "src/vendor/glfw" +include "src/vendor/imgui" +project "Navigator" + kind "StaticLib" + language "C++" + cppdialect "C++17" + staticruntime "on" + targetdir ("lib/" .. outputdir .. "/%{prj.name}") + objdir ("bin-int/" .. outputdir .. "/%{prj.name}") + pchheader "navpch.h" + pchsource "navpch.cpp" + + files { + "src/%{prj.name}/**.h", + "src/%{prj.name}/**.cpp" + } + + defines { + "_CRT_SECURE_NO_WARNINGS" + } + + includedirs { + "src/", + "src/vendor/spdlog/include/", + "src/%{prj.name}/", + "%{IncludeDirs.glfw}", + "%{IncludeDirs.ImGui}", + } + + links { + "GLFW", + "ImGui", + "opengl32.lib" + } + + systemversion "latest" + + defines { + "GLFW_INCLUDE_NONE" + } + + filter "configurations:Debug" + defines "NAV_DEBUG" + runtime "Debug" + symbols "on" + + filter "configurations:Release" + defines "NAV_RELEASE" + runtime "Release" + optimize "on" + +project "NavProject" + kind "ConsoleApp" + language "C++" + cppdialect "C++17" + staticruntime "on" + targetdir ("bin/" .. outputdir .. "/%{prj.name}") + objdir ("bin-int/" .. outputdir .. "/%{prj.name}") + + files { + "src/main.cpp" + } + + + includedirs { + "src/Navigator", + "src/vendor/spdlog/include/", + "src/vendor" + } + + links { + "Navigator" + } + + + systemversion "latest" + + filter "configurations:Debug" + defines "NAV_DEBUG" + runtime "Debug" + symbols "on" + + filter "configurations:Release" + defines "NAV_RELEASE" + runtime "Release" + optimize "on" + + filter "configurations:Dist" + defines "NAV_DIST" + runtime "Release" + optimize "on" \ No newline at end of file diff --git a/src/Navigator.h b/src/Navigator.h new file mode 100644 index 0000000..683554b --- /dev/null +++ b/src/Navigator.h @@ -0,0 +1,7 @@ +#ifndef NAVIGATOR_H +#define NAVIGATOR_H + +#include "Navigator/Logger.h" +#include "Navigator/Application.h" + +#endif \ No newline at end of file diff --git a/src/Navigator/Application.cpp b/src/Navigator/Application.cpp new file mode 100644 index 0000000..30b420a --- /dev/null +++ b/src/Navigator/Application.cpp @@ -0,0 +1,31 @@ +#include +#include "Application.h" + +namespace Navigator { + + Application* Application::s_instance = nullptr; + + Application::Application() : + m_runFlag(true) + { + s_instance = this; + } + + Application::~Application() {} + + + void Application::OnEvent() {} + + void Application::PushLayer() {} + + void Application::PushOverlay() {} + + void Application::Run() + { + while(m_runFlag) + { + NAV_TRACE("Doing a run."); + m_runFlag = false; + } + } +} \ No newline at end of file diff --git a/src/Navigator/Application.h b/src/Navigator/Application.h new file mode 100644 index 0000000..a3cff1a --- /dev/null +++ b/src/Navigator/Application.h @@ -0,0 +1,33 @@ +#ifndef APPLICATION_H +#define APPLICATION_H + + +namespace Navigator { + + class Application + { + public: + Application(); + virtual ~Application(); + + void Run(); + + void OnEvent(); + void PushLayer(); + void PushOverlay(); + + inline static Application& Get() { return *s_instance; } + + inline void GetWindow() { return; } + + private: + + bool m_runFlag; + + static Application* s_instance; + }; + + Application* CreateApplication(); +} + +#endif \ No newline at end of file diff --git a/src/Navigator/CompassFile.cpp b/src/Navigator/CompassFile.cpp index 964a1fc..cbb2c0c 100644 --- a/src/Navigator/CompassFile.cpp +++ b/src/Navigator/CompassFile.cpp @@ -74,7 +74,7 @@ namespace Navigator { { if(!IsOpen()) { - EVB_WARN("Unable to get hit size from file {0}, sending invalid value.", m_filename); + NAV_WARN("Unable to get hit size from file {0}, sending invalid value.", m_filename); return 0; } diff --git a/src/Navigator/CompassRun.cpp b/src/Navigator/CompassRun.cpp index e159861..07bba4a 100644 --- a/src/Navigator/CompassRun.cpp +++ b/src/Navigator/CompassRun.cpp @@ -11,116 +11,22 @@ */ #include #include "CompassRun.h" -#include "RunCollector.h" -#include "SlowSort.h" -#include "FastSort.h" -#include "SFPAnalyzer.h" -#include "FlagHandler.h" namespace Navigator { CompassRun::CompassRun() : - m_directory(""), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_progressFraction(0.1) + m_directory("") { } CompassRun::CompassRun(const std::string& dir) : - m_directory(dir), m_scalerinput(""), m_runNum(0), m_scaler_flag(false), m_progressFraction(0.1) + m_directory(dir) { } CompassRun::~CompassRun() {} - - /*Load em into a map*/ - void CompassRun::SetScalers() - { - std::ifstream input(m_scalerinput); - if(!input.is_open()) - return; - - m_scaler_flag = true; - std::string junk, filename, varname; - Long64_t init = 0; - std::getline(input, junk); - std::getline(input, junk); - m_scaler_map.clear(); - while(input>>filename) - { - input>>varname; - filename = m_directory+filename+"_run_"+std::to_string(m_runNum)+".bin"; - m_scaler_map[filename] = TParameter(varname.c_str(), init); - } - input.close(); - } - - bool CompassRun::GetBinaryFiles() - { - std::string prefix = ""; - std::string suffix = ".bin"; //binaries - RunCollector grabber(m_directory, prefix, suffix); - grabber.GrabAllFiles(); - - m_datafiles.clear(); //so that the CompassRun can be reused - m_datafiles.reserve(grabber.GetFileList().size()); - bool scalerd; - m_totalHits = 0; //reset total run size - - for(auto& entry : grabber.GetFileList()) - { - //Handle scaler files, if they exist - if(m_scaler_flag) - { - scalerd = false; - for(auto& scaler_pair : m_scaler_map) - { - if(entry == scaler_pair.first) - { - ReadScalerData(entry); - scalerd = true; - break; - } - } - if(scalerd) - continue; - } - - m_datafiles.emplace_back(entry); - m_datafiles[m_datafiles.size()-1].AttachShiftMap(&m_smap); - //Any time we have a file that fails to be found, we terminate the whole process - if(!m_datafiles[m_datafiles.size() - 1].IsOpen()) - return false; - - m_totalHits += m_datafiles[m_datafiles.size()-1].GetNumberOfHits(); - } - - return true; - } - - /* - Pure counting of scalers. Potential upgrade path to something like - average count rate etc. - */ - void CompassRun::ReadScalerData(const std::string& filename) - { - if(!m_scaler_flag) - return; - - Long64_t count; - count = 0; - CompassFile file(filename); - auto& this_param = m_scaler_map[file.GetName()]; - while(true) - { - file.GetNextHit(); - if(file.IsEOF()) - break; - count++; - } - this_param.SetVal(count); - } - /* GetHitsFromFiles() is the function which actually retrieves and sorts the data from the individual files. There are several tricks which allow this to happen. First is that, after sorting, it is impossible @@ -161,383 +67,5 @@ namespace Navigator { *earliestHit.second = true; return true; } - - void CompassRun::Convert2RawRoot(const std::string& name) { - TFile* output = TFile::Open(name.c_str(), "RECREATE"); - TTree* outtree = new TTree("Data", "Data"); - - outtree->Branch("Board", &hit.board); - outtree->Branch("Channel", &hit.channel); - outtree->Branch("Energy", &hit.lgate); - outtree->Branch("EnergyShort", &hit.sgate); - outtree->Branch("Timestamp", &hit.timestamp); - outtree->Branch("Flags", &hit.flags); - - if(!m_smap.IsValid()) - { - EVB_WARN("Bad shift map ({0}) at CompassRun::Convert(), shifts all set to 0.", m_smap.GetFilename()); - } - - SetScalers(); - - if(!GetBinaryFiles()) - { - EVB_ERROR("Unable to find binary files at CompassRun::Convert(), exiting!"); - return; - } - - unsigned int count = 0, flush = m_totalHits*m_progressFraction, flush_count = 0; - - startIndex = 0; //Reset the startIndex - if(flush == 0) - flush = 1; - while(true) - { - count++; - if(count == flush) - { //Progress Log - count = 0; - flush_count++; - m_progressCallback(flush_count*flush, m_totalHits); - } - - if(!GetHitsFromFiles()) - break; - outtree->Fill(); - } - - output->cd(); - outtree->Write(outtree->GetName(), TObject::kOverwrite); - for(auto& entry : m_scaler_map) - entry.second.Write(); - - output->Close(); - } - - void CompassRun::Convert2SortedRoot(const std::string& name, const std::string& mapfile, double window) - { - TFile* output = TFile::Open(name.c_str(), "RECREATE"); - TTree* outtree = new TTree("SortTree", "SortTree"); - - outtree->Branch("event", &event); - - if(!m_smap.IsValid()) - { - EVB_WARN("Bad shift map ({0}) at CompassRun::Convert2SortedRoot(), shifts all set to 0.", m_smap.GetFilename()); - } - - SetScalers(); - - if(!GetBinaryFiles()) - { - EVB_ERROR("Unable to find binary files at CompassRun::Convert2SortedRoot(), exiting!"); - return; - } - - unsigned int count = 0, flush = m_totalHits*m_progressFraction, flush_count = 0; - - startIndex = 0; - SlowSort coincidizer(window, mapfile); - bool killFlag = false; - if(flush == 0) - flush = 1; - while(true) - { - count++; - if(count == flush) - { - count = 0; - flush_count++; - m_progressCallback(flush_count*flush, m_totalHits); - } - - if(!GetHitsFromFiles()) - { - coincidizer.FlushHitsToEvent(); - killFlag = true; - } - else - coincidizer.AddHitToEvent(hit); - - if(coincidizer.IsEventReady()) - { - event = coincidizer.GetEvent(); - outtree->Fill(); - if(killFlag) break; - } - } - - output->cd(); - outtree->Write(outtree->GetName(), TObject::kOverwrite); - for(auto& entry : m_scaler_map) - entry.second.Write(); - - coincidizer.GetEventStats()->Write(); - output->Close(); - } - - void CompassRun::Convert2FastSortedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window) - { - TFile* output = TFile::Open(name.c_str(), "RECREATE"); - TTree* outtree = new TTree("SortTree", "SortTree"); - - outtree->Branch("event", &event); - - if(!m_smap.IsValid()) - { - EVB_WARN("Bad shift map ({0}) at CompassRun::Convert2FastSortedRoot(), shifts all set to 0.", m_smap.GetFilename()); - } - - SetScalers(); - - if(!GetBinaryFiles()) - { - EVB_ERROR("Unable to find binary files at CompassRun::Convert2FastSortedRoot(), exiting!"); - return; - } - - unsigned int count = 0, flush = m_totalHits*m_progressFraction, flush_count = 0; - - startIndex = 0; - CoincEvent this_event; - std::vector fast_events; - SlowSort coincidizer(window, mapfile); - FastSort speedyCoincidizer(fsi_window, fic_window); - - FlagHandler flagger; - - bool killFlag = false; - if(flush == 0) - flush = 1; - while(true) - { - count++; - if(count == flush) - { - count = 0; - flush_count++; - m_progressCallback(flush_count*flush, m_totalHits); - } - - if(!GetHitsFromFiles()) - { - coincidizer.FlushHitsToEvent(); - killFlag = true; - } - else - { - flagger.CheckFlag(hit.board, hit.channel, hit.flags); - coincidizer.AddHitToEvent(hit); - } - - if(coincidizer.IsEventReady()) - { - this_event = coincidizer.GetEvent(); - - fast_events = speedyCoincidizer.GetFastEvents(this_event); - for(auto& entry : fast_events) - { - event = entry; - outtree->Fill(); - } - if(killFlag) - break; - } - } - - output->cd(); - outtree->Write(outtree->GetName(), TObject::kOverwrite); - for(auto& entry : m_scaler_map) - entry.second.Write(); - - coincidizer.GetEventStats()->Write(); - output->Close(); - } - - - void CompassRun::Convert2SlowAnalyzedRoot(const std::string& name, const std::string& mapfile, double window, - int zt, int at, int zp, int ap, int ze, int ae, double bke, double b, double theta) - { - - TFile* output = TFile::Open(name.c_str(), "RECREATE"); - TTree* outtree = new TTree("SPSTree", "SPSTree"); - - outtree->Branch("event", &pevent); - - if(!m_smap.IsValid()) - { - EVB_WARN("Bad shift map ({0}) at CompassRun::Convert2SlowAnalyzedRoot(), shifts all set to 0.", m_smap.GetFilename()); - } - - SetScalers(); - - if(!GetBinaryFiles()) - { - EVB_ERROR("Unable to find binary files at CompassRun::Convert2SlowAnalyzedRoot(), exiting!"); - return; - } - - unsigned int count = 0, flush = m_totalHits*m_progressFraction, flush_count = 0; - - startIndex = 0; - CoincEvent this_event; - SlowSort coincidizer(window, mapfile); - SFPAnalyzer analyzer(zt, at, zp, ap, ze, ae, bke, theta, b); - - std::vector> parvec; - parvec.reserve(9); - parvec.emplace_back("ZT", zt); - parvec.emplace_back("AT", at); - parvec.emplace_back("ZP", zp); - parvec.emplace_back("AP", ap); - parvec.emplace_back("ZE", ze); - parvec.emplace_back("AE", ae); - parvec.emplace_back("Bfield", b); - parvec.emplace_back("BeamKE", bke); - parvec.emplace_back("Theta", theta); - - bool killFlag = false; - if(flush == 0) - flush = 1; - while(true) - { - count++; - if(count == flush) - { - count = 0; - flush_count++; - m_progressCallback(flush_count*flush, m_totalHits); - } - - if(!GetHitsFromFiles()) - { - coincidizer.FlushHitsToEvent(); - killFlag = true; - } - else - { - coincidizer.AddHitToEvent(hit); - } - - if(coincidizer.IsEventReady()) - { - this_event = coincidizer.GetEvent(); - pevent = analyzer.GetProcessedEvent(this_event); - outtree->Fill(); - if(killFlag) - break; - } - } - - output->cd(); - outtree->Write(outtree->GetName(), TObject::kOverwrite); - for(auto& entry : m_scaler_map) - entry.second.Write(); - - for(auto& entry : parvec) - entry.Write(); - - coincidizer.GetEventStats()->Write(); - analyzer.GetHashTable()->Write(); - analyzer.ClearHashTable(); - output->Close(); - } - - void CompassRun::Convert2FastAnalyzedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window, - int zt, int at, int zp, int ap, int ze, int ae, double bke, double b, double theta) - { - - TFile* output = TFile::Open(name.c_str(), "RECREATE"); - TTree* outtree = new TTree("SPSTree", "SPSTree"); - - outtree->Branch("event", &pevent); - - if(!m_smap.IsValid()) - { - EVB_WARN("Bad shift map ({0}) at CompassRun::Convert2FastAnalyzedRoot(), shifts all set to 0.", m_smap.GetFilename()); - } - - SetScalers(); - - if(!GetBinaryFiles()) - { - EVB_ERROR("Unable to find binary files at CompassRun::Convert2FastAnalyzedRoot(), exiting!"); - return; - } - - unsigned int count = 0, flush = m_totalHits*m_progressFraction, flush_count = 0; - - startIndex = 0; - CoincEvent this_event; - std::vector fast_events; - SlowSort coincidizer(window, mapfile); - FastSort speedyCoincidizer(fsi_window, fic_window); - SFPAnalyzer analyzer(zt, at, zp, ap, ze, ae, bke, theta, b); - - std::vector> parvec; - parvec.reserve(9); - parvec.emplace_back("ZT", zt); - parvec.emplace_back("AT", at); - parvec.emplace_back("ZP", zp); - parvec.emplace_back("AP", ap); - parvec.emplace_back("ZE", ze); - parvec.emplace_back("AE", ae); - parvec.emplace_back("Bfield", b); - parvec.emplace_back("BeamKE", bke); - parvec.emplace_back("Theta", theta); - - FlagHandler flagger; - - bool killFlag = false; - if(flush == 0) - flush = 1; - while(true) - { - count++; - if(count == flush) - { - count = 0; - flush_count++; - m_progressCallback(flush_count*flush, m_totalHits); - } - - if(!GetHitsFromFiles()) - { - coincidizer.FlushHitsToEvent(); - killFlag = true; - } - else - { - flagger.CheckFlag(hit.board, hit.channel, hit.flags); - coincidizer.AddHitToEvent(hit); - } - - if(coincidizer.IsEventReady()) - { - this_event = coincidizer.GetEvent(); - - fast_events = speedyCoincidizer.GetFastEvents(this_event); - for(auto& entry : fast_events) - { - pevent = analyzer.GetProcessedEvent(entry); - outtree->Fill(); - } - if(killFlag) - break; - } - } - - output->cd(); - outtree->Write(outtree->GetName(), TObject::kOverwrite); - for(auto& entry : m_scaler_map) - entry.second.Write(); - - for(auto& entry : parvec) - entry.Write(); - - coincidizer.GetEventStats()->Write(); - analyzer.GetHashTable()->Write(); - analyzer.ClearHashTable(); - output->Close(); - } + } \ No newline at end of file diff --git a/src/Navigator/CompassRun.h b/src/Navigator/CompassRun.h index 85375ed..adcae7b 100644 --- a/src/Navigator/CompassRun.h +++ b/src/Navigator/CompassRun.h @@ -11,11 +11,7 @@ #define COMPASSRUN_H #include "CompassFile.h" -#include "DataStructs.h" -#include "RunCollector.h" #include "ShiftMap.h" -#include "ProgressCallback.h" -#include namespace Navigator { @@ -27,46 +23,26 @@ namespace Navigator { CompassRun(const std::string& dir); ~CompassRun(); inline void SetDirectory(const std::string& dir) { m_directory = dir; } - inline void SetScalerInput(const std::string& filename) { m_scalerinput = filename; } inline void SetRunNumber(int n) { m_runNum = n; } inline void SetShiftMap(const std::string& filename) { m_smap.SetFile(filename); } - void Convert2RawRoot(const std::string& name); - void Convert2SortedRoot(const std::string& name, const std::string& mapfile, double window); - void Convert2FastSortedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window); - void Convert2SlowAnalyzedRoot(const std::string& name, const std::string& mapfile, double window, - int zt, int at, int zp, int ap, int ze, int ae, double bke, double b, double theta); - void Convert2FastAnalyzedRoot(const std::string& name, const std::string& mapfile, double window, double fsi_window, double fic_window, - int zt, int at, int zp, int ap, int ze, int ae, double bke, double b, double theta); - inline void SetProgressCallbackFunc(const ProgressCallbackFunc& function) { m_progressCallback = function; } - inline void SetProgressFraction(double frac) { m_progressFraction = frac; } private: - bool GetBinaryFiles(); bool GetHitsFromFiles(); - void SetScalers(); - void ReadScalerData(const std::string& filename); - std::string m_directory, m_scalerinput; + std::string m_directory; std::vector m_datafiles; unsigned int startIndex; //this is the file we start looking at; increases as we finish files. ShiftMap m_smap; - std::unordered_map> m_scaler_map; //maps scaler files to the TParameter to be saved //Potential branch variables CompassHit hit; - CoincEvent event; - ProcessedEvent pevent; //what run is this int m_runNum; unsigned int m_totalHits; //Scaler switch - bool m_scaler_flag; - - ProgressCallbackFunc m_progressCallback; - double m_progressFraction; }; } diff --git a/src/Navigator/Logger.cpp b/src/Navigator/Logger.cpp index e69de29..ea92d2f 100644 --- a/src/Navigator/Logger.cpp +++ b/src/Navigator/Logger.cpp @@ -0,0 +1,17 @@ +#include +#include "Logger.h" +#include "spdlog/sinks/stdout_color_sinks.h" + +namespace Navigator { + + std::shared_ptr Logger::s_logger; + + void Logger::Init() + { + spdlog::set_pattern("%^[%T] %n: %v%$"); + + s_logger = spdlog::stdout_color_mt("NAV"); + s_logger->set_level(spdlog::level::trace); + } + +} \ No newline at end of file diff --git a/src/Navigator/Logger.h b/src/Navigator/Logger.h index b7e9745..b3fa28c 100644 --- a/src/Navigator/Logger.h +++ b/src/Navigator/Logger.h @@ -2,4 +2,29 @@ #define LOGGER_H #include "spdlog/spdlog.h" -#include "spdlog/fmt/" \ No newline at end of file +#include "spdlog/fmt/ostr.h" + +namespace Navigator { + + class Logger + { + + public: + static void Init(); + + inline static std::shared_ptr GetLogger() { return s_logger; } + + private: + static std::shared_ptr s_logger; + + }; + +} + +#define NAV_CRITICAL(...) ::Navigator::Logger::GetLogger()->critical(__VA_ARGS__) +#define NAV_WARN(...) ::Navigator::Logger::GetLogger()->warn(__VA_ARGS__) +#define NAV_ERROR(...) ::Navigator::Logger::GetLogger()->error(__VA_ARGS__) +#define NAV_TRACE(...) ::Navigator::Logger::GetLogger()->trace(__VA_ARGS__) +#define NAV_INFO(...) ::Navigator::Logger::GetLogger()->info(__VA_ARGS__) + +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..7f27cf8 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,16 @@ +#include "Navigator.h" + +Navigator::Application* Navigator::CreateApplication() { return new Application(); } + +int main(int argc, const char** argv) +{ + Navigator::Logger::Init(); + NAV_TRACE("Logger Initialized!"); + + auto app = Navigator::CreateApplication(); + + NAV_TRACE("Navigator Application Created!"); + app->Run(); + + delete app; +} \ No newline at end of file diff --git a/src/navpch.cpp b/src/navpch.cpp new file mode 100644 index 0000000..75e0870 --- /dev/null +++ b/src/navpch.cpp @@ -0,0 +1 @@ +#include "navpch.h" \ No newline at end of file diff --git a/src/navpch.h b/src/navpch.h index 54deab9..fd6ce36 100644 --- a/src/navpch.h +++ b/src/navpch.h @@ -17,4 +17,6 @@ #include +#include "Navigator/Logger.h" + #endif \ No newline at end of file