Project
Loading...
Searching...
No Matches
MCLabelAccumulator.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#include "MCLabelAccumulator.h"
16
17#include "GPUHostDataTypes.h"
18#include "GPUTPCClusterFinder.h"
20
21using namespace o2::gpu;
22using namespace o2::gpu::tpccf;
23
25 : mIndexMap(clusterer.mPindexMap), mLabels(clusterer.mPinputLabels), mOutput(clusterer.mPlabelsByRow)
26{
27}
28
30{
31 if (q == 0 || !engaged()) {
32 return;
33 }
34
35 uint32_t index = mIndexMap[pos];
36
37 const auto& labels = mLabels->getLabels(index);
38
39 for (const auto& label : labels) {
40 int32_t h = label.getRawValue() % mMaybeHasLabel.size();
41
42 if (mMaybeHasLabel[h]) {
43 auto lookup = std::find(mClusterLabels.begin(), mClusterLabels.end(), label);
44 if (lookup != mClusterLabels.end()) {
45 continue;
46 }
47 }
48
49 mMaybeHasLabel[h] = true;
50 mClusterLabels.emplace_back(label);
51 }
52}
53
54void MCLabelAccumulator::commit(Row row, uint32_t indexInRow, uint32_t maxElemsPerBucket)
55{
56 if (indexInRow >= maxElemsPerBucket || !engaged()) {
57 return;
58 }
59
60 auto& out = mOutput[row];
61 while (out.lock.test_and_set(std::memory_order_acquire)) {
62 ;
63 }
64 if (out.data.size() <= indexInRow) {
65 out.data.resize(indexInRow + 100); // Increase in steps of 100 at least to reduce number of resize operations
66 }
67 out.data[indexInRow].labels = std::move(mClusterLabels);
68 out.lock.clear(std::memory_order_release);
69}
uint8_t lookup(const char input) noexcept
Definition of a container to keep Monte Carlo truth external to simulation objects.
uint16_t pos
Definition RawData.h:3
Class for time synchronization of RawReader instances.
gsl::span< const TruthElement > getLabels(uint32_t dataindex) const
void collect(const ChargePos &, tpccf::Charge)
void commit(tpccf::Row, uint32_t, uint32_t)
MCLabelAccumulator(GPUTPCClusterFinder &)
GLuint index
Definition glcorearb.h:781
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
std::vector< GPUTPCClusterMCInterim > data
std::vector< int > row