12 const size_t framesPerBX,
14 const size_t maxFramesPerFile,
18 framesPerBX_(framesPerBX),
20 maxFramesPerFile_(maxFramesPerFile),
21 maxEventsPerFile_(maxFramesPerFile_),
24 channelMap_(channelSpecs) {
25 if (channelMap_.empty())
26 throw std::runtime_error(
"BoardDataWriter channel map cannnot be empty");
28 for (
const auto& [
id,
value] : channelMap_) {
33 if ((spec.tmux % boardTMUX_) != 0)
36 ", is not a multiple of the board TMUX, " +
std::to_string(boardTMUX_));
38 const size_t tmuxRatio(spec.tmux / boardTMUX_);
39 if (
indices.size() != tmuxRatio)
42 ", does not match link:board TMUX ratio, " +
std::to_string(tmuxRatio));
44 maxEventsPerFile_ =
std::min(maxEventsPerFile_,
45 ((maxFramesPerFile_ - spec.offset) / (framesPerBX_ * boardTMUX_)) - (tmuxRatio - 1));
53 const size_t framesPerBX,
55 const size_t maxFramesPerFile,
57 const std::map<std::string, ChannelSpec>& channelSpecs)
63 if (not eventData.
has(
id))
68 for (
const auto& [
id, channelData] : eventData) {
72 "] was given to BoardDataWriter, but its structure was not defined");
78 if (channelData.size() > (spec.tmux *
framesPerBX_ - spec.interpacketGap))
81 " cycles between packets) is too long (" +
std::to_string(channelData.size()) +
84 if (channelData.empty())
92 BoardData::Channel::iterator it(
boardData_.
at(chanIndex).end() - 1);
94 it -= (channelData.size() - 1);
127 const std::map<std::string, ChannelSpec>& specMap) {
129 for (
const auto&
x : indexMap)
130 channelMap[
x.first] = {specMap.at(
x.first.interface),
x.second};
140 for (
size_t tmuxIndex = 0; tmuxIndex <
indices.size(); tmuxIndex++)
std::bitset< TTBV::S_ > Frame
Logical ID for link within any given time slice (e.g. ["tracks", 0] -> ["tracks", 17] for links from ...
BoardDataWriter(FileFormat, const std::string &filePath, const size_t framesPerBX, const size_t tmux, const size_t maxFramesPerFile, const ChannelMap_t &)
void addEvent(const EventData &data)
std::string to_string(const V &value)
void write(const BoardData &, const std::string &filePath, const FileFormat)
std::function< std::string(const size_t)> filePathGen_
static ChannelMap_t mergeMaps(const std::map< LinkId, std::vector< size_t >> &, const std::map< std::string, ChannelSpec > &)
filePath
CUSTOMIZE FOR ML.
std::map< LinkId, std::pair< ChannelSpec, std::vector< size_t > > > ChannelMap_t
std::vector< std::string > fileNames_
Class representing information phase-2 ATCA I/O data corresponding to a single event, with logical channel IDs (essentially string-uint pairs, e.g. tracks-0 to tracks-17).
bool has(const LinkId &) const