Skip to content

Commit

Permalink
Optionally drop huge clusters in the ALPIDE clusterer (#13808)
Browse files Browse the repository at this point in the history
  • Loading branch information
mconcas authored Dec 16, 2024
1 parent ce6b536 commit a498560
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
3 changes: 2 additions & 1 deletion Detectors/ITSMFT/ITS/workflow/src/ClustererSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ void ClustererDPL::updateTimeDependentParams(ProcessingContext& pc)
// settings for the fired pixel overflow masking
const auto& alpParams = o2::itsmft::DPLAlpideParam<o2::detectors::DetID::ITS>::Instance();
const auto& clParams = o2::itsmft::ClustererParam<o2::detectors::DetID::ITS>::Instance();
mClusterer->setDropHugeClusters(clParams.dropHugeClusters);
if (clParams.maxBCDiffToMaskBias > 0 && clParams.maxBCDiffToSquashBias > 0) {
LOGP(fatal, "maxBCDiffToMaskBias = {} and maxBCDiffToMaskBias = {} cannot be set at the same time. Either set masking or squashing with a BCDiff > 0", clParams.maxBCDiffToMaskBias, clParams.maxBCDiffToSquashBias);
LOGP(fatal, "maxBCDiffToMaskBias = {} and maxBCDiffToSquashBias = {} cannot be set at the same time. Either set masking or squashing with a BCDiff > 0", clParams.maxBCDiffToMaskBias, clParams.maxBCDiffToSquashBias);
}
auto nbc = clParams.maxBCDiffToMaskBias;
nbc += mClusterer->isContinuousReadOut() ? alpParams.roFrameLengthInBC : (alpParams.roFrameLengthTrig / o2::constants::lhc::LHCBunchSpacingNS);
Expand Down
3 changes: 2 additions & 1 deletion Detectors/ITSMFT/MFT/workflow/src/ClustererSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ void ClustererDPL::updateTimeDependentParams(ProcessingContext& pc)
const auto& alpParams = o2::itsmft::DPLAlpideParam<o2::detectors::DetID::MFT>::Instance();
const auto& clParams = o2::itsmft::ClustererParam<o2::detectors::DetID::MFT>::Instance();
if (clParams.maxBCDiffToMaskBias > 0 && clParams.maxBCDiffToSquashBias > 0) {
LOGP(fatal, "maxBCDiffToMaskBias = {} and maxBCDiffToMaskBias = {} cannot be set at the same time. Either set masking or squashing with a BCDiff > 0", clParams.maxBCDiffToMaskBias, clParams.maxBCDiffToSquashBias);
LOGP(fatal, "maxBCDiffToMaskBias = {} and maxBCDiffToSquashBias = {} cannot be set at the same time. Either set masking or squashing with a BCDiff > 0", clParams.maxBCDiffToMaskBias, clParams.maxBCDiffToSquashBias);
}
mClusterer->setDropHugeClusters(clParams.dropHugeClusters);
auto nbc = clParams.maxBCDiffToMaskBias;
nbc += mClusterer->isContinuousReadOut() ? alpParams.roFrameLengthInBC : (alpParams.roFrameLengthTrig / o2::constants::lhc::LHCBunchSpacingNS);
mClusterer->setMaxBCSeparationToMask(nbc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ class Clusterer
bool isContinuousReadOut() const { return mContinuousReadout; }
void setContinuousReadOut(bool v) { mContinuousReadout = v; }

bool isDropHugeClusters() const { return mDropHugeClusters; }
void setDropHugeClusters(bool v) { mDropHugeClusters = v; }

int getMaxBCSeparationToMask() const { return mMaxBCSeparationToMask; }
void setMaxBCSeparationToMask(int n) { mMaxBCSeparationToMask = n; }

Expand Down Expand Up @@ -238,6 +241,7 @@ class Clusterer

// clusterization options
bool mContinuousReadout = true; ///< flag continuous readout
bool mDropHugeClusters = false; ///< don't include clusters that would be split in more than one

///< mask continuosly fired pixels in frames separated by less than this amount of BCs (fired from hit in prev. ROF)
int mMaxBCSeparationToMask = 6000. / o2::constants::lhc::LHCBunchSpacingNS + 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct ClustererParam : public o2::conf::ConfigurableParamHelper<ClustererParam<
int maxBCDiffToMaskBias = 10; ///< mask if 2 ROFs differ by <= StrobeLength + Bias BCs, use value <0 to disable masking
int maxBCDiffToSquashBias = -10; ///< squash if 2 ROFs differ by <= StrobeLength + Bias BCs, use value <0 to disable squashing
float maxSOTMUS = 8.; ///< max expected signal over threshold in \mus
bool dropHugeClusters = false; ///< option to drop huge clusters (mitigate beam background)

O2ParamDef(ClustererParam, getParamName().data());

Expand Down
56 changes: 29 additions & 27 deletions Detectors/ITSMFT/common/reconstruction/src/Clusterer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -263,36 +263,38 @@ void Clusterer::ClustererThread::finishChip(ChipPixelData* curChipData, CompClus
parent->streamCluster(pixArrBuff, &labelsBuff, bbox, parent->mPattIdConverter, compClusPtr, patternsPtr, labelsClusPtr, nlab);
} else {
auto warnLeft = MaxHugeClusWarn - parent->mNHugeClus;
if (warnLeft > 0) {
LOGP(warn, "Splitting a huge cluster: chipID {}, rows {}:{} cols {}:{}{}", bbox.chipID, bbox.rowMin, bbox.rowMax, bbox.colMin, bbox.colMax,
warnLeft == 1 ? " (Further warnings will be muted)" : "");
if (!parent->mDropHugeClusters) {
if (warnLeft > 0) {
LOGP(warn, "Splitting a huge cluster: chipID {}, rows {}:{} cols {}:{}{}", bbox.chipID, bbox.rowMin, bbox.rowMax, bbox.colMin, bbox.colMax,
warnLeft == 1 ? " (Further warnings will be muted)" : "");
#ifdef WITH_OPENMP
#pragma omp critical
#endif
{
parent->mNHugeClus++;
{
parent->mNHugeClus++;
}
}
}
BBox bboxT(bbox); // truncated box
std::vector<PixelData> pixbuf;
do {
bboxT.rowMin = bbox.rowMin;
bboxT.colMax = std::min(bbox.colMax, uint16_t(bboxT.colMin + o2::itsmft::ClusterPattern::MaxColSpan - 1));
do { // Select a subset of pixels fitting the reduced bounding box
bboxT.rowMax = std::min(bbox.rowMax, uint16_t(bboxT.rowMin + o2::itsmft::ClusterPattern::MaxRowSpan - 1));
for (const auto& pix : pixArrBuff) {
if (bboxT.isInside(pix.getRowDirect(), pix.getCol())) {
pixbuf.push_back(pix);
BBox bboxT(bbox); // truncated box
std::vector<PixelData> pixbuf;
do {
bboxT.rowMin = bbox.rowMin;
bboxT.colMax = std::min(bbox.colMax, uint16_t(bboxT.colMin + o2::itsmft::ClusterPattern::MaxColSpan - 1));
do { // Select a subset of pixels fitting the reduced bounding box
bboxT.rowMax = std::min(bbox.rowMax, uint16_t(bboxT.rowMin + o2::itsmft::ClusterPattern::MaxRowSpan - 1));
for (const auto& pix : pixArrBuff) {
if (bboxT.isInside(pix.getRowDirect(), pix.getCol())) {
pixbuf.push_back(pix);
}
}
}
if (!pixbuf.empty()) { // Stream a piece of cluster only if the reduced bounding box is not empty
parent->streamCluster(pixbuf, &labelsBuff, bboxT, parent->mPattIdConverter, compClusPtr, patternsPtr, labelsClusPtr, nlab, true);
pixbuf.clear();
}
bboxT.rowMin = bboxT.rowMax + 1;
} while (bboxT.rowMin < bbox.rowMax);
bboxT.colMin = bboxT.colMax + 1;
} while (bboxT.colMin < bbox.colMax);
if (!pixbuf.empty()) { // Stream a piece of cluster only if the reduced bounding box is not empty
parent->streamCluster(pixbuf, &labelsBuff, bboxT, parent->mPattIdConverter, compClusPtr, patternsPtr, labelsClusPtr, nlab, true);
pixbuf.clear();
}
bboxT.rowMin = bboxT.rowMax + 1;
} while (bboxT.rowMin < bbox.rowMax);
bboxT.colMin = bboxT.colMax + 1;
} while (bboxT.colMin < bbox.colMax);
}
}
}
}
Expand Down Expand Up @@ -451,8 +453,8 @@ void Clusterer::print() const
{
// print settings
LOGP(info, "Clusterizer squashes overflow pixels separated by {} BC and <= {} in row/col seeking down to {} neighbour ROFs", mMaxBCSeparationToSquash, mMaxRowColDiffToMask, mSquashingDepth);
LOG(info) << "Clusterizer masks overflow pixels separated by < " << mMaxBCSeparationToMask << " BC and <= "
<< mMaxRowColDiffToMask << " in row/col";
LOGP(info, "Clusterizer masks overflow pixels separated by < {} BC and <= {} in row/col", mMaxBCSeparationToMask, mMaxRowColDiffToMask);
LOGP(info, "Clusterizer does {} drop huge clusters", mDropHugeClusters ? "" : "not");

#ifdef _PERFORM_TIMING_
auto& tmr = const_cast<TStopwatch&>(mTimer); // ugly but this is what root does internally
Expand Down

0 comments on commit a498560

Please sign in to comment.