17#if !defined(GPUCA_NO_ROOT) && !defined(GPUCA_NO_FMT) && !defined(GPUCA_STANDALONE)
36 res->setTimeStamp(
src.getTimeStamp());
37 res->setVDrift(
src.getVDrift());
39 res->setLumi(
src.getLumi());
59 size_t nextDynOffs = alignOffset(selfSizeFix);
60 nextDynOffs = alignOffset(nextDynOffs + origCorr.mNumberOfScenarios *
sizeof(
size_t));
61 nextDynOffs = alignOffset(nextDynOffs + origCorr.mNumberOfScenarios *
sizeof(
size_t));
63 for (
int isc = 0; isc < origCorr.mNumberOfScenarios; isc++) {
64 const auto& spline = origCorr.mScenarioPtr[isc];
65 nextDynOffs = alignOffset(nextDynOffs +
sizeof(
SplineType));
66 nextDynOffs = alignOffset(nextDynOffs + spline.getFlatBufferSize());
69 for (
int is = 0; is < 3; is++) {
72 nextDynOffs = alignOffset(nextDynOffs);
78 LOGP(info,
"TPCFastTransformPOD: this={:p} sizeof={} mApplyCorrection={} mNumberOfScenarios={} mTotalSize={} mOffsScenariosOffsets={} mT0={} mVdrift={} mLumi={} mIDC={}",
79 (
void*)
this,
sizeof(*
this), mApplyCorrection, mNumberOfScenarios, mTotalSize, mOffsScenariosOffsets, mT0, mVdrift, mLumi, mIDC);
83 LOGP(info,
"mSplineDataOffsets[{}][{}]={}", s,
i, mSplineDataOffsets[s][
i]);
86 const size_t scenOffset = getScenarioOffset(0);
87 const auto& spline = getSplineForRow(0);
88 LOGP(info,
"scenOffset={} spline_addr={:p} expected={:p}", scenOffset, (
void*)&spline, (
void*)(getThis() + scenOffset));
90 const float* splineData = getCorrectionData(0, 0);
91 LOGP(info,
"spline internal check: &spline={:p} splineData={:p} buf_start={:p} buf_end={:p}",
92 (
void*)&spline, (
void*)splineData,
93 (
void*)getThis(), (
void*)(getThis() + mTotalSize));
96 bool dataInBuf = (splineData >= (
float*)getThis()) && (splineData < (
float*)(getThis() + mTotalSize));
97 LOGP(info,
"splineData in buffer: {}", dataInBuf);
99 LOGP(info,
"splineData offset from buf_start = {}", (
size_t)((
const char*)splineData - getThis()));
106 auto& podMap = getNonConst(buff);
107 podMap.mApplyCorrection =
true;
110 podMap.mNumberOfScenarios = origCorr.mNumberOfScenarios;
113 podMap.mRowInfos[
row] = origCorr.getRowInfo(
row);
116 podMap.mTimeStamp = origCorr.mTimeStamp;
126 podMap.mOffsScenariosOffsets = nextDynOffs;
127 LOGP(
debug,
"Set mOffsScenariosOffsets = {}", podMap.mOffsScenariosOffsets);
128 nextDynOffs = alignOffset(nextDynOffs + podMap.mNumberOfScenarios *
sizeof(
size_t));
130 podMap.mOffsFlatBufferOffsets = nextDynOffs;
131 nextDynOffs = alignOffset(nextDynOffs + podMap.mNumberOfScenarios *
sizeof(
size_t));
134 size_t* scenOffs =
reinterpret_cast<size_t*
>(buff + podMap.mOffsScenariosOffsets);
135 size_t* flatBufOffs =
reinterpret_cast<size_t*
>(buff + podMap.mOffsFlatBufferOffsets);
137 for (
int isc = 0; isc < origCorr.mNumberOfScenarios; isc++) {
138 scenOffs[isc] = nextDynOffs;
139 const auto& spline = origCorr.mScenarioPtr[isc];
140 if (buffSize < nextDynOffs +
sizeof(
SplineType)) {
141 throw std::runtime_error(fmt::format(
"attempt to write {} bytes for slim spline for scenario {} to {}, overflowing the buffer of size {}",
sizeof(
SplineType), isc, nextDynOffs +
sizeof(
SplineType), buffSize));
145 auto* slimSpline =
new (buff + scenOffs[isc])
SplineType();
146 slimSpline->importFrom(spline);
147 nextDynOffs = alignOffset(nextDynOffs +
sizeof(
SplineType));
148 LOGP(
debug,
"Write {} bytes for slim spline scenario {} to offset {}",
sizeof(
SplineType), isc, scenOffs[isc]);
151 flatBufOffs[isc] = nextDynOffs;
152 std::memcpy(buff + nextDynOffs, spline.getFlatBufferPtr(), spline.getFlatBufferSize());
155 slimSpline->setActualBufferAddress(buff + nextDynOffs);
157 nextDynOffs = alignOffset(nextDynOffs + spline.getFlatBufferSize());
161 for (
int is = 0; is < 3; is++) {
162 float*
data =
reinterpret_cast<float*
>(buff + nextDynOffs);
163 LOGP(
debug,
"splinID={} start offset {} -> {}", is, nextDynOffs, (
void*)
data);
166 size_t sectorDataSizeBytes = origCorr.mSectorDataSizeBytes[is];
169 podMap.mSplineDataOffsets[sector][is] = nextDynOffs + sectorDataSizeBytes * sector;
172 if (buffSize < nextDynOffs +
dataSize) {
173 throw std::runtime_error(fmt::format(
"attempt to copy {} bytes of data for spline{} to {}, overflowing the buffer of size {}", sectorDataSizeBytes, is, nextDynOffs, buffSize));
175 const char* dataOr = origCorr.mCorrectionData[is];
179 nextDynOffs = alignOffset(nextDynOffs);
180 podMap.mTotalSize = nextDynOffs;
181 if (buffSize != podMap.mTotalSize) {
182 throw std::runtime_error(fmt::format(
"Estimated buffer size {} differs from filled one {}", buffSize, podMap.mTotalSize));
184 return &getNonConst(buff);
190 auto podMap =
create(buff, buffSize,
src.getCorrection());
192 podMap->mVdrift =
src.getVDrift();
193 podMap->mT0 =
src.getT0();
194 podMap->mLumi =
src.getLumi();
195 if (
src.isIDCSet()) {
196 podMap->mIDC =
src.getIDC();
198 podMap->mTimeStamp =
src.getTimeStamp();
203#ifndef GPUCA_STANDALONE
210 std::vector<unsigned char> sector,
row;
211 std::vector<float>
y,
z;
212 std::vector<std::array<float, 3>> corr0, corr1;
213 std::vector<std::array<float, 2>> corrInv0, corrInv1;
214 std::vector<float> corrInvX0, corrInvX1;
216 sector.reserve(npoints);
217 row.reserve(npoints);
220 corr0.reserve(npoints);
221 corr1.reserve(npoints);
222 corrInv0.reserve(npoints);
223 corrInv1.reserve(npoints);
224 corrInvX0.reserve(npoints);
225 corrInvX1.reserve(npoints);
227 for (
int i = 0;
i < npoints;
i++) {
228 sector.push_back(gRandom->Integer(
NSECTORS));
229 row.push_back(gRandom->Integer(
NROWS));
231 z.push_back((sector.back() <
NSECTORS / 2 ? 1.f : -1.f) * gRandom->Rndm() * 240);
233 long origStart[3], origEnd[3], thisStart[3], thisEnd[3];
234 origStart[0] = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
235 for (
int i = 0;
i < npoints;
i++) {
236 std::array<float, 3>
val;
238 corr0.push_back(
val);
241 origEnd[0] = origStart[1] = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
242 for (
int i = 0;
i < npoints;
i++) {
243 std::array<float, 2>
val;
244 origCorr.getCorrectionYZatRealYZ(sector[
i],
row[
i],
y[
i],
z[
i],
val[0],
val[1]);
245 corrInv0.push_back(
val);
248 origEnd[1] = origStart[2] = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
249 for (
int i = 0;
i < npoints;
i++) {
250 corrInvX0.push_back(origCorr.getCorrectionXatRealYZ(sector[
i],
row[
i],
y[
i],
z[
i]));
253 origEnd[2] = thisStart[0] = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
254 for (
int i = 0;
i < npoints;
i++) {
255 std::array<float, 3>
val;
257 corr1.push_back(
val);
259 thisEnd[0] = thisStart[1] = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
260 for (
int i = 0;
i < npoints;
i++) {
261 std::array<float, 2>
val;
262 this->getCorrectionYZatRealYZ(sector[
i],
row[
i],
y[
i],
z[
i],
val[0],
val[1]);
263 corrInv1.push_back(
val);
266 thisEnd[1] = thisStart[2] = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
267 for (
int i = 0;
i < npoints;
i++) {
268 corrInvX1.push_back(this->getCorrectionXatRealYZ(sector[
i],
row[
i],
y[
i],
z[
i]));
270 thisEnd[2] = std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
272 size_t ndiff[3] = {};
273 for (
int i = 0;
i < npoints;
i++) {
274 if (corr0[
i][0] != corr1[
i][0] || corr0[
i][1] != corr1[
i][1] || corr0[
i][2] != corr1[
i][2]) {
277 if (corrInv0[
i][0] != corrInv1[
i][0] || corrInv0[
i][1] != corrInv1[
i][1]) {
280 if (corrInvX0[
i] != corrInvX1[
i]) {
285 LOGP(info,
" (ns per call) original this Nmissmatch");
286 LOGP(info,
"getCorrection {:.3e} {:.3e} {}",
double(origEnd[0] - origStart[0]) / npoints * 1000.,
double(thisEnd[0] - thisStart[0]) / npoints * 1000., ndiff[0]);
287 LOGP(info,
"getCorrectionInvCorrectedX {:.3e} {:.3e} {}",
double(origEnd[1] - origStart[1]) / npoints * 1000.,
double(thisEnd[1] - thisStart[1]) / npoints * 1000., ndiff[1]);
288 LOGP(info,
"getCorrectionInvUV {:.3e} {:.3e} {}",
double(origEnd[2] - origStart[2]) / npoints * 1000.,
double(thisEnd[2] - thisStart[2]) / npoints * 1000., ndiff[2]);
289 return ndiff[0] == 0 && ndiff[1] == 0 && ndiff[2] == 0;
Forward declaration — specializations below select ClassDefNV based on FlatBase.
GLdouble GLdouble GLdouble z
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...