Skip to content

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

Open
forynski wants to merge 17 commits into
AliceO2Group:masterfrom
forynski:my-local-pid-branch-fresh
Open

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

Conversation

@forynski

Copy link
Copy Markdown

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.

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.

3 participants