91 LOG(fatal) <<
"configKeyValue tpcTriggeredMode does not match GRP isDetContinuousReadOut(TPC) setting";
96 mParam->UpdateSettings(&mConfig->configGRP);
98 mTPCVDriftHelper->extractCCDBInputs(pc);
99 if (mTPCVDriftHelper->isUpdated()) {
111 if (tmp ==
nullptr) {
112 LOG(error) <<
"invalid input";
118 if (tmp ==
nullptr) {
119 LOG(error) <<
"invalid input";
124 auto triggers = pc.
inputs().
get<gsl::span<o2::tpc::TriggerInfoDLBZS>>(
"trigger");
125 auto cput = mTimer.CpuTime();
128 std::vector<bool> rejectHits, rejectTracks, rejectTrackHits, rejectTrackHitsReduced;
130 std::vector<std::pair<std::vector<unsigned int>, std::vector<unsigned short>>> tmpBuffer(std::max<int>(mNThreads, 1));
134 for (
const auto& trig : triggers) {
136 if (trig.triggerWord.isValid(it)) {
138 trigComp.
deltaBC.push_back(trig.triggerWord.getTriggerBC(it));
139 trigComp.
triggerType.push_back(trig.triggerWord.getTriggerType(it));
148 throw std::runtime_error(
"Configured solenoid Bz does not match value used for track model encoding");
151 throw std::runtime_error(
"Configured max time bin does not match value used for track model encoding");
154 rejectHits.resize(
clusters.nUnattachedClusters);
155 rejectTracks.resize(
clusters.nTracks);
156 rejectTrackHits.resize(
clusters.nAttachedClusters);
157 rejectTrackHitsReduced.resize(
clusters.nAttachedClustersReduced);
161 const float totalT = std::max(mFastTransform->getMaxDriftTime(0), mFastTransform->getMaxDriftTime(
GPUCA_NSECTORS / 2));
163 unsigned int offset = 0, lasti = 0;
166#pragma omp parallel for firstprivate(offset, lasti) num_threads(mNThreads)
168 for (
unsigned int i = 0;
i <
clusters.nTracks;
i++) {
169 unsigned int tMinP = maxTime, tMaxP = 0;
171 if (cl.getTimePacked() > tMaxP) {
172 tMaxP = cl.getTimePacked();
174 if (cl.getTimePacked() < tMinP) {
175 tMinP = cl.getTimePacked();
185 o2::gpu::TPCClusterDecompressionCore::decompressTrack(
clusters, *mParam, maxTime,
i,
offset, checker);
186 const float tMin = o2::tpc::ClusterNative::unpackTime(tMinP), tMax = o2::tpc::ClusterNative::unpackTime(tMaxP);
192 rejectTrackHits[k] =
true;
195 rejectTrackHitsReduced[k] =
true;
197 rejectTracks[
i] =
true;
198 static std::atomic_flag lock = ATOMIC_FLAG_INIT;
199 while (lock.test_and_set(std::memory_order_acquire)) {
204 lock.clear(std::memory_order_release);
220#pragma omp parallel for num_threads(mNThreads) schedule(static, (GPUCA_NSECTORS + mNThreads - 1) / mNThreads)
222 for (
unsigned int ii = 0; ii <
clusters.nSliceRows; ii++) {
227 int myThread = omp_get_thread_num();
231 unsigned int count = 0;
232 const float x = GPUTPCGeometry::Row2X(
j);
233 auto checker = [
i,
j, firstIR, totalT,
x,
this, &preCl, &
count, &outBuffer = tmpBuffer[myThread], &rejectHits, &clustersFiltered](
const o2::tpc::ClusterNative& cl,
unsigned int k) {
234 const float y = GPUTPCGeometry::LinearPad2Y(
i,
j, cl.getPad());
235 const float r = sqrtf(
x *
x +
y *
y);
236 const float maxz =
r * mEtaFactor + mMaxZ;
237 const unsigned int deltaBC = std::max<float>(0.f, totalT - mFastTransform->convDeltaZtoDeltaTimeInTimeFrameAbs(maxz)) *
constants::LHCBCPERTIMEBIN;
242 rejectHits[k] =
true;
244 static std::atomic_flag lock = ATOMIC_FLAG_INIT;
245 while (lock.test_and_set(std::memory_order_acquire)) {
248 lock.clear(std::memory_order_release);
250 outBuffer.first.emplace_back(0);
251 outBuffer.second.emplace_back(0);
252 GPUTPCCompression_EncodeUnattached(clustersFiltered.
nComppressionModes, cl, outBuffer.first.back(), outBuffer.second.back(),
count++ ? &preCl :
nullptr);
261 for (
int i = 1;
i < mNThreads;
i++) {
262 tmpBuffer[0].first.insert(tmpBuffer[0].
first.end(), tmpBuffer[
i].first.begin(), tmpBuffer[
i].first.end());
263 tmpBuffer[
i].first.clear();
264 tmpBuffer[0].second.insert(tmpBuffer[0].second.end(), tmpBuffer[
i].second.begin(), tmpBuffer[
i].second.end());
265 tmpBuffer[
i].second.clear();
267 clustersFiltered.
timeDiffU = tmpBuffer[0].first.data();
268 clustersFiltered.
padDiffU = tmpBuffer[0].second.data();
272 uint32_t prevOrbit = -1;
273 uint16_t prevBC = -1;
278 for (
size_t it = 1; it < trigComp.
triggerType.size(); it++) {
281 trigComp.
deltaBC[it] -= prevBC;
292 auto iosize = mCTFCoder.
encode(
buffer,
clusters, clustersFiltered, trigComp, mSelIR ? &rejectHits :
nullptr, mSelIR ? &rejectTracks :
nullptr, mSelIR ? &rejectTrackHits :
nullptr, mSelIR ? &rejectTrackHitsReduced :
nullptr);
298 LOG(info) << iosize.asString() <<
" in " << mTimer.CpuTime() - cput <<
" s";
309 std::vector<InputSpec> inputs;
311 inputs.emplace_back(
"input",
"TPC", inputType, 0, Lifetime::Timeframe);
312 inputs.emplace_back(
"trigger",
"TPC",
"TRIGGERWORDS", 0, Lifetime::Timeframe);
314 if (ctfdictOpt.empty() || ctfdictOpt ==
"ccdb") {
315 inputs.emplace_back(
"ctfdict",
"TPC",
"CTFDICT", 0, Lifetime::Condition,
ccdbParamSpec(
"TPC/Calib/CTFDictionaryTree"));
318 std::shared_ptr<o2::base::GRPGeomRequest> ggreq;
320 inputs.emplace_back(
"selIRFrames",
"CTF",
"SELIRFRAMES", 0, Lifetime::Timeframe);
325 "tpc-entropy-encoder",
327 Outputs{{
"TPC",
"CTFDATA", 0, Lifetime::Timeframe},
328 {{
"ctfrep"},
"TPC",
"CTFENCREP", 0, Lifetime::Timeframe}},
329 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(inputFromFile, selIR, ggreq, ctfdictOpt)},
330 Options{{
"no-ctf-columns-combining", VariantType::Bool,
false, {
"Do not combine correlated columns in CTF"}},
331 {
"irframe-margin-bwd", VariantType::UInt32, 0u, {
"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
332 {
"irframe-margin-fwd", VariantType::UInt32, 0u, {
"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
333 {
"irframe-clusters-maxeta", VariantType::Float, 1.5f, {
"Max eta for non-assigned clusters"}},
334 {
"irframe-clusters-maxz", VariantType::Float, 25.f, {
"Max z for non assigned clusters (combined with maxeta)"}},
335 {
"mem-factor", VariantType::Float, 1.f, {
"Memory allocation margin factor"}},
336 {
"nThreads-tpc-encoder", VariantType::UInt32, 1u, {
"number of threads to use for decoding"}},
337 {
"ans-version", VariantType::String, {
"version of ans entropy coder implementation to use"}}}};
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
o2::ctf::CTFIOSize encode(VEC &buff, const CompressedClusters &ccl, const CompressedClusters &cclFiltered, const detail::TriggerInfo &trigComp, std::vector< bool > *rejectHits=nullptr, std::vector< bool > *rejectTracks=nullptr, std::vector< bool > *rejectTrackHits=nullptr, std::vector< bool > *rejectTrackHitsReduced=nullptr)
entropy-encode compressed clusters to flat buffer