16#ifndef O2_TRD_CTFCODER_H
17#define O2_TRD_CTFCODER_H
43 template <typename VEC>
47 template <typename VTRG, typename VTRK, typename VDIG>
48 o2::ctf::CTFIOSize
decode(const
CTF::base& ec, VTRG& trigVec, VTRK& trkVec, VDIG& digVec);
55 template <
typename VEC>
56 o2::ctf::CTFIOSize encode_impl(VEC& buff,
const gsl::span<const TriggerRecord>& trigData,
const gsl::span<const Tracklet64>& trkData,
const gsl::span<const Digit>& digData);
58 void appendToTree(TTree&
tree,
CTF& ec);
59 void readFromTree(TTree&
tree,
int entry, std::vector<TriggerRecord>& trigVec, std::vector<Tracklet64>& trkVec, std::vector<Digit>& digVec);
60 int mCheckBogusTrig = 1;
62 std::vector<TriggerRecord> mTrgRecFilt;
63 std::vector<Tracklet64> mTrkDataFilt;
64 std::vector<Digit> mDigDataFilt;
68template <
typename VEC>
71 static size_t bogusWarnMsg = 0;
72 if (mCheckBogusTrig && bogusWarnMsg < mCheckBogusTrig) {
76 for (
const auto& trig : trigData) {
77 LOGP(
debug,
"Trig#{} Old: {}/{} New: {}/{}", cnt++, bcPrev, orbitPrev, trig.getBCData().bc, trig.getBCData().orbit);
78 auto orbitPrevT = orbitPrev;
79 auto bcPrevT = bcPrev;
80 bcPrev = trig.getBCData().bc;
81 orbitPrev = trig.getBCData().orbit;
82 if (trig.getBCData().orbit < orbitPrevT || trig.getBCData().bc >= o2::constants::lhc::LHCMaxBunches || (trig.getBCData().orbit == orbitPrevT && trig.getBCData().bc < bcPrevT)) {
83 LOGP(warning,
"Bogus TRD trigger at bc:{}/orbit:{} (previous was {}/{}), with {} tracklets and {} digits",
84 trig.getBCData().bc, trig.getBCData().orbit, bcPrevT, orbitPrevT, trig.getNumberOfTracklets(), trig.getNumberOfDigits());
85 if (++bogusWarnMsg >= mCheckBogusTrig) {
86 LOGP(warning,
"Max amount of warnings ({}) was issued, will not warn anymore",
size_t(mCheckBogusTrig));
97 for (
const auto& trig : trigData) {
99 mTrgRecFilt.push_back(trig);
100 auto trkIt = trkData.begin() + trig.getFirstTracklet();
101 auto digIt = digData.begin() + trig.getFirstDigit();
102 auto& trigC = mTrgRecFilt.back();
103 trigC.setFirstTracklet((
int)mTrkDataFilt.size());
104 trigC.setFirstDigit((
int)mDigDataFilt.size());
105 std::copy(trkIt, trkIt + trig.getNumberOfTracklets(), std::back_inserter(mTrkDataFilt));
106 std::copy(digIt, digIt + trig.getNumberOfDigits(), std::back_inserter(mDigDataFilt));
109 return encode_impl(buff, mTrgRecFilt, mTrkDataFilt, mDigDataFilt);
111 return encode_impl(buff, trigData, trkData, digData);
114template <
typename VEC>
115o2::ctf::CTFIOSize CTFCoder::encode_impl(VEC& buff,
const gsl::span<const TriggerRecord>& trigData,
const gsl::span<const Tracklet64>& trkData,
const gsl::span<const Digit>& digData)
137 CTFHelper helper(trigData, trkData, digData);
139 auto szIni =
sizeof(CTFHeader) + helper.getSize() * 2. / 3;
145 ec->setHeader(helper.createHeader());
150#define ENCODETRD(beg, end, slot, bits) CTF::get(buff.data())->encode(beg, end, int(slot), bits, optField[int(slot)], &buff, mCoders[int(slot)], getMemMarginFactor());
172 finaliseCTFOutput<CTF>(buff);
173 iosize.
rawIn = trigData.size() *
sizeof(TriggerRecord) +
sizeof(Tracklet64) * trkData.size() +
sizeof(Digit) * digData.size();
178template <
typename VTRG,
typename VTRK,
typename VDIG>
184 std::vector<uint16_t> HCIDTrk, posTrk, CIDDig, ADCDig;
185 std::vector<int16_t> bcInc;
186 std::vector<uint32_t> entriesTrk, entriesDig, pidTrk;
187 std::vector<int32_t> orbitInc;
188 std::vector<uint8_t> padrowTrk, colTrk, slopeTrk, ROBDig, MCMDig, chanDig;
191#define DECODETRD(part, slot) ec.decode(part, int(slot), mCoders[int(slot)])
215 trigVec.reserve(
header.nTriggers);
216 trkVec.reserve(
header.nTracklets);
217 digVec.reserve(
header.nDigits);
218 uint32_t trkCount = 0, digCount = 0, adcCount = 0;
222 static size_t countDiscardMsg = 0;
226 if (orbitInc[itrig]) {
228 orbit += orbitInc[itrig];
232 bool triggerOK =
true;
233 if (mCheckBogusTrig && (
bc >= o2::constants::lhc::LHCMaxBunches || orbitInc[itrig] < 0 || bcInc[itrig] < 0 ||
orbit < orbitPrevGood || (entriesTrk[itrig] == 0 && entriesDig[itrig] == 0))) {
234 if (countDiscardMsg <
size_t(mCheckBogusTrig) || mCheckBogusTrig < 0) {
235 LOGP(warning,
"Bogus TRD trigger at bc:{}/orbit:{} (increments: {}/{}, 1st TF orbit: {}) with {} tracklets and {} digits{}: {}",
237 orbitInc[itrig] < 0 ?
" (decreasing orbit!) " :
"",
238 mCheckBogusTrig > 0 ?
"discarding" :
"discarding disabled");
239 if (++countDiscardMsg ==
size_t(mCheckBogusTrig) && mCheckBogusTrig > 0) {
240 LOGP(warning,
"Max amount of warnings ({}) was issued, will not warn anymore",
size_t(mCheckBogusTrig));
243 if (mCheckBogusTrig > 0) {
251 orbitPrevGood =
orbit;
252 uint32_t firstEntryTrk = trkVec.size();
254 for (
uint32_t it = 0; it < entriesTrk[itrig]; it++) {
255 hcid += HCIDTrk[trkCount];
256 trkVec.emplace_back(
header.format, hcid, padrowTrk[trkCount], colTrk[trkCount], posTrk[trkCount], slopeTrk[trkCount], pidTrk[trkCount]);
259 uint32_t firstEntryDig = digVec.size();
261 for (
uint32_t id = 0;
id < entriesDig[itrig];
id++) {
262 cid += CIDDig[digCount];
263 auto& dig = digVec.emplace_back(cid & 0xfff, ROBDig[digCount], MCMDig[digCount], chanDig[digCount], (cid >> 12) & 0x3);
264 dig.setADC({&ADCDig[adcCount], constants::TIMEBINS});
266 adcCount += constants::TIMEBINS;
268 if (
mBCShift &&
bc < o2::constants::lhc::LHCMaxBunches) {
272 LOGP(
debug,
"Storing TRD trigger at {} (increments: {}/{}) with {} tracklets and {} digits",
ir.
asString(), bcInc[itrig], orbitInc[itrig], entriesTrk[itrig], entriesDig[itrig]);
273 trigVec.emplace_back(
ir, firstEntryDig, entriesDig[itrig], firstEntryTrk, entriesTrk[itrig]);
275 trkCount += entriesTrk[itrig];
276 digCount += entriesDig[itrig];
277 adcCount += constants::TIMEBINS * entriesDig[itrig];
281 assert(digCount ==
header.nDigits && trkCount ==
header.nTracklets && adcCount == (
int)ADCDig.size());
Declarations for CTFCoderBase class (support of external dictionaries)
unsigned short int uint16_t
std::vector< std::string > header
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h trd
Header to collect LHC related constants.
#define DECODETRD(part, slot)
#define ENCODETRD(beg, end, slot, bits)
Helper for TRD CTF creation.
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 ...
Static class with identifiers, bitmasks and names for ALICE detectors.
void setCheckBogusTrig(int v)
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const TriggerRecord > &trigData, const gsl::span< const Tracklet64 > &trkData, const gsl::span< const Digit > &digData)
entropy-encode data to buffer with CTF
void createCoders(const std::vector< char > &bufVec, o2::ctf::CTFCoderBase::OpType op) final
CTFCoder(o2::ctf::CTFCoderBase::OpType op, const std::string &ctfdictOpt="none")
~CTFCoder() final=default
o2::ctf::CTFIOSize decode(const CTF::base &ec, VTRG &trigVec, VTRK &trkVec, VDIG &digVec)
entropy decode data from buffer with CTF
Header for data corresponding to the same hardware trigger adapted from DataFormatsITSMFT/ROFRecord.
long check(o2::dataformats::IRFrame fr, size_t bwd=0, size_t fwd=0)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string asString() const
wrapper for the Entropy-encoded triggers and cells of the TF
o2::InteractionRecord ir(0, 0)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))