24#ifndef GPUCA_GPUCODE_DEVICE
38 for (
uint32_t i = 0;
i < GPUTPCGeometry::NROWS + 1;
i++) {
41 for (
uint32_t i = 0;
i < GPUTPCGeometry::NROWS;
i++) {
42 mRows[
i].mX = GPUTPCGeometry::Row2X(
i);
43 mRows[
i].mMaxY = CAMath::Tan(p.dAlpha / 2.f) * mRows[
i].mX;
50 mClusterIdOffset = clusterIdOffset;
55 int32_t hitMemCount = GPUTPCGeometry::NROWS * constants::GPU_ROWALIGNMENT + mNumberOfHits;
56 const uint32_t kVectorAlignment = 256;
57 mNumberOfHitsPlusAlign =
GPUProcessor::nextMultipleOf<(kVectorAlignment > constants::GPU_ROWALIGNMENT ? kVectorAlignment : constants::GPU_ROWALIGNMENT) /
sizeof(
int32_t)>(hitMemCount);
75 const int32_t firstHitInBinSize = GetGridSize(mNumberOfHits, GPUTPCGeometry::NROWS) + GPUTPCGeometry::NROWS * constants::GPU_ROWALIGNMENT /
sizeof(
int32_t);
102 maxY =
row->mMaxY * 2.f / constants::GRID_MIN_BIN_SIZE + 1;
103 maxZ = (mem->param.continuousMaxTimeBin > 0 ? (mem->calibObjects.fastTransform->convTimeToZinTimeFrame(0, 0, mem->param.continuousMaxTimeBin)) : GPUTPCGeometry::TPCLength()) + 50;
104 maxZ =
maxZ / constants::GRID_MIN_BIN_SIZE + 1;
109 return 128 *
nRows + 4 * nHits;
115 float tfFactor = 1.f;
116 if (dz > GPUTPCGeometry::TPCLength() + 20.f) {
117 tfFactor = dz / GPUTPCGeometry::TPCLength();
118 dz = GPUTPCGeometry::TPCLength();
120 const float norm = CAMath::InvSqrt(
row->mNHits / tfFactor);
121 float sy = CAMath::Min(CAMath::Max((
yMax - yMin) * norm, constants::GRID_MIN_BIN_SIZE), constants::GRID_MAX_BIN_SIZE);
122 float sz = CAMath::Min(CAMath::Max(dz * norm, constants::GRID_MIN_BIN_SIZE), constants::GRID_MAX_BIN_SIZE);
124 GetMaxNBins(mem,
row, maxy, maxz);
125 int32_t ny = CAMath::Max(1, CAMath::Min<int32_t>(maxy, (
yMax - yMin) / sy + 1));
126 int32_t nz = CAMath::Max(1, CAMath::Min<int32_t>(maxz, (
zMax -
zMin) / sz + 1));
149 row.mGrid.CreateEmpty();
151 row.mHitNumberOffset = 0;
158 for (int32_t
i = 0;
i < 4;
i++) {
172 static_assert(
sizeof(*YZData) <= (
sizeof(*mLinkUpData) +
sizeof(*mLinkDownData)),
"Cannot reuse memory");
173 static_assert(
sizeof(*binMemory) <=
sizeof(*mHitWeights),
"Cannot reuse memory");
176 for (
uint32_t rowIndex = iBlock; rowIndex < GPUTPCGeometry::NROWS; rowIndex += nBlocks) {
182 const uint32_t NumberOfClusters = mem->ioPtrs.clustersNative->nClusters[
iSector][rowIndex];
183 const uint32_t RowOffset = mem->ioPtrs.clustersNative->clusterOffset[
iSector][rowIndex] - mem->ioPtrs.clustersNative->clusterOffset[
iSector][0];
187 row.mFirstHitInBinOffset = CAMath::nextMultipleOf<constants::GPU_ROWALIGNMENT /
sizeof(
calink)>(GetGridSize(RowOffset, rowIndex) + rowIndex * constants::GPU_ROWALIGNMENT /
sizeof(
int32_t));
189 if (NumberOfClusters >= maxN) {
191 mem->errorCodes.raiseError(GPUErrors::ERROR_SECTORDATA_HITINROW_OVERFLOW,
iSector * 1000 + rowIndex, NumberOfClusters, maxN);
192 SetRowGridEmpty(
row);
205 if (NumberOfClusters == 0) {
207 SetRowGridEmpty(
row);
212 for (
uint32_t i = iThread;
i < NumberOfClusters;
i += nThreads) {
214 GPUTPCConvertImpl::convert(*mem,
iSector, rowIndex, mem->ioPtrs.clustersNative->clusters[
iSector][rowIndex][
i].getPad(), mem->ioPtrs.clustersNative->clusters[
iSector][rowIndex][
i].getTime(),
x,
y,
z);
216 YZData[RowOffset +
i] = CAMath::MakeFloat2(
y,
z);
220 row.mNHits = NumberOfClusters;
221 row.mHitNumberOffset = CAMath::nextMultipleOf<constants::GPU_ROWALIGNMENT /
sizeof(
calink)>(RowOffset + rowIndex * constants::GPU_ROWALIGNMENT /
sizeof(
calink));
224#ifdef GPUCA_HAVE_ATOMIC_MINMAX_FLOAT
225 CAMath::AtomicMinShared(&tmpMinMax[0], yMin);
226 CAMath::AtomicMaxShared(&tmpMinMax[1],
yMax);
227 CAMath::AtomicMinShared(&tmpMinMax[2],
zMin);
228 CAMath::AtomicMaxShared(&tmpMinMax[3],
zMax);
230 for (int32_t
i = 0;
i < nThreads;
i++) {
233 if (tmpMinMax[0] > yMin) {
236 if (tmpMinMax[1] <
yMax) {
239 if (tmpMinMax[2] >
zMin) {
242 if (tmpMinMax[3] <
zMax) {
250 CreateGrid(mem, &
row, tmpMinMax[0], tmpMinMax[1], tmpMinMax[2], tmpMinMax[3]);
254 const int32_t numberOfBins = grid.N();
255 constexpr const int32_t maxBins =
sizeof(
calink) < 4 ? (int32_t)(1ul << (
sizeof(
calink) * 8)) : 0x7FFFFFFF;
256 if (
sizeof(
calink) < 4 && numberOfBins >= maxBins) {
258 mem->errorCodes.raiseError(GPUErrors::ERROR_SECTORDATA_BIN_OVERFLOW,
iSector * 1000 + rowIndex, numberOfBins, maxBins);
259 SetRowGridEmpty(
row);
263 const uint32_t nn = numberOfBins + grid.Ny() + 3;
264 const uint32_t maxnn = GetGridSize(NumberOfClusters, 1);
267 mem->errorCodes.raiseError(GPUErrors::ERROR_SECTORDATA_FIRSTHITINBIN_OVERFLOW,
iSector,
nn, maxnn);
268 SetRowGridEmpty(
row);
275 for (int32_t bin = iThread; bin < numberOfBins; bin += nThreads) {
279 for (
uint32_t hitIndex = iThread; hitIndex <
row.mNHits; hitIndex += nThreads) {
280 const int32_t globalHitIndex = RowOffset + hitIndex;
281 const calink bin =
row.mGrid.GetBin(YZData[globalHitIndex].
x, YZData[globalHitIndex].
y);
283 bins[hitIndex] = bin;
284 CAMath::AtomicAdd(&
c[bin], 1u);
290 for (int32_t bin = 0; bin < numberOfBins; ++bin) {
294 for (
uint32_t bin = numberOfBins; bin <
nn; bin++) {
300 constexpr float maxVal = (((
int64_t)1 << (
sizeof(
cahit) < 3 ?
sizeof(
cahit) * 8 : 24)) - 1);
301 constexpr float packingConstant = 1.f / (maxVal - 2.f);
302 const float y0 =
row.mGrid.YMin();
303 const float z0 =
row.mGrid.ZMin();
304 const float stepY = (
row.mGrid.YMax() -
y0) * packingConstant;
305 const float stepZ = (
row.mGrid.ZMax() - z0) * packingConstant;
306 const float stepYi = 1.f / stepY;
307 const float stepZi = 1.f / stepZ;
314 row.mHstepYi = stepYi;
315 row.mHstepZi = stepZi;
320 for (
uint32_t hitIndex = iThread; hitIndex <
row.mNHits; hitIndex += nThreads) {
322 const calink ind = CAMath::AtomicAdd(&
c[bin], (
calink)-1) - 1;
323 const int32_t globalBinsortedIndex =
row.mHitNumberOffset + ind;
324 const int32_t globalHitIndex = RowOffset + hitIndex;
327 mClusterDataIndex[globalBinsortedIndex] = RowOffset + hitIndex;
329 const float xx = ((YZData[globalHitIndex].
x -
y0) * stepYi) + .5;
330 const float yy = ((YZData[globalHitIndex].
y - z0) * stepZi) + .5;
331#if !defined(GPUCA_GPUCODE) && !defined(NDEBUG)
332 if (xx < 0 || yy < 0 || xx > maxVal || yy > maxVal) {
333 std::cout <<
"!!!! hit packing error!!! " << xx <<
" " << yy <<
" (" << maxVal <<
")" << std::endl;
338 mHitData[globalBinsortedIndex].x = (
cahit)xx;
339 mHitData[globalBinsortedIndex].y = (
cahit)yy;
344 if (iThread == 0 && !mem->param.par.continuousTracking) {
345 const float maxAbsZ = CAMath::Max(CAMath::Abs(tmpMinMax[2]), CAMath::Abs(tmpMinMax[3]));
347 mem->errorCodes.raiseError(GPUErrors::ERROR_SECTORDATA_Z_OVERFLOW,
iSector, (
uint32_t)maxAbsZ);
348 SetRowGridEmpty(
row);
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 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 Print launch bounds used for RTC code as debugging for exit after Allow RTC with slave GPUReconstruction instances with optConstexpr and optSpecialcode Maximum number of RTC cache files per backend in the cache the oldest are Prepend RTC compilation commands by this string Load a parameter object containing the launch bounds from a file h configStandalone Processing proc_param TPC Cluster Z Error Parameterization h nn
bounded_vector< float > bins
static void computePointerWithAlignment(T *&basePtr, S *&objPtr, size_t nEntries=1)
static constexpr size_t nextMultipleOf(size_t size)
void SetClusterData(int32_t nClusters, int32_t clusterIdOffset)
void InitializeRows(const GPUParam &p)
void * SetPointersScratch(void *mem, bool idsOnGPU)
void * SetPointersWeights(void *mem)
void * SetPointersClusterIds(void *mem, bool idsOnGPU)
void * SetPointersLinks(void *mem)
void * SetPointersRows(void *mem)
GLfloat GLfloat GLfloat GLfloat GLfloat maxY
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat maxZ
GLuint GLfloat GLfloat y0
GLdouble GLdouble GLdouble z
GPUd() const expr uint32_t MultivariatePolynomialHelper< Dim
typename std::vector< T, vecpod_allocator< T > > vecpod