Skip to content

Commit 314d6ac

Browse files
committed
Resize pars_vals and make generated code scope-dependent
1 parent 9a29316 commit 314d6ac

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/CombineCodegenImpl.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,9 @@ void RooFit::Experimental::codegenImpl(RooParametricHist& arg, CodegenContext& c
250250
arg.getFlattenedMorphs(diffs_flat, sums_flat);
251251
}
252252

253+
std::string xName = ctx.getResult(arg.observable());
253254
std::stringstream bin_i;
254-
bin_i << ctx.buildCall("RooFit::Detail::MathFuncs::parametricHistFindBin", arg.getNBins(), arg.getBins(), arg.getX());
255+
bin_i << ctx.buildCall("RooFit::Detail::MathFuncs::parametricHistFindBin", arg.getNBins(), arg.getBins(), xName);
255256
std::stringstream code;
256257
code << ctx.buildCall("RooFit::Detail::MathFuncs::parametricHistEvaluate",
257258
bin_i.str(),
@@ -265,7 +266,7 @@ void RooFit::Experimental::codegenImpl(RooParametricHist& arg, CodegenContext& c
265266
arg.getWidths(),
266267
arg.getSmoothRegion())
267268
+ ";\n";
268-
ctx.addToCodeBody(code.str(), true);
269+
ctx.addToCodeBody(code.str());
269270
ctx.addResult(&arg, code.str());
270271
}
271272

src/RooParametricHist.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ Double_t RooParametricHist::evaluate() const
165165
double xVal = getX();
166166
int bin_i = RooFit::Detail::MathFuncs::parametricHistFindBin(N_bins, bins, xVal);
167167
if (bin_i < 0) return 0.0; // Out of range
168+
pars_vals_.resize(N_bins);
168169
pars_vals_[bin_i] = getParVal(bin_i);
169170
if (bins.empty() || widths.empty()) return 0.0;
170171
const double* bins_ptr = bins.data();

0 commit comments

Comments
 (0)