Skip to content

Commit

Permalink
Fix compilation of benchHistFactory
Browse files Browse the repository at this point in the history
The interface to store and retrieve the minimization path was removed.
It was not necessary anymore, because by now all backends that are
benchmarked behave the same and therefore the minimizer follows the same
minimization path.
  • Loading branch information
guitargeek committed Oct 18, 2024
1 parent 9a52714 commit a6034f2
Showing 1 changed file with 10 additions and 27 deletions.
37 changes: 10 additions & 27 deletions root/roofit/histfactory/benchHistFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,10 @@ class TestData {
constraintParams.add(*mc->GetParametersOfInterest());
if (mc->GetNuisanceParameters())
constraintParams.add(*mc->GetNuisanceParameters());

auto *pdf = ws->pdf("simPdf");

std::unique_ptr<RooAbsReal> nll{pdf->createNLL(*ws->data("obsData"), Constrain(constraintParams),
GlobalObservables(*mc->GetGlobalObservables()), EvalBackend::Legacy())};

RooMinimizer m(*nll);
m.setPrintLevel(-1);
m.setStrategy(0);
m.setLoggingToDataSet(true);

m.minimize("Minuit2");

minimizationPath = std::make_unique<RooDataSet>(*m.getLogDataSet());
}

std::unique_ptr<RooWorkspace> ws;

// Dataset with the floating parameters as columns, and each call to getVal
// in the minimization path as rows.
std::unique_ptr<RooDataSet> minimizationPath;

// The constraint parameters in the model.
RooArgSet constraintParams;
};
Expand All @@ -77,22 +59,23 @@ static void benchHistFactory001(benchmark::State &state)
GlobalObservables(*mc->GetGlobalObservables()),
EvalBackend(evalBackend))};

auto &minimizationPath = *g_testData.minimizationPath;

RooArgSet parameters{};
RooArgSet parameters;
RooArgSet initialParams;
nll->getParameters(nullptr, parameters);
parameters.snapshot(initialParams);

// The minimization path depends on the configuration in unpredictable ways.
// That's why we don't use the RooMinimizer each time, but only "emulate" a
// fit by taking a reference minimization path.

for (auto _ : state) {
for (auto i = 0; i < minimizationPath.numEntries(); ++i) {
state.PauseTiming();
parameters.assign(*minimizationPath.get(i));
state.ResumeTiming();
nll->getVal();
}
state.PauseTiming();
parameters.assign(initialParams);
RooMinimizer m(*nll);
m.setPrintLevel(-1);
m.setStrategy(0);
state.ResumeTiming();
m.minimize("Minuit2");
}
}

Expand Down

0 comments on commit a6034f2

Please sign in to comment.