16#ifndef O2_CTP_CTFCODER_H
17#define O2_CTP_CTFCODER_H
45 template <typename VEC>
49 template <typename VTRG>
53 template <typename
CTF>
64 template <
typename VEC>
67 void appendToTree(TTree&
tree,
CTF& ec);
69 std::vector<CTPDigit> mDataFilt;
71 int mBCShiftInputs = 0;
72 bool mDecodeInps =
false;
76template <
typename VEC>
81 for (
const auto& trig :
data) {
83 mDataFilt.push_back(trig);
86 return encode_impl(buff, mDataFilt,
lumi);
88 return encode_impl(buff,
data,
lumi);
91template <
typename VEC>
103 CTFHelper helper(
data);
106 auto szIni =
sizeof(CTFHeader) + helper.getSize() * 2. / 3;
112 ec->setHeader(helper.createHeader(
lumi));
117#define ENCODECTP(beg, end, slot, bits) CTF::get(buff.data())->encode(beg, end, int(slot), bits, optField[int(slot)], &buff, mCoders[int(slot)], getMemMarginFactor());
125 finaliseCTFOutput<CTF>(buff);
126 iosize.
rawIn =
data.size() *
sizeof(CTPDigit);
131template <
typename VTRG>
137 std::vector<int16_t> bcInc;
138 std::vector<int32_t> orbitInc;
139 std::vector<uint8_t> bytesInput, bytesClass;
142#define DECODECTP(part, slot) ec.decode(part, int(slot), mCoders[int(slot)])
151 std::map<o2::InteractionRecord, CTPDigit> digitsMap;
153 lumi.nHBFCounted = header.lumiNHBFs;
154 lumi.nHBFCountedFV0 = header.lumiNHBFsFV0 ? header.lumiNHBFsFV0 : header.lumiNHBFs;
155 lumi.counts = header.lumiCounts;
156 lumi.countsFV0 = header.lumiCountsFV0;
157 lumi.orbit = header.lumiOrbit;
160 auto itInp = bytesInput.begin();
161 auto itCls = bytesClass.begin();
163 bool checkIROKInputs = (mBCShiftInputs == 0);
164 for (uint32_t itrig = 0; itrig < header.nTriggers; itrig++) {
166 if (orbitInc[itrig]) {
167 ir.
bc = bcInc[itrig];
170 ir.
bc += bcInc[itrig];
173 auto irs =
ir - mBCShiftInputs;
174 uint64_t CTPInputMask = 0;
176 CTPInputMask |=
static_cast<uint64_t
>(*itInp++) << (8 *
i);
179 if (digitsMap.count(irs)) {
180 if (digitsMap[irs].isInputEmpty()) {
181 digitsMap[irs].CTPInputMask = CTPInputMask;
185 LOG(error) <<
"CTPInpurMask already exist:" << irs <<
" dig.CTPInputMask:" << digitsMap[irs].CTPInputMask <<
" CTPInputMask:" << CTPInputMask;
188 CTPDigit dig = {irs, CTPInputMask, 0};
189 digitsMap[irs] = dig;
199 uint64_t CTPClassMask = 0;
201 CTPClassMask |=
static_cast<uint64_t
>(*itCls++) << (8 *
i);
204 if (digitsMap.count(irs)) {
205 if (digitsMap[irs].isClassEmpty()) {
206 digitsMap[irs].CTPClassMask = CTPClassMask;
210 LOG(error) <<
"CTPClassMask already exist:" << irs <<
" dig.CTPClassMask:" << digitsMap[irs].CTPClassMask <<
" CTPClassMask:" << CTPClassMask;
213 CTPDigit dig = {irs, 0, CTPClassMask};
214 digitsMap[irs] = dig;
224 uint64_t trgclassmask = 0xffffffffffffffff;
229 std::pmr::vector<CTPDigit>
digits;
231 for (
auto const& dig :
digits) {
232 data.emplace_back(dig);
235 for (
auto const& dig : digitsMap) {
236 data.emplace_back(dig.second);
239 assert(itInp == bytesInput.end());
240 assert(itCls == bytesClass.end());
245template <
typename CTF = o2::ctp::CTF>
248 auto match = o2::ctf::CTFCoderBase::finaliseCCDB<CTF>(matcher, obj);
250 LOG(info) <<
"BCShiftInputs:" << mBCShiftInputs;
Declarations for CTFCoderBase class (support of external dictionaries)
#define ENCODECTP(beg, end, slot, bits)
#define DECODECTP(part, slot)
Helper for CTP CTF creation.
Digits tw Raw translation.
static const TriggerOffsetsParam & Instance()
void checkDictVersion(const CTFDictHeader &h) const
ctf::ANSHeader mANSVersion
std::string getPrefix() const
o2::utils::IRFrameSelector mIRFrameSelector
virtual void assignDictVersion(CTFDictHeader &h) const
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 ...
CTPConfiguration & getCTPConfig()
~CTFCoder() final=default
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const CTPDigit > &data, const LumiInfo &lumi)
entropy-encode data to buffer with CTF
void setCTPConfig(CTPConfiguration cfg)
void createCoders(const std::vector< char > &bufVec, o2::ctf::CTFCoderBase::OpType op) final
bool canApplyBCShiftInputs(const o2::InteractionRecord &ir) const
CTFCoder(o2::ctf::CTFCoderBase::OpType op)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
add CTP related shifts
void setDecodeInps(bool decodeinps)
o2::ctf::CTFIOSize decode(const CTF::base &ec, VTRG &data, LumiInfo &lumi)
entropy decode data from buffer with CTF
static constexpr int CTPClsNBytes
static constexpr int CTPInpNBytes
uint64_t getTriggerClassMask() const
static int shiftInputs(std::map< o2::InteractionRecord, CTPDigit > &digitsMap, std::pmr::vector< CTPDigit > &digits, uint32_t TFOrbit, uint64_t trgclassmask=0xffffffffffffffff)
Static class with identifiers, bitmasks and names for ALICE detectors.
long check(o2::dataformats::IRFrame fr, size_t bwd=0, size_t fwd=0)
bool match(const std::vector< std::string > &queries, const char *pattern)
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 trigger inputs and classes of the TF
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< Digit > digits