Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 38 additions & 11 deletions ALICE3/Core/FlatLutEntry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,36 @@
namespace o2::delphes
{

void lutEntry_t::print() const
{
LOGF(info, " nch = %f, eta = %f, pt = %f, valid = %s\n", nch, eta, pt, valid ? "true" : "false");
LOGF(info, " eff = %f, eff2 = %f, itof = %f, otof = %f\n", eff, eff2, itof, otof);
LOGF(info, " covm: ");
for (int i = 0; i < 15; ++i) {

Check failure on line 33 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

Check failure on line 33 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOGF(info, "%f ", covm[i]);
}
LOGF(info, "\n");
LOGF(info, " eigval: ");
for (int i = 0; i < 5; ++i) {

Check failure on line 38 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

Check failure on line 38 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOGF(info, "%f ", eigval[i]);
}
LOGF(info, "\n");
LOGF(info, " eigvec:\n");
for (int i = 0; i < 5; ++i) {

Check failure on line 43 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

Check failure on line 43 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
for (int j = 0; j < 5; ++j) {

Check failure on line 44 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

Check failure on line 44 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOGF(info, "%f ", eigvec[i][j]);
}
LOGF(info, "\n");
}
LOGF(info, " eiginv:\n");
for (int i = 0; i < 5; ++i) {

Check failure on line 50 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

Check failure on line 50 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
for (int j = 0; j < 5; ++j) {

Check failure on line 51 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.

Check failure on line 51 in ALICE3/Core/FlatLutEntry.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOGF(info, "%f ", eiginv[i][j]);
}
LOGF(info, "\n");
}
}

float map_t::fracPositionWithinBin(float val) const
{
float width = (max - min) / nbins;
Expand Down Expand Up @@ -90,10 +120,10 @@
mEtaBins = header.etamap.nbins;
mPtBins = header.ptmap.nbins;

size_t headerSize = sizeof(lutHeader_t);
size_t numEntries = static_cast<size_t>(mNchBins) * mRadBins * mEtaBins * mPtBins;
size_t entriesSize = numEntries * sizeof(lutEntry_t);
size_t totalSize = headerSize + entriesSize;
const size_t headerSize = sizeof(lutHeader_t);
const size_t numEntries = static_cast<size_t>(mNchBins) * mRadBins * mEtaBins * mPtBins;
const size_t entriesSize = numEntries * sizeof(lutEntry_t);
const size_t totalSize = headerSize + entriesSize;

mData.resize(totalSize);
// Write header at the beginning
Expand All @@ -103,13 +133,10 @@

size_t FlatLutData::getEntryOffset(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const
{
size_t headerSize = sizeof(lutHeader_t);

// Linear index: nch varies slowest, pt varies fastest
// idx = nch * (rad*eta*pt) + rad * (eta*pt) + eta * pt + pt
size_t linearIdx = static_cast<size_t>(nch_bin) * (mRadBins * mEtaBins * mPtBins) + static_cast<size_t>(rad_bin) * (mEtaBins * mPtBins) + static_cast<size_t>(eta_bin) * mPtBins + static_cast<size_t>(pt_bin);

return headerSize + linearIdx * sizeof(lutEntry_t);
static constexpr size_t headerSize = sizeof(lutHeader_t);
const size_t linearIdx = getEntryIndex(nch_bin, rad_bin, eta_bin, pt_bin);
static constexpr size_t entrySize = sizeof(lutEntry_t);
return headerSize + linearIdx * entrySize;
}

const lutEntry_t* FlatLutData::getEntryRef(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const
Expand Down
7 changes: 7 additions & 0 deletions ALICE3/Core/FlatLutEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ class FlatLutData
*/
void initialize(const lutHeader_t& header);

size_t getEntryIndex(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const
{
// Linear index: nch varies slowest, pt varies fastest
// idx = nch * (rad*eta*pt) + rad * (eta*pt) + eta * pt + pt
return static_cast<size_t>(nch_bin) * (mRadBins * mEtaBins * mPtBins) + static_cast<size_t>(rad_bin) * (mEtaBins * mPtBins) + static_cast<size_t>(eta_bin) * mPtBins + static_cast<size_t>(pt_bin);
}

/**
* @brief Get LUT entry by bin indices (view)
*/
Expand Down
Loading