92 LOG(fatal) <<
"configKeyValue tpcTriggeredMode does not match GRP isDetContinuousReadOut(TPC) setting";
97 mParam->UpdateSettings(&mConfig->configGRP);
99 mTPCVDriftHelper->extractCCDBInputs(pc);
100 if (mTPCVDriftHelper->isUpdated()) {
112 if (tmp ==
nullptr) {
113 LOG(error) <<
"invalid input";
119 if (tmp ==
nullptr) {
120 LOG(error) <<
"invalid input";
125 auto triggers = pc.
inputs().
get<gsl::span<o2::tpc::TriggerInfoDLBZS>>(
"trigger");
126 auto cput = mTimer.CpuTime();
129 std::vector<bool> rejectHits, rejectTracks, rejectTrackHits, rejectTrackHitsReduced;
131 std::vector<std::pair<std::vector<unsigned int>, std::vector<unsigned short>>> tmpBuffer(std::max<int>(mNThreads, 1));
135 for (
const auto& trig : triggers) {
137 if (trig.triggerWord.isValid(it)) {
139 trigComp.
deltaBC.push_back(trig.triggerWord.getTriggerBC(it));
140 trigComp.
triggerType.push_back(trig.triggerWord.getTriggerType(it));
149 throw std::runtime_error(
"Configured solenoid Bz does not match value used for track model encoding");
152 throw std::runtime_error(
"Configured max time bin does not match value used for track model encoding");
155 rejectHits.resize(
clusters.nUnattachedClusters);
156 rejectTracks.resize(
clusters.nTracks);
157 rejectTrackHits.resize(
clusters.nAttachedClusters);
158 rejectTrackHitsReduced.resize(
clusters.nAttachedClustersReduced);
162 const float totalT = std::max(mFastTransform->getMaxDriftTime(0), mFastTransform->getMaxDriftTime(
GPUCA_NSECTORS / 2));
164 unsigned int offset = 0, lasti = 0;
167#pragma omp parallel for firstprivate(offset, lasti) num_threads(mNThreads)
169 for (
unsigned int i = 0;
i <
clusters.nTracks;
i++) {
170 unsigned int tMinP = maxTime, tMaxP = 0;
172 if (cl.getTimePacked() > tMaxP) {
173 tMaxP = cl.getTimePacked();
175 if (cl.getTimePacked() < tMinP) {
176 tMinP = cl.getTimePacked();
186 o2::gpu::TPCClusterDecompressionCore::decompressTrack(
clusters, *mParam, maxTime,
i,
offset, checker);
187 const float tMin = o2::tpc::ClusterNative::unpackTime(tMinP), tMax = o2::tpc::ClusterNative::unpackTime(tMaxP);
193 rejectTrackHits[k] =
true;
196 rejectTrackHitsReduced[k] =
true;
198 rejectTracks[
i] =
true;
199 static std::atomic_flag lock = ATOMIC_FLAG_INIT;
200 while (lock.test_and_set(std::memory_order_acquire)) {
205 lock.clear(std::memory_order_release);
221#pragma omp parallel for num_threads(mNThreads) schedule(static, (GPUCA_NSECTORS + mNThreads - 1) / mNThreads)
223 for (
unsigned int ii = 0; ii <
clusters.nSliceRows; ii++) {
228 int myThread = omp_get_thread_num();
232 unsigned int count = 0;
233 const float x = mParam->tpcGeometry.Row2X(
j);
234 auto checker = [
i,
j, firstIR, totalT,
x,
this, &preCl, &
count, &outBuffer = tmpBuffer[myThread], &rejectHits, &clustersFiltered](
const o2::tpc::ClusterNative& cl,
unsigned int k) {
235 const float y = mParam->tpcGeometry.LinearPad2Y(
i,
j, cl.getPad());
236 const float r = sqrtf(
x *
x +
y *
y);
237 const float maxz =
r * mEtaFactor + mMaxZ;
238 const unsigned int deltaBC = std::max<float>(0.f, totalT - mFastTransform->convDeltaZtoDeltaTimeInTimeFrameAbs(maxz)) *
constants::LHCBCPERTIMEBIN;
243 rejectHits[k] =
true;
245 static std::atomic_flag lock = ATOMIC_FLAG_INIT;
246 while (lock.test_and_set(std::memory_order_acquire)) {
249 lock.clear(std::memory_order_release);
251 outBuffer.first.emplace_back(0);
252 outBuffer.second.emplace_back(0);
253 GPUTPCCompression_EncodeUnattached(clustersFiltered.
nComppressionModes, cl, outBuffer.first.back(), outBuffer.second.back(),
count++ ? &preCl :
nullptr);
262 for (
int i = 1;
i < mNThreads;
i++) {
263 tmpBuffer[0].first.insert(tmpBuffer[0].
first.end(), tmpBuffer[
i].first.begin(), tmpBuffer[
i].first.end());
264 tmpBuffer[
i].first.clear();
265 tmpBuffer[0].second.insert(tmpBuffer[0].second.end(), tmpBuffer[
i].second.begin(), tmpBuffer[
i].second.end());
266 tmpBuffer[
i].second.clear();
268 clustersFiltered.
timeDiffU = tmpBuffer[0].first.data();
269 clustersFiltered.
padDiffU = tmpBuffer[0].second.data();
273 uint32_t prevOrbit = -1;
274 uint16_t prevBC = -1;
279 for (
size_t it = 1; it < trigComp.
triggerType.size(); it++) {
282 trigComp.
deltaBC[it] -= prevBC;
293 auto iosize = mCTFCoder.
encode(
buffer,
clusters, clustersFiltered, trigComp, mSelIR ? &rejectHits :
nullptr, mSelIR ? &rejectTracks :
nullptr, mSelIR ? &rejectTrackHits :
nullptr, mSelIR ? &rejectTrackHitsReduced :
nullptr);
299 LOG(info) << iosize.asString() <<
" in " << mTimer.CpuTime() - cput <<
" s";
310 std::vector<InputSpec> inputs;
312 inputs.emplace_back(
"input",
"TPC", inputType, 0, Lifetime::Timeframe);
313 inputs.emplace_back(
"trigger",
"TPC",
"TRIGGERWORDS", 0, Lifetime::Timeframe);
314 inputs.emplace_back(
"ctfdict",
"TPC",
"CTFDICT", 0, Lifetime::Condition,
ccdbParamSpec(
"TPC/Calib/CTFDictionaryTree"));
316 std::shared_ptr<o2::base::GRPGeomRequest> ggreq;
318 inputs.emplace_back(
"selIRFrames",
"CTF",
"SELIRFRAMES", 0, Lifetime::Timeframe);
323 "tpc-entropy-encoder",
325 Outputs{{
"TPC",
"CTFDATA", 0, Lifetime::Timeframe},
326 {{
"ctfrep"},
"TPC",
"CTFENCREP", 0, Lifetime::Timeframe}},
327 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(inputFromFile, selIR, ggreq)},
328 Options{{
"ctf-dict", VariantType::String,
"ccdb", {
"CTF dictionary: empty or ccdb=CCDB, none=no external dictionary otherwise: local filename"}},
329 {
"no-ctf-columns-combining", VariantType::Bool,
false, {
"Do not combine correlated columns in CTF"}},
330 {
"irframe-margin-bwd", VariantType::UInt32, 0u, {
"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
331 {
"irframe-margin-fwd", VariantType::UInt32, 0u, {
"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
332 {
"irframe-clusters-maxeta", VariantType::Float, 1.5f, {
"Max eta for non-assigned clusters"}},
333 {
"irframe-clusters-maxz", VariantType::Float, 25.f, {
"Max z for non assigned clusters (combined with maxeta)"}},
334 {
"mem-factor", VariantType::Float, 1.f, {
"Memory allocation margin factor"}},
335 {
"nThreads-tpc-encoder", VariantType::UInt32, 1u, {
"number of threads to use for decoding"}},
336 {
"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