diff --git a/root/roofit/histfactory/TestWorkspaces.cxx b/root/roofit/histfactory/TestWorkspaces.cxx index cd65ed96..9c657670 100644 --- a/root/roofit/histfactory/TestWorkspaces.cxx +++ b/root/roofit/histfactory/TestWorkspaces.cxx @@ -12,7 +12,7 @@ /// Returns the workspace that is also created in the hf001_example.C tutorial. /// Note that running this function creates a directory `hf001_data` in the /// current directory. -RooWorkspace * +std::unique_ptr TestWorkspaces::getWorkspace001(RooStats::HistFactory::HistoToWorkspaceFactoryFast::Configuration const &cfg) { using namespace RooStats::HistFactory; @@ -81,5 +81,5 @@ TestWorkspaces::getWorkspace001(RooStats::HistFactory::HistoToWorkspaceFactoryFa meas.SetExportOnly(true); // Now, do the measurement - return MakeModelAndMeasurementFast(meas, cfg); + return std::unique_ptr{MakeModelAndMeasurementFast(meas, cfg)}; } diff --git a/root/roofit/histfactory/TestWorkspaces.h b/root/roofit/histfactory/TestWorkspaces.h index f7258f2c..4caebac8 100644 --- a/root/roofit/histfactory/TestWorkspaces.h +++ b/root/roofit/histfactory/TestWorkspaces.h @@ -3,11 +3,14 @@ #include +#include + class RooWorkspace; namespace TestWorkspaces { -RooWorkspace *getWorkspace001(RooStats::HistFactory::HistoToWorkspaceFactoryFast::Configuration const &cfg); +std::unique_ptr +getWorkspace001(RooStats::HistFactory::HistoToWorkspaceFactoryFast::Configuration const &cfg); } // namespace TestWorkspaces diff --git a/root/roofit/histfactory/benchHistFactory.cxx b/root/roofit/histfactory/benchHistFactory.cxx index 4a9b82e7..689819a7 100644 --- a/root/roofit/histfactory/benchHistFactory.cxx +++ b/root/roofit/histfactory/benchHistFactory.cxx @@ -23,18 +23,18 @@ class TestData { using namespace RooFit; RooStats::HistFactory::HistoToWorkspaceFactoryFast::Configuration hfCfg; - auto *w = TestWorkspaces::getWorkspace001(hfCfg); + std::unique_ptr ws = TestWorkspaces::getWorkspace001(hfCfg); - auto *mc = static_cast(w->obj("ModelConfig")); + auto *mc = static_cast(ws->obj("ModelConfig")); if (mc->GetParametersOfInterest()) constraintParams.add(*mc->GetParametersOfInterest()); if (mc->GetNuisanceParameters()) constraintParams.add(*mc->GetNuisanceParameters()); - auto *pdf = w->pdf("simPdf"); + auto *pdf = ws->pdf("simPdf"); - std::unique_ptr nll{pdf->createNLL(*w->data("obsData"), Constrain(constraintParams), + std::unique_ptr nll{pdf->createNLL(*ws->data("obsData"), Constrain(constraintParams), GlobalObservables(*mc->GetGlobalObservables()), EvalBackend::Legacy())}; RooMinimizer m(*nll); @@ -64,14 +64,14 @@ static void benchHistFactory001(benchmark::State &state) RooStats::HistFactory::HistoToWorkspaceFactoryFast::Configuration hfCfg; hfCfg.binnedFitOptimization = state.range(0); - auto *w = TestWorkspaces::getWorkspace001(hfCfg); + std::unique_ptr ws = TestWorkspaces::getWorkspace001(hfCfg); - auto *mc = static_cast(w->obj("ModelConfig")); + auto *mc = static_cast(ws->obj("ModelConfig")); - auto *pdf = w->pdf("simPdf"); + auto *pdf = ws->pdf("simPdf"); auto evalBackend = static_cast(state.range(1)); - std::unique_ptr nll{pdf->createNLL(*w->data("obsData"), Constrain(g_testData.constraintParams), + std::unique_ptr nll{pdf->createNLL(*ws->data("obsData"), Constrain(g_testData.constraintParams), GlobalObservables(*mc->GetGlobalObservables()), EvalBackend(evalBackend))}; diff --git a/root/roofit/roofit/RooFitBinnedBenchmarks.cxx b/root/roofit/roofit/RooFitBinnedBenchmarks.cxx index 8babe773..809effbb 100644 --- a/root/roofit/roofit/RooFitBinnedBenchmarks.cxx +++ b/root/roofit/roofit/RooFitBinnedBenchmarks.cxx @@ -115,11 +115,11 @@ void buildBinnedTest(int n_channels = 1, int nbins = 10, int nnps = 1, const cha meas.AddChannel(*chan); } HistoToWorkspaceFactoryFast hist2workspace(meas); - RooWorkspace *ws; + std::unique_ptr ws; if (n_channels < 2) { - ws = hist2workspace.MakeSingleChannelModel(meas, *chan); + ws = std::unique_ptr{hist2workspace.MakeSingleChannelModel(meas, *chan)}; } else { - ws = hist2workspace.MakeCombinedModel(meas); + ws = std::unique_ptr{hist2workspace.MakeCombinedModel(meas)}; } for (RooAbsArg * arg : ws->components()) { if (arg->IsA() == RooRealSumPdf::Class()) {