Project
Loading...
Searching...
No Matches
GPUO2InterfaceRefit.cxx
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
14
15#include "GPUO2InterfaceRefit.h"
16#include "GPUO2InterfaceUtils.h"
19#include "GPUParam.h"
21#include "GPUTrackingRefit.h"
22#include "TPCFastTransformPOD.h"
24
25using namespace o2::gpu;
26using namespace o2::tpc;
27
28void GPUO2InterfaceRefit::fillSharedClustersAndOccupancyMap(const ClusterNativeAccess* cl, const gsl::span<const TrackTPC> trks, const TPCClRefElem* trackRef, uint8_t* shmap, uint32_t* ocmap, uint32_t nHbfPerTf, const GPUParam* param)
29{
30 if (!cl || (!shmap && cl->nClustersTotal > 0)) {
31 throw std::runtime_error("Must provide clusters access and preallocated buffer for shared map");
32 }
33 std::unique_ptr<GPUParam> tmpParam;
34 if (param == nullptr) {
35 tmpParam = GPUO2InterfaceUtils::getFullParam(0.f, nHbfPerTf);
36 param = tmpParam.get();
37 }
38 if ((param->rec.tpc.occupancyMapTimeBins || param->rec.tpc.sysClusErrorC12Norm) && ocmap && !nHbfPerTf) {
39 throw std::runtime_error("Must provide nHbfPerTf for occupancy map");
40 }
41 memset(shmap, 0, sizeof(char) * cl->nClustersTotal);
42 for (uint32_t i = 0; i < trks.size(); i++) {
43 for (int32_t j = 0; j < trks[i].getNClusterReferences(); j++) {
44 size_t idx = &trks[i].getCluster(trackRef, j, *cl) - cl->clustersLinear;
45 shmap[idx] = shmap[idx] ? 2 : 1;
46 }
47 }
48 std::vector<uint32_t> tmp;
49 uint32_t* binmap = nullptr;
50 if (ocmap && nHbfPerTf) {
51 tmp.resize(param->rec.tpc.occupancyMapTimeBinsAverage ? GPUTPCClusterOccupancyMapBin::getNBins(*param) : 0, 0);
52 binmap = param->rec.tpc.occupancyMapTimeBinsAverage ? tmp.data() : (ocmap + 2);
53 *ocmap = cl->nClustersTotal / nHbfPerTf;
54 if (param->rec.tpc.occupancyMapTimeBins) {
55 ocmap[1] = param->rec.tpc.occupancyMapTimeBins * 0x10000 + param->rec.tpc.occupancyMapTimeBinsAverage;
56 }
57 }
58
59 for (uint32_t i = 0; i < cl->nClustersTotal; i++) {
60 shmap[i] = (shmap[i] > 1 ? GPUTPCGMMergedTrackHit::flagShared : 0) | cl->clustersLinear[i].getFlags();
61 if (binmap) {
62 binmap[(uint32_t)(cl->clustersLinear[i].getTime() / param->rec.tpc.occupancyMapTimeBins)]++;
63 }
64 }
65
66 if (ocmap && nHbfPerTf && param->rec.tpc.occupancyMapTimeBinsAverage) {
67 for (uint32_t bin = 0; bin < GPUTPCClusterOccupancyMapBin::getNBins(*param); bin++) {
68 int32_t binmin = CAMath::Max<int32_t>(0, bin - param->rec.tpc.occupancyMapTimeBinsAverage);
69 int32_t binmax = CAMath::Min<int32_t>(GPUTPCClusterOccupancyMapBin::getNBins(*param), bin + param->rec.tpc.occupancyMapTimeBinsAverage + 1);
70 uint32_t sum = 0;
71 for (int32_t i = binmin; i < binmax; i++) {
72 sum += binmap[i];
73 }
74 sum /= binmax - binmin;
75 ocmap[2 + bin] = sum;
76 }
77 }
78}
79
81{
82 std::unique_ptr<GPUParam> tmpParam;
83 if (param == nullptr) {
84 tmpParam = GPUO2InterfaceUtils::getFullParam(0.f, nHbfPerTf);
85 param = tmpParam.get();
86 }
87 if ((param->rec.tpc.occupancyMapTimeBins || param->rec.tpc.sysClusErrorC12Norm) && !nHbfPerTf) {
88 throw std::runtime_error("nHbfPerTf must not be zero for creation of the occupancy map");
89 }
90 if (param->rec.tpc.occupancyMapTimeBins) {
91 return (GPUTPCClusterOccupancyMapBin::getNBins(*param) + 2) * sizeof(uint32_t);
92 } else if (param->rec.tpc.sysClusErrorC12Norm) {
93 return sizeof(uint32_t);
94 } else {
95 return 0;
96 }
97}
98
99GPUO2InterfaceRefit::GPUO2InterfaceRefit(const ClusterNativeAccess* cl, const TPCFastTransformPOD* trans, float bzNominalGPU, const TPCClRefElem* trackRef, uint32_t nHbfPerTf, const uint8_t* sharedmap, const uint32_t* occupancymap, int32_t occupancyMapSize, const std::vector<TrackTPC>* trks, o2::base::Propagator* p)
100{
101 mParam = GPUO2InterfaceUtils::getFullParam(bzNominalGPU, nHbfPerTf);
102 size_t expectedOccMapSize = nHbfPerTf ? fillOccupancyMapGetSize(nHbfPerTf, mParam.get()) : 0;
103 if (cl->nClustersTotal) {
104 if (sharedmap == nullptr && trks == nullptr) {
105 throw std::runtime_error("Must provide either shared cluster map or vector of tpc tracks to build the map");
106 }
107 if ((sharedmap == nullptr) ^ (expectedOccMapSize && occupancymap == nullptr)) {
108 throw std::runtime_error("Must provide either both shared cluster map and occupancy map or none of them");
109 }
110 if (sharedmap == nullptr) {
111 mSharedMap.resize(cl->nClustersTotal);
112 sharedmap = mSharedMap.data();
113 mOccupancyMap.resize(expectedOccMapSize / sizeof(*mOccupancyMap.data()));
114 occupancymap = mOccupancyMap.data();
115 occupancyMapSize = expectedOccMapSize;
116 fillSharedClustersAndOccupancyMap(cl, *trks, trackRef, mSharedMap.data(), mOccupancyMap.data(), nHbfPerTf, mParam.get());
117 }
118 }
119 GPUO2InterfaceUtils::paramUseExternalOccupancyMap(mParam.get(), nHbfPerTf, occupancymap, occupancyMapSize);
120
121 mRefit = std::make_unique<GPUTrackingRefit>();
122 mRefit->SetGPUParam(mParam.get());
123 mRefit->SetClusterStateArray(sharedmap);
124 mRefit->SetPropagator(p);
125 mRefit->SetClusterNative(cl);
126 mRefit->SetTrackHitReferences(trackRef);
127 mRefit->SetFastTransform(trans);
128}
129
130void GPUO2InterfaceRefit::updateCalib(const TPCFastTransformPOD* trans, float bzNominalGPU)
131{
132 mParam->UpdateBzOnly(bzNominalGPU);
133 mRefit->SetFastTransform(trans);
134}
135
136int32_t GPUO2InterfaceRefit::RefitTrackAsGPU(o2::tpc::TrackTPC& trk, bool outward, bool resetCov) { return mRefit->RefitTrackAsGPU(trk, outward, resetCov); }
137int32_t GPUO2InterfaceRefit::RefitTrackAsTrackParCov(o2::tpc::TrackTPC& trk, bool outward, bool resetCov) { return mRefit->RefitTrackAsTrackParCov(trk, outward, resetCov); }
138int32_t GPUO2InterfaceRefit::RefitTrackAsGPU(o2::track::TrackParCov& trk, const o2::tpc::TrackTPCClusRef& clusRef, float time0, float* chi2, bool outward, bool resetCov) { return mRefit->RefitTrackAsGPU(trk, clusRef, time0, chi2, outward, resetCov); }
139int32_t GPUO2InterfaceRefit::RefitTrackAsTrackParCov(o2::track::TrackParCov& trk, const o2::tpc::TrackTPCClusRef& clusRef, float time0, float* chi2, bool outward, bool resetCov, int32_t eLossSign) { return mRefit->RefitTrackAsTrackParCov(trk, clusRef, time0, chi2, outward, resetCov, eLossSign); }
140void GPUO2InterfaceRefit::setIgnoreErrorsAtTrackEnds(bool v) { mRefit->mIgnoreErrorsOnTrackEnds = v; }
141void GPUO2InterfaceRefit::setTrackReferenceX(float v) { mParam->rec.tpc.trackReferenceX = v; }
142
Class of a TPC cluster in TPC-native coordinates (row, time)
unsigned int uint32_t
std::vector< double > sum
int32_t i
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
float chi2
uint32_t j
Definition RawData.h:0
POD correction map.
void updateCalib(const o2::gpu::TPCFastTransformPOD *trans, float bzNominalGPU)
int32_t RefitTrackAsTrackParCov(o2::tpc::TrackTPC &trk, bool outward=false, bool resetCov=false)
static size_t fillOccupancyMapGetSize(uint32_t nHbfPerTf, const GPUParam *param=nullptr)
static void fillSharedClustersAndOccupancyMap(const o2::tpc::ClusterNativeAccess *cl, const gsl::span< const o2::tpc::TrackTPC > trks, const o2::tpc::TPCClRefElem *trackRef, uint8_t *shmap, uint32_t *ocmap=nullptr, uint32_t nHbfPerTf=0, const GPUParam *param=nullptr)
GPUO2InterfaceRefit(const o2::tpc::ClusterNativeAccess *cl, const o2::gpu::TPCFastTransformPOD *trans, float bzNominalGPU, const o2::tpc::TPCClRefElem *trackRef, uint32_t nHbfPerTf=0, const uint8_t *sharedmap=nullptr, const uint32_t *occupancymap=nullptr, int32_t occupancyMapSize=-1, const std::vector< o2::tpc::TrackTPC > *trks=nullptr, o2::base::Propagator *p=nullptr)
int32_t RefitTrackAsGPU(o2::tpc::TrackTPC &trk, bool outward=false, bool resetCov=false)
static void paramUseExternalOccupancyMap(GPUParam *param, uint32_t nHbfPerTf, const uint32_t *occupancymap, int32_t occupancyMapSize)
static std::unique_ptr< GPUParam > getFullParam(float solenoidBz, uint32_t nHbfPerTf=0, std::unique_ptr< GPUO2InterfaceConfiguration > *pConfiguration=nullptr, std::unique_ptr< GPUSettingsO2 > *pO2Settings=nullptr, bool *autoMaxTimeBin=nullptr)
const GLdouble * v
Definition glcorearb.h:832
GLenum GLfloat param
Definition glcorearb.h:271
Global TPC definitions and constants.
TrackParCovF TrackParCov
Definition Track.h:33
const ClusterNative * clustersLinear