@@ -281,23 +281,24 @@ void GPUChainTracking::PrepareEventFromNative()
281281int GPUChainTracking::PrepareEvent ()
282282{
283283 mRec ->MemoryScalers ()->nTRDTracklets = mIOPtrs .nTRDTracklets ;
284- if (mIOPtrs .tpcRaw ) {
285- mRec ->MemoryScalers ()->nTPCdigits = mIOPtrs .tpcRaw ;
286- mRec ->MemoryScalers ()->nTPCHits = mRec ->MemoryScalers ()->NTPCClusters (mRec ->MemoryScalers ()->nTPCdigits );
284+ if (mIOPtrs .tpcPackedDigits ) {
285+ mRec ->MemoryScalers ()->nTPCdigits = 0 ;
287286 size_t maxDigits = 0 ;
288287 for (unsigned int iSlice = 0 ; iSlice < NSLICES; iSlice++) {
289- if (mIOPtrs .nTPCDigits [iSlice] > maxDigits) {
290- maxDigits = mIOPtrs .nTPCDigits [iSlice];
288+ mRec ->MemoryScalers ()->nTPCdigits += mIOPtrs .tpcPackedDigits ->nTPCDigits [iSlice];
289+ if (mIOPtrs .tpcPackedDigits ->nTPCDigits [iSlice] > maxDigits) {
290+ maxDigits = mIOPtrs .tpcPackedDigits ->nTPCDigits [iSlice];
291291 }
292- processors ()->tpcTrackers [iSlice].Data ().SetClusterData (nullptr , mRec ->MemoryScalers ()->NTPCClusters (mIOPtrs .nTPCDigits [iSlice]), 0 ); // TODO: fixme
293292 }
294- // Distribute maximum digits, so that we can reuse the memory easily
295293 for (unsigned int iSlice = 0 ; iSlice < NSLICES; iSlice++) {
294+ processors ()->tpcTrackers [iSlice].Data ().SetClusterData (nullptr , mRec ->MemoryScalers ()->NTPCClusters (mIOPtrs .tpcPackedDigits ->nTPCDigits [iSlice]), 0 ); // TODO: fixme
295+ // Distribute maximum digits, so that we can reuse the memory easily
296296 processors ()->tpcClusterer [iSlice].SetNMaxDigits (maxDigits);
297297 }
298+ mRec ->MemoryScalers ()->nTPCHits = mRec ->MemoryScalers ()->NTPCClusters (mRec ->MemoryScalers ()->nTPCdigits );
298299 processors ()->tpcCompressor .mMaxClusters = mRec ->MemoryScalers ()->nTPCHits ;
299300 processors ()->tpcConverter .mNClustersTotal = mRec ->MemoryScalers ()->nTPCHits ;
300- GPUInfo (" Event has %lld TPC Digits" , (long long int )mIOPtrs . tpcRaw );
301+ GPUInfo (" Event has %lld TPC Digits" , (long long int )mRec -> MemoryScalers ()-> nTPCdigits );
301302 } else if (mIOPtrs .clustersNative ) {
302303 PrepareEventFromNative ();
303304 } else {
@@ -402,6 +403,9 @@ void GPUChainTracking::DumpData(const char* filename)
402403 DumpData (fp, &mIOPtrs .clustersNative ->clustersLinear , &mIOPtrs .clustersNative ->nClustersTotal , InOutPointerType::CLUSTERS_NATIVE);
403404 fwrite (&mIOPtrs .clustersNative ->nClusters [0 ][0 ], sizeof (mIOPtrs .clustersNative ->nClusters [0 ][0 ]), NSLICES * GPUCA_ROW_COUNT, fp);
404405 }
406+ if (mIOPtrs .tpcPackedDigits ) {
407+ DumpData (fp, mIOPtrs .tpcPackedDigits ->tpcDigits , mIOPtrs .tpcPackedDigits ->nTPCDigits , InOutPointerType::TPC_DIGIT);
408+ }
405409 DumpData (fp, mIOPtrs .sliceOutTracks , mIOPtrs .nSliceOutTracks , InOutPointerType::SLICE_OUT_TRACK);
406410 DumpData (fp, mIOPtrs .sliceOutClusters , mIOPtrs .nSliceOutClusters , InOutPointerType::SLICE_OUT_CLUSTER);
407411 DumpData (fp, &mIOPtrs .mcLabelsTPC , &mIOPtrs .nMCLabelsTPC , InOutPointerType::MC_LABEL_TPC);
@@ -486,6 +490,10 @@ int GPUChainTracking::ReadData(const char* filename)
486490 r = fread (&mClusterNativeAccess ->nClusters [0 ][0 ], sizeof (mClusterNativeAccess ->nClusters [0 ][0 ]), NSLICES * GPUCA_ROW_COUNT, fp);
487491 mClusterNativeAccess ->setOffsetPtrs ();
488492 }
493+ mDigitMap .reset (new GPUTrackingInOutDigits);
494+ if (ReadData (fp, mDigitMap ->tpcDigits , mDigitMap ->nTPCDigits , mIOMem .tpcDigits , InOutPointerType::TPC_DIGIT)) {
495+ mIOPtrs .tpcPackedDigits = mDigitMap .get ();
496+ }
489497#endif
490498 ReadData (fp, mIOPtrs .sliceOutTracks , mIOPtrs .nSliceOutTracks , mIOMem .sliceOutTracks , InOutPointerType::SLICE_OUT_TRACK);
491499 ReadData (fp, mIOPtrs .sliceOutClusters , mIOPtrs .nSliceOutClusters , mIOMem .sliceOutClusters , InOutPointerType::SLICE_OUT_CLUSTER);
@@ -780,12 +788,12 @@ int GPUChainTracking::RunTPCClusterizer()
780788 SetupGPUProcessor (&clusterer, false );
781789 memset ((void *)clusterer.mPmemory , 0 , sizeof (*clusterer.mPmemory ));
782790 if (doGPU) {
783- clusterer.mPmemory ->nDigits = mIOPtrs .nTPCDigits [iSlice];
791+ clusterer.mPmemory ->nDigits = mIOPtrs .tpcPackedDigits -> nTPCDigits [iSlice];
784792 TransferMemoryResourceLinkToGPU (clusterer.mMemoryId , -1 );
785- mRec ->GPUMemCpy (clustererShadow.mPdigits , mIOPtrs .tpcDigits [iSlice], sizeof (mIOPtrs . tpcDigits [iSlice] [0 ]) * clusterer.mPmemory ->nDigits , 0 , true );
793+ mRec ->GPUMemCpy (clustererShadow.mPdigits , mIOPtrs .tpcPackedDigits -> tpcDigits [iSlice], sizeof (clustererShadow. mPdigits [0 ]) * clusterer.mPmemory ->nDigits , 0 , true );
786794 } else {
787- clusterer.mPdigits = (gpucf::PackedDigit*)mIOPtrs .tpcDigits [iSlice]; // TODO: Needs fixing, double-allocated and invalid const cast
788- clusterer.mPmemory ->nDigits = mIOPtrs .nTPCDigits [iSlice];
795+ clusterer.mPdigits = (gpucf::PackedDigit*)mIOPtrs .tpcPackedDigits -> tpcDigits [iSlice]; // TODO: Needs fixing, double-allocated and invalid const cast
796+ clusterer.mPmemory ->nDigits = mIOPtrs .tpcPackedDigits -> nTPCDigits [iSlice];
789797 }
790798 runKernel<GPUMemClean16>({BlockCount (), ThreadCount (), 0 }, nullptr , krnlRunRangeNone, {}, clustererShadow.mPchargeMap , TPC_NUM_OF_PADS * TPC_MAX_TIME_PADDED * sizeof (*clustererShadow.mPchargeMap ));
791799 runKernel<GPUMemClean16>({BlockCount (), ThreadCount (), 0 }, nullptr , krnlRunRangeNone, {}, clustererShadow.mPpeakMap , TPC_NUM_OF_PADS * TPC_MAX_TIME_PADDED * sizeof (*clustererShadow.mPpeakMap ));
@@ -1578,7 +1586,7 @@ int GPUChainTracking::RunChain()
15781586 return (1 );
15791587 }
15801588
1581- if (GetRecoSteps ().isSet (RecoStep::TPCClusterFinding)) {
1589+ if (GetRecoSteps ().isSet (RecoStep::TPCClusterFinding) && mIOPtrs . tpcPackedDigits ) {
15821590 timerClusterer.Start ();
15831591 RunTPCClusterizer ();
15841592 timerClusterer.Stop ();
@@ -1632,7 +1640,7 @@ int GPUChainTracking::RunChain()
16321640 if (GetDeviceProcessingSettings ().runQA ) {
16331641 printf (" QA Time: %'d us\n " , (int )(1000000 * timerQA.GetElapsedTime () / nCount));
16341642 }
1635- if (mIOPtrs .tpcRaw ) {
1643+ if (mIOPtrs .tpcPackedDigits ) {
16361644 printf (" TPC Clusterizer Time: %'d us\n " , (int )(1000000 * timerClusterer.GetElapsedTime () / nCount));
16371645 }
16381646 if (mIOPtrs .clustersNative ) {
0 commit comments