12#define BOOST_TEST_MODULE Test MIDCTFIO
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
19#include <boost/test/unit_test.hpp>
20#include <boost/test/data/test_case.hpp>
21#include <boost/test/data/dataset.hpp>
29#include <TStopwatch.h>
34namespace boost_data = boost::unit_test::data;
40 std::array<std::vector<ColumnData>,
NEvTypes> colData{};
47 gSystem->Load(
"libO2DetectorsCommonDataFormats");
52 for (
int irof = 0; irof < 1000; irof++) {
53 ir += 1 + gRandom->Integer(200);
54 for (uint8_t evtyp = 0; evtyp <
NEvTypes; evtyp++) {
55 if (gRandom->Rndm() > 0.8) {
60 nch = gRandom->Poisson(10);
62 auto start = colData[evtyp].size();
63 for (
int ich = 0; ich < nch; ich++) {
64 uint8_t deId = gRandom->Integer(128);
65 uint8_t columnId = gRandom->Integer(128);
66 for (
int i = 0;
i < 5;
i++) {
67 pattern[
i] = gRandom->Integer(0x7fff);
82 std::vector<o2::ctf::BufferType>
vec;
89 LOG(info) <<
"Compressed in " <<
sw.CpuTime() <<
" s";
95 TFile
flOut(
"test_ctf_mid.root",
"recreate");
101 LOG(info) <<
"Wrote to tree in " <<
sw.CpuTime() <<
" s";
108 TFile
flIn(
"test_ctf_mid.root");
113 LOG(info) <<
"Read back from tree in " <<
sw.CpuTime() <<
" s";
126 LOG(info) <<
"Decompressed in " <<
sw.CpuTime() <<
" s";
128 for (uint32_t it = 0; it <
NEvTypes; it++) {
130 const auto& rofs =
rofData[it];
132 const auto&
cols = colData[it];
133 LOG(info) <<
"Test for event type " << it;
136 LOG(info) <<
" BOOST_CHECK rofsD.size() " <<
rofsD.size() <<
" rofs.size() " <<
rofData[0].size()
137 <<
" BOOST_CHECK(colsD.size() " << colsD.size() <<
" cols.size()) " << colData[0].size();
139 for (
size_t i = 0;
i < rofs.size();
i++) {
140 const auto& dor = rofs[
i];
141 const auto& ddc =
rofsD[
i];
142 LOG(
debug) <<
" Orig.ROFRecord " <<
i <<
" " << dor.interactionRecord <<
" " << dor.firstEntry <<
" " << dor.nEntries;
143 LOG(
debug) <<
" Deco.ROFRecord " <<
i <<
" " << ddc.interactionRecord <<
" " << ddc.firstEntry <<
" " << ddc.nEntries;
145 BOOST_CHECK(dor.interactionRecord == ddc.interactionRecord);
150 for (
size_t i = 0;
i <
cols.size();
i++) {
151 const auto& cor =
cols[
i];
152 const auto& cdc = colsD[
i];
155 for (
int j = 0;
j < 5;
j++) {
157 LOG(
debug) <<
"col " <<
i <<
" pat " <<
j <<
" : " << cor.patterns[
j] <<
" : " << cdc.patterns[
j];
Class to check if give InteractionRecord or IRFrame is selected by the external IRFrame vector.
class for entropy encoding/decoding of MID column data
Definition of the Names Generator class.
static constexpr std::string_view CTFTREENAME
void setANSVersion(const ctf::ANSHeader &ansVersion) noexcept
void readFromTree(TTree &tree, const std::string &name, int ev=0)
read from tree to non-flat object
static auto get(void *head)
cast arbitrary buffer head to container class. Head is supposed to respect the alignment
static auto getImage(const void *newHead)
get const image of the container wrapper, with pointers in the image relocated to new head
o2::ctf::CTFIOSize encode(VEC &buff, const CTFHelper::TFData &tfData)
entropy-encode data to buffer with CTF
o2::ctf::CTFIOSize decode(const CTF::base &ec, std::array< VROF, NEvTypes > &rofVec, std::array< VCOL, NEvTypes > &colVec)
entropy decode data from buffer with CTF
constexpr ANSHeader ANSVersionCompat
constexpr ANSHeader ANSVersion1
BOOST_DATA_TEST_CASE(MID_DigitMerger, boost::unit_test::data::make(getDEList()), deId)
constexpr uint32_t NEvTypes
std::array< gsl::span< const o2::mid::ROFRecord >, NEvTypes > rofData
std::array< gsl::span< const o2::mid::ColumnData >, NEvTypes > colData
void buildReferences(o2::utils::IRFrameSelector &irSelector)
Column data structure for MID.
std::vector< ROFRecord > rofsD
std::vector< o2::ctf::BufferType > vec
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::array< std::vector< ROFRecord >, NEvTypes > rofDataD
std::vector< o2::ctf::ANSHeader > ANSVersions
o2::InteractionRecord ir(0, 0)
std::array< std::vector< ROFRecord >, NEvTypes > rofData
o2::utils::IRFrameSelector irSelector
TTree ctfTree(std::string(o2::base::NameConf::CTFTREENAME).c_str(), "O2 CTF tree")
std::array< std::vector< ColumnData >, NEvTypes > colDataD
TFile flOut("test_ctf_mid.root", "recreate")
TFile flIn("test_ctf_mid.root")
std::array< uint16_t, 5 > pattern
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))