126 _integrateBinsPrecision(cfg.integrateOverBinsPrecision)
154 _integrateBinsPrecision(other._integrateBinsPrecision)
182 const char* addCoefRangeName) {
206 delete projDataDeps ;
237 if (realDepRLV && realDepRLV->isDerived()) {
239 realDepRLV->leafNodeServerList(&tmp2, 0,
true);
256 if (!realReal) continue ;
258 if (!datReal) continue ;
263 coutE(
InputArguments) <<
"RooAbsOptTestStatistic: ERROR minimum of FUNC observable " << arg->GetName()
264 <<
"(" << realReal->
getMin() <<
") is smaller than that of "
265 << arg->GetName() <<
" in the dataset (" << datReal->
getMin() <<
")" << endl ;
271 coutE(
InputArguments) <<
"RooAbsOptTestStatistic: ERROR maximum of FUNC observable " << arg->GetName()
272 <<
" is larger than that of " << arg->GetName() <<
" in the dataset" << endl ;
279 if (rangeName && strlen(rangeName)) {
292 std::unique_ptr<RooArgSet> origObsSet( real.
getObservables(indata) );
294 if (rangeName && strlen(rangeName)) {
295 cxcoutI(
Fitting) <<
"RooAbsOptTestStatistic::ctor(" <<
GetName() <<
") constructing test statistic for sub-range named " << rangeName << endl ;
297 bool observablesKnowRange =
false;
304 auto transferRangeAndBinning = [&](
RooRealVar & toVar,
const char* toName,
const char* fromName) {
310 if(!fromName || realObs->
hasBinning(fromName)) {
315 observablesKnowRange |= realObs->
hasRange(rangeName);
318 if (!(addCoefRangeName && strlen(addCoefRangeName))) {
319 transferRangeAndBinning(*realObs,
Form(
"NormalizationRangeFor%s",rangeName),
nullptr);
323 transferRangeAndBinning(*realObs,
nullptr, rangeName);
327 transferRangeAndBinning(*dataObs,
nullptr, rangeName);
331 const std::string fitRangeName = std::string(
"fit_") +
GetName();
333 std::string newAttr = origAttrib ? origAttrib :
"";
335 if (newAttr.find(fitRangeName) == std::string::npos) {
336 newAttr += (newAttr.empty() ?
"" :
",") + fitRangeName;
341 transferRangeAndBinning(*origObs, fitRangeName.c_str(), rangeName);
347 if (!observablesKnowRange)
348 coutW(
Fitting) <<
"None of the fit observables seem to know the range '" << rangeName <<
"'. This means that the full range will be used." << std::endl;
360 if (rangeName && strlen(rangeName)) {
365 if (addCoefRangeName && strlen(addCoefRangeName)) {
367 <<
") fixing interpretation of coefficients of any RooAddPdf component to range " << addCoefRangeName << endl ;
371 <<
") fixing interpretation of coefficients of any RooAddPdf to full domain of observables " << endl ;
399 delete projDataDeps ;
403 coutI(
Optimization) <<
"RooAbsOptTestStatistic::ctor(" <<
GetName() <<
") optimizing internal clone of p.d.f for likelihood evaluation."
404 <<
"Lazy evaluation and associated change tracking will disabled for all nodes that depend on observables" << endl ;
457 double sum(0), carry(0);
458 for (
Int_t i = 0; i <
n; ++i) {
462 const double t =
sum +
y;
463 carry = (t -
sum) -
y;
493 indent2 +=
"opt >>" ;
518 <<
") dataset cache is owned by another object, no constant term optimization can be applied" << endl ;
526 <<
") function caching prohibited by test statistic, no constant term optimization is applied" << endl ;
538 <<
") optimizing evaluation of test statistic by finding all nodes in p.d.f that depend exclusively"
539 <<
" on observables and constant parameters and precalculating their values" << endl ;
545 <<
") deactivating optimization of constant terms in test statistic" << endl ;
551 <<
") one ore more parameter were changed from constant to floating or vice versa, "
552 <<
"re-evaluating constant term optimization" << endl ;
559 <<
") the value of one ore more constant parameter were changed re-evaluating constant term optimization" << endl ;
625 coutI(
Minimization) <<
" Optimization customization: Level-1 constant-term optimization prohibited by attribute NoOptimizeLevel1 set on top-level pdf "
630 coutI(
Minimization) <<
" Optimization customization: Level-2 constant-term optimization prohibited by attribute NoOptimizeLevel2 set on top-level pdf "
632 applyTrackingOpt=false ;
644 if (applyTrackingOpt) {
647 <<
") WARNING Cache-and-track optimization (Optimize level 2) is only available for datasets"
648 <<
" implement in terms of RooVectorDataStore - ignoring this option for current dataset" << endl ;
649 applyTrackingOpt = false ;
653 if (applyTrackingOpt) {
656 for (
auto arg : branches) {
657 arg->setCacheAndTrackHints(trackNodes);
661 trackNodes.
remove(*constNodes) ;
683 actualTrackNodes.
remove(*constNodes) ;
685 if (constNodes->
getSize()<20) {
686 coutI(
Minimization) <<
" The following expressions have been identified as constant and will be precalculated and cached: " << *constNodes << endl ;
688 coutI(
Minimization) <<
" A total of " << constNodes->
getSize() <<
" expressions have been identified as constant and will be precalculated and cached." << endl ;
691 if (actualTrackNodes.
getSize()>0) {
692 if (actualTrackNodes.
getSize()<20) {
693 coutI(
Minimization) <<
" The following expressions will be evaluated in cache-and-track mode: " << actualTrackNodes << endl ;
695 coutI(
Minimization) <<
" A total of " << constNodes->
getSize() <<
" expressions will be evaluated in cache-and-track-mode." << endl ;
750 std::unique_ptr<RooAbsData> oldOwnedData;
757 coutW(
InputArguments) <<
"RooAbsOptTestStatistic::setData(" <<
GetName() <<
") WARNING: test statistic was constructed with range selection on data, "
758 <<
"ignoring request to _not_ clone the input dataset" << endl ;
814 <<
") WARNING: object sealed by creator - access to data is not permitted: "
815 << (notice?
sealNotice():
"<no user notice>") << endl ;
830 <<
") WARNING: object sealed by creator - access to data is not permitted: "
831 << (notice?
sealNotice():
"<no user notice>") << endl ;
848 auto& pdf =
static_cast<RooAbsPdf&
>(*_funcClone);
static void indent(ostringstream &buf, int indent_level)
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
virtual RooAbsArg * cloneTree(const char *newname=0) const
Clone tree expression of objects.
bool recursiveRedirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool recurseInNewSet=true)
Recursively replace all servers with the new servers in newSet.
void printCompactTree(const char *indent="", const char *fileName=0, const char *namePat=0, RooAbsArg *client=0)
Print tree structure of expression tree on stdout, or to file if filename is specified.
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
RooArgSet * getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
bool findConstantNodes(const RooArgSet &observables, RooArgSet &cacheList)
Find branch nodes with all-constant parameters, and add them to the list of nodes that can be cached ...
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
virtual void optimizeCacheMode(const RooArgSet &observables)
Activate cache mode optimization with given definition of observables.
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
RooArgSet * getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
void branchNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=0, bool recurseNonDerived=false) const
Fill supplied list with all branch nodes of the arg tree starting with ourself as top node.
virtual RooAbsReal * highBoundFunc() const
Return pointer to RooAbsReal parameterized upper bound, if any.
virtual RooAbsReal * lowBoundFunc() const
Return pointer to RooAbsReal parameterized lower bound, if any.
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
RooAbsCollection * selectByAttrib(const char *name, bool value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void setAttribAll(const Text_t *name, bool value=true)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
Storage_t::size_type size() const
RooAbsArg * first() const
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual const RooAbsArg * cacheOwner()=0
virtual void forceCacheUpdate()
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
RooAbsDataStore * store()
RooFit::UniqueId< RooAbsData > const & uniqueId() const
Returns a unique ID that is different for every instantiated RooAbsData object.
void setDirtyProp(bool flag)
Control propagation of dirty flags from observables in dataset.
virtual void setArgStatus(const RooArgSet &set, bool active)
virtual void optimizeReadingWithCaching(RooAbsArg &arg, const RooArgSet &cacheList, const RooArgSet &keepObsList)
Prepare dataset for use with cached constant terms listed in 'cacheList' of expression 'arg'.
bool hasFilledCache() const
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
RooArgSet const * getGlobalObservables() const
Returns snapshot of global observables stored in this data.
virtual void resetCache()
Internal method – Remove cached function values.
RooAbsData * reduce(const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg())
Create a reduced copy of this dataset.
void attachBuffers(const RooArgSet &extObs)
virtual void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=0, bool skipZeroWeights=false)
Internal method – Cache given set of functions with data.
RooAbsOptTestStatistic is the abstract base class for test statistics objects that evaluate a functio...
bool setDataSlave(RooAbsData &data, bool cloneData=true, bool ownNewDataAnyway=false) override
Change dataset that is used to given one.
~RooAbsOptTestStatistic() override
Destructor.
RooAbsReal * _funcClone
Pointer to internal clone of input function.
bool _sealed
Is test statistic sealed – i.e. no access to data.
void optimizeConstantTerms(bool, bool=true)
Driver function to activate global constant term optimization.
double combinedValue(RooAbsReal **gofArray, Int_t nVal) const override
Method to combined test statistic results calculated into partitions into the global result.
RooAbsReal * _origFunc
Original function.
bool _ownData
Do we own the dataset.
void optimizeCaching()
This method changes the value caching logic for all nodes that depends on any of the observables as d...
const char * sealNotice() const
RooAbsData * _origData
Original data.
virtual bool allowFunctionCache()
RooArgSet * _funcObsSet
List of observables in the pdf expression.
void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true) override
Driver function to propagate constant term optimizations in test statistic.
void setUpBinSampling()
Inspect PDF to find out if we are doing a binned fit to a 1-dimensional unbinned PDF.
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override
Catch server redirect calls and forward to internal clone of function.
RooArgSet _cachedNodes
! List of nodes that are cached as constant expressions
void initSlave(RooAbsReal &real, RooAbsData &indata, const RooArgSet &projDeps, const char *rangeName, const char *addCoefRangeName)
void printCompactTreeHook(std::ostream &os, const char *indent="") override
Catch print hook function and forward to function clone.
RooArgSet * _normSet
Pointer to set with observables used for normalization.
const char * cacheUniqueSuffix() const override
Returns a suffix string that is unique for RooAbsOptTestStatistic instances that don't share the same...
RooArgSet * _funcCloneSet
Set owning all components of internal clone of input function.
RooAbsData * _dataClone
Pointer to internal clone if input data.
virtual RooArgSet requiredExtraObservables() const
RooAbsOptTestStatistic()
Default Constructor.
double _integrateBinsPrecision
RooArgSet * _projDeps
Set of projected observable.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual double getMax(const char *name=0) const
Get maximum of currently defined range.
virtual double getMin(const char *name=0) const
Get minimum of currently defined range.
bool hasRange(const char *name) const override
Check if variable has a binning with given name.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual double getValV(const RooArgSet *normalisationSet=nullptr) const
Return value of object.
virtual void fixAddCoefNormalization(const RooArgSet &addNormSet=RooArgSet(), bool force=true)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
virtual void fixAddCoefRange(const char *rangeName=0, bool force=true)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
RooAbsTestStatistic is the abstract base class for all test statistics.
double _evalCarry
! carry of Kahan sum in evaluatePartition
std::string _addCoefRangeName
Name of reference to be used for RooAddPdf components.
GOFOpMode operMode() const
RooSetProxy _paramSet
Parameters of the test statistic (=parameters of the input function)
RooAbsReal * _func
Pointer to original input function.
void printCompactTreeHook(std::ostream &os, const char *indent="") override
Add extra information on component test statistics when printing itself as part of a tree structure.
std::string _rangeName
Name of range in which to calculate test statistic.
void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true) override
Forward constant term optimization management calls to component test statistics.
void setEventCount(Int_t nEvents)
virtual double getCarry() const
bool _splitRange
Split rangeName in RooSimultaneous index labels if true.
RooAbsData * _data
Pointer to original input dataset.
const bool _takeGlobalObservablesFromData
If the global observable values are taken from data.
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override
Forward server redirect calls to component test statistics.
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.
void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
RooDataSet is a container class to hold unbinned data.
static void softAbort()
Soft abort function that interrupts macro execution but doesn't kill ROOT.
RooProdPdf is an efficient implementation of a product of PDFs of the form.
RooArgSet * getConnectedParameters(const RooArgSet &observables) const
Return all parameter constraint p.d.f.s on parameters listed in constrainedParams.
RooRealVar represents a variable that can be changed from the outside.
bool hasBinning(const char *name) const override
Returns true if variable has a binning named 'name'.
const RooAbsBinning & getBinning(const char *name=0, bool verbose=true, bool createOnTheFly=false) const override
Return binning definition with name.
void setRange(const char *name, double min, double max)
Set a fit or plotting range.
void setBinning(const RooAbsBinning &binning, const char *name=0)
Add given binning under name 'name' with this variable.
RooVectorDataStore uses std::vectors to store data columns.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
const char * GetName() const override
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
const char * Data() const
RooCmdArg SelectVars(const RooArgSet &vars)
RooCmdArg CutRange(const char *rangeName)
constexpr Value_t value() const
Return numerical value of ID.
static uint64_t sum(uint64_t i)