Project
Loading...
Searching...
No Matches
HwClusterer.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef ALICEO2_TPC_HWClusterer_H_
17#define ALICEO2_TPC_HWClusterer_H_
18
19#include <Vc/Vc>
20
23
26
27#include <vector>
28#include <utility>
29#include <memory>
30
31namespace o2
32{
33namespace tpc
34{
35
36class Digit;
37class ClusterHardware;
38
41class HwClusterer : public Clusterer
42{
43 private:
48 std::vector<ClusterHardwareContainer8kb>* clusterOutputContainer,
49 MCLabelContainer* labelOutput);
50
51 public:
57 std::vector<ClusterHardwareContainer8kb>* clusterOutput,
58 int sectorid,
59 MCLabelContainer* labelOutput = nullptr);
60
62 ~HwClusterer() override = default;
63
65 HwClusterer(HwClusterer const& other) = default;
66
68 void init();
69
74 void process(gsl::span<o2::tpc::Digit const> const& digits, ConstMCLabelContainerView const& mcDigitTruth) override;
75 void process(gsl::span<o2::tpc::Digit const> const& digits, ConstMCLabelContainerView const& mcDigitTruth, bool clearContainerFirst);
76
81 void finishProcess(gsl::span<o2::tpc::Digit const> const& digits, ConstMCLabelContainerView const& mcDigitTruth) override;
82 void finishProcess(gsl::span<o2::tpc::Digit const> const& digits, ConstMCLabelContainerView const& mcDigitTruth, bool clearContainerFirst);
83
86 void setContinuousReadout(bool isContinuous);
87
90 void setPeakChargeThreshold(unsigned charge);
91
95
98 void setRejectSinglePadClusters(bool doReject);
99
102 void setRejectSingleTimeClusters(bool doReject);
103
106 void setRejectLaterTimebin(bool doReject);
107
112 void setSplittingMode(short mode);
113
114 private:
115 /*
116 * Helper functions
117 */
118
125 void hwClusterProcessor(Vc::uint_m peakMask, unsigned qMaxIndex, short centerPad, int centerTime, unsigned short row);
126
132 void hwPeakFinder(unsigned qMaxIndex, short centerPad, int mappedCenterTime, unsigned short row);
133
147 void updateCluster(const Vc::uint_m selectionMask, int row, short centerPad, int centerTime, short dp, short dt, Vc::uint_v& qTot, Vc::int_v& pad, Vc::int_v& time, Vc::int_v& sigmaPad2, Vc::int_v& sigmaTime2, std::vector<std::unique_ptr<std::vector<std::pair<MCCompLabel, unsigned>>>>& mcLabels, Vc::uint_m splitMask = Vc::Mask<uint>(false));
148
151 void writeOutputWithTimeOffset(int timeOffset);
152
155 void computeClusterForTime(int timebin);
156
159 void findPeaksForTime(int timebin);
160
163 void finishFrame(bool clear = false);
164
167 void clearBuffer(int timebin);
168
171 short getFirstSetBitOfField();
172
176 int mapTimeInRange(int time);
177
180 Vc::uint_v getFpOfADC(const Vc::uint_v value);
181
182 /*
183 * class members
184 */
185 static const int mTimebinsInBuffer = 6;
186
187 unsigned short mNumRows;
188 unsigned short mNumRowSets;
189 short mCurrentMcContainerInBuffer;
190 short mSplittingMode;
191 int mClusterSector;
192 int mPreviousTimebin;
193 int mFirstTimebin;
194 int mLastTimebin;
195 unsigned mLastHB;
196 unsigned mPeakChargeThreshold;
197 unsigned mContributionChargeThreshold;
198 unsigned mClusterCounter;
199 bool mIsContinuousReadout;
200 bool mRejectSinglePadClusters;
201 bool mRejectSingleTimeClusters;
202 bool mRejectLaterTimebin;
203
204 std::vector<unsigned short> mPadsPerRow;
205 std::vector<unsigned short> mPadsPerRowSet;
206 std::vector<unsigned short> mGlobalRowToRegion;
207 std::vector<unsigned short> mGlobalRowToLocalRow;
208 std::vector<unsigned short> mGlobalRowToVcIndex;
209 std::vector<unsigned short> mGlobalRowToRowSet;
210 std::vector<std::vector<Vc::uint_v>> mDataBuffer;
211 std::vector<std::vector<Vc::int_v>> mIndexBuffer;
212 std::vector<std::shared_ptr<MCLabelContainer const>> mMCtruth;
213
214 std::vector<std::unique_ptr<std::vector<ClusterHardware>>> mTmpClusterArray;
215 std::vector<std::unique_ptr<std::vector<std::vector<std::pair<MCCompLabel, unsigned>>>>> mTmpLabelArray;
216
217 std::vector<ClusterHardwareContainer8kb>* mClusterArray;
218 MCLabelContainer* mClusterMcLabelArray;
219};
220
221inline void HwClusterer::process(gsl::span<o2::tpc::Digit const> const& digits, ConstMCLabelContainerView const& mcDigitTruth)
222{
223 process(digits, mcDigitTruth, true);
224}
225
226inline void HwClusterer::finishProcess(gsl::span<o2::tpc::Digit const> const& digits, ConstMCLabelContainerView const& mcDigitTruth)
227{
228 finishProcess(digits, mcDigitTruth, true);
229}
230
231inline void HwClusterer::setContinuousReadout(bool isContinuous)
232{
233 mIsContinuousReadout = isContinuous;
234}
235
237{
238 mPeakChargeThreshold = charge;
239}
240
242{
243 mContributionChargeThreshold = charge;
244}
245
247{
248 mRejectSinglePadClusters = doReject;
249}
250
252{
253 mRejectSingleTimeClusters = doReject;
254}
255
256inline void HwClusterer::setRejectLaterTimebin(bool doReject)
257{
258 mRejectLaterTimebin = doReject;
259}
260
262{
263 mSplittingMode = mode;
264}
265
266inline int HwClusterer::mapTimeInRange(int time)
267{
268 return (mTimebinsInBuffer + (time % mTimebinsInBuffer)) % mTimebinsInBuffer;
269}
270
271inline Vc::uint_v HwClusterer::getFpOfADC(const Vc::uint_v value)
272{
273 return value & 0x3FFF;
274}
275
276inline short HwClusterer::getFirstSetBitOfField()
277{
278 for (short i = 0; i < mTimebinsInBuffer; ++i) {
279 if ((mCurrentMcContainerInBuffer >> i) & 0x1) {
280 return i;
281 }
282 }
283 return -1;
284}
285
286} // namespace tpc
287} // namespace o2
288
289#endif
A const (ready only) version of MCTruthContainer.
Helper class for memory management of TPC Data Formats, external from the actual data type classes to...
int16_t charge
Definition RawEventData.h:5
int16_t time
Definition RawEventData.h:4
int32_t i
Base class for TPC clusterer.
Base Class for TPC clusterer.
Definition Clusterer.h:36
Class for TPC HW cluster finding.
Definition HwClusterer.h:42
void process(gsl::span< o2::tpc::Digit const > const &digits, ConstMCLabelContainerView const &mcDigitTruth) override
void setRejectLaterTimebin(bool doReject)
void setRejectSinglePadClusters(bool doReject)
void init()
initialize the clusterer from HwClustererParam
void setContinuousReadout(bool isContinuous)
void setContributionChargeThreshold(unsigned charge)
void finishProcess(gsl::span< o2::tpc::Digit const > const &digits, ConstMCLabelContainerView const &mcDigitTruth) override
void setPeakChargeThreshold(unsigned charge)
HwClusterer(HwClusterer const &other)=default
Copy Constructor.
void setSplittingMode(short mode)
~HwClusterer() override=default
Destructor.
void setRejectSingleTimeClusters(bool doReject)
GLenum mode
Definition glcorearb.h:266
GLsizei const GLfloat * value
Definition glcorearb.h:819
o2::cpv::Digit Digit
o2::dataformats::MCTruthContainer< o2::MCCompLabel > MCLabelContainer
o2::dataformats::ConstMCTruthContainerView< o2::MCCompLabel > ConstMCLabelContainerView
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
VectorOfTObjectPtrs other
vec clear()
std::vector< Digit > digits
std::vector< int > row