95RooAbsOptTestStatistic::RooAbsOptTestStatistic(
const char *
name,
const char *title,
RooAbsReal &
real,
97 RooAbsTestStatistic::Configuration
const &cfg)
102 if (operMode() !=
Slave) {
112RooAbsOptTestStatistic::RooAbsOptTestStatistic(
const RooAbsOptTestStatistic &
other,
const char *
name)
120 if (operMode() !=
Slave) {
122 if (
other._normSet) {
124 other._normSet->snapshot(*_normSet);
150 if (
_funcClone->getAttribute(
"BinnedLikelihood")) {
151 _funcClone->setAttribute(
"BinnedLikelihoodActive") ;
155 if (!projDeps.
empty()) {
178 indata.get()->snapshot(*_normSet,
false);
182 for (std::size_t i = 0; i <
_funcObsSet->size(); ++i) {
210 coutE(InputArguments) <<
"RooAbsOptTestStatistic: ERROR minimum of FUNC observable " << arg->
GetName()
211 <<
"(" <<
realReal->getMin() <<
") is smaller than that of "
212 << arg->GetName() <<
" in the dataset (" <<
datReal->getMin() <<
")" << std::endl ;
218 coutE(InputArguments) <<
"RooAbsOptTestStatistic: ERROR maximum of FUNC observable " << arg->GetName()
219 <<
" is larger than that of " << arg->GetName() <<
" in the dataset" << std::endl ;
240 cxcoutI(Fitting) <<
"RooAbsOptTestStatistic::ctor(" << GetName() <<
") constructing test statistic for sub-range named " <<
rangeName << std::endl ;
252 for(std::string
const& token :
tokens) {
253 if(!
realObs->hasRange(token.c_str())) {
255 errMsg <<
"The observable \"" <<
realObs->GetName() <<
"\" doesn't define the requested range \""
256 << token <<
"\". Replacing it with the default range." << std::endl;
279 cxcoutI(Fitting) <<
"RooAbsOptTestStatistic::ctor(" << GetName()
280 <<
") fixing interpretation of coefficients of any RooAddPdf component to range " <<
addCoefRangeName << std::endl ;
298 if (!projDeps.
empty()) {
301 projDeps.
snapshot(*_projDeps,
false) ;
304 _normSet->
remove(*_projDeps,
true,
true) ;
313 coutI(Optimization) <<
"RooAbsOptTestStatistic::ctor(" << GetName() <<
") optimizing internal clone of p.d.f for likelihood evaluation."
314 <<
"Lazy evaluation and associated change tracking will disabled for all nodes that depend on observables" << std::endl ;
332 if(_takeGlobalObservablesFromData && _data->getGlobalObservables()) {
333 recursiveRedirectServers(*_data->getGlobalObservables()) ;
342RooAbsOptTestStatistic::~RooAbsOptTestStatistic()
344 if (operMode()==
Slave) {
364double RooAbsOptTestStatistic::combinedValue(
RooAbsReal** array,
Int_t n)
const
369 for (
Int_t i = 0; i <
n; ++i) {
371 carry +=
reinterpret_cast<RooAbsOptTestStatistic*
>(array[i])->getCarry();
373 const double t =
sum +
y;
374 carry = (t -
sum) -
y;
399void RooAbsOptTestStatistic::printCompactTreeHook(ostream& os,
const char*
indent)
401 RooAbsTestStatistic::printCompactTreeHook(os,
indent) ;
418void RooAbsOptTestStatistic::constOptimizeTestStatistic(ConstOpCode opcode,
bool doAlsoTrackingOpt)
422 std::stringstream
ss;
423 ss <<
"Deprecated constant term optimization detected,\n"
424 <<
"enabled via RooFit::Optimize() or RooMinimizer::optimizeConst():\n"
425 <<
" This functionality only affects the legacy evaluation backend.\n"
426 <<
" The vectorized CPU backend performs const term optimization automatically.\n"
427 <<
" The option is ignored and will be removed in ROOT 6.42.\n"
428 <<
" Should your fit not be possible without the legacy backend, please open a GitHub issue.\n";
437 if (opcode==Activate) {
438 cxcoutW(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
439 <<
") dataset cache is owned by another object, no constant term optimization can be applied" << std::endl ;
445 if (opcode==Activate) {
446 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
447 <<
") function caching prohibited by test statistic, no constant term optimization is applied" << std::endl ;
452 if (
_dataClone->hasFilledCache() && opcode==Activate) {
458 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
459 <<
") optimizing evaluation of test statistic by finding all nodes in p.d.f that depend exclusively"
460 <<
" on observables and constant parameters and precalculating their values" << std::endl ;
465 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
466 <<
") deactivating optimization of constant terms in test statistic" << std::endl ;
471 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
472 <<
") one ore more parameter were changed from constant to floating or vice versa, "
473 <<
"re-evaluating constant term optimization" << std::endl ;
479 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
480 <<
") the value of one ore more constant parameter were changed re-evaluating constant term optimization" << std::endl ;
500void RooAbsOptTestStatistic::optimizeCaching()
527void RooAbsOptTestStatistic::optimizeConstantTerms(
bool activate,
bool applyTrackingOpt)
541 if (
_funcClone->getAttribute(
"NoOptimizeLevel1")) {
542 coutI(Minimization) <<
" Optimization customization: Level-1 constant-term optimization prohibited by attribute NoOptimizeLevel1 set on top-level pdf "
546 if (
_funcClone->getAttribute(
"NoOptimizeLevel2")) {
547 coutI(Minimization) <<
" Optimization customization: Level-2 constant-term optimization prohibited by attribute NoOptimizeLevel2 set on top-level pdf "
563 coutW(Optimization) <<
"RooAbsOptTestStatistic::optimizeConstantTerms(" << GetName()
564 <<
") WARNING Cache-and-track optimization (Optimize level 2) is only available for datasets"
565 <<
" implement in terms of RooVectorDataStore - ignoring this option for current dataset" << std::endl ;
577 trackNodes.remove(*std::unique_ptr<RooAbsCollection>{
trackNodes.selectByAttrib(
"Constant",
true)});
580 trackNodes.setAttribAll(
"CacheAndTrack",
true) ;
596 std::unique_ptr<RooAbsCollection>
constNodes{
_cachedNodes.selectByAttrib(
"ConstantExpressionCached",
true)};
601 coutI(Minimization) <<
" The following expressions have been identified as constant and will be precalculated and cached: " << *
constNodes << std::endl ;
603 coutI(Minimization) <<
" A total of " <<
constNodes->size() <<
" expressions have been identified as constant and will be precalculated and cached." << std::endl ;
608 coutI(Minimization) <<
" The following expressions will be evaluated in cache-and-track mode: " <<
actualTrackNodes << std::endl ;
610 coutI(Minimization) <<
" A total of " <<
constNodes->size() <<
" expressions will be evaluated in cache-and-track-mode." << std::endl ;
667 coutW(InputArguments) <<
"RooAbsOptTestStatistic::setData(" << GetName() <<
") WARNING: test statistic was constructed with range selection on data, "
668 <<
"ignoring request to _not_ clone the input dataset" << std::endl ;
703 if(_takeGlobalObservablesFromData && _data->getGlobalObservables()) {
704 recursiveRedirectServers(*_data->getGlobalObservables()) ;
719 coutW(ObjectHandling) <<
"RooAbsOptTestStatistic::data(" << GetName()
720 <<
") WARNING: object sealed by creator - access to data is not permitted: "
731const RooAbsData& RooAbsOptTestStatistic::data()
const
735 coutW(ObjectHandling) <<
"RooAbsOptTestStatistic::data(" << GetName()
736 <<
") WARNING: object sealed by creator - access to data is not permitted: "
752void RooAbsOptTestStatistic::setUpBinSampling() {
754 auto& pdf =
static_cast<RooAbsPdf&
>(*_funcClone);
765const char* RooAbsOptTestStatistic::cacheUniqueSuffix()
const {
int Int_t
Signed integer 4 bytes (int)
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Abstract container object that can hold multiple RooAbsArg objects.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Abstract base class for binned and unbinned datasets.
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Abstract base class for objects that represent a real value and implements functionality common to al...
virtual double getValV(const RooArgSet *normalisationSet=nullptr) const
Return value of object.
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursiveStep) override
Function that is called at the end of redirectServers().
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
static std::unique_ptr< RooAbsPdf > create(RooAbsPdf &pdf, RooAbsData const &data, double precision)
Creates a wrapping RooBinSamplingPdf if appropriate.
Container class to hold unbinned data.
static void softAbort()
Soft abort function that interrupts macro execution but doesn't kill ROOT.
Efficient implementation of a product of PDFs of the form.
Variable that can be changed from the outside.
Uses std::vector to store data columns.
const char * GetName() const override
Returns name of object.
RooCmdArg SelectVars(const RooArgSet &vars)
RooCmdArg CutRange(const char *rangeName)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
std::unique_ptr< T > cloneTreeWithSameParameters(T const &arg, RooArgSet const *observables=nullptr)
Clone RooAbsArg object and reattach to original parameters.
static uint64_t sum(uint64_t i)