16#ifndef O2_PHOS_CTFCODER_H
17#define O2_PHOS_CTFCODER_H
42 template <typename VEC>
46 template <typename VTRG, typename VCELL>
47 o2::ctf::CTFIOSize
decode(const
CTF::base& ec, VTRG& trigVec, VCELL& cellVec);
52 template <typename VEC>
53 o2::ctf::CTFIOSize encode_impl(VEC& buff, const
gsl::span<const
TriggerRecord>& trigData, const
gsl::span<const
Cell>& cellData);
54 void appendToTree(TTree&
tree,
CTF& ec);
57 std::vector<
Cell> mCellDataFilt;
61template <typename VEC>
66 mCellDataFilt.clear();
67 for (
const auto& trig : trigData) {
69 mTrgDataFilt.push_back(trig);
70 auto cellIt = cellData.begin() + trig.getFirstEntry();
71 auto& trigC = mTrgDataFilt.back();
72 trigC.setDataRange((
int)mCellDataFilt.size(), trig.getNumberOfObjects());
73 std::copy(cellIt, cellIt + trig.getNumberOfObjects(), std::back_inserter(mCellDataFilt));
76 return encode_impl(buff, mTrgDataFilt, mCellDataFilt);
78 return encode_impl(buff, trigData, cellData);
81template <
typename VEC>
82o2::ctf::CTFIOSize CTFCoder::encode_impl(VEC& buff,
const gsl::span<const TriggerRecord>& trigData,
const gsl::span<const Cell>& cellData)
96 CTFHelper helper(trigData, cellData);
99 auto szIni =
sizeof(CTFHeader) + helper.getSize() * 2. / 3;
105 ec->setHeader(helper.createHeader());
110#define ENCODEPHS(beg, end, slot, bits) CTF::get(buff.data())->encode(beg, end, int(slot), bits, optField[int(slot)], &buff, mCoders[int(slot)], getMemMarginFactor());
122 finaliseCTFOutput<CTF>(buff);
123 iosize.
rawIn = trigData.size() *
sizeof(TriggerRecord) + cellData.size() *
sizeof(Cell);
128template <
typename VTRG,
typename VCELL>
134 std::vector<int16_t> bcInc;
135 std::vector<int32_t> orbitInc;
136 std::vector<uint16_t> entries, energy, cellTime, packedID;
137 std::vector<uint8_t> status;
140#define DECODEPHOS(part, slot) ec.decode(part, int(slot), mCoders[int(slot)])
154 trigVec.reserve(header.nTriggers);
155 status.reserve(header.nCells);
157 uint32_t firstEntry = 0, cellCount = 0;
162 for (uint32_t itrig = 0; itrig < header.nTriggers; itrig++) {
164 if (orbitInc[itrig]) {
165 ir.
bc = bcInc[itrig];
168 ir.
bc += bcInc[itrig];
170 firstEntry = cellVec.size();
174 cellCount += entries[itrig];
177 for (uint16_t ic = 0; ic < entries[itrig]; ic++) {
178 cell.
setPacked(packedID[cellCount], cellTime[cellCount], energy[cellCount], status[cellCount]);
179 cellVec.emplace_back(cell);
182 trigVec.emplace_back(
ir -
mBCShift, firstEntry, entries[itrig]);
184 assert(cellCount == header.nCells);
Declarations for CTFCoderBase class (support of external dictionaries)
#define DECODEPHOS(part, slot)
#define ENCODEPHS(beg, end, slot, bits)
Helper for PHOS CTF creation.
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.
o2::ctf::CTFIOSize decode(const CTF::base &ec, VTRG &trigVec, VCELL &cellVec)
entropy decode data from buffer with CTF
void createCoders(const std::vector< char > &bufVec, o2::ctf::CTFCoderBase::OpType op) final
~CTFCoder() final=default
CTFCoder(o2::ctf::CTFCoderBase::OpType op)
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
void setPacked(uint16_t id, uint16_t t, uint16_t en, uint16_t status)
Header for data corresponding to the same hardware trigger adapted from DataFormatsEMCAL/TriggerRecor...
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()))