Project
Loading...
Searching...
No Matches
GPUDisplayImportEvent.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#ifndef GPUCA_NO_ROOT
16#include "Rtypes.h" // Include ROOT header first, to use ROOT and disable replacements
17#endif
18
19#include "GPUDisplay.h"
20#include "frontend/GPUDisplayInfo.inc"
21#include "GPUO2DataTypes.h"
22#include "GPUTPCConvertImpl.h"
23#include "GPUTRDGeometry.h"
24#include "GPUTRDTrackletWord.h"
25#include "GPUChainTracking.h"
26#include "GPUParam.inc"
27
31#include "TOFBase/Geo.h"
33#ifndef GPUCA_STANDALONE
35#endif
36
37#include <oneapi/tbb.h>
38
39using namespace o2::gpu;
40
41void GPUDisplay::DrawGLScene_updateEventData()
42{
43 mUpdateGUIOptions = true; // E.g. number of collisions
44 HighResTimer timer(mChain->GetProcessingSettings().debugLevel >= 2);
45 if (mIOPtrs->clustersNative) {
46 mCurrentClusters = mIOPtrs->clustersNative->nClustersTotal;
47 } else {
48 mCurrentClusters = 0;
49 for (int32_t iSector = 0; iSector < NSECTORS; iSector++) {
50 mCurrentClusters += mIOPtrs->nClusterData[iSector];
51 }
52 }
53 if (mNMaxClusters < mCurrentClusters) {
54 mNMaxClusters = mCurrentClusters;
55 mGlobalPosPtr.reset(new float4[mNMaxClusters]);
56 mGlobalPos = mGlobalPosPtr.get();
57 }
58
59 mCurrentSpacePointsTRD = mIOPtrs->trdSpacePoints ? mIOPtrs->nTRDTracklets : 0;
60 if (mCurrentSpacePointsTRD > mNMaxSpacePointsTRD) {
61 mNMaxSpacePointsTRD = mCurrentSpacePointsTRD;
62 mGlobalPosPtrTRD.reset(new float4[mNMaxSpacePointsTRD]);
63 mGlobalPosPtrTRD2.reset(new float4[mNMaxSpacePointsTRD]);
64 mGlobalPosTRD = mGlobalPosPtrTRD.get();
65 mGlobalPosTRD2 = mGlobalPosPtrTRD2.get();
66 }
67
68 mCurrentClustersITS = mIOPtrs->itsClusters ? mIOPtrs->nItsClusters : 0;
69 if (mNMaxClustersITS < mCurrentClustersITS) {
70 mNMaxClustersITS = mCurrentClustersITS;
71 mGlobalPosPtrITS.reset(new float4[mNMaxClustersITS]);
72 mGlobalPosITS = mGlobalPosPtrITS.get();
73 }
74
75 mCurrentClustersTOF = mIOPtrs->nTOFClusters;
76 if (mNMaxClustersTOF < mCurrentClustersTOF) {
77 mNMaxClustersTOF = mCurrentClustersTOF;
78 mGlobalPosPtrTOF.reset(new float4[mNMaxClustersTOF]);
79 mGlobalPosTOF = mGlobalPosPtrTOF.get();
80 }
81
82 uint32_t nTpcMergedTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks;
83 if ((size_t)nTpcMergedTracks > mTRDTrackIds.size()) {
84 mTRDTrackIds.resize(nTpcMergedTracks);
85 }
86 if (mIOPtrs->nItsTracks > mITSStandaloneTracks.size()) {
87 mITSStandaloneTracks.resize(mIOPtrs->nItsTracks);
88 }
89 for (uint32_t i = 0; i < nTpcMergedTracks; i++) {
90 mTRDTrackIds[i] = -1;
91 }
92 auto tmpDoTRDTracklets = [&](auto* trdTracks) {
93 for (uint32_t i = 0; i < mIOPtrs->nTRDTracks; i++) {
94 if (trdTracks[i].getNtracklets()) {
95 mTRDTrackIds[trdTracks[i].getRefGlobalTrackIdRaw()] = i;
96 }
97 }
98 };
99 if (mIOPtrs->trdTracksO2) {
100 tmpDoTRDTracklets(mIOPtrs->trdTracksO2);
101 } else {
102 tmpDoTRDTracklets(mIOPtrs->trdTracks);
103 }
104 if (mIOPtrs->nItsTracks) {
105 std::fill(mITSStandaloneTracks.begin(), mITSStandaloneTracks.end(), true);
106 if (mIOPtrs->tpcLinkITS) {
107 for (uint32_t i = 0; i < nTpcMergedTracks; i++) {
108 if (mIOPtrs->tpcLinkITS[i] != -1) {
109 mITSStandaloneTracks[mIOPtrs->tpcLinkITS[i]] = false;
110 }
111 }
112 }
113 }
114 if (timer.IsRunning()) {
115 GPUInfo("Display Time: Init:\t\t%6.0f us", timer.GetCurrentElapsedTime(true) * 1e6);
116 }
117
118 if (mCfgH.trackFilter) {
119 uint32_t nTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks;
120 mTrackFilter.resize(nTracks);
121 std::fill(mTrackFilter.begin(), mTrackFilter.end(), true);
122 if (buildTrackFilter()) {
123 SetInfo("Error running track filter from %s", trackFilterName().c_str());
124 } else {
125 uint32_t nFiltered = 0;
126 for (uint32_t i = 0; i < mTrackFilter.size(); i++) {
127 nFiltered += !mTrackFilter[i];
128 }
129 if (mUpdateTrackFilter) {
130 SetInfo("Applied track filter %s - filtered %u / %u", trackFilterName().c_str(), nFiltered, (uint32_t)mTrackFilter.size());
131 }
132 }
133 }
134 mUpdateTrackFilter = false;
135 if (timer.IsRunning()) {
136 GPUInfo("Display Time: Track Filter:\t%6.0f us", timer.GetCurrentElapsedTime(true) * 1e6);
137 }
138
139 mMaxClusterZ = tbb::parallel_reduce(tbb::blocked_range<int32_t>(0, NSECTORS, 1), float(0.f), [&](const tbb::blocked_range<int32_t>& r, float maxClusterZ) {
140 for (int32_t iSector = r.begin(); iSector < r.end(); iSector++) {
141 uint32_t row = 0;
142 uint32_t nCls = mIOPtrs->clustersNative ? mIOPtrs->clustersNative->nClustersSector[iSector] : 0;
143 for (uint32_t i = 0; i < nCls; i++) {
144 int32_t cid;
145 cid = mIOPtrs->clustersNative->clusterOffset[iSector][0] + i;
146 while (row < GPUTPCGeometry::NROWS - 1 && mIOPtrs->clustersNative->clusterOffset[iSector][row + 1] <= (uint32_t)cid) {
147 row++;
148 }
149 if (cid >= mNMaxClusters) {
150 throw std::runtime_error("Cluster Buffer Size exceeded");
151 }
152 float4* ptr = &mGlobalPos[cid];
153 float x, y, z;
154 const auto& cln = mIOPtrs->clustersNative->clusters[iSector][0][i];
155 GPUTPCConvertImpl::convert(*mCalib->fastTransform, *mParam, iSector, row, cln.getPad(), cln.getTime(), x, y, z);
156 if (mCfgH.clustersOnNominalRow) {
157 x = GPUTPCGeometry::Row2X(row);
158 }
159 mParam->Sector2Global(iSector, x + mCfgH.xzAdd, y, z, &ptr->x, &ptr->y, &ptr->z);
160
161 if (fabsf(ptr->z) > maxClusterZ) {
162 maxClusterZ = fabsf(ptr->z);
163 }
164 ptr->z += iSector < 18 ? mCfgH.xzAdd : -mCfgH.xzAdd;
165 ptr->x *= GL_SCALE_FACTOR;
166 ptr->y *= GL_SCALE_FACTOR;
167 ptr->z *= GL_SCALE_FACTOR;
168 ptr->w = tCLUSTER;
169 }
170 }
171 return maxClusterZ; // clang-format off
172 }, [](const float a, const float b) { return std::max(a, b); }, tbb::simple_partitioner()); // clang-format on
173 if (timer.IsRunning()) {
174 GPUInfo("Display Time: Load TPC:\t\t%6.0f us", timer.GetCurrentElapsedTime(true) * 1e6);
175 }
176
177 mMaxClusterZ = tbb::parallel_reduce(tbb::blocked_range<int32_t>(0, mCurrentSpacePointsTRD, 32), float(mMaxClusterZ), [&](const tbb::blocked_range<int32_t>& r, float maxClusterZ) {
178 int32_t trdTriggerRecord = -1;
179 float trdZoffset = 0;
180 for (int i = r.begin(); i < r.end(); i++) {
181 while (mParam->par.continuousTracking && trdTriggerRecord < (int32_t)mIOPtrs->nTRDTriggerRecords - 1 && mIOPtrs->trdTrackletIdxFirst[trdTriggerRecord + 1] <= i) {
182 trdTriggerRecord++; // This requires to go through the data in order I believe
183 float trdTime = mIOPtrs->trdTriggerTimes[trdTriggerRecord] * 1e3 / o2::constants::lhc::LHCBunchSpacingNS / o2::tpc::constants::LHCBCPERTIMEBIN;
184 trdZoffset = fabsf(mCalib->fastTransform->convVertexTimeToZOffset(0, trdTime, mParam->continuousMaxTimeBin));
185 }
186 const auto& sp = mIOPtrs->trdSpacePoints[i];
187 int32_t iSec = trdGeometry()->GetSector(mIOPtrs->trdTracklets[i].GetDetector());
188 float4* ptr = &mGlobalPosTRD[i];
189 mParam->Sector2Global(iSec, sp.getX() + mCfgH.xzAdd, sp.getY(), sp.getZ(), &ptr->x, &ptr->y, &ptr->z);
190 ptr->z += ptr->z > 0 ? trdZoffset : -trdZoffset;
191 if (fabsf(ptr->z) > maxClusterZ) {
192 maxClusterZ = fabsf(ptr->z);
193 }
194 ptr->x *= GL_SCALE_FACTOR;
195 ptr->y *= GL_SCALE_FACTOR;
196 ptr->z *= GL_SCALE_FACTOR;
197 ptr->w = tTRDCLUSTER;
198 ptr = &mGlobalPosTRD2[i];
199 mParam->Sector2Global(iSec, sp.getX() + mCfgH.xzAdd + 4.5f, sp.getY() + 1.5f * sp.getDy(), sp.getZ(), &ptr->x, &ptr->y, &ptr->z);
200 ptr->z += ptr->z > 0 ? trdZoffset : -trdZoffset;
201 if (fabsf(ptr->z) > maxClusterZ) {
202 maxClusterZ = fabsf(ptr->z);
203 }
204 ptr->x *= GL_SCALE_FACTOR;
205 ptr->y *= GL_SCALE_FACTOR;
206 ptr->z *= GL_SCALE_FACTOR;
207 ptr->w = tTRDCLUSTER;
208 }
209 return maxClusterZ; // clang-format off
210 }, [](const float a, const float b) { return std::max(a, b); }, tbb::static_partitioner()); // clang-format on
211 if (timer.IsRunning()) {
212 GPUInfo("Display Time: Load TRD:\t\t%6.0f us", timer.GetCurrentElapsedTime(true) * 1e6);
213 }
214
215 mMaxClusterZ = tbb::parallel_reduce(tbb::blocked_range<int32_t>(0, mCurrentClustersTOF, 32), float(mMaxClusterZ), [&](const tbb::blocked_range<int32_t>& r, float maxClusterZ) {
216 for (int32_t i = r.begin(); i < r.end(); i++) {
217 float4* ptr = &mGlobalPosTOF[i];
218 mParam->Sector2Global(mIOPtrs->tofClusters[i].getSector(), mIOPtrs->tofClusters[i].getX() + mCfgH.xzAdd, mIOPtrs->tofClusters[i].getY(), mIOPtrs->tofClusters[i].getZ(), &ptr->x, &ptr->y, &ptr->z);
219 float ZOffset = 0;
220 if (mParam->par.continuousTracking) {
221 float tofTime = mIOPtrs->tofClusters[i].getTime() * 1e-3 / o2::constants::lhc::LHCBunchSpacingNS / o2::tpc::constants::LHCBCPERTIMEBIN;
222 ZOffset = fabsf(mCalib->fastTransform->convVertexTimeToZOffset(0, tofTime, mParam->continuousMaxTimeBin));
223 ptr->z += ptr->z > 0 ? ZOffset : -ZOffset;
224 }
225 if (fabsf(ptr->z) > maxClusterZ) {
226 maxClusterZ = fabsf(ptr->z);
227 }
228 ptr->x *= GL_SCALE_FACTOR;
229 ptr->y *= GL_SCALE_FACTOR;
230 ptr->z *= GL_SCALE_FACTOR;
231 ptr->w = tTOFCLUSTER;
232 }
233 return maxClusterZ; // clang-format off
234 }, [](const float a, const float b) { return std::max(a, b); }); // clang-format on
235 if (timer.IsRunning()) {
236 GPUInfo("Display Time: Load TOF:\t\t%6.0f us", timer.GetCurrentElapsedTime(true) * 1e6);
237 }
238
239 if (mCurrentClustersITS) {
240 float itsROFhalfLen = 0;
241#ifndef GPUCA_STANDALONE // Not available in standalone benchmark
242 if (mParam->par.continuousTracking) {
244 itsROFhalfLen = alpParams.roFrameLengthInBC / (float)o2::tpc::constants::LHCBCPERTIMEBIN / 2;
245 }
246#endif
247 int32_t i = 0;
248 for (uint32_t j = 0; j < mIOPtrs->nItsClusterROF; j++) {
249 float ZOffset = 0;
250 if (mParam->par.continuousTracking) {
252 float itsROFtime = mIOPtrs->itsClusterROF[j].getBCData().differenceInBC(startIR) / (float)o2::tpc::constants::LHCBCPERTIMEBIN;
253 ZOffset = fabsf(mCalib->fastTransform->convVertexTimeToZOffset(0, itsROFtime + itsROFhalfLen, mParam->continuousMaxTimeBin));
254 }
255 if (i != mIOPtrs->itsClusterROF[j].getFirstEntry()) {
256 throw std::runtime_error("Inconsistent ITS data, number of clusters does not match ROF content");
257 }
258 for (int32_t k = 0; k < mIOPtrs->itsClusterROF[j].getNEntries(); k++) {
259 float4* ptr = &mGlobalPosITS[i];
260 const auto& cl = mIOPtrs->itsClusters[i];
261 auto* itsGeo = o2::its::GeometryTGeo::Instance();
262 auto p = cl.getXYZGlo(*itsGeo);
263 ptr->x = p.X();
264 ptr->y = p.Y();
265 ptr->z = p.Z();
266 ptr->z += ptr->z > 0 ? ZOffset : -ZOffset;
267 if (fabsf(ptr->z) > mMaxClusterZ) {
268 mMaxClusterZ = fabsf(ptr->z);
269 }
270 ptr->x *= GL_SCALE_FACTOR;
271 ptr->y *= GL_SCALE_FACTOR;
272 ptr->z *= GL_SCALE_FACTOR;
273 ptr->w = tITSCLUSTER;
274 i++;
275 }
276 }
277 }
278 if (timer.IsRunning()) {
279 GPUInfo("Display Time: Load ITS:\t\t%6.0f us", timer.GetCurrentElapsedTime(true) * 1e6);
280 }
281}
Definition of the TOF cluster.
int32_t i
uint32_t iSector
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
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 float
TRD Tracklet word for GPU tracker - 32bit tracklet info + half chamber ID + index.
Definition of the GeometryTGeo class.
Definition of the ITSMFT ROFrame (trigger) record.
uint32_t j
Definition RawData.h:0
TBranch * ptr
T getX() const
Definition BaseCluster.h:62
T getY() const
Definition BaseCluster.h:63
T getZ() const
Definition BaseCluster.h:64
const GPUSettingsProcessing & GetProcessingSettings() const
Definition GPUChain.h:76
static GeometryTGeo * Instance()
int getNEntries() const
Definition ROFRecord.h:62
const BCData & getBCData() const
Definition ROFRecord.h:58
int getFirstEntry() const
Definition ROFRecord.h:63
std::int8_t getSector() const
Definition Cluster.h:64
double getTime() const
Definition Cluster.h:72
GLint GLenum GLint x
Definition glcorearb.h:403
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLint y
Definition glcorearb.h:270
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GPUdoubleBinary64 b
int64_t differenceInBC(const InteractionRecord &other) const
S< TPCFastTransformPOD >::type * fastTransform
int32_t float z
Definition GPUParam.h:95
const o2::tpc::ClusterNativeAccess * clustersNative
const GPUTRDSpacePoint * trdSpacePoints
const o2::tof::Cluster * tofClusters
const o2::BaseCluster< float > * itsClusters
const o2::itsmft::ROFRecord * itsClusterROF
const GPUTRDTrackGPU * trdTracks
const GPUTRDTrackletWord * trdTracklets
unsigned int nClustersSector[constants::MAXSECTOR]
const ClusterNative * clusters[constants::MAXSECTOR][constants::MAXGLOBALPADROW]
unsigned int clusterOffset[constants::MAXSECTOR][constants::MAXGLOBALPADROW]
std::vector< int > row