15#include <fmt/format.h>
28 gsl::span<const o2::mch::Digit>
digits,
30 : mTimeClusterSize(timeClusterSize),
31 mNbinsInOneWindow(nBins),
32 mBinWidth(timeClusterSize / nBins),
35 mImprovePeakSearch(improvePeakSearch),
37 mLastSavedTimeBin(-1),
47void ROFTimeClusterFinder::initTimeBins()
49 static constexpr uint32_t maxNTimeBins = 1e7;
54 if (mInputROFs.empty()) {
60 auto tfSize = mInputROFs.back().getBCData().differenceInBC(mFirstIR);
61 mNbinsInOneTF = tfSize / mBinWidth + 1;
62 if (mNbinsInOneTF > maxNTimeBins) {
63 LOGP(alarm,
"Number of time bins exceeding the limit");
64 mNbinsInOneTF = maxNTimeBins;
66 mTimeBins.resize(mNbinsInOneTF);
70 for (
size_t iRof = 0; iRof < mInputROFs.size(); iRof++) {
71 const auto& rof = mInputROFs[iRof];
72 const auto&
ir = rof.getBCData();
74 auto binIdx = rofBc / mBinWidth;
77 if (rofBc <= previousROFbc || rofBc > tfSize) {
78 LOGP(alarm,
"Wrong ROF ordering");
81 previousROFbc = rofBc;
82 if (rof.getNEntries() < 1) {
83 LOGP(alarm,
"Empty ROF");
88 if (binIdx >= mNbinsInOneTF) {
92 auto& timeBin = mTimeBins[binIdx];
94 if (timeBin.mFirstIdx < 0) {
95 timeBin.mFirstIdx = iRof;
97 timeBin.mLastIdx = iRof;
100 if (mImprovePeakSearch) {
101 auto rofDigits = mDigits.subspan(rof.getFirstIdx(), rof.getNEntries());
102 for (
auto& digit : rofDigits) {
103 if (mIsGoodDigit(digit)) {
108 nDigitsPS = rof.getNEntries();
110 timeBin.mNDigitsPS += nDigitsPS;
114 std::cout <<
"Peak search histogram:" << std::endl;
116 if (mTimeBins[
i].mFirstIdx >= 0) {
117 auto nDigits = mInputROFs[mTimeBins[
i].mLastIdx].getLastIdx() - mInputROFs[mTimeBins[
i].mFirstIdx].getFirstIdx() + 1;
118 std::cout << fmt::format(
"bin {}: {}/{}",
i, mTimeBins[
i].mNDigitsPS, nDigits) << std::endl;
126int32_t ROFTimeClusterFinder::getNextPeak()
128 int32_t sPadding = mNbinsInOneWindow / 2;
131 std::cout <<
"Searching peak from " << mLastSavedTimeBin + 1 << std::endl;
136 for (
int32_t i = mLastSavedTimeBin + sPadding + 1;
i < mNbinsInOneTF;
i++) {
137 auto& peak = mTimeBins[
i];
144 for (
int j =
i - sPadding;
j <
i;
j++) {
145 if (
j >= 0 && peak <= mTimeBins[
j]) {
151 for (
int j =
i + 1;
j <=
i + sPadding;
j++) {
152 if (
j < mNbinsInOneTF && peak < mTimeBins[
j]) {
163 auto nDigits = mInputROFs[peak.mLastIdx].getLastIdx() - mInputROFs[peak.mFirstIdx].getFirstIdx() + 1;
164 std::cout << fmt::format(
"new peak found at bin {}, entries = {}/{}",
i, peak.mNDigitsPS, nDigits) << std::endl;
174void ROFTimeClusterFinder::storeROF(
int32_t firstBin,
int32_t lastBin)
177 std::cout << fmt::format(
"Storing ROF from bin range [{},{}]", firstBin, lastBin) << std::endl;
183 if (lastBin >= mNbinsInOneTF) {
184 lastBin = mNbinsInOneTF - 1;
189 for (
int32_t j = firstBin;
j <= lastBin;
j++) {
190 auto& timeBin = mTimeBins[
j];
191 if (timeBin.mFirstIdx < 0) {
195 if (rofFirstIdx < 0) {
196 rofFirstIdx = timeBin.mFirstIdx;
198 rofLastIdx = timeBin.mLastIdx;
201 auto size = timeBin.mLastIdx - timeBin.mFirstIdx + 1;
202 auto nDigits = mInputROFs[timeBin.mLastIdx].getLastIdx() - mInputROFs[timeBin.mFirstIdx].getFirstIdx() + 1;
203 std::cout << fmt::format(
" bin {}: firstIdx={} size={} ndigits={}/{}",
j, timeBin.mFirstIdx,
size, timeBin.mNDigitsPS, nDigits) << std::endl;
208 if (rofFirstIdx >= 0) {
210 auto& firstRofInCluster = mInputROFs[rofFirstIdx];
211 auto&
irFirst = firstRofInCluster.getBCData();
212 auto& lastRofInCluster = mInputROFs[rofLastIdx];
213 auto&
irLast = lastRofInCluster.getBCData();
216 auto firstDigitIdx = firstRofInCluster.getFirstIdx();
217 auto nDigits = lastRofInCluster.getLastIdx() - firstDigitIdx + 1;
221 auto bcWidth = bcDiff + lastRofInCluster.getBCWidth();
224 mOutputROFs.emplace_back(
irFirst, firstDigitIdx, nDigits, bcWidth);
227 std::cout << fmt::format(
"new ROF stored: firstDigitIdx={} size={} bcWidth={}", firstDigitIdx, nDigits, bcWidth) << std::endl;
231 mLastSavedTimeBin = lastBin;
239 std::cout <<
"\n\n==================\n[ROFTimeClusterFinder] processing new TF\n"
246 mLastSavedTimeBin = -1;
248 while ((peak = getNextPeak()) >= 0) {
249 int32_t peakStart = peak - mNbinsInOneWindow / 2;
250 int32_t peakEnd = peakStart + mNbinsInOneWindow - 1;
255 std::cout << fmt::format(
"peakStart={} mLastSavedTimeBin={}", peakStart, mLastSavedTimeBin) << std::endl;
257 while ((peakStart - mLastSavedTimeBin) > 1) {
258 int32_t firstBin = mLastSavedTimeBin + 1;
259 int32_t lastBin = firstBin + mNbinsInOneWindow - 1;
260 if (lastBin >= peakStart) {
261 lastBin = peakStart - 1;
264 storeROF(firstBin, lastBin);
266 storeROF(peakStart, peakEnd);
280 bufSize = mOutputROFs.size() * sizeOfROFRecord;
288 for (
size_t i = 0;
i < mOutputROFs.size();
i++) {
289 auto& rof = mOutputROFs[
i];
290 memcpy(p, &(rof), sizeOfROFRecord);
294 return reinterpret_cast<char*
>(
buf);
301 for (
size_t i = 0;
i < mInputROFs.size();
i++) {
302 auto& rof = mInputROFs[
i];
303 const auto ir = rof.getBCData();
304 std::cout << fmt::format(
" ROF {} RANGE {}-{} SIZE {} IR {}-{},{}\n",
i, rof.getFirstIdx(), rof.getLastIdx(),
313 for (
size_t i = 0;
i < mOutputROFs.size();
i++) {
314 auto& rof = mOutputROFs[
i];
315 std::cout << fmt::format(
" ROF {} RANGE {}-{} SIZE {} IR {}-{},{}\n",
i, rof.getFirstIdx(), rof.getLastIdx(),
316 rof.getNEntries(), rof.getBCData().orbit, rof.getBCData().bc, rof.getBCData().toLong());
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc true
Class to group the fired pads according to their time stamp.
char * saveROFRsToBuffer(size_t &bufSize)
stores the output ROFs into a flat memory buffer
ROFTimeClusterFinder(gsl::span< const o2::mch::ROFRecord > rofs, gsl::span< const o2::mch::Digit > digits, uint32_t timeClusterSize, uint32_t nBins, bool improvePeakSearch, bool debug)
void process()
process the digit ROFs and create the time clusters
void dumpInputROFs()
debugging output
GLenum GLuint GLenum GLsizei const GLchar * buf
DigitFilter createDigitFilter(uint32_t minADC, bool rejectBackground, bool selectSignal, const StatusMap &statusMap={}, uint32_t statusMask=0)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint16_t bc
bunch crossing ID of interaction
int64_t differenceInBC(const InteractionRecord &other) const
o2::InteractionRecord ir(0, 0)
std::vector< Digit > digits