mirror of
https://github.com/gwm17/Specter.git
synced 2024-11-26 04:08:50 -05:00
Compare commits
3 Commits
a3d9f92545
...
a26ac08f34
Author | SHA1 | Date | |
---|---|---|---|
a26ac08f34 | |||
e2a77a1d75 | |||
957a15e1a7 |
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -24,3 +24,6 @@
|
|||
[submodule "Specter/vendor/yaml-cpp"]
|
||||
path = Specter/vendor/yaml-cpp
|
||||
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)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
add_subdirectory(vendor/glad)
|
||||
add_subdirectory(vendor/glfw)
|
||||
add_subdirectory(vendor/imgui)
|
||||
|
||||
set(YAML_CPP_BUILD_TOOLS Off)
|
||||
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)
|
||||
|
|
|
@ -99,6 +99,10 @@ target_sources(Specter PRIVATE
|
|||
Platform/OpenGL/OpenGLRendererAPI.h
|
||||
Platform/OpenGL/OpenGLWindow.cpp
|
||||
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
|
||||
|
@ -114,7 +118,7 @@ target_sources(Specter PRIVATE
|
|||
)
|
||||
|
||||
#Link our accompanying dependencies
|
||||
target_link_libraries(Specter PRIVATE imgui glfw glad yaml-cpp)
|
||||
target_link_libraries(Specter PRIVATE imgui glfw glad yaml-cpp DaqGrimoire)
|
||||
|
||||
#Link OS graphics implementations
|
||||
set(THREADS_PREFER_PTHREAD_FLAG On)
|
||||
|
|
|
@ -31,7 +31,8 @@ namespace Specter {
|
|||
SPEC_PROFILE_FUNCTION();
|
||||
static bool onlineFlag = false;
|
||||
static bool offlineFlag = false;
|
||||
static std::vector<DataSource::SourceType> availTypes = { DataSource::SourceType::CompassOnline, DataSource::SourceType::CompassOffline };
|
||||
static std::vector<DataSource::SourceType> availTypes = { DataSource::SourceType::CompassOnline, DataSource::SourceType::CompassOffline, DataSource::SourceType::DaqromancyOnline,
|
||||
DataSource::SourceType::DaqromancyOffline };
|
||||
|
||||
if (m_openFlag)
|
||||
{
|
||||
|
@ -83,6 +84,26 @@ namespace Specter {
|
|||
else if (m_chosenType == DataSource::SourceType::CompassOffline)
|
||||
{
|
||||
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"))
|
||||
{
|
||||
m_fileDialog.OpenDialog(FileDialog::Type::OpenDir);
|
||||
|
@ -97,12 +118,12 @@ namespace Specter {
|
|||
|
||||
if (ImGui::Button("Ok"))
|
||||
{
|
||||
if (m_chosenType == DataSource::SourceType::CompassOffline)
|
||||
if (m_chosenType == DataSource::SourceType::CompassOffline || m_chosenType == DataSource::SourceType::DaqromancyOffline)
|
||||
{
|
||||
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, false, 0U, m_channels_per_board);
|
||||
Application::Get().OnEvent(event);
|
||||
}
|
||||
else if (m_chosenType == DataSource::SourceType::CompassOnline)
|
||||
else if (m_chosenType == DataSource::SourceType::CompassOnline || m_chosenType == DataSource::SourceType::DaqromancyOnline)
|
||||
{
|
||||
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, true, m_bitflags, m_channels_per_board);
|
||||
Application::Get().OnEvent(event);
|
||||
|
|
115
Specter/src/Specter/Physics/Daqromancy/DYFileSource.cpp
Normal file
115
Specter/src/Specter/Physics/Daqromancy/DYFileSource.cpp
Normal file
|
@ -0,0 +1,115 @@
|
|||
#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;
|
||||
}
|
||||
}
|
34
Specter/src/Specter/Physics/Daqromancy/DYFileSource.h
Normal file
34
Specter/src/Specter/Physics/Daqromancy/DYFileSource.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#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
|
39
Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.cpp
Normal file
39
Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#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;
|
||||
}
|
||||
}
|
24
Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.h
Normal file
24
Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#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,6 +9,8 @@
|
|||
#include "DataSource.h"
|
||||
#include "Caen/CompassRun.h"
|
||||
#include "Caen/CompassOnlineSource.h"
|
||||
#include "Daqromancy/DYFileSource.h"
|
||||
#include "Daqromancy/DYOnlineSource.h"
|
||||
|
||||
namespace Specter {
|
||||
|
||||
|
@ -19,6 +21,8 @@ namespace Specter {
|
|||
{
|
||||
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::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;
|
||||
}
|
||||
SPEC_WARN("Invalid DataSourceType at CreateDataSource!");
|
||||
|
@ -32,6 +36,8 @@ namespace Specter {
|
|||
case DataSource::SourceType::None: return "None";
|
||||
case DataSource::SourceType::CompassOnline : return "CompassOnline";
|
||||
case DataSource::SourceType::CompassOffline : return "CompassOffline";
|
||||
case DataSource::SourceType::DaqromancyOffline: return "DaqromancyOffline";
|
||||
case DataSource::SourceType::DaqromancyOnline: return "DaqromancyOnline";
|
||||
}
|
||||
|
||||
return "None";
|
||||
|
|
|
@ -21,7 +21,9 @@ namespace Specter {
|
|||
{
|
||||
None,
|
||||
CompassOnline,
|
||||
CompassOffline
|
||||
CompassOffline,
|
||||
DaqromancyOnline,
|
||||
DaqromancyOffline
|
||||
};
|
||||
|
||||
DataSource() :
|
||||
|
|
|
@ -17,11 +17,11 @@ namespace Specter {
|
|||
|
||||
struct SpecData
|
||||
{
|
||||
uint32_t longEnergy;
|
||||
uint32_t shortEnergy;
|
||||
uint64_t calEnergy;
|
||||
uint64_t timestamp;
|
||||
uint32_t id;
|
||||
uint32_t longEnergy = 0;
|
||||
uint32_t shortEnergy = 0;
|
||||
uint64_t calEnergy = 0;
|
||||
uint64_t timestamp = 0;
|
||||
uint32_t id = 0;
|
||||
};
|
||||
|
||||
using SpecEvent = std::vector<SpecData>;
|
||||
|
|
1
Specter/vendor/DaqGrimoire
vendored
Submodule
1
Specter/vendor/DaqGrimoire
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit dedd1e0e953423a50ec8a35f4cb3161218aac642
|
Loading…
Reference in New Issue
Block a user