Skip to content

Commit ebcf15c

Browse files
committed
[RF][HF] Re-use any type of RooAbsArgs in ParamHistFunc::createParamSet
When connecting preprocessing functions to nuisance parameters via `Measurement::AddPreprocessFunction`, the nuisance parameter is replaced by a RooAbsReal that is not a RooRealVar, and the implementation of `ParamHistFunc::createParamSet` should be able to deal with that. So far, `createParamSet` assumed that any pre-existing argument in the workspace with the nuisance parameter name is of type RooRealVar, which is not valid in that case. Therefore, using preprocessing functions in place of these parameters resulted in a segfault. To fix this, the code is generalized to any RooAbsArg type. Closes #12225.
1 parent ca48671 commit ebcf15c

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

roofit/histfactory/src/ParamHistFunc.cxx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,8 @@ RooArgList ParamHistFunc::createParamSet(RooWorkspace& w, const std::string& Pre
317317
gamma.setConstant( false );
318318

319319
w.import( gamma, RooFit::RecycleConflictNodes() );
320-
RooRealVar* gamma_wspace = (RooRealVar*) w.var( VarName );
321-
322-
paramSet.add( *gamma_wspace );
323320

321+
paramSet.add(*w.arg(VarName));
324322
}
325323
}
326324

@@ -351,10 +349,8 @@ RooArgList ParamHistFunc::createParamSet(RooWorkspace& w, const std::string& Pre
351349
gamma.setConstant( false );
352350

353351
w.import( gamma, RooFit::RecycleConflictNodes() );
354-
RooRealVar* gamma_wspace = (RooRealVar*) w.var( VarName );
355-
356-
paramSet.add( *gamma_wspace );
357352

353+
paramSet.add(*w.arg(VarName));
358354
}
359355
}
360356
}
@@ -388,10 +384,8 @@ RooArgList ParamHistFunc::createParamSet(RooWorkspace& w, const std::string& Pre
388384
gamma.setConstant( false );
389385

390386
w.import( gamma, RooFit::RecycleConflictNodes() );
391-
RooRealVar* gamma_wspace = (RooRealVar*) w.var( VarName );
392-
393-
paramSet.add( *gamma_wspace );
394387

388+
paramSet.add(*w.arg(VarName));
395389
}
396390
}
397391
}
@@ -431,10 +425,12 @@ RooArgList ParamHistFunc::createParamSet(RooWorkspace& w, const std::string& Pre
431425
RooArgList params = ParamHistFunc::createParamSet( w, Prefix, vars );
432426

433427
for (auto comp : params) {
434-
auto var = static_cast<RooRealVar*>(comp);
435-
436-
var->setMin( gamma_min );
437-
var->setMax( gamma_max );
428+
// If the gamma is subject to a preprocess function, it is a RooAbsReal and
429+
// we don't need to set the range.
430+
if(auto var = dynamic_cast<RooRealVar*>(comp)) {
431+
var->setMin( gamma_min );
432+
var->setMax( gamma_max );
433+
}
438434
}
439435

440436
return params;

0 commit comments

Comments
 (0)