27 gsl::span<const DigROFRecord> digitROFs,
28 std::vector<o2::iotof::Cluster>&
clusters,
29 std::vector<unsigned char>& patterns,
30 std::vector<o2::itsmft::ROFRecord>& clusterROFs,
33 gsl::span<const DigMC2ROFRecord> digMC2ROFs,
34 std::vector<o2::itsmft::MC2ROFRecord>* clusterMC2ROFs)
36 LOG(info) <<
"Running clusterizer on " << digitROFs.size() <<
" ROFs, total digits: " <<
digits.size();
39 mThread = std::make_unique<ClustererThread>(
this);
42 for (
size_t iROF = 0; iROF < digitROFs.size(); ++iROF) {
43 LOG(
debug) <<
"Processing digit ROF " << iROF <<
"/" << digitROFs.size();
44 const auto& inROF = digitROFs[iROF];
45 const auto outFirst =
static_cast<int>(
clusters.size());
46 const int first = inROF.getFirstEntry();
47 const int nEntries = inROF.getNEntries();
50 LOG(
debug) <<
"Digit ROF " << iROF <<
" has no entries, skipping";
51 clusterROFs.emplace_back(inROF.getBCData(), inROF.getROFrame(), outFirst, 0);
60 const auto& da = digits[a];
61 const auto& db = digits[b];
62 if (da.getChipIndex() != db.getChipIndex()) {
63 return da.getChipIndex() < db.getChipIndex();
65 if (da.getColumn() != db.getColumn()) {
66 return da.getColumn() < db.getColumn();
68 return da.getRow() < db.getRow();
70 LOG(
debug) <<
"Found " << nEntries <<
" digits for ROF " << iROF;
74 while (sliceStart < nEntries) {
75 const int chipFirst = sliceStart;
76 const uint16_t chipID =
digits[
mSortIdx[sliceStart]].getChipIndex();
77 while (sliceStart < nEntries &&
digits[
mSortIdx[sliceStart]].getChipIndex() == chipID) {
80 const int chipN = sliceStart - chipFirst;
82 LOG(
debug) <<
"Processing chip " << chipID <<
" with " << chipN <<
" digits, next chip start from index " << sliceStart;
86 LOG(
debug) <<
"Finished processing digit ROF " << iROF <<
", produced " << (
clusters.size() - outFirst) <<
" clusters";
87 clusterROFs.emplace_back(inROF.getBCData(), inROF.getROFrame(),
88 outFirst,
static_cast<int>(
clusters.size()) - outFirst);
91 LOG(info) <<
"Finished processing all digit ROFs, total clusters produced: " <<
clusters.size();
92 if (clusterMC2ROFs && !digMC2ROFs.empty()) {
93 clusterMC2ROFs->reserve(clusterMC2ROFs->size() + digMC2ROFs.size());
94 for (
const auto& in : digMC2ROFs) {
95 clusterMC2ROFs->emplace_back(in.eventRecordID, in.rofRecordID, in.minROF, in.maxROF);
101void Clusterer::ClustererThread::processChip(gsl::span<const Digit>
digits,
102 int chipFirst,
int chipN,
103 std::vector<Cluster>* clustersOut,
104 std::vector<unsigned char>* patternsOut,
111 const auto& sortIdx = parent->mSortIdx;
116 for (
auto i = 0;
i < chipN; ++
i) {
117 finishChipSingleHitFast(
digits, sortIdx[chipFirst +
i], labelsDigPtr, labelsClusPtr);
137 if (!patterns.empty()) {
138 patternsOut->insert(patternsOut->end(), patterns.begin(), patterns.end());
148void Clusterer::ClustererThread::finishChipSingleHitFast(gsl::span<const Digit>
digits,
153 const auto& digit =
digits[digitIdx];
154 const uint16_t chipID = digit.getChipIndex();
155 const uint16_t
row = digit.getRow();
156 const uint16_t
col = digit.getColumn();
157 const double time = digit.getTime();
161 fetchMCLabels(digitIdx, labelsDigPtr, nlab);
162 const auto cnt =
static_cast<uint32_t
>(
clusters.size());
163 for (
int i = nlab;
i--;) {
164 labels.addElement(cnt, labelsBuff[
i]);
169 patterns.emplace_back(1);
170 patterns.emplace_back(1);
171 patterns.emplace_back(0x80);
virtual void process(gsl::span< const Digit > digits, gsl::span< const DigROFRecord > digitROFs, std::vector< o2::iotof::Cluster > &clusters, std::vector< unsigned char > &patterns, std::vector< o2::itsmft::ROFRecord > &clusterROFs, const ConstDigitTruth *digitLabels=nullptr, ClusterTruth *clusterLabels=nullptr, gsl::span< const DigMC2ROFRecord > digMC2ROFs={}, std::vector< o2::itsmft::MC2ROFRecord > *clusterMC2ROFs=nullptr)