18#include "GPUChainTrackingGetters.inc"
27#define GPUSETTINGS_STANDALONE
28#define GPUSETTINGS_DISPLAY
46 mMaxBunchesFull =
TIME_ORBIT / config.bunchSpacing;
47 mMaxBunches = (
TIME_ORBIT - config.abortGapTime) / config.bunchSpacing;
49 if (config.overlayRaw &&
chain->GetTPCTransform() ==
nullptr) {
50 GPUInfo(
"Overlay Raw Events requires TPC Fast Transform");
51 throw std::exception();
53 if (config.bunchSim) {
54 if (config.bunchCount * config.bunchTrainCount > mMaxBunches) {
55 GPUInfo(
"Invalid timeframe settings: too many colliding bunches requested!");
56 throw std::exception();
58 mTrainDist = mMaxBunches / config.bunchTrainCount;
59 mCollisionProbability = (
float)config.interactionRate * (
float)(mMaxBunchesFull * config.bunchSpacing / 1e9f) / (
float)(config.bunchCount * config.bunchTrainCount);
60 GPUInfo(
"Timeframe settings: %d trains of %d bunches, bunch spacing: %d, train spacing: %dx%d, filled bunches %d / %d (%d), collision probability %f, mixing %d events", config.bunchTrainCount, config.bunchCount, config.bunchSpacing, mTrainDist, config.bunchSpacing,
61 config.bunchCount * config.bunchTrainCount, mMaxBunches, mMaxBunchesFull, mCollisionProbability, mNEventsInDirectory);
66 mEventUsed.resize(mNEventsInDirectory);
67 if (config.noEventRepeat == 2) {
68 memset(mEventUsed.data(), 0, mNEventsInDirectory *
sizeof(mEventUsed[0]));
75 if (config.overlayRaw) {
80 tmp.fTime += shiftTTotal;
88 tmp.z +=
iSector < NSECTORS / 2 ? shiftZ : -shiftZ;
93 tmp.z +=
i < NSECTORS / 2 ? shiftZ : -shiftZ;
106 float sign =
iSector < NSECTORS / 2 ? 1 : -1;
108 if (currentClusterSector !=
i) {
118 currentClusterSector++;
124 currentClusterTotal++;
154 for (
uint32_t i = 0;
i < mShiftedEvents.size();
i++) {
155 auto&
ptr = std::get<0>(mShiftedEvents[
i]);
158 if (config.overlayRaw) {
165 SetDisplayInformation(
i);
169 uint32_t nClustersSectorOffset[NSECTORS] = {0};
171 nClustersSectorOffset[
i] = nClustersTotal;
175 if (nClustersTotalRaw && nClustersTotalRaw != nClustersTotal) {
176 GPUError(
"Inconsitency between raw clusters and cluster data");
177 throw std::exception();
180 GPUError(
"Inconsitency between TPC clusters and MC labels");
181 throw std::exception();
188 uint32_t nClustersEventOffset[NSECTORS] = {0};
189 for (
uint32_t i = 0;
i < mShiftedEvents.size();
i++) {
190 auto&
ptr = std::get<0>(mShiftedEvents[
i]);
193 memcpy((
void*)&mChain->
mIOMem.
clusterData[
j][nClustersEventOffset[
j]], (
void*)
ptr.clusterData[
j],
ptr.nClusterData[
j] *
sizeof(
ptr.clusterData[
j][0]));
194 if (nClustersTotalRaw) {
195 memcpy((
void*)&mChain->
mIOMem.
rawClusters[
j][nClustersEventOffset[
j]], (
void*)
ptr.rawClusters[
j],
ptr.nRawClusters[
j] *
sizeof(
ptr.rawClusters[
j][0]));
198 memcpy((
void*)&mChain->
mIOMem.
mcLabelsTPC[nClustersSectorOffset[
j] + nClustersEventOffset[
j]], (
void*)&
ptr.mcLabelsTPC[inEventOffset],
ptr.nClusterData[
j] *
sizeof(
ptr.mcLabelsTPC[0]));
201 mChain->
mIOMem.
clusterData[
j][nClustersEventOffset[
j] + k].id = nClustersSectorOffset[
j] + nClustersEventOffset[
j] + k;
203 for (
int32_t l = 0; l < 3; l++) {
205 if (
label.fMCID >= 0) {
206 label.fMCID += nTrackOffset;
212 nClustersEventOffset[
j] +=
ptr.nClusterData[
j];
213 inEventOffset +=
ptr.nClusterData[
j];
216 memcpy((
void*)&mChain->
mIOMem.
mcInfosTPC[nTrackOffset], (
void*)
ptr.mcInfosTPC,
ptr.nMCInfosTPC *
sizeof(
ptr.mcInfosTPC[0]));
221 nTrackOffset +=
ptr.nMCInfosTPC;
222 nColOffset +=
ptr.nMCInfosTPCCol;
225 GPUInfo(
"Merged %d events, %u clusters total", (
int32_t)mShiftedEvents.size(), nClustersTotal);
227 mShiftedEvents.clear();
232 if (config.nTotalEventsInTF && mNTotalCollisions >= config.nTotalEventsInTF) {
237 int64_t lastBunch = config.timeFrameLen / config.bunchSpacing;
238 int64_t lastTFBunch = lastBunch -
DRIFT_TIME / config.bunchSpacing;
239 int32_t nCollisions = 0, nBorderCollisions = 0, nTrainCollissions = 0, nMultipleCollisions = 0, nTrainMultipleCollisions = 0;
241 int32_t mcMin = -1, mcMax = -1;
243 while (nBunch < lastBunch) {
244 for (
int32_t iTrain = 0; iTrain < config.bunchTrainCount && nBunch < lastBunch; iTrain++) {
245 int32_t nCollisionsInTrain = 0;
246 for (
int32_t iBunch = 0; iBunch < config.bunchCount && nBunch < lastBunch; iBunch++) {
247 const bool inTF = nBunch >= 0 && nBunch < lastTFBunch && (config.nTotalEventsInTF == 0 || nCollisions < mNTotalCollisions + config.nTotalEventsInTF);
248 if (mcMin == -1 && inTF) {
251 if (mcMax == -1 && nBunch >= 0 && !inTF) {
255 double randVal = mDisUniReal(inTF ? mRndGen2 : mRndGen1);
256 double p =
exp(-mCollisionProbability);
258 while (randVal > p) {
259 if (config.noBorder && (nBunch < 0 || nBunch >= lastTFBunch)) {
262 if (nCollisionsInTrain >= mNEventsInDirectory) {
263 GPUError(
"Error: insuffient events for mixing!");
266 if (nCollisionsInTrain == 0 && config.noEventRepeat == 0) {
267 memset(mEventUsed.data(), 0, mNEventsInDirectory *
sizeof(mEventUsed[0]));
275 if (config.noEventRepeat == 1) {
276 useEvent = mSimBunchNoRepeatEvent;
278 while (mEventUsed[useEvent = (inTF && config.eventStride ? (mEventStride += config.eventStride) : mDisUniInt(inTF ? mRndGen2 : mRndGen1)) % mNEventsInDirectory]) {
282 if (config.noEventRepeat) {
283 mSimBunchNoRepeatEvent++;
285 mEventUsed[useEvent] = 1;
286 double shift = (double)nBunch * (
double)config.bunchSpacing * (double)
TPCZ / (
double)
DRIFT_TIME;
289 GPUError(
"Unexpected error");
293 printf(
"Placing event %4d+%d (ID %4d) at z %7.3f (time %'dns) %s(collisions %4d, bunch %6d, train %3d) (%'10d clusters, %'10d MC labels, %'10d track MC info)\n", nCollisions, nBorderCollisions, useEvent, shift, (
int32_t)(nBunch * config.bunchSpacing), inTF ?
" inside" :
"outside",
296 nCollisionsInTrain++;
297 p2 *= mCollisionProbability / nInBunchPileUp;
299 if (config.noEventRepeat && mSimBunchNoRepeatEvent >= mNEventsInDirectory) {
303 if (nInBunchPileUp > 1) {
304 nMultipleCollisions++;
308 nBunch += mTrainDist - config.bunchCount;
309 if (nCollisionsInTrain) {
312 if (nCollisionsInTrain > 1) {
313 nTrainMultipleCollisions++;
317 nBunch += mMaxBunchesFull - mTrainDist * config.bunchTrainCount;
319 mNTotalCollisions += nCollisions;
320 GPUInfo(
"Timeframe statistics: collisions: %d+%d in %d trains (inside / outside), average rate %f (pile up: in bunch %d, in train %d)", nCollisions, nBorderCollisions, nTrainCollissions, (
float)nCollisions / (
float)(config.timeFrameLen -
DRIFT_TIME) * 1e9, nMultipleCollisions,
321 nTrainMultipleCollisions);
325 if (!config.noBorder && mChain->
GetQA()) {
333 for (
int32_t iEventInTimeframe = 0; iEventInTimeframe < config.nMerge; iEventInTimeframe++) {
335 if (config.shiftFirstEvent || iEventInTimeframe) {
336 if (config.randomizeDistance) {
337 shift = mDisUniReal(mRndGen2);
338 if (config.shiftFirstEvent) {
339 shift = (iEventInTimeframe + shift) * config.averageDistance;
341 if (iEventInTimeframe == 0) {
344 shift = (iEventInTimeframe - 0.5f + shift) * config.averageDistance;
348 if (config.shiftFirstEvent) {
349 shift = config.averageDistance * (iEventInTimeframe + 0.5f);
351 shift = config.averageDistance * (iEventInTimeframe);
358 if (
ReadEventShifted(iEvent * config.nMerge + iEventInTimeframe, shift) < 0) {
366void GPUReconstructionTimeframe::SetDisplayInformation(int32_t iCol)
369 for (uint32_t sl = 0; sl < NSECTORS; sl++) {
uint64_t exp(uint64_t base, uint8_t exp) noexcept
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 removed(0=no limit)") AddOption(prependCommand
configStandalone Reconstruction rec_tpc float
const TPCFastTransformPOD * GetTPCTransform() const
const GPUQA * GetQA() const
GPUDisplayInterface * GetEventDisplay()
GPUTrackingInOutPointers & mIOPtrs
struct o2::gpu::GPUChainTracking::InOutMemory mIOMem
virtual void SetCollisionFirstCluster(uint32_t collision, int32_t sector, int32_t cluster)=0
void SetMCTrackRange(int32_t min, int32_t max)
int32_t ReadEventShifted(int32_t i, float shiftZ, float minZ=-1e6, float maxZ=-1e6, bool silent=false)
static constexpr int32_t TPCZ
GPUReconstructionTimeframe(GPUChainTracking *rec, int32_t(*read)(int32_t), int32_t nEvents)
static constexpr int32_t DRIFT_TIME
static constexpr int32_t TIME_ORBIT
int32_t LoadCreateTimeFrame(int32_t iEvent)
void MergeShiftedEvents()
int32_t LoadMergedEvents(int32_t iEvent)
GLuint GLsizei const GLchar * label
GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat maxZ
GPUSettingsStandalone configStandalone
std::unique_ptr< GPUTPCMCInfo[]> mcInfosTPC
std::unique_ptr< GPUTPCMCInfoCol[]> mcInfosTPCCol
std::unique_ptr< AliHLTTPCClusterMCLabel[]> mcLabelsTPC
std::unique_ptr< GPUTPCClusterData[]> clusterData[NSECTORS]
std::unique_ptr< AliHLTTPCRawCluster[]> rawClusters[NSECTORS]
const o2::tpc::ClusterNativeAccess * clustersNative
uint32_t nClusterData[NSECTORS]
uint32_t nRawClusters[NSECTORS]