14#ifndef ALICEO2_ITS_CLUSTERER_H
15#define ALICEO2_ITS_CLUSTERER_H
17#define _PERFORM_TIMING_
21#define _ALLOW_DIAGONAL_ALPIDE_CLUSTERS_
38#ifdef _PERFORM_TIMING_
39#include <TStopwatch.h>
50class ConstMCTruthContainerView;
138 std::vector<std::pair<int, uint32_t>>
pixels;
161 pixels.emplace_back(firstIndex, ip);
162 firstIndex =
pixels.size() - 1;
172 pixels.emplace_back(-1, ip);
202 template <
typename VCLUS,
typename VPAT>
204 VCLUS* compClusPtr, VPAT* patternsPtr,
MCTruth* labelsClusPtr,
int nlab,
bool isHuge =
false);
245 bool mContinuousReadout =
true;
246 bool mDropHugeClusters =
false;
250 int mMaxRowColDiffToMask = 0;
254 int mSquashingDepth = 0;
257 std::vector<std::unique_ptr<ClustererThread>> mThreads;
258 std::vector<ChipPixelData> mChips;
259 std::vector<ChipPixelData> mChipsOld;
260 std::vector<ChipPixelData*> mFiredChipsPtr;
265 TStopwatch mTimerMerge;
268template <
typename VCLUS,
typename VPAT>
270 VCLUS* compClusPtr, VPAT* patternsPtr,
MCTruth* labelsClusPtr,
int nlab,
bool isHuge)
272 if (labelsClusPtr && lblBuff) {
273 auto cnt = compClusPtr->
size();
274 for (
int i = nlab;
i--;) {
278 auto colSpanW =
bbox.colSpan();
279 auto rowSpanW =
bbox.rowSpan();
281 std::array<unsigned char, ClusterPattern::MaxPatternBytes> patt{};
282 for (
const auto& pix : pixbuf) {
283 uint32_t
ir = pix.getRowDirect() -
bbox.rowMin, ic = pix.getCol() -
bbox.colMin;
284 int nbits =
ir * colSpanW + ic;
285 patt[nbits >> 3] |= (0x1 << (7 - (nbits % 8)));
292 float xCOG = 0., zCOG = 0.;
298 patternsPtr->emplace_back((
unsigned char)rowSpanW);
299 patternsPtr->emplace_back((
unsigned char)colSpanW);
300 int nBytes = rowSpanW * colSpanW / 8;
301 if (((rowSpanW * colSpanW) % 8) != 0) {
304 patternsPtr->insert(patternsPtr->end(), std::begin(patt), std::begin(patt) + nBytes);
307 compClusPtr->emplace_back(
row,
col, pattID,
bbox.chipID);
std::vector< std::string > labels
Definition of the ITSMFT compact cluster.
Definition of the LookUp class.
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.
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
int getMaxBCSeparationToMask() const
void setMaxRowColDiffToMask(int v)
int getMaxROFDepthToSquash() const
void setMaxBCSeparationToMask(int n)
TStopwatch & getTimerMerge()
Clusterer & operator=(const Clusterer &)=delete
bool isDropHugeClusters() const
void setDictionary(const TopologyDictionary *dict)
int getMaxBCSeparationToSquash() const
static constexpr int MaxLabels
void setContinuousReadOut(bool v)
int getMaxRowColDiffToMask() const
void setMaxBCSeparationToSquash(int n)
void setMaxROFDepthToSquash(int v)
bool isContinuousReadOut() const
void setDropHugeClusters(bool v)
static constexpr int MaxHugeClusWarn
static void streamCluster(const std::vector< PixelData > &pixbuf, const std::array< Label, MaxLabels > *lblBuff, const BBox &bbox, const LookUp &pattIdConverter, VCLUS *compClusPtr, VPAT *patternsPtr, MCTruth *labelsClusPtr, int nlab, bool isHuge=false)
Clusterer(const Clusterer &)=delete
void loadDictionary(const std::string &fileName)
void setNChips(int n)
load the dictionary of cluster topologies
static constexpr unsigned short InvalidPatternID
void setDictionary(const TopologyDictionary *dict)
void loadDictionary(std::string fileName)
< 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
constexpr double LHCBunchSpacingNS
std::vector< unsigned char > PatternCont
std::vector< ROFRecord > ROFRecCont
std::vector< CompClusterExt > CompClusCont
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void adjust(uint16_t row, uint16_t col)
bool isInside(uint16_t row, uint16_t col) const
bool isAcceptableSize() const
int column2[SegmentationAlpide::NRows+2]
int column1[SegmentationAlpide::NRows+2]
std::vector< PixelData > pixArrBuff
temporary buffer for building cluster labels
std::vector< PreCluster > preClusters
temporary buffer for pattern calc.
void addNewPrecluster(uint32_t ip, uint16_t row)
void initChip(const ChipPixelData *curChipData, uint32_t first)
void finishChip(ChipPixelData *curChipData, CompClusCont *compClus, PatternCont *patterns, const ConstMCTruth *labelsDig, MCTruth *labelsClus)
uint16_t currCol
Column being processed.
std::vector< std::pair< int, uint32_t > > pixels
bool noLeftCol
flag that there is no column on the left to check
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...
void fetchMCLabels(int digID, const ConstMCTruth *labelsDig, int &nfilled)
ClustererThread(Clusterer *par=nullptr, int _id=-1)
void swapColumnBuffers()
add cluster at row (entry ip in the ChipPixeData) to the precluster with given index
void finishChipSingleHitFast(uint32_t hit, ChipPixelData *curChipData, CompClusCont *compClusPtr, PatternCont *patternsPtr, const ConstMCTruth *labelsDigPtr, MCTruth *labelsClusPTr)
std::array< Label, MaxLabels > labelsBuff
std::vector< ThreadStat > stats
CompClusCont compClusters
preclusters info
void resetColumn(int *buff)
reset column buffer, for the performance reasons we use memset
void updateChip(const ChipPixelData *curChipData, uint32_t ip)
methods and transient data used within a thread
o2::InteractionRecord ir(0, 0)