Skip to content

[Tools] Add PID feature extractor and ONNX inference tasks - #17419

Merged
dsekihat merged 17 commits into
AliceO2Group:masterfrom
forynski:my-local-pid-branch-fresh
Aug 13, 2026
Merged

[Tools] Add PID feature extractor and ONNX inference tasks#17419
dsekihat merged 17 commits into
AliceO2Group:masterfrom
forynski:my-local-pid-branch-fresh

Conversation

@forynski

Copy link
Copy Markdown
Contributor

Adds two new tasks under Tools/PIDFeatureExtractor/:

  • pidFeatureExtractor.cxx: extracts a 34-feature / 7-detector-group PID
    feature set (TPC, TOF, TRD, ITS, EMCal, HMPID, centrality) from AO2D
    data for both MC (reconstructed + truth) and real/raw data, writing a
    ROOT TTree (and optionally CSV). Includes optional DPG-style track
    cuts (off by default) and an optional Bayesian PID posterior for
    comparison against the ML model.

  • pidOnnxInference.cxx: runs a trained ONNX model over the extractor's
    output and writes per-track class probabilities, using
    o2::analysis::MlResponse (Tools/ML) for CCDB/local model loading.

Notes for reviewers:

  • pidFeatureExtractor.cxx writes a plain TFile/TTree rather than an AOD
    table (DECLARE_SOA_TABLE/Produces<>). This is deliberate: two
    Produces<> tables sharing a column prefix in one struct triggered a
    reproducible compile failure against the current O2 build
    (ASoA.h/MetadataTrait constraint errors). Manual ROOT I/O avoids it.
  • pidOnnxInference.cxx is a plain DataProcessorSpec, not an
    AnalysisTask - it has no AOD subscription (it reads the extractor's
    output file directly), and runs standalone after the extractor
    rather than chained in the same pipeline.
  • The model's expected input feature order (in pidOnnxInference.cxx) is
    a reasonable default but not yet verified against the actual training
    code - flagged in the README.
  • modelPathsCcdb currently holds a placeholder CCDB path; needs a real
    location once the model is deployed.

See README.md in the new folder for full usage and configuration
details.

@github-actions github-actions Bot added the tools label Aug 11, 2026
@github-actions github-actions Bot changed the title Tools: Add PID feature extractor and ONNX inference tasks [Tools] Add PID feature extractor and ONNX inference tasks Aug 11, 2026
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

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

ktf
ktf previously approved these changes Aug 12, 2026

@ktf ktf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to be able to run tests.

@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/staging for c662104 at 2026-08-12 14:14:

## sw/BUILD/O2Physics-latest/log
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/Tools/PIDFeatureExtractor/pidOnnxInference.cxx:317:46: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'const int'
/sw/slc9_x86-64/O2/daily-20260812-0000-local1/include/Framework/StructToTuple.h:61:38: error: static assertion failed: You need to make sure that you have implicit constructors or that you call the explicit constructor correctly.
/sw/slc9_x86-64/GCC-Toolchain/v14.2.0-alice2-1/include/c++/14.2.0/bits/stl_construct.h:115:28: error: no matching function for call to 'construct_at(PidOnnxInference*&)'
ninja: build stopped: subcommand failed.

Full log here.

@ktf
ktf self-requested a review August 12, 2026 14:28
@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for c662104 at 2026-08-12 16:29:

## sw/BUILD/O2Physics-latest/log
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/Tools/PIDFeatureExtractor/pidOnnxInference.cxx:317:46: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'const int'
/sw/slc9_x86-64/O2/daily-20260812-0000-local1/include/Framework/StructToTuple.h:61:38: error: static assertion failed: You need to make sure that you have implicit constructors or that you call the explicit constructor correctly.
/sw/slc9_x86-64/GCC-Toolchain/v14.2.0-alice2-1/include/c++/14.2.0/bits/stl_construct.h:115:28: error: no matching function for call to 'construct_at(PidOnnxInference*&)'
ninja: build stopped: subcommand failed.

Full log here.

@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/o2 for c662104 at 2026-08-12 18:05:

## sw/BUILD/O2Physics-latest/log
/sw/SOURCES/O2Physics/slc9_x86-64-slc9_x86-64/0/Tools/PIDFeatureExtractor/pidOnnxInference.cxx:317:46: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'const int'
/sw/slc9_x86-64/O2/daily-20260812-0000-local1/include/Framework/StructToTuple.h:61:38: error: static assertion failed: You need to make sure that you have implicit constructors or that you call the explicit constructor correctly.
/sw/slc9_x86-64/GCC-Toolchain/v14.2.0-alice2-1/include/c++/14.2.0/bits/stl_construct.h:115:28: error: no matching function for call to 'construct_at(PidOnnxInference*&)'
ninja: build stopped: subcommand failed.

Full log here.

@forynski
forynski requested a review from ktf August 13, 2026 09:17
@dsekihat
dsekihat enabled auto-merge (squash) August 13, 2026 12:50
@dsekihat
dsekihat merged commit df8948f into AliceO2Group:master Aug 13, 2026
16 of 17 checks passed
@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for d056ad4 at 2026-08-13 19:57:

## sw/BUILD/O2Physics-code-check-latest/log
--
========== List of issues found ==========
++ echo 'Found 23 errors and 6 warnings.'
Found 23 errors and 6 warnings.
++ [[ 23 -gt 0 ]]
++ cat /sw/BUILD/5dd7458a406b90d25224f0350a3f5062ebeaa782/O2Physics-code-check/errors.txt
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:30:1: error: included header EventSelection.h is not used directly [misc-include-cleaner,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:148:42: error: no header providing "o2::framework::OutputObjHandlingPolicy" is directly included [misc-include-cleaner,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:185:13: error: no header providing "o2::framework::InitContext" is directly included [misc-include-cleaner,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:263:11: error: no header providing "o2::framework::AxisSpec" is directly included [misc-include-cleaner,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:268:40: error: no header providing "o2::framework::kTH1F" is directly included [misc-include-cleaner,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:271:49: error: no header providing "o2::framework::kTH2F" is directly included [misc-include-cleaner,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:299:50: error: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:299:87: error: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:299:103: error: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:397:5: error: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:398:5: error: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:399:5: error: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:400:34: error: 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,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:400:49: error: 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,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:400:56: error: 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,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidOnnxInference.cxx:70:9: error: implicit conversion 'uint32_t' (aka 'unsigned int') -> 'bool' [readability-implicit-bool-conversion,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidOnnxInference.cxx:212:3: error: no header providing "Long64_t" is directly included [misc-include-cleaner,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidOnnxInference.cxx:327:13: error: no header providing "o2::ccdb::CcdbApi" is directly included [misc-include-cleaner,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidOnnxInference.cxx:330:13: error: no header providing "o2::framework::InitContext" is directly included [misc-include-cleaner,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidOnnxInference.cxx:344:22: error: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidOnnxInference.cxx:345:5: error: no header providing "o2::framework::LabeledArray" is directly included [misc-include-cleaner,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidOnnxInference.cxx:345:33: error: 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,-warnings-as-errors]
Tools/PIDFeatureExtractor/pidOnnxInference.cxx:362:21: error: no header providing "o2::aod::Collisions" is directly included [misc-include-cleaner,-warnings-as-errors]
++ [[ 6 -gt 0 ]]
++ cat /sw/BUILD/5dd7458a406b90d25224f0350a3f5062ebeaa782/O2Physics-code-check/warnings.txt
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:281:62: warning: statement should be inside braces [readability-braces-around-statements]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:283:66: warning: statement should be inside braces [readability-braces-around-statements]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:285:50: warning: statement should be inside braces [readability-braces-around-statements]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:287:48: warning: statement should be inside braces [readability-braces-around-statements]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:289:53: warning: statement should be inside braces [readability-braces-around-statements]
Tools/PIDFeatureExtractor/pidFeatureExtractor.cxx:291:55: warning: statement should be inside braces [readability-braces-around-statements]
++ [[ 23 -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

Development

Successfully merging this pull request may close these issues.

4 participants