24void CTFCoder::appendToTree(TTree&
tree,
CTF& ec)
31void CTFCoder::readFromTree(TTree&
tree,
int entry, std::vector<ReadoutWindowData>& rofRecVec, std::vector<Digit>& cdigVec, std::vector<uint8_t>&
pattVec)
41 const gsl::span<const ReadoutWindowData>& rofRecVec,
42 const gsl::span<const Digit>& cdigVec,
43 const gsl::span<const uint8_t>&
pattVec)
48 if (!rofRecVec.size()) {
51 std::vector<Digit> digCopy;
52 int ndigTot = 0, nrofTot = 0, nrofIni = rofRecVec.size(), ndigIni = cdigVec.size();
54 uint32_t prevOrbit = 0;
55 LOGF(
debug,
"TOF compress %d ReadoutWindow with %ld digits", nrofIni, ndigIni);
57 cc.bcIncROF.reserve(nrofIni);
58 cc.orbitIncROF.reserve(nrofIni);
59 cc.ndigROF.reserve(nrofIni);
60 cc.ndiaROF.reserve(nrofIni);
61 cc.ndiaCrate.reserve(nrofIni * 72);
63 cc.timeFrameInc.reserve(ndigIni);
64 cc.timeTDCInc.reserve(ndigIni);
65 cc.stripID.reserve(ndigIni);
66 cc.chanInStrip.reserve(ndigIni);
67 cc.tot.reserve(ndigIni);
70 for (
int rof0 = 0; rof0 < nrofIni; rof0++) {
71 const auto& rofRec = rofRecVec[rof0];
72 const auto ir = rofRec.getBCData();
78 int ndig = rofRec.size(), idigMin = rofRec.first(), idigMax = idigMin + ndig;
79 for (
int idig = idigMin; idig < idigMax; idig++) {
80 digCopy.push_back(cdigVec[idig]);
83 std::sort(digCopy.begin(), digCopy.end(), [](
o2::tof::Digit a,
o2::tof::Digit b) { return (a.getBC() == b.getBC()) ? (a.getTDC() < b.getTDC()) : a.getBC() < b.getBC(); });
85 int timeframe = 0, tdc = 0, ndigAcc = 0;
86 for (
int idig = idigMin; idig < idigMax; idig++) {
87 const auto& dig = digCopy[idig - idigMin];
92 int deltaBC = dig.getBC() - rofInBC;
93 int ctimeframe = deltaBC / 64;
94 int cTDC = (deltaBC % 64) * 1024 + dig.getTDC();
95 if (ctimeframe == timeframe) {
96 cc.timeFrameInc.push_back(0);
97 cc.timeTDCInc.push_back(cTDC - tdc);
99 cc.timeFrameInc.push_back(ctimeframe - timeframe);
100 cc.timeTDCInc.push_back(cTDC);
101 timeframe = ctimeframe;
105 int chan = dig.getChannel();
108 cc.tot.push_back(dig.getTOT());
109 LOGF(
debug,
"%d) TOFBC = %d, deltaBC = %d, TDC = %d, CH=%d", nrofTot, rofInBC, deltaBC, cTDC, chan);
110 LOGF(
debug,
"%d) TF=%d, TDC=%d, STRIP=%d, CH=%d, TOT=%d", idig,
cc.timeFrameInc[idig],
cc.timeTDCInc[idig],
cc.stripID[idig],
cc.chanInStrip[idig],
cc.tot[idig]);
115 prevOrbit =
cc.header.firstOrbit =
ir.
orbit;
116 prevBC =
cc.header.firstBC =
ir.
bc;
119 cc.orbitIncROF.push_back(0);
120 cc.bcIncROF.push_back(
ir.
bc - prevBC);
122 cc.orbitIncROF.push_back(
ir.
orbit - prevOrbit);
123 cc.bcIncROF.push_back(
ir.
bc);
126 cc.ndigROF.push_back(ndigAcc);
127 cc.ndiaROF.push_back(rofRec.sizeDia());
128 cc.ndiaCrate.reserve(
cc.ndiaCrate.size() + 72);
129 for (
int icrate = 0; icrate < 72; icrate++) {
130 if (rofRec.isEmptyCrate(icrate)) {
131 cc.ndiaCrate.push_back(0);
133 cc.ndiaCrate.push_back(rofRec.getDiagnosticInCrate(icrate) + 1);
141 cc.header.nROFs = nrofTot;
142 cc.header.nDigits = ndigTot;
143 cc.header.nPatternBytes =
pattVec.size();
144 cc.pattMap.resize(
cc.header.nPatternBytes);
145 memcpy(
cc.pattMap.data(),
pattVec.data(),
cc.header.nPatternBytes);
154#define MAKECODER(part, slot) createCoder(op, std::get<rans::RenormedDenseHistogram<decltype(part)::value_type>>(ctf.getDictionary<decltype(part)::value_type>(slot, mANSVersion)), int(slot))
189 LOG(
debug) <<
"Estimated output size is " << sz <<
" bytes";
#define MAKECODER(part, slot)
class for entropy encoding/decoding of TOF compressed infos data
size_t estimateBufferSize(size_t slot, source_IT samplesBegin, source_IT samplesEnd)
o2::utils::IRFrameSelector mIRFrameSelector
void readFromTree(TTree &tree, const std::string &name, int ev=0)
read from tree to non-flat object
static auto getImage(const void *newHead)
get const image of the container wrapper, with pointers in the image relocated to new head
size_t appendToTree(TTree &tree, const std::string &name) const
attach to tree
static constexpr const char * getName(ID id)
names of defined detectors
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.
static constexpr Int_t NPADS
long check(o2::dataformats::IRFrame fr, size_t bwd=0, size_t fwd=0)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
uint16_t bc
bunch crossing ID of interaction
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"
o2::InteractionRecord ir(0, 0)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))
std::vector< unsigned char > pattVec