|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | + |
| 11 | +/// \file GPUTPCCFCheckPadBaseline.h |
| 12 | +/// \author Felix Weiglhofer |
| 13 | + |
| 14 | +#include "GPUTPCCFCheckPadBaseline.h" |
| 15 | +#include "Array2D.h" |
| 16 | +#include "PackedCharge.h" |
| 17 | +#include "clusterFinderDefs.h" |
| 18 | + |
| 19 | +using namespace GPUCA_NAMESPACE::gpu; |
| 20 | +using namespace GPUCA_NAMESPACE::gpu::tpccf; |
| 21 | + |
| 22 | +template <> |
| 23 | +GPUd() void GPUTPCCFCheckPadBaseline::Thread<0>(int nBlocks, int nThreads, int iBlock, int iThread, GPUSharedMemory& smem, processorType& clusterer) |
| 24 | +{ |
| 25 | + static_assert(TPC_MAX_FRAGMENT_LEN % NumOfCachedTimebins == 0); |
| 26 | + |
| 27 | + Array2D<PackedCharge> chargeMap(reinterpret_cast<PackedCharge*>(clusterer.mPchargeMap)); |
| 28 | + |
| 29 | + int totalCharges = 0; |
| 30 | + int consecCharges = 0; |
| 31 | + int maxConsecCharges = 0; |
| 32 | + |
| 33 | + int localPadId = iThread / NumOfCachedTimebins; |
| 34 | + int localTimeBin = iThread % NumOfCachedTimebins; |
| 35 | + bool handlePad = localTimeBin == 0; |
| 36 | + int basePad = iBlock * PadsPerBlock; |
| 37 | + |
| 38 | + CfFragment& fragment = clusterer.mPmemory->fragment; |
| 39 | + |
| 40 | + ChargePos basePos = padToChargePos(basePad + localPadId, clusterer); |
| 41 | + |
| 42 | + for (tpccf::TPCFragmentTime t = localTimeBin + fragment.firstNonOverlapTimeBin(); t < fragment.lastNonOverlapTimeBin(); t += NumOfCachedTimebins) { |
| 43 | + ChargePos pos = basePos.delta({0, t}); |
| 44 | + smem.charges[localPadId][localTimeBin] = (pos.valid()) ? chargeMap[pos].unpack() : 0; |
| 45 | + GPUbarrierWarp(); |
| 46 | + if (handlePad) { |
| 47 | + for (int i = 0; i < NumOfCachedTimebins; i++) { |
| 48 | + Charge q = smem.charges[localPadId][i]; |
| 49 | + totalCharges += (q > 0); |
| 50 | + consecCharges = (q > 0) ? consecCharges + 1 : 0; |
| 51 | + maxConsecCharges = CAMath::Max(consecCharges, maxConsecCharges); |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + GPUbarrierWarp(); |
| 57 | + |
| 58 | + if (handlePad) { |
| 59 | + int totalChargesBaseline = clusterer.Param().rec.maxTimeBinAboveThresholdIn1000Bin * fragment.lengthWithoutOverlap() / 1000; |
| 60 | + int consecChargesBaseline = clusterer.Param().rec.maxConsecTimeBinAboveThreshold; |
| 61 | + bool hasLostBaseline = (totalChargesBaseline > 0 && totalCharges >= totalChargesBaseline) || (consecChargesBaseline > 0 && maxConsecCharges >= consecChargesBaseline); |
| 62 | + clusterer.mPpadHasLostBaseline[basePad + localPadId] |= hasLostBaseline; |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +GPUd() ChargePos GPUTPCCFCheckPadBaseline::padToChargePos(int pad, const GPUTPCClusterFinder& clusterer) |
| 67 | +{ |
| 68 | + const GPUTPCGeometry& geo = clusterer.Param().tpcGeometry; |
| 69 | + |
| 70 | + int padOffset = 0; |
| 71 | + for (Row r = 0; r < TPC_NUM_OF_ROWS; r++) { |
| 72 | + int padInRow = pad - padOffset; |
| 73 | + if (0 <= padInRow && padInRow < geo.NPads(r)) { |
| 74 | + return ChargePos{r, Pad(padInRow), 0}; |
| 75 | + } |
| 76 | + padOffset += geo.NPads(r); |
| 77 | + } |
| 78 | + |
| 79 | + return ChargePos{0, 0, INVALID_TIME_BIN}; |
| 80 | +} |
0 commit comments