From 1de7bc9b7dd65b9c96d0f37d907f678c6d0b0261 Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Sat, 1 Oct 2022 15:26:41 -0400 Subject: [PATCH] Remove now unused channels per board references from everywhere. --- Specter/src/Specter/Editor/SourceDialog.cpp | 9 ++------- Specter/src/Specter/Editor/SourceDialog.h | 1 - Specter/src/Specter/Events/PhysicsEvent.h | 7 ++----- .../Specter/Physics/Caen/CompassOnlineSource.cpp | 15 ++++++--------- .../Specter/Physics/Caen/CompassOnlineSource.h | 15 +++++---------- Specter/src/Specter/Physics/Caen/CompassRun.cpp | 12 ++++++++---- Specter/src/Specter/Physics/Caen/CompassRun.h | 15 +++++++-------- .../Specter/Physics/Daqromancy/DYFileSource.cpp | 4 ++-- .../src/Specter/Physics/Daqromancy/DYFileSource.h | 3 +-- .../Specter/Physics/Daqromancy/DYOnlineSource.cpp | 4 ++-- .../Specter/Physics/Daqromancy/DYOnlineSource.h | 2 +- Specter/src/Specter/Physics/DataSource.cpp | 10 +++++----- Specter/src/Specter/Physics/DataSource.h | 2 +- Specter/src/Specter/Physics/PhysicsLayer.cpp | 2 +- 14 files changed, 43 insertions(+), 58 deletions(-) diff --git a/Specter/src/Specter/Editor/SourceDialog.cpp b/Specter/src/Specter/Editor/SourceDialog.cpp index 1d81a93..4f4c65a 100644 --- a/Specter/src/Specter/Editor/SourceDialog.cpp +++ b/Specter/src/Specter/Editor/SourceDialog.cpp @@ -44,7 +44,6 @@ namespace Specter { m_chosenPort = "51489"; m_chosenWindow = 3000000; m_bitflags = 0; - m_channels_per_board = 16; ImGui::OpenPopup(ICON_FA_LINK " Attach Source"); } if (ImGui::BeginPopupModal(ICON_FA_LINK " Attach Source")) @@ -79,7 +78,6 @@ namespace Specter { { m_bitflags = m_bitflags ^ CompassHeaders::EnergyCalibrated; } - ImGui::InputInt("Channels Per Digitizer Board", &m_channels_per_board); } else if (m_chosenType == DataSource::SourceType::CompassOffline) { @@ -92,13 +90,11 @@ namespace Specter { 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) { @@ -111,7 +107,6 @@ namespace Specter { 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); } ImGui::InputInt("Coinc. Window (ps)", &m_chosenWindow); @@ -120,12 +115,12 @@ namespace Specter { { 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); + PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, false, 0U); Application::Get().OnEvent(event); } 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); + PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, true, m_bitflags); Application::Get().OnEvent(event); } ImGui::CloseCurrentPopup(); diff --git a/Specter/src/Specter/Editor/SourceDialog.h b/Specter/src/Specter/Editor/SourceDialog.h index 37d7192..b160543 100644 --- a/Specter/src/Specter/Editor/SourceDialog.h +++ b/Specter/src/Specter/Editor/SourceDialog.h @@ -30,7 +30,6 @@ namespace Specter { FileDialog m_fileDialog; uint16_t m_bitflags; int m_chosenWindow; - int m_channels_per_board; }; } diff --git a/Specter/src/Specter/Events/PhysicsEvent.h b/Specter/src/Specter/Events/PhysicsEvent.h index 82310fb..0d89a54 100644 --- a/Specter/src/Specter/Events/PhysicsEvent.h +++ b/Specter/src/Specter/Events/PhysicsEvent.h @@ -21,9 +21,8 @@ namespace Specter { { public: //Bitflags is a final option for random crap needed for a source. Currently used for compass online to indicate header state. - PhysicsStartEvent(const std::string& loc, DataSource::SourceType type, uint64_t window, const std::string& port = "51489", bool sortFlag=false, uint16_t bitflags = 0, - int channels_per_board=16) : - m_sourceLocation(loc), m_port(port), m_sourceType(type), m_coincidenceWindow(window), m_sortFlag(sortFlag), m_bitflags(bitflags), m_channels_per_board(channels_per_board) + PhysicsStartEvent(const std::string& loc, DataSource::SourceType type, uint64_t window, const std::string& port = "51489", bool sortFlag=false, uint16_t bitflags = 0) : + m_sourceLocation(loc), m_port(port), m_sourceType(type), m_coincidenceWindow(window), m_sortFlag(sortFlag), m_bitflags(bitflags) {} inline const std::string GetSourceLocation() const { return m_sourceLocation; } @@ -31,7 +30,6 @@ namespace Specter { inline const DataSource::SourceType GetSourceType() const { return m_sourceType; } inline const uint64_t GetCoincidenceWindow() const { return m_coincidenceWindow; } inline const bool GetSortFlag() const { return m_sortFlag; } - inline const int GetChannelsPerBoard() const { return m_channels_per_board; } inline const uint16_t GetBitFlags() const { return m_bitflags; } std::string ToString() const override @@ -49,7 +47,6 @@ namespace Specter { uint64_t m_coincidenceWindow; bool m_sortFlag; uint16_t m_bitflags; - int m_channels_per_board; }; class PhysicsStopEvent : public Event diff --git a/Specter/src/Specter/Physics/Caen/CompassOnlineSource.cpp b/Specter/src/Specter/Physics/Caen/CompassOnlineSource.cpp index 819b856..2db689b 100644 --- a/Specter/src/Specter/Physics/Caen/CompassOnlineSource.cpp +++ b/Specter/src/Specter/Physics/Caen/CompassOnlineSource.cpp @@ -5,13 +5,6 @@ need to know if the buffer is/was filled, however we use non-blocking since we don't want the entire process to hang on attempting a connection or waiting for data to come over the pipe. We handle the case of an un-filled buffer internally. - IMPORTANT - Specter wants a unqiue ID on each hit. To do this we use the idiom: - id = board_number * nchannels_per_board + channel_number - This requires two things: that the class variable m_nchannels_per_board be set to match your physical digitizers, and that ALL of your - digitizers have the SAME number of channels. By default CompassRun assumes 16 channels per board, as this is what is used with the SE-SPS setup at FoxLab. - If you use a different set of boards, CHANGE THIS VALUE! If you use mixed boards, you will need to invent a new id scheme altogether. - ADDITIONALLY CoMPASS servers provide no stream side information on the state of a transfer (verified via communication w/ CAEN). That is: there are no headers or enders on the data transfers. This forces us to use the size of a single CoMPASS datum (CompassHit) to determine the state of a transfer. If the read buffer size is not a whole multiple of CompassHits, the data @@ -20,13 +13,17 @@ Maybe we can get them to change this? Headers reeaaally should exist for transfers like this. GWM -- April 2022 + + Make it so that number of channels per board is no longer fixed. Use pairing function defined in Utils/Functions.h to generate a UUID for each board channel/pair. + + GWM -- Oct 2022 */ #include "CompassOnlineSource.h" namespace Specter { - CompassOnlineSource::CompassOnlineSource(const std::string& hostname, const std::string& port, uint16_t header, int channels_per_board) : - DataSource(), m_bufferIter(nullptr), m_bufferEnd(nullptr), m_header(header), m_nchannels_per_board(channels_per_board) + CompassOnlineSource::CompassOnlineSource(const std::string& hostname, const std::string& port, uint16_t header) : + DataSource(), m_bufferIter(nullptr), m_bufferEnd(nullptr), m_header(header) { InitConnection(hostname, port); } diff --git a/Specter/src/Specter/Physics/Caen/CompassOnlineSource.h b/Specter/src/Specter/Physics/Caen/CompassOnlineSource.h index b2ae09b..97c7bfa 100644 --- a/Specter/src/Specter/Physics/Caen/CompassOnlineSource.h +++ b/Specter/src/Specter/Physics/Caen/CompassOnlineSource.h @@ -5,13 +5,6 @@ need to know if the buffer is/was filled, however we use non-blocking since we don't want the entire process to hang on attempting a connection or waiting for data to come over the pipe. We handle the case of an un-filled buffer internally. - IMPORTANT - Specter wants a unqiue ID on each hit. To do this we use the idiom: - id = board_number * nchannels_per_board + channel_number - This requires two things: that the class variable m_nchannels_per_board be set to match your physical digitizers, and that ALL of your - digitizers have the SAME number of channels. By default CompassRun assumes 16 channels per board, as this is what is used with the SE-SPS setup at FoxLab. - If you use a different set of boards, CHANGE THIS VALUE! If you use mixed boards, you will need to invent a new id scheme altogether. - ADDITIONALLY CoMPASS servers provide no stream side information on the state of a transfer (verified via communication w/ CAEN). That is: there are no headers or enders on the data transfers. This forces us to use the size of a single CoMPASS datum (CompassHit) to determine the state of a transfer. If the read buffer size is not a whole multiple of CompassHits, the data @@ -26,6 +19,10 @@ of Specter's runtime). Best to use the CoMPASSPlot for waves. GWM -- May 2022 + + Make it so that number of channels per board is no longer fixed. Use pairing function defined in Utils/Functions.h to generate a UUID for each board channel/pair. + + GWM -- Oct 2022 */ #ifndef COMPASS_ONLINE_SOURCE_H #define COMPASS_ONLINE_SOURCE_H @@ -39,7 +36,7 @@ namespace Specter { class CompassOnlineSource : public DataSource { public: - CompassOnlineSource(const std::string& hostname, const std::string& port, uint16_t header, int channels_per_board=16); + CompassOnlineSource(const std::string& hostname, const std::string& port, uint16_t header); virtual ~CompassOnlineSource() override; virtual const SpecData& GetData() override; @@ -53,8 +50,6 @@ namespace Specter { std::vector m_currentBuffer; uint16_t m_header; int m_datasize; //size of CoMPASS hit in bytes, set by header arg - const int m_nchannels_per_board = 16; //IMPORTANT: Used for ID'ing channels uniquely. If you use boards with 32 or 8 or 64 channels you must change this! If you mix boards with - //different numbers of channels, you will have to find a different id solution. char* m_bufferIter; char* m_bufferEnd; CompassHit m_currentHit; diff --git a/Specter/src/Specter/Physics/Caen/CompassRun.cpp b/Specter/src/Specter/Physics/Caen/CompassRun.cpp index 1992179..cc7204d 100644 --- a/Specter/src/Specter/Physics/Caen/CompassRun.cpp +++ b/Specter/src/Specter/Physics/Caen/CompassRun.cpp @@ -10,25 +10,29 @@ Updated to also handle scaler data. -- GWM Oct. 2020 Modifed and updated for use in Specter. Obviously stripped out any ROOT code. Also, now uses the very nice std::filesystem - library to handle filepathing. Also, removed scalers (for now). + library to handle filepathing. GWM -- Feb 2022 Update to reflect new CAEN binary data format with headers to indicate data contents. GWM -- May 2022 + + Make it so that number of channels per board is no longer fixed. Use pairing function defined in Utils/Functions.h to generate a UUID for each board channel/pair. + + GWM -- Oct 2022 */ #include "CompassRun.h" namespace Specter { CompassRun::CompassRun() : - DataSource(), m_directory(""), m_startIndex(0), m_nchannels_per_board(16) + DataSource(), m_directory(""), m_startIndex(0) { } - CompassRun::CompassRun(const std::string& dir, int channels_per_board) : - DataSource(), m_directory(dir), m_startIndex(0), m_nchannels_per_board(channels_per_board) + CompassRun::CompassRun(const std::string& dir) : + DataSource(), m_directory(dir), m_startIndex(0) { CollectFiles(); } diff --git a/Specter/src/Specter/Physics/Caen/CompassRun.h b/Specter/src/Specter/Physics/Caen/CompassRun.h index 9568c6f..74475bd 100644 --- a/Specter/src/Specter/Physics/Caen/CompassRun.h +++ b/Specter/src/Specter/Physics/Caen/CompassRun.h @@ -8,17 +8,17 @@ Written by G.W. McCann Oct. 2020 Modifed and updated for use in Specter. Obviously stripped out any ROOT code. Also, now uses the very nice std::filesystem - library to handle filepathing. One change of great import: Specter wants a unqiue ID on each hit. To do this we use the idiom: - id = board_number * nchannels_per_board + channel_number - This requires two things: that the class variable m_nchannels_per_board be set to match your physical digitizers, and that ALL of your - digitizers have the SAME number of channels. By default CompassRun assumes 16 channels per board, as this is what is used with the SE-SPS setup at FoxLab. - If you use a different set of boards, CHANGE THIS VALUE! If you use mixed boards, you will need to invent a new id scheme altogether. + library to handle filepathing. GWM -- Feb 2022 Update to reflect new CAEN binary data format with headers to indicate data contents. GWM -- May 2022 + + Make it so that number of channels per board is no longer fixed. Use pairing function defined in Utils/Functions.h to generate a UUID for each board channel/pair. + + GWM -- Oct 2022 */ #ifndef COMPASSRUN_H #define COMPASSRUN_H @@ -36,7 +36,7 @@ namespace Specter { public: CompassRun(); - CompassRun(const std::string& dir, int channels_per_board=16); + CompassRun(const std::string& dir); virtual ~CompassRun(); virtual const SpecData& GetData() override; inline void SetDirectory(const std::string& dir) { m_directory = dir; CollectFiles(); } @@ -52,8 +52,7 @@ namespace Specter { std::vector m_datafiles; unsigned int m_startIndex; //this is the file we start looking at; increases as we finish files. - int m_nchannels_per_board; //IMPORTANT: Used for ID'ing channels uniquely. If you use boards with 32 or 8 or 64 channels you must change this! If you mix boards with - //different numbers of channels, you will have to find a different id solution. + ShiftMap m_smap; CompassHit m_hit; diff --git a/Specter/src/Specter/Physics/Daqromancy/DYFileSource.cpp b/Specter/src/Specter/Physics/Daqromancy/DYFileSource.cpp index 6084bfb..0c61696 100644 --- a/Specter/src/Specter/Physics/Daqromancy/DYFileSource.cpp +++ b/Specter/src/Specter/Physics/Daqromancy/DYFileSource.cpp @@ -2,8 +2,8 @@ namespace Specter { - DYFileSource::DYFileSource(const std::string& directory, int channels_per_board) : - DataSource(), m_directory(directory), m_channelsPerBoard(channels_per_board) + DYFileSource::DYFileSource(const std::string& directory) : + DataSource(), m_directory(directory) { CollectFiles(); } diff --git a/Specter/src/Specter/Physics/Daqromancy/DYFileSource.h b/Specter/src/Specter/Physics/Daqromancy/DYFileSource.h index c7987ca..c2c729b 100644 --- a/Specter/src/Specter/Physics/Daqromancy/DYFileSource.h +++ b/Specter/src/Specter/Physics/Daqromancy/DYFileSource.h @@ -10,7 +10,7 @@ namespace Specter { class DYFileSource : public DataSource { public: - DYFileSource(const std::string& directory, int channels_per_board = 16); + DYFileSource(const std::string& directory); virtual ~DYFileSource(); virtual const SpecData& GetData() override; @@ -21,7 +21,6 @@ namespace Specter { std::filesystem::path m_directory; static constexpr std::string_view s_extension = ".dybin"; - int m_channelsPerBoard; std::vector m_files; DaqGrimoire::DYListData m_dyHit; diff --git a/Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.cpp b/Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.cpp index 19f7ca2..837f28f 100644 --- a/Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.cpp +++ b/Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.cpp @@ -2,8 +2,8 @@ namespace Specter { - DYOnlineSource::DYOnlineSource(const std::string& hostname, const std::string& port, int channelsPerBoard) : - DataSource(), m_clientConnection(hostname, port), m_channelsPerBoard(channelsPerBoard) + DYOnlineSource::DYOnlineSource(const std::string& hostname, const std::string& port) : + DataSource(), m_clientConnection(hostname, port) { m_validFlag = m_clientConnection.IsConnected(); } diff --git a/Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.h b/Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.h index 104db03..446c0c1 100644 --- a/Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.h +++ b/Specter/src/Specter/Physics/Daqromancy/DYOnlineSource.h @@ -9,7 +9,7 @@ namespace Specter { class DYOnlineSource : public DataSource { public: - DYOnlineSource(const std::string& hostname, const std::string& port, int channelsPerBoard = 16); + DYOnlineSource(const std::string& hostname, const std::string& port); ~DYOnlineSource(); virtual const SpecData& GetData() override; diff --git a/Specter/src/Specter/Physics/DataSource.cpp b/Specter/src/Specter/Physics/DataSource.cpp index 3336b4e..9c21598 100644 --- a/Specter/src/Specter/Physics/DataSource.cpp +++ b/Specter/src/Specter/Physics/DataSource.cpp @@ -15,14 +15,14 @@ namespace Specter { //loc=either an ip address or a file location, port=address port, or unused in case of file - DataSource* CreateDataSource(const std::string& location, const std::string& port, uint16_t header, int channels_per_board, DataSource::SourceType type) + DataSource* CreateDataSource(const std::string& location, const std::string& port, uint16_t header, DataSource::SourceType type) { switch(type) { - 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::CompassOffline : return new CompassRun(location); + case DataSource::SourceType::CompassOnline : return new CompassOnlineSource(location, port, header); + case DataSource::SourceType::DaqromancyOffline: return new DYFileSource(location); + case DataSource::SourceType::DaqromancyOnline: return new DYOnlineSource(location, port); case DataSource::SourceType::None : return nullptr; } SPEC_WARN("Invalid DataSourceType at CreateDataSource!"); diff --git a/Specter/src/Specter/Physics/DataSource.h b/Specter/src/Specter/Physics/DataSource.h index 23e134d..b408e9e 100644 --- a/Specter/src/Specter/Physics/DataSource.h +++ b/Specter/src/Specter/Physics/DataSource.h @@ -40,7 +40,7 @@ namespace Specter { SpecData m_datum; }; - DataSource* CreateDataSource(const std::string& location, const std::string& port, uint16_t bitflags, int channels_per_board, DataSource::SourceType type); + DataSource* CreateDataSource(const std::string& location, const std::string& port, uint16_t bitflags, DataSource::SourceType type); std::string ConvertDataSourceTypeToString(DataSource::SourceType type); } diff --git a/Specter/src/Specter/Physics/PhysicsLayer.cpp b/Specter/src/Specter/Physics/PhysicsLayer.cpp index 4cda838..0d85d5b 100644 --- a/Specter/src/Specter/Physics/PhysicsLayer.cpp +++ b/Specter/src/Specter/Physics/PhysicsLayer.cpp @@ -114,7 +114,7 @@ namespace Specter { { SPEC_PROFILE_FUNCTION(); std::scoped_lock guard(m_sourceMutex); //Shouldn't matter for this, but safety first - m_source.reset(CreateDataSource(event.GetSourceLocation(), event.GetSourcePort(), event.GetBitFlags(), event.GetChannelsPerBoard(), event.GetSourceType())); + m_source.reset(CreateDataSource(event.GetSourceLocation(), event.GetSourcePort(), event.GetBitFlags(), event.GetSourceType())); m_eventBuilder.SetCoincidenceWindow(event.GetCoincidenceWindow()); m_eventBuilder.SetSortFlag(event.GetSortFlag()); m_eventBuilder.ClearAll(); //Protect against stopping mid-event