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
2 changes: 1 addition & 1 deletion roofit/roofitcore/src/RooFormulaVar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ RooFormula& RooFormulaVar::getFormula() const

double RooFormulaVar::evaluate() const
{
return getFormula().eval(_lastNSet);
return getFormula().eval(_actualVars.nset());
}


Expand Down
2 changes: 1 addition & 1 deletion roofit/roofitcore/src/RooGenericPdf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ RooFormula& RooGenericPdf::formula() const

double RooGenericPdf::evaluate() const
{
return formula().eval(_normSet) ;
return formula().eval(_actualVars.nset()) ;
}


Expand Down
2 changes: 1 addition & 1 deletion roofit/roofitcore/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ROOT_ADD_GTEST(testRooBinSamplingPdf testRooBinSamplingPdf.cxx LIBRARIES RooFitC
ROOT_ADD_GTEST(testRooSimPdfBuilder testRooSimPdfBuilder.cxx LIBRARIES RooFitCore)
ROOT_ADD_GTEST(testRooWrapperPdf testRooWrapperPdf.cxx LIBRARIES Gpad RooFitCore)
ROOT_ADD_GTEST(testRooFitDriver testRooFitDriver.cxx LIBRARIES RooFitCore RooFit)
ROOT_ADD_GTEST(testGenericPdf testGenericPdf.cxx LIBRARIES RooFitCore)
ROOT_ADD_GTEST(testGenericPdf testGenericPdf.cxx LIBRARIES RooFitCore RooFit)
ROOT_ADD_GTEST(testRooAbsPdf testRooAbsPdf.cxx LIBRARIES RooFitCore RooFit)
ROOT_ADD_GTEST(testRooAbsCollection testRooAbsCollection.cxx LIBRARIES RooFitCore)
ROOT_ADD_GTEST(testRooDataSet testRooDataSet.cxx LIBRARIES Tree RooFitCore)
Expand Down
33 changes: 28 additions & 5 deletions roofit/roofitcore/test/testGenericPdf.cxx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Tests for the GenericPdf
// Author: Stephan Hageboeck, CERN 05/2019
// Authors: Stephan Hageboeck, CERN 05/2019
// Jonas Rembser, CERN 06/2022

#include "RooRealVar.h"
#include "RooGenericPdf.h"
#include "RooWorkspace.h"
#include <RooExponential.h>
#include <RooRealVar.h>
#include <RooGenericPdf.h>
#include <RooWorkspace.h>

#include "gtest/gtest.h"
#include <gtest/gtest.h>

#define MAKE_JOHNSON_AND_VARS RooRealVar mass("mass", "mass", 0., -200., 200.);\
RooRealVar mu("mu", "Location parameter of normal distribution", 100., -200., 200.);\
Expand Down Expand Up @@ -53,3 +55,24 @@ TEST(GenericPdf, CrashWhenRenamingArguments) {
// Would crash:
EXPECT_NEAR(impPdf->getVal(), 0.15, 1.E-6);
}

// ROOT-5101: Identity PDF affects normalization
TEST(GenericPdf, IdentidyPdfNormalization) {
RooRealVar x{"x", "x", 0.0, 100.0};
RooRealVar s{"s", "s", -0.5, -10.0, 0.0};

RooExponential exp{"exp", "exp", x, s};

// This RooGenericPdf should behave exactly the same as the exponential, only
// that the integration will be done numerically.
RooGenericPdf pdf{"pdf", "pdf", "@0", {exp}};

RooArgSet normSet{x};

// Check that the values with and without normalization are almost identical.
// They are not exactly identical for the normalized case, because the
// RooGenericPdf doesn't do analytic integration.
constexpr double tol = 1e-6;
EXPECT_NEAR(exp.getVal(), pdf.getVal(), tol);
EXPECT_NEAR(exp.getVal(normSet), pdf.getVal(normSet), tol);
}