24 if (!opt.has_value()) {
25 throw std::invalid_argument(fmt::format(
"elinkId {} is not valid", elinkId));
27 return opt.value() * 2 + (chId > 31);
42 for (
const auto& s :
data) {
43 n10 += s.nof10BitWords();
45 uint32_t bunchCrossingCounter{0};
47 bunchCrossingCounter =
data[0].bunchCrossing;
53 assertNofBits(
"bunchCrossingCounter", bunchCrossingCounter, 20);
61uint64_t
build64(uint16_t a10, uint16_t b10 = 0, uint16_t c10 = 0, uint16_t d10 = 0, uint16_t e10 = 0)
68 return (
static_cast<uint64_t
>(a10) << 40) |
69 (
static_cast<uint64_t
>(b10) << 30) |
70 (
static_cast<uint64_t
>(c10) << 20) |
71 (
static_cast<uint64_t
>(d10) << 10) |
72 (
static_cast<uint64_t
>(e10));
77 while (b10.size() % 5) {
82void b10to64(std::vector<uint10_t> b10, std::vector<uint64_t>& b64, uint16_t prefix14)
84 uint64_t prefix = prefix14;
89 for (
auto i = 0;
i < b10.size();
i += 5) {
90 uint64_t
v =
build64(b10[
i + 4], b10[
i + 3], b10[
i + 2], b10[
i + 1], b10[
i + 0]);
91 b64.emplace_back(
v | prefix);
98 b10.emplace_back(
c.nofSamples());
99 b10.emplace_back(
c.sampaTime);
100 if (
c.isClusterSum()) {
101 b10.emplace_back(
c.chargeSum & 0x3FF);
102 b10.emplace_back((
c.chargeSum & 0xFFC00) >> 10);
104 for (
auto& s :
c.samples) {
113 b10.emplace_back((
value & 0x3FF));
114 b10.emplace_back((
value & 0xFFC00) >> 10);
115 b10.emplace_back((
value & 0x3FF00000) >> 20);
116 b10.emplace_back((
value & 0xFFC0000000) >> 30);
117 b10.emplace_back((
value & 0x3FF0000000000) >> 40);
127 gsl::span<const SampaCluster>
clusters,
GLsizei const GLfloat * value
uint64_t build64(uint16_t a10, uint16_t b10=0, uint16_t c10=0, uint16_t d10=0, uint16_t e10=0)
void addPadding(std::vector< uint10_t > &b10)
void fillUserLogicBuffer10(std::vector< uint10_t > &b10, gsl::span< const SampaCluster > clusters, uint8_t elinkId, DualSampaChannelId chId, bool addSync)
uint16_t computeChipAddress(uint8_t elinkId, DualSampaChannelId chId)
void assertNofBits(std::string_view msg, T value, int n)
void append(std::vector< uint10_t > &b10, uint50_t value)
SampaHeader buildSampaHeader(uint8_t elinkId, DualSampaChannelId chId, gsl::span< const SampaCluster > data)
int assertIsInRange(std::string what, uint64_t value, uint64_t min, uint64_t max)
void appendSync(std::vector< uint10_t > &b10)
void b10to64(std::vector< uint10_t > b10, std::vector< uint64_t > &b64, uint16_t prefix14)
void bufferizeClusters(gsl::span< const SampaCluster > clusters, std::vector< uint10_t > &b10)
int computeHeaderParity(uint64_t value)
std::optional< uint8_t > indexFromElinkId(uint8_t elinkId)
Extracts the index from the elinkId.
constexpr uint64_t sampaSyncWord
uint6_t DualSampaChannelId
int computeHammingCode(uint64_t value)
std::vector< Cluster > clusters