Skip to content

ITkPix* encoder reimplementations & ITkPixV2 unit test

Ondrej Kovanda requested to merge okovanda_itkpixv2_encoder into devel

The encoder for ITkPixV1/V2 is implemented in a base class (libEmu/ItkpixEncoder.cpp), which holds the commonalities of the encoding machinery, and two derived classes (libRd53b/Rd53bEncoder.cpp and libItkpixv2/Itkpixv2Encoder.cpp) holding the chip-specific functions. The encoding of the QCore hit maps uses a LUT in libEmu/include/ItkpixQCoreEncodingLUT.h, indexed by the 16-bit raw hit map. Currently, the input into the encoder is a std::vector<std::vector<uint16_t>>, representing the (ToT + 1) values in the individual pixels. A simple hit map generator is present in libEmu/HitMapGenerator.cxx, which generates random uniform hit maps with adjustable occupancy. For example, an encoded stream of 18 random events can be obtained by:

#include "HitMapGenerator.h"
#include "Itkpixv2Encoder.h"
...
FrontEndData truth;
    
std::unique_ptr<HitMapGenerator> generator(new HitMapGenerator());
int nEvents = 18;
int nEventsPerStream = 16;
generator->setSeed(0);
float occupancy = 1e-4;
    
std::unique_ptr<Itkpixv2Encoder> encoder(new Itkpixv2Encoder());
encoder->setEventsPerStream(nEventsPerStream);
for (int evt = 0; evt < nEvents; evt++){
    generator->randomHitMap(occupancy);
    truth.events.push_back(generator->outTruth());
    if   (evt != nEvents - 1) encoder->addToStream(generator->outHits());
    else                      encoder->addToStream(generator->outHits(), true); //make sure the stream is ended with the last added event
}
    
std::vector<uint32_t> words = encoder->getWords();

This generation/encoding recipe is used in a newly introduced unit test for the Itkpixv2 decoder in libItkpxv2/tests/test_Itkpixv2_data_processor.cpp.

Other affected files: libRd53b/tests/test_data_processor.cpp: - switching to the new generation/encoding implementation above - fixing a double-increase bug in the loop comparing decoded events to truth (odd indices were skipped due to 2x ievt++)

libItkpixv2/Itkpixv2DataProcessor.cpp: - adding a patch to catch the corner case where the 16-bit hit map retireval reaches the end of the last word in the stream, which leads to undecoded last hit. The decoder now does not exit upon reaching the end of the stream if it's in the hit map retrieval stage.

Doxyfile: - Excluding the encoding LUT from doxygen, since it's too large and thus was failing to pass the CI pipeline.

CMakeLists: - Adding the appropriate linking/include info for the encoder implementation in libEmu, libRd53b and libItkpixv2

Merge request reports