From bfeeea09eb93118d26eec736ee281e2e271e636d Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 18 Nov 2024 14:33:48 +0100 Subject: [PATCH] Add global flag to set NLL evaluation backend * 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 --- interface/Combine.h | 1 + src/Combine.cc | 1 + src/RooSimultaneousOpt.cc | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/interface/Combine.h b/interface/Combine.h index 5aea6a5e41a..0bf0a07d902 100644 --- a/interface/Combine.h +++ b/interface/Combine.h @@ -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 { diff --git a/src/Combine.cc b/src/Combine.cc index 4cf64dd0974..5f083c22c49 100644 --- a/src/Combine.cc +++ b/src/Combine.cc @@ -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_=""; diff --git a/src/RooSimultaneousOpt.cc b/src/RooSimultaneousOpt.cc index f689b4af999..de51640ca81 100644 --- a/src/RooSimultaneousOpt.cc +++ b/src/RooSimultaneousOpt.cc @@ -2,6 +2,8 @@ #include "../interface/CachingNLL.h" #include +extern std::string nllBackend_; + #if ROOT_VERSION_CODE < ROOT_VERSION(6,30,0) RooAbsReal* RooSimultaneousOpt::createNLL(RooAbsData& data, const RooLinkedList& cmdList) @@ -10,6 +12,16 @@ std::unique_ptr 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");