Skip to content

Commit

Permalink
Add global flag to set NLL evaluation backend
Browse files Browse the repository at this point in the history
  * In case the value is `"combine"`, it will use combines caching NLL
    classes

  * In any other case, it will RooFits default `createNLL()`, setting
    the RooFit::EvalBackend to the value on the global flag.
    See: https://root.cern.ch/doc/master/classRooAbsPdf.html#a24b1afec4fd149e08967eac4285800de
  • Loading branch information
guitargeek committed Nov 18, 2024
1 parent be8261d commit bfeeea0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions interface/Combine.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extern bool bypassFrequentistFit_;
extern std::string setPhysicsModelParameterExpression_;
extern std::string setPhysicsModelParameterRangeExpression_;
extern std::string defineBackgroundOnlyModelParameterExpression_;
extern std::string nllBackend_;

namespace {
struct ToCleanUp {
Expand Down
1 change: 1 addition & 0 deletions src/Combine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ TTree *Combine::tree_ = 0;
std::string setPhysicsModelParameterExpression_ = "";
std::string setPhysicsModelParameterRangeExpression_ = "";
std::string defineBackgroundOnlyModelParameterExpression_ = "";
std::string nllBackend_ = "combine";

std::string Combine::trackParametersNameString_="";
std::string Combine::trackErrorsNameString_="";
Expand Down
12 changes: 12 additions & 0 deletions src/RooSimultaneousOpt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "../interface/CachingNLL.h"
#include <RooCmdConfig.h>

extern std::string nllBackend_;

#if ROOT_VERSION_CODE < ROOT_VERSION(6,30,0)
RooAbsReal*
RooSimultaneousOpt::createNLL(RooAbsData& data, const RooLinkedList& cmdList)
Expand All @@ -10,6 +12,16 @@ std::unique_ptr<RooAbsReal>
RooSimultaneousOpt::createNLLImpl(RooAbsData& data, const RooLinkedList& cmdList)
#endif
{
if (nllBackend_ != "combine") {
RooLinkedList cmdListCopy{cmdList};
// Set the RooFit::EvalBackend() of RooFit to what the nllBackend_ in
// combine is set.
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,30,0)
RooCmdArg evalBackendArg{RooFit::EvalBackend(nllBackend_)};
cmdListCopy.Add(&evalBackendArg);
#endif
return RooSimultaneous::createNLLImpl(data, cmdListCopy);
}
RooCmdConfig pc(Form("RooSimultaneousOpt::createNLL(%s)",GetName())) ;
pc.defineSet("cPars","Constrain",0,0);
RooArgSet *cPars = pc.getSet("cPars");
Expand Down

0 comments on commit bfeeea0

Please sign in to comment.