Skip to content

Commit ee8ab28

Browse files
cbmswdavidrohr
authored andcommitted
TPCFastTransform: bugfix in reduced metadata format
1 parent a3fa1a9 commit ee8ab28

2 files changed

Lines changed: 27 additions & 31 deletions

File tree

GPU/TPCFastTransformation/TPCFastSpaceChargeCorrection.cxx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,18 @@ void TPCFastSpaceChargeCorrection::finishConstruction()
512512
mSectorDataSizeBytes[is] = 0;
513513
for (int32_t j = 0; j < mGeo.getNumberOfRows(); j++) {
514514
RowInfo& row = getRowInfo(j);
515-
SplineType& spline = mConstructionScenarios[row.splineScenarioID];
516515
row.dataOffsetBytes[is] = mSectorDataSizeBytes[is];
517-
mSectorDataSizeBytes[is] += spline.getSizeOfParameters();
516+
const SplineType& spline = mConstructionScenarios[row.splineScenarioID];
517+
if (is == 0) {
518+
const SplineTypeXYZ& splineXYZ = reinterpret_cast<const SplineTypeXYZ&>(spline);
519+
mSectorDataSizeBytes[is] += splineXYZ.getSizeOfParameters();
520+
} else if (is == 1) {
521+
const SplineTypeInvX& splineInvX = reinterpret_cast<const SplineTypeInvX&>(spline);
522+
mSectorDataSizeBytes[is] += splineInvX.getSizeOfParameters();
523+
} else if (is == 2) {
524+
const SplineTypeInvYZ& splineInvYZ = reinterpret_cast<const SplineTypeInvYZ&>(spline);
525+
mSectorDataSizeBytes[is] += splineInvYZ.getSizeOfParameters();
526+
}
518527
}
519528
bufferSize += mSectorDataSizeBytes[is] * mGeo.getNumberOfSectors();
520529
}
@@ -556,24 +565,23 @@ GPUd() void TPCFastSpaceChargeCorrection::setNoCorrection()
556565
} // row
557566

558567
for (int32_t sector = 0; sector < mGeo.getNumberOfSectors(); sector++) {
559-
560568
for (int32_t row = 0; row < mGeo.getNumberOfRows(); row++) {
561-
const SplineType& spline = getSplineForRow(row);
562569
for (int32_t is = 0; is < 3; is++) {
563570
float* data = getCorrectionData(sector, row, is);
564-
int32_t nPar = spline.getNumberOfParameters();
565-
if (is == 1) {
566-
nPar = nPar / 3;
567-
}
568-
if (is == 2) {
569-
nPar = nPar * 2 / 3;
571+
int32_t nPar = 0;
572+
if (is == 0) {
573+
nPar = getSplineForRow(row).getNumberOfParameters();
574+
} else if (is == 1) {
575+
nPar = getSplineInvXforRow(row).getNumberOfParameters();
576+
} else if (is == 2) {
577+
nPar = getSplineInvYZforRow(row).getNumberOfParameters();
570578
}
571579
for (int32_t i = 0; i < nPar; i++) {
572580
data[i] = 0.f;
573581
}
574582
}
575583
} // row
576-
} // sector
584+
} // sector
577585
}
578586

579587
void TPCFastSpaceChargeCorrection::constructWithNoCorrection(const TPCFastTransformGeo& geo)

GPU/TPCFastTransformation/TPCFastTransformPOD.cxx

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TPCFastTransformPOD* TPCFastTransformPOD::create(aligned_unique_buffer_ptr<TPCFa
3131
{
3232
size_t size = estimateSize(src);
3333
destVector.alloc(size); // allocate exact size
34-
LOGP(debug, "OrigCorrSize:{} SelfSize: {} Estimated POS size: {}", src.getCorrection().getFlatBufferSize(), sizeof(TPCFastTransformPOD), size);
34+
LOGP(debug, "OrigCorrSize:{} SelfSize: {} Estimated POD size: {}", src.getCorrection().getFlatBufferSize(), sizeof(TPCFastTransformPOD), size);
3535
auto res = create(destVector.getraw(), size, src);
3636
res->setTimeStamp(src.getTimeStamp());
3737
res->setVDrift(src.getVDrift());
@@ -48,7 +48,7 @@ TPCFastTransformPOD* TPCFastTransformPOD::create(aligned_unique_buffer_ptr<TPCFa
4848
// create filling only part corresponding to TPCFastSpaceChargeCorrection. Data members coming from TPCFastTransform (e.g. VDrift, T0..) are not set
4949
size_t size = estimateSize(origCorr);
5050
destVector.alloc(size);
51-
LOGP(debug, "OrigCorrSize:{} SelfSize: {} Estimated POS size: {}", origCorr.getFlatBufferSize(), sizeof(TPCFastTransformPOD), size);
51+
LOGP(debug, "OrigCorrSize:{} SelfSize: {} Estimated POD size: {}", origCorr.getFlatBufferSize(), sizeof(TPCFastTransformPOD), size);
5252
return create(destVector.getraw(), size, origCorr);
5353
}
5454

@@ -67,19 +67,7 @@ size_t TPCFastTransformPOD::estimateSize(const TPCFastSpaceChargeCorrection& ori
6767
}
6868
// space for splines data
6969
for (int is = 0; is < 3; is++) {
70-
for (int sector = 0; sector < origCorr.mGeo.getNumberOfSectors(); sector++) {
71-
for (int row = 0; row < NROWS; row++) {
72-
const auto& spline = origCorr.getSplineForRow(row);
73-
int nPar = spline.getNumberOfParameters();
74-
if (is == 1) {
75-
nPar = nPar / 3;
76-
}
77-
if (is == 2) {
78-
nPar = nPar * 2 / 3;
79-
}
80-
nextDynOffs += nPar * sizeof(float);
81-
}
82-
}
70+
nextDynOffs += origCorr.mSectorDataSizeBytes[is] * TPCFastTransformGeo::getNumberOfSectors();
8371
}
8472
nextDynOffs = alignOffset(nextDynOffs);
8573
return nextDynOffs;
@@ -177,18 +165,18 @@ TPCFastTransformPOD* TPCFastTransformPOD::create(char* buff, size_t buffSize, co
177165
// metadata
178166
size_t sectorDataSizeBytes = origCorr.mSectorDataSizeBytes[is];
179167

180-
for (int sector = 0; sector < origCorr.mGeo.getNumberOfSectors(); sector++) {
181-
podMap.mSplineDataOffsets[sector][is] = sectorDataSizeBytes * sector;
168+
for (int sector = 0; sector < TPCFastTransformGeo::getNumberOfSectors(); sector++) {
169+
podMap.mSplineDataOffsets[sector][is] = nextDynOffs + sectorDataSizeBytes * sector;
182170
}
183-
if (buffSize < nextDynOffs + sectorDataSizeBytes * origCorr.mGeo.getNumberOfSectors()) {
171+
size_t dataSize = TPCFastTransformGeo::getNumberOfSectors() * sectorDataSizeBytes;
172+
if (buffSize < nextDynOffs + dataSize) {
184173
throw std::runtime_error(fmt::format("attempt to copy {} bytes of data for spline{} to {}, overflowing the buffer of size {}", sectorDataSizeBytes, is, nextDynOffs, buffSize));
185174
}
186175
const char* dataOr = origCorr.mCorrectionData[is];
187-
size_t dataSize = origCorr.mGeo.getNumberOfSectors() * sectorDataSizeBytes;
188176
std::memcpy(data, dataOr, dataSize);
189177
nextDynOffs += dataSize;
190178
}
191-
179+
nextDynOffs = alignOffset(nextDynOffs);
192180
podMap.mTotalSize = nextDynOffs;
193181
if (buffSize != podMap.mTotalSize) {
194182
throw std::runtime_error(fmt::format("Estimated buffer size {} differs from filled one {}", buffSize, podMap.mTotalSize));

0 commit comments

Comments
 (0)