24void CTFCoder::appendToTree(TTree&
tree,
CTF& ec)
31void CTFCoder::readFromTree(TTree&
tree,
int entry, std::vector<ROFRecord>& rofRecVec,
42 const gsl::span<const ROFRecord>& rofRecVec,
43 const gsl::span<const CompClusterExt>&
cclusVec,
44 const gsl::span<const unsigned char>&
pattVec,
50 if (!rofRecVec.size()) {
53 uint32_t firstROF = rofRecVec.size(), nrofSel = rofRecVec.size(), nClusSel =
cclusVec.size();
54 std::vector<bool> reject(rofRecVec.size());
56 for (
size_t ir = 0;
ir < rofRecVec.size();
ir++) {
57 auto irStart = rofRecVec[
ir].getBCData();
61 nClusSel -= rofRecVec[
ir].getNEntries();
62 }
else if (firstROF == rofRecVec.size()) {
74 const auto& rofRec0 = rofRecVec[firstROF];
75 cc.header.firstOrbit = rofRec0.getBCData().orbit;
76 cc.header.firstBC = rofRec0.getBCData().bc;
77 cc.header.nROFs = nrofSel;
78 cc.header.nClusters = nClusSel;
80 cc.firstChipROF.resize(nrofSel);
81 cc.bcIncROF.resize(nrofSel);
82 cc.orbitIncROF.resize(nrofSel);
83 cc.nclusROF.resize(nrofSel);
85 cc.row.resize(nClusSel);
86 cc.colInc.resize(nClusSel);
88 cc.chipInc.reserve(1000);
89 cc.chipMul.reserve(1000);
90 cc.pattID.resize(nClusSel);
92 bool selectPatterns = nrofSel < rofRecVec.size();
93 if (!selectPatterns) {
101 uint16_t prevBC =
cc.header.firstBC;
102 uint32_t prevOrbit =
cc.header.firstOrbit;
103 int irofOut = 0, iclOut = 0;
105 for (uint32_t irof = 0; irof < rofRecVec.size(); irof++) {
106 const auto& rofRec = rofRecVec[irof];
107 const auto& intRec = rofRec.getBCData();
110 if (selectPatterns && pattIt != pattIt0) {
111 cc.pattMap.insert(
cc.pattMap.end(), pattIt0, pattIt);
114 for (
int icl = rofRec.getFirstEntry(); icl < rofRec.getFirstEntry() + rofRec.getNEntries(); icl++) {
123 if (intRec.orbit == prevOrbit) {
124 cc.orbitIncROF[irofOut] = 0;
125#ifdef _CHECK_INCREMENTES_
126 if (intRec.bc < prevBC) {
127 LOG(warning) <<
"Negative BC increment " << intRec.bc <<
" -> " << prevBC;
130 cc.bcIncROF[irofOut] = int16_t(intRec.bc - prevBC);
132 cc.orbitIncROF[irofOut] = int32_t(intRec.orbit - prevOrbit);
133#ifdef _CHECK_INCREMENTES_
134 if (intRec.orbit < prevOrbit) {
135 LOG(warning) <<
"Negative Orbit increment " << intRec.orbit <<
" -> " << prevOrbit;
138 cc.bcIncROF[irofOut] = intRec.bc;
139 prevOrbit = intRec.orbit;
142 auto ncl = rofRec.getNEntries();
143 cc.nclusROF[irofOut] = ncl;
145 cc.firstChipROF[irofOut] = 0;
149 cc.firstChipROF[irofOut] =
cclusVec[rofRec.getFirstEntry()].getChipID();
150 int icl = rofRec.getFirstEntry(), iclMax = icl + ncl;
152 uint16_t prevChip =
cc.firstChipROF[irofOut], prevCol = 0;
154 cc.chipMul.push_back(0);
155 cc.chipInc.push_back(0);
157 for (; icl < iclMax; icl++) {
159 cc.row[iclOut] = cl.getRow();
160 cc.pattID[iclOut] = cl.getPatternID();
164 if (cl.getChipID() == prevChip) {
167 cc.colInc[iclOut] = int16_t(cl.getCol()) - prevCol;
168 prevCol = cl.getCol();
171 cc.chipInc.push_back(int16_t(cl.getChipID() - prevChip));
172#ifdef _CHECK_INCREMENTES_
173 if (cl.getChipID() < prevChip) {
174 LOG(warning) <<
"Negative Chip increment " << cl.getChipID() <<
" -> " << prevChip;
177 cc.chipMul.push_back(1);
178 prevCol =
cc.colInc[iclOut] = cl.getCol();
179 prevChip = cl.getChipID();
185 if (selectPatterns && pattIt != pattIt0) {
186 cc.pattMap.insert(
cc.pattMap.end(), pattIt0, pattIt);
189 cc.header.nPatternBytes =
cc.pattMap.size();
190 cc.header.nChips =
cc.chipMul.size();
198#define MAKECODER(part, slot) createCoder(op, std::get<rans::RenormedDenseHistogram<decltype(part)::value_type>>(ctf.getDictionary<decltype(part)::value_type>(slot, mANSVersion)), int(slot))
232 LOG(
debug) <<
"Estimated output size is " << sz <<
" bytes";
243#define DECODEITSMFT(part, slot) ec.decode(part, int(slot), mCoders[int(slot)])
#define MAKECODER(part, slot)
class for entropy encoding/decoding of ITS/MFT compressed clusters data
#define DECODEITSMFT(part, slot)
void checkDictVersion(const CTFDictHeader &h) const
std::string getPrefix() const
size_t estimateBufferSize(size_t slot, source_IT samplesBegin, source_IT samplesEnd)
o2::utils::IRFrameSelector mIRFrameSelector
<<======================== Auxiliary classes =======================<<
void readFromTree(TTree &tree, const std::string &name, int ev=0)
read from tree to non-flat object
const H & getHeader() const
void print(const std::string &prefix="", int verbosity=1) const
print itself
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, VCLUS &cclusVec, VPAT &pattVec, const NoiseMap *noiseMap, const LookUp &clPattLookup)
entropy decode clusters from buffer with CTF
static void skipPattern(iterator &pattIt)
static constexpr unsigned short InvalidPatternID
bool isGroup(int id) const
NoiseMap class for the ITS and MFT.
long check(o2::dataformats::IRFrame fr, size_t bwd=0, size_t fwd=0)
wrapper for the Entropy-encoded clusters of the TF
Compressed but not yet entropy-encoded clusters.
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
std::vector< CompClusterExt > cclusVec