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 ;
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)
430 cxcoutW(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
431 <<
") dataset cache is owned by another object, no constant term optimization can be applied" << std::endl ;
438 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
439 <<
") function caching prohibited by test statistic, no constant term optimization is applied" << std::endl ;
450 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
451 <<
") optimizing evaluation of test statistic by finding all nodes in p.d.f that depend exclusively"
452 <<
" on observables and constant parameters and precalculating their values" << std::endl ;
457 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
458 <<
") deactivating optimization of constant terms in test statistic" << std::endl ;
463 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
464 <<
") one ore more parameter were changed from constant to floating or vice versa, "
465 <<
"re-evaluating constant term optimization" << std::endl ;
471 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" << GetName()
472 <<
") the value of one ore more constant parameter were changed re-evaluating constant term optimization" << std::endl ;
494void RooAbsOptTestStatistic::optimizeCaching()
523void RooAbsOptTestStatistic::optimizeConstantTerms(
bool activate,
bool applyTrackingOpt)
537 if (
_funcClone->getAttribute(
"NoOptimizeLevel1")) {
538 coutI(Minimization) <<
" Optimization customization: Level-1 constant-term optimization prohibited by attribute NoOptimizeLevel1 set on top-level pdf "
542 if (
_funcClone->getAttribute(
"NoOptimizeLevel2")) {
543 coutI(Minimization) <<
" Optimization customization: Level-2 constant-term optimization prohibited by attribute NoOptimizeLevel2 set on top-level pdf "
559 coutW(Optimization) <<
"RooAbsOptTestStatistic::optimizeConstantTerms(" << GetName()
560 <<
") WARNING Cache-and-track optimization (Optimize level 2) is only available for datasets"
561 <<
" implement in terms of RooVectorDataStore - ignoring this option for current dataset" << std::endl ;
573 trackNodes.remove(*std::unique_ptr<RooAbsCollection>{
trackNodes.selectByAttrib(
"Constant",
true)});
576 trackNodes.setAttribAll(
"CacheAndTrack",
true) ;
592 std::unique_ptr<RooAbsCollection>
constNodes{
_cachedNodes.selectByAttrib(
"ConstantExpressionCached",
true)};
597 coutI(Minimization) <<
" The following expressions have been identified as constant and will be precalculated and cached: " << *
constNodes << std::endl ;
599 coutI(Minimization) <<
" A total of " <<
constNodes->size() <<
" expressions have been identified as constant and will be precalculated and cached." << std::endl ;
604 coutI(Minimization) <<
" The following expressions will be evaluated in cache-and-track mode: " <<
actualTrackNodes << std::endl ;
606 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 {
770void RooAbsOptTestStatistic::runRecalculateCache(std::size_t firstEvent, std::size_t
lastEvent, std::size_t
stepSize)
const
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.
void Activate(TList *slaves=0)
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
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)