diff --git a/PWGHF/Core/CentralityEstimation.h b/PWGHF/Core/CentralityEstimation.h index bd1746c4604..fbe18d28d89 100644 --- a/PWGHF/Core/CentralityEstimation.h +++ b/PWGHF/Core/CentralityEstimation.h @@ -59,8 +59,8 @@ concept hasNTracksPVCent = requires(T collision) { /// Evaluate centrality/multiplicity percentile using FT0A estimator /// \param candidate is candidate /// \return centrality/multiplicity percentile of the collision -template -float getCentralityColl(const Coll& collision) +template +float getCentralityColl(const TCollision& collision) { return collision.centFT0A(); } @@ -68,8 +68,8 @@ float getCentralityColl(const Coll& collision) /// Evaluate centrality/multiplicity percentile using FT0C estimator /// \param candidate is candidate /// \return centrality/multiplicity percentile of the collision -template -float getCentralityColl(const Coll& collision) +template +float getCentralityColl(const TCollision& collision) { return collision.centFT0C(); } @@ -77,8 +77,8 @@ float getCentralityColl(const Coll& collision) /// Evaluate centrality/multiplicity percentile using FT0M estimator /// \param candidate is candidate /// \return centrality/multiplicity percentile of the collision -template -float getCentralityColl(const Coll& collision) +template +float getCentralityColl(const TCollision& collision) { return collision.centFT0M(); } @@ -86,8 +86,8 @@ float getCentralityColl(const Coll& collision) /// Evaluate centrality/multiplicity percentile using FV0A estimator /// \param candidate is candidate /// \return centrality/multiplicity percentile of the collision -template -float getCentralityColl(const Coll& collision) +template +float getCentralityColl(const TCollision& collision) { return collision.centFV0A(); } @@ -95,8 +95,8 @@ float getCentralityColl(const Coll& collision) /// Evaluate centrality/multiplicity percentile using NTracksPV estimator /// \param candidate is candidate /// \return centrality/multiplicity percentile of the collision -template -float getCentralityColl(const Coll& collision) +template +float getCentralityColl(const TCollision& collision) { return collision.centNTPV(); } @@ -104,8 +104,8 @@ float getCentralityColl(const Coll& collision) /// Default case if no centrality/multiplicity estimator is provided /// \param candidate is candidate /// \return dummy value for centrality/multiplicity percentile of the collision -template -float getCentralityColl(const Coll&) +template +float getCentralityColl(const TCollision&) { return 105.0f; } @@ -114,36 +114,36 @@ float getCentralityColl(const Coll&) /// \param collision is the collision with the centrality information /// \param centEstimator integer to select the centrality estimator /// \return collision centrality -template -float getCentralityColl(const Coll& collision, int centEstimator) +template +float getCentralityColl(const TCollision& collision, const int centEstimator) { switch (centEstimator) { case CentralityEstimator::FT0A: - if constexpr (hasFT0ACent) { + if constexpr (hasFT0ACent) { return collision.centFT0A(); } LOG(fatal) << "Collision does not have centFT0A()."; break; case CentralityEstimator::FT0C: - if constexpr (hasFT0CCent) { + if constexpr (hasFT0CCent) { return collision.centFT0C(); } LOG(fatal) << "Collision does not have centFT0C()."; break; case CentralityEstimator::FT0M: - if constexpr (hasFT0MCent) { + if constexpr (hasFT0MCent) { return collision.centFT0M(); } LOG(fatal) << "Collision does not have centFT0M()."; break; case CentralityEstimator::FV0A: - if constexpr (hasFV0ACent) { + if constexpr (hasFV0ACent) { return collision.centFV0A(); } LOG(fatal) << "Collision does not have centFV0A()."; break; default: - LOG(fatal) << "Centrality estimator not valid. Possible values are V0A, T0M, T0A, T0C."; + LOG(fatal) << "Centrality estimator not valid. See CentralityEstimator for valid values."; break; } return -999.f; @@ -152,13 +152,14 @@ float getCentralityColl(const Coll& collision, int centEstimator) /// \brief Function to get MC collision centrality /// \param collSlice collection of reconstructed collisions associated to a generated one /// \return generated MC collision centrality -template -float getCentralityGenColl(CCs const& collSlice) +template +float getCentralityGenColl(TCollisions const& collSlice) { - float centrality{-1}; - float multiplicity{0.f}; + using TMult = uint16_t; // type of numContrib + float centrality{-1.f}; + TMult multiplicity{}; for (const auto& collision : collSlice) { - float collMult = collision.numContrib(); + const TMult collMult = collision.numContrib(); if (collMult > multiplicity) { centrality = getCentralityColl(collision); multiplicity = collMult; @@ -171,13 +172,14 @@ float getCentralityGenColl(CCs const& collSlice) /// \param collSlice collection of reconstructed collisions associated to a generated one /// \param centEstimator integer to select the centrality estimator /// \return generated MC collision centrality -template -float getCentralityGenColl(CCs const& collSlice, int centEstimator) +template +float getCentralityGenColl(TCollisions const& collSlice, const int centEstimator) { - float centrality{-1}; - float multiplicity{0.f}; + using TMult = uint16_t; // type of numContrib + float centrality{-1.f}; + TMult multiplicity{}; for (const auto& collision : collSlice) { - float collMult = collision.numContrib(); + const TMult collMult = collision.numContrib(); if (collMult > multiplicity) { centrality = getCentralityColl(collision, centEstimator); multiplicity = collMult; diff --git a/PWGHF/Core/DecayChannels.h b/PWGHF/Core/DecayChannels.h index 0398afed1c2..0c0392d99e2 100644 --- a/PWGHF/Core/DecayChannels.h +++ b/PWGHF/Core/DecayChannels.h @@ -30,10 +30,12 @@ namespace o2::hf_decay // - HF cascades to LF cascades (Ωc0/Ξc0 → Ξ+ π−, Ξc+ → Ξ+ π− π+) // - Σc +using HfDecayChannel = int8_t; + namespace hf_cand_2prong { /// @brief 2-prong candidates: main channels -enum DecayChannelMain : int8_t { +enum DecayChannelMain : HfDecayChannel { // D0 D0ToPiK = 1, // π+ K− D0ToPiKPi0 = 2, // π+ K− π0 @@ -47,7 +49,7 @@ enum DecayChannelMain : int8_t { NChannelsMain = JpsiToMuMu // last channel }; /// @brief 2-prong candidates: resonant channels -enum DecayChannelResonant : int8_t { +enum DecayChannelResonant : HfDecayChannel { // D0 D0ToRhoplusPi = 1, // ρ+ π− D0ToRhoplusK = 2, // ρ+ K− @@ -61,7 +63,7 @@ enum DecayChannelResonant : int8_t { namespace hf_cand_3prong { /// @brief 3-prong candidates: main channels -enum DecayChannelMain : int8_t { +enum DecayChannelMain : HfDecayChannel { // D+ DplusToPiKPi = 1, // π+ K− π+ DplusToPiKPiPi0 = 2, // π+ K− π+ π0 @@ -94,7 +96,7 @@ enum DecayChannelMain : int8_t { NChannelsMain = XicToSPiPi // last channel }; /// @brief 3-prong candidates: resonant channels -enum DecayChannelResonant : int8_t { +enum DecayChannelResonant : HfDecayChannel { // D+ DplusToPhiPi = 1, // φ π+ DplusToKstar0K = 2, // anti-K*0 K+ @@ -136,7 +138,7 @@ enum DecayChannelResonant : int8_t { namespace hf_cand_dstar { /// @brief D*+ candidates: main channels -enum DecayChannelMain : int8_t { +enum DecayChannelMain : HfDecayChannel { // D*+ DstarToPiKPi = 1, // π+ K− π+ (from [(D0 → π+ K−) π+]) DstarToPiKPiPi0 = 2, // π+ K− π+ π0 (from [(D0 → π+ K− π0) π+] or [(D+ → π+ K− π+) π0]) @@ -148,7 +150,7 @@ enum DecayChannelMain : int8_t { namespace hf_cand_beauty { /// @brief beauty candidates: main channels -enum DecayChannelMain : int8_t { +enum DecayChannelMain : HfDecayChannel { // B0 B0ToDminusPi = 1, // D− π+ B0ToDminusPiPi0 = 2, // D− π+ π0 @@ -176,7 +178,7 @@ enum DecayChannelMain : int8_t { NChannelsMain = B0ToDsPi // last channel }; /// @brief beauty candidates: resonant channels -enum DecayChannelResonant : int8_t { +enum DecayChannelResonant : HfDecayChannel { // B0 B0ToDminusRhoplus = 1, // D− ρ+ B0ToDstarminusPi = 2, // D*− π+ @@ -195,7 +197,7 @@ enum DecayChannelResonant : int8_t { NChannelsResonant = BplusToDstar0Pi // last channel }; /// @brief beauty candidates: beauty to J/ψ decay channels -enum DecayChannelToJpsiMain : int8_t { +enum DecayChannelToJpsiMain : HfDecayChannel { // B0 B0ToJpsiPiK = 1, // J/ψ π− K+ // Bs0 @@ -210,7 +212,7 @@ enum DecayChannelToJpsiMain : int8_t { NChannelsToJpsiMain = BcToJpsiPi // last channel }; /// @brief beauty candidates: beauty to J/ψ resonant decay channels -enum DecayChannelToJpsiResonant : int8_t { +enum DecayChannelToJpsiResonant : HfDecayChannel { // B0 B0ToJpsiKstar0 = 1, // J/ψ K*0(892) // Bs0 @@ -223,7 +225,7 @@ enum DecayChannelToJpsiResonant : int8_t { namespace hf_cand_reso { /// @brief resonance candidates: main channels -enum DecayChannelMain : int8_t { +enum DecayChannelMain : HfDecayChannel { // D1(2420)0 D1zeroToDstarPi = 1, // D*+ π- // D2*(2460)0 diff --git a/PWGHF/D2H/DataModel/ReducedDataModel.h b/PWGHF/D2H/DataModel/ReducedDataModel.h index 06b219be522..ff75b8187df 100644 --- a/PWGHF/D2H/DataModel/ReducedDataModel.h +++ b/PWGHF/D2H/DataModel/ReducedDataModel.h @@ -50,8 +50,8 @@ namespace aod { namespace hf_reduced_collision { -DECLARE_SOA_COLUMN(Bz, bz, float); //! Magnetic field in z-direction -DECLARE_SOA_COLUMN(HfCollisionRejectionMap, hfCollisionRejectionMap, uint32_t); //! Bitmask with failed selection criteria +DECLARE_SOA_COLUMN(Bz, bz, float); //! Magnetic field in z-direction +DECLARE_SOA_COLUMN(HfCollisionRejectionMap, hfCollisionRejectionMap, o2::hf_evsel::HfCollisionRejectionMask); //! Bitmask with failed selection criteria // keep track of the number of studied events (for normalization purposes) DECLARE_SOA_COLUMN(OriginalCollisionCount, originalCollisionCount, int); //! Size of COLLISION table processed DECLARE_SOA_COLUMN(ZvtxSelectedCollisionCount, zvtxSelectedCollisionCount, int); //! Number of COLLISIONS with |zvtx| < zvtxMax @@ -1186,7 +1186,7 @@ DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! DECLARE_SOA_COLUMN(ItsNClsSoftPi, itsNClsSoftPi, int); //! minimum value of number of ITS clusters for the decay daughter tracks DECLARE_SOA_COLUMN(TpcNClsCrossedRowsSoftPi, tpcNClsCrossedRowsSoftPi, int); //! minimum value of number of TPC crossed rows for the decay daughter tracks DECLARE_SOA_COLUMN(TpcChi2NClSoftPi, tpcChi2NClSoftPi, float); //! maximum value of TPC chi2 for the decay daughter tracks -DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! +DECLARE_SOA_DYNAMIC_COLUMN(Px, px, //! [](float pxProng0, float pxProng1, float pxProng2) -> float { return 1.f * pxProng0 + 1.f * pxProng1 + 1.f * pxProng2; }); DECLARE_SOA_DYNAMIC_COLUMN(Py, py, //! [](float pyProng0, float pyProng1, float pyProng2) -> float { return 1.f * pyProng0 + 1.f * pyProng1 + 1.f * pyProng2; }); @@ -1398,16 +1398,16 @@ DECLARE_SOA_COLUMN(InvMassProng1, invMassProng1, float); //! Invariant Mass of V DECLARE_SOA_COLUMN(Sign, sign, int8_t); //! Sign of the Resonance candidate DECLARE_SOA_COLUMN(IsWrongSign, isWrongSign, int8_t); //! Flag for wrong sign of the Resonance candidate, 1 = wrong sign, 0 = right sign -DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // flag for resonance decay channel classification reconstruction level -DECLARE_SOA_COLUMN(FlagMcMatchRecD, flagMcMatchRecD, int8_t); // flag for D meson bachelor decay channel classification reconstruction level -DECLARE_SOA_COLUMN(FlagMcMatchChanD, flagMcMatchChanD, int8_t); // flag for D meson resonant channel classification reconstruction level -DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // flag for decay channel classification generator level -DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, uint16_t); // debug flag for mis-association at reconstruction level -DECLARE_SOA_COLUMN(Origin, origin, int8_t); // Flag for origin of MC particle 1=promt, 2=FD -DECLARE_SOA_COLUMN(SignD0, signD0, int8_t); // Sign of the D0 in the channels with D* -> D0 pi, needed in case of non-matched D* -DECLARE_SOA_COLUMN(PtGen, ptGen, float); // Pt at generation level in GeV/c -DECLARE_SOA_COLUMN(InvMassGen, invMassGen, float); //! Invariant mass at generation level in GeV/c2 -DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! +DECLARE_SOA_COLUMN(FlagMcMatchRec, flagMcMatchRec, int8_t); // flag for resonance decay channel classification reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchRecD, flagMcMatchRecD, int8_t); // flag for D meson bachelor decay channel classification reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchChanD, flagMcMatchChanD, int8_t); // flag for D meson resonant channel classification reconstruction level +DECLARE_SOA_COLUMN(FlagMcMatchGen, flagMcMatchGen, int8_t); // flag for decay channel classification generator level +DECLARE_SOA_COLUMN(DebugMcRec, debugMcRec, uint16_t); // debug flag for mis-association at reconstruction level +DECLARE_SOA_COLUMN(Origin, origin, int8_t); // Flag for origin of MC particle 1=promt, 2=FD +DECLARE_SOA_COLUMN(SignD0, signD0, int8_t); // Sign of the D0 in the channels with D* -> D0 pi, needed in case of non-matched D* +DECLARE_SOA_COLUMN(PtGen, ptGen, float); // Pt at generation level in GeV/c +DECLARE_SOA_COLUMN(InvMassGen, invMassGen, float); //! Invariant mass at generation level in GeV/c2 +DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, //! [](float pxProng0, float pxProng1, float pyProng0, float pyProng1) -> float { return RecoDecay::pt((1.f * pxProng0 + 1.f * pxProng1), (1.f * pyProng0 + 1.f * pyProng1)); }); DECLARE_SOA_DYNAMIC_COLUMN(PtProng0, ptProng0, //! [](float pxProng0, float pyProng0) -> float { return RecoDecay::pt(pxProng0, pyProng0); }); diff --git a/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx index 0b73b385893..c382c180cf1 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx @@ -1021,7 +1021,7 @@ struct HfDataCreatorCharmHadPiReduced { { registry.fill(HIST("hEvents"), 1 + Event::Processed); float centrality = -1.f; - auto hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + const auto hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (configs.skipRejectedCollisions && hfRejMap != 0) { return; } @@ -1487,15 +1487,16 @@ struct HfDataCreatorCharmHadPiReduced { // Check event selection float centDummy{-1.f}, centFT0C{-1.f}, centFT0M{-1.f}; const auto collSlice = collisions.sliceBy(preslices.colPerMcCollision, mcCollision.globalIndex()); - auto hfRejMap = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centDummy); + const auto hfRejMap = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centDummy); if (configs.skipRejectedCollisions && hfRejMap != 0) { return; } // get centrality - float multiplicity{0.f}; + using TMult = uint16_t; // type of numContrib + TMult multiplicity{}; for (const auto& collision : collSlice) { - float collMult = collision.numContrib(); + const TMult collMult = collision.numContrib(); if (collMult > multiplicity) { centFT0C = collision.centFT0C(); centFT0M = collision.centFT0M(); diff --git a/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx index fb1964d0ef9..c2d7d6f3047 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorCharmResoReduced.cxx @@ -830,8 +830,8 @@ struct HfDataCreatorCharmResoReduced { CCand const& candCharmBach, BBachTr const& bachelorTrack, Tr const& tracks, - int& indexHfCandCharm, - int64_t& indexCandTrBach) + const int64_t indexHfCandCharm, + const int64_t indexCandTrBach) { std::vector vecDaughtersReso{}; int8_t sign{0}, nKinkedTracks{0}, origin{0}, flagCharmBach{0}, flagCharmBachInterm{0}, flagTrack{0}, flagReso{0}; @@ -992,7 +992,7 @@ struct HfDataCreatorCharmResoReduced { { // helpers for ReducedTables filling float centrality = -1.f; - uint16_t hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + const auto hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (rejectCollisionsWithBadEvSel && hfRejMap != 0) { return; } @@ -1546,7 +1546,7 @@ struct HfDataCreatorCharmResoReduced { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint16_t rejectionMask{0}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; int nSplitColl = 0; const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex()); rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); diff --git a/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx index cf6785d286c..41ee2790334 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorJpsiHadReduced.cxx @@ -511,10 +511,10 @@ struct HfDataCreatorJpsiHadReduced { /// \param indexHfCandJpsi is the index of the Jpsi candidate /// \param selectedTracksBach is the map with the indices of selected bachelor pion tracks template - void fillMcRecoInfo(const CColl& collision, - const PParticles& particlesMc, - const std::vector& vecDaughtersB, - int& indexHfCandJpsi, + void fillMcRecoInfo(CColl const& collision, + PParticles const& particlesMc, + std::vector const& vecDaughtersB, + const int64_t indexHfCandJpsi, std::array, 2> selectedTracksBach, const int64_t indexCollisionMaxNumContrib) { @@ -728,13 +728,13 @@ struct HfDataCreatorJpsiHadReduced { registry.fill(HIST("hEvents"), 1 + Event::Processed); float centrality = -1.f; - auto hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + const auto hfRejMap = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (skipRejectedCollisions && hfRejMap != 0) { return; } // helpers for ReducedTables filling - int indexHfReducedCollision = hfReducedCollision.lastIndex() + 1; + int const indexHfReducedCollision = hfReducedCollision.lastIndex() + 1; // std::map where the key is the track.globalIndex() and // the value is the track index in the table of the selected tracks std::map selectedTracksBach; @@ -797,8 +797,8 @@ struct HfDataCreatorJpsiHadReduced { // --------------------------------- // reconstruct J/Psi candidate secondary vertex - o2::track::TrackParCov trackParCovJpsi{}; - std::array pVecJpsi{}; + o2::track::TrackParCov trackParCovJpsi{}; // FIXME: unused + std::array pVecJpsi{}; // FIXME: unused registry.fill(HIST("hFitCandidatesJpsi"), SVFitting::BeforeFit); try { if (df2.process(trackPosParCov, trackNegParCov) == 0) { @@ -823,8 +823,8 @@ struct HfDataCreatorJpsiHadReduced { } registry.fill(HIST("hSelectionsJpsi"), 2 + aod::SelectionStep::RecoPID, candidate.pt()); - int indexHfCandJpsi = hfJpsi.lastIndex() + 1; - float invMassJpsi = runJpsiToee ? hfHelper.invMassJpsiToEE(candidate) : hfHelper.invMassJpsiToMuMu(candidate); + int const indexHfCandJpsi = hfJpsi.lastIndex() + 1; + float const invMassJpsi = runJpsiToee ? hfHelper.invMassJpsiToEE(candidate) : hfHelper.invMassJpsiToMuMu(candidate); registry.fill(HIST("hMassJpsi"), invMassJpsi); registry.fill(HIST("hPtJpsi"), candidate.pt()); registry.fill(HIST("hCpaJpsi"), candidate.cpa()); @@ -1189,7 +1189,7 @@ struct HfDataCreatorJpsiHadReduced { auto candsJpsiThisColl = candsJpsi.sliceBy(candsJpsiPerCollision, thisCollId); auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); - int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + int64_t const indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); runDataCreation(collision, candsJpsiThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions @@ -1226,7 +1226,7 @@ struct HfDataCreatorJpsiHadReduced { auto candsJpsiThisColl = candsJpsi.sliceBy(candsJpsiPerCollision, thisCollId); auto trackIdsThisCollision = trackIndices.sliceBy(trackIndicesPerCollision, thisCollId); auto collsSameMcCollision = collisions.sliceBy(colPerMcCollision, collision.mcCollisionId()); - int64_t indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); + int64_t const indexCollisionMaxNumContrib = getIndexCollisionMaxNumContrib(collsSameMcCollision); runDataCreation(collision, candsJpsiThisColl, trackIdsThisCollision, tracks, particlesMc, indexCollisionMaxNumContrib, bcs); } // handle normalization by the right number of collisions diff --git a/PWGHF/D2H/Tasks/taskD0.cxx b/PWGHF/D2H/Tasks/taskD0.cxx index 30bc3787e24..3e4be3ca15c 100644 --- a/PWGHF/D2H/Tasks/taskD0.cxx +++ b/PWGHF/D2H/Tasks/taskD0.cxx @@ -391,7 +391,7 @@ struct HfTaskD0 { cent = getCentralityColl(collision, centEstimator); } if (storeOccupancy && occEstimator != OccupancyEstimator::None) { - occ = getOccupancyColl(collision, occEstimator); + occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); } } @@ -558,7 +558,7 @@ struct HfTaskD0 { cent = getCentralityColl(collision, centEstimator); } if (storeOccupancy && occEstimator != OccupancyEstimator::None) { - occ = getOccupancyColl(collision, occEstimator); + occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); } float massD0, massD0bar; if constexpr (reconstructionType == aod::hf_cand::VertexerType::KfParticle) { @@ -844,7 +844,7 @@ struct HfTaskD0 { cent = getCentralityGenColl(recoCollsPerMcCollCent, centEstimator); } if (storeOccupancy && occEstimator != OccupancyEstimator::None) { - occ = getOccupancyGenColl(recoCollsPerMcCollCent, occEstimator); + occ = o2::hf_occupancy::getOccupancyGenColl(recoCollsPerMcCollCent, occEstimator); } } else { const auto& recoCollsPerMcColl = collisions.sliceBy(colPerMcCollision, particle.mcCollision().globalIndex()); diff --git a/PWGHF/D2H/Tasks/taskDplus.cxx b/PWGHF/D2H/Tasks/taskDplus.cxx index 921d39364e6..9740516e91c 100644 --- a/PWGHF/D2H/Tasks/taskDplus.cxx +++ b/PWGHF/D2H/Tasks/taskDplus.cxx @@ -506,7 +506,7 @@ struct HfTaskDplus { cent = getCentralityColl(collision, centEstimator); } if (storeOccupancy && occEstimator != OccupancyEstimator::None) { - occ = getOccupancyColl(collision, occEstimator); + occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); } if (storePvContributors) { numPvContr = collision.numContrib(); @@ -563,7 +563,7 @@ struct HfTaskDplus { cent = getCentralityColl(collision, centEstimator); } if (storeOccupancy && occEstimator != OccupancyEstimator::None) { - occ = getOccupancyColl(collision, occEstimator); + occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); } if (storePvContributors) { numPvContr = collision.numContrib(); @@ -587,7 +587,7 @@ struct HfTaskDplus { cent = getCentralityColl(collision, centEstimator); } if (storeOccupancy && occEstimator != OccupancyEstimator::None) { - occ = getOccupancyColl(collision, occEstimator); + occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); } if (storePvContributors) { numPvContr = collision.numContrib(); @@ -622,7 +622,7 @@ struct HfTaskDplus { cent = getCentralityGenColl(recoCollsPerGenMcColl, centEstimator); } if (storeOccupancy && occEstimator != OccupancyEstimator::None) { - occ = getOccupancyGenColl(recoCollsPerGenMcColl, occEstimator); + occ = o2::hf_occupancy::getOccupancyGenColl(recoCollsPerGenMcColl, occEstimator); } for (const auto& particle : mcParticlesPerGenMcColl) { diff --git a/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx b/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx index 7960aeb7f4f..5666daeaacb 100644 --- a/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx +++ b/PWGHF/D2H/Tasks/taskFlowCharmHadrons.cxx @@ -317,10 +317,10 @@ struct HfTaskFlowCharmHadrons { /// \param tracksQy is the Y component of the Q vector for the tracks /// \param channel is the decay channel template - void getQvecDtracks(const T1& cand, + void getQvecDtracks(T1 const& cand, std::vector& tracksQx, std::vector& tracksQy, - float& ampl) + const float ampl) { // TODO: add possibility to consider different weights for the tracks, at the moment only pT is considered; float pXTrack0 = cand.pxProng0(); @@ -398,7 +398,7 @@ struct HfTaskFlowCharmHadrons { /// Get the event selection flags /// \param hfevselflag is the event selection flag - std::vector getEventSelectionFlags(uint32_t hfevselflag) + std::vector getEventSelectionFlags(const o2::hf_evsel::HfCollisionRejectionMask hfevselflag) { return { TESTBIT(hfevselflag, o2::hf_evsel::EventRejection::NoSameBunchPileup), @@ -419,16 +419,16 @@ struct HfTaskFlowCharmHadrons { /// \param outputMl are the ML scores /// \param occupancy is the occupancy of the collision using the track estimator /// \param hfevselflag flag of the collision associated to utilsEvSelHf.h - void fillThn(float& mass, - float& pt, - float& cent, - float& cosNPhi, - float& sinNPhi, - float& cosDeltaPhi, - float& sp, - std::vector& outputMl, - float& occupancy, - uint32_t& hfevselflag) + void fillThn(const float mass, + const float pt, + const float cent, + const float cosNPhi, + const float sinNPhi, + const float cosDeltaPhi, + const float sp, + const std::vector& outputMl, + const float occupancy, + const o2::hf_evsel::HfCollisionRejectionMask hfevselflag) { if (occEstimator != 0) { std::vector evtSelFlags = getEventSelectionFlags(hfevselflag); @@ -476,7 +476,7 @@ struct HfTaskFlowCharmHadrons { aod::BCsWithTimestamps const&, float& centrality) { - float occupancy = getOccupancyColl(collision, occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); centrality = o2::hf_centrality::getCentralityColl(collision, centEstimator); @@ -546,9 +546,9 @@ struct HfTaskFlowCharmHadrons { return; } float occupancy = 0.; - uint32_t hfevflag{}; + o2::hf_evsel::HfCollisionRejectionMask hfevflag{}; if (occEstimator != 0) { - occupancy = getOccupancyColl(collision, occEstimator); + occupancy = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); registry.fill(HIST("trackOccVsFT0COcc"), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); hfevflag = hfEvSel.getHfCollisionRejectionMask(collision, cent, ccdb, registry); } @@ -668,7 +668,7 @@ struct HfTaskFlowCharmHadrons { // If TPC is used for the SP estimation, the tracks of the hadron candidate must be removed from the TPC Q vector to avoid double counting if (qvecDetector == QvecEstimator::TPCNeg || qvecDetector == QvecEstimator::TPCPos) { - float ampl = amplQVec - static_cast(nProngs); + float const ampl = amplQVec - static_cast(nProngs); std::vector tracksQx = {}; std::vector tracksQy = {}; if constexpr (std::is_same_v || std::is_same_v) { @@ -846,11 +846,10 @@ struct HfTaskFlowCharmHadrons { centrality = o2::hf_centrality::getCentralityColl(collision, o2::hf_centrality::CentralityEstimator::FT0C); if (storeResoOccu) { - float occupancy{-1.f}; - occupancy = getOccupancyColl(collision, occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); registry.fill(HIST("trackOccVsFT0COcc"), collision.trackOccupancyInTimeRange(), collision.ft0cOccupancyInTimeRange()); - uint32_t hfevflag = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); - std::vector evtSelFlags = getEventSelectionFlags(hfevflag); + const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + std::vector evtSelFlags = getEventSelectionFlags(rejectionMask); registry.fill(HIST("spReso/hSparseReso"), centrality, xQVecFT0c * xQVecFV0a + yQVecFT0c * yQVecFV0a, xQVecFT0c * xQVecBTot + yQVecFT0c * yQVecBTot, xQVecFV0a * xQVecBTot + yQVecFV0a * yQVecBTot, diff --git a/PWGHF/DataModel/CandidateReconstructionTables.h b/PWGHF/DataModel/CandidateReconstructionTables.h index 3ee949eadc8..5a032b6aa74 100644 --- a/PWGHF/DataModel/CandidateReconstructionTables.h +++ b/PWGHF/DataModel/CandidateReconstructionTables.h @@ -18,7 +18,9 @@ #ifndef PWGHF_DATAMODEL_CANDIDATERECONSTRUCTIONTABLES_H_ #define PWGHF_DATAMODEL_CANDIDATERECONSTRUCTIONTABLES_H_ +#include "PWGHF/Utils/utilsEvSelHf.h" #include "PWGHF/Utils/utilsPid.h" +// #include "PWGLF/DataModel/LFStrangenessTables.h" #include "ALICE3/DataModel/ECAL.h" @@ -192,7 +194,7 @@ DECLARE_SOA_TABLE(PidTpcTofTinyPr, "AOD", "PIDTPCTOFTINYPR", //! Table of the TP namespace hf_sel_collision { -DECLARE_SOA_COLUMN(WhyRejectColl, whyRejectColl, uint32_t); //! +DECLARE_SOA_COLUMN(WhyRejectColl, whyRejectColl, o2::hf_evsel::HfCollisionRejectionMask); //! } // namespace hf_sel_collision DECLARE_SOA_TABLE(HfSelCollision, "AOD", "HFSELCOLLISION", //! diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index a4c7c4ced21..a897d9fd2f3 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -234,7 +234,7 @@ struct HfCandidateCreator2Prong { /// reject candidates not satisfying the event selections auto collision = rowTrackIndexProng2.template collision_as(); float centrality{-1.f}; - uint32_t rejectionMask{0}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; if constexpr (applyUpcSel) { rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); } else { @@ -340,7 +340,7 @@ struct HfCandidateCreator2Prong { if (indexCollision == track1.collisionId() && track1.isPVContributor()) { SETBIT(bitmapProngsContributorsPV, 1); } - uint8_t nProngsContributorsPV = hf_trkcandsel::countOnesInBinary(bitmapProngsContributorsPV); + const auto nProngsContributorsPV = hf_trkcandsel::countOnesInBinary(bitmapProngsContributorsPV); // fill candidate table rows rowCandidateBase(indexCollision, @@ -391,7 +391,7 @@ struct HfCandidateCreator2Prong { /// reject candidates in collisions not satisfying the event selections auto collision = rowTrackIndexProng2.template collision_as(); float centrality{-1.f}; - uint32_t rejectionMask{0}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; if constexpr (applyUpcSel) { rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); } else { @@ -501,7 +501,7 @@ struct HfCandidateCreator2Prong { if (indexCollision == track1.collisionId() && track1.isPVContributor()) { SETBIT(bitmapProngsContributorsPV, 1); } - uint8_t nProngsContributorsPV = hf_trkcandsel::countOnesInBinary(bitmapProngsContributorsPV); + const auto nProngsContributorsPV = hf_trkcandsel::countOnesInBinary(bitmapProngsContributorsPV); // fill candidate table rows rowCandidateBase(indexCollision, @@ -750,7 +750,7 @@ struct HfCandidateCreator2Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -768,7 +768,7 @@ struct HfCandidateCreator2Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -786,7 +786,7 @@ struct HfCandidateCreator2Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -809,7 +809,7 @@ struct HfCandidateCreator2Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); /// monitor the satisfied event selections @@ -1028,7 +1028,7 @@ struct HfCandidateCreator2ProngExpressions { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint32_t rejectionMask{0u}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; int nSplitColl = 0; if constexpr (centEstimator == CentralityEstimator::FT0C) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index f3bfce8ba51..dce9db32828 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -276,7 +276,7 @@ struct HfCandidateCreator3Prong { /// reject candidates in collisions not satisfying the event selections auto collision = rowTrackIndexProng3.template collision_as(); float centrality{-1.f}; - uint32_t rejectionMask{0}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; if constexpr (applyUpcSel) { rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); } else { @@ -394,7 +394,7 @@ struct HfCandidateCreator3Prong { if (indexCollision == track2.collisionId() && track2.isPVContributor()) { SETBIT(bitmapProngsContributorsPV, 2); } - uint8_t nProngsContributorsPV = hf_trkcandsel::countOnesInBinary(bitmapProngsContributorsPV); + const auto nProngsContributorsPV = hf_trkcandsel::countOnesInBinary(bitmapProngsContributorsPV); // fill candidate table rows rowCandidateBase(indexCollision, @@ -447,7 +447,7 @@ struct HfCandidateCreator3Prong { /// reject candidates in collisions not satisfying the event selections auto collision = rowTrackIndexProng3.template collision_as(); float centrality{-1.f}; - uint32_t rejectionMask{0}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; if constexpr (applyUpcSel) { rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); } else { @@ -635,7 +635,7 @@ struct HfCandidateCreator3Prong { if (indexCollision == track2.collisionId() && track2.isPVContributor()) { SETBIT(bitmapProngsContributorsPV, 2); } - uint8_t nProngsContributorsPV = hf_trkcandsel::countOnesInBinary(bitmapProngsContributorsPV); + const auto nProngsContributorsPV = hf_trkcandsel::countOnesInBinary(bitmapProngsContributorsPV); // fill candidate table rows rowCandidateBase(indexCollision, @@ -894,7 +894,7 @@ struct HfCandidateCreator3Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -912,7 +912,7 @@ struct HfCandidateCreator3Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -930,7 +930,7 @@ struct HfCandidateCreator3Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -953,7 +953,7 @@ struct HfCandidateCreator3Prong { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc(collision, centrality, ccdb, registry, bcs); /// monitor the satisfied event selections @@ -1316,7 +1316,7 @@ struct HfCandidateCreator3ProngExpressions { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint32_t rejectionMask{0u}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; int nSplitColl = 0; if constexpr (centEstimator == CentralityEstimator::FT0C) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); diff --git a/PWGHF/TableProducer/candidateCreatorCascade.cxx b/PWGHF/TableProducer/candidateCreatorCascade.cxx index 20e16710463..1bfe94031cb 100644 --- a/PWGHF/TableProducer/candidateCreatorCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorCascade.cxx @@ -564,7 +564,7 @@ struct HfCandidateCreatorCascadeMc { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint32_t rejectionMask{0u}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; int nSplitColl = 0; if constexpr (centEstimator == CentralityEstimator::FT0C) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); diff --git a/PWGHF/TableProducer/candidateCreatorDstar.cxx b/PWGHF/TableProducer/candidateCreatorDstar.cxx index 9036717104b..3bb4472be62 100644 --- a/PWGHF/TableProducer/candidateCreatorDstar.cxx +++ b/PWGHF/TableProducer/candidateCreatorDstar.cxx @@ -732,7 +732,7 @@ struct HfCandidateCreatorDstarExpressions { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint32_t rejectionMask{0u}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; int nSplitColl = 0; if constexpr (centEstimator == CentralityEstimator::FT0C) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); diff --git a/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx b/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx index 9a59c28cf9c..e826254ea35 100644 --- a/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx +++ b/PWGHF/TableProducer/candidateCreatorSigmac0plusplus.cxx @@ -587,7 +587,7 @@ struct HfCandidateSigmac0plusplusMc { auto mcCollision = particle.mcCollision(); float centrality{-1.f}; const auto collSlice = collInfos.sliceBy(colPerMcCollision, mcCollision.globalIndex()); - auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); + const auto rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, collSlice, centrality); hfEvSelMc.fillHistograms(mcCollision, rejectionMask, 0); if (rejectionMask != 0) { // at least one event selection not satisfied --> reject gen particles from this collision diff --git a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx index 9d7413d75d1..5f3e0b3ebba 100644 --- a/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx +++ b/PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx @@ -2726,7 +2726,7 @@ struct HfCandidateCreatorXic0Omegac0Mc { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint32_t rejectionMask{0u}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; int nSplitColl = 0; if constexpr (centEstimator == CentralityEstimator::FT0C) { const auto collSlice = collsWithMcLabels.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); diff --git a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx index 5fea174e4f9..192465b5e33 100644 --- a/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx +++ b/PWGHF/TableProducer/candidateCreatorXicToXiPiPi.cxx @@ -798,7 +798,7 @@ struct HfCandidateCreatorXicToXiPiPi { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -815,7 +815,7 @@ struct HfCandidateCreatorXicToXiPiPi { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -832,7 +832,7 @@ struct HfCandidateCreatorXicToXiPiPi { /// bitmask with event. selection info float centrality{-1.f}; - float occupancy = getOccupancyColl(collision, hfEvSel.occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, hfEvSel.occEstimator); const auto rejectionMask = hfEvSel.getHfCollisionRejectionMask(collision, centrality, ccdb, registry); /// monitor the satisfied event selections @@ -1071,7 +1071,7 @@ struct HfCandidateCreatorXicToXiPiPiExpressions { const auto mcParticlesPerMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, mcCollision.globalIndex()); // Slice the collisions table to get the collision info for the current MC collision float centrality{-1.f}; - uint32_t rejectionMask{0u}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; int nSplitColl = 0; if constexpr (centEstimator == o2::hf_centrality::CentralityEstimator::FT0C) { const auto collSlice = collInfos.sliceBy(colPerMcCollisionFT0C, mcCollision.globalIndex()); diff --git a/PWGHF/TableProducer/trackIndexSkimCreator.cxx b/PWGHF/TableProducer/trackIndexSkimCreator.cxx index 4b03533ce1f..8bfd706500a 100644 --- a/PWGHF/TableProducer/trackIndexSkimCreator.cxx +++ b/PWGHF/TableProducer/trackIndexSkimCreator.cxx @@ -160,8 +160,8 @@ struct HfTrackIndexSkimCreatorTagSelCollisions { template void selectCollision(const Col& collision, const BCsType& bcs) { - float centrality = -1.; - uint32_t rejectionMask; + float centrality = -1.f; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; if constexpr (applyUpcSel) { rejectionMask = hfEvSel.getHfCollisionRejectionMaskWithUpc( @@ -1294,7 +1294,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); @@ -3094,7 +3094,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; @@ -3363,7 +3363,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 diff --git a/PWGHF/Tasks/taskCharmHadImpactPar.cxx b/PWGHF/Tasks/taskCharmHadImpactPar.cxx index 3000d5bf8c5..01c838df129 100644 --- a/PWGHF/Tasks/taskCharmHadImpactPar.cxx +++ b/PWGHF/Tasks/taskCharmHadImpactPar.cxx @@ -269,13 +269,13 @@ struct HfTaskCharmHadImpactPar { } } } - float centrality = 0.; - float occupancy = 0.; + float centrality = 0.f; + float occupancy = 0.f; if (centEstimator != CentralityEstimator::None) { centrality = getCentralityColl(collision, centEstimator); } if (occEstimator != OccupancyEstimator::None) { - occupancy = getOccupancyColl(collision, occEstimator); + occupancy = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); } int8_t flagMcMatchRec = 0; diff --git a/PWGHF/Tasks/taskMcValidation.cxx b/PWGHF/Tasks/taskMcValidation.cxx index 97b57f150bc..8cf7ea7d0ce 100644 --- a/PWGHF/Tasks/taskMcValidation.cxx +++ b/PWGHF/Tasks/taskMcValidation.cxx @@ -283,11 +283,11 @@ struct HfTaskMcValidationGen { // Slice the collisions table to get the collision info for the current MC collision float centrality{105.f}; - int occupancy = 0; + float occupancy{0.f}; if (storeOccupancy) { - occupancy = getOccupancyGenColl(recoCollisions, OccupancyEstimator::Its); + occupancy = o2::hf_occupancy::getOccupancyGenColl(recoCollisions, OccupancyEstimator::Its); } - uint32_t rejectionMask{0u}; + o2::hf_evsel::HfCollisionRejectionMask rejectionMask{}; if constexpr (centEstimator == CentralityEstimator::FT0C) { rejectionMask = hfEvSelMc.getHfMcCollisionRejectionMask(mcCollision, recoCollisions, centrality); } else if constexpr (centEstimator == CentralityEstimator::FT0M) { diff --git a/PWGHF/Utils/utilsAnalysis.h b/PWGHF/Utils/utilsAnalysis.h index 7a2c2f45d0a..d5879647f94 100644 --- a/PWGHF/Utils/utilsAnalysis.h +++ b/PWGHF/Utils/utilsAnalysis.h @@ -35,7 +35,7 @@ enum BHadMothers { NotMatched = 0, LambdaBZero }; /// Convert the B hadron mother PDG for non prompt candidates to a flag -/// \param pdg of the b hadron mother +/// \param flagBHad pdg of the b hadron mother /// \return integer map to specific mothers' PDG codes BHadMothers getBHadMotherFlag(const int flagBHad) { @@ -54,21 +54,21 @@ BHadMothers getBHadMotherFlag(const int flagBHad) return BHadMothers::NotMatched; } -/// Finds pT bin in an array. -/// \param bins array of pT bins -/// \param value pT +/// Finds bin in an array that contains a value. +/// \param bins array of bins +/// \param value value to find /// \return index of the pT bin /// \note Accounts for the offset so that pT bin array can be used to also configure a histogram axis. -template -int findBin(T1 const& binsPt, T2 value) +template +int findBin(TArrayPt const& bins, TNumber const value) { - if (value < binsPt->front()) { + if (value < bins->front()) { return -1; } - if (value >= binsPt->back()) { + if (value >= bins->back()) { return -1; } - return std::distance(binsPt->begin(), std::upper_bound(binsPt->begin(), binsPt->end(), value)) - 1; + return std::distance(bins->begin(), std::upper_bound(bins->begin(), bins->end(), value)) - 1; } /// Single-track cut on DCAxy and DCAz @@ -78,8 +78,12 @@ int findBin(T1 const& binsPt, T2 value) /// \param dcaXY is the prong dcaXY /// \param dcaZ is the prong dcaZ /// \return true if track passes all cuts -template -bool isSelectedTrackDca(T1 const& binsPt, T2 const& cuts, const float pt, const float dcaXY, const float dcaZ) +template +bool isSelectedTrackDca(TArrayPt const& binsPt, + TArrayCuts const& cuts, + const float pt, + const float dcaXY, + const float dcaZ) { auto binPt = findBin(binsPt, pt); if (binPt == -1) { @@ -105,8 +109,10 @@ bool isSelectedTrackDca(T1 const& binsPt, T2 const& cuts, const float pt, const /// \param itsNClustersFoundMin is the minimum number of ITS clusters /// \param itsChi2PerClusterMax is the maximum value of chi2 fit over ITS clusters /// \return true if track passes all cuts -template -bool isSelectedTrackItsQuality(T const& track, const int itsNClustersFoundMin, const float itsChi2PerClusterMax) +template +bool isSelectedTrackItsQuality(TTrack const& track, + const int itsNClustersFoundMin, + const float itsChi2PerClusterMax) { if (track.itsNCls() < itsNClustersFoundMin) { return false; @@ -124,8 +130,12 @@ bool isSelectedTrackItsQuality(T const& track, const int itsNClustersFoundMin, c /// \param tpcNCrossedRowsOverFindableClustersMin is the minimum of TPC CrossedRows/FindableClusters value /// \param tpcChi2PerClusterMax is the maximum value of chi2 fit over TPC clusters /// \return true if track passes all cuts -template -bool isSelectedTrackTpcQuality(T const& track, const int tpcNClustersFoundMin, const int tpcNCrossedRowsMin, const float tpcNCrossedRowsOverFindableClustersMin, const float tpcChi2PerClusterMax) +template +bool isSelectedTrackTpcQuality(TTrack const& track, + const int tpcNClustersFoundMin, + const int tpcNCrossedRowsMin, + const float tpcNCrossedRowsOverFindableClustersMin, + const float tpcChi2PerClusterMax) { if (track.tpcNClsFound() < tpcNClustersFoundMin) { return false; @@ -142,7 +152,7 @@ bool isSelectedTrackTpcQuality(T const& track, const int tpcNClustersFoundMin, c return true; } -/// Mass selection of 2 or 3 prong canidates in triggered data analysis +/// Mass selection of 2 or 3 prong candidates in triggered data analysis /// \tparam nProngs switch between 2-prong and 3-prong selection /// \param invMass is the invariant mass of the candidate /// \param pdgMass is the pdg Mass of the candidate particle @@ -150,10 +160,13 @@ bool isSelectedTrackTpcQuality(T const& track, const int tpcNClustersFoundMin, c /// \param cutConfig is the struct with the pt-dependent mass configurations /// \return true if candidate passes selection template -bool isCandidateInMassRange(const float& invMass, const double& pdgMass, const float& pt, Config const& cutConfig) +bool isCandidateInMassRange(const float invMass, + const double pdgMass, + const float pt, + Config const& cutConfig) { - float peakMean = (pt < cutConfig.ptDeltaMassMax.value) ? ((pdgMass + cutConfig.deltaMassPars->get("constant")) + cutConfig.deltaMassPars->get("linear") * pt) : pdgMass; - float peakWidth = cutConfig.sigmaPars->get("constant") + cutConfig.sigmaPars->get("linear") * pt; + const float peakMean = (pt < cutConfig.ptDeltaMassMax.value) ? ((pdgMass + cutConfig.deltaMassPars->get("constant")) + cutConfig.deltaMassPars->get("linear") * pt) : pdgMass; + const float peakWidth = cutConfig.sigmaPars->get("constant") + cutConfig.sigmaPars->get("linear") * pt; return (!(std::abs(invMass - peakMean) > cutConfig.nSigmaMax.value * peakWidth && pt < cutConfig.ptMassCutMax.value)); } @@ -164,9 +177,9 @@ struct HfTrigger2ProngCuts : o2::framework::ConfigurableGroup { static constexpr float DefaultDeltaMassPars[1][2] = {{-0.0025f, 0.0001f}}; static constexpr float DefaultSigmaPars[1][2] = {{0.01424f, 0.00178f}}; - o2::framework::Configurable nSigmaMax{"nSigmaMax", 2, "Maximum number of sigmas for pT-differential mass cut for 2-prong candidates"}; - o2::framework::Configurable ptDeltaMassMax{"ptDeltaMassMax", 10., "Max pT to apply delta mass shift to PDG mass value for 2-prong candidates"}; - o2::framework::Configurable ptMassCutMax{"ptMassCutMax", 9999., "Max pT to apply pT-differential cut for 2-prong candidates"}; + o2::framework::Configurable nSigmaMax{"nSigmaMax", 2.f, "Maximum number of sigmas for pT-differential mass cut for 2-prong candidates"}; + o2::framework::Configurable ptDeltaMassMax{"ptDeltaMassMax", 10.f, "Max pT to apply delta mass shift to PDG mass value for 2-prong candidates"}; + o2::framework::Configurable ptMassCutMax{"ptMassCutMax", 9999.f, "Max pT to apply pT-differential cut for 2-prong candidates"}; o2::framework::Configurable> deltaMassPars{"deltaMassPars", {DefaultDeltaMassPars[0], 2, {"constant", "linear"}}, "delta mass parameters for HF 2-prong trigger mass cut"}; o2::framework::Configurable> sigmaPars{"sigmaPars", {DefaultSigmaPars[0], 2, {"constant", "linear"}}, "sigma parameters for HF 2-prong trigger mass cut"}; }; @@ -178,8 +191,8 @@ struct HfTrigger3ProngCuts : o2::framework::ConfigurableGroup { static constexpr float DefaultDeltaMassPars[1][2] = {{-0.0025f, 0.0001f}}; static constexpr float DefaultSigmaPars[1][2] = {{0.00796f, 0.00176f}}; o2::framework::Configurable nSigmaMax{"nSigmaMax", 2, "Maximum number of sigmas for pT-differential mass cut for 3-prong candidates"}; - o2::framework::Configurable ptDeltaMassMax{"ptDeltaMassMax", 10., "Max pT to apply delta mass shift to PDG mass value for 3-prong candidates"}; - o2::framework::Configurable ptMassCutMax{"ptMassCutMax", 9999., "Max pT to apply pT-differential cut for 3-prong candidates"}; + o2::framework::Configurable ptDeltaMassMax{"ptDeltaMassMax", 10.f, "Max pT to apply delta mass shift to PDG mass value for 3-prong candidates"}; + o2::framework::Configurable ptMassCutMax{"ptMassCutMax", 9999.f, "Max pT to apply pT-differential cut for 3-prong candidates"}; o2::framework::Configurable> deltaMassPars{"deltaMassPars", {DefaultDeltaMassPars[0], 2, {"constant", "linear"}}, "delta mass parameters for HF 3-prong trigger mass cut"}; o2::framework::Configurable> sigmaPars{"sigmaPars", {DefaultSigmaPars[0], 2, {"constant", "linear"}}, "sigma parameters for HF 3-prong trigger mass cut"}; }; diff --git a/PWGHF/Utils/utilsBfieldCCDB.h b/PWGHF/Utils/utilsBfieldCCDB.h index 8d7166eca4a..d14203161e4 100644 --- a/PWGHF/Utils/utilsBfieldCCDB.h +++ b/PWGHF/Utils/utilsBfieldCCDB.h @@ -34,9 +34,12 @@ /// \param lut is a pointer to the o2::base::MatLayerCylSet object /// \param isRun2 tells whether we are analysing Run2 converted data or not (different GRP object type) template -void initCCDB(TBc const& bc, int& mRunNumber, - o2::framework::Service const& ccdb, std::string const& ccdbPathGrp, o2::base::MatLayerCylSet* lut, - bool isRun2) +void initCCDB(TBc const& bc, + int& mRunNumber, + o2::framework::Service const& ccdb, + std::string const& ccdbPathGrp, + o2::base::MatLayerCylSet* lut, + const bool isRun2) { if (mRunNumber != bc.runNumber()) { LOGF(info, "====== initCCDB function called (isRun2==%d)", isRun2); diff --git a/PWGHF/Utils/utilsDerivedData.h b/PWGHF/Utils/utilsDerivedData.h index 044abed2f90..4a08d37d535 100644 --- a/PWGHF/Utils/utilsDerivedData.h +++ b/PWGHF/Utils/utilsDerivedData.h @@ -39,8 +39,10 @@ namespace o2::analysis::hf_derived /// \param cursor cursor of the filled table /// \param enabled switch for filling the table /// \param size size of the source table -template -void reserveTable(T& cursor, const o2::framework::Configurable& enabled, const uint64_t size) +template +void reserveTable(TCursor& cursor, + const o2::framework::Configurable& enabled, + const uint64_t size) { if (enabled.value) { cursor.reserve(size); @@ -94,36 +96,34 @@ struct HfProducesDerivedData : o2::framework::ProducesGroup { conf = &c; } - template - void reserveTablesCandidates(T size) + void reserveTablesCandidates(const uint64_t size) { o2::analysis::hf_derived::reserveTable(rowCandidateBase, conf->fillCandidateBase, size); } - template - void reserveTablesColl(T size) + void reserveTablesColl(const uint64_t size) { o2::analysis::hf_derived::reserveTable(rowCollBase, conf->fillCollBase, size); o2::analysis::hf_derived::reserveTable(rowCollId, conf->fillCollId, size); } - template - void reserveTablesMcColl(T size) + void reserveTablesMcColl(const uint64_t size) { o2::analysis::hf_derived::reserveTable(rowMcCollBase, conf->fillMcCollBase, size); o2::analysis::hf_derived::reserveTable(rowMcCollId, conf->fillMcCollId, size); o2::analysis::hf_derived::reserveTable(rowMcRCollId, conf->fillMcRCollId, size); } - template - void reserveTablesParticles(T size) + void reserveTablesParticles(const uint64_t size) { o2::analysis::hf_derived::reserveTable(rowParticleBase, conf->fillParticleBase, size); o2::analysis::hf_derived::reserveTable(rowParticleId, conf->fillParticleId, size); } - template - void fillTablesCandidate(const T& candidate, double invMass, double y) + template + void fillTablesCandidate(const TCandidate& candidate, + const double invMass, + const double y) { if (conf->fillCandidateBase.value) { rowCandidateBase( @@ -136,9 +136,8 @@ struct HfProducesDerivedData : o2::framework::ProducesGroup { } } - template - // void fillTablesCollision(const T& collision, int isEventReject, int runNumber) - void fillTablesCollision(const T& collision) + template + void fillTablesCollision(TCollision const& collision) { if (conf->fillCollBase.value) { rowCollBase( @@ -165,8 +164,8 @@ struct HfProducesDerivedData : o2::framework::ProducesGroup { } } - template - void fillTablesMcCollision(const T& mcCollision) + template + void fillTablesMcCollision(TMcCollision const& mcCollision) { if (conf->fillMcCollBase.value) { rowMcCollBase( @@ -186,8 +185,8 @@ struct HfProducesDerivedData : o2::framework::ProducesGroup { } } - template - void fillTablesParticle(const T& particle, U mass) + template + void fillTablesParticle(TMcParticle const& particle, const TMass mass) { if (conf->fillParticleBase.value) { rowParticleBase( @@ -206,10 +205,10 @@ struct HfProducesDerivedData : o2::framework::ProducesGroup { } } - template - void preProcessMcCollisions(CollisionType const& mcCollisions, - o2::framework::Preslice const& mcParticlesPerMcCollision, - ParticleType const& mcParticles) + template + void preProcessMcCollisions(TMcCollisions const& mcCollisions, + o2::framework::Preslice const& mcParticlesPerMcCollision, + TMcParticles const& mcParticles) { if (!conf->fillMcRCollId.value) { return; @@ -217,26 +216,26 @@ struct HfProducesDerivedData : o2::framework::ProducesGroup { hasMcParticles.clear(); // Fill MC collision flags for (const auto& mcCollision : mcCollisions) { - auto thisMcCollId = mcCollision.globalIndex(); - auto particlesThisMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, thisMcCollId); + const auto thisMcCollId = mcCollision.globalIndex(); + const auto particlesThisMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, thisMcCollId); LOGF(debug, "MC collision %d has %d MC particles (preprocess)", thisMcCollId, particlesThisMcColl.size()); hasMcParticles[thisMcCollId] = (particlesThisMcColl.size() > 0); } } - template - void processMcParticles(CollisionType const& mcCollisions, - o2::framework::Preslice const& mcParticlesPerMcCollision, - ParticleType const& mcParticles, - TMass const massParticle) + template + void processMcParticles(TMcCollisions const& mcCollisions, + o2::framework::Preslice const& mcParticlesPerMcCollision, + TMcParticles const& mcParticles, + const TMass massParticle) { // Fill MC collision properties - auto sizeTableMcColl = mcCollisions.size(); + const auto sizeTableMcColl = mcCollisions.size(); reserveTablesMcColl(sizeTableMcColl); for (const auto& mcCollision : mcCollisions) { - auto thisMcCollId = mcCollision.globalIndex(); - auto particlesThisMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, thisMcCollId); - auto sizeTablePart = particlesThisMcColl.size(); + const auto thisMcCollId = mcCollision.globalIndex(); + const auto particlesThisMcColl = mcParticles.sliceBy(mcParticlesPerMcCollision, thisMcCollId); + const auto sizeTablePart = particlesThisMcColl.size(); LOGF(debug, "MC collision %d has %d MC particles", thisMcCollId, sizeTablePart); // Skip MC collisions without HF particles (and without HF candidates in matched reconstructed collisions if saving indices of reconstructed collisions matched to MC collisions) LOGF(debug, "MC collision %d has %d saved derived rec. collisions", thisMcCollId, matchedCollisions[thisMcCollId].size()); diff --git a/PWGHF/Utils/utilsEvSelHf.h b/PWGHF/Utils/utilsEvSelHf.h index d54c17b2eb2..4af173070d5 100644 --- a/PWGHF/Utils/utilsEvSelHf.h +++ b/PWGHF/Utils/utilsEvSelHf.h @@ -55,16 +55,16 @@ enum OccupancyEstimator { None = 0, /// Get the occupancy /// \param collision is the collision with the occupancy information /// \return collision occupancy -template -float getOccupancyColl(Coll const& collision, int occEstimator) +template +float getOccupancyColl(TCollision const& collision, const int occEstimator) { switch (occEstimator) { case OccupancyEstimator::Its: - return collision.trackOccupancyInTimeRange(); + return static_cast(collision.trackOccupancyInTimeRange()); case OccupancyEstimator::Ft0c: - return collision.ft0cOccupancyInTimeRange(); + return static_cast(collision.ft0cOccupancyInTimeRange()); default: - LOG(fatal) << "Occupancy estimator not valid. Possible values are ITS or FT0C."; + LOG(fatal) << "Occupancy estimator not valid. See OccupancyEstimator for valid values."; break; } return -999.f; @@ -73,14 +73,14 @@ float getOccupancyColl(Coll const& collision, int occEstimator) /// \brief Function to get MC collision occupancy /// \param collSlice collection of reconstructed collisions associated to a generated one /// \return generated MC collision occupancy -template -int getOccupancyGenColl(CCs const& collSlice, int occEstimator) +template +float getOccupancyGenColl(TCollisions const& collSlice, const int occEstimator) { - float multiplicity{0.f}; - int occupancy = 0; + using TMult = uint16_t; // type of numContrib + TMult multiplicity{}; + float occupancy{0.f}; for (const auto& collision : collSlice) { - float collMult{0.f}; - collMult = collision.numContrib(); + const TMult collMult = collision.numContrib(); if (collMult > multiplicity) { occupancy = getOccupancyColl(collision, occEstimator); multiplicity = collMult; @@ -115,14 +115,16 @@ enum EventRejection { NEventRejection }; -o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, +EventRejection::NEventRejection - 0.5f, ""}; -o2::framework::AxisSpec axisUpcEvents = {o2::aod::sgselector::DoubleGap + 1, -0.5f, +o2::aod::sgselector::DoubleGap + 0.5f, ""}; +using HfCollisionRejectionMask = uint32_t; // 32 bits, in case new ev. selections will be added + +const o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, +EventRejection::NEventRejection - 0.5f, ""}; +const o2::framework::AxisSpec axisUpcEvents = {o2::aod::sgselector::DoubleGap + 1, -0.5f, +o2::aod::sgselector::DoubleGap + 0.5f, ""}; /// \brief Function to put labels on monitoring histogram /// \param hRejection monitoring histogram /// \param softwareTriggerLabel bin label for software trigger rejection template -void setEventRejectionLabels(Histo& hRejection, std::string softwareTriggerLabel = "") +void setEventRejectionLabels(Histo& hRejection, std::string const& softwareTriggerLabel = "") { // Puts labels on the collision monitoring histogram. hRejection->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All"); @@ -148,8 +150,8 @@ void setEventRejectionLabels(Histo& hRejection, std::string softwareTriggerLabel struct HfEventSelection : o2::framework::ConfigurableGroup { std::string prefix = "hfEvSel"; // JSON group name // event selection parameters (in chronological order of application) - o2::framework::Configurable centralityMin{"centralityMin", 0., "Minimum centrality"}; - o2::framework::Configurable centralityMax{"centralityMax", 100., "Maximum centrality"}; + o2::framework::Configurable centralityMin{"centralityMin", 0.f, "Minimum centrality"}; + o2::framework::Configurable centralityMax{"centralityMax", 100.f, "Maximum centrality"}; o2::framework::Configurable useSel8Trigger{"useSel8Trigger", true, "Apply the sel8 event selection"}; o2::framework::Configurable triggerClass{"triggerClass", -1, "Trigger class different from sel8 (e.g. kINT7 for Run2) used only if useSel8Trigger is false"}; o2::framework::Configurable useTvxTrigger{"useTvxTrigger", true, "Apply TVX trigger sel"}; @@ -262,10 +264,13 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { /// \param ccdb ccdb service needed to retrieve the needed info for zorro /// \param registry reference to the histogram registry needed for zorro /// \return bitmask with the event selection criteria not satisfied by the collision - template - uint32_t getHfCollisionRejectionMask(const Coll& collision, float& centrality, o2::framework::Service const& ccdb, o2::framework::HistogramRegistry& registry) + template + HfCollisionRejectionMask getHfCollisionRejectionMask(TCollision const& collision, + float& centrality, + o2::framework::Service const& ccdb, + o2::framework::HistogramRegistry& registry) { - uint32_t rejectionMask{0}; // 32 bits, in case new ev. selections will be added + HfCollisionRejectionMask rejectionMask{}; if constexpr (centEstimator != o2::hf_centrality::CentralityEstimator::None) { centrality = o2::hf_centrality::getCentralityColl(collision, centEstimator); @@ -317,7 +322,7 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { SETBIT(rejectionMask, EventRejection::NoCollInRofStandard); } if (useOccupancyCut) { - float occupancy = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); + const auto occupancy = o2::hf_occupancy::getOccupancyColl(collision, occEstimator); if (occupancy < occupancyMin || occupancy > occupancyMax) { SETBIT(rejectionMask, EventRejection::Occupancy); } @@ -341,9 +346,8 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { if (softwareTrigger.value != "") { // we might have to update it from CCDB - auto bc = collision.template bc_as(); - - int runNumber = bc.runNumber(); + const auto bc = collision.template bc_as(); + const auto runNumber = bc.runNumber(); if (runNumber != currentRun) { // We might need to update Zorro from CCDB if the run number changes zorro.setCCDBpath(ccdbPathSoftwareTrigger); zorro.setBCtolerance(bcMarginForSoftwareTrigger); @@ -366,17 +370,21 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { return rejectionMask; } - template - uint32_t getHfCollisionRejectionMaskWithUpc(const Coll& collision, float& centrality, o2::framework::Service const& ccdb, o2::framework::HistogramRegistry& registry, const BCsType& bcs) + template + HfCollisionRejectionMask getHfCollisionRejectionMaskWithUpc(TCollision const& collision, + float& centrality, + o2::framework::Service const& ccdb, + o2::framework::HistogramRegistry& registry, + TBcs const& bcs) { - auto rejectionMaskWithUpc = getHfCollisionRejectionMask(collision, centrality, ccdb, registry); + auto rejectionMaskWithUpc = getHfCollisionRejectionMask(collision, centrality, ccdb, registry); if (useEvSel) { - SGCutParHolder sgCuts = setSgPreselection(); - auto bc = collision.template foundBC_as(); - auto bcRange = udhelpers::compatibleBCs(collision, sgCuts.NDtcoll(), bcs, sgCuts.minNBCs()); - auto sgSelectionResult = sgSelector.IsSelected(sgCuts, collision, bcRange, bc); - int upcEventType = sgSelectionResult.value; + const SGCutParHolder sgCuts = setSgPreselection(); + const auto bc = collision.template foundBC_as(); + const auto bcRange = udhelpers::compatibleBCs(collision, sgCuts.NDtcoll(), bcs, sgCuts.minNBCs()); + const auto sgSelectionResult = sgSelector.IsSelected(sgCuts, collision, bcRange, bc); + const int upcEventType = sgSelectionResult.value; if (upcEventType > o2::aod::sgselector::DoubleGap) { SETBIT(rejectionMaskWithUpc, EventRejection::UpcEventCut); } else { @@ -390,11 +398,14 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { /// \brief Fills histograms for monitoring event selections satisfied by the collision. /// \param collision analysed collision /// \param rejectionMask bitmask storing the info about which ev. selections are not satisfied by the collision - template - void fillHistograms(Coll const& collision, const uint32_t rejectionMask, float& centrality, float occupancy = -1) + template + void fillHistograms(TCollision const& collision, + const HfCollisionRejectionMask rejectionMask, + const float centrality, + const float occupancy = -1.f) { hCollisions->Fill(EventRejection::None); - const float posZ = collision.posZ(); + const auto posZ = collision.posZ(); hPosZBeforeEvSel->Fill(posZ); for (std::size_t reason = 1; reason < EventRejection::NEventRejection; reason++) { @@ -415,30 +426,31 @@ struct HfEventSelection : o2::framework::ConfigurableGroup { struct HfEventSelectionMc { // event selection parameters (in chronological order of application) - bool useSel8Trigger{false}; // Apply the Sel8 selection - bool useTvxTrigger{false}; // Apply the TVX trigger - bool useTimeFrameBorderCut{true}; // Apply TF border cut - bool useItsRofBorderCut{false}; // Apply the ITS RO frame border cut - float zPvPosMin{-1000.f}; // Minimum PV posZ (cm) - float zPvPosMax{1000.f}; // Maximum PV posZ (cm) - float centralityMin{0.f}; // Minimum centrality - float centralityMax{100.f}; // Maximum centrality - bool requireGoodRct{false}; // Apply RCT selection - std::string rctLabel{""}; // RCT selection flag - bool rctCheckZDC; // require ZDC from RCT - bool rctTreatLimitedAcceptanceAsBad; // RCT flag to reject events with limited acceptance for selected detectors + bool useSel8Trigger{false}; // Apply the Sel8 selection + bool useTvxTrigger{false}; // Apply the TVX trigger + bool useTimeFrameBorderCut{true}; // Apply TF border cut + bool useItsRofBorderCut{false}; // Apply the ITS RO frame border cut + float zPvPosMin{-1000.f}; // Minimum PV posZ (cm) + float zPvPosMax{1000.f}; // Maximum PV posZ (cm) + float centralityMin{0.f}; // Minimum centrality + float centralityMax{100.f}; // Maximum centrality + bool requireGoodRct{false}; // Apply RCT selection + std::string rctLabel{""}; // RCT selection flag + bool rctCheckZDC{false}; // require ZDC from RCT + bool rctTreatLimitedAcceptanceAsBad{false}; // RCT flag to reject events with limited acceptance for selected detectors // util to retrieve the RCT info from CCDB o2::aod::rctsel::RCTFlagsChecker rctChecker; // histogram names static constexpr char NameHistGenCollisionsCent[] = "hGenCollisionsCent"; - std::shared_ptr hGenCollisionsCent; static constexpr char NameHistRecCollisionsCentMc[] = "hRecCollisionsCentMc"; - std::shared_ptr hRecCollisionsCentMc; static constexpr char NameHistNSplitVertices[] = "hNSplitVertices"; - std::shared_ptr hNSplitVertices; static constexpr char NameHistGenCollisions[] = "hGenCollisions"; + + std::shared_ptr hGenCollisionsCent; + std::shared_ptr hRecCollisionsCentMc; + std::shared_ptr hNSplitVertices; std::shared_ptr hGenCollisions; /// \brief Adds collision monitoring histograms in the histogram registry. @@ -456,7 +468,7 @@ struct HfEventSelectionMc { /// \brief Configures the object from the reco workflow /// \param registry reference to the histogram registry /// \param device device spec to get the configs from the reco workflow - void configureFromDevice(const o2::framework::DeviceSpec& device) + void configureFromDevice(o2::framework::DeviceSpec const& device) { for (const auto& option : device.options) { if (option.name.compare("hfEvSel.useSel8Trigger") == 0) { @@ -490,7 +502,8 @@ struct HfEventSelectionMc { /// \brief Inits the HF event selection object /// \param device device spec to get the configs from the reco workflow /// \param registry reference to the histogram registry - void init(const o2::framework::DeviceSpec& device, o2::framework::HistogramRegistry& registry) + void init(o2::framework::DeviceSpec const& device, + o2::framework::HistogramRegistry& registry) { // we get the configuration from the reco workflow configureFromDevice(device); @@ -509,12 +522,14 @@ struct HfEventSelectionMc { /// \param collSlice collection of reconstructed collisions /// \param centrality centrality variable to be set in this function /// \return a bitmask with the event selections not satisfied by the analysed collision - template - uint32_t getHfMcCollisionRejectionMask(TMcColl const& mcCollision, CCs const& collSlice, float& centrality) + template + HfCollisionRejectionMask getHfMcCollisionRejectionMask(TMcCollision const& mcCollision, + TCollisions const& collSlice, + float& centrality) { - uint32_t rejectionMask{0}; - float zPv = mcCollision.posZ(); - auto bc = mcCollision.template bc_as(); + HfCollisionRejectionMask rejectionMask{}; + const auto zPv = mcCollision.posZ(); + const auto bc = mcCollision.template bc_as(); if constexpr (centEstimator != o2::hf_centrality::CentralityEstimator::None) { centrality = o2::hf_centrality::getCentralityGenColl(collSlice, centEstimator); @@ -560,8 +575,10 @@ struct HfEventSelectionMc { /// \brief Fills histogram for monitoring event selections satisfied by the collision. /// \param collision analysed collision /// \param rejectionMask bitmask storing the info about which ev. selections are not satisfied by the collision - template - void fillHistograms(Coll const& mcCollision, const uint32_t rejectionMask, int nSplitColl = 0) + template + void fillHistograms(TMcCollision const& mcCollision, + const HfCollisionRejectionMask rejectionMask, + const int nSplitColl = 0) { hGenCollisions->Fill(EventRejection::None); diff --git a/PWGHF/Utils/utilsMcGen.h b/PWGHF/Utils/utilsMcGen.h index 76152505906..485b15de1af 100644 --- a/PWGHF/Utils/utilsMcGen.h +++ b/PWGHF/Utils/utilsMcGen.h @@ -35,8 +35,12 @@ namespace hf_mc_gen { -template -void fillMcMatchGen2Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V& rowMcMatchGen, bool rejectBackground, bool matchCorrelatedBackground) +template +void fillMcMatchGen2Prong(TMcParticles const& mcParticles, + TMcParticlesPerColl const& mcParticlesPerMcColl, + TCursor& rowMcMatchGen, + const bool rejectBackground, + const bool matchCorrelatedBackground) { using namespace o2::constants::physics; using namespace o2::hf_decay::hf_cand_2prong; @@ -123,8 +127,12 @@ void fillMcMatchGen2Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V } } -template -void fillMcMatchGen3Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V& rowMcMatchGen, bool rejectBackground, std::vector const& pdgMothersCorrelBkg = {}) +template +void fillMcMatchGen3Prong(TMcParticles const& mcParticles, + TMcParticlesPerColl const& mcParticlesPerMcColl, + TCursor& rowMcMatchGen, + const bool rejectBackground, + std::vector const& pdgMothersCorrelBkg = {}) { using namespace o2::constants::physics; using namespace o2::hf_decay::hf_cand_3prong; @@ -157,7 +165,7 @@ void fillMcMatchGen3Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V if (std::abs(particle.pdgCode()) != pdgMother) { continue; // Skip if the particle PDG code does not match the mother PDG code } - auto finalStates = getDecayChannelsMain(pdgMother); + const auto finalStates = getDecayChannelsMain(pdgMother); constexpr int DepthMainMax = 2; // Depth for final state matching constexpr int DepthResoMax = 1; // Depth for resonant decay matching @@ -307,8 +315,8 @@ void fillMcMatchGen3Prong(T const& mcParticles, U const& mcParticlesPerMcColl, V } } -template -void fillMcMatchGenBplus(T const& mcParticles, U& rowMcMatchGen) +template +void fillMcMatchGenBplus(TMcParticles const& mcParticles, TCursor& rowMcMatchGen) { using namespace o2::constants::physics; using namespace o2::hf_decay::hf_cand_beauty; @@ -340,8 +348,8 @@ void fillMcMatchGenBplus(T const& mcParticles, U& rowMcMatchGen) } // B candidate } -template -void fillMcMatchGenB0(T const& mcParticles, U& rowMcMatchGen) +template +void fillMcMatchGenB0(TMcParticles const& mcParticles, TCursor& rowMcMatchGen) { using namespace o2::constants::physics; using namespace o2::hf_decay::hf_cand_beauty; diff --git a/PWGHF/Utils/utilsPid.h b/PWGHF/Utils/utilsPid.h index 4590bb50b2c..bc5024daf75 100644 --- a/PWGHF/Utils/utilsPid.h +++ b/PWGHF/Utils/utilsPid.h @@ -44,40 +44,40 @@ enum PidMethod { /// Function to combine TPC and TOF NSigma /// \param tiny switch between full and tiny (binned) PID tables -/// \param tpcNSigma is the (binned) NSigma separation in TPC (if tiny = true) -/// \param tofNSigma is the (binned) NSigma separation in TOF (if tiny = true) +/// \param nSigmaTpc is the (binned) NSigma separation in TPC (if tiny = true) +/// \param nSigmaTof is the (binned) NSigma separation in TOF (if tiny = true) /// \return combined NSigma of TPC and TOF -template -T1 combineNSigma(T1 tpcNSigma, T1 tofNSigma) +template +TNumber combineNSigma(TNumber nSigmaTpc, TNumber nSigmaTof) { static constexpr float DefaultNSigmaTolerance = .1f; static constexpr float DefaultNSigma = -999.f + DefaultNSigmaTolerance; // -999.f is the default value set in TPCPIDResponse.h and PIDTOF.h if constexpr (tiny) { - tpcNSigma *= aod::pidtpc_tiny::binning::bin_width; - tofNSigma *= aod::pidtof_tiny::binning::bin_width; + nSigmaTpc *= aod::pidtpc_tiny::binning::bin_width; + nSigmaTof *= aod::pidtof_tiny::binning::bin_width; } - if ((tpcNSigma > DefaultNSigma) && (tofNSigma > DefaultNSigma)) { // TPC and TOF - return std::sqrt(.5f * (tpcNSigma * tpcNSigma + tofNSigma * tofNSigma)); + if ((nSigmaTpc > DefaultNSigma) && (nSigmaTof > DefaultNSigma)) { // TPC and TOF + return std::sqrt(.5f * (nSigmaTpc * nSigmaTpc + nSigmaTof * nSigmaTof)); } - if (tpcNSigma > DefaultNSigma) { // only TPC - return std::abs(tpcNSigma); + if (nSigmaTpc > DefaultNSigma) { // only TPC + return std::abs(nSigmaTpc); } - if (tofNSigma > DefaultNSigma) { // only TOF - return std::abs(tofNSigma); + if (nSigmaTof > DefaultNSigma) { // only TOF + return std::abs(nSigmaTof); } - return tofNSigma; // no TPC nor TOF + return nSigmaTof; // no TPC nor TOF } -/// @brief Function to fill tables with HF prong PID information -/// @tparam TRK datatype of the prong track -/// @tparam ROW datatype of the prong PID table to fill -/// @tparam specPid particle species -/// @param track prong track -/// @param rowPid cursor of the prong PID table to fill -template -void fillProngPid(TRK const& track, ROW& rowPid) +/// \brief Function to fill tables with HF prong PID information +/// \tparam specPid particle species +/// \tparam TTrack datatype of the prong track +/// \tparam TCursor datatype of the cursor of the prong PID table to fill +/// \param track prong track +/// \param rowPid cursor of the prong PID table to fill +template +void fillProngPid(TTrack const& track, TCursor& rowPid) { // get PID information for the daughter tracks diff --git a/PWGHF/Utils/utilsTrkCandHf.h b/PWGHF/Utils/utilsTrkCandHf.h index 43db7a21e08..295b8fb7538 100644 --- a/PWGHF/Utils/utilsTrkCandHf.h +++ b/PWGHF/Utils/utilsTrkCandHf.h @@ -22,6 +22,7 @@ #include +#include #include namespace o2::hf_trkcandsel @@ -36,10 +37,10 @@ enum SVFitting { o2::framework::AxisSpec axisCands = {SVFitting::NCases, -0.5f, static_cast(SVFitting::NCases) - 0.5f, ""}; -/// @brief Function to put labels on candidate monitoring histogram +/// \brief Function to put labels on candidate monitoring histogram /// \param hCandidates is the histogram -template -void setLabelHistoCands(Histo& hCandidates) +template +void setLabelHistoCands(THisto& hCandidates) { hCandidates->SetTitle("HF candidate counter;;candidates"); hCandidates->GetXaxis()->SetBinLabel(SVFitting::BeforeFit + 1, "Before secondary vertexing"); @@ -47,16 +48,15 @@ void setLabelHistoCands(Histo& hCandidates) hCandidates->GetXaxis()->SetBinLabel(SVFitting::Fail + 1, "Run-time error in secondary vertexing"); } -/// @brief Function to evaluate number of ones in a binary representation of the argument +/// \brief Function to evaluate number of ones in a binary representation of the argument /// \param num is the input argument -int countOnesInBinary(uint8_t num) +int countOnesInBinary(const uint8_t num) { - int count = 0; - - for (int iBit = 0; iBit < 8; iBit++) { + int count{0}; + constexpr std::size_t NBits{8u}; + for (std::size_t iBit{0u}; iBit < NBits; iBit++) { count += TESTBIT(num, iBit); } - return count; } @@ -66,10 +66,13 @@ int countOnesInBinary(uint8_t num) /// \param binsPtTrack is the array of pt bins for track selection /// \param cutsTrackDCA are the cuts for track DCA selection /// \return true if track passes all cuts -template -bool isSelectedTrackDCA(const T1& trackPar, const T2& dca, const C1& binsPtTrack, const C2& cutsTrackDCA) +template +bool isSelectedTrackDCA(TTrackPar const& trackPar, + TArrayDca const& dca, + TArrayPt const& binsPtTrack, + TArrayCuts const& cutsTrackDCA) { - auto binPtTrack = o2::analysis::findBin(binsPtTrack, trackPar.getPt()); + const auto binPtTrack = o2::analysis::findBin(binsPtTrack, trackPar.getPt()); if (binPtTrack == -1) { return false; }