11#define BOOST_TEST_MODULE Test EMCAL Base
12#define BOOST_TEST_MAIN
13#define BOOST_TEST_DYN_LINK
15#include <boost/test/unit_test.hpp>
38 samplesPretrigger = 0,
40 bool havePolarity =
false,
41 haveSecBaselineCorr =
false,
43 haveSpareReadout =
true;
70 auto encoded_config = trailer.
encode();
75 BOOST_CHECK_EQUAL(trailer_decoded_config.getNumberOfNonZeroSuppressedPresamples(), presamplesNoZS);
76 BOOST_CHECK_EQUAL(trailer_decoded_config.getNumberOfNonZeroSuppressedPostsamples(), postsamplesNoZS);
78 BOOST_CHECK_EQUAL(trailer_decoded_config.getNumberOfPretriggerSamples(), samplesPretrigger);
79 BOOST_CHECK_EQUAL(trailer_decoded_config.getNumberOfSamplesPerChannel(), samplesChannel);
81 BOOST_CHECK_EQUAL(trailer_decoded_config.hasSecondBaselineCorr(), haveSecBaselineCorr);
86 BOOST_CHECK_CLOSE(trailer_decoded_config.getTimeSampleNS(), timesample, 1);
87 BOOST_CHECK_CLOSE(trailer_decoded_config.getL1PhaseNS(), 25, 1);
92 for (
int ircu = 0; ircu < 46; ircu++) {
94 auto encoded_rcu = trailer.
encode();
104 for (
auto [bufmode, nbuffers] : buffertests) {
106 auto encoded_buffer = trailer.
encode();
115 std::array<int, 10> nerrors = {0, 1, 6, 10, 112, 232, 255, 52, 22, 76};
116 for (
auto error : nerrors) {
118 auto encoded_error = trailer.
encode();
120 BOOST_CHECK_EQUAL(trailer_decoded_error.getNumberOfChannelLengthMismatch(), error);
123 for (
auto error : nerrors) {
125 auto encoded_error = trailer.
encode();
127 BOOST_CHECK_EQUAL(trailer_decoded_error.getNumberOfChannelAddressMismatch(), error);
Information stored in the RCU trailer.
void setNumberOfNonZeroSuppressedPostsamples(uint16_t npostsamples)
Set the number of postsamples before zero suppression.
void setPayloadSize(uint32_t size)
set the payload size in number of DDL (32-bit) words
void setTimeSamplePhaseNS(uint64_t triggertime, uint64_t timesample)
Set the time sample length and L1 phase based on the trigger time.
void setNumberOfNonZeroSuppressedPresamples(uint16_t npresamples)
Set the number of presamples after zero suppression.
void setNumberOfChannelAddressMismatch(uint16_t nchannel)
Set the number of channels with address mismatch.
static RCUTrailer constructFromPayloadWords(const gsl::span< const uint32_t > payloadwords)
Decode RCU trailer from payload.
void setSparseReadout(bool isSparse)
Set sparse readout mode.
BufferMode_t
Handler for encoding of the number of ALTRO buffers in the configuration.
@ NBUFFERS8
8 ALTRO buffers
@ NBUFFERS4
4 ALTRO buffers
void setNumberOfAltroBuffers(BufferMode_t bufmode)
Set the number of ALTRO buffers.
void setNumberOfPretriggerSamples(uint16_t nsamples)
Set the number of pretrigger samples.
void setBaselineCorrection(uint16_t baselineCorrection)
Set baseline correction method.
void setSecondBaselineCorrection(bool doHave)
Specify whether second basedline correction has been applied.
void setGlitchFilter(uint16_t glitchfilter)
Set the glitch filter.
void setActiveFECsA(uint16_t value)
void setActiveFECsB(uint16_t value)
void setZeroSuppression(bool doHave)
Specify whether zero suppression has been applied.
void setFirmwareVersion(uint8_t version)
Set the firmware version.
std::vector< uint32_t > encode() const
Encode RCU trailer as array of DDL (32-bit) words.
void setNumberOfSamplesPerChannel(uint16_t nsamples)
Set the number of samples per channel.
void setNumberOfChannelLengthMismatch(uint8_t nchannel)
Set the number of channels with length mismatch.
void setRCUID(int rcuid)
Set the ID of the RCU.
void setPolarity(bool doSet)
Set the polarity.
void setNumberOfPostsamples(uint16_t npostsamples)
Set the number of postsamples (after zero suppression)
void setNumberOfPresamples(uint16_t npresamples)
Set the number of presamples (after zero suppression)
BOOST_AUTO_TEST_CASE(RCUTrailer_test)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())