2020// | *|
2121#define _ALLOW_DIAGONAL_ALPIDE_CLUSTERS_
2222
23+ #include < algorithm>
2324#include < utility>
2425#include < vector>
2526#include < cstring>
@@ -94,18 +95,10 @@ class Clusterer
9495 }
9596 void adjust (uint16_t row, uint16_t col)
9697 {
97- if (row < rowMin) {
98- rowMin = row;
99- }
100- if (row > rowMax) {
101- rowMax = row;
102- }
103- if (col < colMin) {
104- colMin = col;
105- }
106- if (col > colMax) {
107- colMax = col;
108- }
98+ rowMin = std::min (row, rowMin);
99+ rowMax = std::max (row, rowMax);
100+ colMin = std::min (col, colMin);
101+ colMax = std::max (col, colMax);
109102 }
110103 };
111104
@@ -121,6 +114,10 @@ class Clusterer
121114 };
122115
123116 struct ClustererThread {
117+ struct PreCluster {
118+ int head = 0 ; // index of precluster head in the pixels
119+ int index = 0 ;
120+ };
124121 Clusterer* parent = nullptr ; // parent clusterer
125122 int id = -1 ;
126123 // buffers for entries in preClusterIndices in 2 columns, to avoid boundary checks, we reserve
@@ -133,12 +130,11 @@ class Clusterer
133130 // pixels[].first is the index of the next pixel of the same precluster in the pixels
134131 // pixels[].second is the index of the referred pixel in the ChipPixelData (element of mChips)
135132 std::vector<std::pair<int , uint32_t >> pixels;
136- std::vector<int > preClusterHeads; // index of precluster head in the pixels
137- std::vector<int > preClusterIndices;
138133 uint16_t currCol = 0xffff ; // /< Column being processed
139134 bool noLeftCol = true ; // /< flag that there is no column on the left to check
140135 std::array<Label, MaxLabels> labelsBuff; // ! temporary buffer for building cluster labels
141136 std::vector<PixelData> pixArrBuff; // ! temporary buffer for pattern calc.
137+ std::vector<PreCluster> preClusters; // ! preclusters info
142138 //
143139 // / temporary storage for the thread output
144140 CompClusCont compClusters;
@@ -152,10 +148,11 @@ class Clusterer
152148 // /< swap current and previous column buffers
153149 void swapColumnBuffers () { std::swap (prev, curr); }
154150
151+ // /< add cluster at row (entry ip in the ChipPixeData) to the precluster with given index
155152 // /< add cluster at row (entry ip in the ChipPixeData) to the precluster with given index
156153 void expandPreCluster (uint32_t ip, uint16_t row, int preClusIndex)
157154 {
158- auto & firstIndex = preClusterHeads[preClusterIndices [preClusIndex]] ;
155+ auto & firstIndex = preClusters[preClusters [preClusIndex]. index ]. head ;
159156 pixels.emplace_back (firstIndex, ip);
160157 firstIndex = pixels.size () - 1 ;
161158 curr[row] = preClusIndex;
@@ -164,11 +161,10 @@ class Clusterer
164161 // /< add new precluster at given row of current column for the fired pixel with index ip in the ChipPixelData
165162 void addNewPrecluster (uint32_t ip, uint16_t row)
166163 {
167- preClusterHeads.push_back (pixels.size ());
164+ int lastIndex = preClusters.size ();
165+ preClusters.emplace_back (pixels.size (), lastIndex);
168166 // new head does not point yet (-1) on other pixels, store just the entry of the pixel in the ChipPixelData
169167 pixels.emplace_back (-1 , ip);
170- int lastIndex = preClusterIndices.size ();
171- preClusterIndices.push_back (lastIndex);
172168 curr[row] = lastIndex; // store index of the new precluster in the current column buffer
173169 }
174170
@@ -212,19 +208,25 @@ class Clusterer
212208 bool isContinuousReadOut () const { return mContinuousReadout ; }
213209 void setContinuousReadOut (bool v) { mContinuousReadout = v; }
214210
211+ bool isDropHugeClusters () const { return mDropHugeClusters ; }
212+ void setDropHugeClusters (bool v) { mDropHugeClusters = v; }
213+
215214 int getMaxBCSeparationToMask () const { return mMaxBCSeparationToMask ; }
216215 void setMaxBCSeparationToMask (int n) { mMaxBCSeparationToMask = n; }
217216
218217 int getMaxRowColDiffToMask () const { return mMaxRowColDiffToMask ; }
219218 void setMaxRowColDiffToMask (int v) { mMaxRowColDiffToMask = v; }
220219
221- int getMaxROFDepthToSquash () const { return mSquashingDepth ; }
220+ int getMaxROFDepthToSquash (int layer = - 1 ) const { return (layer < 0 ) ? mSquashingDepth : mSquashingLayerDepth [layer] ; }
222221 void setMaxROFDepthToSquash (int v) { mSquashingDepth = v; }
222+ void addMaxROFDepthToSquash (int v) { mSquashingLayerDepth .push_back (v); }
223223
224- int getMaxBCSeparationToSquash () const { return mMaxBCSeparationToSquash ; }
224+ int getMaxBCSeparationToSquash (int layer = - 1 ) const { return (layer < 0 ) ? mMaxBCSeparationToSquash : mMaxBCSeparationToSquashLayer [layer] ; }
225225 void setMaxBCSeparationToSquash (int n) { mMaxBCSeparationToSquash = n; }
226+ void addMaxBCSeparationToSquash (int n) { mMaxBCSeparationToSquashLayer .push_back (n); }
226227
227- void print () const ;
228+ void print (bool showsTiming) const ;
229+ void reset ();
228230 void clear ();
229231
230232 // /< load the dictionary of cluster topologies
@@ -249,6 +251,7 @@ class Clusterer
249251
250252 // clusterization options
251253 bool mContinuousReadout = true ; // /< flag continuous readout
254+ bool mDropHugeClusters = false ; // /< don't include clusters that would be split in more than one
252255
253256 // /< mask continuosly fired pixels in frames separated by less than this amount of BCs (fired from hit in prev. ROF)
254257 int mMaxBCSeparationToMask = static_cast <int >(6000 . / o2::constants::lhc::LHCBunchSpacingNS + 10 );
@@ -258,6 +261,8 @@ class Clusterer
258261 // /< Squashing options
259262 int mSquashingDepth = 0 ; // /< squashing is applied to next N rofs
260263 int mMaxBCSeparationToSquash = 6000 . / o2::constants::lhc::LHCBunchSpacingNS + 10 ;
264+ std::vector<int > mSquashingLayerDepth ;
265+ std::vector<int > mMaxBCSeparationToSquashLayer ;
261266
262267 std::vector<std::unique_ptr<ClustererThread>> mThreads ; // buffers for threads
263268 std::vector<ChipPixelData> mChips ; // currently processed ROF's chips data
0 commit comments