Skip to content

Commit 4e7f6ff

Browse files
committed
Merge branch 'master' into mlfix
2 parents 7243322 + 7ffc10c commit 4e7f6ff

127 files changed

Lines changed: 20199 additions & 8832 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/commands/migrate-ccdb.md‎

Lines changed: 201 additions & 18 deletions
Large diffs are not rendered by default.

‎.github/workflows/clean-test.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ name: Clean PR checks
3939
type: boolean
4040
default: true
4141

42+
'check_build/O2Physics/code-check':
43+
description: build/O2Physics/code-check
44+
type: boolean
45+
default: true
46+
4247
permissions: {}
4348

4449
jobs:

‎.github/workflows/mega-linter.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
id: ml
4040
# You can override MegaLinter flavor used to have faster performances
4141
# More info at https://megalinter.io/flavors/
42-
uses: oxsecurity/megalinter@v10.0.0
42+
uses: oxsecurity/megalinter@v10.1.0
4343
env:
4444
# All available variables are described in documentation:
4545
# https://megalinter.io/configuration/

‎ALICE3/Core/FlatLutEntry.cxx‎

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12+
/// \file FlatLutEntry.cxx
13+
/// \brief Flat LUT implementation for compact helper tables used by the ALICE3 track smearing workflow.
14+
1215
#include "FlatLutEntry.h"
1316

1417
#include <Framework/Logger.h>
@@ -22,33 +25,33 @@
2225
#include <ios>
2326
#include <span>
2427

25-
namespace o2::delphes
28+
namespace o2::fastsim
2629
{
2730

2831
void lutEntry_t::print() const
2932
{
3033
LOGF(info, " nch = %f, eta = %f, pt = %f, valid = %s\n", nch, eta, pt, valid ? "true" : "false");
3134
LOGF(info, " eff = %f, eff2 = %f, itof = %f, otof = %f\n", eff, eff2, itof, otof);
3235
LOGF(info, " covm: ");
33-
for (int i = 0; i < 15; ++i) {
36+
for (int i = 0; i < kNumCovarianceTerms; ++i) {
3437
LOGF(info, "%f ", covm[i]);
3538
}
3639
LOGF(info, "\n");
3740
LOGF(info, " eigval: ");
38-
for (int i = 0; i < 5; ++i) {
41+
for (int i = 0; i < kNumEigenModes; ++i) {
3942
LOGF(info, "%f ", eigval[i]);
4043
}
4144
LOGF(info, "\n");
4245
LOGF(info, " eigvec:\n");
43-
for (int i = 0; i < 5; ++i) {
44-
for (int j = 0; j < 5; ++j) {
46+
for (int i = 0; i < kNumEigenModes; ++i) {
47+
for (int j = 0; j < kNumEigenModes; ++j) {
4548
LOGF(info, "%f ", eigvec[i][j]);
4649
}
4750
LOGF(info, "\n");
4851
}
4952
LOGF(info, " eiginv:\n");
50-
for (int i = 0; i < 5; ++i) {
51-
for (int j = 0; j < 5; ++j) {
53+
for (int i = 0; i < kNumEigenModes; ++i) {
54+
for (int j = 0; j < kNumEigenModes; ++j) {
5255
LOGF(info, "%f ", eiginv[i][j]);
5356
}
5457
LOGF(info, "\n");
@@ -57,23 +60,18 @@ void lutEntry_t::print() const
5760

5861
float map_t::fracPositionWithinBin(float val) const
5962
{
60-
float width = (max - min) / nbins;
61-
int bin;
62-
float returnVal = 0.5f;
63+
const float width = (max - min) / nbins;
64+
const int bin = find(val);
6365
if (log) {
64-
bin = static_cast<int>((std::log10(val) - min) / width);
65-
returnVal = ((std::log10(val) - min) / width) - bin;
66-
} else {
67-
bin = static_cast<int>((val - min) / width);
68-
returnVal = val / width - bin;
66+
return ((std::log10(val) - min) / width) - bin;
6967
}
70-
return returnVal;
68+
return val / width - bin;
7169
}
7270

7371
int map_t::find(float val) const
7472
{
75-
float width = (max - min) / nbins;
76-
int bin;
73+
const float width = (max - min) / nbins;
74+
int bin = 0;
7775
if (log) {
7876
bin = static_cast<int>((std::log10(val) - min) / width);
7977
} else {
@@ -93,7 +91,7 @@ void map_t::print() const
9391
LOGF(info, "nbins = %d, min = %f, max = %f, log = %s \n", nbins, min, max, log ? "on" : "off");
9492
}
9593

96-
bool lutHeader_t::check_version() const
94+
bool lutHeader_t::checkVersion() const
9795
{
9896
return (version == LUTCOVM_VERSION);
9997
}
@@ -120,7 +118,7 @@ void FlatLutData::initialize(const lutHeader_t& header)
120118
mEtaBins = header.etamap.nbins;
121119
mPtBins = header.ptmap.nbins;
122120

123-
const size_t headerSize = sizeof(lutHeader_t);
121+
constexpr size_t headerSize = sizeof(lutHeader_t);
124122
const size_t numEntries = static_cast<size_t>(mNchBins) * mRadBins * mEtaBins * mPtBins;
125123
const size_t entriesSize = numEntries * sizeof(lutEntry_t);
126124
const size_t totalSize = headerSize + entriesSize;
@@ -133,10 +131,10 @@ void FlatLutData::initialize(const lutHeader_t& header)
133131

134132
size_t FlatLutData::getEntryOffset(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const
135133
{
136-
static constexpr size_t headerSize = sizeof(lutHeader_t);
134+
static constexpr size_t HeaderSize = sizeof(lutHeader_t);
137135
const size_t linearIdx = getEntryIndex(nch_bin, rad_bin, eta_bin, pt_bin);
138-
static constexpr size_t entrySize = sizeof(lutEntry_t);
139-
return headerSize + linearIdx * entrySize;
136+
static constexpr size_t EntrySize = sizeof(lutEntry_t);
137+
return HeaderSize + linearIdx * EntrySize;
140138
}
141139

142140
const lutEntry_t* FlatLutData::getEntryRef(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const
@@ -153,12 +151,12 @@ lutEntry_t* FlatLutData::getEntry(int nch_bin, int rad_bin, int eta_bin, int pt_
153151

154152
const lutHeader_t& FlatLutData::getHeaderRef() const
155153
{
156-
return *reinterpret_cast<const lutHeader_t*>(mDataRef.data());
154+
return *static_cast<const lutHeader_t*>(static_cast<const void*>(mDataRef.data()));
157155
}
158156

159157
lutHeader_t& FlatLutData::getHeader()
160158
{
161-
return *reinterpret_cast<lutHeader_t*>(mData.data());
159+
return *static_cast<lutHeader_t*>(static_cast<void*>(mData.data()));
162160
}
163161

164162
void FlatLutData::updateRef()
@@ -200,26 +198,26 @@ void FlatLutData::view(const uint8_t* buffer, size_t size)
200198

201199
void FlatLutData::validateBuffer(const uint8_t* buffer, size_t size)
202200
{
203-
auto header = PreviewHeader(buffer, size);
204-
auto mNchBins = header.nchmap.nbins;
205-
auto mRadBins = header.radmap.nbins;
206-
auto mEtaBins = header.etamap.nbins;
207-
auto mPtBins = header.ptmap.nbins;
201+
auto header = previewHeader(buffer, size);
202+
const auto nchBins = header.nchmap.nbins;
203+
const auto radBins = header.radmap.nbins;
204+
const auto etaBins = header.etamap.nbins;
205+
const auto ptBins = header.ptmap.nbins;
208206

209-
size_t expectedSize = sizeof(lutHeader_t) + static_cast<size_t>(mNchBins) * mRadBins * mEtaBins * mPtBins * sizeof(lutEntry_t);
207+
const size_t expectedSize = sizeof(lutHeader_t) + static_cast<size_t>(nchBins) * radBins * etaBins * ptBins * sizeof(lutEntry_t);
210208

211209
if (size < expectedSize) {
212210
throw framework::runtime_error_f("Buffer size mismatch: expected %zu, got %zu", expectedSize, size);
213211
}
214212
}
215213

216-
lutHeader_t FlatLutData::PreviewHeader(const uint8_t* buffer, size_t size)
214+
lutHeader_t FlatLutData::previewHeader(const uint8_t* buffer, size_t size)
217215
{
218216
if (size < sizeof(lutHeader_t)) {
219217
throw framework::runtime_error_f("Buffer too small for LUT header: expected at least %zu, got %zu", sizeof(lutHeader_t), size);
220218
}
221-
const auto* header = reinterpret_cast<const lutHeader_t*>(buffer);
222-
if (!header->check_version()) {
219+
const auto* header = static_cast<const lutHeader_t*>(static_cast<const void*>(buffer));
220+
if (!header->checkVersion()) {
223221
throw framework::runtime_error_f("LUT header version mismatch: expected %d, got %d", LUTCOVM_VERSION, header->version);
224222
}
225223
return *header;
@@ -256,14 +254,14 @@ bool FlatLutData::isLoaded() const
256254
return ((!mData.empty()) || (!mDataRef.empty()));
257255
}
258256

259-
lutHeader_t FlatLutData::PreviewHeader(std::ifstream& file, const char* filename)
257+
lutHeader_t FlatLutData::previewHeader(std::ifstream& file, const char* filename)
260258
{
261259
lutHeader_t tempHeader;
262260
file.read(reinterpret_cast<char*>(&tempHeader), sizeof(lutHeader_t));
263261
if (file.gcount() != static_cast<std::streamsize>(sizeof(lutHeader_t))) {
264262
throw framework::runtime_error_f("Failed to read LUT header from %s", filename);
265263
}
266-
if (!tempHeader.check_version()) {
264+
if (!tempHeader.checkVersion()) {
267265
throw framework::runtime_error_f("LUT header version mismatch: expected %d, got %d", LUTCOVM_VERSION, tempHeader.version);
268266
}
269267
return tempHeader;
@@ -272,7 +270,7 @@ lutHeader_t FlatLutData::PreviewHeader(std::ifstream& file, const char* filename
272270
FlatLutData FlatLutData::loadFromFile(std::ifstream& file, const char* filename)
273271
{
274272
// Read header first
275-
lutHeader_t tempHeader = PreviewHeader(file, filename);
273+
lutHeader_t tempHeader = previewHeader(file, filename);
276274

277275
FlatLutData data;
278276

@@ -300,4 +298,4 @@ void FlatLutData::reset()
300298
resetDimensions();
301299
}
302300

303-
} // namespace o2::delphes
301+
} // namespace o2::fastsim

0 commit comments

Comments
 (0)