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;
159 auto itInp = bytesInput.begin();
160 auto itCls = bytesClass.begin();
162 bool checkIROKInputs = (mBCShiftInputs == 0);
165 if (orbitInc[itrig]) {
166 ir.
bc = bcInc[itrig];
169 ir.
bc += bcInc[itrig];
172 auto irs =
ir - mBCShiftInputs;
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;
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.
std::vector< std::string > header
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
char error[CURL_ERROR_SIZE]
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
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
add CTP related shifts
void setDecodeInps(bool decodeinps)
CTFCoder(o2::ctf::CTFCoderBase::OpType op, const std::string &ctfdictOpt="none")
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, fair::mq::pmr::polymorphic_allocator< T > > vector
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
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