Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAbsOptTestStatistic.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 *
4 * Copyright (c) 2024, CERN
5 *
6 * Redistribution and use in source and binary forms,
7 * with or without modification, are permitted according to the terms
8 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
9 */
10
11#ifndef ROO_ABS_OPT_TEST_STATISTIC
12#define ROO_ABS_OPT_TEST_STATISTIC
13
14#include "RooAbsTestStatistic.h"
15#include "RooSetProxy.h"
16#include "RooCategoryProxy.h"
17#include "TString.h"
18
19class RooArgSet ;
20class RooAbsData ;
21class RooAbsReal ;
22
24public:
25
26 // Constructors, assignment etc
27 RooAbsOptTestStatistic(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
28 const RooArgSet& projDeps,
30 RooAbsOptTestStatistic(const RooAbsOptTestStatistic& other, const char* name=nullptr);
31 ~RooAbsOptTestStatistic() override;
32
33 double combinedValue(RooAbsReal** gofArray, Int_t nVal) const override ;
34
36 const RooAbsReal& function() const { return *_funcClone ; }
37
38 RooAbsData& data() ;
39 const RooAbsData& data() const ;
40
41
42 const char* cacheUniqueSuffix() const override;
43
44 // Override this to be always true to force calculation of likelihood without parameters
45 bool isDerived() const override { return true ; }
46
47 void seal(const char* notice="") { _sealed = true ; _sealNotice = notice ; }
48 bool isSealed() const { return _sealed ; }
49 const char* sealNotice() const { return _sealNotice.Data() ; }
50
51private:
52 void setUpBinSampling();
53
54protected:
55
56 bool setDataSlave(RooAbsData& data, bool cloneData=true, bool ownNewDataAnyway=false) override ;
57 void initSlave(RooAbsReal& real, RooAbsData& indata, const RooArgSet& projDeps, const char* rangeName,
58 const char* addCoefRangeName) ;
59
60 friend class RooAbsReal ;
61 friend class RooAbsTestStatistic ;
62
63 virtual bool allowFunctionCache() { return true ; }
64 void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true) override ;
65
66 bool redirectServersHook(const RooAbsCollection& newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override ;
67 void printCompactTreeHook(std::ostream& os, const char* indent="") override ;
68 virtual RooArgSet requiredExtraObservables() const { return RooArgSet() ; }
69 void optimizeCaching() ;
70 void optimizeConstantTerms(bool,bool=true) ;
71 void runRecalculateCache(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const override;
72
73 RooArgSet* _normSet = nullptr; ///< Pointer to set with observables used for normalization
74 RooArgSet* _funcCloneSet = nullptr; ///< Set owning all components of internal clone of input function
75 RooAbsData* _dataClone = nullptr; ///< Pointer to internal clone if input data
76 RooAbsReal* _funcClone = nullptr; ///< Pointer to internal clone of input function
77 RooArgSet* _projDeps = nullptr; ///< Set of projected observable
78 bool _ownData = false; ///< Do we own the dataset
79 bool _sealed = false; ///< Is test statistic sealed -- i.e. no access to data
80 TString _sealNotice ; ///< User-defined notice shown when reading a sealed likelihood
81 RooArgSet* _funcObsSet = nullptr; ///< List of observables in the pdf expression
82 RooArgSet _cachedNodes ; ///<! List of nodes that are cached as constant expressions
83 bool _skipZeroWeights = false; ///<! Whether to skip entries with weight zero in the evaluation
84
85 RooAbsReal* _origFunc = nullptr; ///< Original function
86 RooAbsData* _origData = nullptr; ///< Original data
87 bool _optimized = false; ///<!
88 double _integrateBinsPrecision{-1.}; // Precision for finer sampling of bins.
89};
90
91#endif
static void indent(ostringstream &buf, int indent_level)
char name[80]
Definition TGX11.cxx:110
Abstract container object that can hold multiple RooAbsArg objects.
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
Abstract base class for test statistics objects that evaluate a function or PDF at each point of a gi...
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.
void seal(const char *notice="")
void runRecalculateCache(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const override
const RooAbsReal & function() const
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
bool isDerived() const override
Does value or shape of this arg depend on any other arg?
RooAbsData * _origData
Original data.
bool _skipZeroWeights
! Whether to skip entries with weight zero in the evaluation
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)
TString _sealNotice
User-defined notice shown when reading a sealed likelihood.
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
RooArgSet * _projDeps
Set of projected observable.
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
Abstract base class for all test statistics.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376