16#ifndef O2_EMCAL_CTFCODER_H
17#define O2_EMCAL_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);
56 void assignDictVersion(
o2::ctf::CTFDictHeader&
h) const final;
58 std::vector<
Cell> mCellDataFilt;
62template <typename VEC>
67 mCellDataFilt.clear();
68 for (
const auto& trig : trigData) {
70 mTrgDataFilt.push_back(trig);
71 auto cellIt = cellData.begin() + trig.getFirstEntry();
72 auto& trigC = mTrgDataFilt.back();
73 trigC.setDataRange((
int)mCellDataFilt.size(), trig.getNumberOfObjects());
74 std::copy(cellIt, cellIt + trig.getNumberOfObjects(), std::back_inserter(mCellDataFilt));
77 return encode_impl(buff, mTrgDataFilt, mCellDataFilt);
79 return encode_impl(buff, trigData, cellData);
82template <
typename VEC>
83o2::ctf::CTFIOSize CTFCoder::encode_impl(VEC& buff,
const gsl::span<const TriggerRecord>& trigData,
const gsl::span<const Cell>& cellData)
99 CTFHelper helper(trigData, cellData);
102 auto szIni =
sizeof(CTFHeader) + helper.getSize() * 2. / 3;
108 ec->setHeader(helper.createHeader());
113#define ENCODEEMC(beg, end, slot, bits) CTF::get(buff.data())->encode(beg, end, int(slot), bits, optField[int(slot)], &buff, mCoders[int(slot)], getMemMarginFactor());
127 finaliseCTFOutput<CTF>(buff);
128 iosize.
rawIn =
sizeof(TriggerRecord) * trigData.size() +
sizeof(Cell) * cellData.size();
133template <
typename VTRG,
typename VCELL>
139 std::vector<int32_t> orbitInc;
140 std::vector<int16_t> bcInc;
141 std::vector<uint16_t> entries, energy, cellTime, tower, trigger;
142 std::vector<uint8_t> status;
145#define DECODEEMCAL(part, slot) ec.decode(part, int(slot), mCoders[int(slot)])
158 if (trigger.empty()) {
159 trigger.resize(header.nTriggers);
166 trigVec.reserve(header.nTriggers);
167 status.reserve(header.nCells);
170 if (header.majorVersion == 1 && header.minorVersion == 1) {
172 }
else if (header.majorVersion == 1 && header.minorVersion == 2) {
176 uint32_t firstEntry = 0, cellCount = 0;
181 for (uint32_t itrig = 0; itrig < header.nTriggers; itrig++) {
183 if (orbitInc[itrig]) {
184 ir.
bc = bcInc[itrig];
187 ir.
bc += bcInc[itrig];
192 cellCount += entries[itrig];
195 firstEntry = cellVec.size();
197 for (uint16_t ic = 0; ic < entries[itrig]; ic++) {
198 cellVec.emplace_back(tower[cellCount], energy[cellCount], cellTime[cellCount], status[cellCount], encodingversion);
204 trigVec.emplace_back(trg);
206 assert(cellCount == header.nCells);
Declarations for CTFCoderBase class (support of external dictionaries)
#define ENCODEEMC(beg, end, slot, bits)
#define DECODEEMCAL(part, slot)
Helper for EMCAL CTF creation.
Class for time synchronization of RawReader instances.
void checkDictVersion(const CTFDictHeader &h) const
ctf::ANSHeader mANSVersion
std::string getPrefix() const
o2::utils::IRFrameSelector mIRFrameSelector
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.
~CTFCoder() final=default
CTFCoder(o2::ctf::CTFCoderBase::OpType op)
void createCoders(const std::vector< char > &bufVec, o2::ctf::CTFCoderBase::OpType op) final
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
EMCAL compressed cell information.
Header for data corresponding to the same hardware trigger.
void setBCData(const BCData &data)
void setDataRange(int firstentry, int nentries)
void setTriggerBitsCompressed(uint16_t triggerbits)
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()))