16#ifndef O2_FDD_CTFCODER_H
17#define O2_FDD_CTFCODER_H
43 template <typename VEC>
47 template <typename VDIG, typename VCHAN>
48 o2::ctf::CTFIOSize
decode(const
CTF::base& ec, VDIG& digitVec, VCHAN& channelVec);
54 template <
int MAJOR_VERSION,
int MINOR_VERSION>
59 template <
int MAJOR_VERSION,
int MINOR_VERSION, typename VDIG, typename VCHAN>
60 void decompress(const
CompressedDigits& cd, VDIG& digitVec, VCHAN& channelVec);
62 void appendToTree(TTree&
tree,
CTF& ec);
64 void assignDictVersion(
o2::ctf::CTFDictHeader&
h) const final;
68template <typename VEC>
87 compress<1, 0>(cd, digitVec, channelVec);
89 compress<1, 1>(cd, digitVec, channelVec);
92 compress<1, 1>(cd, digitVec, channelVec);
95 auto szIni = estimateCompressedSize(cd);
101 ec->setHeader(cd.header);
107#define ENCODEFDD(part, slot, bits) CTF::get(buff.data())->encode(part, int(slot), bits, optField[int(slot)], &buff, mCoders[int(slot)], getMemMarginFactor());
120 finaliseCTFOutput<CTF>(buff);
126template <
typename VDIG,
typename VCHAN>
135#define DECODEFDD(part, slot) ec.decode(part, int(slot), mCoders[int(slot)])
148 if (hd.minorVersion == 0 && hd.majorVersion == 1) {
149 decompress<1, 0>(cd, digitVec, channelVec);
151 decompress<1, 1>(cd, digitVec, channelVec);
158template <
int MAJOR_VERSION,
int MINOR_VERSION,
typename VDIG,
typename VCHAN>
159void CTFCoder::decompress(
const CompressedDigits& cd, VDIG& digitVec, VCHAN& channelVec)
164 channelVec.reserve(cd.
idChan.size());
166 uint32_t firstEntry = 0, clCount = 0, chipCount = 0;
177 firstEntry = channelVec.size();
182 for (uint8_t ic = 0; ic < cd.
nChan[idig]; ic++) {
183 auto icc = channelVec.size();
184 if constexpr (MINOR_VERSION == 0 && MAJOR_VERSION == 1) {
191 const auto& chan = channelVec.emplace_back(chID, cd.
time[icc], cd.
charge[icc], cd.
feeBits[icc]);
193 if (chan.mPMNumber > 7) {
194 amplA += chan.mChargeADC;
199 amplC += chan.mChargeADC;
220 digitVec.emplace_back(firstEntry, cd.
nChan[idig],
ir, trig);
225template <
int MAJOR_VERSION,
int MINOR_VERSION>
226void CTFCoder::compress(CompressedDigits& cd,
const gsl::span<const Digit>& digitVec,
const gsl::span<const ChannelData>& channelVec)
230 cd.header.det =
mDet;
231 if (!digitVec.size()) {
234 uint32_t firstDig = digitVec.size(), nDigSel = digitVec.size(), nChanSel = channelVec.size();
235 std::vector<bool> reject(digitVec.size());
237 for (
size_t id = 0;
id < digitVec.size();
id++) {
241 nChanSel -= digitVec[
id].ref.getEntries();
242 }
else if (firstDig == digitVec.size()) {
252 const auto& dig0 = digitVec[firstDig];
253 cd.header.nTriggers = nDigSel;
254 cd.header.firstOrbit = dig0.mIntRecord.orbit;
255 cd.header.firstBC = dig0.mIntRecord.bc;
257 cd.trigger.resize(cd.header.nTriggers);
258 cd.bcInc.resize(cd.header.nTriggers);
259 cd.orbitInc.resize(cd.header.nTriggers);
260 cd.nChan.resize(cd.header.nTriggers);
262 cd.idChan.resize(nChanSel);
263 cd.time.resize(nChanSel);
264 cd.charge.resize(nChanSel);
265 cd.feeBits.resize(nChanSel);
267 uint16_t prevBC = cd.header.firstBC;
268 uint32_t prevOrbit = cd.header.firstOrbit;
269 uint32_t ccount = 0, dcount = 0;
270 for (uint32_t idig = 0; idig < digitVec.size(); idig++) {
274 const auto& digit = digitVec[idig];
275 const auto chanels = digit.getBunchChannelData(channelVec);
278 cd.trigger[dcount] = digit.mTriggers.getTriggersignals();
279 if (prevOrbit == digit.mIntRecord.orbit) {
280 cd.bcInc[dcount] = digit.mIntRecord.bc - prevBC;
281 cd.orbitInc[dcount] = 0;
283 cd.bcInc[dcount] = digit.mIntRecord.bc;
284 cd.orbitInc[dcount] = digit.mIntRecord.orbit - prevOrbit;
286 prevBC = digit.mIntRecord.bc;
287 prevOrbit = digit.mIntRecord.orbit;
289 cd.nChan[dcount] = chanels.size();
290 if (!cd.nChan[dcount]) {
291 LOG(
debug) <<
"Digits with no channels";
296 for (uint8_t ic = 0; ic < cd.nChan[dcount]; ic++) {
297 if constexpr (MINOR_VERSION == 0 && MAJOR_VERSION == 1) {
298 cd.idChan[ccount] = chanels[ic].mPMNumber - prevChan;
300 cd.idChan[ccount] = chanels[ic].mPMNumber;
302 cd.time[ccount] = chanels[ic].mTime;
303 cd.charge[ccount] = chanels[ic].mChargeADC;
304 cd.feeBits[ccount] = chanels[ic].mFEEBits;
305 prevChan = chanels[ic].mPMNumber;
Declarations for CTFCoderBase class (support of external dictionaries)
Base definition of FIT-FDD geometry.
#define DECODEFDD(part, slot)
#define ENCODEFDD(part, slot, bits)
Class for time synchronization of RawReader instances.
void checkDictVersion(const CTFDictHeader &h) const
ctf::ANSHeader mANSVersion
std::string getPrefix() const
o2::utils::IRFrameSelector mIRFrameSelector
<<======================== 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(o2::ctf::CTFCoderBase::OpType op)
o2::ctf::CTFIOSize decode(const CTF::base &ec, VDIG &digitVec, VCHAN &channelVec)
entropy decode clusters from buffer with CTF
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const Digit > &digitVec, const gsl::span< const ChannelData > &channelVec)
entropy-encode digits to buffer with CTF
void createCoders(const std::vector< char > &bufVec, o2::ctf::CTFCoderBase::OpType op) final
~CTFCoder() final=default
static const int16_t DEFAULT_AMP
static const int16_t DEFAULT_TIME
void setTriggers(uint8_t trgsig, uint8_t chanA, uint8_t chanC, int32_t aamplA, int32_t aamplC, int16_t atimeA, int16_t atimeC)
long check(o2::dataformats::IRFrame fr, size_t bwd=0, size_t fwd=0)
uint8_t itsSharedClusterMap uint8_t
o2::fit::Triggers Triggers
struct o2::upgrades_utils::@459 fdd
Collision labels.
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 clusters of the TF
Intermediate, compressed but not yet entropy-encoded digits.
std::vector< int32_t > orbitInc
std::vector< uint8_t > feeBits
std::vector< int16_t > time
std::vector< uint8_t > trigger
std::vector< int16_t > charge
std::vector< int16_t > bcInc
std::vector< uint8_t > idChan
std::vector< uint8_t > nChan
std::vector< o2::mch::ChannelCode > cc
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
o2::InteractionRecord ir(0, 0)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))