16#define BOOST_TEST_MODULE Test TPC DataFormats
17#define BOOST_TEST_MAIN
18#define BOOST_TEST_DYN_LINK
19#include "../include/DataFormatsTPC/CompressedClusters.h"
20#include "../include/DataFormatsTPC/CompressedClustersHelpers.h"
21#include <boost/test/unit_test.hpp>
32template <
typename ContainerType>
36 std::generate(
target.begin(),
target.end(), []() { return rand() % 256; });
40 std::vector<unsigned short>
qTotA;
41 std::vector<unsigned short>
qMaxA;
50 std::vector<unsigned char>
qPtA;
51 std::vector<unsigned char>
rowA;
53 std::vector<unsigned int>
timeA;
54 std::vector<unsigned short>
padA;
56 std::vector<unsigned short>
qTotU;
57 std::vector<unsigned short>
qMaxU;
70 clusters.nAttachedClusters = rand() % 32;
82 clusters.nAttachedClustersReduced = rand() % 32;
106 clusters.nUnattachedClusters = rand() % 32;
124 clusters.nSliceRowClusters =
data.nSliceRowClusters.data();
137 BOOST_REQUIRE(restored.
qTotA ==
nullptr);
157 std::string fileName = gSystem->TempDirectory();
158 fileName +=
"/testCompressedClusters.root";
161 std::unique_ptr<TFile> testFile(TFile::Open(fileName.c_str(),
"RECREATE"));
162 std::unique_ptr<TTree> testTree = std::make_unique<TTree>(
"testtree",
"testtree");
164 auto* branch = testTree->Branch(
"compclusters", &
clusters);
167 testTree->SetDirectory(
nullptr);
172 std::unique_ptr<TFile>
file(TFile::Open(fileName.c_str()));
173 BOOST_REQUIRE(
file !=
nullptr);
174 TTree*
tree =
reinterpret_cast<TTree*
>(
file->GetObjectChecked(
"testtree",
"TTree"));
175 BOOST_REQUIRE(
tree !=
nullptr);
176 TBranch* branch =
tree->GetBranch(
"compclusters");
177 BOOST_REQUIRE(branch !=
nullptr);
179 branch->SetAddress(&readback);
181 BOOST_REQUIRE(readback !=
nullptr);
Global TPC definitions and constants.
BOOST_AUTO_TEST_CASE(ClusterHardware_test1)
void fillClusters(CompressedClustersROOT &clusters, ClustersData &data)
void fillRandom(ContainerType &target, size_t size)
std::vector< unsigned short > padResA
[nAttachedClustersReduced]
std::vector< unsigned char > sigmaTimeA
[nAttachedClusters]
std::vector< unsigned int > timeDiffU
[nUnattachedClusters]
std::vector< unsigned char > qPtA
[nAttachedClusters]
std::vector< unsigned char > sliceA
[nTracks]
std::vector< unsigned char > sigmaTimeU
[nUnattachedClusters]
std::vector< unsigned short > padA
[nTracks]
std::vector< unsigned short > qTotA
std::vector< unsigned short > nTrackClusters
[nUnattachedClusters]
std::vector< unsigned char > rowA
[nTracks]
std::vector< unsigned int > timeResA
[nAttachedClustersReduced]
std::vector< unsigned short > padDiffU
[nUnattachedClusters]
std::vector< unsigned char > flagsU
[nUnattachedClusters]
std::vector< unsigned short > qMaxU
[nUnattachedClusters]
std::vector< unsigned char > flagsA
[nAttachedClusters]
std::vector< unsigned char > rowDiffA
[nAttachedClusters]
std::vector< unsigned int > timeA
[nTracks]
std::vector< unsigned char > sigmaPadA
[nAttachedClustersReduced]
std::vector< unsigned int > nSliceRowClusters
[nTracks]
std::vector< unsigned short > qTotU
[nTracks]
std::vector< unsigned char > sigmaPadU
[nUnattachedClusters]
std::vector< unsigned char > sliceLegDiffA
[nAttachedClustersReduced]
std::vector< unsigned short > qMaxA
[nAttachedClusters]
unsigned int nUnattachedClusters
unsigned int nAttachedClusters
static size_t flattenTo(ContainerType &container, CompressedClustersROOT &clusters)
static size_t restoreFrom(ContainerType &container, CompressedClustersROOT &clusters)
Restore the array pointers from the data in the container.
std::vector< Cluster > clusters
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))