16#ifndef O2_TOF_CTFCODER_H
17#define O2_TOF_CTFCODER_H
41 template <typename VEC>
45 template <typename VROF, typename VDIG, typename VPAT>
46 o2::ctf::CTFIOSize
decode(const
CTF::base& ec, VROF& rofRecVec, VDIG& cdigVec, VPAT&
pattVec);
55 template <typename VROF, typename VDIG, typename VPAT>
58 void appendToTree(TTree&
tree,
CTF& ec);
64template <typename VEC>
83 compress(
cc, rofRecVec, cdigVec,
pattVec);
85 auto szIni = estimateCompressedSize(
cc);
91 ec->setHeader(
cc.header);
96#define ENCODETOF(part, slot, bits) CTF::get(buff.data())->encode(part, int(slot), bits, optField[int(slot)], &buff, mCoders[int(slot)], getMemMarginFactor());
111 finaliseCTFOutput<CTF>(buff);
118template <
typename VROF,
typename VDIG,
typename VPAT>
126#define DECODETOF(part, slot) ec.decode(part, int(slot), mCoders[int(slot)])
142 decompress(
cc, rofRecVec, cdigVec,
pattVec);
148template <
typename VROF,
typename VDIG,
typename VPAT>
151 rofRecVec.resize(
cc.header.nROFs);
152 cdigVec.resize(
cc.header.nDigits);
154 std::vector<Digit> digCopy;
157 uint32_t firstEntry = 0, digCount = 0, stripCount = 0, ndiagnostic = 0;
158 for (uint32_t irof = 0; irof <
cc.header.nROFs; irof++) {
160 auto& rofRec = rofRecVec[irof];
161 if (
cc.orbitIncROF[irof]) {
162 prevIR.bc =
cc.bcIncROF[irof];
163 prevIR.orbit +=
cc.orbitIncROF[irof];
165 prevIR.bc +=
cc.bcIncROF[irof];
167 rofRec.setBCData(prevIR);
168 rofRec.setFirstEntry(firstEntry);
169 rofRec.setNEntries(
cc.ndigROF[irof]);
170 rofRec.setFirstEntryDia(ndiagnostic);
171 rofRec.setNEntriesDia(
cc.ndiaROF[irof]);
172 for (
int icrate = 0; icrate < 72; icrate++) {
173 rofRec.setDiagnosticInCrate(icrate,
cc.ndiaCrate[irof * 72 + icrate] - 1);
175 firstEntry +=
cc.ndigROF[irof];
176 ndiagnostic +=
cc.ndiaROF[irof];
178 if (!
cc.ndigROF[irof]) {
186 int firstDig = digCount;
188 int64_t BCrow = prevIR.toLong();
190 digCopy.resize(
cc.ndigROF[irof]);
191 for (uint32_t idig = 0; idig <
cc.ndigROF[irof]; idig++) {
192 auto& digit = digCopy[idig];
193 LOGF(
debug,
"%d) TF=%d, TDC=%d, STRIP=%d, CH=%d", idig,
cc.timeFrameInc[digCount],
cc.timeTDCInc[digCount],
cc.stripID[digCount],
cc.chanInStrip[digCount]);
194 if (
cc.timeFrameInc[digCount]) {
195 ctdc =
cc.timeTDCInc[digCount];
196 ctimeframe +=
cc.timeFrameInc[digCount];
198 ctdc +=
cc.timeTDCInc[digCount];
200 LOGF(
debug,
"BC=%ld, TDC=%d, TOT=%d, CH=%d", uint32_t(ctimeframe) * 64 + ctdc / 1024 + BCrow, ctdc % 1024,
cc.tot[digCount], uint32_t(
cc.stripID[digCount]) * 96 +
cc.chanInStrip[digCount]);
202 digit.setBC(uint32_t(ctimeframe) * 64 + ctdc / 1024 + BCrow);
203 digit.setTDC(ctdc % 1024);
204 digit.setTOT(
cc.tot[digCount]);
205 digit.setChannel(uint32_t(
cc.stripID[digCount]) * 96 +
cc.chanInStrip[digCount]);
211 std::sort(digCopy.begin(), digCopy.end(),
213 int str1 = a.getChannel() / Geo::NPADS;
214 int str2 = b.getChannel() / Geo::NPADS;
216 return (a.getOrderingKey() < b.getOrderingKey());
222 for (uint32_t idig = 0; idig < digCopy.size(); idig++) {
223 cdigVec[firstDig + idig] = digCopy[idig];
229 memcpy(
pattVec.data(),
cc.pattMap.data(),
cc.header.nPatternBytes);
230 assert(digCount ==
cc.header.nDigits);
232 if (digCount !=
cc.header.nDigits) {
233 LOG(error) <<
"expected " <<
cc.header.nDigits <<
" but counted " << digCount <<
" in ROFRecords";
234 throw std::runtime_error(
"mismatch between expected and counter number of digits");
Declarations for CTFCoderBase class (support of external dictionaries)
#define DECODETOF(part, slot)
#define ENCODETOF(part, slot, bits)
void checkDictVersion(const CTFDictHeader &h) const
ctf::ANSHeader mANSVersion
std::string getPrefix() const
virtual void assignDictVersion(CTFDictHeader &h) 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)
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const ReadoutWindowData > &rofRecVec, const gsl::span< const Digit > &cdigVec, const gsl::span< const uint8_t > &pattVec)
entropy-encode clusters to buffer with CTF
void createCoders(const std::vector< char > &bufVec, o2::ctf::CTFCoderBase::OpType op) final
o2::ctf::CTFIOSize decode(const CTF::base &ec, VROF &rofRecVec, VDIG &cdigVec, VPAT &pattVec)
entropy decode clusters from buffer with CTF
TOF digit implementation.
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
return(kp2 - aa - bb) *kp1/aa
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
wrapper for the Entropy-encoded clusters of the TF
Compressed but not yet entropy-encoded infos.
std::vector< o2::mch::ChannelCode > cc
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))
std::vector< unsigned char > pattVec