96RooAbsOptTestStatistic::RooAbsOptTestStatistic(
const char *
name,
const char *title,
RooAbsReal &
real,
98 RooAbsTestStatistic::Configuration
const &cfg)
103 if (operMode() !=
Slave) {
113RooAbsOptTestStatistic::RooAbsOptTestStatistic(
const RooAbsOptTestStatistic &
other,
const char *
name)
121 if (operMode() !=
Slave) {
123 if (
other._normSet) {
125 other._normSet->snapshot(*_normSet);
151 if (
_funcClone->getAttribute(
"BinnedLikelihood")) {
152 _funcClone->setAttribute(
"BinnedLikelihoodActive") ;
156 if (!projDeps.
empty()) {
179 indata.get()->snapshot(*_normSet,
false);
183 for (std::size_t i = 0; i <
_funcObsSet->size(); ++i) {
211 coutE(InputArguments) <<
"RooAbsOptTestStatistic: ERROR minimum of FUNC observable " << arg->
GetName()
212 <<
"(" <<
realReal->getMin() <<
") is smaller than that of "
213 << arg->GetName() <<
" in the dataset (" <<
datReal->getMin() <<
")" << std::endl ;
219 coutE(InputArguments) <<
"RooAbsOptTestStatistic: ERROR maximum of FUNC observable " << arg->GetName()
220 <<
" is larger than that of " << arg->GetName() <<
" in the dataset" << std::endl ;
242 cxcoutI(Fitting) <<
"RooAbsOptTestStatistic::ctor(" << GetName() <<
") constructing test statistic for sub-range named " <<
rangeName << std::endl ;
254 for(std::string
const& token :
tokens) {
255 if(!
realObs->hasRange(token.c_str())) {
257 errMsg <<
"The observable \"" <<
realObs->GetName() <<
"\" doesn't define the requested range \""
258 << token <<
"\". Replacing it with the default range." << std::endl;
281 cxcoutI(Fitting) <<
"RooAbsOptTestStatistic::ctor(" << GetName()
282 <<
") fixing interpretation of coefficients of any RooAddPdf component to range " <<
addCoefRangeName << std::endl ;
300 if (!projDeps.
empty()) {
303 projDeps.
snapshot(*_projDeps,
false) ;
306 _normSet->
remove(*_projDeps,
true,
true) ;
315 coutI(Optimization) <<
"RooAbsOptTestStatistic::ctor(" << GetName() <<
") optimizing internal clone of p.d.f for likelihood evaluation."
316 <<
"Lazy evaluation and associated change tracking will disabled for all nodes that depend on observables" << std::endl ;
334 if(_takeGlobalObservablesFromData && _data->getGlobalObservables()) {
335 recursiveRedirectServers(*_data->getGlobalObservables()) ;
344RooAbsOptTestStatistic::~RooAbsOptTestStatistic()
346 if (operMode()==
Slave) {
366double RooAbsOptTestStatistic::combinedValue(
RooAbsReal** array,
Int_t n)
const
371 for (
Int_t i = 0; i <
n; ++i) {
373 carry +=
reinterpret_cast<RooAbsOptTestStatistic*
>(array[i])->getCarry();
375 const double t =
sum +
y;
376 carry = (t -
sum) -
y;
401void RooAbsOptTestStatistic::printCompactTreeHook(ostream& os,
const char*
indent)
403 RooAbsTestStatistic::printCompactTreeHook(os,
indent) ;
420void RooAbsOptTestStatistic::constOptimizeTestStatistic(ConstOpCode opcode,
bool doAlsoTrackingOpt)
424 std::stringstream
ss;
425 ss <<
"Deprecated constant term optimization detected,\n"
426 <<
"enabled via RooFit::Optimize() or RooMinimizer::optimizeConst():\n"
427 <<
" This functionality only affects the legacy evaluation backend.\n"
428 <<
" The vectorized CPU backend performs const term optimization automatically.\n"
429 <<
" The option is ignored and will be removed in ROOT 6.42.\n"
430 <<
" Should your fit not be possible without the legacy backend, please open a GitHub issue.\n";
442 if (opcode==Activate) {
443 cxcoutW(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
444 <<
") dataset cache is owned by another object, no constant term optimization can be applied" << std::endl ;
450 if (opcode==Activate) {
451 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
452 <<
") function caching prohibited by test statistic, no constant term optimization is applied" << std::endl ;
457 if (
_dataClone->hasFilledCache() && opcode==Activate) {
463 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
464 <<
") optimizing evaluation of test statistic by finding all nodes in p.d.f that depend exclusively"
465 <<
" on observables and constant parameters and precalculating their values" << std::endl ;
470 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
471 <<
") deactivating optimization of constant terms in test statistic" << std::endl ;
476 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
477 <<
") one ore more parameter were changed from constant to floating or vice versa, "
478 <<
"re-evaluating constant term optimization" << std::endl ;
484 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
485 <<
") the value of one ore more constant parameter were changed re-evaluating constant term optimization" << std::endl ;
507void RooAbsOptTestStatistic::optimizeCaching()
536void RooAbsOptTestStatistic::optimizeConstantTerms(
bool activate,
bool applyTrackingOpt)
550 if (
_funcClone->getAttribute(
"NoOptimizeLevel1")) {
551 coutI(Minimization) <<
" Optimization customization: Level-1 constant-term optimization prohibited by attribute NoOptimizeLevel1 set on top-level pdf "
555 if (
_funcClone->getAttribute(
"NoOptimizeLevel2")) {
556 coutI(Minimization) <<
" Optimization customization: Level-2 constant-term optimization prohibited by attribute NoOptimizeLevel2 set on top-level pdf "
572 coutW(Optimization) <<
"RooAbsOptTestStatistic::optimizeConstantTerms(" << GetName()
573 <<
") WARNING Cache-and-track optimization (Optimize level 2) is only available for datasets"
574 <<
" implement in terms of RooVectorDataStore - ignoring this option for current dataset" << std::endl ;
586 trackNodes.remove(*std::unique_ptr<RooAbsCollection>{
trackNodes.selectByAttrib(
"Constant",
true)});
589 trackNodes.setAttribAll(
"CacheAndTrack",
true) ;
605 std::unique_ptr<RooAbsCollection>
constNodes{
_cachedNodes.selectByAttrib(
"ConstantExpressionCached",
true)};
610 coutI(Minimization) <<
" The following expressions have been identified as constant and will be precalculated and cached: " << *
constNodes << std::endl ;
612 coutI(Minimization) <<
" A total of " <<
constNodes->size() <<
" expressions have been identified as constant and will be precalculated and cached." << std::endl ;
617 coutI(Minimization) <<
" The following expressions will be evaluated in cache-and-track mode: " <<
actualTrackNodes << std::endl ;
619 coutI(Minimization) <<
" A total of " <<
constNodes->size() <<
" expressions will be evaluated in cache-and-track-mode." << std::endl ;
680 coutW(InputArguments) <<
"RooAbsOptTestStatistic::setData(" << GetName() <<
") WARNING: test statistic was constructed with range selection on data, "
681 <<
"ignoring request to _not_ clone the input dataset" << std::endl ;
716 if(_takeGlobalObservablesFromData && _data->getGlobalObservables()) {
717 recursiveRedirectServers(*_data->getGlobalObservables()) ;
732 coutW(ObjectHandling) <<
"RooAbsOptTestStatistic::data(" << GetName()
733 <<
") WARNING: object sealed by creator - access to data is not permitted: "
744const RooAbsData& RooAbsOptTestStatistic::data()
const
748 coutW(ObjectHandling) <<
"RooAbsOptTestStatistic::data(" << GetName()
749 <<
") WARNING: object sealed by creator - access to data is not permitted: "
765void RooAbsOptTestStatistic::setUpBinSampling() {
767 auto& pdf =
static_cast<RooAbsPdf&
>(*_funcClone);
778const 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)