Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions roofit/histfactory/inc/RooStats/HistFactory/Measurement.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <TNamed.h>

#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
Expand Down Expand Up @@ -699,6 +700,10 @@ class Measurement : public TNamed {
const std::vector<RooStats::HistFactory::PreprocessFunction> &GetFunctionObjects() const { return fFunctionObjects; }
std::vector<std::string> GetPreprocessFunctions() const;

using PreprocessFunctionCallback = std::function<void(RooWorkspace &)>;
void AddPreprocessFunctionCallback(PreprocessFunctionCallback callback);
void ApplyPreprocessFunctionCallbacks(RooWorkspace &ws) const;

Comment on lines +703 to +706
/// get vector of defined Asimov Datasets
std::vector<RooStats::HistFactory::Asimov> &GetAsimovDatasets() { return fAsimovDatasets; }
/// add an Asimov Dataset
Expand Down Expand Up @@ -772,6 +777,10 @@ class Measurement : public TNamed {
/// List of Preprocess Function objects
std::vector<RooStats::HistFactory::PreprocessFunction> fFunctionObjects;

/// Programmatic preprocess callbacks, executed during workspace creation.
/// Transient because std::function is not ROOT-streamable.
std::vector<PreprocessFunctionCallback> fPreprocessFunctionCallbacks; //!

Comment on lines +780 to +783
/// List of Asimov datasets to generate
std::vector<RooStats::HistFactory::Asimov> fAsimovDatasets;

Expand Down
2 changes: 2 additions & 0 deletions roofit/histfactory/src/HistoToWorkspaceFactoryFast.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,8 @@ RooArgList HistoToWorkspaceFactoryFast::createObservables(const TH1 *hist, RooWo
proto.Print();
}

measurement.ApplyPreprocessFunctionCallbacks(proto);

RooArgSet likelihoodTerms("likelihoodTerms");
RooArgSet constraintTerms("constraintTerms");
vector<string> likelihoodTermNames;
Expand Down
16 changes: 16 additions & 0 deletions roofit/histfactory/src/Measurement.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ void Measurement::AddPreprocessFunction(std::string name, std::string expression
AddFunctionObject(func);
}

void Measurement::AddPreprocessFunctionCallback(PreprocessFunctionCallback callback)
{
if (callback) {
fPreprocessFunctionCallbacks.push_back(callback);
}
}
Comment on lines +91 to +96

void Measurement::ApplyPreprocessFunctionCallbacks(RooWorkspace &ws) const
{
for (const auto &callback : fPreprocessFunctionCallbacks) {
if (callback) {
callback(ws);
}
}
}

/// Returns a list of defined preprocess function expressions
std::vector<std::string> Measurement::GetPreprocessFunctions() const
{
Expand Down
Loading