mirror of
https://github.com/gwm17/Specter.git
synced 2025-02-21 03:38:52 -05:00
Compare commits
No commits in common. "a26ac08f34f2efa09616f6553710cb88dd33bcc1" and "a3d9f92545095432d7194d42b35674d36ad2589d" have entirely different histories.
a26ac08f34
...
a3d9f92545
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -24,6 +24,3 @@
|
||||||
[submodule "Specter/vendor/yaml-cpp"]
|
[submodule "Specter/vendor/yaml-cpp"]
|
||||||
path = Specter/vendor/yaml-cpp
|
path = Specter/vendor/yaml-cpp
|
||||||
url = https://github.com/jbeder/yaml-cpp.git
|
url = https://github.com/jbeder/yaml-cpp.git
|
||||||
[submodule "Specter/vendor/DaqGrimoire"]
|
|
||||||
path = Specter/vendor/DaqGrimoire
|
|
||||||
url = https://github.com/gwm17/DaqGrimoire.git
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
set(CMAKE_BUILD_TYPE "Debug")
|
set(CMAKE_BUILD_TYPE "Debug")
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
add_subdirectory(vendor/glad)
|
add_subdirectory(vendor/glad)
|
||||||
add_subdirectory(vendor/glfw)
|
add_subdirectory(vendor/glfw)
|
||||||
add_subdirectory(vendor/imgui)
|
add_subdirectory(vendor/imgui)
|
||||||
|
|
||||||
set(YAML_CPP_BUILD_TOOLS Off)
|
|
||||||
add_subdirectory(vendor/yaml-cpp)
|
add_subdirectory(vendor/yaml-cpp)
|
||||||
|
|
||||||
set(GRIMOIRE_ASIO_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/vendor/asio/asio/include)
|
|
||||||
add_subdirectory(vendor/DaqGrimoire)
|
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
|
@ -99,10 +99,6 @@ target_sources(Specter PRIVATE
|
||||||
Platform/OpenGL/OpenGLRendererAPI.h
|
Platform/OpenGL/OpenGLRendererAPI.h
|
||||||
Platform/OpenGL/OpenGLWindow.cpp
|
Platform/OpenGL/OpenGLWindow.cpp
|
||||||
Platform/OpenGL/OpenGLWindow.h
|
Platform/OpenGL/OpenGLWindow.h
|
||||||
Specter/Physics/Daqromancy/DYFileSource.h
|
|
||||||
Specter/Physics/Daqromancy/DYFileSource.cpp
|
|
||||||
Specter/Physics/Daqromancy/DYOnlineSource.h
|
|
||||||
Specter/Physics/Daqromancy/DYOnlineSource.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#ImPlot sources
|
#ImPlot sources
|
||||||
|
@ -118,7 +114,7 @@ target_sources(Specter PRIVATE
|
||||||
)
|
)
|
||||||
|
|
||||||
#Link our accompanying dependencies
|
#Link our accompanying dependencies
|
||||||
target_link_libraries(Specter PRIVATE imgui glfw glad yaml-cpp DaqGrimoire)
|
target_link_libraries(Specter PRIVATE imgui glfw glad yaml-cpp)
|
||||||
|
|
||||||
#Link OS graphics implementations
|
#Link OS graphics implementations
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG On)
|
set(THREADS_PREFER_PTHREAD_FLAG On)
|
||||||
|
|
|
@ -31,8 +31,7 @@ namespace Specter {
|
||||||
SPEC_PROFILE_FUNCTION();
|
SPEC_PROFILE_FUNCTION();
|
||||||
static bool onlineFlag = false;
|
static bool onlineFlag = false;
|
||||||
static bool offlineFlag = false;
|
static bool offlineFlag = false;
|
||||||
static std::vector<DataSource::SourceType> availTypes = { DataSource::SourceType::CompassOnline, DataSource::SourceType::CompassOffline, DataSource::SourceType::DaqromancyOnline,
|
static std::vector<DataSource::SourceType> availTypes = { DataSource::SourceType::CompassOnline, DataSource::SourceType::CompassOffline };
|
||||||
DataSource::SourceType::DaqromancyOffline };
|
|
||||||
|
|
||||||
if (m_openFlag)
|
if (m_openFlag)
|
||||||
{
|
{
|
||||||
|
@ -84,26 +83,6 @@ namespace Specter {
|
||||||
else if (m_chosenType == DataSource::SourceType::CompassOffline)
|
else if (m_chosenType == DataSource::SourceType::CompassOffline)
|
||||||
{
|
{
|
||||||
ImGui::InputText("Run Directory", &m_chosenLocation);
|
ImGui::InputText("Run Directory", &m_chosenLocation);
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::Button("Choose Location"))
|
|
||||||
{
|
|
||||||
m_fileDialog.OpenDialog(FileDialog::Type::OpenDir);
|
|
||||||
}
|
|
||||||
auto temp = m_fileDialog.RenderFileDialog();
|
|
||||||
if (!temp.first.empty() && temp.second == FileDialog::Type::OpenDir)
|
|
||||||
m_chosenLocation = temp.first;
|
|
||||||
ImGui::InputInt("Channels Per Digitizer Board", &m_channels_per_board);
|
|
||||||
}
|
|
||||||
else if (m_chosenType == DataSource::SourceType::DaqromancyOnline)
|
|
||||||
{
|
|
||||||
ImGui::InputText("Hostname", &m_chosenLocation);
|
|
||||||
ImGui::InputText("Port", &m_chosenPort);
|
|
||||||
ImGui::InputInt("Channels Per Digitizer Board", &m_channels_per_board);
|
|
||||||
}
|
|
||||||
else if (m_chosenType == DataSource::SourceType::DaqromancyOffline)
|
|
||||||
{
|
|
||||||
ImGui::InputText("Run Directory", &m_chosenLocation);
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::Button("Choose Location"))
|
if (ImGui::Button("Choose Location"))
|
||||||
{
|
{
|
||||||
m_fileDialog.OpenDialog(FileDialog::Type::OpenDir);
|
m_fileDialog.OpenDialog(FileDialog::Type::OpenDir);
|
||||||
|
@ -118,12 +97,12 @@ namespace Specter {
|
||||||
|
|
||||||
if (ImGui::Button("Ok"))
|
if (ImGui::Button("Ok"))
|
||||||
{
|
{
|
||||||
if (m_chosenType == DataSource::SourceType::CompassOffline || m_chosenType == DataSource::SourceType::DaqromancyOffline)
|
if (m_chosenType == DataSource::SourceType::CompassOffline)
|
||||||
{
|
{
|
||||||
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, false, 0U, m_channels_per_board);
|
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, false, 0U, m_channels_per_board);
|
||||||
Application::Get().OnEvent(event);
|
Application::Get().OnEvent(event);
|
||||||
}
|
}
|
||||||
else if (m_chosenType == DataSource::SourceType::CompassOnline || m_chosenType == DataSource::SourceType::DaqromancyOnline)
|
else if (m_chosenType == DataSource::SourceType::CompassOnline)
|
||||||
{
|
{
|
||||||
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, true, m_bitflags, m_channels_per_board);
|
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, true, m_bitflags, m_channels_per_board);
|
||||||
Application::Get().OnEvent(event);
|
Application::Get().OnEvent(event);
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
#include "DYFileSource.h"
|
|
||||||
|
|
||||||
namespace Specter {
|
|
||||||
|
|
||||||
DYFileSource::DYFileSource(const std::string& directory, int channels_per_board) :
|
|
||||||
DataSource(), m_directory(directory), m_channelsPerBoard(channels_per_board)
|
|
||||||
{
|
|
||||||
CollectFiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
DYFileSource::~DYFileSource()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DYFileSource::CollectFiles()
|
|
||||||
{
|
|
||||||
SPEC_PROFILE_FUNCTION();
|
|
||||||
int nfiles = 0;
|
|
||||||
for (auto& item : std::filesystem::directory_iterator(m_directory))
|
|
||||||
{
|
|
||||||
if (item.path().extension() == s_extension)
|
|
||||||
nfiles++;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_files.clear();
|
|
||||||
m_files.reserve(nfiles);
|
|
||||||
for (auto& item : std::filesystem::directory_iterator(m_directory))
|
|
||||||
{
|
|
||||||
if (item.path().extension() == s_extension)
|
|
||||||
{
|
|
||||||
m_files.emplace_back(item.path().string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long total_hits = 0;
|
|
||||||
for (auto& file : m_files)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!file.IsOpen())
|
|
||||||
{
|
|
||||||
SPEC_ERROR("Unable to open a DYFile file {0}", file.GetFilePath());
|
|
||||||
m_validFlag = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
total_hits += file.GetFileSizeEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_files.size() == 0)
|
|
||||||
{
|
|
||||||
SPEC_WARN("Unable to find any files with extension {0} in directory {1}. CompassRun killed.", s_extension, m_directory);
|
|
||||||
m_validFlag = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SPEC_INFO("Succesfully opened {0} files with {1} total hits", nfiles, total_hits);
|
|
||||||
m_validFlag = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DYFileSource::GetNextHit()
|
|
||||||
{
|
|
||||||
SPEC_PROFILE_FUNCTION();
|
|
||||||
DaqGrimoire::DYFileReader* earliestFile = nullptr;
|
|
||||||
|
|
||||||
for (std::size_t i = m_startIndex; i < m_files.size(); i++)
|
|
||||||
{
|
|
||||||
if (m_files[i].IsHitUsed())
|
|
||||||
m_files[i].ReadNextEvent();
|
|
||||||
|
|
||||||
if (m_files[i].IsEOF())
|
|
||||||
{
|
|
||||||
if (i == m_startIndex)
|
|
||||||
m_startIndex++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (i == m_startIndex || m_files[i].GetCurrentEvent().timestamp < earliestFile->GetCurrentEvent().timestamp)
|
|
||||||
{
|
|
||||||
earliestFile = &(m_files[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (earliestFile == nullptr)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
m_dyHit = earliestFile->GetCurrentEvent();
|
|
||||||
earliestFile->SetHitUsed();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SpecData& DYFileSource::GetData()
|
|
||||||
{
|
|
||||||
if (!IsValid())
|
|
||||||
{
|
|
||||||
SPEC_ERROR("Trying to access DYFileSource data when invalid, bug detected!");
|
|
||||||
m_datum = SpecData();
|
|
||||||
return m_datum;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!GetNextHit())
|
|
||||||
{
|
|
||||||
m_validFlag = false;
|
|
||||||
m_datum = SpecData();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Convert data from Daqromancy format to universal Specter format.
|
|
||||||
m_datum.longEnergy = m_dyHit.energy;
|
|
||||||
m_datum.shortEnergy = m_dyHit.energyShort;
|
|
||||||
m_datum.timestamp = m_dyHit.timestamp;
|
|
||||||
m_datum.id = m_dyHit.board * m_channelsPerBoard + m_dyHit.channel;
|
|
||||||
}
|
|
||||||
return m_datum;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
#ifndef DY_FILE_SOURCE_H
|
|
||||||
#define DY_FILE_SOURCE_H
|
|
||||||
|
|
||||||
#include "DaqGrimoire.h"
|
|
||||||
#include "Specter/Physics/DataSource.h"
|
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
namespace Specter {
|
|
||||||
|
|
||||||
class DYFileSource : public DataSource
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DYFileSource(const std::string& directory, int channels_per_board = 16);
|
|
||||||
virtual ~DYFileSource();
|
|
||||||
|
|
||||||
virtual const SpecData& GetData() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void CollectFiles();
|
|
||||||
bool GetNextHit();
|
|
||||||
|
|
||||||
std::filesystem::path m_directory;
|
|
||||||
static constexpr std::string_view s_extension = ".dybin";
|
|
||||||
int m_channelsPerBoard;
|
|
||||||
|
|
||||||
std::vector<DaqGrimoire::DYFileReader> m_files;
|
|
||||||
DaqGrimoire::DYListData m_dyHit;
|
|
||||||
std::size_t m_startIndex;
|
|
||||||
|
|
||||||
uint64_t m_totalDataHits;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,39 +0,0 @@
|
||||||
#include "DYOnlineSource.h"
|
|
||||||
|
|
||||||
namespace Specter {
|
|
||||||
|
|
||||||
DYOnlineSource::DYOnlineSource(const std::string& hostname, const std::string& port, int channelsPerBoard) :
|
|
||||||
DataSource(), m_clientConnection(hostname, port), m_channelsPerBoard(channelsPerBoard)
|
|
||||||
{
|
|
||||||
m_validFlag = m_clientConnection.IsConnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
DYOnlineSource::~DYOnlineSource()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const SpecData& DYOnlineSource::GetData()
|
|
||||||
{
|
|
||||||
if (!m_clientConnection.IsConnected())
|
|
||||||
{
|
|
||||||
m_validFlag = false;
|
|
||||||
m_datum = SpecData();
|
|
||||||
return m_datum;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_clientConnection.GetNextEvent(m_dyHit))
|
|
||||||
{
|
|
||||||
//Convert data from Daqromancy format to universal Specter format.
|
|
||||||
m_datum.longEnergy = m_dyHit.energy;
|
|
||||||
m_datum.shortEnergy = m_dyHit.energyShort;
|
|
||||||
m_datum.timestamp = m_dyHit.timestamp;
|
|
||||||
m_datum.id = m_dyHit.board * m_channelsPerBoard + m_dyHit.channel;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_datum = SpecData();
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_datum;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
#ifndef DY_ONLINE_SOURCE_H
|
|
||||||
#define DY_ONLINE_SOURCE_H
|
|
||||||
|
|
||||||
#include "Specter/Physics/DataSource.h"
|
|
||||||
#include "NetIO/DYClient.h"
|
|
||||||
|
|
||||||
namespace Specter {
|
|
||||||
|
|
||||||
class DYOnlineSource : public DataSource
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DYOnlineSource(const std::string& hostname, const std::string& port, int channelsPerBoard = 16);
|
|
||||||
~DYOnlineSource();
|
|
||||||
|
|
||||||
virtual const SpecData& GetData() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
DaqGrimoire::DYClient m_clientConnection;
|
|
||||||
DaqGrimoire::DYListData m_dyHit;
|
|
||||||
int m_channelsPerBoard;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -9,8 +9,6 @@
|
||||||
#include "DataSource.h"
|
#include "DataSource.h"
|
||||||
#include "Caen/CompassRun.h"
|
#include "Caen/CompassRun.h"
|
||||||
#include "Caen/CompassOnlineSource.h"
|
#include "Caen/CompassOnlineSource.h"
|
||||||
#include "Daqromancy/DYFileSource.h"
|
|
||||||
#include "Daqromancy/DYOnlineSource.h"
|
|
||||||
|
|
||||||
namespace Specter {
|
namespace Specter {
|
||||||
|
|
||||||
|
@ -21,8 +19,6 @@ namespace Specter {
|
||||||
{
|
{
|
||||||
case DataSource::SourceType::CompassOffline : return new CompassRun(location, channels_per_board);
|
case DataSource::SourceType::CompassOffline : return new CompassRun(location, channels_per_board);
|
||||||
case DataSource::SourceType::CompassOnline : return new CompassOnlineSource(location, port, header, channels_per_board);
|
case DataSource::SourceType::CompassOnline : return new CompassOnlineSource(location, port, header, channels_per_board);
|
||||||
case DataSource::SourceType::DaqromancyOffline: return new DYFileSource(location, channels_per_board);
|
|
||||||
case DataSource::SourceType::DaqromancyOnline: return new DYOnlineSource(location, port, channels_per_board);
|
|
||||||
case DataSource::SourceType::None : return nullptr;
|
case DataSource::SourceType::None : return nullptr;
|
||||||
}
|
}
|
||||||
SPEC_WARN("Invalid DataSourceType at CreateDataSource!");
|
SPEC_WARN("Invalid DataSourceType at CreateDataSource!");
|
||||||
|
@ -36,8 +32,6 @@ namespace Specter {
|
||||||
case DataSource::SourceType::None: return "None";
|
case DataSource::SourceType::None: return "None";
|
||||||
case DataSource::SourceType::CompassOnline : return "CompassOnline";
|
case DataSource::SourceType::CompassOnline : return "CompassOnline";
|
||||||
case DataSource::SourceType::CompassOffline : return "CompassOffline";
|
case DataSource::SourceType::CompassOffline : return "CompassOffline";
|
||||||
case DataSource::SourceType::DaqromancyOffline: return "DaqromancyOffline";
|
|
||||||
case DataSource::SourceType::DaqromancyOnline: return "DaqromancyOnline";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "None";
|
return "None";
|
||||||
|
|
|
@ -21,9 +21,7 @@ namespace Specter {
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
CompassOnline,
|
CompassOnline,
|
||||||
CompassOffline,
|
CompassOffline
|
||||||
DaqromancyOnline,
|
|
||||||
DaqromancyOffline
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DataSource() :
|
DataSource() :
|
||||||
|
|
|
@ -17,11 +17,11 @@ namespace Specter {
|
||||||
|
|
||||||
struct SpecData
|
struct SpecData
|
||||||
{
|
{
|
||||||
uint32_t longEnergy = 0;
|
uint32_t longEnergy;
|
||||||
uint32_t shortEnergy = 0;
|
uint32_t shortEnergy;
|
||||||
uint64_t calEnergy = 0;
|
uint64_t calEnergy;
|
||||||
uint64_t timestamp = 0;
|
uint64_t timestamp;
|
||||||
uint32_t id = 0;
|
uint32_t id;
|
||||||
};
|
};
|
||||||
|
|
||||||
using SpecEvent = std::vector<SpecData>;
|
using SpecEvent = std::vector<SpecData>;
|
||||||
|
|
1
Specter/vendor/DaqGrimoire
vendored
1
Specter/vendor/DaqGrimoire
vendored
|
@ -1 +0,0 @@
|
||||||
Subproject commit dedd1e0e953423a50ec8a35f4cb3161218aac642
|
|
Loading…
Reference in New Issue
Block a user