16#ifndef O2_TPC_CTFCODER_H
17#define O2_TPC_CTFCODER_H
63template <
int A,
int B>
68template <
int A,
int B>
71template <
typename value_T,
size_t shift>
75 template <
typename iterA_T,
typename iterB_T>
76 inline value_T
operator()(iterA_T iterA, iterB_T iterB)
const
78 return *iterB + (
static_cast<value_T
>(*iterA) << shift);
81 template <
typename iterA_T,
typename iterB_T>
84 *iterA =
value >> shift;
85 *iterB =
value & ((0x1 << shift) - 0x1);
89template <
typename iterA_T,
typename iterB_T,
typename F>
94 auto advanceIter = [](
auto iter,
size_t nElements) {
96 std::advance(tmp, nElements);
104template <
int bits_A,
int bits_B>
109 template <
typename iterA_T,
typename iterB_T,
typename F>
116 decodingFunctor(iter, slot);
129 template <typename VEC>
130 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);
132 template <typename VEC, typename TRIGVEC>
133 o2::ctf::CTFIOSize
decode(const
CTF::base& ec, VEC& buff, TRIGVEC& buffTrig);
143 template <
size_t ALG =
Alignment, typename T>
146 auto sz =
sizeof(T) *
n;
148 return res ? sz + (ALG -
res) : sz;
151 template <
size_t ALG = Alignment,
typename T>
154 auto sz =
sizeof(T) *
n;
156 var =
reinterpret_cast<T*
>(
ptr);
157 auto& ptrR =
reinterpret_cast<size_t&
>(
ptr);
158 ptrR +=
res ? sz + (ALG -
res) : sz;
165 void checkDataDictionaryConsistency(
const CTFHeader&
h);
167 template <
int NU,
int NL,
typename CU,
typename CL>
170 template <
typename source_T>
173 bool mCombineColumns =
false;
176template <
typename source_T>
183template <
typename VEC>
187 using namespace detail;
224 if (mCombineColumns) {
227 ec->setHeader(
CTFHeader{o2::detectors::DetID::TPC, 0, 1, 0,
235 const auto slotVal =
static_cast<int>(slot);
237 std::vector<std::decay_t<
decltype(*begin)>> tmp;
238 tmp.reserve(std::distance(
begin,
end));
240 if (!(*reject)[std::distance(
begin,
i)]) {
241 tmp.emplace_back(*
i);
244 iosize +=
CTF::get(buff.data())->encode(tmp.begin(), tmp.end(), slotVal, probabilityBits, optField[slotVal], &buff, coders[slotVal], mfc);
246 iosize +=
CTF::get(buff.data())->encode(
begin,
end, slotVal, probabilityBits, optField[slotVal], &buff, coders[slotVal], mfc);
250 if (mCombineColumns) {
261 if (mCombineColumns) {
273 if (mCombineColumns) {
288 if (mCombineColumns) {
301 if (mCombineColumns) {
318 finaliseCTFOutput<CTF>(buff);
324template <
typename VEC,
typename TRIGVEC>
327 using namespace detail;
332 checkDataDictionaryConsistency(
header);
335 size_t sizeCFlatBody =
alignSize(ccFlat);
337 size_t vsz =
sizeof(
typename std::remove_reference<
decltype(buffVec)>::type::value_type);
338 buffVec.resize(sz / vsz);
340 auto buff =
reinterpret_cast<void*
>(
reinterpret_cast<char*
>(buffVec.data()) + sizeCFlatBody);
349 const auto slotVal =
static_cast<int>(slot);
350 iosize += ec.
decode(
begin, slotVal, coders[slotVal]);
353 if (mCombineColumns) {
362 if (mCombineColumns) {
372 if (mCombineColumns) {
385 if (mCombineColumns) {
396 if (mCombineColumns) {
406 static TriggerInfo trigInfo;
407 trigInfo.resize(
header.nTriggers);
416 if (trigInfo.deltaOrbit[it] || !it) {
418 auto&
t = buffTrig.emplace_back();
419 t.orbit = prevOrbit + trigInfo.deltaOrbit[it];
420 t.triggerWord.triggerEntries[freeSlot++] = (trigInfo.deltaBC[it] & 0xFFF) | ((trigInfo.triggerType[it] & 0x7) << 12) | 0x8000;
421 prevBC = trigInfo.deltaBC[it];
424 prevBC += trigInfo.deltaBC[it];
425 buffTrig.back().triggerWord.triggerEntries[freeSlot++] = (prevBC & 0xFFF) | ((trigInfo.triggerType[it] & 0x7) << 12) | 0x8000;
Declarations for CTFCoderBase class (support of external dictionaries)
Container to store compressed TPC cluster data.
unsigned short int uint16_t
std::vector< std::string > header
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
void encodeTPC(const std::string &name, const TPCCompressedClusters &compressedClusters, bool mergeColumns, rapidjson::Writer< rapidjson::OStreamWrapper > &writer)
Class for time synchronization of RawReader instances.
void createCoder(OpType op, const o2::rans::RenormedDenseHistogram< S > &renormedHistogram, int slot)
float getMemMarginFactor() const
std::vector< std::any > mCoders
void checkDictVersion(const CTFDictHeader &h) const
ctf::ANSHeader mANSVersion
std::string getPrefix() const
virtual void assignDictVersion(CTFDictHeader &h) const
static auto get(void *head)
cast arbitrary buffer head to container class. Head is supposed to respect the alignment
o2::ctf::CTFIOSize decode(container_T &dest, int slot, const std::any &decoderExt={}) const
decode block at provided slot to destination vector (will be resized as needed)
const H & getHeader() const
void print(const std::string &prefix="", int verbosity=1) const
print itself
static constexpr int getNBlocks()
static auto create(void *head, size_t sz)
create container from arbitrary buffer of predefined size (in bytes!!!). Head is supposed to respect ...
Static class with identifiers, bitmasks and names for ALICE detectors.
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
static void setAlignedPtr(void *&ptr, T *&var, size_t n=1)
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)
size_t estimateCompressedSize(const CompressedClusters &ccl)
static size_t alignSize(T *&var, size_t n=1)
void createCoders(const std::vector< char > &bufVec, o2::ctf::CTFCoderBase::OpType op) final
static size_t estimateSize(CompressedClusters &c)
estimate size needed to store in the flat buffer the payload of the CompressedClusters (here only the...
CTFCoder(o2::ctf::CTFCoderBase::OpType op, const std::string &ctfdictOpt="none")
static size_t constexpr Alignment
bool getCombineColumns() const
~CTFCoder() final=default
static void setCompClusAddresses(CompressedClusters &c, void *&buff)
set addresses of the CompressedClusters fields to point on already reserved memory region
void operator()(iterA_T iterA, iterB_T iterB, value_T value) const
value_T operator()(iterA_T iterA, iterB_T iterB) const
GLsizei const GLfloat * value
public interface for rANS iterators.
typename combinedType< A, B >::type combinedType_t
auto makeInputIterators(iterA_T iterA, iterB_T iterB, size_t nElements, F functor)
Enum< T >::Iterator begin(Enum< T >)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
wrapper for the Entropy-encoded clusters of the TF
static constexpr int NBitsSliceLegDiff
o2::ctf::EncodedBlocks< CTFHeader, 26, uint32_t > container_t
static constexpr int NBitsQMax
static constexpr int NBitsSigmaTime
unsigned int nUnattachedClusters
unsigned int nAttachedClusters
unsigned int nAttachedClustersReduced
void set(size_t bufferSize, const CompressedClusters &v)
combinedType_t< bits_A, bits_B > combined_t
static void decode(iterA_T iterA, iterB_T iterB, CTF::Slots slot, F decodingFunctor)
std::vector< int32_t > deltaOrbit
std::vector< int16_t > deltaBC
std::vector< uint8_t > triggerType
std::conditional_t<(A+B > 16), uint32_t, std::conditional_t<(A+B > 8), uint16_t, uint8_t > > type
auto makeInputIterators(iterA_T iterA, iterB_T iterB, size_t nElements, F functor)
std::vector< o2::mch::ChannelCode > cc