12#define BOOST_TEST_MODULE Test MCHCTFIO
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>
30#include <TStopwatch.h>
35namespace boost_data = boost::unit_test::data;
41 std::vector<ROFRecord> rofs;
47 for (
int irof = 0; irof < 1000; irof++) {
48 ir += 1 + gRandom->Integer(200);
51 nch = gRandom->Poisson(20);
54 for (
int ich = 0; ich < nch; ich++) {
55 int16_t detID = 100 + gRandom->Integer(1025 - 100);
56 int16_t padID = gRandom->Integer(28672);
58 uint32_t
adc = gRandom->Integer(1024 * 1024);
59 uint16_t nsamp = gRandom->Integer(1024);
60 auto& d =
digs.emplace_back(detID, padID,
adc, tfTime, nsamp);
61 bool sat = gRandom->Rndm() > 0.9;
64 rofs.emplace_back(
ir,
start, nch);
68 std::vector<o2::ctf::BufferType>
vec;
75 LOG(info) <<
"Compressed in " <<
sw.CpuTime() <<
" s";
81 TFile
flOut(
"test_ctf_mch.root",
"recreate");
87 LOG(info) <<
"Wrote to tree in " <<
sw.CpuTime() <<
" s";
94 TFile
flIn(
"test_ctf_mch.root");
99 LOG(info) <<
"Read back from tree in " <<
sw.CpuTime() <<
" s";
112 LOG(info) <<
"Decompressed in " <<
sw.CpuTime() <<
" s";
114 LOG(info) <<
" BOOST_CHECK rofsD.size() " <<
rofsD.size() <<
" rofs.size() " << rofs.size()
115 <<
" BOOST_CHECK(digsD.size() " <<
digsD.size() <<
" digs.size()) " <<
digs.size();
class for entropy encoding/decoding of MCH digit data
BOOST_DATA_TEST_CASE(DefaultConstructorNofSamplesIsInvariant, boost::unit_test::data::make(nsamples), nofSamples)
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 decode(const CTF::base &ec, VROF &rofVec, VCOL &digVec)
entropy decode data from buffer with CTF
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const ROFRecord > &rofData, const gsl::span< const Digit > &digData)
entropy-encode data to buffer with CTF
constexpr ANSHeader ANSVersionCompat
constexpr ANSHeader ANSVersion1
int64_t differenceInBC(const InteractionRecord &other) const
std::vector< Digit > digsD
std::vector< o2::ctf::BufferType > vec
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< ROFRecord > rofsD
std::vector< o2::ctf::ANSHeader > ANSVersions
TFile flOut("test_ctf_mch.root", "recreate")
o2::InteractionRecord ir(ir0)
TTree ctfTree(std::string(o2::base::NameConf::CTFTREENAME).c_str(), "O2 CTF tree")
std::vector< Digit > digs
TFile flIn("test_ctf_mch.root")
o2::InteractionRecord ir0(3, 5)
BOOST_TEST(rofs==rofsD, boost::test_tools::per_element())
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))