12#define BOOST_TEST_MODULE Test EMCCTFIO
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::vector<TriggerRecord> triggers;
46 for (
int irof = 0; irof < 1000; irof++) {
47 ir += 1 + gRandom->Integer(200);
50 short tower = gRandom->Poisson(10);
51 while (tower < 17665) {
52 float timeCell = gRandom->Rndm() * 1500 - 600.;
53 float en = gRandom->Rndm() * 250.;
56 int readoutsource = gRandom->Integer(3);
58 switch (readoutsource) {
61 const auto ENHGLG = o2::emcal::constants::EMCAL_HGLGTRANSITION * o2::emcal::constants::EMCAL_ADCENERGY;
63 chantype = ChannelType_t::LOW_GAIN;
65 chantype = ChannelType_t::HIGH_GAIN;
70 chantype = ChannelType_t::LEDMON;
73 chantype = ChannelType_t::TRU;
77 std::cerr <<
"Unknown type" << std::endl;
80 cells.emplace_back(tower, en, timeCell, chantype);
81 tower += 1 + gRandom->Integer(100);
83 uint32_t trigBits = gRandom->Integer(0xFFFFFFFF);
88 std::vector<o2::ctf::BufferType>
vec;
95 LOG(info) <<
"Compressed in " <<
sw.CpuTime() <<
" s";
101 TFile
flOut(
"test_ctf_emcal.root",
"recreate");
107 LOG(info) <<
"Wrote to tree in " <<
sw.CpuTime() <<
" s";
114 TFile
flIn(
"test_ctf_emcal.root");
119 LOG(info) <<
"Read back from tree in " <<
sw.CpuTime() <<
" s";
132 LOG(info) <<
"Decompressed in " <<
sw.CpuTime() <<
" s";
136 LOG(info) <<
" BOOST_CHECK triggersD.size() " <<
triggersD.size() <<
" triggers.size() " << triggers.size()
137 <<
" BOOST_CHECK(cellsD.size() " <<
cellsD.size() <<
" cells.size()) " <<
cells.size();
139 for (
size_t i = 0;
i < triggers.size();
i++) {
140 const auto& dor = triggers[
i];
142 LOG(
debug) <<
" Orig.TriggerRecord " <<
i <<
" " << dor.getBCData() <<
" " << dor.getFirstEntry() <<
" " << dor.getNumberOfObjects();
143 LOG(
debug) <<
" Deco.TriggerRecord " <<
i <<
" " << ddc.getBCData() <<
" " << ddc.getFirstEntry() <<
" " << ddc.getNumberOfObjects();
148 BOOST_CHECK_EQUAL(dor.getTriggerBitsCompressed(), ddc.getTriggerBitsCompressed());
157 auto triggerbittest = triggers[
i];
158 triggerbittest.setTriggerBitsCompressed(triggerbittest.getTriggerBitsCompressed());
162 for (
size_t i = 0;
i <
cells.size();
i++) {
163 const auto& cor =
cells[
i];
class for entropy encoding/decoding of EMCAL 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, VTRG &trigVec, VCELL &cellVec)
entropy decode data from buffer with CTF
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const TriggerRecord > &trigData, const gsl::span< const Cell > &cellData)
entropy-encode data to buffer with CTF
constexpr ANSHeader ANSVersionCompat
constexpr ANSHeader ANSVersion1
ChannelType_t
Type of a raw data channel.
std::vector< Cell > cells
std::vector< o2::ctf::BufferType > vec
TFile flIn("test_ctf_emcal.root")
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< o2::ctf::ANSHeader > ANSVersions
o2::InteractionRecord ir(0, 0)
std::vector< TriggerRecord > triggersD
TTree ctfTree(std::string(o2::base::NameConf::CTFTREENAME).c_str(), "O2 CTF tree")
TFile flOut("test_ctf_emcal.root", "recreate")
std::vector< Cell > cellsD
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))