14#ifndef ALICEO2_ITS_CLUSTERER_H
15#define ALICEO2_ITS_CLUSTERER_H
17#define _PERFORM_TIMING_
21#define _ALLOW_DIAGONAL_ALPIDE_CLUSTERS_
39#ifdef _PERFORM_TIMING_
40#include <TStopwatch.h>
51class ConstMCTruthContainerView;
132 std::vector<std::pair<int, uint32_t>>
pixels;
146 void resetColumn(
int* buff)
const { std::memset(buff, -1,
sizeof(
int) * (
size - 2)); }
156 pixels.emplace_back(firstIndex, ip);
157 firstIndex =
pixels.size() - 1;
167 pixels.emplace_back(-1, ip);
204 template <
typename VCLUS,
typename VPAT>
206 VCLUS* compClusPtr, VPAT* patternsPtr,
MCTruth* labelsClusPtr,
int nlab,
bool isIB,
bool isHuge =
false);
228 void print(
bool showsTiming)
const;
235 LOGP(info,
"Setting TopologyDictionary with IB size={} & OB size={}", dict->
getSize(
true), dict->
getSize(
false));
253 bool mContinuousReadout =
true;
254 bool mDropHugeClusters =
false;
258 int mMaxRowColDiffToMask = 0;
262 int mSquashingDepth = 0;
264 std::vector<int> mSquashingLayerDepth;
265 std::vector<int> mMaxBCSeparationToSquashLayer;
267 std::vector<std::unique_ptr<ClustererThread>> mThreads;
268 std::vector<ChipPixelData> mChips;
269 std::vector<ChipPixelData> mChipsOld;
270 std::vector<ChipPixelData*> mFiredChipsPtr;
274#ifdef _PERFORM_TIMING_
276 TStopwatch mTimerMerge;
280template <
typename VCLUS,
typename VPAT>
282 VCLUS* compClusPtr, VPAT* patternsPtr,
MCTruth* labelsClusPtr,
int nlab,
bool isIB,
bool isHuge)
284 if (labelsClusPtr && lblBuff) {
285 auto cnt = compClusPtr->
size();
286 for (
int i = nlab;
i--;) {
290 auto colSpanW =
bbox.colSpan();
291 auto rowSpanW =
bbox.rowSpan();
293 std::array<unsigned char, itsmft::ClusterPattern::MaxPatternBytes> patt{};
294 for (
const auto& pix : pixbuf) {
295 uint32_t
ir = pix.getRowDirect() -
bbox.rowMin, ic = pix.getCol() -
bbox.colMin;
296 int nbits =
ir * colSpanW + ic;
297 patt[nbits >> 3] |= (0x1 << (7 - (nbits % 8)));
301 LOGP(
debug,
"PattID: findGroupID({},{},{})={}",
row,
col, patt[0], pattID);
305 float xCOG = 0., zCOG = 0.;
311 patternsPtr->emplace_back((
unsigned char)rowSpanW);
312 patternsPtr->emplace_back((
unsigned char)colSpanW);
313 int nBytes = rowSpanW * colSpanW / 8;
314 if (((rowSpanW * colSpanW) % 8) != 0) {
317 patternsPtr->insert(patternsPtr->end(), std::begin(patt), std::begin(patt) + nBytes);
320 compClusPtr->emplace_back(
row,
col, pattID,
bbox.chipID);
std::vector< std::string > labels
Definition of the ITSMFT compact cluster.
Header to collect LHC related constants.
Transient data classes for single pixel and set of pixels from current chip.
Abstract class for Alpide data reader class.
Definition of the SegmentationAlpide class.
Definition of the LookUp class for its3.
void setDictionary(const its3::TopologyDictionary *dict)
void setContinuousReadOut(bool v)
static constexpr int MaxLabels
int getMaxBCSeparationToSquash(int layer=-1) const
void setDropHugeClusters(bool v)
int getMaxBCSeparationToMask() const
int getMaxRowColDiffToMask() const
TStopwatch & getTimerMerge()
int getMaxROFDepthToSquash(int layer=-1) const
void addMaxBCSeparationToSquash(int n)
Clusterer & operator=(Clusterer &&)=delete
void process(int nThreads, PixelReader &r, CompClusCont *compClus, PatternCont *patterns, ROFRecCont *vecROFRec, MCTruth *labelsCl=nullptr)
void setMaxBCSeparationToMask(int n)
bool isContinuousReadOut() const
Clusterer(Clusterer &&)=delete
void clear()
load the dictionary of cluster topologies
static void streamCluster(const std::vector< PixelData > &pixbuf, const std::array< Label, MaxLabels > *lblBuff, const BBox &bbox, const its3::LookUp &pattIdConverter, VCLUS *compClusPtr, VPAT *patternsPtr, MCTruth *labelsClusPtr, int nlab, bool isIB, bool isHuge=false)
Clusterer & operator=(const Clusterer &)=delete
void addMaxROFDepthToSquash(int v)
void setMaxRowColDiffToMask(int v)
Clusterer(const Clusterer &)=delete
void setMaxBCSeparationToSquash(int n)
bool isDropHugeClusters() const
static constexpr int MaxHugeClusWarn
void setMaxROFDepthToSquash(int v)
void setDictionary(const TopologyDictionary *dict)
int getSize(bool IB) const
Returns the number of elements in the dicionary;.
static int getCOG(int rowSpan, int colSpan, const unsigned char patt[MaxPatternBytes], float &xCOG, float &zCOG)
Static: Compute pattern's COG position. Returns the number of fired pixels.
static constexpr uint8_t MaxRowSpan
static constexpr uint8_t MaxColSpan
static constexpr unsigned short InvalidPatternID
< single pixel datum, with possibility to set a flag of pixel being masked out
PixelReader class for the ITSMFT.
static constexpr int NRows
GLint GLint GLsizei GLint GLenum GLenum const void * pixels
GLenum GLuint GLint GLint layer
constexpr double LHCBunchSpacingNS
std::vector< unsigned char > PatternCont
std::vector< itsmft::CompClusterExt > CompClusCont
std::vector< itsmft::ROFRecord > ROFRecCont
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
bool isInside(uint16_t row, uint16_t col) const
bool isAcceptableSize() const
void adjust(uint16_t row, uint16_t col)
ClustererThread & operator=(ClustererThread &&)=delete
std::vector< PixelData > pixArrBuff
temporary buffer for building cluster labels
void addNewPrecluster(uint32_t ip, uint16_t row)
std::vector< ThreadStat > stats
void finishChipSingleHitFast(uint32_t hit, ChipPixelData *curChipData, CompClusCont *compClusPtr, PatternCont *patternsPtr, const ConstMCTruth *labelsDigPtr, MCTruth *labelsClusPTr)
std::array< Label, MaxLabels > labelsBuff
void process(uint16_t chip, uint16_t nChips, CompClusCont *compClusPtr, PatternCont *patternsPtr, const ConstMCTruth *labelsDigPtr, MCTruth *labelsClPtr, const itsmft::ROFRecord &rofPtr)
void updateChip(const ChipPixelData *curChipData, uint32_t ip)
void expandPreCluster(uint32_t ip, uint16_t row, int preClusIndex)
add new precluster at given row of current column for the fired pixel with index ip in the ChipPixelD...
std::vector< PreCluster > preClusters
temporary buffer for pattern calc.
ClustererThread(const ClustererThread &)=delete
void fetchMCLabels(int digID, const ConstMCTruth *labelsDig, int &nfilled)
std::vector< std::pair< int, uint32_t > > pixels
ClustererThread(ClustererThread &&)=delete
bool noLeftCol
flag that there is no column on the left to check
ClustererThread & operator=(const ClustererThread &)=delete
ClustererThread(Clusterer *par=nullptr, int _id=-1)
CompClusCont compClusters
preclusters info
void initChip(const ChipPixelData *curChipData, uint32_t first)
void resetColumn(int *buff) const
reset column buffer, for the performance reasons we use memset
void finishChip(ChipPixelData *curChipData, CompClusCont *compClus, PatternCont *patterns, const ConstMCTruth *labelsDig, MCTruth *labelsClus)
uint16_t currCol
Column being processed.
methods and transient data used within a thread
o2::InteractionRecord ir(0, 0)