74 if (mIdROF >= mROFRecVec.size()) {
77 if (mIdROF < 0 || mIdDig >= mROFRecVec[mIdROF].getNEntries()) {
83 int did = mROFRecVec[mIdROF].getFirstEntry() + mIdDig;
85 const auto* digit = &mDigits[did];
86 chipData.
setChipID(digit->getChipIndex());
87 chipData.
setROFrame(mROFRecVec[mIdROF].getROFrame());
90 if (mSquashOverflowsDepth) {
91 if (!mSquashedDigitsMask[did]) {
92 chipData.
getData().emplace_back(digit);
93 mSquashedDigitsMask[did] =
true;
99 chipData.
getData().emplace_back(digit);
101 int lim = mROFRecVec[mIdROF].getFirstEntry() + mROFRecVec[mIdROF].getNEntries();
102 while ((++did < lim) && (digit = &mDigits[did])->getChipIndex() == chipData.
getChipID()) {
103 if (mSquashOverflowsDepth) {
104 if (!mSquashedDigitsMask[did]) {
105 chipData.
getData().emplace_back(digit);
106 mSquashedDigitsMask[did] =
true;
107 if (mDigitsMCTruth) {
112 chipData.
getData().emplace_back(digit);
115 mIdDig = did - mROFRecVec[mIdROF].getFirstEntry();
118 if (!mIdROF || mIdROFLast != mIdROF) {
120 for (uint16_t iROF{1}; iROF <= mSquashOverflowsDepth && (mIdROF + iROF) < mROFRecVec.size(); ++iROF) {
121 mBookmarkNextROFs[iROF - 1] = mROFRecVec[mIdROF + iROF].getFirstEntry();
126 for (uint16_t iROF{1}; iROF <= mSquashOverflowsDepth && (mIdROF + iROF) < mROFRecVec.size(); ++iROF) {
127 int idNextROF{mIdROF + iROF};
128 if (std::abs(mROFRecVec[idNextROF].getBCData().differenceInBC(mROFRecVec[idNextROF - 1].getBCData())) > mMaxBCSeparationToSquash) {
133 for (
int i{mBookmarkNextROFs[iROF - 1]};
i < mROFRecVec[idNextROF].getFirstEntry() + mROFRecVec[idNextROF].getNEntries(); ++
i) {
134 if (mDigits[
i].getChipIndex() < chipData.
getChipID()) {
135 ++mBookmarkNextROFs[iROF - 1];
137 if (mDigits[
i].getChipIndex() == chipData.
getChipID()) {
147 size_t initialSize{chipData.
getData().size()};
149 for (
size_t iPixel{0}, iDigitNext{0}; iPixel < initialSize; ++iPixel) {
150 const auto& pixel = chipData.
getData()[iPixel];
151 for (; iDigitNext < nDigitsNext; ++iDigitNext) {
152 const auto* digitNext = &mDigits[mBookmarkNextROFs[iROF - 1] + iDigitNext];
153 if (digitNext->getRow() == pixel.getRowDirect() && digitNext->getColumn() == pixel.getCol()) {
154 mSquashedDigitsMask[mBookmarkNextROFs[iROF - 1] + iDigitNext] =
true;
159 const auto mincol = pixel.getCol() > mMaxSquashDist ? pixel.getCol() - mMaxSquashDist : 0;
160 const auto minrow = pixel.getRowDirect() > mMaxSquashDist ? pixel.getRowDirect() - mMaxSquashDist : 0;
161 if (iDigitNext == nDigitsNext) {
164 while ((mDigits[mBookmarkNextROFs[iROF - 1] + iDigitNext].
getColumn() > mincol || mDigits[mBookmarkNextROFs[iROF - 1] + iDigitNext].getRow() > minrow) && iDigitNext > 0) {
167 for (; iDigitNext < nDigitsNext; iDigitNext++) {
168 if (mSquashedDigitsMask[mBookmarkNextROFs[iROF - 1] + iDigitNext]) {
171 const auto* digitNext = &mDigits[mBookmarkNextROFs[iROF - 1] + iDigitNext];
172 const auto drow = digitNext->getRow() - pixel.getRowDirect();
173 const auto dcol = digitNext->getColumn() - pixel.getCol();
174 if (!dcol && !drow) {
175 mSquashedDigitsMask[mBookmarkNextROFs[iROF - 1] + iDigitNext] =
true;
182 for (
int iPixel{0}, iDigitNext{0}; iPixel < initialSize; ++iPixel) {
185 const auto mincol = pixel.
getCol() > mMaxSquashDist ? pixel.
getCol() - mMaxSquashDist : 0;
187 if (iDigitNext == nDigitsNext) {
190 while ((mDigits[mBookmarkNextROFs[iROF - 1] + iDigitNext].
getColumn() > mincol || mDigits[mBookmarkNextROFs[iROF - 1] + iDigitNext].getRow() > minrow) && iDigitNext > 0) {
193 for (; iDigitNext < nDigitsNext; iDigitNext++) {
194 if (mSquashedDigitsMask[mBookmarkNextROFs[iROF - 1] + iDigitNext]) {
197 const auto* digitNext = &mDigits[mBookmarkNextROFs[iROF - 1] + iDigitNext];
198 const auto drow = digitNext->getRow() - pixel.
getRowDirect();
199 const auto dcol = digitNext->getColumn() - pixel.
getCol();
205 if (dcol > mMaxSquashDist || (dcol == mMaxSquashDist && drow > mMaxSquashDist)) {
208 if (dcol < -mMaxSquashDist || (drow > mMaxSquashDist || drow < -mMaxSquashDist)) {
211 mSquashedDigitsMask[mBookmarkNextROFs[iROF - 1] + iDigitNext] =
true;
212 chipData.
getData().emplace_back(digitNext);
213 if (mDigitsMCTruth) {
214 chipData.
getPixIds().push_back(mBookmarkNextROFs[iROF - 1] + iDigitNext);
220 mBookmarkNextROFs[iROF - 1] += nDigitsNext;
222 if (mSquashOverflowsDepth) {
223 if (mDigitsMCTruth) {
227 std::sort(chipData.
getPixelsOrder().begin(), chipData.
getPixelsOrder().end(), [&
pixels](
int a,
int b) ->
bool { return pixels[a].getCol() == pixels[b].getCol() ? pixels[a].getRow() < pixels[b].getRow() : pixels[a].getCol() < pixels[b].getCol(); });
229 std::sort(chipData.
getData().begin(), chipData.
getData().end(), [](
auto& d1,
auto& d2) ->
bool { return d1.getCol() == d2.getCol() ? d1.getRow() < d2.getRow() : d1.getCol() < d2.getCol(); });
238 const auto* digit = &mDigits[mBookmarkNextROFs[iROF - 1] + iDigit];
240 for (
int iOtherDigit{0}; iOtherDigit < maxDigits; ++iOtherDigit) {
241 if (mSquashedDigitsMask[mBookmarkNextROFs[iROF - 1] + iOtherDigit]) {
244 const auto* otherDigit = &mDigits[mBookmarkNextROFs[iROF - 1] + iOtherDigit];
245 const auto drow = otherDigit->getRow() - digit->getRow();
246 const auto dcol = otherDigit->getColumn() - digit->getColumn();
247 if (dcol > mMaxSquashDist || (dcol == mMaxSquashDist && drow > mMaxSquashDist)) {
250 if (dcol < -mMaxSquashDist || (drow > mMaxSquashDist || drow < -mMaxSquashDist)) {
253 mSquashedDigitsMask[mBookmarkNextROFs[iROF - 1] + iOtherDigit] =
true;
254 chipData.
getData().emplace_back(otherDigit);
255 if (mDigitsMCTruth) {
256 chipData.
getPixIds().push_back(mBookmarkNextROFs[iROF - 1] + iOtherDigit);