Skip to content

[RF] Refactor RooAICRegistry and its usage - #22983

Merged
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:rooaicregistry
Aug 14, 2026
Merged

guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:rooaicregistry

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

Modernize RooAICRegistry, the helper that operator p.d.f.s use to cache analytical integration codes and their associated RooArgSets, and clean up its usage across RooFitCore.

Storage and ownership:

  • Replace the four parallel std::vector<RooArgSet*> members and the hand-written copy/destroy bookkeeping with a single std::array<std::vector<std::unique_ptr<RooArgSet>>, 4>. The manual destructor and copyImpl() helper are gone; lifetime is now handled by the smart pointers.
  • store() no longer takes ownership of the RooArgSets passed to it; it only snapshots them. Callers are updated accordingly: they either keep their unique_ptrs (RooAbsAnaConvPdf) or pass stack objects instead of heap allocations (RooAbsCachedPdf), removing several new/release()/delete dances.

API:

  • Replace the four retrieve() out-parameter overloads with a single method returning a small Output struct (the code list plus the four set pointers), so call sites no longer declare and thread raw pointers by reference.
  • Drop the ClassDef/dictionary and the corresponding LinkDef entry: all data members were transient, so the registry was never persisted and does not need I/O support.

Cleanups in the consumers:

  • Remove the unused _codeReg registry members (and the now-redundant RooAICRegistry.h includes) from RooHistFunc, RooHistPdf and RooAddModel.
  • In RooProdPdf, _genCode only ever stored code lists without any RooArgSets, so demote it from a RooAICRegistry to a plain std::vector<std::vector<int>> and look codes up directly.

AI was only used to generate the commit message, and all the code changes were done by the human.

@guitargeek guitargeek self-assigned this Aug 2, 2026
@guitargeek
guitargeek requested a review from hageboeck as a code owner August 2, 2026 12:46
@github-actions

github-actions Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 9h 22m 24s ⏱️
 3 853 tests  3 852 ✅ 0 💤 1 ❌
75 652 runs  75 650 ✅ 1 💤 1 ❌

For more details on these failures, see this check.

Results for commit 7db3834.

♻️ This comment has been updated with latest results.

Modernize RooAICRegistry, the helper that operator p.d.f.s use to cache
analytical integration codes and their associated RooArgSets, and clean
up its usage across RooFitCore.

Storage and ownership:

  - Replace the four parallel `std::vector<RooArgSet*>` members and the
    hand-written copy/destroy bookkeeping with a single
    `std::array<std::vector<std::unique_ptr<RooArgSet>>, 4>`. The manual
    destructor and `copyImpl()` helper are gone; lifetime is now handled
    by the smart pointers.
  - `store()` no longer takes ownership of the RooArgSets passed to it;
    it only snapshots them. Callers are updated accordingly: they either
    keep their `unique_ptr`s (RooAbsAnaConvPdf) or pass stack objects
    instead of heap allocations (RooAbsCachedPdf), removing several
    `new`/`release()`/`delete` dances.

API:

  - Replace the four `retrieve()` out-parameter overloads with a single
    method returning a small `Output` struct (the code list plus the
    four set pointers), so call sites no longer declare and thread raw
    pointers by reference.
  - Drop the `ClassDef`/dictionary and the corresponding LinkDef entry:
    all data members were transient, so the registry was never persisted
    and does not need I/O support.

Cleanups in the consumers:

  - Remove the unused `_codeReg` registry members (and the now-redundant
    RooAICRegistry.h includes) from RooHistFunc, RooHistPdf and
    RooAddModel.
  - In RooProdPdf, `_genCode` only ever stored code lists without any
    RooArgSets, so demote it from a RooAICRegistry to a plain
    `std::vector<std::vector<int>>` and look codes up directly.

@lmoneta lmoneta 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.

LGTM! This is now a cleaner and easier to maintain code!

@guitargeek
guitargeek merged commit c050cbd into root-project:master Aug 14, 2026
30 of 34 checks passed
@guitargeek
guitargeek deleted the rooaicregistry branch August 14, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants