Skip to content

Decoding RD53b does not identify end of streams when data comes on the fly

When trying to use endec for decoding of frames as they would come from the FE (i.e don't know where the end of the event is and cannot call core.finalize()), dd behaviour for RD53B was notives. In the following examples, I am decoding 2 streams containg 10 hits, spanning 5 frames, each (produced with encode_file 10hits.txt -f RD53B,id,eos --id 0. Executing test_header_only example:

  std::vector<uint64_t> data = {
    0x8000c6e811e23940,
    0x0ba7948523986373,
    0x1295d0c3a4bb6b82,
    0x105e47a8b5521319,
    0x0c29200000000000,
... + 1 second event as above
};
  core.decode(data);
  std::cout << "Finalize\n";
  core.finalize();

one gets:

evt_init(0)
add_hit(3,111,1)
add_hit(52,70,0)
add_hit(81,317,8)
add_hit(159,114,12)
add_hit(212,228,14)
add_hit(261,59,11)
add_hit(356,369,0)
add_hit(369,287,5)
add_hit(371,341,4)
add_hit(385,177,9)
evt_done()
Finalize
evt_init(0)
add_hit(3,111,1)
add_hit(52,70,0)
add_hit(81,317,8)
add_hit(159,114,12)
add_hit(212,228,14)
add_hit(261,59,11)
add_hit(356,369,0)
add_hit(369,287,5)
add_hit(371,341,4)
add_hit(385,177,9)
evt_done()

==> expected behaviour: when EOS(first bit of the second event as this is RD53B) is triggered, the callback is called. Then, the call to finalize decodes the second event. However, feeding the 64-bit frames one by one:

  for(auto i = 0; i < data.size(); i++){
    std::cout << "i " << i << "\n"; 
    core.decode(&data[i], 1);
  }
  std::cout << "Finalize \n";
  core.finalize();

one gets

i 0
i 1
i 2
i 3
i 4
i 5
i 6
i 7
i 8
i 9
Finalize 
evt_init(0)
add_hit(3,111,1)
add_hit(52,70,0)
add_hit(81,317,8)
add_hit(159,114,12)
add_hit(212,228,14)
add_hit(261,59,11)
add_hit(356,369,0)
add_hit(369,287,5)
add_hit(371,341,4)
add_hit(385,177,9)
on_error(9)
evt_done()

==> The EoS is not captured, data are decoded only when core.finalized is called with an error 9, which means throwing away data after EoS.

This behaviour is not seen for RD53C. The callback is correctly called at the end of first event, then at the end of second event, then finalize is printed.