16#ifndef O2_CTP_CTFCODER_H
17#define O2_CTP_CTFCODER_H
44 template <typename VEC>
48 template <typename VTRG>
52 template <typename
CTF>
63 template <
typename VEC>
66 void appendToTree(TTree&
tree,
CTF& ec);
68 std::vector<CTPDigit> mDataFilt;
70 int mBCShiftInputs = 0;
71 bool mDecodeInps =
false;
75template <
typename VEC>
80 for (
const auto& trig :
data) {
82 mDataFilt.push_back(trig);
85 return encode_impl(buff, mDataFilt,
lumi);
87 return encode_impl(buff,
data,
lumi);
90template <
typename VEC>
102 CTFHelper helper(
data);
105 auto szIni =
sizeof(CTFHeader) + helper.getSize() * 2. / 3;
111 ec->setHeader(helper.createHeader(
lumi));
116#define ENCODECTP(beg, end, slot, bits) CTF::get(buff.data())->encode(beg, end, int(slot), bits, optField[int(slot)], &buff, mCoders[int(slot)], getMemMarginFactor());
124 finaliseCTFOutput<CTF>(buff);
125 iosize.
rawIn =
data.size() *
sizeof(CTPDigit);
130template <
typename VTRG>
136 std::vector<int16_t> bcInc;
137 std::vector<int32_t> orbitInc;
138 std::vector<uint8_t> bytesInput, bytesClass;
141#define DECODECTP(part, slot) ec.decode(part, int(slot), mCoders[int(slot)])
150 std::map<o2::InteractionRecord, CTPDigit> digitsMap;
152 lumi.nHBFCounted = header.lumiNHBFs;
153 lumi.nHBFCountedFV0 = header.lumiNHBFsFV0 ? header.lumiNHBFsFV0 : header.lumiNHBFs;
154 lumi.counts = header.lumiCounts;
155 lumi.countsFV0 = header.lumiCountsFV0;
156 lumi.orbit = header.lumiOrbit;
159 auto itInp = bytesInput.begin();
160 auto itCls = bytesClass.begin();
162 bool checkIROKInputs = (mBCShiftInputs == 0);
163 for (uint32_t itrig = 0; itrig < header.nTriggers; itrig++) {
165 if (orbitInc[itrig]) {
166 ir.
bc = bcInc[itrig];
169 ir.
bc += bcInc[itrig];
172 auto irs =
ir - mBCShiftInputs;
173 uint64_t CTPInputMask = 0;
175 CTPInputMask |=
static_cast<uint64_t
>(*itInp++) << (8 *
i);
178 if (digitsMap.count(irs)) {
179 if (digitsMap[irs].isInputEmpty()) {
180 digitsMap[irs].CTPInputMask = CTPInputMask;
184 LOG(error) <<
"CTPInpurMask already exist:" << irs <<
" dig.CTPInputMask:" << digitsMap[irs].CTPInputMask <<
" CTPInputMask:" << CTPInputMask;
187 CTPDigit dig = {irs, CTPInputMask, 0};
188 digitsMap[irs] = dig;
198 uint64_t CTPClassMask = 0;
200 CTPClassMask |=
static_cast<uint64_t
>(*itCls++) << (8 *
i);
203 if (digitsMap.count(irs)) {
204 if (digitsMap[irs].isClassEmpty()) {
205 digitsMap[irs].CTPClassMask = CTPClassMask;
209 LOG(error) <<
"CTPClassMask already exist:" << irs <<
" dig.CTPClassMask:" << digitsMap[irs].CTPClassMask <<
" CTPClassMask:" << CTPClassMask;
212 CTPDigit dig = {irs, 0, CTPClassMask};
213 digitsMap[irs] = dig;
223 uint64_t trgclassmask = 0xffffffffffffffff;
230 for (
auto const& dig :
digits) {
231 data.emplace_back(dig);
234 for (
auto const& dig : digitsMap) {
235 data.emplace_back(dig.second);
238 assert(itInp == bytesInput.end());
239 assert(itCls == bytesClass.end());
244template <
typename CTF = o2::ctp::CTF>
247 auto match = o2::ctf::CTFCoderBase::finaliseCCDB<CTF>(matcher, obj);
249 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, o2::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)
std::vector< T, o2::pmr::polymorphic_allocator< T > > vector
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