Skip to content

Commit cfd760e

Browse files
authored
[ALICE3] Fix casts (#18381)
1 parent 1b35063 commit cfd760e

11 files changed

Lines changed: 20 additions & 20 deletions

‎ALICE3/Core/FlatLutEntry.cxx‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,23 @@ size_t FlatLutData::getEntryOffset(int nch_bin, int rad_bin, int eta_bin, int pt
140140
const lutEntry_t* FlatLutData::getEntryRef(int nch_bin, int rad_bin, int eta_bin, int pt_bin) const
141141
{
142142
size_t offset = getEntryOffset(nch_bin, rad_bin, eta_bin, pt_bin);
143-
return reinterpret_cast<const lutEntry_t*>(mDataRef.data() + offset);
143+
return reinterpret_cast<const lutEntry_t*>(mDataRef.data() + offset); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
144144
}
145145

146146
lutEntry_t* FlatLutData::getEntry(int nch_bin, int rad_bin, int eta_bin, int pt_bin)
147147
{
148148
size_t offset = getEntryOffset(nch_bin, rad_bin, eta_bin, pt_bin);
149-
return reinterpret_cast<lutEntry_t*>(mData.data() + offset);
149+
return reinterpret_cast<lutEntry_t*>(mData.data() + offset); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
150150
}
151151

152152
const lutHeader_t& FlatLutData::getHeaderRef() const
153153
{
154-
return *static_cast<const lutHeader_t*>(static_cast<const void*>(mDataRef.data()));
154+
return *reinterpret_cast<const lutHeader_t*>(mDataRef.data()); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
155155
}
156156

157157
lutHeader_t& FlatLutData::getHeader()
158158
{
159-
return *static_cast<lutHeader_t*>(static_cast<void*>(mData.data()));
159+
return *reinterpret_cast<lutHeader_t*>(mData.data()); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
160160
}
161161

162162
void FlatLutData::updateRef()
@@ -216,7 +216,7 @@ lutHeader_t FlatLutData::previewHeader(const uint8_t* buffer, size_t size)
216216
if (size < sizeof(lutHeader_t)) {
217217
throw framework::runtime_error_f("Buffer too small for LUT header: expected at least %zu, got %zu", sizeof(lutHeader_t), size);
218218
}
219-
const auto* header = static_cast<const lutHeader_t*>(static_cast<const void*>(buffer));
219+
const auto* header = reinterpret_cast<const lutHeader_t*>(buffer); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
220220
if (!header->checkVersion()) {
221221
throw framework::runtime_error_f("LUT header version mismatch: expected %d, got %d", LUTCOVM_VERSION, header->version);
222222
}
@@ -246,7 +246,7 @@ FlatLutData FlatLutData::ViewFromBuffer(const uint8_t* buffer, size_t size)
246246

247247
FlatLutData FlatLutData::ViewFromBuffer(std::span<std::byte> const& span)
248248
{
249-
return ViewFromBuffer(reinterpret_cast<const uint8_t*>(span.data()), span.size_bytes());
249+
return ViewFromBuffer(reinterpret_cast<const uint8_t*>(span.data()), span.size_bytes()); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
250250
}
251251

252252
bool FlatLutData::isLoaded() const
@@ -257,7 +257,7 @@ bool FlatLutData::isLoaded() const
257257
lutHeader_t FlatLutData::previewHeader(std::ifstream& file, const char* filename)
258258
{
259259
lutHeader_t tempHeader;
260-
file.read(reinterpret_cast<char*>(&tempHeader), sizeof(lutHeader_t));
260+
file.read(reinterpret_cast<char*>(&tempHeader), sizeof(lutHeader_t)); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
261261
if (file.gcount() != static_cast<std::streamsize>(sizeof(lutHeader_t))) {
262262
throw framework::runtime_error_f("Failed to read LUT header from %s", filename);
263263
}
@@ -282,7 +282,7 @@ FlatLutData FlatLutData::loadFromFile(std::ifstream& file, const char* filename)
282282
size_t numEntries = static_cast<size_t>(data.mNchBins) * data.mRadBins * data.mEtaBins * data.mPtBins;
283283
size_t entriesSize = numEntries * sizeof(lutEntry_t);
284284

285-
file.read(reinterpret_cast<char*>(data.data() + headerSize), entriesSize);
285+
file.read(reinterpret_cast<char*>(data.data() + headerSize), entriesSize); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
286286
if (file.gcount() != static_cast<std::streamsize>(entriesSize)) {
287287
throw framework::runtime_error_f("Failed to read LUT entries from %s: expected %zu bytes, got %zu", filename, entriesSize, static_cast<size_t>(file.gcount()));
288288
}

‎ALICE3/Core/FlatLutWriter.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void FlatLutWriter::lutWrite(const char* filename, int pdg, float field, size_t
266266
setMap(lutHeader.ptmap, mPtBinning);
267267

268268
// Write header to file
269-
lutFile.write(reinterpret_cast<char*>(&lutHeader), sizeof(lutHeader_t));
269+
lutFile.write(reinterpret_cast<char*>(&lutHeader), sizeof(lutHeader_t)); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
270270
if (!lutFile.good()) {
271271
LOGF(error, "Failed to write LUT header to %s", filename);
272272
lutFile.close();
@@ -361,7 +361,7 @@ void FlatLutWriter::lutWrite(const char* filename, int pdg, float field, size_t
361361
diagonalise(lutEntry);
362362

363363
// Write entry to file
364-
lutFile.write(reinterpret_cast<char*>(&lutEntry), sizeof(lutEntry_t));
364+
lutFile.write(reinterpret_cast<char*>(&lutEntry), sizeof(lutEntry_t)); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
365365
if (!lutFile.good()) {
366366
LOGF(error, "Failed to write LUT entry at index [%d,%d,%d,%d]", inch, irad, ieta, ipt);
367367
lutFile.close();

‎ALICE3/Core/FlatTrackSmearer.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ bool TrackSmearer::viewTable(int pdg, const uint8_t* buffer, size_t size, bool f
171171

172172
bool TrackSmearer::viewTable(int pdg, std::span<std::byte> const& span, bool forceReload)
173173
{
174-
return viewTable(pdg, reinterpret_cast<const uint8_t*>(span.data()), span.size_bytes(), forceReload);
174+
return viewTable(pdg, reinterpret_cast<const uint8_t*>(span.data()), span.size_bytes(), forceReload); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
175175
}
176176

177177
bool TrackSmearer::hasTable(int pdg) const

‎ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ struct OnTheFlyMidPid {
10361036
if (etStatus) {
10371037
histos.fill(HIST("h1dEventTimedelta"), eventCollisionTimePS - tzero[0]);
10381038
}
1039-
static_cast<TEfficiency*>(listEfficiency->At(0))->Fill(etStatus, dNdEta);
1039+
dynamic_cast<TEfficiency*>(listEfficiency->At(0))->Fill(etStatus, dNdEta);
10401040
}
10411041

10421042
// Then we do a second loop to compute the measured quantities with the measured event time

‎ALICE3/TableProducer/alice3-correlatorDDbar.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct alice3correlatorddbar {
115115

116116
void init(InitContext&)
117117
{
118-
auto vbins = (std::vector<double>)binsPt;
118+
auto vbins = std::vector<double>(binsPt);
119119
registry.add("hMass", "D0,D0bar candidates;inv. mass (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
120120
registry.add("hMassD0", "D0,D0bar candidates;inv. mass D0 only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});
121121
registry.add("hMassD0bar", "D0,D0bar candidates;inv. mass D0bar only (#pi K) (GeV/#it{c}^{2});entries", {HistType::kTH2F, {{massAxisBins, massAxisMin, massAxisMax}, {vbins, "#it{p}_{T} (GeV/#it{c})"}}});

‎ALICE3/TableProducer/alice3DqTableMaker.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ struct Alice3DqTableMaker {
301301
fStatsList.setObject(new TList());
302302
fStatsList->SetOwner(true);
303303
std::vector<TString> eventLabels{"Collisions before filtering", "Before cuts", "After cuts"};
304-
TH2I* histEvents = new TH2I("EventStats", "Event statistics", eventLabels.size(), -0.5, eventLabels.size() - 0.5, o2::aod::evsel::kNsel + 1, -0.5, (float)o2::aod::evsel::kNsel + 0.5);
304+
TH2I* histEvents = new TH2I("EventStats", "Event statistics", eventLabels.size(), -0.5, eventLabels.size() - 0.5, o2::aod::evsel::kNsel + 1, -0.5, static_cast<float>(o2::aod::evsel::kNsel) + 0.5);
305305
int ibX = 1;
306306
for (auto label = eventLabels.begin(); label != eventLabels.end(); label++, ibX++) {
307307
histEvents->GetXaxis()->SetBinLabel(ibX, (*label).Data());
@@ -583,7 +583,7 @@ struct Alice3DqTableMaker {
583583
if (fDoDetailedQA) {
584584
j = 0;
585585
for (const auto& cut : fTrackCuts) {
586-
if ((trackTempFilterMap & (uint8_t(1) << j)) != 0u) {
586+
if ((trackTempFilterMap & (static_cast<uint8_t>(1) << j)) != 0u) {
587587
fHistMan->FillHistClass(Form("TrackBarrel_%s_%s", cut->GetName(), sig->GetName()), dqefficiency_helpers::varValues()); // fill the reconstructed truth
588588
}
589589
j++;

‎ALICE3/TableProducer/alice3HfSelector3Prong.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct Alice3HfSelector3Prong {
114114
labels[1 + aod::SelectionStep::RecoPID] = "Skims & Topological & PID selections";
115115
labels[1 + aod::SelectionStep::RecoMl] = "ML selection";
116116
static const AxisSpec axisSelections = {kNBinsSelections, 0.5, kNBinsSelections + 0.5, ""};
117-
registry.add("hSelections", "Selections;;#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisSelections, {(std::vector<double>)binsPt, "#it{p}_{T} (GeV/#it{c})"}}});
117+
registry.add("hSelections", "Selections;;#it{p}_{T} (GeV/#it{c})", {HistType::kTH2F, {axisSelections, {std::vector<double>(binsPt), "#it{p}_{T} (GeV/#it{c})"}}});
118118
for (int iBin = 0; iBin < kNBinsSelections; ++iBin) {
119119
registry.get<TH2>(HIST("hSelections"))->GetXaxis()->SetBinLabel(iBin + 1, labels[iBin].data());
120120
}

‎ALICE3/TableProducer/alice3TrackingTranslator.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ struct Alice3TrackingTranslator {
360360
if (filesList) {
361361
TIter next(filesList);
362362
TSystemFile* file;
363-
while ((file = static_cast<TSystemFile*>(next()))) {
363+
while ((file = dynamic_cast<TSystemFile*>(next()))) {
364364
TString fname = file->GetName();
365365
LOG(debug) << "Found file: " << fname.Data();
366366
if (!file->IsDirectory() && fname.EndsWith(".root")) {

‎ALICE3/Tasks/alice3-qa-multiplicity.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct ALICE3MultTask {
4141

4242
void init(InitContext&)
4343
{
44-
const AxisSpec axisMult{MaxMult.value > 10000.f ? 10000 : (int)MaxMult, 0, MaxMult, "Reconstructed tracks"};
44+
const AxisSpec axisMult{MaxMult.value > 10000.f ? 10000 : static_cast<int>(MaxMult), 0, MaxMult, "Reconstructed tracks"};
4545
TString tit = Form("%.3f < #it{#eta} < %.3f", MinEta.value, MaxEta.value);
4646
histos.add("multiplicity/numberOfTracksNoCut", tit, kTH1D, {axisMult});
4747
histos.add("multiplicity/numberOfTracks", tit, kTH1D, {axisMult});

‎ALICE3/Tasks/alice3DqEfficiency.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ struct Alice3DqEfficiencyAnalysisSameEventPairing {
983983
fHistMan->SetUseDefaultVariableNames(true);
984984
fHistMan->SetDefaultVarNames(dqefficiency_helpers::varNames(), dqefficiency_helpers::varUnits());
985985

986-
VarManager::SetCollisionSystem((TString)fConfigOptions.syst, fConfigOptions.energy); // set collision system and center of mass energy
986+
VarManager::SetCollisionSystem(TString(fConfigOptions.syst), fConfigOptions.energy); // set collision system and center of mass energy
987987

988988
defineHistograms(fHistMan, histNames.Data(), cfgAddSEPHistogram.value.data()); // define all histograms
989989
dqhistograms::AddHistogramsFromJSON(fHistMan, cfgAddJSONHistograms.value.c_str()); // ad-hoc histograms via JSON

0 commit comments

Comments
 (0)