12#ifndef O2_MCH_RAW_BARE_ELINK_ENCODER_H
13#define O2_MCH_RAW_BARE_ELINK_ENCODER_H
23#include <fmt/format.h>
24#include <fmt/printf.h>
37template <
typename CHARGESUM>
55 void addChannelData(
uint8_t chId,
const std::vector<SampaCluster>&
data);
57 void addHeartbeat(
uint20_t bunchCrossing);
64 void fillWithSync(
int upto);
67 bool get(
int i)
const;
73 void resetLocalBunchCrossing();
88 uint64_t nofSync()
const {
return mNofSync; }
105template <
typename CHARGESUM>
113 mLocalBunchCrossing{0},
121 mPhase =
static_cast<int>(
rand() % 20);
124 for (
int i = 0;
i < mPhase;
i++) {
130template <
typename CHARGESUM>
134 throw std::invalid_argument(
"cannot add empty data");
137 assertNotMixingClusters<CHARGESUM>(
data);
141 append50(
header.uint64());
143 for (
const auto&
s :
data) {
148template <
typename CHARGESUM>
157template <
typename CHARGESUM>
166template <
typename CHARGESUM>
167void ElinkEncoder<BareFormat, CHARGESUM>::append(
bool value)
169 mBitSet.append(
value);
174template <
typename CHARGESUM>
175void ElinkEncoder<BareFormat, CHARGESUM>::append10(
uint16_t value)
177 mBitSet.append(
value, 10);
182template <
typename CHARGESUM>
183void ElinkEncoder<BareFormat, CHARGESUM>::append20(
uint32_t value)
185 mBitSet.append(
value, 20);
190template <
typename CHARGESUM>
191void ElinkEncoder<BareFormat, CHARGESUM>::append50(
uint64_t value)
193 mBitSet.append(
value, 50);
197template <
typename CHARGESUM>
198void ElinkEncoder<BareFormat, CHARGESUM>::assertSync()
200 bool firstSync = (mNofSync == 0);
205 bool pendingSync = (mSyncIndex != 0);
207 if (firstSync || pendingSync) {
208 for (
int i = mSyncIndex;
i < 50;
i++) {
218template <
typename CHARGESUM>
226template <
typename CHARGESUM>
229 auto d = upto -
len();
235template <
typename CHARGESUM>
239 return mBitSet.get(
i);
242template <
typename CHARGESUM>
245 return mBitSet.len();
248template <
typename CHARGESUM>
251 return mBitSet.subset(
a,
b).uint64(0,
b -
a + 1);
254template <
typename CHARGESUM>
257 mLocalBunchCrossing = mPhase;
unsigned short int uint16_t
std::vector< std::string > header
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
void appendCharges(const SampaCluster &sc)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLenum GLenum GLsizei len
GLboolean GLboolean GLboolean GLboolean a
uint16_t computeChipAddress(uint8_t elinkId, DualSampaChannelId chId)
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)
SampaHeader sampaHeartbeat(uint8_t elinkId, uint20_t bunchCrossing)
Heartbeat packet.
int circularAppend(BitSet &bs, const BitSet &ringBuffer, int startBit, int n)
SampaHeader sampaSync()
The 50-bits Sampa SYNC word.
void append(const char *msg, std::string &to)
Piece of data for one Sampa channel.
uint16_t nofSamples() const