12#define BOOST_TEST_MODULE Test TPCCTFIO
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>
34namespace boost_data = boost::unit_test::data;
41 std::vector<o2::tpc::TriggerInfoDLBZS> triggers, triggersR;
44 c.nUnattachedClusters = 88;
45 c.nAttachedClustersReduced = 77;
48 triggers.emplace_back();
49 triggers.back().orbit = 1234;
52 triggers.emplace_back();
53 triggers.back().orbit = 1236;
56 std::vector<char> bVec;
62 auto buff =
reinterpret_cast<void*
>(
reinterpret_cast<char*
>(bVec.data()) + sizeCFlatBody);
71 for (
int i = 0;
i <
c.nUnattachedClusters;
i++) {
80 for (
int i = 0;
i <
c.nAttachedClusters;
i++) {
87 for (
int i = 0;
i <
c.nAttachedClustersReduced;
i++) {
89 c.sliceLegDiffA[
i] =
i;
93 for (
int i = 0;
i <
c.nTracks;
i++) {
99 c.nTrackClusters[
i] =
i;
101 for (
int i = 0;
i <
c.nSliceRows;
i++) {
102 c.nSliceRowClusters[
i] =
i;
107 std::vector<o2::ctf::BufferType> vecIO;
114 for (
const auto& trig : triggers) {
116 if (trig.triggerWord.isValid(it)) {
118 trigComp.
deltaBC.push_back(trig.triggerWord.getTriggerBC(it));
119 trigComp.
triggerType.push_back(trig.triggerWord.getTriggerType(it));
126 uint32_t prevOrbit = -1;
127 uint16_t prevBC = -1;
132 for (
size_t it = 1; it < trigComp.
triggerType.size(); it++) {
135 trigComp.
deltaBC[it] -= prevBC;
145 coder.
encode(vecIO,
c,
c, trigComp);
148 LOG(info) <<
"Compressed in " <<
sw.CpuTime() <<
" s";
153 TFile
flOut(
"test_ctf_tpc.root",
"recreate");
160 LOG(info) <<
"Wrote to tree in " <<
sw.CpuTime() <<
" s";
167 TFile
flIn(
"test_ctf_tpc.root");
172 LOG(info) <<
"Read back from tree in " <<
sw.CpuTime() <<
" s";
175 std::vector<char> vecIn;
184 LOG(info) <<
"Decompressed in " <<
sw.CpuTime() <<
" s";
Container to store compressed TPC cluster data.
Definition of the Names Generator class.
class for entropy encoding/decoding of TPC compressed clusters data
Definitions of TPC Zero Suppression Data Headers.
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 CompressedClusters &ccl, const CompressedClusters &cclFiltered, const detail::TriggerInfo &trigComp, std::vector< bool > *rejectHits=nullptr, std::vector< bool > *rejectTracks=nullptr, std::vector< bool > *rejectTrackHits=nullptr, std::vector< bool > *rejectTrackHitsReduced=nullptr)
entropy-encode compressed clusters to flat buffer
o2::ctf::CTFIOSize decode(const CTF::base &ec, VEC &buff, TRIGVEC &buffTrig)
decode entropy-encoded bloks to TPC CompressedClusters into the externally provided vector (e....
void setCombineColumns(bool v)
static size_t alignSize(T *&var, size_t n=1)
static size_t estimateSize(CompressedClusters &c)
estimate size needed to store in the flat buffer the payload of the CompressedClusters (here only the...
static void setCompClusAddresses(CompressedClusters &c, void *&buff)
set addresses of the CompressedClusters fields to point on already reserved memory region
constexpr ANSHeader ANSVersionCompat
constexpr ANSHeader ANSVersion1
Global TPC definitions and constants.
unsigned int nUnattachedClusters
unsigned char nComppressionModes
unsigned int nAttachedClusters
unsigned int nAttachedClustersReduced
void set(size_t bufferSize, const CompressedClusters &v)
Trigger info including the orbit.
static constexpr uint16_t MaxTriggerEntries
Maximum number of trigger information.
@ Cal
Laser (Calibration trigger)
@ PP
Pre Pulse for calibration.
std::vector< int32_t > deltaOrbit
std::vector< int16_t > deltaBC
std::vector< uint8_t > triggerType
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
TFile flIn("test_ctf_cpv.root")
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()))
TFile flOut("test_ctf_cpv.root", "recreate")
BOOST_DATA_TEST_CASE(CTFTest, boost_data::make(ANSVersions) ^ boost_data::make(CombineColumns), ansVersion, combineColumns)
std::vector< bool > CombineColumns(true, false)
std::vector< o2::ctf::ANSHeader > ANSVersions