From 07397253dfcf6eefc5acd2b085a7565c32ddbee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Thu, 10 Sep 2026 11:43:56 +0200 Subject: [PATCH] Fix check warnings --- ALICE3/TableProducer/OTF/onTheFlyTracker.cxx | 169 ++++++++++--------- 1 file changed, 89 insertions(+), 80 deletions(-) diff --git a/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx b/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx index b277127f906..ea200240565 100644 --- a/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx +++ b/ALICE3/TableProducer/OTF/onTheFlyTracker.cxx @@ -102,8 +102,6 @@ #include #include -#include - using namespace o2; using namespace o2::framework; using std::array; @@ -291,9 +289,9 @@ struct OnTheFlyTracker { nSiliconHits(nSiliconHitsInput), nTPCHits(nTPCHitsInput), trackType(trackTypeInput) {} - const TimeEst& getTimeMUS() const { return timeEst; } + [[nodiscard]] const TimeEst& getTimeMUS() const { return timeEst; } int64_t mcLabel = -1; ///< MC label of the track - TimeEst timeEst{}; ///< time estimate in ns + TimeEst timeEst; ///< time estimate in ns bool isDecayDau = false; ///< is a decay daughter bool isPVContributor = false; ///< track is PV contributor bool isWeakDecayDau = false; ///< is a weak decay daughter @@ -450,7 +448,7 @@ struct OnTheFlyTracker { // load LUTs for primaries for (const auto& entry : globalConfiguration) { int pdg = 0; - if (entry.first.find("lut") != 0) { + if (!entry.first.starts_with("lut")) { continue; } if (entry.first.find("lutEl") != std::string::npos) { @@ -487,8 +485,7 @@ struct OnTheFlyTracker { if (filename.empty()) { LOG(warning) << "No LUT file passed for pdg " << pdg << ", skipping."; } - bool success = mSmearer[icfg]->loadTable(pdg, filename.c_str()); - if (!success) { + if (!mSmearer[icfg]->loadTable(pdg, filename.c_str())) { LOG(fatal) << "Having issue with loading the LUT " << pdg << " " << filename; } } @@ -500,7 +497,7 @@ struct OnTheFlyTracker { mSmearer[icfg]->skipUnreconstructed(!processUnreconstructedTracks.value); insertHist(histPath + "hPtGenerated", "hPtGenerated;#it{p}_{T} (GeV/c);Counts", kTH1D, {{axes.axisMomentum}}); - insertHist(histPath + "hPhiGenerated", "hPhiGenerated;#phi (rad);Counts", kTH1D, {{100, 0.0f, 2 * M_PI, "#phi (rad)"}}); + insertHist(histPath + "hPhiGenerated", "hPhiGenerated;#phi (rad);Counts", kTH1D, {{100, 0.0f, o2::constants::math::TwoPI, "#phi (rad)"}}); insertHist(histPath + "hPtGeneratedEl", "hPtGeneratedEl;Gen #it{p}_{T} (GeV/c);Counts", kTH1D, {{axes.axisMomentum}}); insertHist(histPath + "hPtGeneratedPi", "hPtGeneratedPi;Gen #it{p}_{T} (GeV/c);Counts", kTH1D, {{axes.axisMomentum}}); @@ -740,7 +737,7 @@ struct OnTheFlyTracker { // Cross-check LOGF(info, "Check field at (0, 0, 0): %.1f kG, nominal: %.1f", static_cast(fieldInstance->GetBz(0, 0, 0)), static_cast(field)); LOGF(info, "Initializing empty material cylinder LUT - could be better in the future"); - o2::base::MatLayerCylSet* lut = new o2::base::MatLayerCylSet(); + auto* lut = new o2::base::MatLayerCylSet(); lut->addLayer(200, 200.1, 2, 1.0f, 100.0f); LOGF(info, "MatLayerCylSet::optimizePhiSlices()"); lut->optimizePhiSlices(); @@ -1070,10 +1067,10 @@ struct OnTheFlyTracker { if (TMath::IsNaN(xiDaughterTrackParCovsTracked[i].getZ())) { isReco[i] = false; continue; - } else { - getHist(histPath + "hXiBuilding")->Fill(4.0f); - histos.fill(HIST("hNaNBookkeeping"), i + 1, 1.0f); } + getHist(histPath + "hXiBuilding")->Fill(4.0f); + histos.fill(HIST("hNaNBookkeeping"), i + 1, 1.0f); + trackTime = (eventCollisionTimeNS + gRandom->Gaus(0., timeResolutionNs)) * nsToMus; // TODO: add flag for whether it's a ghost track or not, currently assuming all are reconstructed tracks if they pass the fast tracker requirements TrackType trackType = isReco[i] ? TrackType::kRecoCascDaug : TrackType::kGenCascDaug; @@ -1298,7 +1295,7 @@ struct OnTheFlyTracker { o2::track::TrackParCov trackedCascade; const o2::track::TrackParCov& trackedBach = xiDaughterTrackParCovsTracked[0]; const int nCascHits = fastTracker[icfg]->FastTrack(perfectCascadeTrack, trackedCascade, dNdEta, xiDecayRadius2D); - reconstructedCascade = (fastTrackerSettings.minSiliconHitsForKinkReco < nCascHits) ? true : false; + reconstructedCascade = fastTrackerSettings.minSiliconHitsForKinkReco < nCascHits; if (reconstructedCascade) { std::array pCasc{}; std::array pBach{}; @@ -1358,10 +1355,9 @@ struct OnTheFlyTracker { std::array{o2::constants::physics::MassPionCharged, o2::constants::physics::MassLambda}); newCascadeTrack.setPID(pdgCodeToPID(PDG_t::kXiMinus)); // FIXME: not OK for omegas float trackTime = (eventCollisionTimeNS + gRandom->Gaus(0., timeResolutionNs)) * nsToMus; - if (reconstructedCascade) { - tracksCascadeProngs[kCascProngs + 1] = TrackAlice3{newCascadeTrack, mcParticle.globalIndex(), trackTime, timeResolutionUs, false, false, false, 1, thisCascade.foundClusters, TrackType::kRecoCascDaug}; - } - tracksCascadeProngs[kCascProngs + 1] = TrackAlice3{newCascadeTrack, mcParticle.globalIndex(), trackTime, timeResolutionUs, false, false, false, 1, thisCascade.foundClusters, 0, TrackType::kRecoCascDaug}; + + tracksCascadeProngs[kCascProngs + 1] = TrackAlice3{newCascadeTrack, mcParticle.globalIndex(), trackTime, timeResolutionUs, false, false, false, 1, thisCascade.foundClusters, TrackType::kRecoCascDaug}; + fillCascadeTable = true; } // end fitter OK } // end cascade found @@ -1840,57 +1836,58 @@ struct OnTheFlyTracker { /// \param trackParCov track of the particle to compute bremsstrahlung for void computeBremsstrahlungLoss(const int icfg, const auto& mcParticle, o2::track::TrackParCov& trackParCov) { - if (brSettings.radiateBR) { - const o2::fastsim::GeometryEntry geoEntry = mGeoContainer.getEntry(icfg); - - for (auto const& layerName : geoEntry.getLayerNames()) { - if (layerName.find("global") != std::string::npos) { // Layers with global tag are skipped - continue; - } + if (!brSettings.radiateBR) { + return; + } + const o2::fastsim::GeometryEntry geoEntry = mGeoContainer.getEntry(icfg); - float mass = o2::constants::physics::MassElectron; + for (auto const& layerName : geoEntry.getLayerNames()) { + if (layerName.find("global") != std::string::npos) { // Layers with global tag are skipped + continue; + } - switch (std::abs(mcParticle.pdgCode())) { - case kElectron: - mass = o2::constants::physics::MassElectron; - break; - case kMuonMinus: - mass = o2::constants::physics::MassMuon; - break; - case kPiPlus: - mass = o2::constants::physics::MassPionCharged; - break; - case kKPlus: - mass = o2::constants::physics::MassKaonCharged; - break; - case kProton: - mass = o2::constants::physics::MassProton; - break; - default: - break; - } + float mass = o2::constants::physics::MassElectron; + + switch (std::abs(mcParticle.pdgCode())) { + case kElectron: + mass = o2::constants::physics::MassElectron; + break; + case kMuonMinus: + mass = o2::constants::physics::MassMuon; + break; + case kPiPlus: + mass = o2::constants::physics::MassPionCharged; + break; + case kKPlus: + mass = o2::constants::physics::MassKaonCharged; + break; + case kProton: + mass = o2::constants::physics::MassProton; + break; + default: + break; + } - float lambda = brSettings.radiationStrength * mcParticle.e() * geoEntry.getFloatValue(layerName, "x0") / (mass * mass); - ULong64_t nPhotons = gRandom->Poisson(lambda); + float lambda = brSettings.radiationStrength * mcParticle.e() * geoEntry.getFloatValue(layerName, "x0") / (mass * mass); + ULong64_t nPhotons = gRandom->Poisson(lambda); - double initialMomentum = trackParCov.getP(); + double initialMomentum = trackParCov.getP(); - for (ULong64_t photon = 0; photon < nPhotons; ++photon) { - float radiativeLoss = 1.0f - brSettings.minBREnergyFraction * std::pow(brSettings.maxBREnergyFraction / brSettings.minBREnergyFraction, gRandom->Rndm()); - trackParCov.setQ2Pt(trackParCov.getQ2Pt() / radiativeLoss); - } + for (ULong64_t photon = 0; photon < nPhotons; ++photon) { + float radiativeLoss = 1.0f - brSettings.minBREnergyFraction * std::pow(brSettings.maxBREnergyFraction / brSettings.minBREnergyFraction, gRandom->Rndm()); + trackParCov.setQ2Pt(trackParCov.getQ2Pt() / radiativeLoss); + } - double afterRadiationMomentum = trackParCov.getP(); + double afterRadiationMomentum = trackParCov.getP(); - if (brSettings.doBRQA) { - const std::string histPath = "Configuration_" + std::to_string(icfg) + "/"; + if (brSettings.doBRQA) { + const std::string histPath = "Configuration_" + std::to_string(icfg) + "/"; - getHist(histPath + "h1dNBRPhotons")->Fill(static_cast(nPhotons)); - getHist(histPath + "h1dBREnergyLoss")->Fill((initialMomentum - afterRadiationMomentum) / afterRadiationMomentum); + getHist(histPath + "h1dNBRPhotons")->Fill(static_cast(nPhotons)); + getHist(histPath + "h1dBREnergyLoss")->Fill((initialMomentum - afterRadiationMomentum) / afterRadiationMomentum); - getHist(histPath + "h2dBRPtRes")->Fill(trackParCov.getPt(), (trackParCov.getPt() - mcParticle.pt()) / trackParCov.getPt()); - getHist(histPath + "h2dBRPtResAbs")->Fill(trackParCov.getPt(), trackParCov.getPt() - mcParticle.pt()); - } + getHist(histPath + "h2dBRPtRes")->Fill(trackParCov.getPt(), (trackParCov.getPt() - mcParticle.pt()) / trackParCov.getPt()); + getHist(histPath + "h2dBRPtResAbs")->Fill(trackParCov.getPt(), trackParCov.getPt() - mcParticle.pt()); } } } @@ -1980,28 +1977,44 @@ struct OnTheFlyTracker { } getHist(histPath + "hPtGenerated")->Fill(mcParticle.pt()); getHist(histPath + "hPhiGenerated")->Fill(mcParticle.phi()); - if (std::abs(mcParticle.pdgCode()) == kElectron) - getHist(histPath + "hPtGeneratedEl")->Fill(mcParticle.pt()); - if (std::abs(mcParticle.pdgCode()) == kPiPlus) - getHist(histPath + "hPtGeneratedPi")->Fill(mcParticle.pt()); - if (std::abs(mcParticle.pdgCode()) == kKPlus) - getHist(histPath + "hPtGeneratedKa")->Fill(mcParticle.pt()); - if (std::abs(mcParticle.pdgCode()) == kProton) - getHist(histPath + "hPtGeneratedPr")->Fill(mcParticle.pt()); + switch (std::abs(mcParticle.pdgCode())) { + case kElectron: + getHist(histPath + "hPtGeneratedEl")->Fill(mcParticle.pt()); + break; + case kPiPlus: + getHist(histPath + "hPtGeneratedPi")->Fill(mcParticle.pt()); + break; + case kKPlus: + getHist(histPath + "hPtGeneratedKa")->Fill(mcParticle.pt()); + break; + case kProton: + getHist(histPath + "hPtGeneratedPr")->Fill(mcParticle.pt()); + break; + default: + break; + } if (!reconstructed && !processUnreconstructedTracks) { continue; } getHist(histPath + "hPtReconstructed")->Fill(trackParCov.getPt()); - if (std::abs(mcParticle.pdgCode()) == kElectron) - getHist(histPath + "hPtReconstructedEl")->Fill(trackParCov.getPt()); - if (std::abs(mcParticle.pdgCode()) == kPiPlus) - getHist(histPath + "hPtReconstructedPi")->Fill(trackParCov.getPt()); - if (std::abs(mcParticle.pdgCode()) == kKPlus) - getHist(histPath + "hPtReconstructedKa")->Fill(trackParCov.getPt()); - if (std::abs(mcParticle.pdgCode()) == kProton) - getHist(histPath + "hPtReconstructedPr")->Fill(trackParCov.getPt()); + switch (std::abs(mcParticle.pdgCode())) { + case kElectron: + getHist(histPath + "hPtReconstructedEl")->Fill(mcParticle.pt()); + break; + case kPiPlus: + getHist(histPath + "hPtReconstructedPi")->Fill(mcParticle.pt()); + break; + case kKPlus: + getHist(histPath + "hPtReconstructedKa")->Fill(mcParticle.pt()); + break; + case kProton: + getHist(histPath + "hPtReconstructedPr")->Fill(mcParticle.pt()); + break; + default: + break; + } } if (doExtraQA) { getHist(histPath + "h2dPtRes")->Fill(trackParCov.getPt(), (trackParCov.getPt() - mcParticle.pt()) / trackParCov.getPt()); @@ -2189,11 +2202,7 @@ struct OnTheFlyTracker { computeBremsstrahlungLoss(icfg, mcParticle, perfectTrackParCov); perfectTrackParCov.setPID(pdgCodeToPID(mcParticle.pdgCode())); nTrkHits = fastTracker[icfg]->FastTrack(perfectTrackParCov, trackParCov, dNdEta); - if (nTrkHits < fastTrackerSettings.minSiliconHits) { - reconstructed = false; - } else { - reconstructed = true; - } + reconstructed = nTrkHits >= fastTrackerSettings.minSiliconHits; } if (!reconstructed && !processUnreconstructedTracks) {