Skip to content
Merged
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
5 changes: 2 additions & 3 deletions roofit/hs3/test/testHS3HistFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <RooStats/HistFactory/Measurement.h>
#include <RooStats/HistFactory/MakeModelAndMeasurementsFast.h>

#include <RooMsgService.h>
#include <RooHelpers.h>

#include <TROOT.h>

Expand Down Expand Up @@ -73,8 +73,7 @@ measurement(std::string const &inputFileName = "test_hs3_histfactory_json_input.

TEST(TestHS3HistFactoryJSON, Create)
{
auto &msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

toJSON(*measurement(), "hf.json");
}
Expand Down
3 changes: 1 addition & 2 deletions roofit/hs3/test/testRooFitHS3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ TEST(RooFitHS3, RooArgusBG)
{
using namespace RooFit;

auto &msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

// --- Observable ---
RooRealVar mes("mes", "m_{ES} (GeV)", 5.20, 5.30);
Expand Down
8 changes: 3 additions & 5 deletions roofit/roofit/test/testRooParamHistFunc.cxx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Tests for RooParamHistFunc
// Author: Jonas Rembser, CERN 03/2020

#include <RooMsgService.h>
#include <RooHelpers.h>
#include <RooParamHistFunc.h>
#include <RooRealSumPdf.h>
#include <RooRealVar.h>
Expand All @@ -20,8 +20,7 @@ TEST(RooParamHistFunc, Integration)
// inspired by this issue on GitHub:
// https://github.com/root-project/root/issues/7182

auto& msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

constexpr int nBins = 20;
constexpr double xMin = 0;
Expand Down Expand Up @@ -76,8 +75,7 @@ TEST(RooParamHistFunc, IntegrationAndCloning)
// The test was inspired by this error reported on the forum:
// https://root-forum.cern.ch/t/barlow-beeston-in-subrange/43909/5

auto& msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

using namespace RooFit;

Expand Down
2 changes: 1 addition & 1 deletion roofit/roofitcore/inc/RooHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace RooHelpers {
/// Can also temporarily activate / deactivate message topics.
/// Use as
/// ~~~{.cpp}
/// RooHelpers::LocalChangeMessageLevel changeMsgLvl(RooFit::WARNING);
/// RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);
/// [ statements that normally generate a lot of output ]
/// ~~~
class LocalChangeMsgLevel {
Expand Down
9 changes: 5 additions & 4 deletions roofit/roofitcore/test/TestStatistics/RooRealL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <RooWorkspace.h>
#include <RooAbsPdf.h>
#include <RooDataSet.h>
#include <RooHelpers.h>
#include <RooMinimizer.h>
#include <RooFitResult.h>
#include <RooProdPdf.h>
Expand Down Expand Up @@ -105,7 +106,7 @@ void count_NLL_components(RooAbsReal *nll)

TEST_P(RooRealL, getValRooAddition)
{
RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::ERROR);

RooRandom::randomGenerator()->SetSeed(std::get<0>(GetParam()));

Expand Down Expand Up @@ -134,7 +135,7 @@ TEST_P(RooRealL, getValRooConstraintSumAddition)
// modified from
// https://github.com/roofit-dev/rootbench/blob/43d12f33e8dac7af7d587b53a2804ddf6717e92f/root/roofit/roofit/RooFitASUM.cxx#L417

RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::ERROR);

RooWorkspace ws;
ws.factory("Polynomial::p0(x[0, 10000])");
Expand Down Expand Up @@ -235,7 +236,7 @@ TEST_P(RealLVsMPFE, getVal)
{
// Compare our MP NLL to actual RooRealMPFE results using the same strategies.

RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::ERROR);

// parameters
std::size_t seed = std::get<0>(GetParam());
Expand Down Expand Up @@ -266,7 +267,7 @@ TEST_P(RealLVsMPFE, minimize)
{
// do a minimization (e.g. like in GradMinimizer_Gaussian1D test)

RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::ERROR);

// parameters
std::size_t seed = std::get<0>(GetParam());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "RooWorkspace.h"
#include "RooDataHist.h" // complete type in Binned test
#include "RooCategory.h" // complete type in MultiBinnedConstraint test
#include "RooHelpers.h"
#include "RooMinimizer.h"
#include "RooFitResult.h"
#include "RooFit/TestStatistics/LikelihoodWrapper.h"
Expand Down Expand Up @@ -62,9 +63,15 @@ class Environment : public testing::Environment {
public:
void SetUp() override
{
RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR);
_changeMsgLvl = std::make_unique<RooHelpers::LocalChangeMsgLevel>(RooFit::ERROR);
ROOT::Math::MinimizerOptions::SetDefaultMinimizer("Minuit2");
}
void TearDown() override
{
_changeMsgLvl.reset();
}
private:
std::unique_ptr<RooHelpers::LocalChangeMsgLevel> _changeMsgLvl;
};

// Previously, we just called AddGlobalTestEnvironment in global namespace, but this caused either a warning about an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ class Environment : public testing::Environment {
public:
void SetUp() override
{
RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR);
_changeMsgLvl = std::make_unique<RooHelpers::LocalChangeMsgLevel>(RooFit::ERROR);
RooFit::MultiProcess::Config::setDefaultNWorkers(2);
}
void TearDown() override
{
_changeMsgLvl.reset();
}
private:
std::unique_ptr<RooHelpers::LocalChangeMsgLevel> _changeMsgLvl;
};

// Previously, we just called AddGlobalTestEnvironment in global namespace, but this caused either a warning about an
Expand Down
11 changes: 10 additions & 1 deletion roofit/roofitcore/test/TestStatistics/testLikelihoodSerial.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ using RooFit::TestStatistics::LikelihoodWrapper;

class Environment : public testing::Environment {
public:
void SetUp() override { RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR); }
void SetUp() override
{
_changeMsgLvl = std::make_unique<RooHelpers::LocalChangeMsgLevel>(RooFit::ERROR);
}
void TearDown() override
{
_changeMsgLvl.reset();
}
private:
std::unique_ptr<RooHelpers::LocalChangeMsgLevel> _changeMsgLvl;
};

// Previously, we just called AddGlobalTestEnvironment in global namespace, but this caused either a warning about an
Expand Down
8 changes: 7 additions & 1 deletion roofit/roofitcore/test/TestStatistics/testPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ class Environment : public testing::Environment {
public:
void SetUp() override
{
RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR);
_changeMsgLvl = std::make_unique<RooHelpers::LocalChangeMsgLevel>(RooFit::ERROR);
ROOT::Math::MinimizerOptions::SetDefaultMinimizer("Minuit2");
}
void TearDown() override
{
_changeMsgLvl.reset();
}
private:
std::unique_ptr<RooHelpers::LocalChangeMsgLevel> _changeMsgLvl;
};

int main(int argc, char **argv)
Expand Down
11 changes: 10 additions & 1 deletion roofit/roofitcore/test/TestStatistics/testRooAbsL.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ using RooFit::TestStatistics::LikelihoodWrapper;

class Environment : public testing::Environment {
public:
void SetUp() override { RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR); }
void SetUp() override
{
_changeMsgLvl = std::make_unique<RooHelpers::LocalChangeMsgLevel>(RooFit::ERROR);
}
void TearDown() override
{
_changeMsgLvl.reset();
}
private:
std::unique_ptr<RooHelpers::LocalChangeMsgLevel> _changeMsgLvl;
};

// Previously, we just called AddGlobalTestEnvironment in global namespace, but this caused either a warning about an
Expand Down
4 changes: 2 additions & 2 deletions roofit/roofitcore/test/testGlobalObservables.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <RooAbsPdf.h>
#include <RooDataSet.h>
#include <RooFitResult.h>
#include <RooMsgService.h>
#include <RooHelpers.h>
#include <RooRealVar.h>
#include <RooWorkspace.h>

Expand Down Expand Up @@ -42,7 +42,7 @@ class TestGlobalObservables : public ::testing::Test {
void SetUp() override
{
// silence log output
RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

// We use the global observable also in the model for the event
// observables. It's unusual, but let's better do this to also cover the
Expand Down
3 changes: 2 additions & 1 deletion roofit/roofitcore/test/testNaNPacker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "RooNaNPacker.h"
#include "RooRealVar.h"
#include "RooGenericPdf.h"
#include "RooHelpers.h"
#include "RooMinimizer.h"
#include "RooFitResult.h"
#include "RooDataSet.h"
Expand Down Expand Up @@ -121,7 +122,7 @@ TEST(RooNaNPacker, FitSimpleLinear) {
/// The minimiser needs to recover from that.
/// Test also that when recovery with NaN packing is switched off, the minimiser fails to recover.
TEST(RooNaNPacker, FitParabola) {
RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING); // We don't need integration messages
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING); // We don't need integration messages

RooRealVar x("x", "x", -10, 10);
RooRealVar a1("a1", "a1", 12., -10., 20.);
Expand Down
9 changes: 3 additions & 6 deletions roofit/roofitcore/test/testRooAbsPdf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ TEST(RooAbsPdf, AsymptoticallyCorrectErrors)
{
using namespace RooFit;

auto &msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

RooRealVar x("x", "xxx", 0, 0, 10);
RooRealVar a("a", "aaa", 2, 0, 10);
Expand Down Expand Up @@ -146,8 +145,7 @@ TEST(RooAbsPdf, ConditionalFitBatchMode)
TEST(RooAbsPdf, MultiRangeFit)
{
using namespace RooFit;
auto &msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

RooWorkspace ws;

Expand Down Expand Up @@ -205,8 +203,7 @@ TEST(RooAbsPdf, MultiRangeFit)
TEST(RooAbsPdf, MultiRangeFit2D)
{
using namespace RooFit;
auto &msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

// model taken from the rf312_multirangefit.C tutorial
RooWorkspace ws;
Expand Down
6 changes: 2 additions & 4 deletions roofit/roofitcore/test/testRooAddPdf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
/// is taken from the GitHub issue thread, with the plotting part removed.
TEST(RooAddPdf, TestSPlot)
{
auto &msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

double lowRange = 0.;
double highRange = 200.;
Expand Down Expand Up @@ -121,8 +120,7 @@ TEST(RooAddPdf, TestSPlot)
/// issues of RooAddPdf integrals.
TEST(RooAddPdf, Issue10988)
{
auto &msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

using namespace RooFit;

Expand Down
8 changes: 3 additions & 5 deletions roofit/roofitcore/test/testRooBinSamplingPdf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <RooDataSet.h>
#include <RooDataHist.h>
#include <RooRealVar.h>
#include <RooMsgService.h>
#include <RooHelpers.h>

#include <gtest/gtest.h>

Expand All @@ -20,8 +20,7 @@ TEST(RooBinSamplingPdf, LinearPdfCrossCheck)
{
using namespace RooFit;

auto& msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

RooRandom::randomGenerator()->SetSeed(1337ul);

Expand Down Expand Up @@ -50,8 +49,7 @@ TEST(RooBinSamplingPdf, LinearPdfSubRangeCrossCheck)
{
using namespace RooFit;

auto& msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

RooRandom::randomGenerator()->SetSeed(1337ul);

Expand Down
3 changes: 1 addition & 2 deletions roofit/roofitcore/test/testRooDataSet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ TEST(RooDataSet, CrashAfterImportFromTree)
// root-project/root#6951: Broken weights after reducing RooDataSet created with RooAbsPdf::generate()
TEST(RooDataSet, ReduceWithCompositeDataStore)
{
auto &msg = RooMsgService::instance();
msg.setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

RooWorkspace ws{};
ws.factory("Gaussian::gauss(x[-10,10], mean[3,-10,10], sig ma[1,0.1,10])");
Expand Down
3 changes: 2 additions & 1 deletion roofit/roofitcore/test/testRooSimultaneous.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <RooDataSet.h>
#include <RooFitResult.h>
#include <RooGenericPdf.h>
#include <RooHelpers.h>
#include <RooRealVar.h>
#include <RooSimultaneous.h>
#include <RooProdPdf.h>
Expand All @@ -25,7 +26,7 @@ TEST(RooSimultaneous, SingleChannelCrossCheck)
using namespace RooFit;

// silence log output
RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING);
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);

RooWorkspace ws;
ws.factory("Gaussian::gauss1(x[0, 10], mean[1., 0., 10.], width[1, 0.1, 10])");
Expand Down
Loading