@@ -35,7 +35,7 @@ void rf619_discrete_profiling()
35
35
36
36
// Category 1 Pdf-s: Gaussian + Landau.
37
37
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 );
39
39
RooRealVar sigmaL ("sigmaL" , "Landau width" , 3.0 , 1.0 , 8.0 );
40
40
41
41
RooGaussian gauss1 ("gauss1" , "Gaussian" , x , mean , sigmaG );
@@ -118,8 +118,16 @@ void rf619_discrete_profiling()
118
118
data -> add (vars );
119
119
}
120
120
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
+ }
123
131
RooMinimizer minim (* nll1 );
124
132
125
133
minim .setStrategy (1 );
0 commit comments