1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-11-22 18:28:52 -05:00

Some fixes from recent live testing (expanding default window, better examples of sorting at analysis). Updating CompassOnlineSource and CompassFile and CompassRun in advent of CAEN changes to CoMPASS binary data format. Data size and type now controlled by header (or lack there of).

This commit is contained in:
Gordon McCann 2022-05-22 20:47:32 -04:00
parent 40eb727b7d
commit e64a3ce7e6
17 changed files with 291 additions and 131 deletions

View File

@ -61,34 +61,59 @@ namespace Navigator {
if (hit.id < 127)
{
sabreFlag = true;
sabre[hit.id].SetValue(hit.longEnergy);
if (hit.longEnergy > sabre[hit.id].GetValue())
sabre[hit.id].SetValue(hit.longEnergy);
}
switch (hit.id)
{
case 129:
scintLeft.SetValue(hit.longEnergy);
{
if (hit.longEnergy > scintLeft.GetValue())
scintLeft.SetValue(hit.longEnergy);
break;
}
case 135:
cathode.SetValue(hit.longEnergy);
{
if (hit.longEnergy > cathode.GetValue())
cathode.SetValue(hit.longEnergy);
break;
}
case 136:
delayFLTime.SetValue(hit.timestamp / 1.0e3);
{
if (!delayFLTime.IsValid())
delayFLTime.SetValue(hit.timestamp / 1.0e3);
break;
}
case 137:
delayFRTime.SetValue(hit.timestamp / 1.0e3);
{
if (!delayFRTime.IsValid())
delayFRTime.SetValue(hit.timestamp / 1.0e3);
break;
}
case 138:
delayBLTime.SetValue(hit.timestamp / 1.0e3);
{
if (!delayBLTime.IsValid())
delayBLTime.SetValue(hit.timestamp / 1.0e3);
break;
}
case 139:
delayBRTime.SetValue(hit.timestamp / 1.0e3);
{
if (!delayBRTime.IsValid())
delayBRTime.SetValue(hit.timestamp / 1.0e3);
break;
}
case 141:
anodeFront.SetValue(hit.longEnergy);
{
if (hit.longEnergy > anodeFront.GetValue())
anodeFront.SetValue(hit.longEnergy);
break;
}
case 143:
anodeBack.SetValue(hit.longEnergy);
{
if (hit.longEnergy > anodeBack.GetValue())
anodeBack.SetValue(hit.longEnergy);
break;
}
}
}

View File

@ -9,6 +9,7 @@
#include "Navigator/Events/PhysicsEvent.h"
#include "Navigator/Events/Event.h"
#include "Navigator/Core/Application.h"
#include "Navigator/Physics/Caen/CompassHit.h"
#include "imgui.h"
#include "misc/cpp/imgui_stdlib.h"
@ -40,7 +41,8 @@ namespace Navigator {
m_chosenType = DataSource::SourceType::None;
m_chosenLocation = "";
m_chosenPort = "51489";
m_chosenWindow = 2000000;
m_chosenWindow = 3000000;
m_bitflags = 0;
ImGui::OpenPopup(ICON_FA_LINK " Attach Source");
}
if (ImGui::BeginPopupModal(ICON_FA_LINK " Attach Source"))
@ -61,6 +63,20 @@ namespace Navigator {
{
ImGui::InputText("Hostname", &m_chosenLocation);
ImGui::InputText("Port", &m_chosenPort);
if (ImGui::RadioButton("Energy", (m_bitflags & CompassHeaders::Energy) != 0))
{
m_bitflags = m_bitflags ^ CompassHeaders::Energy;
}
ImGui::SameLine();
if (ImGui::RadioButton("Energy Short", (m_bitflags & CompassHeaders::EnergyShort) != 0))
{
m_bitflags = m_bitflags ^ CompassHeaders::EnergyShort;
}
ImGui::SameLine();
if (ImGui::RadioButton("Energy Calibrated", (m_bitflags & CompassHeaders::EnergyCalibrated) != 0))
{
m_bitflags = m_bitflags ^ CompassHeaders::EnergyCalibrated;
}
}
else if (m_chosenType == DataSource::SourceType::CompassOffline)
{
@ -85,7 +101,7 @@ namespace Navigator {
}
else if (m_chosenType == DataSource::SourceType::CompassOnline)
{
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, true);
PhysicsStartEvent event(m_chosenLocation, m_chosenType, m_chosenWindow, m_chosenPort, true, m_bitflags);
Application::Get().OnEvent(event);
}
ImGui::CloseCurrentPopup();

View File

@ -28,6 +28,7 @@ namespace Navigator {
std::string m_chosenLocation;
std::string m_chosenPort;
FileDialog m_fileDialog;
uint16_t m_bitflags;
int m_chosenWindow;
};

View File

@ -3,6 +3,10 @@
Events related to physics processes. Again, based on @TheCherno's work.
GWM -- Feb 2022
Update to reflect new CAEN binary data format with headers to indicate data contents.
GWM -- May 2022
*/
#ifndef PHYSICS_EVENT_H
#define PHYSICS_EVENT_H
@ -16,8 +20,9 @@ namespace Navigator {
class NAV_API PhysicsStartEvent : public Event
{
public:
PhysicsStartEvent(const std::string& loc, DataSource::SourceType type, uint64_t window, const std::string& port = "51489", bool sortFlag=false) :
m_sourceLocation(loc), m_port(port), m_sourceType(type), m_coincidenceWindow(window), m_sortFlag(sortFlag)
//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) :
m_sourceLocation(loc), m_port(port), m_sourceType(type), m_coincidenceWindow(window), m_sortFlag(sortFlag), m_bitflags(bitflags)
{}
inline std::string GetSourceLocation() { return m_sourceLocation; }
@ -40,6 +45,7 @@ namespace Navigator {
DataSource::SourceType m_sourceType;
uint64_t m_coincidenceWindow;
bool m_sortFlag;
uint16_t m_bitflags;
};
class NAV_API PhysicsStopEvent : public Event

View File

@ -11,32 +11,30 @@
Modified for Navigator; not really any significant changes. Just some simple changes, removal of unused data.
GWM -- Feb 2022
Update to reflect new CAEN binary data format with headers to indicate data contents.
GWM -- May 2022
*/
#include "CompassFile.h"
namespace Navigator {
CompassFile::CompassFile() :
m_filename(""), bufferIter(nullptr), bufferEnd(nullptr), m_smap(nullptr), hitUsedFlag(true), m_file(std::make_shared<std::ifstream>()), eofFlag(false)
m_filename(""), m_bufferIter(nullptr), m_bufferEnd(nullptr), m_smap(nullptr), m_hitUsedFlag(true), m_file(std::make_shared<std::ifstream>()), m_eofFlag(false)
{
m_buffersize = bufsize*hitsize;
hitBuffer.resize(m_buffersize);
}
CompassFile::CompassFile(const std::string& filename) :
m_filename(""), bufferIter(nullptr), bufferEnd(nullptr), m_smap(nullptr), hitUsedFlag(true), m_file(std::make_shared<std::ifstream>()), eofFlag(false)
m_filename(""), m_bufferIter(nullptr), m_bufferEnd(nullptr), m_smap(nullptr), m_hitUsedFlag(true), m_file(std::make_shared<std::ifstream>()), m_eofFlag(false)
{
m_buffersize = bufsize*hitsize;
hitBuffer.resize(m_buffersize);
Open(filename);
}
CompassFile::CompassFile(const std::string& filename, int bsize) :
m_filename(""), bufferIter(nullptr), bufferEnd(nullptr), m_smap(nullptr), hitUsedFlag(true),
bufsize(bsize), m_file(std::make_shared<std::ifstream>()), eofFlag(false)
m_filename(""), m_bufferIter(nullptr), m_bufferEnd(nullptr), m_smap(nullptr), m_hitUsedFlag(true),
m_bufsize(bsize), m_file(std::make_shared<std::ifstream>()), m_eofFlag(false)
{
m_buffersize = bufsize*hitsize;
hitBuffer.resize(m_buffersize);
Open(filename);
}
@ -48,53 +46,66 @@ namespace Navigator {
void CompassFile::Open(const std::string& filename)
{
NAV_PROFILE_FUNCTION();
eofFlag = false;
hitUsedFlag = true;
m_eofFlag = false;
m_hitUsedFlag = true;
m_filename = filename;
m_file->open(m_filename, std::ios::binary | std::ios::in);
m_file->seekg(0, std::ios_base::end);
m_size = (unsigned int)m_file->tellg();
m_nHits = m_size/24;
if(m_size == 0)
{
eofFlag = true;
m_eofFlag = true;
}
else
{
m_file->seekg(0, std::ios_base::beg);
ReadHeader();
m_nHits = m_size / m_hitsize;
m_buffersize = m_hitsize * m_bufsize;
m_hitBuffer.resize(m_buffersize);
}
}
void CompassFile::Close()
{
if(IsOpen())
{
m_file->close();
}
}
int CompassFile::GetHitSize()
void CompassFile::ReadHeader()
{
if(!IsOpen())
{
NAV_WARN("Unable to get hit size from file {0}, sending invalid value.", m_filename);
return 0;
return;
}
char* firstHit = new char[24]; //A compass hit by default has 24 bytes (at least in our setup)
m_file->read(firstHit, 24);
firstHit += 16;
int nsamples = *((uint32_t*) firstHit);
m_file->seekg(0, std::ios_base::beg);
delete[] firstHit;
return 24 + nsamples*16;
char* header = new char[2];
m_file->read(header, 2);
m_header = *((uint16_t*)header);
m_hitsize = 16; //default hitsize 16 bytes
if (Compass_IsEnergy(m_header))
m_hitsize += 2;
if (Compass_IsEnergyShort(m_header))
m_hitsize += 2;
if (Compass_IsEnergyCalibrated(m_header))
m_hitsize += 8;
if (Compass_IsWaves)
{
m_hitsize += 5;
char* firstHit = new char[m_hitsize]; //Read chunk of first hit
m_file->read(firstHit, m_hitsize);
firstHit += m_hitsize - 4; //Move to the Nsamples value
uint32_t nsamples = *((uint32_t*)firstHit);
m_hitsize += nsamples * 2; //Each sample is two bytes
m_file->seekg(0, std::ios_base::beg);
m_file->read(header, 2);
delete[] firstHit;
}
delete[] header;
}
/*
@ -110,7 +121,7 @@ namespace Navigator {
NAV_PROFILE_FUNCTION();
if(!IsOpen()) return true;
if((bufferIter == nullptr || bufferIter == bufferEnd) && !IsEOF())
if((m_bufferIter == nullptr || m_bufferIter == m_bufferEnd) && !IsEOF())
{
GetNextBuffer();
}
@ -118,10 +129,10 @@ namespace Navigator {
if(!IsEOF())
{
ParseNextHit();
hitUsedFlag = false;
m_hitUsedFlag = false;
}
return eofFlag;
return m_eofFlag;
}
/*
@ -136,35 +147,58 @@ namespace Navigator {
NAV_PROFILE_FUNCTION();
if(m_file->eof())
{
eofFlag = true;
m_eofFlag = true;
return;
}
m_file->read(hitBuffer.data(), hitBuffer.size());
m_file->read(m_hitBuffer.data(), m_hitBuffer.size());
bufferIter = hitBuffer.data();
bufferEnd = bufferIter + m_file->gcount(); //one past the last datum
m_bufferIter = m_hitBuffer.data();
m_bufferEnd = m_bufferIter + m_file->gcount(); //one past the last datum
}
void CompassFile::ParseNextHit()
{
NAV_PROFILE_FUNCTION();
m_currentHit.board = *((uint16_t*)bufferIter);
bufferIter += 2;
m_currentHit.channel = *((uint16_t*)bufferIter);
bufferIter += 2;
m_currentHit.timestamp = *((uint64_t*)bufferIter);
bufferIter += 8;
m_currentHit.lgate = *((uint16_t*)bufferIter);
bufferIter += 2;
m_currentHit.sgate = *((uint16_t*)bufferIter);
bufferIter += 2;
m_currentHit.flags = *((uint32_t*)bufferIter);
bufferIter += 4;
m_currentHit.Ns = *((uint32_t*)bufferIter);
bufferIter += 4;
m_currentHit.board = *((uint16_t*)m_bufferIter);
m_bufferIter += 2;
m_currentHit.channel = *((uint16_t*)m_bufferIter);
m_bufferIter += 2;
m_currentHit.timestamp = *((uint64_t*)m_bufferIter);
m_bufferIter += 8;
if (Compass_IsEnergy(m_header))
{
m_currentHit.energy = *((uint16_t*)m_bufferIter);
m_bufferIter += 2;
}
if (Compass_IsEnergyCalibrated(m_header))
{
m_currentHit.energyCalibrated = *((uint64_t*)m_bufferIter);
m_bufferIter += 8;
}
if (Compass_IsEnergyShort(m_header))
{
m_currentHit.energyShort = *((uint16_t*)m_bufferIter);
m_bufferIter += 2;
}
m_currentHit.flags = *((uint32_t*)m_bufferIter);
m_bufferIter += 4;
if (Compass_IsWaves(m_header))
{
m_currentHit.waveCode = *((uint8_t*)m_bufferIter);
m_bufferIter += 1;
m_currentHit.Ns = *((uint32_t*)m_bufferIter);
m_bufferIter += 4;
if (m_currentHit.samples.size() != m_currentHit.Ns)
m_currentHit.samples.resize(m_currentHit.Ns);
for (size_t i = 0; i < m_currentHit.samples.size(); i++)
{
m_currentHit.samples[i] = *((uint16_t*)m_bufferIter);
m_bufferIter += 2;
}
}
if(m_smap != nullptr)
{ //memory safety
int gchan = m_currentHit.channel + m_currentHit.board*16;

View File

@ -11,6 +11,10 @@
Modified for Navigator; not really any significant changes. Just some simple changes, removal of unused data.
GWM -- Feb 2022
Update to reflect new CAEN binary data format with headers to indicate data contents.
GWM -- May 2022
*/
#ifndef COMPASSFILE_H
#define COMPASSFILE_H
@ -36,17 +40,17 @@ namespace Navigator {
inline bool IsOpen() const { return m_file->is_open(); };
inline CompassHit GetCurrentHit() const { return m_currentHit; }
inline std::string GetName() const { return m_filename; }
inline bool CheckHitHasBeenUsed() const { return hitUsedFlag; } //query to find out if we've used the current hit
inline void SetHitHasBeenUsed() { hitUsedFlag = true; } //flip the flag to indicate the current hit has been used
inline bool IsEOF() const { return eofFlag; } //see if we've read all available data
inline bool* GetUsedFlagPtr() { return &hitUsedFlag; }
inline bool CheckHitHasBeenUsed() const { return m_hitUsedFlag; } //query to find out if we've used the current hit
inline void SetHitHasBeenUsed() { m_hitUsedFlag = true; } //flip the flag to indicate the current hit has been used
inline bool IsEOF() const { return m_eofFlag; } //see if we've read all available data
inline bool* GetUsedFlagPtr() { return &m_hitUsedFlag; }
inline void AttachShiftMap(ShiftMap* map) { m_smap = map; }
inline unsigned int GetSize() const { return m_size; }
inline unsigned int GetNumberOfHits() const { return m_nHits; }
private:
int GetHitSize();
void ReadHeader();
void ParseNextHit();
void GetNextBuffer();
@ -55,21 +59,22 @@ namespace Navigator {
using FilePointer = std::shared_ptr<std::ifstream>; //to make this class copy/movable
std::string m_filename;
Buffer hitBuffer;
char* bufferIter;
char* bufferEnd;
Buffer m_hitBuffer;
char* m_bufferIter;
char* m_bufferEnd;
ShiftMap* m_smap; //NOT owned by CompassFile. DO NOT delete
bool hitUsedFlag;
int bufsize = 200000; //size of the buffer in hits
int hitsize = 24; //size of a CompassHit in bytes (without alignment padding)
bool m_hitUsedFlag;
int m_bufsize = 200000; //size of the buffer in hits
int m_hitsize; //size of a CompassHit in bytes (without alignment padding)
uint16_t m_header;
int m_buffersize;
CompassHit m_currentHit;
FilePointer m_file;
bool eofFlag;
bool m_eofFlag;
unsigned int m_size; //size of the file in bytes
unsigned int m_nHits; //number of hits in the file (m_size/24)
unsigned int m_nHits; //number of hits in the file (m_size/m_hitsize)
};

View File

@ -0,0 +1,24 @@
#include "CompassHit.h"
namespace Navigator {
bool Compass_IsEnergy(uint16_t header)
{
return (header & CompassHeaders::Energy) != 0;
}
bool Compass_IsEnergyShort(uint16_t header)
{
return (header & CompassHeaders::EnergyShort) != 0;
}
bool Compass_IsEnergyCalibrated(uint16_t header)
{
return (header & CompassHeaders::EnergyCalibrated) != 0;
}
bool Compass_IsWaves(uint16_t header)
{
return (header & CompassHeaders::EnergyCalibrated) != 0;
}
}

View File

@ -3,6 +3,10 @@
Simple struct representing data from the CAEN CoMPASS DAQ. Note here I do not have any of the non-standard data available (calibrated energy, waveform data, etc.)
GWM -- Feb 2022
Update to reflect new CAEN binary data format with headers to indicate data contents.
GWM -- May 2022
*/
#ifndef COMPASS_HIT_H
#define COMPASS_HIT_H
@ -16,12 +20,28 @@ namespace Navigator {
uint16_t board = 0;
uint16_t channel = 0;
uint64_t timestamp = 0;
uint16_t lgate = 0;
uint16_t sgate = 0;
uint16_t energy = 0;
uint16_t energyShort = 0;
uint64_t energyCalibrated = 0;
uint32_t flags = 0;
uint8_t waveCode = 0;
uint32_t Ns = 0;
std::vector<uint16_t> samples;
};
//New to CoMPASS Data Format: Headers indicating what data is present.
enum CompassHeaders
{
Energy = 0x0001,
EnergyShort = 0x0002,
EnergyCalibrated = 0x0004,
Waves = 0x0008
};
bool Compass_IsEnergy(uint16_t header);
bool Compass_IsEnergyShort(uint16_t header);
bool Compass_IsEnergyCalibrated(uint16_t header);
bool Compass_IsWaves(uint16_t header);
}
#endif

View File

@ -25,8 +25,8 @@
namespace Navigator {
CompassOnlineSource::CompassOnlineSource(const std::string& hostname, const std::string& port) :
DataSource(), m_bufferIter(nullptr), m_bufferEnd(nullptr)
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);
}
@ -36,6 +36,17 @@ namespace Navigator {
void CompassOnlineSource::InitConnection(const std::string& hostname, const std::string& port)
{
NAV_PROFILE_FUNCTION();
m_datasize = 16; //base size of CoMPASS data
if (Compass_IsEnergy(m_header))
m_datasize += 2;
if (Compass_IsEnergyShort(m_header))
m_datasize += 2;
if (Compass_IsEnergyCalibrated(m_header))
m_datasize += 8;
if (Compass_IsWaves(m_header))
NAV_ERROR("Navigator does not support reading CoMPASS wave data for an online source!");
m_validFlag = false;
m_connection.Connect(hostname, port);
if (m_connection.IsOpen())
@ -67,8 +78,9 @@ namespace Navigator {
return m_datum;
}
m_datum.longEnergy = m_currentHit.lgate;
m_datum.shortEnergy = m_currentHit.sgate;
m_datum.longEnergy = m_currentHit.energy;
m_datum.shortEnergy = m_currentHit.energyShort;
m_datum.calEnergy = m_currentHit.energyCalibrated;
m_datum.timestamp = m_currentHit.timestamp;
m_datum.id = m_currentHit.board * m_nchannels_per_board + m_currentHit.channel;
@ -101,6 +113,11 @@ namespace Navigator {
m_bufferEnd = m_currentBuffer.data() + m_currentBuffer.size();
}
void CompassOnlineSource::ReadHeader()
{
}
void CompassOnlineSource::GetHit()
{
NAV_PROFILE_FUNCTION();
@ -110,14 +127,23 @@ namespace Navigator {
m_bufferIter += 2;
m_currentHit.timestamp = *((uint64_t*)m_bufferIter);
m_bufferIter += 8;
m_currentHit.lgate = *((uint16_t*)m_bufferIter);
m_bufferIter += 2;
m_currentHit.sgate = *((uint16_t*)m_bufferIter);
m_bufferIter += 2;
if (Compass_IsEnergy(m_header))
{
m_currentHit.energy = *((uint16_t*)m_bufferIter);
m_bufferIter += 2;
}
if (Compass_IsEnergyCalibrated(m_header))
{
m_currentHit.energyCalibrated + *((uint16_t*)m_bufferIter);
m_bufferIter += 8;
}
if (Compass_IsEnergyShort(m_header))
{
m_currentHit.energyShort = *((uint16_t*)m_bufferIter);
m_bufferIter += 2;
}
m_currentHit.flags = *((uint32_t*)m_bufferIter);
m_bufferIter += 4;
m_currentHit.Ns = *((uint32_t*)m_bufferIter);
m_bufferIter += 4;
}
}

View File

@ -20,6 +20,12 @@
Maybe we can get them to change this? Headers reeaaally should exist for transfers like this.
GWM -- April 2022
Update to reflect new CAEN binary data format with headers to indicate data contents. Note that as prev. mentioned, no headers, so cannot rely on data stream to indicate state. State must be selected
by user at UI when creating source. Cannot support waves atm. No way to predict size of first event to calibrate the number of samples for the stream (or guarantee that they will be constant for duration
of Navigator's runtime). Best to use the CoMPASSPlot for waves.
GWM -- May 2022
*/
#ifndef COMPASS_ONLINE_SOURCE_H
#define COMPASS_ONLINE_SOURCE_H
@ -33,7 +39,7 @@ namespace Navigator {
class CompassOnlineSource : public DataSource
{
public:
CompassOnlineSource(const std::string& hostname, const std::string& port);
CompassOnlineSource(const std::string& hostname, const std::string& port, uint16_t header);
virtual ~CompassOnlineSource() override;
virtual const NavData& GetData() override;
@ -42,9 +48,11 @@ namespace Navigator {
void InitConnection(const std::string& hostname, const std::string& port);
void FillBuffer();
void GetHit();
void ReadHeader();
std::vector<char> m_currentBuffer;
static constexpr int m_datasize = 24; //size of CoMPASS hit in bytes, change as needed (if for example you have calibrated energies)
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;

View File

@ -13,6 +13,10 @@
library to handle filepathing. Also, removed scalers (for now).
GWM -- Feb 2022
Update to reflect new CAEN binary data format with headers to indicate data contents.
GWM -- May 2022
*/
#include "CompassRun.h"
@ -139,8 +143,9 @@ namespace Navigator {
else
{
//Convert data from CoMPASS format to universal Navigator format.
m_datum.longEnergy = m_hit.lgate;
m_datum.shortEnergy = m_hit.sgate;
m_datum.longEnergy = m_hit.energy;
m_datum.shortEnergy = m_hit.energyShort;
m_datum.calEnergy = m_hit.energyCalibrated;
m_datum.timestamp = m_hit.timestamp;
m_datum.id = m_hit.board * m_nchannels_per_board + m_hit.channel;
}

View File

@ -15,6 +15,10 @@
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.
GWM -- Feb 2022
Update to reflect new CAEN binary data format with headers to indicate data contents.
GWM -- May 2022
*/
#ifndef COMPASSRUN_H
#define COMPASSRUN_H

View File

@ -13,12 +13,12 @@
namespace Navigator {
//loc=either an ip address or a file location, port=address port, or unused in case of file
DataSource* CreateDataSource(const std::string& loc, const std::string& port, DataSource::SourceType type)
DataSource* CreateDataSource(const std::string& loc, const std::string& port, DataSource::SourceType type, uint16_t bitflags)
{
switch(type)
{
case DataSource::SourceType::CompassOffline : return new CompassRun(loc);
case DataSource::SourceType::CompassOnline : return new CompassOnlineSource(loc, port);
case DataSource::SourceType::CompassOnline : return new CompassOnlineSource(loc, port, bitflags);
case DataSource::SourceType::None : return nullptr;
}
NAV_WARN("Invalid DataSourceType at CreateDataSource!");

View File

@ -38,7 +38,7 @@ namespace Navigator {
NavData m_datum;
};
NAV_API DataSource* CreateDataSource(const std::string& loc, const std::string& port, DataSource::SourceType type);
NAV_API DataSource* CreateDataSource(const std::string& loc, const std::string& port, DataSource::SourceType type, uint16_t bitflags = 0);
NAV_API std::string ConvertDataSourceTypeToString(DataSource::SourceType type);
}

View File

@ -5,6 +5,10 @@
Most likely link to something like nscldaq.
GWM -- Feb 2022
Update to reflect new CAEN binary data format with headers to indicate data contents.
GWM -- May 2022
*/
#ifndef NAVDATA_H
#define NAVDATA_H
@ -15,6 +19,7 @@ namespace Navigator {
{
uint32_t longEnergy;
uint32_t shortEnergy;
uint64_t calEnergy;
uint64_t timestamp;
uint32_t id;
};

View File

@ -32,7 +32,7 @@ namespace Navigator {
private:
bool m_sortFlag;
static constexpr int s_maxDataBuffer = 100;
static constexpr int s_maxDataBuffer = 1000;
std::array<NavData, s_maxDataBuffer> m_dataBuffer;
int m_bufferIndex;
std::vector<NavEvent> m_readyEvents;

View File

@ -54,8 +54,8 @@ namespace Navigator {
m_hit.board = 8;
m_hit.channel = 1;
m_hit.timestamp = m_hit.timestamp + s_timestep;
m_hit.lgate = 512;
m_hit.sgate = 0;
m_hit.energy = 512;
m_hit.energyShort = 0;
m_hit.flags = 0;
m_hit.Ns = 0;
@ -80,13 +80,13 @@ namespace Navigator {
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.lgate;
data_pointer = (char*)&m_hit.energy;
for (int i = 0; i < 2; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.sgate;
data_pointer = (char*)&m_hit.energyShort;
for (int i = 0; i < 2; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
@ -122,8 +122,8 @@ namespace Navigator {
m_hit.board = 8;
m_hit.channel = 1;
m_hit.timestamp = m_hit.timestamp + s_timestep;
m_hit.lgate = 512;
m_hit.sgate = 0;
m_hit.energy = 512;
m_hit.energyShort = 0;
m_hit.flags = 0;
m_hit.Ns = 0;
@ -150,13 +150,13 @@ namespace Navigator {
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.lgate;
data_pointer = (char*)&m_hit.energy;
for (int i = 0; i < 2; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.sgate;
data_pointer = (char*)&m_hit.energyShort;
for (int i = 0; i < 2; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
@ -168,12 +168,6 @@ namespace Navigator {
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.Ns;
for (int i = 0; i < 4; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.board;
for (int i = 0; i < 2; i++)
{
@ -197,13 +191,13 @@ namespace Navigator {
}
else
{
data_pointer = (char*)&m_hit.lgate;
data_pointer = (char*)&m_hit.energy;
for (int i = 0; i < 2; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.sgate;
data_pointer = (char*)&m_hit.energyShort;
for (int i = 0; i < 2; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
@ -215,12 +209,6 @@ namespace Navigator {
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.Ns;
for (int i = 0; i < 4; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.board;
for (int i = 0; i < 2; i++)
{
@ -239,13 +227,13 @@ namespace Navigator {
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.lgate;
data_pointer = (char*)&m_hit.energy;
for (int i = 0; i < 2; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.sgate;
data_pointer = (char*)&m_hit.energyShort;
for (int i = 0; i < 2; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
@ -257,13 +245,6 @@ namespace Navigator {
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
data_pointer = (char*)&m_hit.Ns;
for (int i = 0; i < 4; i++)
{
m_buffer[buffer_position] = *(data_pointer + i);
buffer_position++;
}
even = true;
}
}