Skip to content

Commit d6d6000

Browse files
committed
[RF] Make tutorial r619 runnable without clad.
Also fix a warning that protects from a Gaussian with sigma=0.
1 parent e84d1e9 commit d6d6000

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tutorials/roofit/roofit/rf619_discrete_profiling.C

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void rf619_discrete_profiling()
3535

3636
// Category 1 Pdf-s: Gaussian + Landau.
3737
RooRealVar mean("mean", "shared mean", 25, 0, 50);
38-
RooRealVar sigmaG("sigmaG", "Gaussian width", 2.0, 0.0, 5.0);
38+
RooRealVar sigmaG("sigmaG", "Gaussian width", 2.0, 0.01, 5.0);
3939
RooRealVar sigmaL("sigmaL", "Landau width", 3.0, 1.0, 8.0);
4040

4141
RooGaussian gauss1("gauss1", "Gaussian", x, mean, sigmaG);
@@ -118,8 +118,16 @@ void rf619_discrete_profiling()
118118
data->add(vars);
119119
}
120120

121-
// Create NLL with codegen and minimize it via the discrete profiling method.
122-
std::unique_ptr<RooAbsReal> nll1(simPdf.createNLL(*data, EvalBackend("codegen")));
121+
// Create an NLL and minimize it via the discrete profiling method.
122+
std::unique_ptr<RooAbsReal> nll1;
123+
try {
124+
// Try using an NLL with automatic differentiation if available in ROOT
125+
nll1.reset(simPdf.createNLL(*data, EvalBackend("codegen")));
126+
} catch (std::runtime_error &e) {
127+
std::cout << "Automatic differentiation not activated, falling back to numeric mode (" << e.what() << ")\n";
128+
// Fallback to numeric differentiation
129+
nll1.reset(simPdf.createNLL(*data));
130+
}
123131
RooMinimizer minim(*nll1);
124132

125133
minim.setStrategy(1);

0 commit comments

Comments
 (0)