Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAbsTestStatistic.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooAbsGoodnessOfFit.h,v 1.15 2007/05/11 09:11:30 verkerke Exp $
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef ROO_ABS_TEST_STATISTIC
17#define ROO_ABS_TEST_STATISTIC
19// We can't print deprecation warnings when including headers in cling, because
20// this will be done automatically anyway.
21#ifdef __CLING__
22#ifndef ROOFIT_BUILDS_ITSELF
23// These warnings should only be suppressed when building ROOT itself!
24#warning "Including RooAbsTestStatistic.h is deprecated, and this header will be removed in ROOT v6.34: it is an implementation detail that should not be part of the public user interface"
25#else
26// If we are builting RooFit itself, this will serve as a reminder to actually
27// remove this deprecate public header. Here is now this needs to be done:
28// 1. Move this header file from inc/ to src/
29// 2. Remove the LinkDef entry, ClassDefOverride, and ClassImpl macros for
30// this class
31// 3. If there are are tests using this class in the test/ directory, change
32// the include to use a relative path the moved header file in the src/
33// directory, e.g. #include <RemovedInterface.h> becomes #include
34// "../src/RemovedInterface.h"
35// 4. Remove this ifndef-else-endif block from the header
36// 5. Remove the deprecation warning at the end of the class declaration
37#include <RVersion.h>
38#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 34, 00)
39#error "Please remove this deprecated public interface."
40#endif
41#endif
42#endif
43
44#include "RooAbsReal.h"
45#include "RooSetProxy.h"
46#include "RooRealProxy.h"
47#include "TStopwatch.h"
48#include "Math/Util.h"
49
50#include <string>
51#include <vector>
52
53class RooArgSet ;
55class RooAbsReal ;
56class RooSimultaneous ;
58
62
64 friend class RooRealMPFE;
65public:
66
68 /// Stores the configuration parameters for RooAbsTestStatistic.
69 std::string rangeName;
70 std::string addCoefRangeName;
71 int nCPU = 1;
73 bool verbose = true;
74 bool splitCutRange = false;
75 bool cloneInputData = true;
77 bool binnedL = false;
79 };
80
81 // Constructors, assignment etc
82 RooAbsTestStatistic(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
83 const RooArgSet& projDeps, Configuration const& cfg);
84 RooAbsTestStatistic(const RooAbsTestStatistic& other, const char* name=nullptr);
86 virtual RooAbsTestStatistic* create(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
87 const RooArgSet& projDeps, Configuration const& cfg) = 0;
89 void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true) override ;
91 virtual double combinedValue(RooAbsReal** gofArray, Int_t nVal) const = 0 ;
92 virtual double globalNormalization() const {
93 // Default value of global normalization factor is 1.0
94 return 1.0 ;
95 }
96
97 bool setData(RooAbsData& data, bool cloneData=true) override ;
98
99 void enableOffsetting(bool flag) override ;
100 bool isOffsetting() const override { return _doOffset ; }
101 double offset() const override { return _offset.Sum() ; }
102 virtual double offsetCarry() const { return _offset.Carry(); }
106 // Return test statistic operation mode of this instance (SimMaster, MPMaster or Slave)
107 return _gofOpMode ;
110protected:
111
112 void printCompactTreeHook(std::ostream& os, const char* indent="") override ;
113
114 bool redirectServersHook(const RooAbsCollection& newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override ;
115 double evaluate() const override ;
117 virtual double evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const = 0 ;
118 virtual double getCarry() const;
120 // Overridden in cache-optimized test statistic
121 virtual void runRecalculateCache(std::size_t /*firstEvent*/, std::size_t /*lastEvent*/, std::size_t /*stepSize*/) const {}
124 void setSimCount(Int_t simCount) {
125 // Store total number of components p.d.f. of a RooSimultaneous in this component test statistic
126 _simCount = simCount ;
127 }
128
129 void setEventCount(Int_t nEvents) {
130 // Store total number of events in this component test statistic
131 _nEvents = nEvents ;
132 }
133
134 Int_t numSets() const {
135 // Return total number of sets for parallel calculation
136 return _numSets ;
137 }
138 Int_t setNum() const {
139 // Return parallel calculation set number for this instance
140 return _setNum ;
141 }
142
143 RooSetProxy _paramSet ; ///< Parameters of the test statistic (=parameters of the input function)
144
145
146 // Original arguments
147 RooAbsReal* _func = nullptr; ///< Pointer to original input function
148 RooAbsData* _data = nullptr; ///< Pointer to original input dataset
149 const RooArgSet* _projDeps = nullptr; ///< Pointer to set with projected observables
150 std::string _rangeName ; ///< Name of range in which to calculate test statistic
151 std::string _addCoefRangeName ; ///< Name of reference to be used for RooAddPdf components
152 bool _splitRange = false; ///< Split rangeName in RooSimultaneous index labels if true
153 Int_t _simCount = 1; ///< Total number of component p.d.f.s in RooSimultaneous (if any)
154 bool _verbose = false; ///< Verbose messaging if true
155
156 virtual bool setDataSlave(RooAbsData& /*data*/, bool /*cloneData*/=true, bool /*ownNewDataAnyway*/=false) { return true ; }
157
158 //private:
159
160
161 virtual bool processEmptyDataSets() const { return true ; }
162
163 bool initialize() ;
164 void initSimMode(RooSimultaneous* pdf, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName) ;
165 void initMPMode(RooAbsReal* real, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName) ;
166
167 mutable bool _init = false; ///<! Is object initialized
168 GOFOpMode _gofOpMode = Slave; ///< Operation mode of test statistic instance
169
170 Int_t _nEvents = 0; ///< Total number of events in test statistic calculation
171 Int_t _setNum = 0; ///< Partition number of this instance in parallel calculation mode
172 Int_t _numSets = 1; ///< Total number of partitions in parallel calculation mode
173 Int_t _extSet = 0; ///<! Number of designated set to calculated extended term
174
175 // Simultaneous mode data
176 std::vector<std::unique_ptr<RooAbsTestStatistic>> _gofArray; ///<! Array of sub-contexts representing part of the combined test statistic
177
178 // Parallel mode data
179 Int_t _nCPU = 1; ///< Number of processors to use in parallel calculation mode
180 pRooRealMPFE* _mpfeArray = nullptr; ///<! Array of parallel execution frond ends
181
182 RooFit::MPSplit _mpinterl = RooFit::BulkPartition; ///< Use interleaving strategy rather than N-wise split for partitioning of dataset for multiprocessor-split
183 bool _doOffset = false; ///< Apply interval value offset to control numeric precision?
184 const bool _takeGlobalObservablesFromData = false; ///< If the global observable values are taken from data
185 mutable ROOT::Math::KahanSum<double> _offset {0.0}; ///<! Offset as KahanSum to avoid loss of precision
186 mutable double _evalCarry = 0.0; ///<! carry of Kahan sum in evaluatePartition
187
188 ClassDefOverride(RooAbsTestStatistic,0) // Abstract base class for real-valued test statistics
189
190#ifndef ROOFIT_BUILDS_ITSELF
191} R__DEPRECATED(6,34, "RooAbsTestStatistic is a RooFit implementation detail that should not be instantiated in user code.");
192#else
193};
194#endif
195
196#endif
#define R__DEPRECATED(MAJOR, MINOR, REASON)
Definition RConfig.hxx:521
RooAbsData * pRooAbsData
RooRealMPFE * pRooRealMPFE
int Int_t
Definition RtypesCore.h:45
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition TGX11.cxx:110
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
Definition Util.h:122
T Sum() const
Definition Util.h:240
T Carry() const
Definition Util.h:250
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 objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
Abstract base class for all test statistics.
Int_t _setNum
Partition number of this instance in parallel calculation mode.
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
virtual bool processEmptyDataSets() const
double _evalCarry
! carry of Kahan sum in evaluatePartition
std::string _addCoefRangeName
Name of reference to be used for RooAddPdf components.
Int_t _nEvents
Total number of events in test statistic calculation.
GOFOpMode operMode() const
Int_t _nCPU
Number of processors to use in parallel calculation mode.
RooSetProxy _paramSet
Parameters of the test statistic (=parameters of the input function)
virtual double globalNormalization() const
RooAbsReal * _func
Pointer to original input function.
bool setData(RooAbsData &data, bool cloneData=true) override
Change dataset that is used to given one.
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.
Int_t _numSets
Total number of partitions in parallel calculation mode.
RooFit::MPSplit _mpinterl
Use interleaving strategy rather than N-wise split for partitioning of dataset for multiprocessor-spl...
bool isOffsetting() const override
double evaluate() const override
Calculate and return value of test statistic.
GOFOpMode _gofOpMode
Operation mode of test statistic instance.
virtual bool setDataSlave(RooAbsData &, bool=true, bool=false)
void initMPMode(RooAbsReal *real, RooAbsData *data, const RooArgSet *projDeps, std::string const &rangeName, std::string const &addCoefRangeName)
Initialize multi-processor calculation mode.
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.
bool _init
! Is object initialized
Int_t _simCount
Total number of component p.d.f.s in RooSimultaneous (if any)
ROOT::Math::KahanSum< double > _offset
! Offset as KahanSum to avoid loss of precision
virtual void runRecalculateCache(std::size_t, std::size_t, std::size_t) const
void setSimCount(Int_t simCount)
Int_t _extSet
! Number of designated set to calculated extended term
void setEventCount(Int_t nEvents)
double offset() const override
std::vector< std::unique_ptr< RooAbsTestStatistic > > _gofArray
! Array of sub-contexts representing part of the combined test statistic
bool initialize()
One-time initialization of the test statistic.
virtual double offsetCarry() const
const RooArgSet * _projDeps
Pointer to set with projected observables.
void initSimMode(RooSimultaneous *pdf, RooAbsData *data, const RooArgSet *projDeps, std::string const &rangeName, std::string const &addCoefRangeName)
Initialize simultaneous p.d.f processing mode.
~RooAbsTestStatistic() override
Destructor.
virtual double getCarry() const
bool _verbose
Verbose messaging if true.
void enableOffsetting(bool flag) override
virtual double evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const =0
bool _splitRange
Split rangeName in RooSimultaneous index labels if true.
virtual double combinedValue(RooAbsReal **gofArray, Int_t nVal) const =0
pRooRealMPFE * _mpfeArray
! Array of parallel execution frond ends
bool _doOffset
Apply interval value offset to control numeric precision?
RooAbsData * _data
Pointer to original input dataset.
const bool _takeGlobalObservablesFromData
If the global observable values are taken from data.
void setMPSet(Int_t setNum, Int_t numSets)
Set MultiProcessor set number identification of this instance.
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.
Definition RooArgSet.h:55
Multi-processor front-end for parallel calculation of RooAbsReal objects.
Definition RooRealMPFE.h:29
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
@ BulkPartition
std::string rangeName
Stores the configuration parameters for RooAbsTestStatistic.