Skip to content

[PWGHF] Add 3-prong combinatorics with ML-based single-track selection - #17878

Open
fchinu wants to merge 3 commits into
AliceO2Group:masterfrom
fchinu:ml-based-track-selector
Open

[PWGHF] Add 3-prong combinatorics with ML-based single-track selection#17878
fchinu wants to merge 3 commits into
AliceO2Group:masterfrom
fchinu:ml-based-track-selector

Conversation

@fchinu

@fchinu fchinu commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

This PR adds a simple workflow, similar to the trackIndexSkimCreator (TISC), that runs the combinatorics for Ds and D+ mesons (at the moment only these two are supported) using a ML model to select tracks before the combinatorics.

The ML I used to test this PR is a multiclass BDT which distinguishes background tracks from signal pions/kaons. Two separate models are trained for D+ -> piKpi and Ds -> phi pi -> KKPi.
The idea would be to get a faster and more efficient TISC by pruning the amount of tracks to be processed in the combinatorics. In the TISC, all tracks passing the selections are considered for the combinatorics. Here, I only loop on tracks that satisfy a given hypothesis for a given decay: for example, for the D+, I only loop on tracks passing the BDT selection for 1) D+ pions, 2) D+ kaons and 3) D+ pions again.

Testing on MC (LHC25a5) for central PbPb collisions, this leads to a sizable improvement as compared to the TISC (which was ran enabling only Ds and D+ candidates), both in terms of efficiency:

generated TISC matched TISC eff. (%) ML matched ML eff. (%) ML/TISC
D+ inclusive 7 695 28 0.364 53 0.689 1.89
D+ prompt 4 387 21 0.479 35 0.798 1.67
D+ non-prompt 3 308 7 0.212 18 0.544 2.57
Ds inclusive 3 966 27 0.681 39 0.983 1.44
Ds prompt 1 366 7 0.512 10 0.732 1.43
Ds non-prompt 2 600 20 0.769 29 1.115 1.45

Of number of candidates:

TISC ML ML/TISC
candidates 99 439 71 408 0.72
D+ candidates 69 114 57 002 0.82
Ds candidates 33 200 15 502 0.47
candidates flagged both D+ and Ds 2 875 1 096 0.38

And of CPU:

TISC ML ML/TISC
wall time 5 794 s 1 122 s 0.19
CPU, whole pipeline 7 694 s 3 126 s 0.41

Further tests would be needed before considering using this workflow at analysis level.

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown

O2 linter results: ❌ 0 errors, ⚠️ 0 warnings, 🔕 2 disabled

@github-actions github-actions Bot changed the title Add 3-prong combinatorics with ML-based single-track selection [PWGHF] Add 3-prong combinatorics with ML-based single-track selection Sep 11, 2026
@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/o2 for 23ad41b at 2026-09-11 14:35:

## sw/BUILD/O2Physics-latest/log
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:460:157: error: arithmetic between enumeration type 'TrackTimingStep' and floating-point type 'float' is deprecated [-Werror=deprecated-enum-float-conversion]
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:840:144: error: arithmetic between enumeration type 'TimingStep' and floating-point type 'float' is deprecated [-Werror=deprecated-enum-float-conversion]
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:846:150: error: arithmetic between enumeration type 'LoopCounter' and floating-point type 'float' is deprecated [-Werror=deprecated-enum-float-conversion]
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/PWGHF/Utils/utilsEvSelHf.h:408:36: error: 'const struct o2::soa::Table<o2::aod::Hash<519320931>, o2::aod::Hash<1837103245>, o2::aod::Hash<519320931>, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<1174303634>, o2::aod::Hash<1219172363>, o2::aod::Hash<2286545062> > >::TableIteratorBase<o2::soa::DefaultIndexPolicy, o2::soa::Join<o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<1174303634>, o2::aod::Hash<1219172363>, o2::aod::Hash<2286545062> > >, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<1174303634>, o2::aod::Hash<1219172363>, o2::aod::Hash<2286545062> > >' has no member named 'isInelGt0'
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/PWGHF/Utils/utilsEvSelHf.h:408:36: error: 'const struct o2::soa::Table<o2::aod::Hash<519320931>, o2::aod::Hash<1837103245>, o2::aod::Hash<519320931>, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<2009600272>, o2::aod::Hash<1261423717>, o2::aod::Hash<2286545062> > >::TableIteratorBase<o2::soa::DefaultIndexPolicy, o2::soa::Join<o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<2009600272>, o2::aod::Hash<1261423717>, o2::aod::Hash<2286545062> > >, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<2009600272>, o2::aod::Hash<1261423717>, o2::aod::Hash<2286545062> > >' has no member named 'isInelGt0'
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/PWGHF/Utils/utilsEvSelHf.h:408:36: error: 'const struct o2::soa::Table<o2::aod::Hash<519320931>, o2::aod::Hash<1837103245>, o2::aod::Hash<519320931>, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<3914022046>, o2::aod::Hash<1102176623>, o2::aod::Hash<2286545062> > >::TableIteratorBase<o2::soa::DefaultIndexPolicy, o2::soa::Join<o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<3914022046>, o2::aod::Hash<1102176623>, o2::aod::Hash<2286545062> > >, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<3914022046>, o2::aod::Hash<1102176623>, o2::aod::Hash<2286545062> > >' has no member named 'isInelGt0'
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/PWGHF/Utils/utilsEvSelHf.h:408:36: error: 'const struct o2::soa::Table<o2::aod::Hash<519320931>, o2::aod::Hash<1837103245>, o2::aod::Hash<519320931>, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<4025989913>, o2::aod::Hash<845892459>, o2::aod::Hash<2286545062> > >::TableIteratorBase<o2::soa::DefaultIndexPolicy, o2::soa::Join<o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<4025989913>, o2::aod::Hash<845892459>, o2::aod::Hash<2286545062> > >, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<4025989913>, o2::aod::Hash<845892459>, o2::aod::Hash<2286545062> > >' has no member named 'isInelGt0'
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/PWGHF/Utils/utilsEvSelHf.h:408:36: error: 'const struct o2::soa::Table<o2::aod::Hash<519320931>, o2::aod::Hash<1837103245>, o2::aod::Hash<519320931>, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> > >::TableIteratorBase<o2::soa::DefaultIndexPolicy, o2::soa::Join<o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> > >, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >, o2::soa::Table<o2::aod::Hash<254116537>, o2::aod::Hash<3484684091>, o2::aod::Hash<2286545062> > >' has no member named 'isInelGt0'
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/PWGHF/Utils/utilsEvSelHf.h:408:36: error: 'const struct o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> >::TableIteratorBase<o2::soa::DefaultIndexPolicy, o2::soa::Table<o2::aod::Hash<1373761118>, o2::aod::Hash<4191360419>, o2::aod::Hash<2286545062> > >' has no member named 'isInelGt0'
ninja: build stopped: subcommand failed.

Full log here.

@fchinu
fchinu marked this pull request as draft September 11, 2026 12:36
@fchinu
fchinu marked this pull request as ready for review September 11, 2026 13:13
@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for c024fc4 at 2026-09-11 15:44:

## sw/BUILD/O2Physics-code-check-latest/log
--
========== List of issues found ==========
++ echo 'Found 3 errors and 22 warnings.'
Found 3 errors and 22 warnings.
++ [[ 3 -gt 0 ]]
++ cat /sw/BUILD/5816e278e75ada6393fc90b680ad55115fde5d92/O2Physics-code-check/errors.txt
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:191:41: error: no header providing "std::distance" is directly included [misc-include-cleaner,-warnings-as-errors]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:398:40: error: no header providing "std::size_t" is directly included [misc-include-cleaner,-warnings-as-errors]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:461:35: error: no header providing "TH1" is directly included [misc-include-cleaner,-warnings-as-errors]
++ [[ 22 -gt 0 ]]
++ cat /sw/BUILD/5816e278e75ada6393fc90b680ad55115fde5d92/O2Physics-code-check/warnings.txt
PWGHF/Core/HfMlResponseHfTracks.h:38:9: warning: function-like macro 'CHECK_AND_FILL_VEC_HF_TRACK' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]
PWGHF/Core/HfMlResponseHfTracks.h:138:3: warning: function 'getModelBin' should be marked [[nodiscard]] [modernize-use-nodiscard]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:118:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:183:43: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:183:72: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:183:101: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:183:130: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:183:159: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:183:177: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:183:197: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:189:42: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:189:55: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:190:25: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:191:50: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:339:41: warning: initializer for member 'response' is redundant [readability-redundant-member-init]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:423:43: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:423:60: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:732:78: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:735:70: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:988:9: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:1103:5: warning: uninitialized record type: 'whichHypo3Prong' [cppcoreguidelines-pro-type-member-init]
PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx:1252:13: warning: empty catch statements hide issues; to handle exceptions appropriately, consider re-throwing, handling, or avoiding catch altogether [bugprone-empty-catch]
++ [[ 3 -gt 0 ]]
++ exit 1
--

Full log here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pwghf PWG-HF

Development

Successfully merging this pull request may close these issues.

2 participants