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
19 changes: 19 additions & 0 deletions roofit/roofit/src/RooMomentMorphFuncND.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -850,12 +850,31 @@ void RooMomentMorphFuncND::findShape(const vector<double> &x) const
_squareVec = output;

for (int isq = 0; isq < depth; isq++) {
// Reset to a sentinel before searching: if no matching reference point is
// found below, we must not silently keep the value left over from a
// previous, unrelated call to findShape() (e.g. from a different
// hypercube visited earlier in the fit). Falling through to a stale
// index here would make the interpolation depend on evaluation history
// instead of only on the current parameter point.
_squareIdx[isq] = -1;
for (int iref = 0; iref < nRef; iref++) {
if (_squareVec[isq] == _referenceGrid._nref[iref]) {
_squareIdx[isq] = iref;
break;
}
}
if (_squareIdx[isq] < 0) {
coutE(InputArguments) << "RooMomentMorphFuncND::findShape(" << GetName()
<< ") ERROR: no reference pdf found for grid corner (";
for (unsigned int ix = 0; ix < _squareVec[isq].size(); ++ix) {
ccoutE(InputArguments) << (ix ? ", " : "") << _squareVec[isq][ix];
}
ccoutE(InputArguments) << ") of the hypercube enclosing the current morphing "
<< "parameter point. The reference grid is missing a pdf at this "
<< "coordinate -- check that RooMomentMorphFuncND::Grid::addPdf() was "
<< "called for every corner of the parameter range." << std::endl;
throw string("RooMomentMorphFuncND::findShape() ERROR: incomplete reference grid");
}
}

// std::cout << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
## \date July 2024
## \author Robin Syring

import ROOT
import numpy as np
from sklearn.neural_network import MLPClassifier
import itertools

Check failure on line 33 in tutorials/roofit/roofit/rf617_simulation_based_inference_multidimensional.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

tutorials/roofit/roofit/rf617_simulation_based_inference_multidimensional.py:30:1: I001 Import block is un-sorted or un-formatted help: Organize imports

# Kills warning messages
ROOT.RooMsgService.instance().setGlobalKillBelow(ROOT.RooFit.WARNING)
Expand All @@ -44,7 +44,7 @@
def morphing(setting, n_dimensions):
# Define binning for morphing

binning = [ROOT.RooBinning(n_bins, 0.0, n_bins - 1.0) for dim in range(n_dimensions)]
binning = [ROOT.RooBinning(n_bins - 1, 0.0, n_bins - 1.0) for dim in range(n_dimensions)]
grid = ROOT.RooMomentMorphFuncND.Grid(*binning)

# Set bins for each x variable
Expand Down Expand Up @@ -202,8 +202,7 @@
morphing(ROOT.RooMomentMorphFuncND.Linear, len(mu_observed))

# Calculate the nll for the moprhed distribution
# TODO: Fix RooAddPdf::fixCoefNormalization(nset) warnings with new CPU backend
nll_morph = ws["morph"].createNLL(ws["obs_data"], EvalBackend="legacy")
nll_morph = ws["morph"].createNLL(ws["obs_data"])

# Initialize the SBI model
model = SBI(ws, len(mu_observed))
Expand Down
Loading