Skip to content

[RF] Add HistFactory preprocess callbacks#22191

Draft
tianzhuli2002 wants to merge 1 commit intoroot-project:masterfrom
tianzhuli2002:root-pr-clean
Draft

[RF] Add HistFactory preprocess callbacks#22191
tianzhuli2002 wants to merge 1 commit intoroot-project:masterfrom
tianzhuli2002:root-pr-clean

Conversation

@tianzhuli2002
Copy link
Copy Markdown

@tianzhuli2002 tianzhuli2002 commented May 8, 2026

This Pull request is aimed to fix issue #21052 #21052:

Large HistFactory models can create many expression-based preprocess
functions. Constructing these through RooWorkspace::factory can cause crashes during workspace creation due to Cling/LLVM runtime.

Add an optional callback path to Measurement so callers can create
preprocess objects programmatically once the workspace is available.
The existing string-based preprocess function path is unchanged. This is change is also meant to interface with changes to trex-fitter which will try to use this new callback functionality.

Checklist:

  • tested changes locally

Copilot AI review requested due to automatic review settings May 8, 2026 13:38
@tianzhuli2002 tianzhuli2002 requested a review from guitargeek as a code owner May 8, 2026 13:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional programmatic “preprocess” hook to HistFactory Measurement to let callers create preprocess objects directly on an already-instantiated RooWorkspace, avoiding RooWorkspace::factory()-driven Cling/LLVM issues for very large models.

Changes:

  • Introduce Measurement::PreprocessFunctionCallback plus APIs to register and apply callbacks during workspace creation.
  • Execute registered callbacks during HistoToWorkspaceFactoryFast channel workspace construction (after existing string-based preprocess calls).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
roofit/histfactory/src/Measurement.cxx Implements callback registration and application logic.
roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx Invokes preprocess callbacks during per-channel workspace creation.
roofit/histfactory/inc/RooStats/HistFactory/Measurement.h Adds the new callback API and stores callbacks (transient) in Measurement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +91 to +96
void Measurement::AddPreprocessFunctionCallback(PreprocessFunctionCallback callback)
{
if (callback) {
fPreprocessFunctionCallbacks.push_back(callback);
}
}
Comment on lines +780 to +783
/// Programmatic preprocess callbacks, executed during workspace creation.
/// Transient because std::function is not ROOT-streamable.
std::vector<PreprocessFunctionCallback> fPreprocessFunctionCallbacks; //!

Comment on lines +703 to +706
using PreprocessFunctionCallback = std::function<void(RooWorkspace &)>;
void AddPreprocessFunctionCallback(PreprocessFunctionCallback callback);
void ApplyPreprocessFunctionCallbacks(RooWorkspace &ws) const;

@tianzhuli2002 tianzhuli2002 marked this pull request as draft May 8, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants