125 _integrateBinsPrecision(cfg.integrateOverBinsPrecision)
153 _integrateBinsPrecision(other._integrateBinsPrecision)
181 const char* addCoefRangeName) {
205 delete projDataDeps ;
236 if (realDepRLV && realDepRLV->isDerived()) {
238 realDepRLV->leafNodeServerList(&tmp2, 0,
kTRUE);
255 if (!realReal) continue ;
257 if (!datReal) continue ;
262 coutE(InputArguments) <<
"RooAbsOptTestStatistic: ERROR minimum of FUNC observable " << arg->
GetName()
263 <<
"(" << realReal->
getMin() <<
") is smaller than that of "
264 << arg->GetName() <<
" in the dataset (" << datReal->
getMin() <<
")" << endl ;
270 coutE(InputArguments) <<
"RooAbsOptTestStatistic: ERROR maximum of FUNC observable " << arg->GetName()
271 <<
" is larger than that of " << arg->GetName() <<
" in the dataset" << endl ;
278 if (rangeName && strlen(rangeName)) {
291 std::unique_ptr<RooArgSet> origObsSet( real.
getObservables(indata) );
293 if (rangeName && strlen(rangeName)) {
294 cxcoutI(Fitting) <<
"RooAbsOptTestStatistic::ctor(" <<
GetName() <<
") constructing test statistic for sub-range named " << rangeName << endl ;
296 bool observablesKnowRange =
false;
303 auto transferRangeAndBinning = [&](
RooRealVar & toVar,
const char* toName,
const char* fromName) {
309 if(!fromName || realObs->
hasBinning(fromName)) {
314 observablesKnowRange |= realObs->
hasRange(rangeName);
317 if (!(addCoefRangeName && strlen(addCoefRangeName))) {
318 transferRangeAndBinning(*realObs,
Form(
"NormalizationRangeFor%s",rangeName),
nullptr);
322 transferRangeAndBinning(*realObs,
nullptr, rangeName);
326 transferRangeAndBinning(*dataObs,
nullptr, rangeName);
330 const std::string fitRangeName = std::string(
"fit_") +
GetName();
332 std::string newAttr = origAttrib ? origAttrib :
"";
334 if (newAttr.find(fitRangeName) == std::string::npos) {
335 newAttr += (newAttr.empty() ?
"" :
",") + fitRangeName;
340 transferRangeAndBinning(*origObs, fitRangeName.c_str(), rangeName);
346 if (!observablesKnowRange)
347 coutW(Fitting) <<
"None of the fit observables seem to know the range '" << rangeName <<
"'. This means that the full range will be used." << std::endl;
366 if (rangeName && strlen(rangeName)) {
371 if (addCoefRangeName && strlen(addCoefRangeName)) {
373 <<
") fixing interpretation of coefficients of any RooAddPdf component to range " << addCoefRangeName << endl ;
377 <<
") fixing interpretation of coefficients of any RooAddPdf to full domain of observables " << endl ;
405 delete projDataDeps ;
409 coutI(Optimization) <<
"RooAbsOptTestStatistic::ctor(" <<
GetName() <<
") optimizing internal clone of p.d.f for likelihood evaluation."
410 <<
"Lazy evaluation and associated change tracking will disabled for all nodes that depend on observables" << endl ;
464 for (
Int_t i = 0; i <
n; ++i) {
469 carry = (t -
sum) -
y;
499 indent2 +=
"opt >>" ;
523 cxcoutW(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" <<
GetName()
524 <<
") dataset cache is owned by another object, no constant term optimization can be applied" << endl ;
531 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" <<
GetName()
532 <<
") function caching prohibited by test statistic, no constant term optimization is applied" << endl ;
543 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" <<
GetName()
544 <<
") optimizing evaluation of test statistic by finding all nodes in p.d.f that depend exclusively"
545 <<
" on observables and constant parameters and precalculating their values" << endl ;
550 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" <<
GetName()
551 <<
") deactivating optimization of constant terms in test statistic" << endl ;
556 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" <<
GetName()
557 <<
") one ore more parameter were changed from constant to floating or vice versa, "
558 <<
"re-evaluating constant term optimization" << endl ;
564 cxcoutI(Optimization) <<
"RooAbsOptTestStatistic::constOptimize(" <<
GetName()
565 <<
") the value of one ore more constant parameter were changed re-evaluating constant term optimization" << endl ;
631 coutI(Minimization) <<
" Optimization customization: Level-1 constant-term optimization prohibited by attribute NoOptimizeLevel1 set on top-level pdf "
636 coutI(Minimization) <<
" Optimization customization: Level-2 constant-term optimization prohibited by attribute NoOptimizeLevel2 set on top-level pdf "
650 if (applyTrackingOpt) {
652 coutW(Optimization) <<
"RooAbsOptTestStatistic::optimizeConstantTerms(" <<
GetName()
653 <<
") WARNING Cache-and-track optimization (Optimize level 2) is only available for datasets"
654 <<
" implement in terms of RooVectorDataStore - ignoring this option for current dataset" << endl ;
655 applyTrackingOpt =
kFALSE ;
659 if (applyTrackingOpt) {
662 for (
auto arg : branches) {
663 arg->setCacheAndTrackHints(trackNodes);
667 trackNodes.
remove(*constNodes) ;
689 actualTrackNodes.
remove(*constNodes) ;
691 if (constNodes->
getSize()<20) {
692 coutI(Minimization) <<
" The following expressions have been identified as constant and will be precalculated and cached: " << *constNodes << endl ;
694 coutI(Minimization) <<
" A total of " << constNodes->
getSize() <<
" expressions have been identified as constant and will be precalculated and cached." << endl ;
697 if (actualTrackNodes.
getSize()>0) {
698 if (actualTrackNodes.
getSize()<20) {
699 coutI(Minimization) <<
" The following expressions will be evaluated in cache-and-track mode: " << actualTrackNodes << endl ;
701 coutI(Minimization) <<
" A total of " << constNodes->
getSize() <<
" expressions will be evaluated in cache-and-track-mode." << endl ;
756 std::unique_ptr<RooAbsData> oldOwnedData;
763 coutW(InputArguments) <<
"RooAbsOptTestStatistic::setData(" <<
GetName() <<
") WARNING: test statistic was constructed with range selection on data, "
764 <<
"ignoring request to _not_ clone the input dataset" << endl ;
819 coutW(ObjectHandling) <<
"RooAbsOptTestStatistic::data(" <<
GetName()
820 <<
") WARNING: object sealed by creator - access to data is not permitted: "
821 << (notice?
sealNotice():
"<no user notice>") << endl ;
835 coutW(ObjectHandling) <<
"RooAbsOptTestStatistic::data(" <<
GetName()
836 <<
") WARNING: object sealed by creator - access to data is not permitted: "
837 << (notice?
sealNotice():
"<no user notice>") << endl ;
854 auto& pdf =
static_cast<RooAbsPdf&
>(*_funcClone);
static void indent(ostringstream &buf, int indent_level)
char * Form(const char *fmt,...)
virtual RooAbsArg * cloneTree(const char *newname=0) const
Clone tree expression of objects.
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Given a set of possible observables, return the observables that this PDF depends on.
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'.
Bool_t 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 ...
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'.
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
virtual void optimizeCacheMode(const RooArgSet &observables)
Activate cache mode optimization with given definition of observables.
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
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_t recurseNonDerived=kFALSE) const
Fill supplied list with all branch nodes of the arg tree starting with ourself as top node.
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
Recursively replace all servers with the new servers in newSet.
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.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Storage_t::size_type size() const
RooAbsArg * first() const
void setAttribAll(const Text_t *name, Bool_t value=kTRUE)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
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...
RooAbsCollection * selectByAttrib(const char *name, Bool_t value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
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()
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'.
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.
Bool_t hasFilledCache() const
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.
virtual void cacheArgs(const RooAbsArg *owner, RooArgSet &varSet, const RooArgSet *nset=0, Bool_t skipZeroWeights=kFALSE)
Internal method – Cache given set of functions with data.
void attachBuffers(const RooArgSet &extObs)
virtual void setArgStatus(const RooArgSet &set, Bool_t active)
void setDirtyProp(Bool_t flag)
Control propagation of dirty flags from observables in dataset.
RooAbsOptTestStatistic is the abstract base class for test statistics objects that evaluate a functio...
virtual ~RooAbsOptTestStatistic()
Destructor.
RooAbsReal * _origFunc
List of nodes that are cached as constant expressions.
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
void optimizeConstantTerms(Bool_t, Bool_t=kTRUE)
Driver function to activate global constant term optimization.
void setUpBinSampling()
Inspect PDF to find out if we are doing a binned fit to a 1-dimensional unbinned PDF.
virtual Bool_t allowFunctionCache()
virtual Bool_t redirectServersHook(const RooAbsCollection &newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
Catch server redirect calls and forward to internal clone of function.
virtual void printCompactTreeHook(std::ostream &os, const char *indent="")
Catch print hook function and forward to function clone.
void initSlave(RooAbsReal &real, RooAbsData &indata, const RooArgSet &projDeps, const char *rangeName, const char *addCoefRangeName)
virtual Double_t combinedValue(RooAbsReal **gofArray, Int_t nVal) const
Method to combined test statistic results calculated into partitions into the global result.
RooArgSet * _funcCloneSet
virtual RooArgSet requiredExtraObservables() const
RooAbsOptTestStatistic()
Default Constructor.
double _integrateBinsPrecision
Bool_t setDataSlave(RooAbsData &data, Bool_t cloneData=kTRUE, Bool_t ownNewDataAnyway=kFALSE)
Change dataset that is used to given one.
void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
Driver function to propagate constant term optimizations in test statistic.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
virtual Bool_t hasRange(const char *name) const
Check if variable has a binning with given name.
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual void fixAddCoefRange(const char *rangeName=0, Bool_t force=kTRUE)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual Double_t getValV(const RooArgSet *normalisationSet=nullptr) const
Return value of object.
virtual void fixAddCoefNormalization(const RooArgSet &addNormSet=RooArgSet(), Bool_t force=kTRUE)
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.
std::string _addCoefRangeName
GOFOpMode operMode() const
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
Forward constant term optimization management calls to component test statistics.
virtual Bool_t redirectServersHook(const RooAbsCollection &newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
Forward server redirect calls to component test statistics.
void setEventCount(Int_t nEvents)
virtual Double_t getCarry() const
Double_t _evalCarry
Offset as KahanSum to avoid loss of precision.
const bool _takeGlobalObservablesFromData
virtual void printCompactTreeHook(std::ostream &os, const char *indent="")
Add extra information on component test statistics when printing itself as part of a tree structure.
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.
The RooDataHist is a container class to hold N-dimensional binned data.
void cacheValidEntries()
Compute which bins of the dataset are part of the currently set fit range.
RooDataSet is a container class to hold unbinned data.
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_t hasBinning(const char *name) const
Returns true if variable has a binning named 'name'.
void setRange(const char *name, Double_t min, Double_t max)
Set a fit or plotting range.
const RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const
Return binning definition with name.
void setBinning(const RooAbsBinning &binning, const char *name=0)
Add given binning under name 'name' with this variable.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
virtual void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
RooVectorDataStore uses std::vectors to store data columns.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual const char * GetName() const
Returns name of object.
const char * Data() const
RooCmdArg SelectVars(const RooArgSet &vars)
RooCmdArg CutRange(const char *rangeName)
static uint64_t sum(uint64_t i)