From 02871af6ce859522350a54b0b4cea2a99276f9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 21:14:39 +0200 Subject: [PATCH 01/14] Fix types --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index 8bfd706500a..fa70d079d4b 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -1188,7 +1188,7 @@ struct HfTrackIndexSkimCreator { struct : ConfigurableGroup { Configurable isRun2{"isRun2", false, "enable Run 2 or Run 3 GRP objects for magnetic field"}; - Configurable do3Prong{"do3Prong", 0, "do 3 prong"}; + Configurable do3Prong{"do3Prong", false, "do 3 prong"}; Configurable doDstar{"doDstar", false, "do D* candidates"}; Configurable debug{"debug", false, "debug mode"}; Configurable debugPvRefit{"debugPvRefit", false, "debug lines for primary vertex refit"}; @@ -2117,8 +2117,8 @@ struct HfTrackIndexSkimCreator { std::array, kN2ProngDecays> cutStatus2Prong; std::array, kN3ProngDecays> cutStatus3Prong; - bool nCutStatus2ProngBit[kN2ProngDecays]; // bit value for selection status for each 2-prong candidate where each selection is one bit and they are all set to 1 - bool nCutStatus3ProngBit[kN3ProngDecays]; // bit value for selection status for each 3-prong candidate where each selection is one bit and they are all set to 1 + uint8_t nCutStatus2ProngBit[kN2ProngDecays]; // bit value for selection status for each 2-prong candidate where each selection is one bit and they are all set to 1 + uint8_t nCutStatus3ProngBit[kN3ProngDecays]; // bit value for selection status for each 3-prong candidate where each selection is one bit and they are all set to 1 for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { nCutStatus2ProngBit[iDecay2P] = BIT(kNCuts2Prong[iDecay2P]) - 1; @@ -2324,7 +2324,7 @@ struct HfTrackIndexSkimCreator { } if (config.debug) { - int prong2CutStatus[kN2ProngDecays]; + uint8_t prong2CutStatus[kN2ProngDecays]; for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { prong2CutStatus[iDecay2P] = nCutStatus2ProngBit[iDecay2P]; for (int iCut = 0; iCut < kNCuts2Prong[iDecay2P]; iCut++) { @@ -2588,7 +2588,7 @@ struct HfTrackIndexSkimCreator { } if (config.debug) { - int prong3CutStatus[kN3ProngDecays]; + uint8_t prong3CutStatus[kN3ProngDecays]; for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { prong3CutStatus[iDecay3P] = nCutStatus3ProngBit[iDecay3P]; for (int iCut = 0; iCut < kNCuts3Prong[iDecay3P]; iCut++) { From 3d037f22c47833b746027639e4bec9cb859885b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 21:15:02 +0200 Subject: [PATCH 02/14] Reduce unnecessary operations --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 107 +++++++++--------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index fa70d079d4b..f22df74c44a 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -1497,16 +1497,15 @@ struct HfTrackIndexSkimCreator { { whichHypo[kN2ProngDecays] = 0; // D0 for D* - auto arrMom = std::array{pVecTrack0, pVecTrack1}; pt2Prong = RecoDecay::pt(pVecTrack0, pVecTrack1); - auto pT = pt2Prong + config.ptTolerance; // add tolerance because of no reco decay vertex + auto pt = pt2Prong + config.ptTolerance; // add tolerance because of no reco decay vertex for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { // pT - auto pTBin = findBin(&pTBins2Prong[iDecay2P], pT); + auto binPt = findBin(&pTBins2Prong[iDecay2P], pt); // return immediately if it is outside the defined pT bins - if (pTBin == -1) { + if (binPt == -1) { CLRBIT(isSelected, iDecay2P); if (config.debug) { cutStatus[iDecay2P][0] = false; @@ -1515,26 +1514,29 @@ struct HfTrackIndexSkimCreator { } // invariant mass - double massHypos[2] = {0.f, 0.f}; - whichHypo[iDecay2P] = 3; - double minMass = cut2Prong[iDecay2P].get(pTBin, 0u); - double maxMass = cut2Prong[iDecay2P].get(pTBin, 1u); - double min2 = minMass * minMass; - double max2 = maxMass * maxMass; - - if ((config.debug || TESTBIT(isSelected, iDecay2P)) && minMass >= 0. && maxMass > 0.) { - massHypos[0] = RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][0]); - massHypos[1] = (iDecay2P == hf_cand_2prong::DecayType::D0ToPiK) ? RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][1]) : massHypos[0]; - if (massHypos[0] < min2 || massHypos[0] >= max2) { - CLRBIT(whichHypo[iDecay2P], 0); - } - if (massHypos[1] < min2 || massHypos[1] >= max2) { - CLRBIT(whichHypo[iDecay2P], 1); - } - if (whichHypo[iDecay2P] == 0) { - CLRBIT(isSelected, iDecay2P); - if (config.debug) { - cutStatus[iDecay2P][1] = false; + double massHypos[2] = {0., 0.}; + whichHypo[iDecay2P] = 3; // 2 bits on + + if (config.debug || TESTBIT(isSelected, iDecay2P)) { + double minMass = cut2Prong[iDecay2P].get(binPt, 0u); + double maxMass = cut2Prong[iDecay2P].get(binPt, 1u); + if (minMass >= 0. && maxMass > 0.) { + auto arrMom = std::array{pVecTrack0, pVecTrack1}; + massHypos[0] = RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][0]); + massHypos[1] = (iDecay2P == hf_cand_2prong::DecayType::D0ToPiK) ? RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][1]) : massHypos[0]; + double min2 = minMass * minMass; + double max2 = maxMass * maxMass; + if (massHypos[0] < min2 || massHypos[0] >= max2) { + CLRBIT(whichHypo[iDecay2P], 0); + } + if (massHypos[1] < min2 || massHypos[1] >= max2) { + CLRBIT(whichHypo[iDecay2P], 1); + } + if (whichHypo[iDecay2P] == 0) { + CLRBIT(isSelected, iDecay2P); + if (config.debug) { + cutStatus[iDecay2P][1] = false; + } } } } @@ -1542,7 +1544,7 @@ struct HfTrackIndexSkimCreator { // imp. par. product cut if (config.debug || TESTBIT(isSelected, iDecay2P)) { auto impParProduct = dcaTrack0 * dcaTrack1; - if (impParProduct > cut2Prong[iDecay2P].get(pTBin, 3u)) { + if (impParProduct > cut2Prong[iDecay2P].get(binPt, 3u)) { CLRBIT(isSelected, iDecay2P); if (config.debug) { cutStatus[iDecay2P][2] = false; @@ -1552,7 +1554,7 @@ struct HfTrackIndexSkimCreator { // additional check for D0 to be used in D* finding if (iDecay2P == hf_cand_2prong::DecayType::D0ToPiK && config.doDstar && TESTBIT(isSelected, iDecay2P)) { - auto pTBinDstar = findBin(config.binsPtDstarToD0Pi, pT * 1.2); // assuming the D* pT about 20% higher than the one of the D0 to be safe + auto pTBinDstar = findBin(config.binsPtDstarToD0Pi, pt * 1.2); // assuming the D* pT about 20% higher than the one of the D0 to be safe if (pTBinDstar >= 0) { whichHypo[kN2ProngDecays] = whichHypo[hf_cand_2prong::DecayType::D0ToPiK]; double deltaMass = config.cutsDstarToD0Pi->get(pTBinDstar, 1u); @@ -1592,7 +1594,6 @@ struct HfTrackIndexSkimCreator { CLRBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 1); } } - if (whichHypo[hf_cand_3prong::DecayType::DsToKKPi] == 0) { CLRBIT(isSelected, hf_cand_3prong::DecayType::DsToKKPi); if (config.debug) { @@ -1613,14 +1614,12 @@ struct HfTrackIndexSkimCreator { template void applyPreselection3Prong(T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, int8_t& isIdentifiedPidTrack0, int8_t& isIdentifiedPidTrack2, T2& cutStatus, T3& whichHypo, int& isSelected) { - - auto arrMom = std::array{pVecTrack0, pVecTrack1, pVecTrack2}; - auto pT = RecoDecay::pt(pVecTrack0, pVecTrack1, pVecTrack2) + config.ptTolerance; // add tolerance because of no reco decay vertex + auto pt = RecoDecay::pt(pVecTrack0, pVecTrack1, pVecTrack2) + config.ptTolerance; // add tolerance because of no reco decay vertex for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { // check proton PID for Lc and Xic - whichHypo[iDecay3P] = 3; + whichHypo[iDecay3P] = 3; // 2 bits on if ((iDecay3P == hf_cand_3prong::DecayType::LcToPKPi && config.applyProtonPidForLcToPKPi) || (iDecay3P == hf_cand_3prong::DecayType::XicToPKPi && config.applyProtonPidForXicToPKPi)) { if ((iDecay3P == hf_cand_3prong::DecayType::LcToPKPi && !TESTBIT(isIdentifiedPidTrack0, ChannelsProtonPid::LcToPKPi)) || (iDecay3P == hf_cand_3prong::DecayType::XicToPKPi && !TESTBIT(isIdentifiedPidTrack0, ChannelsProtonPid::XicToPKPi))) { CLRBIT(whichHypo[iDecay3P], 0); @@ -1638,9 +1637,9 @@ struct HfTrackIndexSkimCreator { } // pT - auto pTBin = findBin(&pTBins3Prong[iDecay3P], pT); + auto binPt = findBin(&pTBins3Prong[iDecay3P], pt); // return immediately if it is outside the defined pT bins - if (pTBin == -1) { + if (binPt == -1) { CLRBIT(isSelected, iDecay3P); whichHypo[iDecay3P] = 0; if (config.debug) { @@ -1650,31 +1649,33 @@ struct HfTrackIndexSkimCreator { } // invariant mass - double massHypos[2]; - double minMass = cut3Prong[iDecay3P].get(pTBin, 0u); - double maxMass = cut3Prong[iDecay3P].get(pTBin, 1u); - double min2 = minMass * minMass; - double max2 = maxMass * maxMass; - - if ((config.debug || TESTBIT(isSelected, iDecay3P)) && minMass >= 0. && maxMass > 0.) { // no need to check isSelected but to avoid mistakes - massHypos[0] = RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][0]); - massHypos[1] = (iDecay3P != hf_cand_3prong::DecayType::DplusToPiKPi) ? RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][1]) : massHypos[0]; - if (massHypos[0] < min2 || massHypos[0] >= max2) { - CLRBIT(whichHypo[iDecay3P], 0); - } - if (massHypos[1] < min2 || massHypos[1] >= max2) { - CLRBIT(whichHypo[iDecay3P], 1); - } - if (whichHypo[iDecay3P] == 0) { - CLRBIT(isSelected, iDecay3P); - if (config.debug) { - cutStatus[iDecay3P][1] = false; + if ((config.debug || TESTBIT(isSelected, iDecay3P))) { + double minMass = cut3Prong[iDecay3P].get(binPt, 0u); + double maxMass = cut3Prong[iDecay3P].get(binPt, 1u); + if (minMass >= 0. && maxMass > 0.) { // no need to check isSelected but to avoid mistakes + double massHypos[2] = {0., 0.}; + auto arrMom = std::array{pVecTrack0, pVecTrack1, pVecTrack2}; + double min2 = minMass * minMass; + double max2 = maxMass * maxMass; + massHypos[0] = RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][0]); + massHypos[1] = (iDecay3P != hf_cand_3prong::DecayType::DplusToPiKPi) ? RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][1]) : massHypos[0]; + if (massHypos[0] < min2 || massHypos[0] >= max2) { + CLRBIT(whichHypo[iDecay3P], 0); + } + if (massHypos[1] < min2 || massHypos[1] >= max2) { + CLRBIT(whichHypo[iDecay3P], 1); + } + if (whichHypo[iDecay3P] == 0) { + CLRBIT(isSelected, iDecay3P); + if (config.debug) { + cutStatus[iDecay3P][1] = false; + } } } } if ((config.debug || TESTBIT(isSelected, iDecay3P)) && iDecay3P == hf_cand_3prong::DecayType::DsToKKPi) { - applyPreselectionPhiDecay(pTBin, pVecTrack0, pVecTrack1, pVecTrack2, cutStatus, whichHypo, isSelected); + applyPreselectionPhiDecay(binPt, pVecTrack0, pVecTrack1, pVecTrack2, cutStatus, whichHypo, isSelected); } } } From b2fc994992190265c2a13c3593deb4a7f1fd0aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 21:15:07 +0200 Subject: [PATCH 03/14] Add const by clang-tidy --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index f22df74c44a..c3cd17907d9 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -148,7 +148,7 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { hfEvSel.addHistograms(registry); // collision monitoring if (doprocessTrigAndCentFT0ASel || doprocessTrigAndCentFT0CSel || doprocessTrigAndCentFT0MSel || doprocessTrigAndCentFV0ASel) { - AxisSpec axisCentrality{200, 0., 100., "centrality percentile"}; + AxisSpec const axisCentrality{200, 0., 100., "centrality percentile"}; registry.add("hCentralitySelected", "Centrality percentile of selected events in the centrality interval; centrality percentile;entries", {HistType::kTH1D, {axisCentrality}}); registry.add("hCentralityRejected", "Centrality percentile of selected events outside the centrality interval; centrality percentile;entries", {HistType::kTH1D, {axisCentrality}}); } @@ -410,16 +410,16 @@ struct HfTrackIndexSkimCreatorTagSelTracks { // Needed for PV refitting if (config.doPvRefit) { if (config.fillHistograms) { - AxisSpec axisCollisionX{100, -20.f, 20.f, "X (cm)"}; - AxisSpec axisCollisionY{100, -20.f, 20.f, "Y (cm)"}; - AxisSpec axisCollisionZ{100, -20.f, 20.f, "Z (cm)"}; - AxisSpec axisCollisionXOriginal{100, -2.f, 2.f, "X original PV (cm)"}; - AxisSpec axisCollisionYOriginal{100, -2.f, 2.f, "Y original PV (cm)"}; - AxisSpec axisCollisionZOriginal{100, -2.f, 2.f, "Z original PV (cm)"}; - AxisSpec axisCollisionNContrib{1000, 0, 1000, "Number of contributors"}; - AxisSpec axisCollisionDeltaX{axisPvRefitDeltaX, "#Delta x_{PV} (cm)"}; - AxisSpec axisCollisionDeltaY{axisPvRefitDeltaY, "#Delta y_{PV} (cm)"}; - AxisSpec axisCollisionDeltaZ{axisPvRefitDeltaZ, "#Delta z_{PV} (cm)"}; + AxisSpec const axisCollisionX{100, -20.f, 20.f, "X (cm)"}; + AxisSpec const axisCollisionY{100, -20.f, 20.f, "Y (cm)"}; + AxisSpec const axisCollisionZ{100, -20.f, 20.f, "Z (cm)"}; + AxisSpec const axisCollisionXOriginal{100, -2.f, 2.f, "X original PV (cm)"}; + AxisSpec const axisCollisionYOriginal{100, -2.f, 2.f, "Y original PV (cm)"}; + AxisSpec const axisCollisionZOriginal{100, -2.f, 2.f, "Z original PV (cm)"}; + AxisSpec const axisCollisionNContrib{1000, 0, 1000, "Number of contributors"}; + AxisSpec const axisCollisionDeltaX{axisPvRefitDeltaX, "#Delta x_{PV} (cm)"}; + AxisSpec const axisCollisionDeltaY{axisPvRefitDeltaY, "#Delta y_{PV} (cm)"}; + AxisSpec const axisCollisionDeltaZ{axisPvRefitDeltaZ, "#Delta z_{PV} (cm)"}; registry.add("PvRefit/hVerticesPerTrack", "", kTH1D, {{3, 0.5f, 3.5f, ""}}); registry.get(HIST("PvRefit/hVerticesPerTrack"))->GetXaxis()->SetBinLabel(1, "All PV"); @@ -600,7 +600,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { hasGoodQuality = false; } } else { - UChar_t clustermap = hfTrack.itsClusterMap(); + UChar_t const clustermap = hfTrack.itsClusterMap(); if (!(hfTrack.tpcNClsFound() >= config.tpcNClsFoundMin.value && // is this the number of TPC clusters? It should not be used TESTBIT(hfTrack.flags(), o2::aod::track::ITSrefit) && (TESTBIT(clustermap, 0) || TESTBIT(clustermap, 1)))) { @@ -636,7 +636,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { hasGoodQuality = false; } } else { // selections for Run2 converted data - UChar_t clustermap = hfTrack.itsClusterMap(); + UChar_t const clustermap = hfTrack.itsClusterMap(); if (!(TESTBIT(hfTrack.flags(), o2::aod::track::ITSrefit) && (TESTBIT(clustermap, 0) || TESTBIT(clustermap, 1)))) { hasGoodQuality = false; } @@ -665,7 +665,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { hasGoodQuality = false; } } else { // selections for Run2 converted data - UChar_t clustermap = hfTrack.itsClusterMap(); + UChar_t const clustermap = hfTrack.itsClusterMap(); if (!(TESTBIT(hfTrack.flags(), o2::aod::track::ITSrefit) && (TESTBIT(clustermap, 0) || TESTBIT(clustermap, 1)))) { hasGoodQuality = false; } @@ -787,7 +787,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { o2::vertexing::PVertexer vertexer; o2::conf::ConfigurableParam::updateFromString("pvertexer.useMeanVertexConstraint=false"); /// remove diamond constraint (let's keep it at the moment...) vertexer.init(); - bool pvRefitDoable = vertexer.prepareVertexRefit(vecPvContributorTrackParCov, primVtx); + bool const pvRefitDoable = vertexer.prepareVertexRefit(vecPvContributorTrackParCov, primVtx); if (!pvRefitDoable) { LOG(info) << "Not enough tracks accepted for the refit"; if (config.doPvRefit && config.fillHistograms) { @@ -991,8 +991,8 @@ struct HfTrackIndexSkimCreatorTagSelTracks { // } isSelectedTrack(track, trackPt, trackEta, pvRefitDcaXYDcaZ, statusProng); - int8_t isIdentifiedPid = isSelectedPid(track); - bool isPositive = track.sign() > 0; + int8_t const isIdentifiedPid = isSelectedPid(track); + bool const isPositive = track.sign() > 0; rowSelectedTrack(statusProng, isIdentifiedPid, isPositive); } } @@ -1372,8 +1372,8 @@ struct HfTrackIndexSkimCreator { runNumber = 0; if (config.fillHistograms) { - AxisSpec axisNumTracks{500, -0.5f, 499.5f, "Number of tracks"}; - AxisSpec axisNumCands{1000, -0.5f, 999.5f, "Number of candidates"}; + AxisSpec const axisNumTracks{500, -0.5f, 499.5f, "Number of tracks"}; + AxisSpec const axisNumCands{1000, -0.5f, 999.5f, "Number of candidates"}; registry.add("hNTracks", "Number of selected tracks;# of selected tracks;entries", {HistType::kTH1D, {axisNumTracks}}); // 2-prong histograms registry.add("hVtx2ProngX", "2-prong candidates;#it{x}_{sec. vtx.} (cm);entries", {HistType::kTH1D, {{1000, -2., 2.}}}); @@ -1398,16 +1398,16 @@ struct HfTrackIndexSkimCreator { // needed for PV refitting if (doprocess2And3ProngsWithPvRefit || doprocess2And3ProngsWithPvRefitWithPidForHfFiltersBdt) { - AxisSpec axisCollisionX{100, -20.f, 20.f, "X (cm)"}; - AxisSpec axisCollisionY{100, -20.f, 20.f, "Y (cm)"}; - AxisSpec axisCollisionZ{100, -20.f, 20.f, "Z (cm)"}; - AxisSpec axisCollisionXOriginal{1000, -20.f, 20.f, "X original PV (cm)"}; - AxisSpec axisCollisionYOriginal{1000, -20.f, 20.f, "Y original PV (cm)"}; - AxisSpec axisCollisionZOriginal{1000, -20.f, 20.f, "Z original PV (cm)"}; - AxisSpec axisCollisionNContrib{1000, 0, 1000, "Number of contributors"}; - AxisSpec axisCollisionDeltaX{axisPvRefitDeltaX, "#Delta x_{PV} (cm)"}; - AxisSpec axisCollisionDeltaY{axisPvRefitDeltaY, "#Delta y_{PV} (cm)"}; - AxisSpec axisCollisionDeltaZ{axisPvRefitDeltaZ, "#Delta z_{PV} (cm)"}; + AxisSpec const axisCollisionX{100, -20.f, 20.f, "X (cm)"}; + AxisSpec const axisCollisionY{100, -20.f, 20.f, "Y (cm)"}; + AxisSpec const axisCollisionZ{100, -20.f, 20.f, "Z (cm)"}; + AxisSpec const axisCollisionXOriginal{1000, -20.f, 20.f, "X original PV (cm)"}; + AxisSpec const axisCollisionYOriginal{1000, -20.f, 20.f, "Y original PV (cm)"}; + AxisSpec const axisCollisionZOriginal{1000, -20.f, 20.f, "Z original PV (cm)"}; + AxisSpec const axisCollisionNContrib{1000, 0, 1000, "Number of contributors"}; + AxisSpec const axisCollisionDeltaX{axisPvRefitDeltaX, "#Delta x_{PV} (cm)"}; + AxisSpec const axisCollisionDeltaY{axisPvRefitDeltaY, "#Delta y_{PV} (cm)"}; + AxisSpec const axisCollisionDeltaZ{axisPvRefitDeltaZ, "#Delta z_{PV} (cm)"}; registry.add("PvRefit/verticesPerCandidate", "", kTH1D, {{6, 0.5f, 6.5f, ""}}); registry.get(HIST("PvRefit/verticesPerCandidate"))->GetXaxis()->SetBinLabel(1, "All PV"); registry.get(HIST("PvRefit/verticesPerCandidate"))->GetXaxis()->SetBinLabel(2, "PV refit doable"); @@ -1427,7 +1427,7 @@ struct HfTrackIndexSkimCreator { } if (config.applyMlForHfFilters) { - AxisSpec axisBdtScore{100, 0.f, 1.f}; + AxisSpec const axisBdtScore{100, 0.f, 1.f}; registry.add("ML/hMlScoreBkgD0", "Bkg ML score for D^{0} candidates;Bkg ML score;entries", kTH1D, {axisBdtScore}); registry.add("ML/hMlScorePromptD0", "Prompt ML score for D^{0} candidates;Prompt ML score;entries", kTH1D, {axisBdtScore}); registry.add("ML/hMlScoreNonpromptD0", "Non-prompt ML score for D^{0} candidates;Non-prompt ML score;entries", kTH1D, {axisBdtScore}); @@ -1518,14 +1518,14 @@ struct HfTrackIndexSkimCreator { whichHypo[iDecay2P] = 3; // 2 bits on if (config.debug || TESTBIT(isSelected, iDecay2P)) { - double minMass = cut2Prong[iDecay2P].get(binPt, 0u); - double maxMass = cut2Prong[iDecay2P].get(binPt, 1u); + double const minMass = cut2Prong[iDecay2P].get(binPt, 0u); + double const maxMass = cut2Prong[iDecay2P].get(binPt, 1u); if (minMass >= 0. && maxMass > 0.) { auto arrMom = std::array{pVecTrack0, pVecTrack1}; massHypos[0] = RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][0]); massHypos[1] = (iDecay2P == hf_cand_2prong::DecayType::D0ToPiK) ? RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][1]) : massHypos[0]; - double min2 = minMass * minMass; - double max2 = maxMass * maxMass; + double const min2 = minMass * minMass; + double const max2 = maxMass * maxMass; if (massHypos[0] < min2 || massHypos[0] >= max2) { CLRBIT(whichHypo[iDecay2P], 0); } @@ -1557,7 +1557,7 @@ struct HfTrackIndexSkimCreator { auto pTBinDstar = findBin(config.binsPtDstarToD0Pi, pt * 1.2); // assuming the D* pT about 20% higher than the one of the D0 to be safe if (pTBinDstar >= 0) { whichHypo[kN2ProngDecays] = whichHypo[hf_cand_2prong::DecayType::D0ToPiK]; - double deltaMass = config.cutsDstarToD0Pi->get(pTBinDstar, 1u); + double const deltaMass = config.cutsDstarToD0Pi->get(pTBinDstar, 1u); if (TESTBIT(whichHypo[iDecay2P], 0) && (massHypos[0] > (MassD0 + deltaMass) * (MassD0 + deltaMass) || massHypos[0] < (MassD0 - deltaMass) * (MassD0 - deltaMass))) { CLRBIT(whichHypo[kN2ProngDecays], 0); @@ -1581,15 +1581,15 @@ struct HfTrackIndexSkimCreator { template void applyPreselectionPhiDecay(int& pTBin, T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, T2& cutStatus, T3& whichHypo, int& isSelected) { - double deltaMassMax = cut3Prong[hf_cand_3prong::DecayType::DsToKKPi].get(pTBin, 4u); + double const deltaMassMax = cut3Prong[hf_cand_3prong::DecayType::DsToKKPi].get(pTBin, 4u); if (TESTBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 0)) { - double mass2PhiKKPi = RecoDecay::m2(std::array{pVecTrack0, pVecTrack1}, std::array{arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][0][0], arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][0][1]}); + double const mass2PhiKKPi = RecoDecay::m2(std::array{pVecTrack0, pVecTrack1}, std::array{arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][0][0], arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][0][1]}); if (mass2PhiKKPi > (MassPhi + deltaMassMax) * (MassPhi + deltaMassMax) || mass2PhiKKPi < (MassPhi - deltaMassMax) * (MassPhi - deltaMassMax)) { CLRBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 0); } } if (TESTBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 1)) { - double mass2PhiPiKK = RecoDecay::m2(std::array{pVecTrack1, pVecTrack2}, std::array{arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][1][1], arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][1][2]}); + double const mass2PhiPiKK = RecoDecay::m2(std::array{pVecTrack1, pVecTrack2}, std::array{arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][1][1], arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][1][2]}); if (mass2PhiPiKK > (MassPhi + deltaMassMax) * (MassPhi + deltaMassMax) || mass2PhiPiKK < (MassPhi - deltaMassMax) * (MassPhi - deltaMassMax)) { CLRBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 1); } @@ -1650,13 +1650,13 @@ struct HfTrackIndexSkimCreator { // invariant mass if ((config.debug || TESTBIT(isSelected, iDecay3P))) { - double minMass = cut3Prong[iDecay3P].get(binPt, 0u); - double maxMass = cut3Prong[iDecay3P].get(binPt, 1u); + double const minMass = cut3Prong[iDecay3P].get(binPt, 0u); + double const maxMass = cut3Prong[iDecay3P].get(binPt, 1u); if (minMass >= 0. && maxMass > 0.) { // no need to check isSelected but to avoid mistakes double massHypos[2] = {0., 0.}; auto arrMom = std::array{pVecTrack0, pVecTrack1, pVecTrack2}; - double min2 = minMass * minMass; - double max2 = maxMass * maxMass; + double const min2 = minMass * minMass; + double const max2 = maxMass * maxMass; massHypos[0] = RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][0]); massHypos[1] = (iDecay3P != hf_cand_3prong::DecayType::DplusToPiKPi) ? RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][1]) : massHypos[0]; if (massHypos[0] < min2 || massHypos[0] >= max2) { @@ -1727,7 +1727,7 @@ struct HfTrackIndexSkimCreator { return; } const float ptDummy = 1.; // dummy pT value (only one pT bin) - bool isSelMl = hfMlResponse2Prongs.isSelectedMl(featuresCand, ptDummy, outputScores); + bool const isSelMl = hfMlResponse2Prongs.isSelectedMl(featuresCand, ptDummy, outputScores); if (config.fillHistograms) { registry.fill(HIST("ML/hMlScoreBkgD0"), outputScores[0]); registry.fill(HIST("ML/hMlScorePromptD0"), outputScores[1]); @@ -1897,8 +1897,8 @@ struct HfTrackIndexSkimCreator { } // D0 mass - double deltaMassD0 = config.cutsDstarToD0Pi->get(pTBin, 1u); // 1u == deltaMassD0Index - double invMassD0 = RecoDecay::m(arrMomD0, std::array{MassPiPlus, MassKPlus}); + double const deltaMassD0 = config.cutsDstarToD0Pi->get(pTBin, 1u); // 1u == deltaMassD0Index + double const invMassD0 = RecoDecay::m(arrMomD0, std::array{MassPiPlus, MassKPlus}); if (std::abs(invMassD0 - MassD0) > deltaMassD0) { isSelected = 0; if (config.debug) { @@ -1908,8 +1908,8 @@ struct HfTrackIndexSkimCreator { } // D*+ mass - double maxDeltaMass = config.cutsDstarToD0Pi->get(pTBin, 0u); // 0u == deltaMassIndex - double invMassDstar = RecoDecay::m(arrMom, std::array{MassPiPlus, MassKPlus, MassPiPlus}); + double const maxDeltaMass = config.cutsDstarToD0Pi->get(pTBin, 0u); // 0u == deltaMassIndex + double const invMassDstar = RecoDecay::m(arrMom, std::array{MassPiPlus, MassKPlus, MassPiPlus}); deltaMass = invMassDstar - invMassD0; if (deltaMass > maxDeltaMass) { isSelected = 0; @@ -1955,7 +1955,7 @@ struct HfTrackIndexSkimCreator { o2::vertexing::PVertexer vertexer; o2::conf::ConfigurableParam::updateFromString("pvertexer.useMeanVertexConstraint=false"); /// remove diamond constraint (let's keep it at the moment...) vertexer.init(); - bool pvRefitDoable = vertexer.prepareVertexRefit(vecPvContributorTrackParCov, primVtx); + bool const pvRefitDoable = vertexer.prepareVertexRefit(vecPvContributorTrackParCov, primVtx); if (!pvRefitDoable) { LOG(info) << "Not enough tracks accepted for the refit"; if ((doprocess2And3ProngsWithPvRefit || doprocess2And3ProngsWithPvRefitWithPidForHfFiltersBdt) && config.fillHistograms) { @@ -1975,7 +1975,7 @@ struct HfTrackIndexSkimCreator { } recalcPvRefit = true; int nCandContr = 0; - for (uint64_t myGlobalID : vecCandPvContributorGlobId) { // o2-linter: disable=const-ref-in-for-loop (small type) + for (uint64_t const myGlobalID : vecCandPvContributorGlobId) { // o2-linter: disable=const-ref-in-for-loop (small type) auto trackIterator = std::find(vecPvContributorGlobId.begin(), vecPvContributorGlobId.end(), myGlobalID); /// track global index if (trackIterator != vecPvContributorGlobId.end()) { /// this is a contributor, let's remove it for the PV refit @@ -2113,8 +2113,8 @@ struct HfTrackIndexSkimCreator { // auto centrality = collision.centV0M(); //FIXME add centrality when option for variations to the process function appears - int n2ProngBit = BIT(kN2ProngDecays) - 1; // bit value for 2-prong candidates where each candidate is one bit and they are all set to 1 - int n3ProngBit = BIT(kN3ProngDecays) - 1; // bit value for 3-prong candidates where each candidate is one bit and they are all set to 1 + int const n2ProngBit = BIT(kN2ProngDecays) - 1; // bit value for 2-prong candidates where each candidate is one bit and they are all set to 1 + int const n3ProngBit = BIT(kN3ProngDecays) - 1; // bit value for 3-prong candidates where each candidate is one bit and they are all set to 1 std::array, kN2ProngDecays> cutStatus2Prong; std::array, kN3ProngDecays> cutStatus3Prong; @@ -2158,8 +2158,8 @@ struct HfTrackIndexSkimCreator { // retrieve the selection flag that corresponds to this collision auto isSelProngPos1 = trackIndexPos1.isSelProng(); - bool sel2ProngStatusPos = TESTBIT(isSelProngPos1, CandidateType::Cand2Prong); - bool sel3ProngStatusPos1 = TESTBIT(isSelProngPos1, CandidateType::Cand3Prong); + bool const sel2ProngStatusPos = TESTBIT(isSelProngPos1, CandidateType::Cand2Prong); + bool const sel3ProngStatusPos1 = TESTBIT(isSelProngPos1, CandidateType::Cand3Prong); auto trackParVarPos1 = getTrackParCov(trackPos1); std::array pVecTrackPos1{trackPos1.pVector()}; @@ -2176,8 +2176,8 @@ struct HfTrackIndexSkimCreator { // retrieve the selection flag that corresponds to this collision auto isSelProngNeg1 = trackIndexNeg1.isSelProng(); - bool sel2ProngStatusNeg = TESTBIT(isSelProngNeg1, CandidateType::Cand2Prong); - bool sel3ProngStatusNeg1 = TESTBIT(isSelProngNeg1, CandidateType::Cand3Prong); + bool const sel2ProngStatusNeg = TESTBIT(isSelProngNeg1, CandidateType::Cand2Prong); + bool const sel3ProngStatusNeg1 = TESTBIT(isSelProngNeg1, CandidateType::Cand3Prong); auto trackParVarNeg1 = getTrackParCov(trackNeg1); std::array pVecTrackNeg1{trackNeg1.pVector()}; @@ -2304,7 +2304,7 @@ struct HfTrackIndexSkimCreator { if (config.applyMlForHfFilters) { auto trackParVarPcaPos1 = df2.getTrack(0); auto trackParVarPcaNeg1 = df2.getTrack(1); - std::vector inputFeatures{trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1]}; + std::vector const inputFeatures{trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1]}; applyMlSelectionForHfFilters2Prong(inputFeatures, mlScoresD0, isSelected2ProngCand); } @@ -2342,7 +2342,7 @@ struct HfTrackIndexSkimCreator { registry.fill(HIST("hVtx2ProngX"), secondaryVertex2[0]); registry.fill(HIST("hVtx2ProngY"), secondaryVertex2[1]); registry.fill(HIST("hVtx2ProngZ"), secondaryVertex2[2]); - std::array, 2> arrMom = {pvec0, pvec1}; + std::array, 2> const arrMom = {pvec0, pvec1}; for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { if (TESTBIT(isSelected2ProngCand, iDecay2P)) { if (TESTBIT(whichHypo2Prong[iDecay2P], 0)) { @@ -2385,7 +2385,7 @@ struct HfTrackIndexSkimCreator { } if (nVtxFrom2ProngFitter > 0) { const auto& secondaryVertex2 = df2.getPCACandidate(); - std::array pvCoord2Prong = {collision.posX(), collision.posY(), collision.posZ()}; + std::array const pvCoord2Prong = {collision.posX(), collision.posY(), collision.posZ()}; is2ProngCandidateGoodFor3Prong = isTwoTrackVertexSelectedFor3Prongs(secondaryVertex2, pvCoord2Prong, df2); } else { is2ProngCandidateGoodFor3Prong = false; @@ -2561,7 +2561,7 @@ struct HfTrackIndexSkimCreator { std::array, kN3ProngDecays> mlScores3Prongs; if (config.applyMlForHfFilters) { - std::vector inputFeatures{trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos2.getPt(), dcaInfoPos2[0], dcaInfoPos2[1]}; + std::vector const inputFeatures{trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos2.getPt(), dcaInfoPos2[0], dcaInfoPos2[1]}; std::vector inputFeaturesLcPid{}; if constexpr (usePidForHfFiltersBdt) { inputFeaturesLcPid.push_back(trackPos1.tpcNSigmaPr()); @@ -2606,7 +2606,7 @@ struct HfTrackIndexSkimCreator { registry.fill(HIST("hVtx3ProngX"), secondaryVertex3[0]); registry.fill(HIST("hVtx3ProngY"), secondaryVertex3[1]); registry.fill(HIST("hVtx3ProngZ"), secondaryVertex3[2]); - std::array, 3> arr3Mom = {pvec0, pvec1, pvec2}; + std::array, 3> const arr3Mom = {pvec0, pvec1, pvec2}; for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { if (TESTBIT(isSelected3ProngCand, iDecay3P)) { if (TESTBIT(whichHypo3Prong[iDecay3P], 0)) { @@ -2814,7 +2814,7 @@ struct HfTrackIndexSkimCreator { std::array, kN3ProngDecays> mlScores3Prongs; if (config.applyMlForHfFilters) { - std::vector inputFeatures{trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg2.getPt(), dcaInfoNeg2[0], dcaInfoNeg2[1]}; + std::vector const inputFeatures{trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg2.getPt(), dcaInfoNeg2[0], dcaInfoNeg2[1]}; std::vector inputFeaturesLcPid{}; if constexpr (usePidForHfFiltersBdt) { inputFeaturesLcPid.push_back(trackNeg1.tpcNSigmaPr()); @@ -2859,7 +2859,7 @@ struct HfTrackIndexSkimCreator { registry.fill(HIST("hVtx3ProngX"), secondaryVertex3[0]); registry.fill(HIST("hVtx3ProngY"), secondaryVertex3[1]); registry.fill(HIST("hVtx3ProngZ"), secondaryVertex3[2]); - std::array, 3> arr3Mom = {pvec0, pvec1, pvec2}; + std::array, 3> const arr3Mom = {pvec0, pvec1, pvec2}; for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { if (TESTBIT(isSelected3ProngCand, iDecay3P)) { if (TESTBIT(whichHypo3Prong[iDecay3P], 0)) { @@ -2977,7 +2977,7 @@ struct HfTrackIndexSkimCreator { } } - int nTracks = 0; + int const nTracks = 0; // auto nTracks = trackIndicesPerCollision.lastIndex() - trackIndicesPerCollision.firstIndex(); // number of tracks passing 2 and 3 prong selection in this collision nCand2 = rowTrackIndexProng2.lastIndex() - nCand2; // number of 2-prong candidates in this collision nCand3 = rowTrackIndexProng3.lastIndex() - nCand3; // number of 3-prong candidates in this collision @@ -3185,18 +3185,18 @@ struct HfTrackIndexSkimCreatorCascades { continue; } - std::array pVecPos = {v0.pxpos(), v0.pypos(), v0.pzpos()}; - std::array pVecNeg = {v0.pxneg(), v0.pyneg(), v0.pzneg()}; + std::array const pVecPos = {v0.pxpos(), v0.pypos(), v0.pzpos()}; + std::array const pVecNeg = {v0.pxneg(), v0.pyneg(), v0.pzneg()}; - float ptPos = RecoDecay::pt(pVecPos); - float ptNeg = RecoDecay::pt(pVecNeg); + float const ptPos = RecoDecay::pt(pVecPos); + float const ptNeg = RecoDecay::pt(pVecNeg); if (ptPos < config.ptMinV0Daugh || // to the filters? I can't for now, it is not in the tables ptNeg < config.ptMinV0Daugh) { continue; } - float etaPos = RecoDecay::eta(pVecPos); - float etaNeg = RecoDecay::eta(pVecNeg); + float const etaPos = RecoDecay::eta(pVecPos); + float const etaNeg = RecoDecay::eta(pVecNeg); if ((etaPos > config.etaMaxV0Daugh || etaPos < config.etaMinV0Daugh) || // to the filters? I can't for now, it is not in the tables (etaNeg > config.etaMaxV0Daugh || etaNeg < config.etaMinV0Daugh)) { continue; @@ -3400,9 +3400,9 @@ struct HfTrackIndexSkimCreatorLfCascades { runNumber = 0; if (config.fillHistograms) { - AxisSpec ptAxis = {400, 0.0f, 20.0f, "it{p}_{T} (GeV/c)"}; - AxisSpec massAxisXi = {200, 1.222f, 1.422f, "Inv. Mass (GeV/c^{2})"}; - AxisSpec massAxisOmega = {200, 1.572f, 1.772f, "Inv. Mass (GeV/c^{2})"}; + AxisSpec const ptAxis = {400, 0.0f, 20.0f, "it{p}_{T} (GeV/c)"}; + AxisSpec const massAxisXi = {200, 1.222f, 1.422f, "Inv. Mass (GeV/c^{2})"}; + AxisSpec const massAxisOmega = {200, 1.572f, 1.772f, "Inv. Mass (GeV/c^{2})"}; registry.add("hCandidateCounter", "hCandidateCounter", {HistType::kTH1D, {{10, 0.0f, 10.0f}}}); @@ -3694,9 +3694,9 @@ struct HfTrackIndexSkimCreatorLfCascades { std::array pVecPion1XiHyp = {0.}; df2.getTrack(0).getPxPyPzGlo(pVecXi); df2.getTrack(1).getPxPyPzGlo(pVecPion1XiHyp); - float ptXic = RecoDecay::pt(pVecXi, pVecPion1XiHyp); + float const ptXic = RecoDecay::pt(pVecXi, pVecPion1XiHyp); - std::array, 2> arrMomToXi = {pVecXi, pVecPion1XiHyp}; + std::array, 2> const arrMomToXi = {pVecXi, pVecPion1XiHyp}; auto mass2ProngXiHyp = RecoDecay::m(arrMomToXi, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::XiczeroOmegaczeroToXiPi]); if ((std::abs(casc.mXi() - MassXiMinus) < config.cascadeMassWindow) && (mass2ProngXiHyp >= config.massXiPiMin) && (mass2ProngXiHyp <= config.massXiPiMax)) { @@ -3741,9 +3741,9 @@ struct HfTrackIndexSkimCreatorLfCascades { std::array pVecCharmBachelor1OmegaHyp = {0.}; df2.getTrack(0).getPxPyPzGlo(pVecOmega); df2.getTrack(1).getPxPyPzGlo(pVecCharmBachelor1OmegaHyp); - float ptOmegac = RecoDecay::pt(pVecOmega, pVecCharmBachelor1OmegaHyp); + float const ptOmegac = RecoDecay::pt(pVecOmega, pVecCharmBachelor1OmegaHyp); - std::array, 2> arrMomToOmega = {pVecOmega, pVecCharmBachelor1OmegaHyp}; + std::array, 2> const arrMomToOmega = {pVecOmega, pVecCharmBachelor1OmegaHyp}; auto mass2ProngOmegaPiHyp = RecoDecay::m(arrMomToOmega, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaPi]); auto mass2ProngOmegaKHyp = RecoDecay::m(arrMomToOmega, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaK]); From 344ce0d0abee4d82881221286dcec4fb418d2153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 21:15:21 +0200 Subject: [PATCH 04/14] Add more const --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index c3cd17907d9..c7f794bea4e 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -139,7 +139,7 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { } // set numerical value of the Run 2 trigger class - auto triggerAlias = std::find(aliasLabels, aliasLabels + kNaliases, triggerClassName.value.data()); + const auto triggerAlias = std::find(aliasLabels, aliasLabels + kNaliases, triggerClassName.value.data()); if (triggerAlias != aliasLabels + kNaliases) { hfEvSel.triggerClass.value = std::distance(aliasLabels, triggerAlias); } @@ -750,7 +750,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { /// Prepare the vertex refitting // set the magnetic field from CCDB - auto bc = collision.bc_as(); + const auto bc = collision.bc_as(); initCCDB(bc, runNumber, ccdb, config.isRun2 ? config.ccdbPathGrp : config.ccdbPathGrpMag, lut, config.isRun2); /*if (runNumber != bc.runNumber()) { @@ -2170,14 +2170,14 @@ struct HfTrackIndexSkimCreator { } // first loop over negative tracks - auto groupedTrackIndicesNeg1 = negativeFor2And3Prongs->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + const auto groupedTrackIndicesNeg1 = negativeFor2And3Prongs->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); for (auto trackIndexNeg1 = groupedTrackIndicesNeg1.begin(); trackIndexNeg1 != groupedTrackIndicesNeg1.end(); ++trackIndexNeg1) { - auto trackNeg1 = trackIndexNeg1.template track_as(); + const auto trackNeg1 = trackIndexNeg1.template track_as(); // retrieve the selection flag that corresponds to this collision - auto isSelProngNeg1 = trackIndexNeg1.isSelProng(); - bool const sel2ProngStatusNeg = TESTBIT(isSelProngNeg1, CandidateType::Cand2Prong); - bool const sel3ProngStatusNeg1 = TESTBIT(isSelProngNeg1, CandidateType::Cand3Prong); + const auto isSelProngNeg1 = trackIndexNeg1.isSelProng(); + const bool sel2ProngStatusNeg = TESTBIT(isSelProngNeg1, CandidateType::Cand2Prong); + const bool sel3ProngStatusNeg1 = TESTBIT(isSelProngNeg1, CandidateType::Cand3Prong); auto trackParVarNeg1 = getTrackParCov(trackNeg1); std::array pVecTrackNeg1{trackNeg1.pVector()}; @@ -2800,14 +2800,14 @@ struct HfTrackIndexSkimCreator { std::array pvec0; std::array pvec1; std::array pvec2; - auto trackParVarPcaNeg1 = df3.getTrack(0); - auto trackParVarPcaPos1 = df3.getTrack(1); - auto trackParVarPcaNeg2 = df3.getTrack(2); + const auto trackParVarPcaNeg1 = df3.getTrack(0); + const auto trackParVarPcaPos1 = df3.getTrack(1); + const auto trackParVarPcaNeg2 = df3.getTrack(2); trackParVarPcaNeg1.getPxPyPzGlo(pvec0); trackParVarPcaPos1.getPxPyPzGlo(pvec1); trackParVarPcaNeg2.getPxPyPzGlo(pvec2); - auto pVecCandProng3Neg = RecoDecay::pVec(pvec0, pvec1, pvec2); + const auto pVecCandProng3Neg = RecoDecay::pVec(pvec0, pvec1, pvec2); // 3-prong selections after secondary vertex applySelection3Prong(pVecCandProng3Neg, secondaryVertex3, pvRefitCoord3Prong1Pos2Neg, cutStatus3Prong, isSelected3ProngCand); From e184dc0b86143bb1d95b4c40d54db727ff5521c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 21:15:24 +0200 Subject: [PATCH 05/14] Use bool properly --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index c7f794bea4e..45d19292e6b 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -2296,7 +2296,7 @@ struct HfTrackIndexSkimCreator { pvCoord2Prong[2] = pvRefitCoord2Prong[2]; } applySelection2Prong(pVecCandProng2, secondaryVertex2, pvCoord2Prong, cutStatus2Prong, isSelected2ProngCand); - if (is2ProngCandidateGoodFor3Prong && config.do3Prong == 1) { + if (is2ProngCandidateGoodFor3Prong && config.do3Prong) { is2ProngCandidateGoodFor3Prong = isTwoTrackVertexSelectedFor3Prongs(secondaryVertex2, pvCoord2Prong, df2); } @@ -2378,7 +2378,7 @@ struct HfTrackIndexSkimCreator { } // if the cut on the decay length of 3-prongs computed with the first two tracks is enabled and the vertex was not computed for the D0, we compute it now - if (config.do3Prong == 1 && is2ProngCandidateGoodFor3Prong && (config.minTwoTrackDecayLengthFor3Prongs > 0.f || config.maxTwoTrackChi2PcaFor3Prongs < 1.e9f) && nVtxFrom2ProngFitter == 0) { + if (config.do3Prong && is2ProngCandidateGoodFor3Prong && (config.minTwoTrackDecayLengthFor3Prongs > 0.f || config.maxTwoTrackChi2PcaFor3Prongs < 1.e9f) && nVtxFrom2ProngFitter == 0) { try { nVtxFrom2ProngFitter = df2.process(trackParVarPos1, trackParVarNeg1); } catch (...) { @@ -2392,7 +2392,7 @@ struct HfTrackIndexSkimCreator { } } - if (config.do3Prong == 1 && is2ProngCandidateGoodFor3Prong) { // if 3 prongs are enabled and the first 2 tracks are selected for the 3-prong channels + if (config.do3Prong && is2ProngCandidateGoodFor3Prong) { // if 3 prongs are enabled and the first 2 tracks are selected for the 3-prong channels // second loop over positive tracks for (auto trackIndexPos2 = trackIndexPos1 + 1; trackIndexPos2 != groupedTrackIndicesPos1.end(); ++trackIndexPos2) { From 1a9b5c561893f292c0ca0e8f88a3490f18c4010c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 21:15:28 +0200 Subject: [PATCH 06/14] Use deduction for array declarations. Improve const correctness. --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 220 +++++++++--------- 1 file changed, 110 insertions(+), 110 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index 45d19292e6b..12ef57dc227 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -464,7 +464,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { template uint8_t isSelectedPid(const T& hfTrack) { - std::array statusPid = {TrackSelectorPID::Accepted, TrackSelectorPID::Accepted, TrackSelectorPID::Accepted, TrackSelectorPID::Accepted}; + std::array statusPid{TrackSelectorPID::Accepted, TrackSelectorPID::Accepted, TrackSelectorPID::Accepted, TrackSelectorPID::Accepted}; if constexpr (pidStrategy == ProtonPidStrategy::PidTofOnly) { if (hfTrack.hasTOF()) { for (auto iChannel{0u}; iChannel < ChannelsProtonPid::NChannelsProtonPid; ++iChannel) { @@ -870,7 +870,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { /// Track propagation to the PV refit considering also the material budget /// Mandatory for tracks updated at most only to the innermost ITS layer auto trackPar = getTrackPar(trackToRemove); - std::array dcaInfo{-999., -999.}; + std::array dcaInfo{-999.f, -999.f}; if (o2::base::Propagator::Instance()->propagateToDCABxByBz({primVtxBaseRecalc.getX(), primVtxBaseRecalc.getY(), primVtxBaseRecalc.getZ()}, trackPar, 2.f, noMatCorr, &dcaInfo)) { pvCoord[0] = primVtxBaseRecalc.getX(); pvCoord[1] = primVtxBaseRecalc.getY(); @@ -939,9 +939,9 @@ struct HfTrackIndexSkimCreatorTagSelTracks { float trackPt = track.pt(); float trackEta = track.eta(); - std::array pvRefitDcaXYDcaZ{track.dcaXY(), track.dcaZ()}; - std::array pvRefitPvCoord{0.f, 0.f, 0.f}; - std::array pvRefitPvCovMatrix{1e10f, 1e10f, 1e10f, 1e10f, 1e10f, 1e10f}; + std::array pvRefitDcaXYDcaZ{track.dcaXY(), track.dcaZ()}; + std::array pvRefitPvCoord{0.f, 0.f, 0.f}; + std::array pvRefitPvCovMatrix{1e10f, 1e10f, 1e10f, 1e10f, 1e10f, 1e10f}; // PV refit and DCA recalculation only for tracks with an assigned collision if (config.doPvRefit && track.has_collision() && track.collisionId() == thisCollId && track.isPVContributor()) { @@ -970,10 +970,10 @@ struct HfTrackIndexSkimCreatorTagSelTracks { pvRefitPvCoordPerTrack[trackIdx] = pvRefitPvCoord; pvRefitPvCovMatrixPerTrack[trackIdx] = pvRefitPvCovMatrix; } else if (track.collisionId() != thisCollId) { - auto bc = collision.bc_as(); + const auto bc = collision.bc_as(); initCCDB(bc, runNumber, ccdb, config.isRun2 ? config.ccdbPathGrp : config.ccdbPathGrpMag, lut, config.isRun2); auto trackPar = getTrackPar(track); - std::array dcaInfo{-999., -999.}; + std::array dcaInfo{-999.f, -999.f}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPar, 2.f, noMatCorr, &dcaInfo); trackPt = trackPar.getPt(); trackEta = trackPar.getEta(); @@ -1279,9 +1279,9 @@ struct HfTrackIndexSkimCreator { std::array, 2>, kN3ProngDecays> arrMass3Prong; // arrays of 2-prong and 3-prong cuts std::array, kN2ProngDecays> cut2Prong; - std::array, kN2ProngDecays> pTBins2Prong; + std::array, kN2ProngDecays> binsPt2Prong; std::array, kN3ProngDecays> cut3Prong; - std::array, kN3ProngDecays> pTBins3Prong; + std::array, kN3ProngDecays> binsPt3Prong; // ML response o2::analysis::MlResponse hfMlResponse2Prongs; // only D0 @@ -1344,10 +1344,10 @@ struct HfTrackIndexSkimCreator { // cuts for 2-prong decays retrieved by json. the order must be then one in hf_cand_2prong::DecayType cut2Prong = {config.cutsD0ToPiK, config.cutsJpsiToEE, config.cutsJpsiToMuMu}; - pTBins2Prong = {config.binsPtD0ToPiK, config.binsPtJpsiToEE, config.binsPtJpsiToMuMu}; + binsPt2Prong = {config.binsPtD0ToPiK, config.binsPtJpsiToEE, config.binsPtJpsiToMuMu}; // cuts for 3-prong decays retrieved by json. the order must be then one in hf_cand_3prong::DecayType cut3Prong = {config.cutsDplusToPiKPi, config.cutsLcToPKPi, config.cutsDsToKKPi, config.cutsXicToPKPi}; - pTBins3Prong = {config.binsPtDplusToPiKPi, config.binsPtLcToPKPi, config.binsPtDsToKKPi, config.binsPtXicToPKPi}; + binsPt3Prong = {config.binsPtDplusToPiKPi, config.binsPtLcToPKPi, config.binsPtDsToKKPi, config.binsPtXicToPKPi}; df2.setPropagateToPCA(config.propagateToPCA); df2.setMaxR(config.maxR); @@ -1498,12 +1498,12 @@ struct HfTrackIndexSkimCreator { whichHypo[kN2ProngDecays] = 0; // D0 for D* pt2Prong = RecoDecay::pt(pVecTrack0, pVecTrack1); - auto pt = pt2Prong + config.ptTolerance; // add tolerance because of no reco decay vertex + const auto pt = pt2Prong + config.ptTolerance; // add tolerance because of no reco decay vertex for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { - // pT - auto binPt = findBin(&pTBins2Prong[iDecay2P], pt); + // pt + const auto binPt = findBin(&binsPt2Prong[iDecay2P], pt); // return immediately if it is outside the defined pT bins if (binPt == -1) { CLRBIT(isSelected, iDecay2P); @@ -1518,14 +1518,14 @@ struct HfTrackIndexSkimCreator { whichHypo[iDecay2P] = 3; // 2 bits on if (config.debug || TESTBIT(isSelected, iDecay2P)) { - double const minMass = cut2Prong[iDecay2P].get(binPt, 0u); - double const maxMass = cut2Prong[iDecay2P].get(binPt, 1u); + const double minMass = cut2Prong[iDecay2P].get(binPt, 0u); + const double maxMass = cut2Prong[iDecay2P].get(binPt, 1u); if (minMass >= 0. && maxMass > 0.) { - auto arrMom = std::array{pVecTrack0, pVecTrack1}; + const std::array arrMom{pVecTrack0, pVecTrack1}; massHypos[0] = RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][0]); massHypos[1] = (iDecay2P == hf_cand_2prong::DecayType::D0ToPiK) ? RecoDecay::m2(arrMom, arrMass2Prong[iDecay2P][1]) : massHypos[0]; - double const min2 = minMass * minMass; - double const max2 = maxMass * maxMass; + const double min2 = minMass * minMass; + const double max2 = maxMass * maxMass; if (massHypos[0] < min2 || massHypos[0] >= max2) { CLRBIT(whichHypo[iDecay2P], 0); } @@ -1557,7 +1557,7 @@ struct HfTrackIndexSkimCreator { auto pTBinDstar = findBin(config.binsPtDstarToD0Pi, pt * 1.2); // assuming the D* pT about 20% higher than the one of the D0 to be safe if (pTBinDstar >= 0) { whichHypo[kN2ProngDecays] = whichHypo[hf_cand_2prong::DecayType::D0ToPiK]; - double const deltaMass = config.cutsDstarToD0Pi->get(pTBinDstar, 1u); + const double deltaMass = config.cutsDstarToD0Pi->get(pTBinDstar, 1u); if (TESTBIT(whichHypo[iDecay2P], 0) && (massHypos[0] > (MassD0 + deltaMass) * (MassD0 + deltaMass) || massHypos[0] < (MassD0 - deltaMass) * (MassD0 - deltaMass))) { CLRBIT(whichHypo[kN2ProngDecays], 0); @@ -1571,7 +1571,7 @@ struct HfTrackIndexSkimCreator { } /// Method to perform selections on difference from nominal mass for phi decay - /// \param pTBin pt bin for the cuts + /// \param binPt pt bin for the cuts /// \param pVecTrack0 is the momentum array of the first daughter track /// \param pVecTrack1 is the momentum array of the second daughter track /// \param pVecTrack2 is the momentum array of the third daughter track @@ -1579,17 +1579,17 @@ struct HfTrackIndexSkimCreator { /// \param whichHypo information of the mass hypoteses that were selected /// \param isSelected is a bitmap with selection outcome template - void applyPreselectionPhiDecay(int& pTBin, T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, T2& cutStatus, T3& whichHypo, int& isSelected) + void applyPreselectionPhiDecay(const int binPt, T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, T2& cutStatus, T3& whichHypo, int& isSelected) { - double const deltaMassMax = cut3Prong[hf_cand_3prong::DecayType::DsToKKPi].get(pTBin, 4u); + const double deltaMassMax = cut3Prong[hf_cand_3prong::DecayType::DsToKKPi].get(binPt, 4u); if (TESTBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 0)) { - double const mass2PhiKKPi = RecoDecay::m2(std::array{pVecTrack0, pVecTrack1}, std::array{arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][0][0], arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][0][1]}); + const double mass2PhiKKPi = RecoDecay::m2(std::array{pVecTrack0, pVecTrack1}, std::array{arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][0][0], arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][0][1]}); if (mass2PhiKKPi > (MassPhi + deltaMassMax) * (MassPhi + deltaMassMax) || mass2PhiKKPi < (MassPhi - deltaMassMax) * (MassPhi - deltaMassMax)) { CLRBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 0); } } if (TESTBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 1)) { - double const mass2PhiPiKK = RecoDecay::m2(std::array{pVecTrack1, pVecTrack2}, std::array{arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][1][1], arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][1][2]}); + const double mass2PhiPiKK = RecoDecay::m2(std::array{pVecTrack1, pVecTrack2}, std::array{arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][1][1], arrMass3Prong[hf_cand_3prong::DecayType::DsToKKPi][1][2]}); if (mass2PhiPiKK > (MassPhi + deltaMassMax) * (MassPhi + deltaMassMax) || mass2PhiPiKK < (MassPhi - deltaMassMax) * (MassPhi - deltaMassMax)) { CLRBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 1); } @@ -1614,7 +1614,7 @@ struct HfTrackIndexSkimCreator { template void applyPreselection3Prong(T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, int8_t& isIdentifiedPidTrack0, int8_t& isIdentifiedPidTrack2, T2& cutStatus, T3& whichHypo, int& isSelected) { - auto pt = RecoDecay::pt(pVecTrack0, pVecTrack1, pVecTrack2) + config.ptTolerance; // add tolerance because of no reco decay vertex + const auto pt = RecoDecay::pt(pVecTrack0, pVecTrack1, pVecTrack2) + config.ptTolerance; // add tolerance because of no reco decay vertex for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { @@ -1637,7 +1637,7 @@ struct HfTrackIndexSkimCreator { } // pT - auto binPt = findBin(&pTBins3Prong[iDecay3P], pt); + const auto binPt = findBin(&binsPt3Prong[iDecay3P], pt); // return immediately if it is outside the defined pT bins if (binPt == -1) { CLRBIT(isSelected, iDecay3P); @@ -1650,13 +1650,13 @@ struct HfTrackIndexSkimCreator { // invariant mass if ((config.debug || TESTBIT(isSelected, iDecay3P))) { - double const minMass = cut3Prong[iDecay3P].get(binPt, 0u); - double const maxMass = cut3Prong[iDecay3P].get(binPt, 1u); + const double minMass = cut3Prong[iDecay3P].get(binPt, 0u); + const double maxMass = cut3Prong[iDecay3P].get(binPt, 1u); if (minMass >= 0. && maxMass > 0.) { // no need to check isSelected but to avoid mistakes double massHypos[2] = {0., 0.}; - auto arrMom = std::array{pVecTrack0, pVecTrack1, pVecTrack2}; - double const min2 = minMass * minMass; - double const max2 = maxMass * maxMass; + const std::array arrMom{pVecTrack0, pVecTrack1, pVecTrack2}; + const double min2 = minMass * minMass; + const double max2 = maxMass * maxMass; massHypos[0] = RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][0]); massHypos[1] = (iDecay3P != hf_cand_3prong::DecayType::DplusToPiKPi) ? RecoDecay::m2(arrMom, arrMass3Prong[iDecay3P][1]) : massHypos[0]; if (massHypos[0] < min2 || massHypos[0] >= max2) { @@ -1694,8 +1694,8 @@ struct HfTrackIndexSkimCreator { for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { // pT - auto pTBin = findBin(&pTBins2Prong[iDecay2P], RecoDecay::pt(pVecCand)); - if (pTBin == -1) { // cut if it is outside the defined pT bins + const auto binPt = findBin(&binsPt2Prong[iDecay2P], RecoDecay::pt(pVecCand)); + if (binPt == -1) { // cut if it is outside the defined pT bins CLRBIT(isSelected, iDecay2P); if (config.debug) { cutStatus[iDecay2P][0] = false; @@ -1705,8 +1705,8 @@ struct HfTrackIndexSkimCreator { // cosp if (config.debug || TESTBIT(isSelected, iDecay2P)) { - auto cpa = RecoDecay::cpa(primVtx, secVtx, pVecCand); - if (cpa < cut2Prong[iDecay2P].get(pTBin, 2u)) { // 2u == "cospIndex[iDecay2P]" + const auto cpa = RecoDecay::cpa(primVtx, secVtx, pVecCand); + if (cpa < cut2Prong[iDecay2P].get(binPt, 2u)) { // 2u == "cospIndex[iDecay2P]" CLRBIT(isSelected, iDecay2P); if (config.debug) { cutStatus[iDecay2P][3] = false; @@ -1772,8 +1772,8 @@ struct HfTrackIndexSkimCreator { for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { // pT - auto pTBin = findBin(&pTBins3Prong[iDecay3P], pT); - if (pTBin == -1) { // cut if it is outside the defined pT bins + const auto binPt = findBin(&binsPt3Prong[iDecay3P], pT); + if (binPt == -1) { // cut if it is outside the defined pT bins CLRBIT(isSelected, iDecay3P); if (config.debug) { cutStatus[iDecay3P][0] = false; @@ -1782,9 +1782,9 @@ struct HfTrackIndexSkimCreator { } // cosp - if ((config.debug || TESTBIT(isSelected, iDecay3P))) { - auto cpa = RecoDecay::cpa(primVtx, secVtx, pVecCand); - if (cpa < cut3Prong[iDecay3P].get(pTBin, 2u)) { // 2u == cospIndex[iDecay3P] + if (config.debug || TESTBIT(isSelected, iDecay3P)) { + const auto cpa = RecoDecay::cpa(primVtx, secVtx, pVecCand); + if (cpa < cut3Prong[iDecay3P].get(binPt, 2u)) { // 2u == cospIndex[iDecay3P] CLRBIT(isSelected, iDecay3P); if (config.debug) { cutStatus[iDecay3P][2] = false; @@ -1794,8 +1794,8 @@ struct HfTrackIndexSkimCreator { // decay length if ((config.debug || TESTBIT(isSelected, iDecay3P))) { - auto decayLength = RecoDecay::distance(primVtx, secVtx); - if (decayLength < cut3Prong[iDecay3P].get(pTBin, 3u)) { // 3u == decLenIndex[iDecay3P] + const auto decayLength = RecoDecay::distance(primVtx, secVtx); + if (decayLength < cut3Prong[iDecay3P].get(binPt, 3u)) { // 3u == decLenIndex[iDecay3P] CLRBIT(isSelected, iDecay3P); if (config.debug) { cutStatus[iDecay3P][3] = false; @@ -1880,14 +1880,14 @@ struct HfTrackIndexSkimCreator { uint8_t applySelectionDstar(T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, uint8_t& cutStatus, T2& deltaMass) { uint8_t isSelected{1}; - auto arrMom = std::array{pVecTrack0, pVecTrack1, pVecTrack2}; - auto arrMomD0 = std::array{pVecTrack0, pVecTrack1}; - auto pT = RecoDecay::pt(pVecTrack0, pVecTrack1, pVecTrack2) + config.ptTolerance; // add tolerance because of no reco decay vertex + const std::array arrMom{pVecTrack0, pVecTrack1, pVecTrack2}; + const std::array arrMomD0{pVecTrack0, pVecTrack1}; + const auto pt = RecoDecay::pt(pVecTrack0, pVecTrack1, pVecTrack2) + config.ptTolerance; // add tolerance because of no reco decay vertex - // pT - auto pTBin = findBin(config.binsPtDstarToD0Pi, pT); + // pt + const auto binPt = findBin(config.binsPtDstarToD0Pi, pt); // return immediately if it is outside the defined pT bins - if (pTBin == -1) { + if (binPt == -1) { isSelected = 0; if (config.debug) { CLRBIT(cutStatus, 0); @@ -1897,8 +1897,8 @@ struct HfTrackIndexSkimCreator { } // D0 mass - double const deltaMassD0 = config.cutsDstarToD0Pi->get(pTBin, 1u); // 1u == deltaMassD0Index - double const invMassD0 = RecoDecay::m(arrMomD0, std::array{MassPiPlus, MassKPlus}); + const double deltaMassD0 = config.cutsDstarToD0Pi->get(binPt, 1u); // 1u == deltaMassD0Index + const double invMassD0 = RecoDecay::m(arrMomD0, std::array{MassPiPlus, MassKPlus}); if (std::abs(invMassD0 - MassD0) > deltaMassD0) { isSelected = 0; if (config.debug) { @@ -1908,8 +1908,8 @@ struct HfTrackIndexSkimCreator { } // D*+ mass - double const maxDeltaMass = config.cutsDstarToD0Pi->get(pTBin, 0u); // 0u == deltaMassIndex - double const invMassDstar = RecoDecay::m(arrMom, std::array{MassPiPlus, MassKPlus, MassPiPlus}); + const double maxDeltaMass = config.cutsDstarToD0Pi->get(binPt, 0u); // 0u == deltaMassIndex + const double invMassDstar = RecoDecay::m(arrMom, std::array{MassPiPlus, MassKPlus, MassPiPlus}); deltaMass = invMassDstar - invMassD0; if (deltaMass > maxDeltaMass) { isSelected = 0; @@ -1942,7 +1942,7 @@ struct HfTrackIndexSkimCreator { /// Prepare the vertex refitting // set the magnetic field from CCDB - auto bc = collision.bc_as(); + const auto bc = collision.bc_as(); initCCDB(bc, runNumber, ccdb, config.isRun2 ? config.ccdbPathGrp : config.ccdbPathGrpMag, lut, config.isRun2); // build the VertexBase to initialize the vertexer @@ -2134,7 +2134,7 @@ struct HfTrackIndexSkimCreator { int whichHypo3Prong[kN3ProngDecays]; // set the magnetic field from CCDB - auto bc = collision.bc_as(); + const auto bc = collision.bc_as(); initCCDB(bc, runNumber, ccdb, config.isRun2 ? config.ccdbPathGrp : config.ccdbPathGrpMag, lut, config.isRun2); df2.setBz(o2::base::Propagator::Instance()->getNominalBz()); df3.setBz(o2::base::Propagator::Instance()->getNominalBz()); @@ -2162,8 +2162,8 @@ struct HfTrackIndexSkimCreator { bool const sel3ProngStatusPos1 = TESTBIT(isSelProngPos1, CandidateType::Cand3Prong); auto trackParVarPos1 = getTrackParCov(trackPos1); - std::array pVecTrackPos1{trackPos1.pVector()}; - std::array dcaInfoPos1{trackPos1.dcaXY(), trackPos1.dcaZ()}; + std::array pVecTrackPos1{trackPos1.pVector()}; + std::array dcaInfoPos1{trackPos1.dcaXY(), trackPos1.dcaZ()}; if (thisCollId != trackPos1.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParVarPos1, 2.f, noMatCorr, &dcaInfoPos1); getPxPyPz(trackParVarPos1, pVecTrackPos1); @@ -2180,8 +2180,8 @@ struct HfTrackIndexSkimCreator { const bool sel3ProngStatusNeg1 = TESTBIT(isSelProngNeg1, CandidateType::Cand3Prong); auto trackParVarNeg1 = getTrackParCov(trackNeg1); - std::array pVecTrackNeg1{trackNeg1.pVector()}; - std::array dcaInfoNeg1{trackNeg1.dcaXY(), trackNeg1.dcaZ()}; + std::array pVecTrackNeg1{trackNeg1.pVector()}; + std::array dcaInfoNeg1{trackNeg1.dcaXY(), trackNeg1.dcaZ()}; if (thisCollId != trackNeg1.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParVarNeg1, 2.f, noMatCorr, &dcaInfoNeg1); getPxPyPz(trackParVarNeg1, pVecTrackNeg1); @@ -2198,8 +2198,8 @@ struct HfTrackIndexSkimCreator { } // initialise PV refit coordinates and cov matrix for 2-prongs already here for D* - std::array pvRefitCoord2Prong = {collision.posX(), collision.posY(), collision.posZ()}; /// initialize to the original PV - std::array pvRefitCovMatrix2Prong = getPrimaryVertex(collision).getCov(); /// initialize to the original PV + std::array pvRefitCoord2Prong = {collision.posX(), collision.posY(), collision.posZ()}; /// initialize to the original PV + std::array pvRefitCovMatrix2Prong = getPrimaryVertex(collision).getCov(); /// initialize to the original PV // 2-prong vertex reconstruction float pt2Prong{-1.}; @@ -2222,8 +2222,8 @@ struct HfTrackIndexSkimCreator { // get secondary vertex const auto& secondaryVertex2 = df2.getPCACandidate(); // get track momenta - std::array pvec0; - std::array pvec1; + std::array pvec0{}; + std::array pvec1{}; df2.getTrack(0).getPxPyPzGlo(pvec0); df2.getTrack(1).getPxPyPzGlo(pvec1); @@ -2289,7 +2289,7 @@ struct HfTrackIndexSkimCreator { auto pVecCandProng2 = RecoDecay::pVec(pvec0, pvec1); // 2-prong selections after secondary vertex - std::array pvCoord2Prong = {collision.posX(), collision.posY(), collision.posZ()}; + std::array pvCoord2Prong = {collision.posX(), collision.posY(), collision.posZ()}; if constexpr (doPvRefit) { pvCoord2Prong[0] = pvRefitCoord2Prong[0]; pvCoord2Prong[1] = pvRefitCoord2Prong[1]; @@ -2342,7 +2342,7 @@ struct HfTrackIndexSkimCreator { registry.fill(HIST("hVtx2ProngX"), secondaryVertex2[0]); registry.fill(HIST("hVtx2ProngY"), secondaryVertex2[1]); registry.fill(HIST("hVtx2ProngZ"), secondaryVertex2[2]); - std::array, 2> const arrMom = {pvec0, pvec1}; + const std::array arrMom{pvec0, pvec1}; for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { if (TESTBIT(isSelected2ProngCand, iDecay2P)) { if (TESTBIT(whichHypo2Prong[iDecay2P], 0)) { @@ -2385,7 +2385,7 @@ struct HfTrackIndexSkimCreator { } if (nVtxFrom2ProngFitter > 0) { const auto& secondaryVertex2 = df2.getPCACandidate(); - std::array const pvCoord2Prong = {collision.posX(), collision.posY(), collision.posZ()}; + const std::array pvCoord2Prong{collision.posX(), collision.posY(), collision.posZ()}; is2ProngCandidateGoodFor3Prong = isTwoTrackVertexSelectedFor3Prongs(secondaryVertex2, pvCoord2Prong, df2); } else { is2ProngCandidateGoodFor3Prong = false; @@ -2415,11 +2415,11 @@ struct HfTrackIndexSkimCreator { auto trackPos2 = trackIndexPos2.template track_as(); auto trackParVarPos2 = getTrackParCov(trackPos2); - std::array dcaInfoPos2{trackPos2.dcaXY(), trackPos2.dcaZ()}; + std::array dcaInfoPos2{trackPos2.dcaXY(), trackPos2.dcaZ()}; // preselection of 3-prong candidates if (isSelected3ProngCand) { - std::array pVecTrackPos2{trackPos2.pVector()}; + std::array pVecTrackPos2{trackPos2.pVector()}; if (thisCollId != trackPos2.collisionId()) { // this is not the "default" collision for this track and we still did not re-propagate it, we have to re-propagate it o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParVarPos2, 2.f, noMatCorr, &dcaInfoPos2); getPxPyPz(trackParVarPos2, pVecTrackPos2); @@ -2443,8 +2443,8 @@ struct HfTrackIndexSkimCreator { } /// PV refit excluding the candidate daughters, if contributors - std::array pvRefitCoord3Prong2Pos1Neg = {collision.posX(), collision.posY(), collision.posZ()}; /// initialize to the original PV - std::array pvRefitCovMatrix3Prong2Pos1Neg = getPrimaryVertex(collision).getCov(); /// initialize to the original PV + std::array pvRefitCoord3Prong2Pos1Neg{collision.posX(), collision.posY(), collision.posZ()}; /// initialize to the original PV + std::array pvRefitCovMatrix3Prong2Pos1Neg{getPrimaryVertex(collision).getCov()}; /// initialize to the original PV if constexpr (doPvRefit) { if (config.fillHistograms) { registry.fill(HIST("PvRefit/verticesPerCandidate"), 1); @@ -2545,9 +2545,9 @@ struct HfTrackIndexSkimCreator { // get secondary vertex const auto& secondaryVertex3 = df3.getPCACandidate(); // get track momenta - std::array pvec0; - std::array pvec1; - std::array pvec2; + std::array pvec0{}; + std::array pvec1{}; + std::array pvec2{}; auto trackParVarPcaPos1 = df3.getTrack(0); auto trackParVarPcaNeg1 = df3.getTrack(1); auto trackParVarPcaPos2 = df3.getTrack(2); @@ -2606,7 +2606,7 @@ struct HfTrackIndexSkimCreator { registry.fill(HIST("hVtx3ProngX"), secondaryVertex3[0]); registry.fill(HIST("hVtx3ProngY"), secondaryVertex3[1]); registry.fill(HIST("hVtx3ProngZ"), secondaryVertex3[2]); - std::array, 3> const arr3Mom = {pvec0, pvec1, pvec2}; + const std::array arr3Mom{pvec0, pvec1, pvec2}; for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { if (TESTBIT(isSelected3ProngCand, iDecay3P)) { if (TESTBIT(whichHypo3Prong[iDecay3P], 0)) { @@ -2667,11 +2667,11 @@ struct HfTrackIndexSkimCreator { auto trackNeg2 = trackIndexNeg2.template track_as(); auto trackParVarNeg2 = getTrackParCov(trackNeg2); - std::array dcaInfoNeg2{trackNeg2.dcaXY(), trackNeg2.dcaZ()}; + std::array dcaInfoNeg2{trackNeg2.dcaXY(), trackNeg2.dcaZ()}; // preselection of 3-prong candidates if (isSelected3ProngCand) { - std::array pVecTrackNeg2{trackNeg2.pVector()}; + std::array pVecTrackNeg2{trackNeg2.pVector()}; if (thisCollId != trackNeg2.collisionId()) { // this is not the "default" collision for this track and we still did not re-propagate it, we have to re-propagate it o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParVarNeg2, 2.f, noMatCorr, &dcaInfoNeg2); getPxPyPz(trackParVarNeg2, pVecTrackNeg2); @@ -2695,8 +2695,8 @@ struct HfTrackIndexSkimCreator { } /// PV refit excluding the candidate daughters, if contributors - std::array pvRefitCoord3Prong1Pos2Neg = {collision.posX(), collision.posY(), collision.posZ()}; /// initialize to the original PV - std::array pvRefitCovMatrix3Prong1Pos2Neg = getPrimaryVertex(collision).getCov(); /// initialize to the original PV + std::array pvRefitCoord3Prong1Pos2Neg{collision.posX(), collision.posY(), collision.posZ()}; /// initialize to the original PV + std::array pvRefitCovMatrix3Prong1Pos2Neg{getPrimaryVertex(collision).getCov()}; /// initialize to the original PV if constexpr (doPvRefit) { if (config.fillHistograms) { registry.fill(HIST("PvRefit/verticesPerCandidate"), 1); @@ -2797,9 +2797,9 @@ struct HfTrackIndexSkimCreator { // get secondary vertex const auto& secondaryVertex3 = df3.getPCACandidate(); // get track momenta - std::array pvec0; - std::array pvec1; - std::array pvec2; + std::array pvec0{}; + std::array pvec1{}; + std::array pvec2{}; const auto trackParVarPcaNeg1 = df3.getTrack(0); const auto trackParVarPcaPos1 = df3.getTrack(1); const auto trackParVarPcaNeg2 = df3.getTrack(2); @@ -2859,7 +2859,7 @@ struct HfTrackIndexSkimCreator { registry.fill(HIST("hVtx3ProngX"), secondaryVertex3[0]); registry.fill(HIST("hVtx3ProngY"), secondaryVertex3[1]); registry.fill(HIST("hVtx3ProngZ"), secondaryVertex3[2]); - std::array, 3> const arr3Mom = {pvec0, pvec1, pvec2}; + const std::array arr3Mom{pvec0, pvec1, pvec2}; for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { if (TESTBIT(isSelected3ProngCand, iDecay3P)) { if (TESTBIT(whichHypo3Prong[iDecay3P], 0)) { @@ -2908,10 +2908,10 @@ struct HfTrackIndexSkimCreator { continue; } auto trackPos2 = trackIndexPos2.template track_as(); - std::array pVecTrackPos2{trackPos2.pVector()}; + std::array pVecTrackPos2{trackPos2.pVector()}; if (thisCollId != trackPos2.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it auto trackParVarPos2 = getTrackParCov(trackPos2); - std::array dcaInfoPos2{trackPos2.dcaXY(), trackPos2.dcaZ()}; + std::array dcaInfoPos2{trackPos2.dcaXY(), trackPos2.dcaZ()}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParVarPos2, 2.f, noMatCorr, &dcaInfoPos2); getPxPyPz(trackParVarPos2, pVecTrackPos2); } @@ -2945,10 +2945,10 @@ struct HfTrackIndexSkimCreator { continue; } auto trackNeg2 = trackIndexNeg2.template track_as(); - std::array pVecTrackNeg2{trackNeg2.pVector()}; + std::array pVecTrackNeg2{trackNeg2.pVector()}; if (thisCollId != trackNeg2.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it auto trackParVarNeg2 = getTrackParCov(trackNeg2); - std::array dcaInfoNeg2{trackNeg2.dcaXY(), trackNeg2.dcaZ()}; + std::array dcaInfoNeg2{trackNeg2.dcaXY(), trackNeg2.dcaZ()}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackParVarNeg2, 2.f, noMatCorr, &dcaInfoNeg2); getPxPyPz(trackParVarNeg2, pVecTrackNeg2); } @@ -3151,7 +3151,7 @@ struct HfTrackIndexSkimCreatorCascades { { // set the magnetic field from CCDB for (const auto& collision : collisions) { - auto bc = collision.bc_as(); + const auto bc = collision.bc_as(); initCCDB(bc, runNumber, ccdb, config.isRun2 ? config.ccdbPathGrp : config.ccdbPathGrpMag, lut, config.isRun2); if (config.useDCAFitter) { df2.setBz(o2::base::Propagator::Instance()->getNominalBz()); @@ -3166,10 +3166,10 @@ struct HfTrackIndexSkimCreatorCascades { for (const auto& bachIdx : groupedBachTrackIndices) { auto bach = bachIdx.track_as(); - std::array pVecBach{bach.pVector()}; + std::array pVecBach{bach.pVector()}; auto trackBach = getTrackParCov(bach); if (thisCollId != bach.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it - std::array dcaInfoBach{bach.dcaXY(), bach.dcaZ()}; + std::array dcaInfoBach{bach.dcaXY(), bach.dcaZ()}; o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackBach, 2.f, noMatCorr, &dcaInfoBach); getPxPyPz(trackBach, pVecBach); } @@ -3185,18 +3185,18 @@ struct HfTrackIndexSkimCreatorCascades { continue; } - std::array const pVecPos = {v0.pxpos(), v0.pypos(), v0.pzpos()}; - std::array const pVecNeg = {v0.pxneg(), v0.pyneg(), v0.pzneg()}; + const std::array pVecPos{v0.pxpos(), v0.pypos(), v0.pzpos()}; + const std::array pVecNeg{v0.pxneg(), v0.pyneg(), v0.pzneg()}; - float const ptPos = RecoDecay::pt(pVecPos); - float const ptNeg = RecoDecay::pt(pVecNeg); + const float ptPos = RecoDecay::pt(pVecPos); + const float ptNeg = RecoDecay::pt(pVecNeg); if (ptPos < config.ptMinV0Daugh || // to the filters? I can't for now, it is not in the tables ptNeg < config.ptMinV0Daugh) { continue; } - float const etaPos = RecoDecay::eta(pVecPos); - float const etaNeg = RecoDecay::eta(pVecNeg); + const float etaPos = RecoDecay::eta(pVecPos); + const float etaNeg = RecoDecay::eta(pVecNeg); if ((etaPos > config.etaMaxV0Daugh || etaPos < config.etaMinV0Daugh) || // to the filters? I can't for now, it is not in the tables (etaNeg > config.etaMaxV0Daugh || etaNeg < config.etaMinV0Daugh)) { continue; @@ -3212,7 +3212,7 @@ struct HfTrackIndexSkimCreatorCascades { continue; } - std::array pVecV0 = {v0.px(), v0.py(), v0.pz()}; + std::array pVecV0{v0.px(), v0.py(), v0.pz()}; // invariant-mass cut: we do it here, before updating the momenta of bach and V0 during the fitting to save CPU // TODO: but one should better check that the value here and after the fitter do not change significantly!!! @@ -3224,9 +3224,9 @@ struct HfTrackIndexSkimCreatorCascades { // now we find the DCA between the V0 and the bachelor, for the cascade if (config.useDCAFitter) { - const std::array vertexV0 = {v0.x(), v0.y(), v0.z()}; + const std::array vertexV0{v0.x(), v0.y(), v0.z()}; // we build the neutral track to then build the cascade - std::array covV = {0.}; + std::array covV{}; constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component for (int i = 0; i < 6; i++) { covV[MomInd[i]] = v0.momentumCovMat()[i]; @@ -3260,7 +3260,7 @@ struct HfTrackIndexSkimCreatorCascades { // invariant mass // re-calculate invariant masses with updated momenta, to fill the histogram mass2K0sP = RecoDecay::m(std::array{pVecBach, pVecV0}, std::array{MassProton, MassK0Short}); - std::array posCasc = {0., 0., 0.}; + std::array posCasc{0., 0., 0.}; if (config.useDCAFitter) { const auto& cascVtx = df2.getPCACandidate(); for (int iCoord{0}; iCoord < 3; ++iCoord) { @@ -3356,8 +3356,8 @@ struct HfTrackIndexSkimCreatorLfCascades { // array of PDG masses of possible charm baryon daughters static constexpr int kN2ProngDecays = hf_cand_casc_lf::DecayType2Prong::N2ProngDecays; // number of 2-prong hadron types static constexpr int kN3ProngDecays = hf_cand_casc_lf::DecayType3Prong::N3ProngDecays; // number of 3-prong hadron types - std::array, kN2ProngDecays> arrMass2Prong; - std::array, kN3ProngDecays> arrMass3Prong; + std::array, kN2ProngDecays> arrMass2Prong{}; + std::array, kN3ProngDecays> arrMass3Prong{}; using SelectedCollisions = soa::Filtered>; using SelectedHfTrackAssoc = soa::Filtered>; @@ -3620,9 +3620,9 @@ struct HfTrackIndexSkimCreatorLfCascades { continue; } - const std::array vertexCasc = {casc.x(), casc.y(), casc.z()}; - const std::array pVecCasc = {casc.px(), casc.py(), casc.pz()}; - std::array covCasc = {0.}; + const std::array vertexCasc{casc.x(), casc.y(), casc.z()}; + const std::array pVecCasc{casc.px(), casc.py(), casc.pz()}; + std::array covCasc{}; constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component for (int i = 0; i < 6; i++) { covCasc[MomInd[i]] = casc.momentumCovMat()[i]; @@ -3690,13 +3690,13 @@ struct HfTrackIndexSkimCreatorLfCascades { df2.propagateTracksToVertex(); if (df2.isPropagateTracksToVertexDone()) { - std::array pVecXi = {0.}; - std::array pVecPion1XiHyp = {0.}; + std::array pVecXi = {0.f}; + std::array pVecPion1XiHyp = {0.f}; df2.getTrack(0).getPxPyPzGlo(pVecXi); df2.getTrack(1).getPxPyPzGlo(pVecPion1XiHyp); float const ptXic = RecoDecay::pt(pVecXi, pVecPion1XiHyp); - std::array, 2> const arrMomToXi = {pVecXi, pVecPion1XiHyp}; + const std::array arrMomToXi{pVecXi, pVecPion1XiHyp}; auto mass2ProngXiHyp = RecoDecay::m(arrMomToXi, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::XiczeroOmegaczeroToXiPi]); if ((std::abs(casc.mXi() - MassXiMinus) < config.cascadeMassWindow) && (mass2ProngXiHyp >= config.massXiPiMin) && (mass2ProngXiHyp <= config.massXiPiMax)) { @@ -3737,13 +3737,13 @@ struct HfTrackIndexSkimCreatorLfCascades { if (df2.isPropagateTracksToVertexDone()) { - std::array pVecOmega = {0.}; - std::array pVecCharmBachelor1OmegaHyp = {0.}; + std::array pVecOmega{0.f}; + std::array pVecCharmBachelor1OmegaHyp{0.f}; df2.getTrack(0).getPxPyPzGlo(pVecOmega); df2.getTrack(1).getPxPyPzGlo(pVecCharmBachelor1OmegaHyp); float const ptOmegac = RecoDecay::pt(pVecOmega, pVecCharmBachelor1OmegaHyp); - std::array, 2> const arrMomToOmega = {pVecOmega, pVecCharmBachelor1OmegaHyp}; + const std::array arrMomToOmega{pVecOmega, pVecCharmBachelor1OmegaHyp}; auto mass2ProngOmegaPiHyp = RecoDecay::m(arrMomToOmega, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaPi]); auto mass2ProngOmegaKHyp = RecoDecay::m(arrMomToOmega, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaK]); From 57c5a5b4d35d77230fc655696f4c0965c3156044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 21:15:32 +0200 Subject: [PATCH 07/14] Array declarations. Const correctness --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 113 +++++++++--------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index 12ef57dc227..87fd4494ae5 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -133,7 +133,7 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { void init(InitContext const&) { - std::array doProcess = {doprocessTrigAndCentFT0ASel, doprocessTrigAndCentFT0CSel, doprocessTrigAndCentFT0MSel, doprocessTrigAndCentFV0ASel, doprocessTrigSel, doprocessNoTrigSel, doprocessUpcSel}; + const std::array doProcess = {doprocessTrigAndCentFT0ASel, doprocessTrigAndCentFT0CSel, doprocessTrigAndCentFT0MSel, doprocessTrigAndCentFV0ASel, doprocessTrigSel, doprocessNoTrigSel, doprocessUpcSel}; if (std::accumulate(doProcess.begin(), doProcess.end(), 0) != 1) { LOGP(fatal, "One and only one process function for collision selection can be enabled at a time!"); } @@ -148,7 +148,7 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { hfEvSel.addHistograms(registry); // collision monitoring if (doprocessTrigAndCentFT0ASel || doprocessTrigAndCentFT0CSel || doprocessTrigAndCentFT0MSel || doprocessTrigAndCentFV0ASel) { - AxisSpec const axisCentrality{200, 0., 100., "centrality percentile"}; + const AxisSpec axisCentrality{200, 0., 100., "centrality percentile"}; registry.add("hCentralitySelected", "Centrality percentile of selected events in the centrality interval; centrality percentile;entries", {HistType::kTH1D, {axisCentrality}}); registry.add("hCentralityRejected", "Centrality percentile of selected events outside the centrality interval; centrality percentile;entries", {HistType::kTH1D, {axisCentrality}}); } @@ -158,9 +158,10 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { /// Collision selection /// \param collision collision table with template - void selectCollision(const Col& collision, const BCsType& bcs) + void selectCollision(const Col& collision, + const BCsType& bcs) { - float centrality = -1.f; + float centrality{-1.f}; o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; if constexpr (applyUpcSel) { @@ -349,7 +350,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { void init(InitContext const&) { - std::array doProcess = {doprocessNoPid, doprocessProtonPidTpc, doprocessProtonPidTof, doprocessProtonPidTpcOrTof, doprocessProtonPidTpcAndTof}; + const std::array doProcess = {doprocessNoPid, doprocessProtonPidTpc, doprocessProtonPidTof, doprocessProtonPidTpcOrTof, doprocessProtonPidTpcAndTof}; if (std::accumulate(doProcess.begin(), doProcess.end(), 0) != 1) { LOGP(fatal, "One and only one process function for the different PID selection strategies can be enabled at a time!"); } @@ -398,8 +399,8 @@ struct HfTrackIndexSkimCreatorTagSelTracks { registry.add("hDCAToPrimXYVsPtCutsCascadeBachelor", "tracks selected for cascade-bachelor vertexing;#it{p}_{T}^{track} (GeV/#it{c});DCAxy to prim. vtx. (cm);entries", {HistType::kTH2D, {{360, 0., 36.}, {400, -2., 2.}}}); registry.add("hEtaCutsCascadeBachelor", "tracks selected for cascade-bachelor vertexing;#it{#eta};entries", {HistType::kTH1D, {{static_cast(0.6 * (config.etaMaxTrackBachLfCasc - config.etaMinTrackBachLfCasc) * 100), -1.2 * config.etaMinTrackBachLfCasc, 1.2 * config.etaMaxTrackBachLfCasc}}}); - std::string cutNames[nCuts + 1] = {"selected", "rej pT", "rej eta", "rej track quality", "rej dca"}; - std::string candNames[CandidateType::NCandidateTypes] = {"2-prong", "3-prong", "bachelor", "dstar", "lfCascBachelor"}; + const std::string cutNames[nCuts + 1] = {"selected", "rej pT", "rej eta", "rej track quality", "rej dca"}; + const std::string candNames[CandidateType::NCandidateTypes] = {"2-prong", "3-prong", "bachelor", "dstar", "lfCascBachelor"}; for (int iCandType = 0; iCandType < CandidateType::NCandidateTypes; iCandType++) { for (int iCut = 0; iCut < nCuts + 1; iCut++) { registry.get(HIST("hRejTracks"))->GetXaxis()->SetBinLabel((nCuts + 1) * iCandType + iCut + 1, Form("%s %s", candNames[iCandType].data(), cutNames[iCut].data())); @@ -410,16 +411,16 @@ struct HfTrackIndexSkimCreatorTagSelTracks { // Needed for PV refitting if (config.doPvRefit) { if (config.fillHistograms) { - AxisSpec const axisCollisionX{100, -20.f, 20.f, "X (cm)"}; - AxisSpec const axisCollisionY{100, -20.f, 20.f, "Y (cm)"}; - AxisSpec const axisCollisionZ{100, -20.f, 20.f, "Z (cm)"}; - AxisSpec const axisCollisionXOriginal{100, -2.f, 2.f, "X original PV (cm)"}; - AxisSpec const axisCollisionYOriginal{100, -2.f, 2.f, "Y original PV (cm)"}; - AxisSpec const axisCollisionZOriginal{100, -2.f, 2.f, "Z original PV (cm)"}; - AxisSpec const axisCollisionNContrib{1000, 0, 1000, "Number of contributors"}; - AxisSpec const axisCollisionDeltaX{axisPvRefitDeltaX, "#Delta x_{PV} (cm)"}; - AxisSpec const axisCollisionDeltaY{axisPvRefitDeltaY, "#Delta y_{PV} (cm)"}; - AxisSpec const axisCollisionDeltaZ{axisPvRefitDeltaZ, "#Delta z_{PV} (cm)"}; + const AxisSpec axisCollisionX{100, -20.f, 20.f, "X (cm)"}; + const AxisSpec axisCollisionY{100, -20.f, 20.f, "Y (cm)"}; + const AxisSpec axisCollisionZ{100, -20.f, 20.f, "Z (cm)"}; + const AxisSpec axisCollisionXOriginal{100, -2.f, 2.f, "X original PV (cm)"}; + const AxisSpec axisCollisionYOriginal{100, -2.f, 2.f, "Y original PV (cm)"}; + const AxisSpec axisCollisionZOriginal{100, -2.f, 2.f, "Z original PV (cm)"}; + const AxisSpec axisCollisionNContrib{1000, 0, 1000, "Number of contributors"}; + const AxisSpec axisCollisionDeltaX{axisPvRefitDeltaX, "#Delta x_{PV} (cm)"}; + const AxisSpec axisCollisionDeltaY{axisPvRefitDeltaY, "#Delta y_{PV} (cm)"}; + const AxisSpec axisCollisionDeltaZ{axisPvRefitDeltaZ, "#Delta z_{PV} (cm)"}; registry.add("PvRefit/hVerticesPerTrack", "", kTH1D, {{3, 0.5f, 3.5f, ""}}); registry.get(HIST("PvRefit/hVerticesPerTrack"))->GetXaxis()->SetBinLabel(1, "All PV"); @@ -739,8 +740,8 @@ struct HfTrackIndexSkimCreatorTagSelTracks { template void performPvRefitTrack(aod::Collision const& collision, aod::BCsWithTimestamps const&, - std::vector vecPvContributorGlobId, - std::vector vecPvContributorTrackParCov, + std::vector const& vecPvContributorGlobId, + std::vector const& vecPvContributorTrackParCov, TTrack const& trackToRemove, std::array& pvCoord, std::array& pvCovMatrix, @@ -949,8 +950,8 @@ struct HfTrackIndexSkimCreatorTagSelTracks { pvRefitPvCovMatrix = {collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()}; /// retrieve PV contributors for the current collision - std::vector vecPvContributorGlobId = {}; - std::vector vecPvContributorTrackParCov = {}; + std::vector vecPvContributorGlobId{}; + std::vector vecPvContributorTrackParCov{}; for (const auto& contributor : pvContrCollision) { vecPvContributorGlobId.push_back(contributor.globalIndex()); @@ -1275,17 +1276,17 @@ struct HfTrackIndexSkimCreator { static constexpr int kNCuts2Prong[kN2ProngDecays] = {hf_cuts_presel_2prong::NCutVars, hf_cuts_presel_2prong::NCutVars, hf_cuts_presel_2prong::NCutVars}; // how many different selections are made on 2-prongs static constexpr int kNCuts3Prong[kN3ProngDecays] = {hf_cuts_presel_3prong::NCutVars, hf_cuts_presel_3prong::NCutVars + 1, hf_cuts_presel_ds::NCutVars, hf_cuts_presel_3prong::NCutVars + 1}; // how many different selections are made on 3-prongs (Lc and Xic have also PID potentially) static constexpr int kNCutsDstar = 3; // how many different selections are made on Dstars - std::array, 2>, kN2ProngDecays> arrMass2Prong; - std::array, 2>, kN3ProngDecays> arrMass3Prong; + std::array, 2>, kN2ProngDecays> arrMass2Prong{}; + std::array, 2>, kN3ProngDecays> arrMass3Prong{}; // arrays of 2-prong and 3-prong cuts - std::array, kN2ProngDecays> cut2Prong; - std::array, kN2ProngDecays> binsPt2Prong; - std::array, kN3ProngDecays> cut3Prong; - std::array, kN3ProngDecays> binsPt3Prong; + std::array, kN2ProngDecays> cut2Prong{}; + std::array, kN2ProngDecays> binsPt2Prong{}; + std::array, kN3ProngDecays> cut3Prong{}; + std::array, kN3ProngDecays> binsPt3Prong{}; // ML response - o2::analysis::MlResponse hfMlResponse2Prongs; // only D0 - std::array, kN3ProngDecays> hfMlResponse3Prongs; // D+, Lc, Ds, Xic + o2::analysis::MlResponse hfMlResponse2Prongs; // only D0 + std::array, kN3ProngDecays> hfMlResponse3Prongs{}; // D+, Lc, Ds, Xic std::array hasMlModel3Prong{false}; o2::ccdb::CcdbApi ccdbApi; @@ -1294,7 +1295,7 @@ struct HfTrackIndexSkimCreator { using FilteredTrackAssocSel = soa::Filtered>; // filter collisions - Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); + Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); // filter track indices Filter filterSelectTrackIds = ((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::Cand2Prong))) != 0u) || ((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::Cand3Prong))) != 0u) || ((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::CandDstar))) != 0u); @@ -1502,7 +1503,7 @@ struct HfTrackIndexSkimCreator { for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { - // pt + // pT const auto binPt = findBin(&binsPt2Prong[iDecay2P], pt); // return immediately if it is outside the defined pT bins if (binPt == -1) { @@ -1543,7 +1544,7 @@ struct HfTrackIndexSkimCreator { // imp. par. product cut if (config.debug || TESTBIT(isSelected, iDecay2P)) { - auto impParProduct = dcaTrack0 * dcaTrack1; + const auto impParProduct = dcaTrack0 * dcaTrack1; if (impParProduct > cut2Prong[iDecay2P].get(binPt, 3u)) { CLRBIT(isSelected, iDecay2P); if (config.debug) { @@ -1554,10 +1555,10 @@ struct HfTrackIndexSkimCreator { // additional check for D0 to be used in D* finding if (iDecay2P == hf_cand_2prong::DecayType::D0ToPiK && config.doDstar && TESTBIT(isSelected, iDecay2P)) { - auto pTBinDstar = findBin(config.binsPtDstarToD0Pi, pt * 1.2); // assuming the D* pT about 20% higher than the one of the D0 to be safe - if (pTBinDstar >= 0) { + const auto binPtDstar = findBin(config.binsPtDstarToD0Pi, pt * 1.2); // assuming the D* pT about 20% higher than the one of the D0 to be safe + if (binPtDstar >= 0) { whichHypo[kN2ProngDecays] = whichHypo[hf_cand_2prong::DecayType::D0ToPiK]; - const double deltaMass = config.cutsDstarToD0Pi->get(pTBinDstar, 1u); + const double deltaMass = config.cutsDstarToD0Pi->get(binPtDstar, 1u); if (TESTBIT(whichHypo[iDecay2P], 0) && (massHypos[0] > (MassD0 + deltaMass) * (MassD0 + deltaMass) || massHypos[0] < (MassD0 - deltaMass) * (MassD0 - deltaMass))) { CLRBIT(whichHypo[kN2ProngDecays], 0); @@ -1703,7 +1704,7 @@ struct HfTrackIndexSkimCreator { continue; } - // cosp + // cos of pointing angle if (config.debug || TESTBIT(isSelected, iDecay2P)) { const auto cpa = RecoDecay::cpa(primVtx, secVtx, pVecCand); if (cpa < cut2Prong[iDecay2P].get(binPt, 2u)) { // 2u == "cospIndex[iDecay2P]" @@ -1768,11 +1769,11 @@ struct HfTrackIndexSkimCreator { { if (config.debug || isSelected > 0) { - auto pT = RecoDecay::pt(pVecCand); + const auto pt = RecoDecay::pt(pVecCand); for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { // pT - const auto binPt = findBin(&binsPt3Prong[iDecay3P], pT); + const auto binPt = findBin(&binsPt3Prong[iDecay3P], pt); if (binPt == -1) { // cut if it is outside the defined pT bins CLRBIT(isSelected, iDecay3P); if (config.debug) { @@ -1781,7 +1782,7 @@ struct HfTrackIndexSkimCreator { continue; } - // cosp + // cos of pointing angle if (config.debug || TESTBIT(isSelected, iDecay3P)) { const auto cpa = RecoDecay::cpa(primVtx, secVtx, pVecCand); if (cpa < cut3Prong[iDecay3P].get(binPt, 2u)) { // 2u == cospIndex[iDecay3P] @@ -1819,7 +1820,7 @@ struct HfTrackIndexSkimCreator { return; } - const float ptDummy = 1.; // dummy pT value (only one pT bin) + const float ptDummy = 1.f; // dummy pT value (only one pT bin) for (int iDecay3P{0}; iDecay3P < kN3ProngDecays; ++iDecay3P) { if (TESTBIT(isSelected, iDecay3P) && hasMlModel3Prong[iDecay3P]) { bool isMlSel = false; @@ -1884,7 +1885,7 @@ struct HfTrackIndexSkimCreator { const std::array arrMomD0{pVecTrack0, pVecTrack1}; const auto pt = RecoDecay::pt(pVecTrack0, pVecTrack1, pVecTrack2) + config.ptTolerance; // add tolerance because of no reco decay vertex - // pt + // pT const auto binPt = findBin(config.binsPtDstarToD0Pi, pt); // return immediately if it is outside the defined pT bins if (binPt == -1) { @@ -2116,8 +2117,8 @@ struct HfTrackIndexSkimCreator { int const n2ProngBit = BIT(kN2ProngDecays) - 1; // bit value for 2-prong candidates where each candidate is one bit and they are all set to 1 int const n3ProngBit = BIT(kN3ProngDecays) - 1; // bit value for 3-prong candidates where each candidate is one bit and they are all set to 1 - std::array, kN2ProngDecays> cutStatus2Prong; - std::array, kN3ProngDecays> cutStatus3Prong; + std::array, kN2ProngDecays> cutStatus2Prong{}; + std::array, kN3ProngDecays> cutStatus3Prong{}; uint8_t nCutStatus2ProngBit[kN2ProngDecays]; // bit value for selection status for each 2-prong candidate where each selection is one bit and they are all set to 1 uint8_t nCutStatus3ProngBit[kN3ProngDecays]; // bit value for selection status for each 3-prong candidate where each selection is one bit and they are all set to 1 @@ -2812,7 +2813,7 @@ struct HfTrackIndexSkimCreator { // 3-prong selections after secondary vertex applySelection3Prong(pVecCandProng3Neg, secondaryVertex3, pvRefitCoord3Prong1Pos2Neg, cutStatus3Prong, isSelected3ProngCand); - std::array, kN3ProngDecays> mlScores3Prongs; + std::array, kN3ProngDecays> mlScores3Prongs{}; if (config.applyMlForHfFilters) { std::vector const inputFeatures{trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg2.getPt(), dcaInfoNeg2[0], dcaInfoNeg2[1]}; std::vector inputFeaturesLcPid{}; @@ -3095,7 +3096,7 @@ struct HfTrackIndexSkimCreatorCascades { using SelectedCollisions = soa::Filtered>; using FilteredTrackAssocSel = soa::Filtered>; - Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); + Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); Filter filterSelectTrackIds = (aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::CandV0bachelor))) != 0u && (config.applyProtonPid == false || (aod::hf_sel_track::isIdentifiedPid & static_cast(BIT(ChannelsProtonPid::LcToPK0S))) != 0u); Preslice trackIndicesPerCollision = aod::track_association::collisionId; @@ -3364,7 +3365,7 @@ struct HfTrackIndexSkimCreatorLfCascades { using CascFull = soa::Join; using V0Full = soa::Join; - Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); + Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); Filter filterSelectTrackIds = (aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::CandCascadeBachelor))) != 0u; Preslice tracksPerCollision = aod::track::collisionId; // needed for PV refit @@ -3502,7 +3503,7 @@ struct HfTrackIndexSkimCreatorLfCascades { template bool isPreselectedCandidateXic(T1 const& pVecXi, T1 const& pVecPi1, T1 const& pVecPi2) { - // pt + // pT if (config.ptMinXicplusLfCasc > 0.f) { const auto pt = RecoDecay::pt(pVecXi, pVecPi1, pVecPi2) + config.ptTolerance; // add tolerance because of no reco decay vertex if (pt < config.ptMinXicplusLfCasc) { @@ -3532,7 +3533,7 @@ struct HfTrackIndexSkimCreatorLfCascades { template bool isSelectedCandidateXic(const T1& pVecCand, const T2& secVtx, const T3& primVtx) { - // pt + // pT if (config.ptMinXicplusLfCasc > 0.f) { const auto pt = RecoDecay::pt(pVecCand); if (pt < config.ptMinXicplusLfCasc) { @@ -3690,11 +3691,11 @@ struct HfTrackIndexSkimCreatorLfCascades { df2.propagateTracksToVertex(); if (df2.isPropagateTracksToVertexDone()) { - std::array pVecXi = {0.f}; - std::array pVecPion1XiHyp = {0.f}; + std::array pVecXi{}; + std::array pVecPion1XiHyp{}; df2.getTrack(0).getPxPyPzGlo(pVecXi); df2.getTrack(1).getPxPyPzGlo(pVecPion1XiHyp); - float const ptXic = RecoDecay::pt(pVecXi, pVecPion1XiHyp); + const float ptXic = RecoDecay::pt(pVecXi, pVecPion1XiHyp); const std::array arrMomToXi{pVecXi, pVecPion1XiHyp}; auto mass2ProngXiHyp = RecoDecay::m(arrMomToXi, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::XiczeroOmegaczeroToXiPi]); @@ -3737,15 +3738,15 @@ struct HfTrackIndexSkimCreatorLfCascades { if (df2.isPropagateTracksToVertexDone()) { - std::array pVecOmega{0.f}; - std::array pVecCharmBachelor1OmegaHyp{0.f}; + std::array pVecOmega{}; + std::array pVecCharmBachelor1OmegaHyp{}; df2.getTrack(0).getPxPyPzGlo(pVecOmega); df2.getTrack(1).getPxPyPzGlo(pVecCharmBachelor1OmegaHyp); - float const ptOmegac = RecoDecay::pt(pVecOmega, pVecCharmBachelor1OmegaHyp); + const float ptOmegac = RecoDecay::pt(pVecOmega, pVecCharmBachelor1OmegaHyp); const std::array arrMomToOmega{pVecOmega, pVecCharmBachelor1OmegaHyp}; - auto mass2ProngOmegaPiHyp = RecoDecay::m(arrMomToOmega, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaPi]); - auto mass2ProngOmegaKHyp = RecoDecay::m(arrMomToOmega, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaK]); + const auto mass2ProngOmegaPiHyp = RecoDecay::m(arrMomToOmega, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaPi]); + const auto mass2ProngOmegaKHyp = RecoDecay::m(arrMomToOmega, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::OmegaczeroToOmegaK]); if (std::abs(casc.mOmega() - MassOmegaMinus) < config.cascadeMassWindow) { if ((mass2ProngOmegaPiHyp >= config.massOmegaCharmBachelorMin) && (mass2ProngOmegaPiHyp <= config.massOmegaCharmBachelorMax)) { From f82edd6aca61ddc436734f6ddbc9c72433d7ed7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 21:15:39 +0200 Subject: [PATCH 08/14] Use unsigned types for bitmaps --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 224 +++++++++--------- 1 file changed, 110 insertions(+), 114 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index 87fd4494ae5..fa2d6423533 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -331,9 +331,9 @@ struct HfTrackIndexSkimCreatorTagSelTracks { // single-track cuts static const int nCuts = 4; // array of 2-prong and 3-prong cuts - std::array, CandidateType::NCandidateTypes> cutsSingleTrack; + std::array, CandidateType::NCandidateTypes> cutsSingleTrack{}; // proton PID, if enabled - std::array selectorProton; + std::array selectorProton{}; TrackSelectorKa selectorKaon; Partition pvContributors = ((aod::track::flags & static_cast(aod::track::PVContributor)) == static_cast(aod::track::PVContributor)); @@ -601,7 +601,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { hasGoodQuality = false; } } else { - UChar_t const clustermap = hfTrack.itsClusterMap(); + const auto clustermap = hfTrack.itsClusterMap(); if (!(hfTrack.tpcNClsFound() >= config.tpcNClsFoundMin.value && // is this the number of TPC clusters? It should not be used TESTBIT(hfTrack.flags(), o2::aod::track::ITSrefit) && (TESTBIT(clustermap, 0) || TESTBIT(clustermap, 1)))) { @@ -637,7 +637,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { hasGoodQuality = false; } } else { // selections for Run2 converted data - UChar_t const clustermap = hfTrack.itsClusterMap(); + const auto clustermap = hfTrack.itsClusterMap(); if (!(TESTBIT(hfTrack.flags(), o2::aod::track::ITSrefit) && (TESTBIT(clustermap, 0) || TESTBIT(clustermap, 1)))) { hasGoodQuality = false; } @@ -666,7 +666,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { hasGoodQuality = false; } } else { // selections for Run2 converted data - UChar_t const clustermap = hfTrack.itsClusterMap(); + const auto clustermap = hfTrack.itsClusterMap(); if (!(TESTBIT(hfTrack.flags(), o2::aod::track::ITSrefit) && (TESTBIT(clustermap, 0) || TESTBIT(clustermap, 1)))) { hasGoodQuality = false; } @@ -788,7 +788,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { o2::vertexing::PVertexer vertexer; o2::conf::ConfigurableParam::updateFromString("pvertexer.useMeanVertexConstraint=false"); /// remove diamond constraint (let's keep it at the moment...) vertexer.init(); - bool const pvRefitDoable = vertexer.prepareVertexRefit(vecPvContributorTrackParCov, primVtx); + const bool pvRefitDoable = vertexer.prepareVertexRefit(vecPvContributorTrackParCov, primVtx); if (!pvRefitDoable) { LOG(info) << "Not enough tracks accepted for the refit"; if (config.doPvRefit && config.fillHistograms) { @@ -810,7 +810,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { bool recalcImpPar = false; if (config.doPvRefit && pvRefitDoable) { recalcImpPar = true; - auto trackIterator = std::find(vecPvContributorGlobId.begin(), vecPvContributorGlobId.end(), trackToRemove.globalIndex()); /// track global index + const auto trackIterator = std::find(vecPvContributorGlobId.begin(), vecPvContributorGlobId.end(), trackToRemove.globalIndex()); /// track global index if (trackIterator != vecPvContributorGlobId.end()) { /// this track contributed to the PV fit: let's do the refit without it @@ -818,7 +818,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { vecPvRefitContributorUsed[entry] = false; /// remove the track from the PV refitting - auto primVtxRefitted = vertexer.refitVertex(vecPvRefitContributorUsed, primVtx); // vertex refit + const auto primVtxRefitted = vertexer.refitVertex(vecPvRefitContributorUsed, primVtx); // vertex refit // LOG(info) << "refit " << cnt << "/" << ntr << " result = " << primVtxRefitted.asString(); if (config.debugPvRefit) { LOG(info) << "refit for track with global index " << static_cast(trackToRemove.globalIndex()) << " " << primVtxRefitted.asString(); @@ -908,20 +908,17 @@ struct HfTrackIndexSkimCreatorTagSelTracks { // // TODO: add DCAxy and DCAz uncertainties? // } } - - return; } /// end of performPvRefitTrack function /// Selection tag for tracks + /// \tparam TTracks is the type of the track table /// \param collision is the collision iterator - /// \param tracks is the entire track table /// \param trackIndicesCollision are the track indices associated to this collision (from track-to-collision-associator) /// \param pvContrCollision are the PV contributors of this collision /// \param bcWithTimeStamps is the bc with timestamp for PVrefit /// \param pvRefitDcaPerTrack is a vector to be filled with track dcas after PV refit /// \param pvRefitPvCoordPerTrack is a vector to be filled with PV coordinates after PV refit /// \param pvRefitPvCovMatrixPerTrack is a vector to be filled with PV coordinate covariances after PV refit - /// \return true if the track is compatible with a proton hypothesis template void runTagSelTracks(aod::Collision const& collision, TTracks const&, @@ -932,11 +929,10 @@ struct HfTrackIndexSkimCreatorTagSelTracks { std::vector>& pvRefitPvCoordPerTrack, std::vector>& pvRefitPvCovMatrixPerTrack) { - auto thisCollId = collision.globalIndex(); + const auto thisCollId = collision.globalIndex(); for (const auto& trackId : trackIndicesCollision) { int statusProng = BIT(CandidateType::NCandidateTypes) - 1; // all bits on - auto track = trackId.template track_as(); - auto trackIdx = track.globalIndex(); + const auto track = trackId.template track_as(); float trackPt = track.pt(); float trackEta = track.eta(); @@ -967,6 +963,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { } performPvRefitTrack(collision, bcWithTimeStamps, vecPvContributorGlobId, vecPvContributorTrackParCov, track, pvRefitPvCoord, pvRefitPvCovMatrix, pvRefitDcaXYDcaZ); // we subtract the offset since trackIdx is the global index referred to the total track table + const auto trackIdx = track.globalIndex(); pvRefitDcaPerTrack[trackIdx] = pvRefitDcaXYDcaZ; pvRefitPvCoordPerTrack[trackIdx] = pvRefitPvCoord; pvRefitPvCovMatrixPerTrack[trackIdx] = pvRefitPvCovMatrix; @@ -992,20 +989,19 @@ struct HfTrackIndexSkimCreatorTagSelTracks { // } isSelectedTrack(track, trackPt, trackEta, pvRefitDcaXYDcaZ, statusProng); - int8_t const isIdentifiedPid = isSelectedPid(track); - bool const isPositive = track.sign() > 0; + const int8_t isIdentifiedPid = isSelectedPid(track); + const bool isPositive = track.sign() > 0; rowSelectedTrack(statusProng, isIdentifiedPid, isPositive); } } /// Helper function to fill PVrefit table - /// \param pvRefitDcaPerTrack is a vector to be filled with track dcas after PV refit - /// \param pvRefitPvCoordPerTrack is a vector to be filled with PV coordinates after PV refit - /// \param pvRefitPvCovMatrixPerTrack is a vector to be filled with PV coordinate covariances after PV refit - /// \return true if the track is compatible with a proton hypothesis - void fillPvRefitTable(std::vector>& pvRefitDcaPerTrack, - std::vector>& pvRefitPvCoordPerTrack, - std::vector>& pvRefitPvCovMatrixPerTrack) + /// \param pvRefitDcaPerTrack is a vector filled with track dcas after PV refit + /// \param pvRefitPvCoordPerTrack is a vector filled with PV coordinates after PV refit + /// \param pvRefitPvCovMatrixPerTrack is a vector filled with PV coordinate covariances after PV refit + void fillPvRefitTable(std::vector> const& pvRefitDcaPerTrack, + std::vector> const& pvRefitPvCoordPerTrack, + std::vector> const& pvRefitPvCovMatrixPerTrack) { for (auto iTrack{0u}; iTrack < pvRefitDcaPerTrack.size(); ++iTrack) { tabPvRefitTrack(pvRefitPvCoordPerTrack[iTrack][0], pvRefitPvCoordPerTrack[iTrack][1], pvRefitPvCoordPerTrack[iTrack][2], @@ -1025,7 +1021,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { std::vector> pvRefitPvCoordPerTrack{}; std::vector> pvRefitPvCovMatrixPerTrack{}; if (config.doPvRefit) { - auto numTracks = tracks.size(); + const auto numTracks = tracks.size(); pvRefitDcaPerTrack.resize(numTracks); pvRefitPvCoordPerTrack.resize(numTracks); pvRefitPvCovMatrixPerTrack.resize(numTracks); @@ -1033,9 +1029,9 @@ struct HfTrackIndexSkimCreatorTagSelTracks { } for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto pvContrCollision = pvContributors->sliceByCached(aod::track::collisionId, thisCollId, cache); + const auto thisCollId = collision.globalIndex(); + const auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + const auto pvContrCollision = pvContributors->sliceByCached(aod::track::collisionId, thisCollId, cache); runTagSelTracks(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack); } @@ -1056,7 +1052,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { std::vector> pvRefitPvCoordPerTrack{}; std::vector> pvRefitPvCovMatrixPerTrack{}; if (config.doPvRefit) { - auto numTracks = tracks.size(); + const auto numTracks = tracks.size(); pvRefitDcaPerTrack.resize(numTracks); pvRefitPvCoordPerTrack.resize(numTracks); pvRefitPvCovMatrixPerTrack.resize(numTracks); @@ -1064,9 +1060,9 @@ struct HfTrackIndexSkimCreatorTagSelTracks { } for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto pvContrCollision = pvContributorsWithPidTpc->sliceByCached(aod::track::collisionId, thisCollId, cache); + const auto thisCollId = collision.globalIndex(); + const auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + const auto pvContrCollision = pvContributorsWithPidTpc->sliceByCached(aod::track::collisionId, thisCollId, cache); runTagSelTracks(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack); } @@ -1087,7 +1083,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { std::vector> pvRefitPvCoordPerTrack{}; std::vector> pvRefitPvCovMatrixPerTrack{}; if (config.doPvRefit) { - auto numTracks = tracks.size(); + const auto numTracks = tracks.size(); pvRefitDcaPerTrack.resize(numTracks); pvRefitPvCoordPerTrack.resize(numTracks); pvRefitPvCovMatrixPerTrack.resize(numTracks); @@ -1095,9 +1091,9 @@ struct HfTrackIndexSkimCreatorTagSelTracks { } for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto pvContrCollision = pvContributorsWithPidTof->sliceByCached(aod::track::collisionId, thisCollId, cache); + const auto thisCollId = collision.globalIndex(); + const auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + const auto pvContrCollision = pvContributorsWithPidTof->sliceByCached(aod::track::collisionId, thisCollId, cache); runTagSelTracks(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack); } @@ -1118,7 +1114,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { std::vector> pvRefitPvCoordPerTrack{}; std::vector> pvRefitPvCovMatrixPerTrack{}; if (config.doPvRefit) { - auto numTracks = tracks.size(); + const auto numTracks = tracks.size(); pvRefitDcaPerTrack.resize(numTracks); pvRefitPvCoordPerTrack.resize(numTracks); pvRefitPvCovMatrixPerTrack.resize(numTracks); @@ -1126,9 +1122,9 @@ struct HfTrackIndexSkimCreatorTagSelTracks { } for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto pvContrCollision = pvContributorsWithPidTpcTof->sliceByCached(aod::track::collisionId, thisCollId, cache); + const auto thisCollId = collision.globalIndex(); + const auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + const auto pvContrCollision = pvContributorsWithPidTpcTof->sliceByCached(aod::track::collisionId, thisCollId, cache); runTagSelTracks(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack); } @@ -1149,7 +1145,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { std::vector> pvRefitPvCoordPerTrack{}; std::vector> pvRefitPvCovMatrixPerTrack{}; if (config.doPvRefit) { - auto numTracks = tracks.size(); + const auto numTracks = tracks.size(); pvRefitDcaPerTrack.resize(numTracks); pvRefitPvCoordPerTrack.resize(numTracks); pvRefitPvCovMatrixPerTrack.resize(numTracks); @@ -1157,9 +1153,9 @@ struct HfTrackIndexSkimCreatorTagSelTracks { } for (const auto& collision : collisions) { - auto thisCollId = collision.globalIndex(); - auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto pvContrCollision = pvContributorsWithPidTpcTof->sliceByCached(aod::track::collisionId, thisCollId, cache); + const auto thisCollId = collision.globalIndex(); + const auto groupedTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + const auto pvContrCollision = pvContributorsWithPidTpcTof->sliceByCached(aod::track::collisionId, thisCollId, cache); runTagSelTracks(collision, tracks, groupedTrackIndices, pvContrCollision, bcWithTimeStamps, pvRefitDcaPerTrack, pvRefitPvCoordPerTrack, pvRefitPvCovMatrixPerTrack); } @@ -1373,8 +1369,8 @@ struct HfTrackIndexSkimCreator { runNumber = 0; if (config.fillHistograms) { - AxisSpec const axisNumTracks{500, -0.5f, 499.5f, "Number of tracks"}; - AxisSpec const axisNumCands{1000, -0.5f, 999.5f, "Number of candidates"}; + const AxisSpec axisNumTracks{500, -0.5f, 499.5f, "Number of tracks"}; + const AxisSpec axisNumCands{1000, -0.5f, 999.5f, "Number of candidates"}; registry.add("hNTracks", "Number of selected tracks;# of selected tracks;entries", {HistType::kTH1D, {axisNumTracks}}); // 2-prong histograms registry.add("hVtx2ProngX", "2-prong candidates;#it{x}_{sec. vtx.} (cm);entries", {HistType::kTH1D, {{1000, -2., 2.}}}); @@ -1399,16 +1395,16 @@ struct HfTrackIndexSkimCreator { // needed for PV refitting if (doprocess2And3ProngsWithPvRefit || doprocess2And3ProngsWithPvRefitWithPidForHfFiltersBdt) { - AxisSpec const axisCollisionX{100, -20.f, 20.f, "X (cm)"}; - AxisSpec const axisCollisionY{100, -20.f, 20.f, "Y (cm)"}; - AxisSpec const axisCollisionZ{100, -20.f, 20.f, "Z (cm)"}; - AxisSpec const axisCollisionXOriginal{1000, -20.f, 20.f, "X original PV (cm)"}; - AxisSpec const axisCollisionYOriginal{1000, -20.f, 20.f, "Y original PV (cm)"}; - AxisSpec const axisCollisionZOriginal{1000, -20.f, 20.f, "Z original PV (cm)"}; - AxisSpec const axisCollisionNContrib{1000, 0, 1000, "Number of contributors"}; - AxisSpec const axisCollisionDeltaX{axisPvRefitDeltaX, "#Delta x_{PV} (cm)"}; - AxisSpec const axisCollisionDeltaY{axisPvRefitDeltaY, "#Delta y_{PV} (cm)"}; - AxisSpec const axisCollisionDeltaZ{axisPvRefitDeltaZ, "#Delta z_{PV} (cm)"}; + const AxisSpec axisCollisionX{100, -20.f, 20.f, "X (cm)"}; + const AxisSpec axisCollisionY{100, -20.f, 20.f, "Y (cm)"}; + const AxisSpec axisCollisionZ{100, -20.f, 20.f, "Z (cm)"}; + const AxisSpec axisCollisionXOriginal{1000, -20.f, 20.f, "X original PV (cm)"}; + const AxisSpec axisCollisionYOriginal{1000, -20.f, 20.f, "Y original PV (cm)"}; + const AxisSpec axisCollisionZOriginal{1000, -20.f, 20.f, "Z original PV (cm)"}; + const AxisSpec axisCollisionNContrib{1000, 0, 1000, "Number of contributors"}; + const AxisSpec axisCollisionDeltaX{axisPvRefitDeltaX, "#Delta x_{PV} (cm)"}; + const AxisSpec axisCollisionDeltaY{axisPvRefitDeltaY, "#Delta y_{PV} (cm)"}; + const AxisSpec axisCollisionDeltaZ{axisPvRefitDeltaZ, "#Delta z_{PV} (cm)"}; registry.add("PvRefit/verticesPerCandidate", "", kTH1D, {{6, 0.5f, 6.5f, ""}}); registry.get(HIST("PvRefit/verticesPerCandidate"))->GetXaxis()->SetBinLabel(1, "All PV"); registry.get(HIST("PvRefit/verticesPerCandidate"))->GetXaxis()->SetBinLabel(2, "PV refit doable"); @@ -1428,7 +1424,7 @@ struct HfTrackIndexSkimCreator { } if (config.applyMlForHfFilters) { - AxisSpec const axisBdtScore{100, 0.f, 1.f}; + const AxisSpec axisBdtScore{100, 0.f, 1.f}; registry.add("ML/hMlScoreBkgD0", "Bkg ML score for D^{0} candidates;Bkg ML score;entries", kTH1D, {axisBdtScore}); registry.add("ML/hMlScorePromptD0", "Prompt ML score for D^{0} candidates;Prompt ML score;entries", kTH1D, {axisBdtScore}); registry.add("ML/hMlScoreNonpromptD0", "Non-prompt ML score for D^{0} candidates;Non-prompt ML score;entries", kTH1D, {axisBdtScore}); @@ -1448,13 +1444,13 @@ struct HfTrackIndexSkimCreator { } if (config.applyMlForHfFilters) { - const std::vector onnxFileNames2Prongs = {config.onnxFileNames->get(0u, 0u)}; - const std::array, kN3ProngDecays> onnxFileNames3Prongs = {std::vector{config.onnxFileNames->get(1u, 0u)}, std::vector{config.onnxFileNames->get(2u, 0u)}, std::vector{config.onnxFileNames->get(3u, 0u)}, std::vector{config.onnxFileNames->get(4u, 0u)}}; - const std::vector mlModelPathCcdb2Prongs = {config.mlModelPathCCDB.value + "D0"}; - const std::array, kN3ProngDecays> mlModelPathCcdb3Prongs = {std::vector{config.mlModelPathCCDB.value + "Dplus"}, std::vector{config.mlModelPathCCDB.value + "Lc"}, std::vector{config.mlModelPathCCDB.value + "Ds"}, std::vector{config.mlModelPathCCDB.value + "Xic"}}; - const std::vector ptBinsMl = {0., 1.e10}; - const std::vector cutDirMl = {o2::cuts_ml::CutDirection::CutGreater, o2::cuts_ml::CutDirection::CutSmaller, o2::cuts_ml::CutDirection::CutSmaller}; - const std::array, kN3ProngDecays> thresholdMlScore3Prongs = {config.thresholdMlScoreDplusToPiKPi, config.thresholdMlScoreLcToPiKP, config.thresholdMlScoreDsToPiKK, config.thresholdMlScoreXicToPiKP}; + const std::vector onnxFileNames2Prongs{config.onnxFileNames->get(0u, 0u)}; + const std::array, kN3ProngDecays> onnxFileNames3Prongs{std::vector{config.onnxFileNames->get(1u, 0u)}, std::vector{config.onnxFileNames->get(2u, 0u)}, std::vector{config.onnxFileNames->get(3u, 0u)}, std::vector{config.onnxFileNames->get(4u, 0u)}}; + const std::vector mlModelPathCcdb2Prongs{config.mlModelPathCCDB.value + "D0"}; + const std::array, kN3ProngDecays> mlModelPathCcdb3Prongs{std::vector{config.mlModelPathCCDB.value + "Dplus"}, std::vector{config.mlModelPathCCDB.value + "Lc"}, std::vector{config.mlModelPathCCDB.value + "Ds"}, std::vector{config.mlModelPathCCDB.value + "Xic"}}; + const std::vector ptBinsMl{0., 1.e10}; + const std::vector cutDirMl{o2::cuts_ml::CutDirection::CutGreater, o2::cuts_ml::CutDirection::CutSmaller, o2::cuts_ml::CutDirection::CutSmaller}; + const std::array, kN3ProngDecays> thresholdMlScore3Prongs{config.thresholdMlScoreDplusToPiKPi, config.thresholdMlScoreLcToPiKP, config.thresholdMlScoreDsToPiKK, config.thresholdMlScoreXicToPiKP}; // initialise 2-prong ML response hfMlResponse2Prongs.configure(ptBinsMl, config.thresholdMlScoreD0ToKPi, cutDirMl, 3); @@ -1494,7 +1490,7 @@ struct HfTrackIndexSkimCreator { /// \param isSelected is a bitmap with selection outcome /// \param pt2Prong is the pt of the 2-prong candidate template - void applyPreselection2Prong(T1 const& pVecTrack0, T1 const& pVecTrack1, T2 const& dcaTrack0, T2 const& dcaTrack1, T3& cutStatus, T4& whichHypo, int& isSelected, float& pt2Prong) + void applyPreselection2Prong(T1 const& pVecTrack0, T1 const& pVecTrack1, T2 const& dcaTrack0, T2 const& dcaTrack1, T3& cutStatus, T4& whichHypo, auto& isSelected, float& pt2Prong) { whichHypo[kN2ProngDecays] = 0; // D0 for D* @@ -1580,7 +1576,7 @@ struct HfTrackIndexSkimCreator { /// \param whichHypo information of the mass hypoteses that were selected /// \param isSelected is a bitmap with selection outcome template - void applyPreselectionPhiDecay(const int binPt, T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, T2& cutStatus, T3& whichHypo, int& isSelected) + void applyPreselectionPhiDecay(const int binPt, T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, T2& cutStatus, T3& whichHypo, auto& isSelected) { const double deltaMassMax = cut3Prong[hf_cand_3prong::DecayType::DsToKKPi].get(binPt, 4u); if (TESTBIT(whichHypo[hf_cand_3prong::DecayType::DsToKKPi], 0)) { @@ -1613,7 +1609,7 @@ struct HfTrackIndexSkimCreator { /// \param whichHypo information of the mass hypoteses that were selected /// \param isSelected is a bitmap with selection outcome template - void applyPreselection3Prong(T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, int8_t& isIdentifiedPidTrack0, int8_t& isIdentifiedPidTrack2, T2& cutStatus, T3& whichHypo, int& isSelected) + void applyPreselection3Prong(T1 const& pVecTrack0, T1 const& pVecTrack1, T1 const& pVecTrack2, const auto isIdentifiedPidTrack0, const auto isIdentifiedPidTrack2, T2& cutStatus, T3& whichHypo, auto& isSelected) { const auto pt = RecoDecay::pt(pVecTrack0, pVecTrack1, pVecTrack2) + config.ptTolerance; // add tolerance because of no reco decay vertex @@ -1688,7 +1684,7 @@ struct HfTrackIndexSkimCreator { /// \param cutStatus is a 2D array with outcome of each selection (filled only in debug mode) /// \param isSelected ia s bitmap with selection outcome template - void applySelection2Prong(const T1& pVecCand, const T2& secVtx, const T3& primVtx, T4& cutStatus, int& isSelected) + void applySelection2Prong(const T1& pVecCand, const T2& secVtx, const T3& primVtx, T4& cutStatus, auto& isSelected) { if (config.debug || isSelected > 0) { @@ -1722,13 +1718,13 @@ struct HfTrackIndexSkimCreator { /// \param featuresCand is the vector with the candidate features /// \param outputScores is the vector with the output scores to be filled /// \param isSelected ia s bitmap with selection outcome - void applyMlSelectionForHfFilters2Prong(std::vector featuresCand, std::vector& outputScores, int& isSelected) + void applyMlSelectionForHfFilters2Prong(std::vector featuresCand, std::vector& outputScores, auto& isSelected) { if (!TESTBIT(isSelected, hf_cand_2prong::DecayType::D0ToPiK)) { return; } const float ptDummy = 1.; // dummy pT value (only one pT bin) - bool const isSelMl = hfMlResponse2Prongs.isSelectedMl(featuresCand, ptDummy, outputScores); + const bool isSelMl = hfMlResponse2Prongs.isSelectedMl(featuresCand, ptDummy, outputScores); if (config.fillHistograms) { registry.fill(HIST("ML/hMlScoreBkgD0"), outputScores[0]); registry.fill(HIST("ML/hMlScorePromptD0"), outputScores[1]); @@ -1750,7 +1746,7 @@ struct HfTrackIndexSkimCreator { if (dcaFitter.getChi2AtPCACandidate() > config.maxTwoTrackChi2PcaFor3Prongs) { return false; } - auto decLen = RecoDecay::distance(primVtx, secVtx); + const auto decLen = RecoDecay::distance(primVtx, secVtx); if (decLen < config.minTwoTrackDecayLengthFor3Prongs) { return false; } @@ -1765,7 +1761,7 @@ struct HfTrackIndexSkimCreator { /// \param cutStatus is a 2D array with outcome of each selection (filled only in debug mode) /// \param isSelected ia s bitmap with selection outcome template - void applySelection3Prong(const T1& pVecCand, const T2& secVtx, const T3& primVtx, T4& cutStatus, int& isSelected) + void applySelection3Prong(const T1& pVecCand, const T2& secVtx, const T3& primVtx, T4& cutStatus, auto& isSelected) { if (config.debug || isSelected > 0) { @@ -1814,7 +1810,7 @@ struct HfTrackIndexSkimCreator { /// \param isSelected ia s bitmap with selection outcome /// \param usePidForHfFiltersBdt is the flag to determine whether to use also the PID features for the Lc BDT template - void applyMlSelectionForHfFilters3Prong(std::vector featuresCand, std::vector featuresCandPid, std::array, kN3ProngDecays>& outputScores, int& isSelected) + void applyMlSelectionForHfFilters3Prong(std::vector featuresCand, std::vector featuresCandPid, std::array, kN3ProngDecays>& outputScores, auto& isSelected) { if (isSelected == 0) { return; @@ -1828,7 +1824,7 @@ struct HfTrackIndexSkimCreator { if (iDecay3P != hf_cand_3prong::DecayType::LcToPKPi && iDecay3P != hf_cand_3prong::DecayType::XicToPKPi) { isMlSel = hfMlResponse3Prongs[iDecay3P].isSelectedMl(featuresCand, ptDummy, outputScores[iDecay3P]); } else { - std::vector featuresCandWithPid = featuresCand; + std::vector featuresCandWithPid{featuresCand}; featuresCandWithPid.insert(featuresCandWithPid.end(), featuresCandPid.begin(), featuresCandPid.end()); isMlSel = hfMlResponse3Prongs[iDecay3P].isSelectedMl(featuresCandWithPid, ptDummy, outputScores[iDecay3P]); } @@ -1956,7 +1952,7 @@ struct HfTrackIndexSkimCreator { o2::vertexing::PVertexer vertexer; o2::conf::ConfigurableParam::updateFromString("pvertexer.useMeanVertexConstraint=false"); /// remove diamond constraint (let's keep it at the moment...) vertexer.init(); - bool const pvRefitDoable = vertexer.prepareVertexRefit(vecPvContributorTrackParCov, primVtx); + const bool pvRefitDoable = vertexer.prepareVertexRefit(vecPvContributorTrackParCov, primVtx); if (!pvRefitDoable) { LOG(info) << "Not enough tracks accepted for the refit"; if ((doprocess2And3ProngsWithPvRefit || doprocess2And3ProngsWithPvRefitWithPidForHfFiltersBdt) && config.fillHistograms) { @@ -1976,7 +1972,7 @@ struct HfTrackIndexSkimCreator { } recalcPvRefit = true; int nCandContr = 0; - for (uint64_t const myGlobalID : vecCandPvContributorGlobId) { // o2-linter: disable=const-ref-in-for-loop (small type) + for (const uint64_t myGlobalID : vecCandPvContributorGlobId) { // o2-linter: disable=const-ref-in-for-loop (small type) auto trackIterator = std::find(vecPvContributorGlobId.begin(), vecPvContributorGlobId.end(), myGlobalID); /// track global index if (trackIterator != vecPvContributorGlobId.end()) { /// this is a contributor, let's remove it for the PV refit @@ -2114,8 +2110,8 @@ struct HfTrackIndexSkimCreator { // auto centrality = collision.centV0M(); //FIXME add centrality when option for variations to the process function appears - int const n2ProngBit = BIT(kN2ProngDecays) - 1; // bit value for 2-prong candidates where each candidate is one bit and they are all set to 1 - int const n3ProngBit = BIT(kN3ProngDecays) - 1; // bit value for 3-prong candidates where each candidate is one bit and they are all set to 1 + const auto n2ProngBit = BIT(kN2ProngDecays) - 1; // bit value for 2-prong candidates where each candidate is one bit and they are all set to 1 + const auto n3ProngBit = BIT(kN3ProngDecays) - 1; // bit value for 3-prong candidates where each candidate is one bit and they are all set to 1 std::array, kN2ProngDecays> cutStatus2Prong{}; std::array, kN3ProngDecays> cutStatus3Prong{}; @@ -2149,18 +2145,18 @@ struct HfTrackIndexSkimCreator { // return; //} - auto thisCollId = collision.globalIndex(); + const auto thisCollId = collision.globalIndex(); // first loop over positive tracks - auto groupedTrackIndicesPos1 = positiveFor2And3Prongs->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); + const auto groupedTrackIndicesPos1 = positiveFor2And3Prongs->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); int lastFilledD0 = -1; // index to be filled in table for D* mesons for (auto trackIndexPos1 = groupedTrackIndicesPos1.begin(); trackIndexPos1 != groupedTrackIndicesPos1.end(); ++trackIndexPos1) { - auto trackPos1 = trackIndexPos1.template track_as(); + const auto trackPos1 = trackIndexPos1.template track_as(); // retrieve the selection flag that corresponds to this collision - auto isSelProngPos1 = trackIndexPos1.isSelProng(); - bool const sel2ProngStatusPos = TESTBIT(isSelProngPos1, CandidateType::Cand2Prong); - bool const sel3ProngStatusPos1 = TESTBIT(isSelProngPos1, CandidateType::Cand3Prong); + const auto isSelProngPos1 = trackIndexPos1.isSelProng(); + const bool sel2ProngStatusPos = TESTBIT(isSelProngPos1, CandidateType::Cand2Prong); + const bool sel3ProngStatusPos1 = TESTBIT(isSelProngPos1, CandidateType::Cand3Prong); auto trackParVarPos1 = getTrackParCov(trackPos1); std::array pVecTrackPos1{trackPos1.pVector()}; @@ -2188,7 +2184,7 @@ struct HfTrackIndexSkimCreator { getPxPyPz(trackParVarNeg1, pVecTrackNeg1); } - int isSelected2ProngCand = n2ProngBit; // bitmap for checking status of two-prong candidates (1 is true, 0 is rejected) + uint isSelected2ProngCand = n2ProngBit; // bitmap for checking status of two-prong candidates (1 is true, 0 is rejected) if (config.debug) { for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { @@ -2288,7 +2284,7 @@ struct HfTrackIndexSkimCreator { } } - auto pVecCandProng2 = RecoDecay::pVec(pvec0, pvec1); + const auto pVecCandProng2 = RecoDecay::pVec(pvec0, pvec1); // 2-prong selections after secondary vertex std::array pvCoord2Prong = {collision.posX(), collision.posY(), collision.posZ()}; if constexpr (doPvRefit) { @@ -2303,9 +2299,9 @@ struct HfTrackIndexSkimCreator { std::vector mlScoresD0{}; if (config.applyMlForHfFilters) { - auto trackParVarPcaPos1 = df2.getTrack(0); - auto trackParVarPcaNeg1 = df2.getTrack(1); - std::vector const inputFeatures{trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1]}; + const auto trackParVarPcaPos1 = df2.getTrack(0); + const auto trackParVarPcaNeg1 = df2.getTrack(1); + const std::vector inputFeatures{trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1]}; applyMlSelectionForHfFilters2Prong(inputFeatures, mlScoresD0, isSelected2ProngCand); } @@ -2347,7 +2343,7 @@ struct HfTrackIndexSkimCreator { for (int iDecay2P = 0; iDecay2P < kN2ProngDecays; iDecay2P++) { if (TESTBIT(isSelected2ProngCand, iDecay2P)) { if (TESTBIT(whichHypo2Prong[iDecay2P], 0)) { - auto mass2Prong = RecoDecay::m(arrMom, arrMass2Prong[iDecay2P][0]); + const auto mass2Prong = RecoDecay::m(arrMom, arrMass2Prong[iDecay2P][0]); switch (iDecay2P) { case hf_cand_2prong::DecayType::D0ToPiK: registry.fill(HIST("hMassD0ToPiK"), mass2Prong); @@ -2361,7 +2357,7 @@ struct HfTrackIndexSkimCreator { } } if (TESTBIT(whichHypo2Prong[iDecay2P], 1)) { - auto mass2Prong = RecoDecay::m(arrMom, arrMass2Prong[iDecay2P][1]); + const auto mass2Prong = RecoDecay::m(arrMom, arrMass2Prong[iDecay2P][1]); if (iDecay2P == hf_cand_2prong::DecayType::D0ToPiK) { registry.fill(HIST("hMassD0ToPiK"), mass2Prong); } @@ -2397,7 +2393,7 @@ struct HfTrackIndexSkimCreator { // second loop over positive tracks for (auto trackIndexPos2 = trackIndexPos1 + 1; trackIndexPos2 != groupedTrackIndicesPos1.end(); ++trackIndexPos2) { - int isSelected3ProngCand = n3ProngBit; + uint isSelected3ProngCand = n3ProngBit; if (!TESTBIT(trackIndexPos2.isSelProng(), CandidateType::Cand3Prong)) { // continue immediately if (!config.debug) { continue; @@ -2414,7 +2410,7 @@ struct HfTrackIndexSkimCreator { } } - auto trackPos2 = trackIndexPos2.template track_as(); + const auto trackPos2 = trackIndexPos2.template track_as(); auto trackParVarPos2 = getTrackParCov(trackPos2); std::array dcaInfoPos2{trackPos2.dcaXY(), trackPos2.dcaZ()}; @@ -2435,8 +2431,8 @@ struct HfTrackIndexSkimCreator { } // 3-prong preselections - int8_t isIdentifiedPidTrackPos1 = trackIndexPos1.isIdentifiedPid(); - int8_t isIdentifiedPidTrackPos2 = trackIndexPos2.isIdentifiedPid(); + const auto isIdentifiedPidTrackPos1 = trackIndexPos1.isIdentifiedPid(); + const auto isIdentifiedPidTrackPos2 = trackIndexPos2.isIdentifiedPid(); applyPreselection3Prong(pVecTrackPos1, pVecTrackNeg1, pVecTrackPos2, isIdentifiedPidTrackPos1, isIdentifiedPidTrackPos2, cutStatus3Prong, whichHypo3Prong, isSelected3ProngCand); if (!config.debug && isSelected3ProngCand == 0) { continue; @@ -2549,20 +2545,20 @@ struct HfTrackIndexSkimCreator { std::array pvec0{}; std::array pvec1{}; std::array pvec2{}; - auto trackParVarPcaPos1 = df3.getTrack(0); - auto trackParVarPcaNeg1 = df3.getTrack(1); - auto trackParVarPcaPos2 = df3.getTrack(2); + const auto trackParVarPcaPos1 = df3.getTrack(0); + const auto trackParVarPcaNeg1 = df3.getTrack(1); + const auto trackParVarPcaPos2 = df3.getTrack(2); trackParVarPcaPos1.getPxPyPzGlo(pvec0); trackParVarPcaNeg1.getPxPyPzGlo(pvec1); trackParVarPcaPos2.getPxPyPzGlo(pvec2); - auto pVecCandProng3Pos = RecoDecay::pVec(pvec0, pvec1, pvec2); + const auto pVecCandProng3Pos = RecoDecay::pVec(pvec0, pvec1, pvec2); // 3-prong selections after secondary vertex applySelection3Prong(pVecCandProng3Pos, secondaryVertex3, pvRefitCoord3Prong2Pos1Neg, cutStatus3Prong, isSelected3ProngCand); std::array, kN3ProngDecays> mlScores3Prongs; if (config.applyMlForHfFilters) { - std::vector const inputFeatures{trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos2.getPt(), dcaInfoPos2[0], dcaInfoPos2[1]}; + const std::vector inputFeatures{trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos2.getPt(), dcaInfoPos2[0], dcaInfoPos2[1]}; std::vector inputFeaturesLcPid{}; if constexpr (usePidForHfFiltersBdt) { inputFeaturesLcPid.push_back(trackPos1.tpcNSigmaPr()); @@ -2611,7 +2607,7 @@ struct HfTrackIndexSkimCreator { for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { if (TESTBIT(isSelected3ProngCand, iDecay3P)) { if (TESTBIT(whichHypo3Prong[iDecay3P], 0)) { - auto mass3Prong = RecoDecay::m(arr3Mom, arrMass3Prong[iDecay3P][0]); + const auto mass3Prong = RecoDecay::m(arr3Mom, arrMass3Prong[iDecay3P][0]); switch (iDecay3P) { case hf_cand_3prong::DecayType::DplusToPiKPi: registry.fill(HIST("hMassDPlusToPiKPi"), mass3Prong); @@ -2628,7 +2624,7 @@ struct HfTrackIndexSkimCreator { } } if (TESTBIT(whichHypo3Prong[iDecay3P], 1)) { - auto mass3Prong = RecoDecay::m(arr3Mom, arrMass3Prong[iDecay3P][1]); + const auto mass3Prong = RecoDecay::m(arr3Mom, arrMass3Prong[iDecay3P][1]); switch (iDecay3P) { case hf_cand_3prong::DecayType::DsToKKPi: registry.fill(HIST("hMassDsToKKPi"), mass3Prong); @@ -2815,7 +2811,7 @@ struct HfTrackIndexSkimCreator { std::array, kN3ProngDecays> mlScores3Prongs{}; if (config.applyMlForHfFilters) { - std::vector const inputFeatures{trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg2.getPt(), dcaInfoNeg2[0], dcaInfoNeg2[1]}; + const std::vector inputFeatures{trackParVarPcaNeg1.getPt(), dcaInfoNeg1[0], dcaInfoNeg1[1], trackParVarPcaPos1.getPt(), dcaInfoPos1[0], dcaInfoPos1[1], trackParVarPcaNeg2.getPt(), dcaInfoNeg2[0], dcaInfoNeg2[1]}; std::vector inputFeaturesLcPid{}; if constexpr (usePidForHfFiltersBdt) { inputFeaturesLcPid.push_back(trackNeg1.tpcNSigmaPr()); @@ -2864,7 +2860,7 @@ struct HfTrackIndexSkimCreator { for (int iDecay3P = 0; iDecay3P < kN3ProngDecays; iDecay3P++) { if (TESTBIT(isSelected3ProngCand, iDecay3P)) { if (TESTBIT(whichHypo3Prong[iDecay3P], 0)) { - auto mass3Prong = RecoDecay::m(arr3Mom, arrMass3Prong[iDecay3P][0]); + const auto mass3Prong = RecoDecay::m(arr3Mom, arrMass3Prong[iDecay3P][0]); switch (iDecay3P) { case hf_cand_3prong::DecayType::DplusToPiKPi: registry.fill(HIST("hMassDPlusToPiKPi"), mass3Prong); @@ -2881,7 +2877,7 @@ struct HfTrackIndexSkimCreator { } } if (TESTBIT(whichHypo3Prong[iDecay3P], 1)) { - auto mass3Prong = RecoDecay::m(arr3Mom, arrMass3Prong[iDecay3P][1]); + const auto mass3Prong = RecoDecay::m(arr3Mom, arrMass3Prong[iDecay3P][1]); switch (iDecay3P) { case hf_cand_3prong::DecayType::DsToKKPi: registry.fill(HIST("hMassDsToKKPi"), mass3Prong); @@ -2978,7 +2974,7 @@ struct HfTrackIndexSkimCreator { } } - int const nTracks = 0; + const int nTracks = 0; // auto nTracks = trackIndicesPerCollision.lastIndex() - trackIndicesPerCollision.firstIndex(); // number of tracks passing 2 and 3 prong selection in this collision nCand2 = rowTrackIndexProng2.lastIndex() - nCand2; // number of 2-prong candidates in this collision nCand3 = rowTrackIndexProng3.lastIndex() - nCand3; // number of 3-prong candidates in this collision @@ -3160,13 +3156,13 @@ struct HfTrackIndexSkimCreatorCascades { } const auto thisCollId = collision.globalIndex(); - auto groupedBachTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); - auto groupedV0s = v0s.sliceBy(v0sPerCollision, thisCollId); + const auto groupedBachTrackIndices = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); + const auto groupedV0s = v0s.sliceBy(v0sPerCollision, thisCollId); // fist we loop over the bachelor candidate for (const auto& bachIdx : groupedBachTrackIndices) { - auto bach = bachIdx.track_as(); + const auto bach = bachIdx.track_as(); std::array pVecBach{bach.pVector()}; auto trackBach = getTrackParCov(bach); if (thisCollId != bach.collisionId()) { // this is not the "default" collision for this track, we have to re-propagate it @@ -3253,7 +3249,7 @@ struct HfTrackIndexSkimCreatorCascades { } // cascade candidate pT cut - auto ptCascCand = RecoDecay::pt(pVecBach, pVecV0); + const auto ptCascCand = RecoDecay::pt(pVecBach, pVecV0); if (ptCascCand < config.ptCascCandMin) { continue; } @@ -3401,9 +3397,9 @@ struct HfTrackIndexSkimCreatorLfCascades { runNumber = 0; if (config.fillHistograms) { - AxisSpec const ptAxis = {400, 0.0f, 20.0f, "it{p}_{T} (GeV/c)"}; - AxisSpec const massAxisXi = {200, 1.222f, 1.422f, "Inv. Mass (GeV/c^{2})"}; - AxisSpec const massAxisOmega = {200, 1.572f, 1.772f, "Inv. Mass (GeV/c^{2})"}; + const AxisSpec ptAxis = {400, 0.0f, 20.0f, "it{p}_{T} (GeV/c)"}; + const AxisSpec massAxisXi = {200, 1.222f, 1.422f, "Inv. Mass (GeV/c^{2})"}; + const AxisSpec massAxisOmega = {200, 1.572f, 1.772f, "Inv. Mass (GeV/c^{2})"}; registry.add("hCandidateCounter", "hCandidateCounter", {HistType::kTH1D, {{10, 0.0f, 10.0f}}}); @@ -3698,7 +3694,7 @@ struct HfTrackIndexSkimCreatorLfCascades { const float ptXic = RecoDecay::pt(pVecXi, pVecPion1XiHyp); const std::array arrMomToXi{pVecXi, pVecPion1XiHyp}; - auto mass2ProngXiHyp = RecoDecay::m(arrMomToXi, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::XiczeroOmegaczeroToXiPi]); + const auto mass2ProngXiHyp = RecoDecay::m(arrMomToXi, arrMass2Prong[hf_cand_casc_lf::DecayType2Prong::XiczeroOmegaczeroToXiPi]); if ((std::abs(casc.mXi() - MassXiMinus) < config.cascadeMassWindow) && (mass2ProngXiHyp >= config.massXiPiMin) && (mass2ProngXiHyp <= config.massXiPiMax)) { registry.fill(HIST("hRejpTStatusXicZeroOmegacZeroToXiPi"), 0); From 9660aecebf0b499909a369b92fc4749b39b067f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 21:38:22 +0200 Subject: [PATCH 09/14] Fix rejection mask type --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index fa2d6423533..3d418696852 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -1291,7 +1291,7 @@ struct HfTrackIndexSkimCreator { using FilteredTrackAssocSel = soa::Filtered>; // filter collisions - Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); + Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); // filter track indices Filter filterSelectTrackIds = ((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::Cand2Prong))) != 0u) || ((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::Cand3Prong))) != 0u) || ((aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::CandDstar))) != 0u); @@ -3092,7 +3092,7 @@ struct HfTrackIndexSkimCreatorCascades { using SelectedCollisions = soa::Filtered>; using FilteredTrackAssocSel = soa::Filtered>; - Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); + Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); Filter filterSelectTrackIds = (aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::CandV0bachelor))) != 0u && (config.applyProtonPid == false || (aod::hf_sel_track::isIdentifiedPid & static_cast(BIT(ChannelsProtonPid::LcToPK0S))) != 0u); Preslice trackIndicesPerCollision = aod::track_association::collisionId; @@ -3361,7 +3361,7 @@ struct HfTrackIndexSkimCreatorLfCascades { using CascFull = soa::Join; using V0Full = soa::Join; - Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); + Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast(0)); Filter filterSelectTrackIds = (aod::hf_sel_track::isSelProng & static_cast(BIT(CandidateType::CandCascadeBachelor))) != 0u; Preslice tracksPerCollision = aod::track::collisionId; // needed for PV refit From ec1699a2ad96ead881147d180780d039e9775f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 22:32:03 +0200 Subject: [PATCH 10/14] Pass by const& --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index 3d418696852..dca9db28bc5 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -1930,7 +1930,7 @@ struct HfTrackIndexSkimCreator { void performPvRefitCandProngs(SelectedCollisions::iterator const& collision, aod::BCsWithTimestamps const&, std::vector vecPvContributorGlobId, - std::vector vecPvContributorTrackParCov, + std::vector const& vecPvContributorTrackParCov, std::vector vecCandPvContributorGlobId, std::array& pvCoord, std::array& pvCovMatrix) From 2260a0990bd8d884506e99582e820fcc193ce44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 22:51:57 +0200 Subject: [PATCH 11/14] Remove default template arguments. Pass by const&. --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index dca9db28bc5..d638794f52d 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -1804,12 +1804,12 @@ struct HfTrackIndexSkimCreator { } /// Method to perform ML selections for 2-prong candidates after the rectangular selections + /// \tparam usePidForHfFiltersBdt is the flag to determine whether to use also the PID features for the Lc BDT /// \param featuresCand is the vector with the candidate features /// \param featuresCandPid is the vector with the candidate PID features /// \param outputScores is the array of vectors with the output scores to be filled /// \param isSelected ia s bitmap with selection outcome - /// \param usePidForHfFiltersBdt is the flag to determine whether to use also the PID features for the Lc BDT - template + template void applyMlSelectionForHfFilters3Prong(std::vector featuresCand, std::vector featuresCandPid, std::array, kN3ProngDecays>& outputScores, auto& isSelected) { if (isSelected == 0) { @@ -1929,7 +1929,7 @@ struct HfTrackIndexSkimCreator { /// \param pvCovMatrix is a vector where to store the covariance matrix values of refitted PV void performPvRefitCandProngs(SelectedCollisions::iterator const& collision, aod::BCsWithTimestamps const&, - std::vector vecPvContributorGlobId, + std::vector const& vecPvContributorGlobId, std::vector const& vecPvContributorTrackParCov, std::vector vecCandPvContributorGlobId, std::array& pvCoord, @@ -2055,7 +2055,7 @@ struct HfTrackIndexSkimCreator { return; } /// end of performPvRefitCandProngs function - template + template void run2And3Prongs(SelectedCollisions const& collisions, aod::BCsWithTimestamps const& bcWithTimeStamps, FilteredTrackAssocSel const&, @@ -2832,8 +2832,8 @@ struct HfTrackIndexSkimCreator { if (config.applyMlForHfFilters) { rowTrackIndexMlScoreProng3(mlScores3Prongs[0], mlScores3Prongs[1], mlScores3Prongs[2], mlScores3Prongs[3]); } - // fill table row of coordinates of PV refit if constexpr (doPvRefit) { + // fill table row of coordinates of PV refit rowProng3PVrefit(pvRefitCoord3Prong1Pos2Neg[0], pvRefitCoord3Prong1Pos2Neg[1], pvRefitCoord3Prong1Pos2Neg[2], pvRefitCovMatrix3Prong1Pos2Neg[0], pvRefitCovMatrix3Prong1Pos2Neg[1], pvRefitCovMatrix3Prong1Pos2Neg[2], pvRefitCovMatrix3Prong1Pos2Neg[3], pvRefitCovMatrix3Prong1Pos2Neg[4], pvRefitCovMatrix3Prong1Pos2Neg[5]); } @@ -3001,7 +3001,7 @@ struct HfTrackIndexSkimCreator { FilteredTrackAssocSel const& trackIndices, TracksWithPVRefitAndDCA const& tracks) { - run2And3Prongs(collisions, bcWithTimeStamps, trackIndices, tracks); + run2And3Prongs(collisions, bcWithTimeStamps, trackIndices, tracks); } PROCESS_SWITCH(HfTrackIndexSkimCreator, process2And3ProngsWithPvRefit, "Process 2-prong and 3-prong skim with PV refit", false); @@ -3011,7 +3011,7 @@ struct HfTrackIndexSkimCreator { FilteredTrackAssocSel const& trackIndices, aod::TracksWCovDcaExtra const& tracks) { - run2And3Prongs(collisions, bcWithTimeStamps, trackIndices, tracks); + run2And3Prongs(collisions, bcWithTimeStamps, trackIndices, tracks); } PROCESS_SWITCH(HfTrackIndexSkimCreator, process2And3ProngsNoPvRefit, "Process 2-prong and 3-prong skim without PV refit", true); From 0b39cbfc105c7a0e534f166639fadca62120a644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Wed, 10 Sep 2025 22:59:07 +0200 Subject: [PATCH 12/14] Remove useless argument --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index d638794f52d..d2ef2e102ae 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -165,7 +165,7 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; if constexpr (applyUpcSel) { - rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc( + rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc( collision, centrality, ccdb, registry, bcs); } else { rejectionMask = hfEvSel.getHfCollisionRejectionMask( From 9e8fc286b37973e042bba6789647a65032ea90a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:48:43 +0200 Subject: [PATCH 13/14] Define default etaMin --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index d2ef2e102ae..15e892ab42a 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -77,8 +77,9 @@ #include #include // std::distance #include -#include // std::string -#include // std::vector +#include // std::string +#include // std::forward +#include // std::vector using namespace o2; using namespace o2::analysis; @@ -260,6 +261,7 @@ struct HfTrackIndexSkimCreatorTagSelTracks { Produces tabPvRefitTrack; struct : ConfigurableGroup { + double etaMinDefault{-99999.}; Configurable isRun2{"isRun2", false, "enable Run 2 or Run 3 GRP objects for magnetic field"}; Configurable doPvRefit{"doPvRefit", false, "do PV refit excluding the considered track"}; Configurable fillHistograms{"fillHistograms", true, "fill histograms"}; @@ -275,29 +277,29 @@ struct HfTrackIndexSkimCreatorTagSelTracks { // 2-prong cuts Configurable ptMinTrack2Prong{"ptMinTrack2Prong", -1., "min. track pT for 2 prong candidate"}; Configurable> cutsTrack2Prong{"cutsTrack2Prong", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 2-prong candidates"}; - Configurable etaMinTrack2Prong{"etaMinTrack2Prong", -99999., "min. pseudorapidity for 2 prong candidate"}; + Configurable etaMinTrack2Prong{"etaMinTrack2Prong", std::forward(etaMinDefault), "min. pseudorapidity for 2 prong candidate"}; Configurable etaMaxTrack2Prong{"etaMaxTrack2Prong", 4., "max. pseudorapidity for 2 prong candidate"}; // 3-prong cuts Configurable ptMinTrack3Prong{"ptMinTrack3Prong", -1., "min. track pT for 3 prong candidate"}; Configurable> cutsTrack3Prong{"cutsTrack3Prong", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for 3-prong candidates"}; - Configurable etaMinTrack3Prong{"etaMinTrack3Prong", -99999., "min. pseudorapidity for 3 prong candidate"}; + Configurable etaMinTrack3Prong{"etaMinTrack3Prong", std::forward(etaMinDefault), "min. pseudorapidity for 3 prong candidate"}; Configurable etaMaxTrack3Prong{"etaMaxTrack3Prong", 4., "max. pseudorapidity for 3 prong candidate"}; // bachelor cuts (V0 + bachelor decays) Configurable ptMinTrackBach{"ptMinTrackBach", 0.3, "min. track pT for bachelor in cascade candidate"}; // 0.5 for PbPb 2015? Configurable> cutsTrackBach{"cutsTrackBach", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for the bachelor of V0-bachelor candidates"}; - Configurable etaMinTrackBach{"etaMinTrackBach", -99999., "min. pseudorapidity for bachelor in cascade candidate"}; + Configurable etaMinTrackBach{"etaMinTrackBach", std::forward(etaMinDefault), "min. pseudorapidity for bachelor in cascade candidate"}; Configurable etaMaxTrackBach{"etaMaxTrackBach", 0.8, "max. pseudorapidity for bachelor in cascade candidate"}; // bachelor cuts (cascade + bachelor decays) Configurable ptMinTrackBachLfCasc{"ptMinTrackBachLfCasc", 0.1, "min. track pT for bachelor in cascade + bachelor decays"}; // 0.5 for PbPb 2015? Configurable> cutsTrackBachLfCasc{"cutsTrackBachLfCasc", {hf_cuts_single_track::CutsTrack[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for the bachelor in cascade + bachelor decays"}; - Configurable etaMinTrackBachLfCasc{"etaMinTrackBachLfCasc", -99999., "min. pseudorapidity for bachelor in cascade + bachelor decays"}; + Configurable etaMinTrackBachLfCasc{"etaMinTrackBachLfCasc", std::forward(etaMinDefault), "min. pseudorapidity for bachelor in cascade + bachelor decays"}; Configurable etaMaxTrackBachLfCasc{"etaMaxTrackBachLfCasc", 1.1, "max. pseudorapidity for bachelor in cascade + bachelor decays"}; Configurable useIsGlobalTrackForBachLfCasc{"useIsGlobalTrackForBachLfCasc", false, "check isGlobalTrack status for bachelor in cascade + bachelor decays"}; Configurable useIsGlobalTrackWoDCAForBachLfCasc{"useIsGlobalTrackWoDCAForBachLfCasc", false, "check isGlobalTrackWoDCA status for bachelor in cascade + bachelor decays"}; Configurable useIsQualityTrackITSForBachLfCasc{"useIsQualityTrackITSForBachLfCasc", true, "check isQualityTrackITS status for bachelor in cascade + bachelor decays"}; // soft pion cuts for D* Configurable ptMinSoftPionForDstar{"ptMinSoftPionForDstar", 0.05, "min. track pT for soft pion in D* candidate"}; - Configurable etaMinSoftPionForDstar{"etaMinSoftPionForDstar", -99999., "min. pseudorapidity for soft pion in D* candidate"}; + Configurable etaMinSoftPionForDstar{"etaMinSoftPionForDstar", std::forward(etaMinDefault), "min. pseudorapidity for soft pion in D* candidate"}; Configurable etaMaxSoftPionForDstar{"etaMaxSoftPionForDstar", 0.8, "max. pseudorapidity for soft pion in D* candidate"}; Configurable> cutsTrackDstar{"cutsTrackDstar", {hf_cuts_single_track::CutsTrackPrimary[0], hf_cuts_single_track::NBinsPtTrack, hf_cuts_single_track::NCutVarsTrack, hf_cuts_single_track::labelsPtTrack, hf_cuts_single_track::labelsCutVarTrack}, "Single-track selections per pT bin for the soft pion of D* candidates"}; Configurable useIsGlobalTrackForSoftPion{"useIsGlobalTrackForSoftPion", false, "check isGlobalTrack status for soft pion tracks"}; @@ -357,19 +359,19 @@ struct HfTrackIndexSkimCreatorTagSelTracks { cutsSingleTrack = {config.cutsTrack2Prong, config.cutsTrack3Prong, config.cutsTrackBach, config.cutsTrackDstar, config.cutsTrackBachLfCasc}; - if (config.etaMinTrack2Prong == -99999.) { + if (config.etaMinTrack2Prong == config.etaMinDefault) { config.etaMinTrack2Prong.value = -config.etaMaxTrack2Prong; } - if (config.etaMinTrack3Prong == -99999.) { + if (config.etaMinTrack3Prong == config.etaMinDefault) { config.etaMinTrack3Prong.value = -config.etaMaxTrack3Prong; } - if (config.etaMinTrackBach == -99999.) { + if (config.etaMinTrackBach == config.etaMinDefault) { config.etaMinTrackBach.value = -config.etaMaxTrackBach; } - if (config.etaMinSoftPionForDstar == -99999.) { + if (config.etaMinSoftPionForDstar == config.etaMinDefault) { config.etaMinSoftPionForDstar.value = -config.etaMaxSoftPionForDstar; } - if (config.etaMinTrackBachLfCasc == -99999.) { + if (config.etaMinTrackBachLfCasc == config.etaMinDefault) { config.etaMinTrackBachLfCasc.value = -config.etaMaxTrackBachLfCasc; } @@ -3049,6 +3051,7 @@ struct HfTrackIndexSkimCreatorCascades { Produces rowTrackIndexCasc; struct : ConfigurableGroup { + double etaMinDefault{-99999.}; Configurable isRun2{"isRun2", false, "enable Run 2 or Run 3 GRP objects for magnetic field"}; Configurable fillHistograms{"fillHistograms", true, "fill histograms"}; // vertexing @@ -3061,7 +3064,7 @@ struct HfTrackIndexSkimCreatorCascades { Configurable useAbsDCA{"useAbsDCA", true, "Minimise abs. distance rather than chi2"}; Configurable useWeightedFinalPCA{"useWeightedFinalPCA", true, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"}; // track cuts for V0 daughters - Configurable etaMinV0Daugh{"etaMinV0Daugh", -99999., "min. pseudorapidity V0 daughters"}; + Configurable etaMinV0Daugh{"etaMinV0Daugh", std::forward(etaMinDefault), "min. pseudorapidity V0 daughters"}; Configurable etaMaxV0Daugh{"etaMaxV0Daugh", 1.1, "max. pseudorapidity V0 daughters"}; Configurable ptMinV0Daugh{"ptMinV0Daugh", 0.05, "min. pT V0 daughters"}; // v0 cuts @@ -3107,7 +3110,7 @@ struct HfTrackIndexSkimCreatorCascades { return; } - if (config.etaMinV0Daugh == -99999.) { + if (config.etaMinV0Daugh == config.etaMinDefault) { config.etaMinV0Daugh.value = -config.etaMaxV0Daugh; } From 5d9beacdc9c80b55c46c61a434d64218990a4c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Tue, 16 Sep 2025 18:17:08 +0200 Subject: [PATCH 14/14] Fix magic-number errors --- PWGHF/TableProducer/trackIndexSkimCreator.cxx | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index 15e892ab42a..dcd13a07c01 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -2252,7 +2252,7 @@ struct HfTrackIndexSkimCreator { nCandContr--; isTrackSecondContr = false; } - if (nCandContr == 2) { + if (nCandContr == 2) { // o2-linter: disable="magic-number" (see comment below) /// Both the daughter tracks were used for the original PV refit, let's refit it after excluding them if (config.debugPvRefit) { LOG(info) << "### [2 Prong] Calling performPvRefitCandProngs for HF 2 prong candidate"; @@ -2377,7 +2377,7 @@ struct HfTrackIndexSkimCreator { } // if the cut on the decay length of 3-prongs computed with the first two tracks is enabled and the vertex was not computed for the D0, we compute it now - if (config.do3Prong && is2ProngCandidateGoodFor3Prong && (config.minTwoTrackDecayLengthFor3Prongs > 0.f || config.maxTwoTrackChi2PcaFor3Prongs < 1.e9f) && nVtxFrom2ProngFitter == 0) { + if (config.do3Prong && is2ProngCandidateGoodFor3Prong && (config.minTwoTrackDecayLengthFor3Prongs > 0.f || config.maxTwoTrackChi2PcaFor3Prongs < 1.e9f) && nVtxFrom2ProngFitter == 0) { // o2-linter: disable="magic-number" (default maxTwoTrackChi2PcaFor3Prongs is 1.e10) try { nVtxFrom2ProngFitter = df2.process(trackParVarPos1, trackParVarNeg1); } catch (...) { @@ -2492,7 +2492,7 @@ struct HfTrackIndexSkimCreator { vecCandPvContributorGlobId.push_back(trackPos2.globalIndex()); } - if (nCandContr == 3 || nCandContr == 2) { + if (nCandContr == 3 || nCandContr == 2) { // o2-linter: disable="magic-number" (see comment below) /// At least two of the daughter tracks were used for the original PV refit, let's refit it after excluding them if (config.debugPvRefit) { LOG(info) << "### [3 prong] Calling performPvRefitCandProngs for HF 3 prong candidate, removing " << nCandContr << " daughters"; @@ -2744,7 +2744,7 @@ struct HfTrackIndexSkimCreator { vecCandPvContributorGlobId.push_back(trackNeg2.globalIndex()); } - if (nCandContr == 3 || nCandContr == 2) { + if (nCandContr == 3 || nCandContr == 2) { // o2-linter: disable="magic-number" (see comment below) /// At least two of the daughter tracks were used for the original PV refit, let's refit it after excluding them if (config.debugPvRefit) { LOG(info) << "### [3 prong] Calling performPvRefitCandProngs for HF 3 prong candidate, removing " << nCandContr << " daughters"; @@ -2898,7 +2898,8 @@ struct HfTrackIndexSkimCreator { } } - if (config.doDstar && TESTBIT(isSelected2ProngCand, hf_cand_2prong::DecayType::D0ToPiK) && (pt2Prong + config.ptTolerance) * 1.2 > config.binsPtDstarToD0Pi->at(0) && whichHypo2Prong[kN2ProngDecays] != 0) { // if D* enabled and pt of the D0 is larger than the minimum of the D* one within 20% (D* and D0 momenta are very similar, always within 20% according to PYTHIA8) + if (config.doDstar && TESTBIT(isSelected2ProngCand, hf_cand_2prong::DecayType::D0ToPiK) && (pt2Prong + config.ptTolerance) * 1.2 > config.binsPtDstarToD0Pi->at(0) && whichHypo2Prong[kN2ProngDecays] != 0) { // o2-linter: disable="magic-number" (see comment below) + // if D* enabled and pt of the D0 is larger than the minimum of the D* one within 20% (D* and D0 momenta are very similar, always within 20% according to PYTHIA8) // second loop over positive tracks if (TESTBIT(whichHypo2Prong[kN2ProngDecays], 0) && (!config.applyKaonPidIn3Prongs || TESTBIT(trackIndexNeg1.isIdentifiedPid(), ChannelKaonPid))) { // only for D0 candidates; moreover if kaon PID enabled, apply to the negative track auto groupedTrackIndicesSoftPionsPos = positiveSoftPions->sliceByCached(aod::track::collisionId, collision.globalIndex(), cache); @@ -3227,8 +3228,9 @@ struct HfTrackIndexSkimCreatorCascades { const std::array vertexV0{v0.x(), v0.y(), v0.z()}; // we build the neutral track to then build the cascade std::array covV{}; - constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component - for (int i = 0; i < 6; i++) { + constexpr std::size_t NIndicesMom{6u}; + constexpr std::size_t MomInd[NIndicesMom] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (std::size_t i = 0; i < NIndicesMom; i++) { covV[MomInd[i]] = v0.momentumCovMat()[i]; covV[i] = v0.positionCovMat()[i]; } @@ -3263,7 +3265,7 @@ struct HfTrackIndexSkimCreatorCascades { std::array posCasc{0., 0., 0.}; if (config.useDCAFitter) { const auto& cascVtx = df2.getPCACandidate(); - for (int iCoord{0}; iCoord < 3; ++iCoord) { + for (int iCoord{0}; iCoord < 3; ++iCoord) { // o2-linter: disable="magic-number" ({x, y, z} coordinates}) posCasc[iCoord] = cascVtx[iCoord]; } } @@ -3623,8 +3625,9 @@ struct HfTrackIndexSkimCreatorLfCascades { const std::array vertexCasc{casc.x(), casc.y(), casc.z()}; const std::array pVecCasc{casc.px(), casc.py(), casc.pz()}; std::array covCasc{}; - constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component - for (int i = 0; i < 6; i++) { + constexpr std::size_t NIndicesMom{6u}; + constexpr std::size_t MomInd[NIndicesMom] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component + for (std::size_t i = 0; i < NIndicesMom; i++) { covCasc[MomInd[i]] = casc.momentumCovMat()[i]; covCasc[i] = casc.positionCovMat()[i]; }