16#ifndef O2_CPV_CTFCODER_H
17#define O2_CPV_CTFCODER_H
42 template <typename VEC>
46 template <typename VTRG, typename VCLUSTER>
47 o2::ctf::CTFIOSize
decode(const
CTF::base& ec, VTRG& trigVec, VCLUSTER& cluVec);
52 template <typename VEC>
55 void appendToTree(TTree&
tree,
CTF& ec);
62template <typename VEC>
67 mClusDataFilt.clear();
68 for (
const auto& trig : trigData) {
70 mTrgDataFilt.push_back(trig);
71 auto clusIt = cluData.begin() + trig.getFirstEntry();
72 auto& trigC = mTrgDataFilt.back();
73 trigC.setDataRange((
int)mClusDataFilt.size(), trig.getNumberOfObjects());
74 std::copy(clusIt, clusIt + trig.getNumberOfObjects(), std::back_inserter(mClusDataFilt));
77 return encode_impl(buff, mTrgDataFilt, mClusDataFilt);
79 return encode_impl(buff, trigData, cluData);
82template <
typename VEC>
83o2::ctf::CTFIOSize CTFCoder::encode_impl(VEC& buff,
const gsl::span<const TriggerRecord>& trigData,
const gsl::span<const Cluster>& cluData)
97 CTFHelper helper(trigData, cluData);
100 auto szIni =
sizeof(CTFHeader) + helper.getSize() * 2. / 3;
106 ec->setHeader(helper.createHeader());
111#define ENCODECPV(beg, end, slot, bits) CTF::get(buff.data())->encode(beg, end, int(slot), bits, optField[int(slot)], &buff, mCoders[int(slot)], getMemMarginFactor());
123 finaliseCTFOutput<CTF>(buff);
124 iosize.
rawIn = trigData.size() *
sizeof(TriggerRecord) + cluData.size() *
sizeof(
Cluster);
129template <
typename VTRG,
typename VCLUSTER>
135 std::vector<int16_t> bcInc;
136 std::vector<int32_t> orbitInc;
137 std::vector<uint16_t> entries, posX, posZ;
138 std::vector<uint8_t> energy, status;
141#define DECODECPV(part, slot) ec.decode(part, int(slot), mCoders[int(slot)])
154 trigVec.reserve(header.nTriggers);
155 status.reserve(header.nClusters);
157 uint32_t firstEntry = 0, cluCount = 0;
161 for (uint32_t itrig = 0; itrig < header.nTriggers; itrig++) {
163 if (orbitInc[itrig]) {
164 ir.
bc = bcInc[itrig];
167 ir.
bc += bcInc[itrig];
172 cluCount += entries[itrig];
175 firstEntry = cluVec.size();
176 for (uint16_t ic = 0; ic < entries[itrig]; ic++) {
177 clu.setPacked(posX[cluCount], posZ[cluCount], energy[cluCount], status[cluCount]);
178 cluVec.emplace_back(
clu);
181 trigVec.emplace_back(
ir -
mBCShift, firstEntry, entries[itrig]);
183 assert(cluCount == header.nClusters);
#define ENCODECPV(beg, end, slot, bits)
#define DECODECPV(part, slot)
Helper for CPV CTF creation.
Declarations for CTFCoderBase class (support of external dictionaries)
o2::ctf::CTFIOSize decode(const CTF::base &ec, VTRG &trigVec, VCLUSTER &cluVec)
entropy decode data from buffer with CTF
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const TriggerRecord > &trigData, const gsl::span< const Cluster > &cluData)
entropy-encode data to buffer with CTF
~CTFCoder() final=default
CTFCoder(o2::ctf::CTFCoderBase::OpType op)
void createCoders(const std::vector< char > &bufVec, ctf::CTFCoderBase::OpType op) final
Contains CPV cluster parameters.
Header for data corresponding to the same hardware trigger adapted from DataFormatsEMCAL/TriggerRecor...
void checkDictVersion(const CTFDictHeader &h) const
ctf::ANSHeader mANSVersion
std::string getPrefix() const
o2::utils::IRFrameSelector mIRFrameSelector
virtual void assignDictVersion(CTFDictHeader &h) const
bool canApplyBCShift(const o2::InteractionRecord &ir, long shift) const
<<======================== Auxiliary classes =======================<<
static auto get(void *head)
cast arbitrary buffer head to container class. Head is supposed to respect the alignment
const H & getHeader() const
void print(const std::string &prefix="", int verbosity=1) const
print itself
static constexpr int getNBlocks()
EncodedBlocks< CTFHeader, N, uint32_t > base
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.
HMPID cluster implementation.
long check(o2::dataformats::IRFrame fr, size_t bwd=0, size_t fwd=0)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
uint16_t bc
bunch crossing ID of interaction
wrapper for the Entropy-encoded triggers and cells of the TF
o2::InteractionRecord ir(0, 0)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))