Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 42 additions & 43 deletions PWGHF/D2H/TableProducer/dplusCombinatorics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
#include "Common/DataModel/Multiplicity.h"
#include "Common/DataModel/PIDResponseTPC.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include "Tools/ML/MlResponse.h"

#include <CCDB/BasicCCDBManager.h>
Expand Down Expand Up @@ -126,7 +125,7 @@ DECLARE_SOA_COLUMN(ScorePionDzero, scorePionDzero, float); //! ML score, pion-fr
DECLARE_SOA_COLUMN(ScoreKaonDzero, scoreKaonDzero, float); //! ML score, kaon-from-D0 class
DECLARE_SOA_COLUMN(IsSelPionDzero, isSelPionDzero, bool); //! passes the D0 pion-score threshold
DECLARE_SOA_COLUMN(IsSelKaonDzero, isSelKaonDzero, bool); //! passes the D0 kaon-score threshold
// D+ -> K pi pi model
// D+ -> K pi pi model
DECLARE_SOA_COLUMN(ScoreBkgDplus, scoreBkgDplus, float); //! ML score, background class
DECLARE_SOA_COLUMN(ScorePionDplus, scorePionDplus, float); //! ML score, pion-from-D+ class
DECLARE_SOA_COLUMN(ScoreKaonDplus, scoreKaonDplus, float); //! ML score, kaon-from-D+ class
Expand All @@ -145,8 +144,8 @@ DECLARE_SOA_COLUMN(ScoreKaonDstar, scoreKaonDstar, float); //! ML score, kaon-fr
DECLARE_SOA_COLUMN(IsSelPionDstar, isSelPionDstar, bool); //! passes the D* pion-score threshold
DECLARE_SOA_COLUMN(IsSelKaonDstar, isSelKaonDstar, bool); //! passes the D* kaon-score threshold
// common
DECLARE_SOA_COLUMN(IsPositive, isPositive, bool); //! charge sign of the track
DECLARE_SOA_COLUMN(IsSelAny, isSelAny, bool); //! passes at least one of the four selections
DECLARE_SOA_COLUMN(IsPositive, isPositive, bool); //! charge sign of the track
DECLARE_SOA_COLUMN(IsSelAny, isSelAny, bool); //! passes at least one of the four selections
} // namespace hf_skim_track_sel

DECLARE_SOA_TABLE(HfSkimTrackSels, "AOD", "HFSKIMTRKSEL", //! Track-level ML selection, aligned with aod::TrackAssoc
Expand Down Expand Up @@ -176,15 +175,15 @@ DECLARE_SOA_TABLE(HfSkimTrackSels, "AOD", "HFSKIMTRKSEL", //! Track-level ML sel
namespace hf_skim_track_sel_mask
{
DECLARE_SOA_COLUMN(CollIdx, collIdx, int); //! global index of the collision the association refers to
DECLARE_SOA_COLUMN(SelMask, selMask, uint16_t); //! bit0 -> pi(D0)
//! bit1 -> K(D0)
//! bit2 -> pi(D+)
//! bit3 -> K(D+)
//! bit4 -> pi(Ds)
//! bit5 -> K(Ds)
//! bit6 -> pi(D*)
//! bit7 -> K(D*)
//! bit8 -> positive charge
DECLARE_SOA_COLUMN(SelMask, selMask, uint16_t); //! bit0 -> pi(D0)
//! bit1 -> K(D0)
//! bit2 -> pi(D+)
//! bit3 -> K(D+)
//! bit4 -> pi(Ds)
//! bit5 -> K(Ds)
//! bit6 -> pi(D*)
//! bit7 -> K(D*)
//! bit8 -> positive charge
} // namespace hf_skim_track_sel_mask

/// One row per *selected* (track, collision) association. This is the smallest object from which
Expand All @@ -198,32 +197,32 @@ DECLARE_SOA_TABLE(HfSkimTrackMasks, "AOD", "HFSKIMTRKMASK", //! Compact dump of
namespace hf_skim_track_train
{
// features
DECLARE_SOA_COLUMN(Pt, pt, float); //!
DECLARE_SOA_COLUMN(Eta, eta, float); //!
DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //!
DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //!
DECLARE_SOA_COLUMN(SigmaDcaXY, sigmaDcaXY, float); //!
DECLARE_SOA_COLUMN(SigmaDcaZ, sigmaDcaZ, float); //!
DECLARE_SOA_COLUMN(NormDcaXY, normDcaXY, float); //!
DECLARE_SOA_COLUMN(NormDcaZ, normDcaZ, float); //!
DECLARE_SOA_COLUMN(Signed1Pt, signed1Pt, float); //!
DECLARE_SOA_COLUMN(Tgl, tgl, float); //!
DECLARE_SOA_COLUMN(Sign, sign, float); //!
DECLARE_SOA_COLUMN(IsPvContributor, isPvContributor, float); //!
DECLARE_SOA_COLUMN(ItsNCls, itsNCls, float); //!
DECLARE_SOA_COLUMN(ItsNClsInnerBarrel, itsNClsInnerBarrel, float); //!
DECLARE_SOA_COLUMN(ItsChi2NCl, itsChi2NCl, float); //!
DECLARE_SOA_COLUMN(TpcNClsFound, tpcNClsFound, float); //!
DECLARE_SOA_COLUMN(TpcNClsCrossedRows, tpcNClsCrossedRows, float); //!
DECLARE_SOA_COLUMN(Pt, pt, float); //!
DECLARE_SOA_COLUMN(Eta, eta, float); //!
DECLARE_SOA_COLUMN(DcaXY, dcaXY, float); //!
DECLARE_SOA_COLUMN(DcaZ, dcaZ, float); //!
DECLARE_SOA_COLUMN(SigmaDcaXY, sigmaDcaXY, float); //!
DECLARE_SOA_COLUMN(SigmaDcaZ, sigmaDcaZ, float); //!
DECLARE_SOA_COLUMN(NormDcaXY, normDcaXY, float); //!
DECLARE_SOA_COLUMN(NormDcaZ, normDcaZ, float); //!
DECLARE_SOA_COLUMN(Signed1Pt, signed1Pt, float); //!
DECLARE_SOA_COLUMN(Tgl, tgl, float); //!
DECLARE_SOA_COLUMN(Sign, sign, float); //!
DECLARE_SOA_COLUMN(IsPvContributor, isPvContributor, float); //!
DECLARE_SOA_COLUMN(ItsNCls, itsNCls, float); //!
DECLARE_SOA_COLUMN(ItsNClsInnerBarrel, itsNClsInnerBarrel, float); //!
DECLARE_SOA_COLUMN(ItsChi2NCl, itsChi2NCl, float); //!
DECLARE_SOA_COLUMN(TpcNClsFound, tpcNClsFound, float); //!
DECLARE_SOA_COLUMN(TpcNClsCrossedRows, tpcNClsCrossedRows, float); //!
DECLARE_SOA_COLUMN(TpcCrossedRowsOverFindableCls, tpcCrossedRowsOverFindableCls, float); //!
DECLARE_SOA_COLUMN(TpcChi2NCl, tpcChi2NCl, float); //!
DECLARE_SOA_COLUMN(TpcFractionSharedCls, tpcFractionSharedCls, float); //!
DECLARE_SOA_COLUMN(TpcNSigmaPi, tpcNSigmaPi, float); //!
DECLARE_SOA_COLUMN(TpcNSigmaKa, tpcNSigmaKa, float); //!
DECLARE_SOA_COLUMN(Centrality, centrality, float); //!
DECLARE_SOA_COLUMN(TpcChi2NCl, tpcChi2NCl, float); //!
DECLARE_SOA_COLUMN(TpcFractionSharedCls, tpcFractionSharedCls, float); //!
DECLARE_SOA_COLUMN(TpcNSigmaPi, tpcNSigmaPi, float); //!
DECLARE_SOA_COLUMN(TpcNSigmaKa, tpcNSigmaKa, float); //!
DECLARE_SOA_COLUMN(Centrality, centrality, float); //!
// labels and auxiliary information, not meant to be used as features
DECLARE_SOA_COLUMN(TrackIndex, trackIndex, int64_t); //! global index of the track: the same track can be associated to several collisions, and therefore appear more than once, so the train/test split has to group by it
DECLARE_SOA_COLUMN(McMask, mcMask, uint16_t); //! MC label quality mask (bit 15 = fake track)
DECLARE_SOA_COLUMN(TrackIndex, trackIndex, int64_t); //! global index of the track: the same track can be associated to several collisions, and therefore appear more than once, so the train/test split has to group by it
DECLARE_SOA_COLUMN(McMask, mcMask, uint16_t); //! MC label quality mask (bit 15 = fake track)
DECLARE_SOA_COLUMN(HasCharmBeautyAncestor, hasCharmBeautyAncestor, bool); //! any charm/beauty hadron in the ancestry
// Selection outcomes
DECLARE_SOA_COLUMN(Label, label, int8_t); //! D+ model: -1 = not usable, 0 = bkg, 1 = pion from D+, 2 = kaon from D+
Expand Down Expand Up @@ -291,7 +290,7 @@ constexpr int NPionsDstarToD0Pi = 1;
/// Resonant sub-channels recorded next to the training label, so that the signal definition can be
/// narrowed offline without re-running the workflow.
enum Channels : int {
kNone = -1, ///< no mother found, or mother not in the list of interest
kNone = -1, ///< no mother found, or mother not in the list of interest
kDzeroDirect,
kDplusDirect,
kDplusKstar,
Expand Down Expand Up @@ -408,11 +407,11 @@ enum HfAncestryWalkOutcome : int {
/// Counter bins of hf-dplus-combinatorics.
enum CounterCombinatorics : int {
CountCollisions = 0,
CountTriplets, ///< triplets whose hypothesis mask is non-empty, i.e. reaching the preselection
CountTripletsPresel,///< triplets passing the mass/pT preselection, i.e. reaching the 3-prong fitter
CountTriplets, ///< triplets whose hypothesis mask is non-empty, i.e. reaching the preselection
CountTripletsPresel, ///< triplets passing the mass/pT preselection, i.e. reaching the 3-prong fitter
CountFit2Prong,
CountFit3Prong,
CountRows, ///< rows written to aod::Hf3Prongs
CountRows, ///< rows written to aod::Hf3Prongs
CountRowsDplus,
CountRowsDs,
CountRowsBoth,
Expand Down Expand Up @@ -1505,8 +1504,8 @@ struct HfDplusTrackSelMl {
int pdgMother{-1};
int8_t isPrompt{-1}, channel{Channels::kNone};
const int8_t label = getTrainingLabel(
track, mcParticles, pdgMother, keepIfBackground,
pt, isPrompt, channel);
track, mcParticles, pdgMother, keepIfBackground,
pt, isPrompt, channel);

if (label < 0) { // usable for neither model
continue;
Expand Down
48 changes: 25 additions & 23 deletions PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,21 @@ constexpr int NMassHypos = 2; // mass hypotheses per channel, i.e. the two order
/// The ordering of the channels should strictly follow Channels2Prong
constexpr TrackMlRole trackRoles2Prongs[NChannels2Prong][NMassHypos][N2Prongs] = {
{
{RolePionD0, RoleKaonD0}, // D0 → π± K∓
{RoleKaonD0, RolePionD0} // D0 → π± K∓
}
};
{RolePionD0, RoleKaonD0}, // D0 → π± K∓
{RoleKaonD0, RolePionD0} // D0 → π± K∓
}};

/// Role of each track in the candidate, per channel and mass hypothesis.
/// The ordering of the channels should strictly follow Channels3Prong
constexpr TrackMlRole trackRoles3Prongs[NChannels3Prong][NMassHypos][N3Prongs] = {
{
{RolePionDplus, RoleKaonDplus, RolePionDplus}, // D± → π± K∓ π±
{RolePionDplus, RoleKaonDplus, RolePionDplus} // D± → π± K∓ π± (swapped, no effect for D+)
{RolePionDplus, RoleKaonDplus, RolePionDplus}, // D± → π± K∓ π±
{RolePionDplus, RoleKaonDplus, RolePionDplus} // D± → π± K∓ π± (swapped, no effect for D+)
},
{
{RoleKaonDs, RoleKaonDs, RolePionDs}, // D_s± → K± K∓ π±
{RolePionDs, RoleKaonDs, RoleKaonDs} // D_s± → K± K∓ π± (swapped)
}
};
}};

constexpr double PtMaxModel = 1.e10;

Expand Down Expand Up @@ -439,7 +437,7 @@ struct HfTrackSelectorTagSelTracks {
/// \param features are the input feature names, in the order the model expects
/// \param thrPion, thrKaon are the score thresholds
/// \param name is used in the log message
template<bool IsBinaryModel = false>
template <bool IsBinaryModel = false>
void configureModel(HfTrackModel& model,
std::string const& onnxFile,
std::string const& ccdbPath,
Expand Down Expand Up @@ -485,15 +483,15 @@ struct HfTrackSelectorTagSelTracks {

if (config.applyMlD0) {
configureModel<false>(models2Prong[ChannelD0ToPiK], config.onnxFileNameD0, config.mlModelPathCcdbD0, config.inputFeaturesD0,
config.thresholdScorePionD0, config.thresholdScoreKaonD0, "D0 track model");
config.thresholdScorePionD0, config.thresholdScoreKaonD0, "D0 track model");
}
if (config.applyMlDplus) {
configureModel<false>(models3Prong[ChannelDplusToPiKPi], config.onnxFileNameDplus, config.mlModelPathCcdbDplus, config.inputFeaturesDplus,
config.thresholdScorePionDplus, config.thresholdScoreKaonDplus, "D+ track model");
config.thresholdScorePionDplus, config.thresholdScoreKaonDplus, "D+ track model");
}
if (config.applyMlDs) {
configureModel<false>(models3Prong[ChannelDsToKKPi], config.onnxFileNameDs, config.mlModelPathCcdbDs, config.inputFeaturesDs,
config.thresholdScorePionDs, config.thresholdScoreKaonDs, "Ds track model");
config.thresholdScorePionDs, config.thresholdScoreKaonDs, "Ds track model");
}
if (config.applyMlDstar) {
double thresholdScoreKaonDstar = 0; // D* model has no kaon score, but the configureModel() function expects a value
Expand Down Expand Up @@ -614,7 +612,7 @@ struct HfTrackSelectorTagSelTracks {
/// \param scores is filled with (background, pion-role, kaon-role); -1 if not evaluated
/// \param isSelPion, isSelKaon are filled with the threshold decisions
/// \return true if the model was actually evaluated
template<size_t NClasses>
template <size_t NClasses>
bool evaluateModel(HfTrackModel& model, HfTrackMlFeatures const& features,
std::array<float, NClasses>& scores, bool& isSelPion, bool& isSelKaon)
{
Expand Down Expand Up @@ -921,7 +919,7 @@ struct HfMlBasedTrackSelector {
struct HfProngCandidate {
o2::track::TrackParCov parCov;
std::array<float, 3> pVec{};
std::array<float, 2> dcaInfo{}; ///< DCA (xy, z) to the primary vertex
std::array<float, 2> dcaInfo{}; ///< DCA (xy, z) to the primary vertex
uint32_t mask{}; ///< aod::HfSelTrack::isIdentifiedPid
int64_t globalIndex{}; ///< index in the track table, written to the skim
};
Expand Down Expand Up @@ -953,9 +951,9 @@ struct HfMlBasedTrackSelector {
// filter collisions
Filter filterSelectCollisions = (aod::hf_sel_collision::whyRejectColl == static_cast<o2::hf_evsel::HfCollisionRejectionMask>(0));
// filter track indices
Filter filterSelectTrackIds = ( (aod::hf_sel_track::isSelProng & static_cast<uint32_t>(BIT(CandidateType::Cand2Prong))) != 0u ||
(aod::hf_sel_track::isSelProng & static_cast<uint32_t>(BIT(CandidateType::Cand3Prong))) != 0u ||
(aod::hf_sel_track::isSelProng & static_cast<uint32_t>(BIT(CandidateType::CandDstar))) != 0u );
Filter filterSelectTrackIds = ((aod::hf_sel_track::isSelProng & static_cast<uint32_t>(BIT(CandidateType::Cand2Prong))) != 0u ||
(aod::hf_sel_track::isSelProng & static_cast<uint32_t>(BIT(CandidateType::Cand3Prong))) != 0u ||
(aod::hf_sel_track::isSelProng & static_cast<uint32_t>(BIT(CandidateType::CandDstar))) != 0u);

Preslice<FilteredTrackAssocSel> trackIndicesPerCollision = aod::track_association::collisionId;

Expand Down Expand Up @@ -1702,7 +1700,7 @@ struct HfMlBasedTrackSelector {
}

// D* -> D0 pi+ candidates
const auto tStartDstar = tickIf(doTiming);
const auto tStartDstar = tickIf(doTiming);
if (storeDstar &&
lastFilledD0 != rowTrackIndexProng2.lastIndex()) { // we have a new D0 candidate, so we can try to form a D* candidate

Expand Down Expand Up @@ -1747,8 +1745,12 @@ struct HfMlBasedTrackSelector {
timing[TimeProcessDstar] += elapsedSeconds(tStartDstar);
}

if (!config.do3Prongs) { continue; }
if (!canBe3Prong) { continue; }
if (!config.do3Prongs) {
continue;
}
if (!canBe3Prong) {
continue;
}
if (!isTwoProngVtxGoodFor3Prongs) {
++counters[CountPairsRejected2P];
continue;
Expand All @@ -1761,9 +1763,9 @@ struct HfMlBasedTrackSelector {
}
++counters[CountTripletsEnumerated];
processTriplet(collision, prong1.parCov, prongOpp.parCov, prong2.parCov,
prong1.pVec, prongOpp.pVec, prong2.pVec,
prong1.mask, prongOpp.mask, prong2.mask,
prong1.globalIndex, prongOpp.globalIndex, prong2.globalIndex);
prong1.pVec, prongOpp.pVec, prong2.pVec,
prong1.mask, prongOpp.mask, prong2.mask,
prong1.globalIndex, prongOpp.globalIndex, prong2.globalIndex);
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions PWGHF/TableProducer/candidateCreatorDstar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -394,24 +394,24 @@ struct HfCandidateCreatorDstar {
massDstar = RecoDecay::m(std::array{std::array{pVecSoftPi[0], pVecSoftPi[1], pVecSoftPi[2]},
std::array{pVecD0Prong0[0], pVecD0Prong0[1], pVecD0Prong0[2]},
std::array{pVecD0Prong1[0], pVecD0Prong1[1], pVecD0Prong1[2]}},
std::array{constants::physics::MassPiPlus,
constants::physics::MassPiPlus,
constants::physics::MassKPlus});
std::array{constants::physics::MassPiPlus,
constants::physics::MassPiPlus,
constants::physics::MassKPlus});
massD0 = RecoDecay::m(std::array{std::array{pVecD0Prong0[0], pVecD0Prong0[1], pVecD0Prong0[2]},
std::array{pVecD0Prong1[0], pVecD0Prong1[1], pVecD0Prong1[2]}},
std::array{constants::physics::MassPiPlus,
constants::physics::MassKPlus});
std::array{constants::physics::MassPiPlus,
constants::physics::MassKPlus});
} else {
massDstar = RecoDecay::m(std::array{std::array{pVecSoftPi[0], pVecSoftPi[1], pVecSoftPi[2]},
std::array{pVecD0Prong0[0], pVecD0Prong0[1], pVecD0Prong0[2]},
std::array{pVecD0Prong1[0], pVecD0Prong1[1], pVecD0Prong1[2]}},
std::array{constants::physics::MassPiPlus,
constants::physics::MassKPlus,
constants::physics::MassPiPlus});
std::array{constants::physics::MassPiPlus,
constants::physics::MassKPlus,
constants::physics::MassPiPlus});
massD0 = RecoDecay::m(std::array{std::array{pVecD0Prong0[0], pVecD0Prong0[1], pVecD0Prong0[2]},
std::array{pVecD0Prong1[0], pVecD0Prong1[1], pVecD0Prong1[2]}},
std::array{constants::physics::MassKPlus,
constants::physics::MassPiPlus});
std::array{constants::physics::MassKPlus,
constants::physics::MassPiPlus});
}
auto deltaMass = std::abs(massDstar - massD0);
registry.fill(HIST("QA/hDeltaMassDStar"), deltaMass);
Expand Down
Loading