@@ -34,7 +34,7 @@ TPCFastSpaceChargeCorrection::TPCFastSpaceChargeCorrection()
3434 mScenarioPtr(nullptr ),
3535 mTimeStamp(-1 ),
3636 mCorrectionData{nullptr , nullptr , nullptr },
37- mCorrectionDataSize {0 , 0 , 0 }
37+ mSectorDataSize {0 , 0 , 0 }
3838{
3939 // Default Constructor: creates an empty uninitialized object
4040}
@@ -61,7 +61,7 @@ void TPCFastSpaceChargeCorrection::destroy()
6161 mTimeStamp = -1 ;
6262 for (int32_t is = 0 ; is < 3 ; is++) {
6363 mCorrectionData [is] = nullptr ;
64- mCorrectionDataSize [is] = 0 ;
64+ mSectorDataSize [is] = 0 ;
6565 }
6666 FlatObject::destroy ();
6767}
@@ -98,9 +98,9 @@ void TPCFastSpaceChargeCorrection::cloneFromObject(const TPCFastSpaceChargeCorre
9898
9999 mTimeStamp = obj.mTimeStamp ;
100100
101- mCorrectionDataSize [0 ] = obj.mCorrectionDataSize [0 ];
102- mCorrectionDataSize [1 ] = obj.mCorrectionDataSize [1 ];
103- mCorrectionDataSize [2 ] = obj.mCorrectionDataSize [2 ];
101+ mSectorDataSize [0 ] = obj.mSectorDataSize [0 ];
102+ mSectorDataSize [1 ] = obj.mSectorDataSize [1 ];
103+ mSectorDataSize [2 ] = obj.mSectorDataSize [2 ];
104104
105105 // variable-size data
106106 mScenarioPtr = obj.mScenarioPtr ;
@@ -153,7 +153,7 @@ void TPCFastSpaceChargeCorrection::setActualBufferAddressOld(char* actualFlatBuf
153153 for (int32_t is = 0 ; is < 3 ; is++) {
154154 size_t correctionDataOffset = alignSize (bufferSize, SplineType::getParameterAlignmentBytes ());
155155 mCorrectionData [is] = reinterpret_cast <char *>(mFlatBufferPtr + correctionDataOffset);
156- bufferSize = correctionDataOffset + mCorrectionDataSize [is];
156+ bufferSize = correctionDataOffset + mSectorDataSize [is] * mGeo . getNumberOfSectors () ;
157157 }
158158}
159159
@@ -180,7 +180,7 @@ void TPCFastSpaceChargeCorrection::setActualBufferAddress(char* actualFlatBuffer
180180 for (int32_t is = 0 ; is < 3 ; is++) {
181181 size_t correctionDataOffset = alignSize (bufferSize, SplineType::getParameterAlignmentBytes ());
182182 mCorrectionData [is] = reinterpret_cast <char *>(mFlatBufferPtr + correctionDataOffset);
183- bufferSize = correctionDataOffset + mCorrectionDataSize [is];
183+ bufferSize = correctionDataOffset + mSectorDataSize [is] * mGeo . getNumberOfSectors () ;
184184 }
185185 return ;
186186 }
@@ -232,11 +232,6 @@ void TPCFastSpaceChargeCorrection::setActualBufferAddress(char* actualFlatBuffer
232232 auto * oldRowInfos = reinterpret_cast <RowInfoVersion3*>(mFlatBufferPtr + oldRowsOffset);
233233 auto * oldSectorRowInfos = reinterpret_cast <SectorRowInfoVersion3*>(mFlatBufferPtr + oldSectorRowsOffset);
234234
235- size_t sectorDataSize[3 ];
236- for (int32_t is = 0 ; is < 3 ; is++) {
237- sectorDataSize[is] = mCorrectionDataSize [is] / mGeo .getNumberOfSectors ();
238- }
239-
240235 for (int32_t iSector = 0 ; iSector < mGeo .getNumberOfSectors (); iSector++) {
241236
242237 for (int32_t iRow = 0 ; iRow < mGeo .getNumberOfRows (); iRow++) {
@@ -250,7 +245,7 @@ void TPCFastSpaceChargeCorrection::setActualBufferAddress(char* actualFlatBuffer
250245
251246 newSectorRow.splineScenarioID = oldRowInfo.splineScenarioID ;
252247 for (int32_t is = 0 ; is < 3 ; is++) {
253- newSectorRow.dataOffsetBytes [is] = sectorDataSize [is] * iSector + oldRowInfo.dataOffsetBytes [is];
248+ newSectorRow.dataOffsetBytes [is] = mSectorDataSize [is] * iSector + oldRowInfo.dataOffsetBytes [is];
254249 }
255250
256251 { // grid for the measured coordinates
@@ -295,9 +290,9 @@ void TPCFastSpaceChargeCorrection::setActualBufferAddress(char* actualFlatBuffer
295290 size_t oldCorrectionDataOffset = alignSize (oldBufferSize, SplineType::getParameterAlignmentBytes ());
296291 size_t correctionDataOffset = alignSize (bufferSize, SplineType::getParameterAlignmentBytes ());
297292 mCorrectionData [is] = reinterpret_cast <char *>(mFlatBufferPtr + correctionDataOffset);
298- memmove (mCorrectionData [is], mFlatBufferPtr + oldCorrectionDataOffset, mCorrectionDataSize [is]);
299- oldBufferSize = oldCorrectionDataOffset + mCorrectionDataSize [is];
300- bufferSize = correctionDataOffset + mCorrectionDataSize [is];
293+ memmove (mCorrectionData [is], mFlatBufferPtr + oldCorrectionDataOffset, mSectorDataSize [is] * mGeo . getNumberOfSectors () );
294+ oldBufferSize = oldCorrectionDataOffset + mSectorDataSize [is] * mGeo . getNumberOfSectors () ;
295+ bufferSize = correctionDataOffset + mSectorDataSize [is] * mGeo . getNumberOfSectors () ;
301296 }
302297
303298 mFlatBufferSize = bufferSize;
@@ -421,7 +416,7 @@ void TPCFastSpaceChargeCorrection::print() const
421416 mGeo .print ();
422417 LOG (info) << " mNumberOfScenarios = " << mNumberOfScenarios ;
423418 LOG (info) << " mTimeStamp = " << mTimeStamp ;
424- LOG (info) << " mCorrectionDataSize = " << mCorrectionDataSize [0 ] << " " << mCorrectionDataSize [1 ] << " " << mCorrectionDataSize [2 ];
419+ LOG (info) << " mSectorDataSize = " << mSectorDataSize [0 ] << " " << mSectorDataSize [1 ] << " " << mSectorDataSize [2 ];
425420
426421 if (mScenarioPtr ) {
427422 for (int32_t i = 0 ; i < mNumberOfScenarios ; i++) {
@@ -488,7 +483,7 @@ void TPCFastSpaceChargeCorrection::startConstruction(const TPCFastTransformGeo&
488483 mScenarioPtr = nullptr ;
489484 for (int32_t s = 0 ; s < 3 ; s++) {
490485 mCorrectionData [s] = nullptr ;
491- mCorrectionDataSize [s] = 0 ;
486+ mSectorDataSize [s] = 0 ;
492487 }
493488 mClassVersion = 4 ;
494489}
@@ -552,17 +547,22 @@ void TPCFastSpaceChargeCorrection::finishConstruction()
552547 size_t correctionDataOffset[3 ];
553548 for (int32_t is = 0 ; is < 3 ; is++) {
554549 correctionDataOffset[is] = alignSize (bufferSize, SplineType::getParameterAlignmentBytes ());
555- mCorrectionDataSize [is] = 0 ;
556- for (int32_t i = 0 ; i < mGeo .getNumberOfSectors (); i++) {
550+ mSectorDataSize [is] = 0 ;
551+ for (int32_t j = 0 ; j < mGeo .getNumberOfRows (); j++) {
552+ SectorRowInfo& row = getSectorRowInfo (0 , j);
553+ SplineType& spline = mConstructionScenarios [row.splineScenarioID ];
554+ row.dataOffsetBytes [is] = alignSize (mSectorDataSize [is], SplineType::getParameterAlignmentBytes ());
555+ mSectorDataSize [is] = row.dataOffsetBytes [is] + spline.getSizeOfParameters ();
556+ }
557+ mSectorDataSize [is] = alignSize (mSectorDataSize [is], SplineType::getParameterAlignmentBytes ());
558+ for (int32_t i = 1 ; i < mGeo .getNumberOfSectors (); i++) {
557559 for (int32_t j = 0 ; j < mGeo .getNumberOfRows (); j++) {
560+ SectorRowInfo& row0 = getSectorRowInfo (0 , j);
558561 SectorRowInfo& row = getSectorRowInfo (i, j);
559- SplineType& spline = mConstructionScenarios [row.splineScenarioID ];
560- row.dataOffsetBytes [is] = alignSize (mCorrectionDataSize [is], SplineType::getParameterAlignmentBytes ());
561- mCorrectionDataSize [is] = row.dataOffsetBytes [is] + spline.getSizeOfParameters ();
562+ row.dataOffsetBytes [is] = mSectorDataSize [is] * i + row0.dataOffsetBytes [is];
562563 }
563564 }
564- mCorrectionDataSize [is] = alignSize (mCorrectionDataSize [is], SplineType::getParameterAlignmentBytes ());
565- bufferSize = correctionDataOffset[is] + mCorrectionDataSize [is];
565+ bufferSize = correctionDataOffset[is] + mSectorDataSize [is] * mGeo .getNumberOfSectors ();
566566 }
567567
568568 FlatObject::finishConstruction (bufferSize);
0 commit comments