12#define BOOST_TEST_MODULE Test ITSMFTCTFIO
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>
31#include <TStopwatch.h>
35namespace boost_data = boost::unit_test::data;
42 std::vector<ROFRecord> rofRecVec;
49 for (
int irof = 0; irof < 100; irof++) {
50 auto& rofr = rofRecVec.emplace_back();
51 rofr.getBCData().orbit = irof / 10;
52 rofr.getBCData().bc = irof % 10;
53 int nChips = 5 * irof;
54 int chipID = irof / 2;
56 for (
int i = 0;
i < nChips;
i++) {
57 int nhits = gRandom->Poisson(50);
60 for (
int i = 0;
i < nhits;
i++) {
61 row[
i] = gRandom->Integer(512);
62 col[
i] = gRandom->Integer(1024);
64 std::sort(
col.begin(),
col.end());
65 for (
int i = 0;
i < nhits;
i++) {
66 auto& cl =
cclusVec.emplace_back(
row[
i],
col[
i], gRandom->Integer(1000), chipID);
67 if (cl.getPatternID() > 900) {
68 int nbpatt = 1 + gRandom->Poisson(3.);
69 for (
int i = nbpatt;
i--;) {
70 pattVec.push_back(
char(gRandom->Integer(256)));
74 chipID += 1 + gRandom->Poisson(10);
76 rofr.setNEntries(
int(
cclusVec.size()) - rofr.getFirstEntry());
79 LOG(info) <<
"Generated " <<
cclusVec.size() <<
" in " << rofRecVec.size() <<
" ROFs in " <<
sw.CpuTime() <<
" s";
82 std::vector<o2::ctf::BufferType>
vec;
89 LOG(info) <<
"Compressed in " <<
sw.CpuTime() <<
" s";
94 TFile
flOut(
"test_ctf_itsmft.root",
"recreate");
101 LOG(info) <<
"Wrote to tree in " <<
sw.CpuTime() <<
" s";
108 TFile
flIn(
"test_ctf_itsmft.root");
113 LOG(info) <<
"Read back from tree in " <<
sw.CpuTime() <<
" s";
127 LOG(info) <<
"Decompressed in " <<
sw.CpuTime() <<
" s";
134 int di = rofRecVec.size() / 10 ? rofRecVec.size() / 10 : 1;
135 for (
int i = 0;
i <
int(rofRecVec.size());
i +=
di) {
140 int ncl = rofRecVec[
i].getNEntries();
141 int firstCl = rofRecVec[
i].getFirstEntry();
142 for (
int j = 0;
j < ncl;
j += 10) {
143 auto j1 =
j + firstCl;
151 for (
int i = 0;
i <
npatt;
i += 100) {
Definition of the ITSMFT compact cluster.
class for entropy encoding/decoding of ITS/MFT compressed clusters data
Definition of the LookUp class.
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 encode(VEC &buff, const gsl::span< const ROFRecord > &rofRecVec, const gsl::span< const CompClusterExt > &cclusVec, const gsl::span< const unsigned char > &pattVec, const LookUp &clPattLookup, int strobeLength)
entropy-encode clusters to buffer with CTF
o2::ctf::CTFIOSize decode(const CTF::base &ec, VROF &rofRecVec, VCLUS &cclusVec, VPAT &pattVec, const NoiseMap *noiseMap, const LookUp &clPattLookup)
entropy decode clusters from buffer with CTF
constexpr ANSHeader ANSVersionCompat
constexpr ANSHeader ANSVersion1
std::vector< CompClusterExt > cclusVecD
LOG(info)<< "Generated "<< cclusVec.size()<< " in "<< rofRecVec.size()<< " ROFs in "<< sw.CpuTime()<< " s"
std::vector< o2::ctf::BufferType > vec
std::vector< ROFRecord > rofRecVecD
std::vector< unsigned char > pattVec
std::vector< CompClusterExt > cclusVec
std::vector< o2::ctf::ANSHeader > ANSVersions
TFile flIn("test_ctf_itsmft.root")
std::vector< unsigned char > pattVecD
TFile flOut("test_ctf_itsmft.root", "recreate")
TTree ctfTree(std::string(o2::base::NameConf::CTFTREENAME).c_str(), "O2 CTF tree")
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))